mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
Compare commits
873 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e145e2ce6a | |||
| 2398ca1962 | |||
| 9eb91574c3 | |||
| 2edfd1febc | |||
| 4789bfab42 | |||
| f59bdf812a | |||
| 384de674c0 | |||
| fa0fe2a952 | |||
| 8ba2a6852b | |||
| 501784aba1 | |||
| 755e8dd222 | |||
| 24ce443e95 | |||
| 439ae5113d | |||
| 5774cb78c9 | |||
| 27e3f1d1bc | |||
| 301466f944 | |||
| 469867e98c | |||
| 9ca59f7928 | |||
| b3258e017c | |||
| 1da045f58e | |||
| 3c4b4b6a58 | |||
| 455d154b63 | |||
| a2f70be7e4 | |||
| 41a10320f8 | |||
| 772fe616ff | |||
| a9d0f177da | |||
| 35043ad0ec | |||
| 9dbb5291f4 | |||
| dbf5935897 | |||
| c754291c6d | |||
| 317796c919 | |||
| be412abebc | |||
| 2fc0827d49 | |||
| 90931232d9 | |||
| 427a301d1a | |||
| f66c3466ed | |||
| b184cee975 | |||
| 419f608322 | |||
| 5d70f72cc2 | |||
| 5057b2d761 | |||
| 3b20f5e45c | |||
| 2d3643d1f0 | |||
| effad6f62d | |||
| 958c897467 | |||
| e6eea06900 | |||
| f499110bbf | |||
| d0281bb3b4 | |||
| 91174ca974 | |||
| 79ea8c4521 | |||
| 7c85e981f9 | |||
| 363a014298 | |||
| d6966b24fe | |||
| 27c312d7d3 | |||
| b2dbe65739 | |||
| 555e74b8cd | |||
| 6bc58c00b7 | |||
| d9f5646ad1 | |||
| 888e3878bd | |||
| 493405951d | |||
| 0e39cfd4e3 | |||
| fda03b88df | |||
| f74ccb0513 | |||
| 6076d59c4b | |||
| d03678e3dc | |||
| ec6efc5c2b | |||
| f2be396e7a | |||
| 0c4d1afded | |||
| 67a48c6f75 | |||
| 7fb7263424 | |||
| e5e4bb2ea1 | |||
| fc8c748bc4 | |||
| eb308b78ef | |||
| 6168a6b806 | |||
| d07f19d893 | |||
| bff5d4ffbe | |||
| 4dc698a6be | |||
| 3963358d95 | |||
| a2f9fba896 | |||
| 97b171176a | |||
| a594ddeb75 | |||
| ebd5aebd33 | |||
| f771b54f10 | |||
| 67398607d8 | |||
| d33163aae8 | |||
| 2c6212f75f | |||
| 30396b3f0e | |||
| 336cfa8667 | |||
| 8a9e040554 | |||
| 2bd578edb3 | |||
| 308412b5a3 | |||
| e24c610bf1 | |||
| 2e3576b06e | |||
| 98f335ec00 | |||
| 50a96b3e4f | |||
| 5d169e188a | |||
| 4fc61c342c | |||
| f8f352fe65 | |||
| a988ff20c8 | |||
| 6fb050fa58 | |||
| f9a41b9685 | |||
| e5217afc09 | |||
| 3d07aa3bd0 | |||
| 761ec96662 | |||
| ed69d3a061 | |||
| db8e2bfb69 | |||
| 307ee8fb56 | |||
| d025359f72 | |||
| 9ac9ab6818 | |||
| a45fd217d9 | |||
| d3025dc4a8 | |||
| 38e1308865 | |||
| 054e59a891 | |||
| 097a507c9a | |||
| 47ddebf7c4 | |||
| d19a47d4b2 | |||
| fea7ed8f76 | |||
| 0a150a60bb | |||
| 781b4b31cd | |||
| fe7b05cce2 | |||
| 20ed9ffc41 | |||
| c378ec4347 | |||
| 7e302adf53 | |||
| 02c12c6a54 | |||
| d57bd7d7ba | |||
| 59e501e52b | |||
| 8b1ade86ac | |||
| ffabd681c8 | |||
| f1a2ef25c7 | |||
| b54449012b | |||
| 0f75b269c3 | |||
| 8fbd680ebd | |||
| dad5127d4c | |||
| ac29247783 | |||
| 59314ae0aa | |||
| 24d74dd332 | |||
| 0621073f8d | |||
| 1fc7f9d3e8 | |||
| e89677c36d | |||
| 4b7e445a25 | |||
| 911eb66c4a | |||
| 428a56cfd0 | |||
| 9af8117749 | |||
| baa7417c22 | |||
| 6dd779b421 | |||
| b3e105908b | |||
| f87277e1f2 | |||
| 749b29a239 | |||
| 942e8a9229 | |||
| 09a0536921 | |||
| 21e69c6d94 | |||
| 07400e7551 | |||
| e6676e8868 | |||
| 9b034a6753 | |||
| ee78a94aa2 | |||
| 34db041ac4 | |||
| 7abe95ba5f | |||
| 50b15b9506 | |||
| 235a8a73e9 | |||
| a728d20b70 | |||
| a78976b136 | |||
| 437fd64a6f | |||
| b0821be465 | |||
| a555067c43 | |||
| 90162ed2c9 | |||
| 9dc421e789 | |||
| 9bec0c61de | |||
| d301a66f57 | |||
| 3213c051b3 | |||
| 6f0e46ac57 | |||
| f2180257c5 | |||
| 96b8d49ef2 | |||
| 0be45703b5 | |||
| e548e17776 | |||
| c9471c344d | |||
| 085ca2a16d | |||
| 009360a127 | |||
| 3d27c68dee | |||
| 10444e31ce | |||
| 8492a0aa13 | |||
| 6f216dbe52 | |||
| 49bd14496a | |||
| 414a0d7d6e | |||
| b423fff074 | |||
| 96b9571ee1 | |||
| 25d6d9b59e | |||
| 1a4f04cb81 | |||
| dd23bc26a2 | |||
| 8a637f3fa9 | |||
| d0f3cee7de | |||
| e6684a0116 | |||
| f2b81ea68c | |||
| e81856afb9 | |||
| 88b5fbc4c9 | |||
| f1d1c3cbfd | |||
| 6680e9b882 | |||
| 31a21954d9 | |||
| fbcd1bd7de | |||
| d4db49e09e | |||
| 32a20f4783 | |||
| 57e4f585fe | |||
| 916cecca73 | |||
| d286c3784d | |||
| dec08f5eb1 | |||
| 0534ab4ac2 | |||
| e1b179a248 | |||
| 5ab9acfe89 | |||
| 3809e6f994 | |||
| 60fc774ade | |||
| 7250154748 | |||
| df6f4a07d6 | |||
| a3377a77fa | |||
| abc74b09b3 | |||
| 7f0373e0e9 | |||
| df39272544 | |||
| 70dff47f26 | |||
| e42e015410 | |||
| 93b301ee08 | |||
| d9cba6bf5c | |||
| 7498b327d4 | |||
| d12f3dd846 | |||
| 7a5bec077f | |||
| 4b97e33e20 | |||
| 0ee57e488d | |||
| 0df9385f33 | |||
| fe4b5bf582 | |||
| 31abd39ba8 | |||
| 4075245dcb | |||
| dcb001e0d9 | |||
| de41668e71 | |||
| 9a4061910a | |||
| 7db059b910 | |||
| 605ecb164a | |||
| f4376d44a2 | |||
| 5c4c3872f0 | |||
| 69b88b35b9 | |||
| 3514b02960 | |||
| b171959920 | |||
| e38e45c283 | |||
| f55b5120ff | |||
| 7a8d2986af | |||
| b62634242a | |||
| 965e23dba7 | |||
| 6475eb838e | |||
| 287d44f64a | |||
| f064a29efc | |||
| 6dd1dc62bf | |||
| fcacd2a660 | |||
| 8c9ed2c52c | |||
| 36aab1b579 | |||
| 3c50ffd945 | |||
| 7031a4d9c4 | |||
| 043d876642 | |||
| 8860969649 | |||
| b8601bac51 | |||
| bf1f0428ea | |||
| f49161420d | |||
| 58403ff00e | |||
| 5043f00c97 | |||
| 0a457c4bac | |||
| 780dce293d | |||
| 5dbeea80df | |||
| 9af7ec3ff5 | |||
| af127d666d | |||
| eb12b35e37 | |||
| 19775fac3f | |||
| 0bb5cb1fdc | |||
| 78471a2c3a | |||
| 464dbba457 | |||
| 9d455c35d0 | |||
| 3f84024ce8 | |||
| e9ae046592 | |||
| 16ab9998b0 | |||
| ce7b368a8e | |||
| 4c862932e8 | |||
| 8a88aa2128 | |||
| 3706b0f972 | |||
| 115151473a | |||
| a23b133217 | |||
| a728bec15f | |||
| 1139b251ef | |||
| 8c3b85066a | |||
| 0b48e94d3c | |||
| f2ca9f765f | |||
| 46ea054bac | |||
| 03205674aa | |||
| eead73f10c | |||
| a930247eec | |||
| 108045ac54 | |||
| cccf85f3d9 | |||
| e79a70fc2f | |||
| 8b254b3967 | |||
| c4ef0f998c | |||
| 37fb9dd851 | |||
| 2a537df687 | |||
| 1a8a7cc260 | |||
| 4d48dfe018 | |||
| 4e053a4769 | |||
| dd0bdddbc6 | |||
| f5286ae66b | |||
| 6b4e8df411 | |||
| 18a6262eaf | |||
| 8fa395a582 | |||
| 834d03459b | |||
| 534faef82c | |||
| 5658e7a0b4 | |||
| b784ad6b26 | |||
| 32e1e487a9 | |||
| 7f32cca476 | |||
| e8fe3c2eff | |||
| 7cf89392a2 | |||
| c8f0bdd6d7 | |||
| c679e12d16 | |||
| 2144982829 | |||
| 580f063efe | |||
| 3a16c4ebf3 | |||
| ac04629f86 | |||
| 10cd655b67 | |||
| 77d7417132 | |||
| 6cca4d2daa | |||
| f1605011dd | |||
| cb617463ed | |||
| e4abc745c8 | |||
| 155d2f9651 | |||
| 453f93aba6 | |||
| d2611ac0a5 | |||
| 7bf109298b | |||
| b56e8c5f9f | |||
| e78598900a | |||
| 823579dc59 | |||
| 58005d1832 | |||
| 9c53a7a75b | |||
| 1f36a08f05 | |||
| 631a552708 | |||
| d6be83b48c | |||
| ea9c35a64b | |||
| 04c006a733 | |||
| aff1f9126f | |||
| a8acf91980 | |||
| fb77ab67e7 | |||
| d3a277f9fb | |||
| 0aa53f64ff | |||
| 29a920b1ce | |||
| 0729f2ed1a | |||
| 3e0c15e18f | |||
| f276435750 | |||
| d600a6d2c3 | |||
| b5dbb8a16a | |||
| 538c2e09ce | |||
| 752632456c | |||
| 9220e1f85f | |||
| 1036c97be7 | |||
| 521423a343 | |||
| 04c5ccc891 | |||
| e05fa0f4d8 | |||
| c3278ad30f | |||
| e4326e00e4 | |||
| 93d0f88b0d | |||
| 1c385d22cd | |||
| 24786c6ae6 | |||
| 0e5d4b30ed | |||
| 4e233f760d | |||
| fd2474cc38 | |||
| 20eee62c19 | |||
| 182e370086 | |||
| ee2c937cbf | |||
| 2f65e6a801 | |||
| ad440e12b5 | |||
| f469f7aea9 | |||
| eb327c3adc | |||
| 1e56707e5a | |||
| 6816a300f6 | |||
| 0b8191a435 | |||
| f8d8a44a3c | |||
| cd0eacf947 | |||
| dd47cd2a7c | |||
| d8460923ca | |||
| 2e06633972 | |||
| a4b77fc43f | |||
| 5b193e89c0 | |||
| b7dff7d2c3 | |||
| bef53dadb1 | |||
| f943ae7566 | |||
| f1547b069d | |||
| ac7dc1599c | |||
| 46b7dc1ce7 | |||
| 0b24e1098a | |||
| fe69c0a578 | |||
| accb8f7f82 | |||
| 2d61dea287 | |||
| cd8fffd2f7 | |||
| 125a2da9b3 | |||
| 884d930e71 | |||
| 49045c06af | |||
| 48d36cc859 | |||
| 8c4d00b8ef | |||
| 7b148b1a39 | |||
| 0cbb8997e2 | |||
| 3b3191c407 | |||
| 512002c0e8 | |||
| 9652f48044 | |||
| 9a3a72deb0 | |||
| b477d814c6 | |||
| 0c44a497a5 | |||
| 9454bde14a | |||
| 5d8df75e86 | |||
| a924c9d2bb | |||
| 0c8d4d830f | |||
| 0a4d89543a | |||
| f218174ad3 | |||
| dccf845e3b | |||
| fb4997b1ac | |||
| 5453579c7b | |||
| d8ba92e343 | |||
| dd138380c9 | |||
| d020537679 | |||
| 259a3c218a | |||
| d5e8227918 | |||
| 69abf1e9e2 | |||
| 21fb679c08 | |||
| 3d1f81a721 | |||
| 471e2e7b86 | |||
| 8cba0aec5a | |||
| 7541770fbb | |||
| ae4c06f481 | |||
| 84013e42e7 | |||
| aab198e355 | |||
| 5eafa6b5f4 | |||
| b52ea08013 | |||
| e20bebad87 | |||
| 1993e20ffc | |||
| 559a6b317d | |||
| 66a80697c2 | |||
| 6d97a9e9aa | |||
| 9cade51ff4 | |||
| 17512e60b2 | |||
| 706dad6df6 | |||
| 1f45ddc17d | |||
| 3ef5528196 | |||
| e915671a02 | |||
| f2a2469e6e | |||
| 4c671c2ee9 | |||
| c4c17f69c7 | |||
| 1f4b029973 | |||
| 33267de4be | |||
| 141b1523e1 | |||
| 8a0d2a2f10 | |||
| 6d728ae0e7 | |||
| 58f52dfaae | |||
| 5643607845 | |||
| a0284c313a | |||
| 93b111af93 | |||
| 6a8a96b748 | |||
| d1b813b1cc | |||
| 69b0b3601d | |||
| 8663d86f7a | |||
| 40c0393bc0 | |||
| c6193530db | |||
| ce72294273 | |||
| 12e06776be | |||
| 3a3d28e9e6 | |||
| 3b8776f947 | |||
| 23255ed84f | |||
| a3b5996c50 | |||
| 9d0e63e695 | |||
| a606add6eb | |||
| fe06b2360e | |||
| c8009a8a6c | |||
| c2ffd02907 | |||
| 0536deda1a | |||
| 18dabf26e4 | |||
| 7bb98479dd | |||
| b5c830ed35 | |||
| 8e56b404b9 | |||
| e4ee83c590 | |||
| ef5040557d | |||
| bc7fa71894 | |||
| 8999b59f4e | |||
| 81612da80c | |||
| 47130b48ec | |||
| 1b35b95173 | |||
| 2ea3597a10 | |||
| 08dd6a7783 | |||
| d55cb56a1a | |||
| 8bac75ae52 | |||
| 7944ce091e | |||
| 4f4df8a8b7 | |||
| 912b018e32 | |||
| ab8b46203e | |||
| 1a6c107f0b | |||
| e3ff62001b | |||
| f47f8d5da4 | |||
| 3b06519f2f | |||
| c15a350392 | |||
| b1e85fe92b | |||
| 1b19a0821f | |||
| c33a11e952 | |||
| 844c07be9c | |||
| 5175dcdbe4 | |||
| 5e3a7d4307 | |||
| ab978592a0 | |||
| fd0fb7c9b4 | |||
| 28ab904144 | |||
| 0655118f2b | |||
| 8d61025afa | |||
| a65336993c | |||
| 412bb10a06 | |||
| 6025660e23 | |||
| ed59de7e80 | |||
| c90b875aa2 | |||
| eda68ef5e0 | |||
| 3a4492671d | |||
| b2deea6962 | |||
| 9da2854e61 | |||
| 6211a77119 | |||
| 2f08d1b1c1 | |||
| 006a763436 | |||
| e15f4981fb | |||
| 8a115626ba | |||
| 20aba9aa90 | |||
| 63d7716a6c | |||
| b51ce13024 | |||
| 8057ecbc60 | |||
| 69067c1ef9 | |||
| efebaeeb27 | |||
| 8705341563 | |||
| e32bf2df57 | |||
| 44d60e5f52 | |||
| 10a6d374f1 | |||
| 054ef5d00f | |||
| 1fb019b795 | |||
| e0c7691e04 | |||
| c03e6deb95 | |||
| 941dce6032 | |||
| 94224f7ef7 | |||
| f51f006377 | |||
| 487a2b6037 | |||
| 637392c844 | |||
| e11dd21a1e | |||
| 675ce0e9aa | |||
| aed3f99365 | |||
| 1a1cd76bc4 | |||
| a9818e1f63 | |||
| 56900e31db | |||
| 456700a06e | |||
| d63c7c3457 | |||
| e41eada893 | |||
| a32e78c9b8 | |||
| 1d0c2be449 | |||
| bdb0a5702d | |||
| 026a276c02 | |||
| 3b41df5ddc | |||
| 8a9477eaf0 | |||
| ee6221e325 | |||
| f2ba0fd469 | |||
| 53e44b9df5 | |||
| 257c7a5aac | |||
| a5daa63da4 | |||
| 753a193be1 | |||
| 2132fe76ae | |||
| cfe73b361e | |||
| a2791fecd1 | |||
| d2a8d59f6d | |||
| 9907ee2267 | |||
| 2951b2a0d1 | |||
| 5cabac62d7 | |||
| 61af95b7e5 | |||
| ab3c631030 | |||
| 2d88ee031c | |||
| 8ffc8a20d3 | |||
| d34ce78c94 | |||
| c6f4fbb0b8 | |||
| b1c094383f | |||
| 46fff01eaa | |||
| 24641d1444 | |||
| abfd92e387 | |||
| ba1fa6add4 | |||
| 8d8e45b6de | |||
| 05516f2952 | |||
| d34f5b92f4 | |||
| 3023cd2e94 | |||
| 65c7db7ae4 | |||
| b907f01ebb | |||
| 1b3c052c12 | |||
| 9038910303 | |||
| 06b0529813 | |||
| c4942cc70e | |||
| 27715c7f5f | |||
| 1b4a2f2d7a | |||
| bc798bd0b4 | |||
| f6eceb892d | |||
| 6eae83f4eb | |||
| 842e62b0dd | |||
| 10e57dae2d | |||
| 69803cdb0d | |||
| 426a439552 | |||
| 4e6b7a845b | |||
| 30efd55d6c | |||
| a495ff9b98 | |||
| 54b2dce3d6 | |||
| 8f0e837fb7 | |||
| b147f73954 | |||
| e5a0dcb829 | |||
| 4f8d620814 | |||
| ac508a9f19 | |||
| e32c68e0e3 | |||
| 9ae3a6dc29 | |||
| 87384f42f9 | |||
| e28627a676 | |||
| 874f08f6dd | |||
| 77ebf1d857 | |||
| 1a39abf7c7 | |||
| a49075bcb7 | |||
| 6acf65b49f | |||
| 40c98b1dcc | |||
| b359a77a8d | |||
| d259c0d35c | |||
| 011b4a83eb | |||
| 85f9b14326 | |||
| 5f77bdd6fc | |||
| d2eadb98ce | |||
| 291f32bfe2 | |||
| 3a9f6a0edd | |||
| f539ed8977 | |||
| 20619311e3 | |||
| 4ac46d19e9 | |||
| dad459e023 | |||
| 8f6fbda4cf | |||
| b6723e92d8 | |||
| 1344ab987e | |||
| 1dcece8563 | |||
| f2ebf25640 | |||
| f6427f57b8 | |||
| 68459e086a | |||
| 03e166dc89 | |||
| 0940ea77de | |||
| 872ef7c31c | |||
| e89aa824d2 | |||
| 1b65378d6c | |||
| 77666e5210 | |||
| fdbbba5038 | |||
| 5b795c2ccf | |||
| 7bec7016c3 | |||
| aadaa3f2a3 | |||
| 7f735e9a10 | |||
| 91c01f36f4 | |||
| 35bf6a2efd | |||
| 861f8a7288 | |||
| caac612a0d | |||
| a7f1e43225 | |||
| b98794a292 | |||
| c60f7ed8b0 | |||
| 7a6d095b78 | |||
| 77e31f2da6 | |||
| 88df5057fb | |||
| 843ddad987 | |||
| 6a5b2db79d | |||
| 8f81426fa4 | |||
| 6140e15139 | |||
| acb29c5c69 | |||
| 91f43665fd | |||
| 7ec24bfc7b | |||
| f4197f090b | |||
| 824423f3ea | |||
| a21a5ce044 | |||
| 898f40e8a5 | |||
| c5f69d0e44 | |||
| 9d6159c202 | |||
| d56dbdf563 | |||
| 1ddf5a8370 | |||
| 23853e4a19 | |||
| 2fcbbcac84 | |||
| 7e14fff7f3 | |||
| ed71077243 | |||
| b99b09ca6a | |||
| b7fa6b2072 | |||
| e824d48edf | |||
| c49a36e9ca | |||
| 4653e070b1 | |||
| b8c885c8a4 | |||
| 2f5d93daa2 | |||
| e513550cba | |||
| 4bd430ae79 | |||
| 72bde46ca6 | |||
| 33a93457ec | |||
| 3e912f9545 | |||
| 7861829ee4 | |||
| 604bfeea20 | |||
| dc973217b7 | |||
| bc71415dd5 | |||
| 98c877e9ea | |||
| 0512295b8b | |||
| b9329aa417 | |||
| bd4bbe0b7a | |||
| 0c0d529478 | |||
| f17591327d | |||
| 5c9e1b3fd3 | |||
| 8762e87658 | |||
| abb9885b3b | |||
| 22f6e3fe3b | |||
| 364c3f0518 | |||
| dc5368f346 | |||
| af010a51e9 | |||
| 28fe3ef839 | |||
| 09c02b0906 | |||
| 70d7496ed9 | |||
| 20edb299a7 | |||
| 61616fbaef | |||
| 579c1c6aff | |||
| 8d8c25bd6e | |||
| 4526c10d30 | |||
| ef6634a38e | |||
| db6e1add8a | |||
| 751c1fd31e | |||
| 7ef88fcc02 | |||
| 284351a024 | |||
| a3f9e19bd6 | |||
| d99e260b47 | |||
| 83335d6d30 | |||
| ff6f23b3f4 | |||
| c7e008b615 | |||
| ef91489b29 | |||
| b070607f91 | |||
| b4505536f6 | |||
| 9a81111ebc | |||
| b5bbf89b7d | |||
| 49c2911557 | |||
| b07d9a9a63 | |||
| c2fb582db0 | |||
| cbd7566e3c | |||
| 7dbf29d655 | |||
| 4503e0db71 | |||
| 787d479a33 | |||
| a2f944ff92 | |||
| 2db669ca2e | |||
| e7703f3c9b | |||
| 4b5e784081 | |||
| f479e7ff62 | |||
| c7ee0ce82b | |||
| d38ed229bf | |||
| 5d4ec93b09 | |||
| b6adf1ad53 | |||
| 7c29a726f2 | |||
| 798469dfcc | |||
| 0b97a92ae9 | |||
| 6fa680d19f | |||
| 8a29146fc2 | |||
| 44cc6a3a83 | |||
| 9c2ece2bda | |||
| 4fb8bdd5d9 | |||
| 4ba828d0e8 | |||
| da9002356c | |||
| a105143771 | |||
| 776908792a | |||
| 4e73b40a84 | |||
| c0252e5ad9 | |||
| 9ac31f3925 | |||
| 6f3335cc3d | |||
| a8b4e2b399 | |||
| dd2867a23d | |||
| 5d7370e4af | |||
| d0779eadf9 | |||
| a0635840b7 | |||
| 74f9ac7600 | |||
| 7a3bb2a374 | |||
| 27e2286096 | |||
| 9f336b4590 | |||
| 1d9899d830 | |||
| d105ea7a56 | |||
| a32cda96d0 | |||
| 3674315305 | |||
| f7d1f459ca | |||
| cc52a9a28b | |||
| 92fdf3da4c | |||
| 364217c36d | |||
| 4158a66da4 | |||
| 9c73908733 | |||
| b684c6a34d | |||
| 4502eefaae | |||
| 9fdef54efc | |||
| dc76ae8506 | |||
| c65fc571ac | |||
| a4b24880f6 | |||
| 219113bc73 | |||
| 52d406bca7 | |||
| 81b080ec41 | |||
| 94fe3b594d | |||
| 45715d78f7 | |||
| 818a93ab2c | |||
| 29600f1059 | |||
| bd9f3abfea | |||
| 562b8b000f | |||
| be7321723a | |||
| c494dd1cdc | |||
| 5a002c0f04 | |||
| aacba9f6ae | |||
| 6d8606795f | |||
| fbb00be7cd | |||
| c6d82fe029 | |||
| 6b2150b066 | |||
| 8c7bbff1c1 | |||
| e34bacb443 | |||
| 007ee49844 | |||
| bae7096ca1 | |||
| 22453c71b4 | |||
| d57fd9eb60 | |||
| b01cd99a93 | |||
| 645972d549 | |||
| c0b4ad2633 | |||
| 0f80b9d31b | |||
| 65bf35fa3e | |||
| 697b1e5c00 | |||
| c744d48aef | |||
| 93ef1151df | |||
| c74d22d46c | |||
| 1e449e6fd1 | |||
| af678b3c56 | |||
| 39ed309dd5 | |||
| e28261f4f6 | |||
| 484a48e309 | |||
| d1377b3f4e | |||
| fa74438f66 | |||
| 2a0a0a81f2 | |||
| 468d334530 | |||
| 41ff430464 | |||
| 9eeaeb2a14 | |||
| 4e11e12c99 | |||
| fa3a718ad4 | |||
| bd92777b96 | |||
| 1009f73109 | |||
| 13f71502e6 | |||
| 34c84d00da | |||
| e1c23fc6fa | |||
| b7a3d2dcb4 | |||
| 49e4aa78e9 | |||
| 4a2cdaf52a | |||
| 56230e3752 | |||
| 4e17be39f6 | |||
| 2f001987f3 | |||
| 553f2feaa4 | |||
| b70011436e | |||
| 44182af5fa | |||
| 1aae75312e | |||
| d88ff104a3 | |||
| 073cd6cb23 | |||
| 1416e91af7 | |||
| 533291bf33 | |||
| 0d690b60b6 | |||
| 539efcb6ec | |||
| ddf72af139 | |||
| 06b929381d | |||
| fc147f577a | |||
| 388400338e | |||
| 71e86cfcde | |||
| 7356b17688 | |||
| f0d0c0837a | |||
| e26ba1d219 | |||
| afebd44b78 | |||
| f1402c439c | |||
| 9d8adaba26 | |||
| 1165f4407e | |||
| 7a554b0d0c | |||
| 345cc6cf83 | |||
| eee4faa241 | |||
| 83896113d8 | |||
| 75f8c4e909 | |||
| c3ff32a9d6 | |||
| 592fd7ac10 | |||
| d7897d7129 | |||
| d2e0f34d9e | |||
| bdee476a74 | |||
| 9dbf59d1a1 | |||
| a4378b4592 | |||
| 4101929cd5 |
@@ -21,3 +21,6 @@ $config['grades_blocking_application'] = array(
|
||||
$config['fbl'] = FALSE;
|
||||
//Enables Info Mails
|
||||
$config['send_mail'] = TRUE;
|
||||
|
||||
// Display fields to explain equivalence of ECTS and LV-Inhalte
|
||||
$config['explain_equivalence'] = TRUE;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2023 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
$config['migratecontract_oe_default'] = 'TODO_OE_DEFAULT';
|
||||
|
||||
$config['migratecontract_matching_ba1_vertragsart'] = array(
|
||||
'101'=>'dvbund',
|
||||
'102'=>'dvanderengk',
|
||||
'103'=>'echterdv',
|
||||
'104'=>'studentischehilfskr',
|
||||
'105'=>'externerlehrender',
|
||||
'106'=>'dvanderenbet',
|
||||
'107'=>'werkvertrag',
|
||||
'108'=>'studentischehilfskr',
|
||||
'109'=>'ueberlassungsvertrag',
|
||||
'110'=>'echterfreier',
|
||||
'111'=>'echterdv' //All-In
|
||||
);
|
||||
@@ -55,6 +55,12 @@ $config['navigation_header'] = array(
|
||||
'description' => 'CIS',
|
||||
'sort' => 10
|
||||
),
|
||||
'lehrveranstaltungen' => array(
|
||||
'link' => site_url('lehre/lvplanung/LvTemplateUebersicht'),
|
||||
'icon' => '',
|
||||
'description' => 'Lehrveranstaltungen',
|
||||
'sort' => 15
|
||||
),
|
||||
'reihungstest' => array(
|
||||
'link' => site_url('organisation/Reihungstest'),
|
||||
'description' => 'Reihungstests',
|
||||
@@ -287,6 +293,15 @@ $config['navigation_menu']['lehre/lehrauftrag/LehrauftragErteilen/*'] = array(
|
||||
)
|
||||
);
|
||||
|
||||
$config['navigation_menu']['lehre/lvplanung/LvTemplateUebersicht/index'] = array(
|
||||
'lvTemplateUebersicht' => array(
|
||||
'link' => site_url('lehre/lvplanung/LvTemplateUebersicht'),
|
||||
'description' => 'LV Template Übersicht',
|
||||
'icon' => '',
|
||||
'sort' => 1
|
||||
)
|
||||
);
|
||||
|
||||
$config['navigation_menu']['system/issues/Issues/*'] = array(
|
||||
'fehlerzustaendigkeiten' => array(
|
||||
'link' => site_url('system/issues/IssuesZustaendigkeiten'),
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Studentenverwaltung extends Auth_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$permissions = [];
|
||||
$router = load_class('Router');
|
||||
$permissions[$router->method] = ['admin:r', 'assistenz:r'];
|
||||
parent::__construct($permissions);
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function _remap()
|
||||
{
|
||||
$this->load->view('Studentenverwaltung', [
|
||||
'permissions' => [
|
||||
'student/bpk' => $this->permissionlib->isBerechtigt('student/bpk'),
|
||||
'student/alias' => $this->permissionlib->isBerechtigt('student/alias'),
|
||||
'basis/prestudent' => $this->permissionlib->isBerechtigt('basis/prestudent'),
|
||||
'basis/prestudentstatus' => $this->permissionlib->isBerechtigt('basis/prestudentstatus'),
|
||||
'assistenz_stgs' => $this->permissionlib->getSTG_isEntitledFor('assistenz'),
|
||||
'admin' => $this->permissionlib->isBerechtigt('admin'),
|
||||
'assistenz_schreibrechte' => $this->permissionlib->isBerechtigt('assistenz','suid'),
|
||||
'student/keine_studstatuspruefung' => $this->permissionlib->isBerechtigt('student/keine_studstatuspruefung'),
|
||||
'lehre/reihungstestAufsicht' => $this->permissionlib->isBerechtigt('lehre/reihungstestAufsicht')
|
||||
],
|
||||
'variables' => [
|
||||
'semester_aktuell' => $this->variablelib->getVar('semester_aktuell')
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (FAS) and the AntragLib (back-end)
|
||||
* This controller works with calls on the HTTP GET or POST and the output is always RDF
|
||||
*/
|
||||
class Wiederholung extends Auth_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Calls the parent's constructor and loads the FilterCmptLib
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getLvs' => ['student/studierendenantrag:r', 'student/noten:r'],
|
||||
'moveLvsToZeugnis' => ['student/studierendenantrag:w', 'student/noten:w']
|
||||
]);
|
||||
|
||||
// Libraries
|
||||
$this->load->library('AntragLib');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'global',
|
||||
'studierendenantrag'
|
||||
]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
public function getLvs($prestudent_id)
|
||||
{
|
||||
// header für no cache
|
||||
$this->output->set_header("Cache-Control: no-cache");
|
||||
$this->output->set_header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
$this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
$this->output->set_header("Pragma: no-cache");
|
||||
$this->output->set_header("Content-type: application/xhtml+xml");
|
||||
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$sem_akt = $this->variablelib->getVar('semester_aktuell');
|
||||
|
||||
|
||||
$result = $this->antraglib->getLvsForPrestudent($prestudent_id, $sem_akt);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$lvs = $result->retval;
|
||||
|
||||
$rdf_url = 'http://www.technikum-wien.at/antragnote';
|
||||
|
||||
$this->load->view('lehre/Antrag/Wiederholung/getLvs.rdf.php', [
|
||||
'url' => $rdf_url,
|
||||
'lvs' => $lvs
|
||||
]);
|
||||
}
|
||||
|
||||
public function moveLvsToZeugnis()
|
||||
{
|
||||
$anzahl = $this->input->post('anzahl');
|
||||
$student_uid = $this->input->post('student_uid');
|
||||
$this->load->model('education/Studierendenantraglehrveranstaltung_model', 'StudierendenantraglehrveranstaltungModel');
|
||||
$this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel');
|
||||
|
||||
$errormsg = array();
|
||||
|
||||
for($i=0; $i<$anzahl; $i++)
|
||||
{
|
||||
$id = $this->input->post('studierendenantrag_lehrveranstaltung_id_' . $i);
|
||||
$result =$this->StudierendenantraglehrveranstaltungModel->load($id);
|
||||
if(isError($result))
|
||||
{
|
||||
$errormsg[] = getError($result);
|
||||
}
|
||||
elseif(!hasData($result))
|
||||
{
|
||||
$errormsg[] = $this->p->t('studierendenantrag', 'error_no_lv_in_application');
|
||||
}
|
||||
else
|
||||
{
|
||||
$antragLv = getData($result)[0];
|
||||
$result= $this->ZeugnisnoteModel->load([
|
||||
'lehrveranstaltung_id'=> $antragLv->lehrveranstaltung_id,
|
||||
'student_uid'=> $student_uid,
|
||||
'studiensemester_kurzbz' => $antragLv->studiensemester_kurzbz
|
||||
]);
|
||||
if(isError($result))
|
||||
{
|
||||
$errormsg[] = getError($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hasData($result))
|
||||
{
|
||||
$result = $this->ZeugnisnoteModel->update(
|
||||
[
|
||||
'lehrveranstaltung_id'=> $antragLv->lehrveranstaltung_id,
|
||||
'student_uid'=> $student_uid,
|
||||
'studiensemester_kurzbz' => $antragLv->studiensemester_kurzbz
|
||||
],
|
||||
[
|
||||
'note'=> $antragLv->note,
|
||||
'uebernahmedatum' => date('c'),
|
||||
'benotungsdatum' => $antragLv->insertamum,
|
||||
'updateamum' => date('c'),
|
||||
'bemerkung'=>$antragLv->anmerkung,
|
||||
'updatevon'=>getAuthUID()
|
||||
]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->ZeugnisnoteModel->insert([
|
||||
'lehrveranstaltung_id'=> $antragLv->lehrveranstaltung_id,
|
||||
'student_uid'=> $student_uid,
|
||||
'studiensemester_kurzbz' => $antragLv->studiensemester_kurzbz,
|
||||
'note'=> $antragLv->note,
|
||||
'uebernahmedatum' => date('c'),
|
||||
'benotungsdatum' => $antragLv->insertamum,
|
||||
'insertamum' => date('c'),
|
||||
'bemerkung'=>$antragLv->anmerkung,
|
||||
'insertvon'=>getAuthUID()
|
||||
]);
|
||||
}
|
||||
if(isError($result))
|
||||
{
|
||||
$errormsg[] = getError($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($errormsg)
|
||||
$return = false;
|
||||
else
|
||||
$return = true;
|
||||
|
||||
$this->load->view('lehre/Antrag/Wiederholung/moveLvs.rdf.php', [
|
||||
'return' => $return,
|
||||
'errormsg' => $errormsg
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the FilterCmptLib (back-end)
|
||||
* Provides data to the ajax get calls about the filter component
|
||||
* Listens to ajax post calls to change the filter data
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Filter extends FHCAPI_Controller
|
||||
{
|
||||
const FILTER_UNIQUE_ID = 'filterUniqueId'; // Name of the filter cmpt unique id (mandatory)
|
||||
const FILTER_TYPE = 'filterType'; // The filter type (PHP filter definition) used (mandatory)
|
||||
const FILTER_ID = 'filterId'; // The id of the used filter (optional)
|
||||
|
||||
/**
|
||||
* Calls the parent's constructor and loads the FilterCmptLib
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// NOTE: FilterCmpt has its own permissions checks
|
||||
parent::__construct([
|
||||
'getFilter' => self::PERM_LOGGED,
|
||||
'removeFilterField' => self::PERM_LOGGED,
|
||||
'addFilterField' => self::PERM_LOGGED,
|
||||
'applyFilterFields' => self::PERM_LOGGED,
|
||||
'removeCustomFilter' => self::PERM_LOGGED,
|
||||
'saveCustomFilter' => self::PERM_LOGGED,
|
||||
'reloadDataset' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
// Loads the FiltersModel
|
||||
$this->load->model('system/Filters_model', 'FiltersModel');
|
||||
|
||||
// Loads the FilterCmptLib with HTTP GET/POST parameters
|
||||
$this->_startFilterCmptLib();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Retrieves data about the current filter from the session and will be written on the output in JSON format
|
||||
*/
|
||||
public function getFilter()
|
||||
{
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$session = $this->filtercmptlib->getSession();
|
||||
if (is_object($session)) {
|
||||
// If stdClass it is an retval object
|
||||
$session = $this->getDataOrTerminateWithError($session);
|
||||
}
|
||||
$this->terminateWithSuccess($session);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an applied filter (SQL where condition) from the current filter
|
||||
*/
|
||||
public function removeFilterField()
|
||||
{
|
||||
$this->form_validation->set_rules('filterField', 'filterField', 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$result = $this->filtercmptlib->removeFilterField($this->input->post('filterField'));
|
||||
|
||||
if (!$result)
|
||||
$this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->terminateWithSuccess('Field removed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a filter (SQL where clause) to be applied to the current filter
|
||||
*/
|
||||
public function addFilterField()
|
||||
{
|
||||
$this->form_validation->set_rules('filterField', 'filterField', 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$result = $this->filtercmptlib->addFilterField($this->input->post('filterField'));
|
||||
|
||||
if (!$result)
|
||||
$this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->terminateWithSuccess('Field added');
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the filter changes
|
||||
*/
|
||||
public function applyFilterFields()
|
||||
{
|
||||
$this->form_validation->set_rules('filterFields', 'filterFields', 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$result = $this->filtercmptlib->applyFilterFields($this->input->post('filterFields'));
|
||||
|
||||
if (!$result)
|
||||
$this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->terminateWithSuccess('Applied');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the current filter as a custom filter for this user with the given description
|
||||
*/
|
||||
public function saveCustomFilter()
|
||||
{
|
||||
$this->form_validation->set_rules('customFilterName', 'customFilterName', 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$result = $this->filtercmptlib->saveCustomFilter($this->input->post('customFilterName'));
|
||||
|
||||
if (!$result)
|
||||
$this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->terminateWithSuccess('Saved');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a custom filter by its filterId
|
||||
*/
|
||||
public function removeCustomFilter()
|
||||
{
|
||||
$this->form_validation->set_rules('filterId', 'filterId', 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$result = $this->filtercmptlib->removeCustomFilter($this->input->post('filterId'));
|
||||
|
||||
if (!$result)
|
||||
$this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->terminateWithSuccess('Removed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the dataset
|
||||
*/
|
||||
public function reloadDataset()
|
||||
{
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$this->filtercmptlib->reloadDataset();
|
||||
|
||||
$this->terminateWithSuccess('Success');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
/**
|
||||
* Loads the FilterCmptLib with the FILTER_UNIQUE_ID parameter
|
||||
* If the parameter FILTER_UNIQUE_ID is not given then the execution of the controller is terminated and
|
||||
* an error message is printed
|
||||
*/
|
||||
private function _startFilterCmptLib()
|
||||
{
|
||||
$filterUniqueId = null;
|
||||
$filterType = null;
|
||||
$filterId = null;
|
||||
|
||||
$validations = [
|
||||
[
|
||||
'field' => self::FILTER_UNIQUE_ID,
|
||||
'label' => self::FILTER_UNIQUE_ID,
|
||||
'rules' => 'required'
|
||||
],
|
||||
[
|
||||
'field' => self::FILTER_TYPE,
|
||||
'label' => self::FILTER_TYPE,
|
||||
'rules' => 'required'
|
||||
],
|
||||
];
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
if ($this->input->method() == 'get')
|
||||
$this->form_validation->set_data($this->input->get());
|
||||
$this->form_validation->set_rules($validations);
|
||||
|
||||
if ($this->form_validation->run()) {
|
||||
$filterUniqueId = $this->input->post_get(self::FILTER_UNIQUE_ID);
|
||||
$filterType = $this->input->post_get(self::FILTER_TYPE);
|
||||
$filterId = $this->input->post_get(self::FILTER_ID);
|
||||
|
||||
// Loads the FilterCmptLib that contains all the used logic
|
||||
$this->load->library(
|
||||
'FilterCmptLib',
|
||||
array(
|
||||
'filterUniqueId' => $filterUniqueId,
|
||||
'filterType' => $filterType,
|
||||
'filterId' => $filterId
|
||||
)
|
||||
);
|
||||
|
||||
// Start the component
|
||||
$this->filtercmptlib->start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the NavigationLib (back-end)
|
||||
* Provides data to the ajax get calls about the filter
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Navigation extends FHCAPI_Controller
|
||||
{
|
||||
const NAVIGATION_PAGE_PARAM = 'navigation_page'; // Navigation page parameter name
|
||||
|
||||
/**
|
||||
* Loads the NavigationLib where the used logic lies
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'menu' => self::PERM_LOGGED,
|
||||
'header' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
$this->_loadNavigationLib(); // Loads the NavigationLib with parameters
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* This function creates the left Menu for each Page
|
||||
* @param NAVIGATION_PAGE_PARAM GET Parameter witch holds the currently called Page
|
||||
* @return JSON object with the Menu Entries
|
||||
*/
|
||||
public function menu()
|
||||
{
|
||||
$menuArray = $this->navigationlib->getMenuArray($this->input->get(self::NAVIGATION_PAGE_PARAM));
|
||||
|
||||
$this->terminateWithSuccess($menuArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function creates the Top Menu for each Page
|
||||
* @param NAVIGATION_PAGE_PARAM GET Parameter witch holds the currently called Page
|
||||
* @return JSON object with the Menu Entries
|
||||
*/
|
||||
public function header()
|
||||
{
|
||||
$headerArray = $this->navigationlib->getHeaderArray($this->input->get(self::NAVIGATION_PAGE_PARAM));
|
||||
|
||||
$this->terminateWithSuccess($headerArray);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
/**
|
||||
* Loads the NavigationLib with the NAVIGATION_PAGE_PARAM parameter
|
||||
* If the parameter NAVIGATION_PAGE_PARAM is not given then the execution of the controller is terminated and
|
||||
* an error message is printed
|
||||
*/
|
||||
private function _loadNavigationLib()
|
||||
{
|
||||
// If the parameter NAVIGATION_PAGE_PARAM is present in the HTTP GET or POST
|
||||
if (isset($_GET[self::NAVIGATION_PAGE_PARAM]) || isset($_POST[self::NAVIGATION_PAGE_PARAM]))
|
||||
{
|
||||
// If it is present in the HTTP GET
|
||||
if (isset($_GET[self::NAVIGATION_PAGE_PARAM]))
|
||||
{
|
||||
$navigationPage = $this->input->get(self::NAVIGATION_PAGE_PARAM); // is retrieved from the HTTP GET
|
||||
}
|
||||
elseif (isset($_POST[self::NAVIGATION_PAGE_PARAM])) // Else if it is present in the HTTP POST
|
||||
{
|
||||
$navigationPage = $this->input->post(self::NAVIGATION_PAGE_PARAM); // is retrieved from the HTTP POST
|
||||
}
|
||||
|
||||
// Loads the NavigationLib that contains all the used logic
|
||||
$this->load->library('NavigationLib', array(self::NAVIGATION_PAGE_PARAM => $navigationPage));
|
||||
}
|
||||
else // Otherwise an error will be written in the output
|
||||
{
|
||||
show_error('Parameter "' . self::NAVIGATION_PAGE_PARAM . '" not provided!');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the PhrasesLib (back-end)
|
||||
* Provides data to the ajax get calls about the Phrasen plugin
|
||||
* This controller works with JSON calls on the HTTP GET and the output is always JSON
|
||||
*/
|
||||
class Phrasen extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'loadModule' => self::PERM_ANONYMOUS
|
||||
]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* @param string $module
|
||||
*/
|
||||
public function loadModule($module)
|
||||
{
|
||||
$this->load->library('PhrasesLib', [$module], 'pj');
|
||||
$this->terminateWithSuccess(json_decode($this->pj->getJSON()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the SearchBarLib (back-end)
|
||||
* Provides data to the ajax get calls about the searchbar component
|
||||
* This controller works with JSON calls on the HTTP GET and the output is always JSON
|
||||
*/
|
||||
class Searchbar extends FHCAPI_Controller
|
||||
{
|
||||
const SEARCHSTR_PARAM = 'searchstr';
|
||||
const TYPES_PARAM = 'types';
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// NOTE(chris): additional permission checks will be done in SearchBarLib
|
||||
parent::__construct([
|
||||
'search' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
// Load the library SearchBarLib
|
||||
$this->load->library('SearchBarLib');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Gets a JSON body via HTTP POST and provides the parameters
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
// Checks if the searchstr and the types parameters are in the POSTed JSON
|
||||
$this->form_validation->set_rules(self::SEARCHSTR_PARAM, null, 'required');
|
||||
$this->form_validation->set_rules(self::TYPES_PARAM . '[]', null, 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithError(SearchBarLib::ERROR_WRONG_JSON, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
// Convert to json the result from searchbarlib->search
|
||||
$result = $this->searchbarlib->search($this->input->post(self::SEARCHSTR_PARAM), $this->input->post(self::TYPES_PARAM));
|
||||
if (property_exists($result, 'error'))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the UDFLib (back-end)
|
||||
* Provides data to the ajax get calls about the Udf component
|
||||
* Listens to ajax post calls to change the Udf data
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Udf extends FHCAPI_Controller
|
||||
{
|
||||
/**
|
||||
* Calls the parent's constructor and prepares the UDFLib
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// NOTE: UdfLib has its own permissions checks
|
||||
parent::__construct([
|
||||
'load' => self::PERM_LOGGED,
|
||||
'save' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
// Libraries
|
||||
$this->load->library('form_validation');
|
||||
$this->load->library('UDFLib');
|
||||
|
||||
// Models
|
||||
$this->load->model($this->getTargetModelPath(), 'TargetModel');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Load all UDFs for a dataset
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
$pks = $this->TargetModel->getPks();
|
||||
foreach ($pks as $id)
|
||||
$this->form_validation->set_rules($id, $id, 'required');
|
||||
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
|
||||
$id = [];
|
||||
foreach ($pks as $pk)
|
||||
$id[$pk] = $this->input->post($pk);
|
||||
if (!is_array($this->TargetModel->getPk()))
|
||||
$id = current($id);
|
||||
|
||||
$result = $this->udflib->getFieldArray($this->TargetModel, $id);
|
||||
|
||||
$fields = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves UDFs to a dataset
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$pks = $this->TargetModel->getPks();
|
||||
foreach ($pks as $id)
|
||||
$this->form_validation->set_rules($id, $id, 'required');
|
||||
|
||||
$result = $this->udflib->getCiValidations($this->TargetModel, $this->input->post());
|
||||
|
||||
$fieldValidations = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->form_validation->set_rules($fieldvalidations);
|
||||
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
|
||||
$id = [];
|
||||
$fields = $this->input->post();
|
||||
foreach ($pks as $pk) {
|
||||
$id[$pk] = $fields[$pk];
|
||||
unset($fields[$pk]);
|
||||
}
|
||||
if (!is_array($this->TargetModel->getPk()))
|
||||
$id = current($id);
|
||||
|
||||
$result = $this->TargetModel->update($id, $fields);
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(array_fill_keys(array_keys($fields), ''));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
/**
|
||||
* Get the path to the target model from the url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getTargetModelPath()
|
||||
{
|
||||
$ci_model_path = array_slice($this->uri->rsegments, 2);
|
||||
if ($ci_model_path)
|
||||
$ci_model_path[] = ucfirst(array_pop($ci_model_path)) . '_model';
|
||||
return implode(DIRECTORY_SEPARATOR, $ci_model_path);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,387 @@
|
||||
<?php
|
||||
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class BetriebsmittelP extends FHCAPI_Controller
|
||||
{
|
||||
private $person_id = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getAllBetriebsmittel' => ['admin:r', 'assistenz:r'],
|
||||
'addNewBetriebsmittel' => self::PERM_LOGGED,
|
||||
'updateBetriebsmittel' => self::PERM_LOGGED,
|
||||
'loadBetriebsmittel' => ['admin:r', 'assistenz:r'],
|
||||
'deleteBetriebsmittel' => self::PERM_LOGGED,
|
||||
'getTypenBetriebsmittel' => ['admin:r', 'assistenz:r'],
|
||||
'loadInventarliste' => ['admin:r', 'assistenz:r']
|
||||
]);
|
||||
|
||||
//Load Models
|
||||
$this->load->model('ressource/Betriebsmittel_model', 'BetriebsmittelModel');
|
||||
$this->load->model('ressource/Betriebsmittelperson_model', 'BetriebsmittelpersonModel');
|
||||
|
||||
// Additional Permission Checks
|
||||
if ($this->router->method == 'addNewBetriebsmittel') {
|
||||
$this->person_id = current(array_slice($this->uri->rsegments, 2));
|
||||
|
||||
$this->checkPermissionsForPerson(
|
||||
$this->person_id,
|
||||
['admin:rw', 'mitarbeiter:rw', 'basis/betriebsmittel:rw'],
|
||||
['admin:rw', 'assistenz:rw', 'basis/betriebsmittel:rw']
|
||||
);
|
||||
} elseif ($this->router->method == 'updateBetriebsmittel' || $this->router->method == 'deleteBetriebsmittel') {
|
||||
$betriebsmittelperson_id = current(array_slice($this->uri->rsegments, 2));
|
||||
$result = $this->BetriebsmittelpersonModel->load($betriebsmittelperson_id);
|
||||
if (!hasData($result))
|
||||
show_404();
|
||||
$this->person_id = current(getData($result))->person_id;
|
||||
|
||||
$this->checkPermissionsForPerson(
|
||||
$this->person_id,
|
||||
['admin:rw', 'mitarbeiter:rw', 'basis/betriebsmittel:rw'],
|
||||
['admin:rw', 'assistenz:rw', 'basis/betriebsmittel:rw']
|
||||
);
|
||||
}
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('form_validation');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui',
|
||||
'wawi'
|
||||
]);
|
||||
}
|
||||
|
||||
public function getAllBetriebsmittel($type_id, $id)
|
||||
{
|
||||
$result = $this->BetriebsmittelpersonModel->getBetriebsmittelData($id, $type_id);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess((getData($result) ?: []));
|
||||
}
|
||||
|
||||
protected function validateNewOrUpdate()
|
||||
{
|
||||
$this->form_validation->set_rules('betriebsmitteltyp', 'Typ', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired')
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('kaution', 'Kaution', 'numeric|less_than_equal_to[9999.99]', [
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric')
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('ausgegebenam', 'Ausgegeben am', 'required|is_valid_date', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired')
|
||||
]);
|
||||
|
||||
if ($this->input->post('ausgegebenam') && $this->input->post('retouram')) {
|
||||
$this->form_validation->set_rules('retouram', 'Retour am', [
|
||||
'is_valid_date',
|
||||
['is_not_before_ausgegebenam', function ($value) {
|
||||
return (new DateTime($value) >= new DateTime($this->input->post('ausgegebenam')));
|
||||
}]
|
||||
], [
|
||||
'is_not_before_ausgegebenam' => $this->p->t('wawi', 'error_retourdatumVorAusgabe')
|
||||
]);
|
||||
} else {
|
||||
$this->form_validation->set_rules('retouram', 'Retour am', 'is_valid_date');
|
||||
}
|
||||
|
||||
$this->form_validation->set_rules('anmerkung', 'Anmerkung', 'max_length[256]');
|
||||
|
||||
if ($this->input->post('betriebsmitteltyp') == 'Inventar') {
|
||||
// Inventar
|
||||
$this->form_validation->set_rules('betriebsmittel_id', 'Inventarnummer', 'required');
|
||||
} elseif ($this->input->post('betriebsmitteltyp') == 'Zutrittskarte') {
|
||||
// Zutrittskarte
|
||||
if ($this->input->post('nummer') === null && $this->input->post('nummer') === null) {
|
||||
$this->form_validation->set_rules('nummer', 'Nummer', 'required', [
|
||||
'required' => $this->p->t('wawi', 'error_zutrittskarteOhneNummer')
|
||||
]);
|
||||
$this->form_validation->set_rules('nummer2', 'Nummer2', 'required', [
|
||||
'required' => $this->p->t('wawi', 'error_zutrittskarteOhneNummer')
|
||||
]);
|
||||
} else {
|
||||
if ($this->input->post('nummer') === null) {
|
||||
$result = $this->BetriebsmittelpersonModel->loadViewWhere([
|
||||
'betriebsmitteltyp' => $this->input->post('betriebsmitteltyp'),
|
||||
'nummer2' => $this->input->post('nummer2'),
|
||||
'person_id !=' => $this->person_id,
|
||||
'retouram IS NULL' => null
|
||||
]);
|
||||
if (hasData($result))
|
||||
$this->form_validation->set_rules('nummer2', 'Nummer2', 'is_array', [
|
||||
'is_array' => $this->p->t('wawi', 'error_bmZutrittskarteOccupied', (array)current(getData($result)))
|
||||
]);
|
||||
} else {
|
||||
$result = $this->BetriebsmittelpersonModel->loadViewWhere([
|
||||
'betriebsmitteltyp' => $this->input->post('betriebsmitteltyp'),
|
||||
'nummer' => $this->input->post('nummer'),
|
||||
'person_id !=' => $this->person_id,
|
||||
'retouram IS NULL' => null
|
||||
]);
|
||||
if (hasData($result))
|
||||
$this->form_validation->set_rules('nummer', 'Nummer', 'is_array', [
|
||||
'is_array' => $this->p->t('wawi', 'error_bmZutrittskarteOccupied', (array)current(getData($result)))
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
public function addNewBetriebsmittel($person_id)
|
||||
{
|
||||
$this->form_validation->set_rules('uid', 'UID', [
|
||||
['uid_in_person', function ($value) use ($person_id) {
|
||||
if ($value === null)
|
||||
return true;
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$result = $this->BenutzerModel->loadWhere([
|
||||
'uid' => $value,
|
||||
'person_id' => $person_id
|
||||
]);
|
||||
|
||||
return hasData($result);
|
||||
}]
|
||||
], [
|
||||
'uid_in_person' => $this->p->t('person', 'error_uidNotInPerson')
|
||||
]);
|
||||
$this->validateNewOrUpdate();
|
||||
|
||||
$betriebsmitteltyp = $this->input->post('betriebsmitteltyp');
|
||||
$nummer = $this->input->post('nummer');
|
||||
$nummer2 = $this->input->post('nummer2');
|
||||
$beschreibung = $this->input->post('beschreibung');
|
||||
$betriebsmittel_id = $this->input->post('betriebsmittel_id');
|
||||
$anmerkung = $this->input->post('anmerkung');
|
||||
$kaution = $this->input->post('kaution');
|
||||
$ausgegebenam = $this->input->post('ausgegebenam');
|
||||
$retouram = $this->input->post('retouram');
|
||||
$uid = $this->input->post('uid');
|
||||
|
||||
// NOTE(chris): transform_kartennummer
|
||||
if ($betriebsmitteltyp == 'Zutrittskarte' && $nummer)
|
||||
$nummer = is_numeric($nummer) ? ltrim($nummer, "0") : hexdec(implode("", array_reverse(str_split(trim($nummer)))));
|
||||
|
||||
$this->db->trans_start();
|
||||
|
||||
if ($betriebsmitteltyp != 'Inventar') {
|
||||
$this->BetriebsmittelModel->addOrder('updateamum', 'DESC');
|
||||
if ($betriebsmitteltyp == 'Zutrittskarte' && $nummer === null) {
|
||||
$result = $this->BetriebsmittelModel->loadWhere([
|
||||
'betriebsmitteltyp' => $betriebsmitteltyp,
|
||||
'nummer2' => $nummer2
|
||||
]);
|
||||
} else {
|
||||
$result = $this->BetriebsmittelModel->loadWhere([
|
||||
'betriebsmitteltyp' => $betriebsmitteltyp,
|
||||
'nummer' => $nummer
|
||||
]);
|
||||
}
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if ($data) {
|
||||
$data = current($data);
|
||||
if ($data->nummer !== $nummer || $data->nummer2 !== $nummer2 || $data->beschreibung !== $beschreibung) {
|
||||
$result = $this->BetriebsmittelModel->update($data->betriebsmittel_id, [
|
||||
'nummer' => $nummer,
|
||||
'nummer2' => $nummer2,
|
||||
'beschreibung' => $beschreibung,
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID()
|
||||
]);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
$betriebsmittel_id = $data->betriebsmittel_id;
|
||||
} else {
|
||||
$result = $this->BetriebsmittelModel->insert([
|
||||
'betriebsmitteltyp' => $betriebsmitteltyp,
|
||||
'nummer' => $nummer,
|
||||
'nummer2' => $nummer2,
|
||||
'beschreibung' => $beschreibung,
|
||||
'reservieren' => false,
|
||||
'ort_kurzbz' => null,
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => getAuthUID(),
|
||||
]);
|
||||
$betriebsmittel_id = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->BetriebsmittelpersonModel->insert([
|
||||
'person_id' => $person_id,
|
||||
'betriebsmittel_id' => $betriebsmittel_id,
|
||||
'anmerkung' => $anmerkung,
|
||||
'kaution' => $kaution,
|
||||
'ausgegebenam' => $ausgegebenam,
|
||||
'retouram' => $retouram,
|
||||
'uid' => $uid,
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => getAuthUID()
|
||||
]);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
$this->terminateWithSuccess(true);
|
||||
}
|
||||
|
||||
public function updateBetriebsmittel($betriebsmittelperson_id)
|
||||
{
|
||||
$this->validateNewOrUpdate();
|
||||
|
||||
$betriebsmitteltyp = $this->input->post('betriebsmitteltyp');
|
||||
$nummer = $this->input->post('nummer');
|
||||
$nummer2 = $this->input->post('nummer2');
|
||||
$beschreibung = $this->input->post('beschreibung');
|
||||
$betriebsmittel_id = $this->input->post('betriebsmittel_id');
|
||||
$anmerkung = $this->input->post('anmerkung');
|
||||
$kaution = $this->input->post('kaution');
|
||||
$ausgegebenam = $this->input->post('ausgegebenam');
|
||||
$retouram = $this->input->post('retouram');
|
||||
|
||||
// NOTE(chris): transform_kartennummer
|
||||
if ($betriebsmitteltyp == 'Zutrittskarte' && $nummer)
|
||||
$nummer = is_numeric($nummer) ? ltrim($nummer, "0") : hexdec(implode("", array_reverse(str_split(trim($nummer)))));
|
||||
|
||||
$this->db->trans_start();
|
||||
|
||||
if ($betriebsmitteltyp != 'Inventar') {
|
||||
$found = false;
|
||||
if ($nummer !== null && $betriebsmittel_id !== null) {
|
||||
$result = $this->BetriebsmittelModel->load($betriebsmittel_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
if ($data && current($data)->nummer == $nummer) {
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$this->BetriebsmittelModel->addOrder('updateamum', 'DESC');
|
||||
if ($betriebsmitteltyp == 'Zutrittskarte' && $nummer === null) {
|
||||
$result = $this->BetriebsmittelModel->loadWhere([
|
||||
'betriebsmitteltyp' => $betriebsmitteltyp,
|
||||
'nummer2' => $nummer2
|
||||
]);
|
||||
} else {
|
||||
$result = $this->BetriebsmittelModel->loadWhere([
|
||||
'betriebsmitteltyp' => $betriebsmitteltyp,
|
||||
'nummer' => $nummer
|
||||
]);
|
||||
}
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
|
||||
if ($data) {
|
||||
$data = current($data);
|
||||
if ($data->nummer !== $nummer || $data->nummer2 !== $nummer2 || $data->beschreibung !== $beschreibung) {
|
||||
$result = $this->BetriebsmittelModel->update($data->betriebsmittel_id, [
|
||||
'nummer' => $nummer,
|
||||
'nummer2' => $nummer2,
|
||||
'beschreibung' => $beschreibung,
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID()
|
||||
]);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
$betriebsmittel_id = $data->betriebsmittel_id;
|
||||
} else {
|
||||
$result = $this->BetriebsmittelModel->insert([
|
||||
'betriebsmitteltyp' => $betriebsmitteltyp,
|
||||
'nummer' => $nummer,
|
||||
'nummer2' => $nummer2,
|
||||
'beschreibung' => $beschreibung,
|
||||
'reservieren' => false,
|
||||
'ort_kurzbz' => null,
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => getAuthUID(),
|
||||
]);
|
||||
$betriebsmittel_id = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->BetriebsmittelpersonModel->update($betriebsmittelperson_id, [
|
||||
'betriebsmittel_id' => $betriebsmittel_id,
|
||||
'anmerkung' => $anmerkung,
|
||||
'kaution' => $kaution,
|
||||
'ausgegebenam' => $ausgegebenam,
|
||||
'retouram' => $retouram,
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID()
|
||||
]);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
$this->terminateWithSuccess(true);
|
||||
}
|
||||
|
||||
public function loadBetriebsmittel($betriebsmittelperson_id)
|
||||
{
|
||||
$result = $this->BetriebsmittelpersonModel->getBetriebsmittelData($betriebsmittelperson_id, 'betriebsmittelperson_id');
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if (!hasData($result)) {
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Betriebsmittelperson_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
|
||||
public function deleteBetriebsmittel($betriebsmittelperson_id)
|
||||
{
|
||||
$result = $this->BetriebsmittelpersonModel->delete(
|
||||
array('betriebsmittelperson_id' => $betriebsmittelperson_id,
|
||||
)
|
||||
);
|
||||
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if (!hasData($result)) {
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Betriebsmittelperson_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->outputJsonSuccess(current(getData($result)));
|
||||
}
|
||||
|
||||
public function getTypenBetriebsmittel()
|
||||
{
|
||||
$this->load->model('ressource/Betriebsmitteltyp_model', 'BetriebsmitteltypModel');
|
||||
|
||||
$this->BetriebsmitteltypModel->addOrder('beschreibung', 'ASC');
|
||||
$result = $this->BetriebsmitteltypModel->load(); // load All
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
|
||||
public function loadInventarliste($searchString)
|
||||
{
|
||||
$result = $this->BetriebsmittelModel->loadInventarliste($searchString);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class CheckPerson extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'updatePersonUnrulyStatus' => array('basis/mitarbeiter:rw', 'student/antragfreigabe:rw', 'student/studierendenantrag:rw'),
|
||||
'filterPerson' => array('basis/mitarbeiter:rw', 'student/antragfreigabe:rw', 'student/studierendenantrag:rw'),
|
||||
'checkUnruly' => array('basis/mitarbeiter:r', 'student/antragfreigabe:r', 'student/studierendenantrag:r', 'infocenter:r'),
|
||||
'checkDuplicate' => array('infocenter:r'),
|
||||
]);
|
||||
|
||||
$this->_ci =& get_instance();
|
||||
$this->_ci->load->model('person/Person_model', 'PersonModel');
|
||||
}
|
||||
|
||||
public function updatePersonUnrulyStatus()
|
||||
{
|
||||
$data = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$person_id = $data['person_id'];
|
||||
$unruly = $data['unruly'];
|
||||
|
||||
$result = $this->_ci->PersonModel->updateUnruly($person_id, $unruly);
|
||||
|
||||
if(isError($result)) {
|
||||
$this->terminateWithError($result);
|
||||
} else if (isSuccess($result)) {
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function checkDuplicate() {
|
||||
|
||||
$person_id = $this->input->post('person_id');
|
||||
|
||||
$result = $this->_ci->PersonModel->checkDuplicate($person_id);
|
||||
|
||||
if (isSuccess($result))
|
||||
$this->terminateWithSuccess($result);
|
||||
else
|
||||
$this->terminateWithError('Error when searching for person');
|
||||
|
||||
}
|
||||
|
||||
// performs strict check over vorname, nachname, gebdatum
|
||||
public function checkUnruly() {
|
||||
|
||||
$vorname = $this->input->post('vorname');
|
||||
$nachname = $this->input->post('nachname');
|
||||
$gebdatum = $this->input->post('gebdatum');
|
||||
|
||||
$result = $this->_ci->PersonModel->checkUnruly($vorname, $nachname, $gebdatum);
|
||||
|
||||
if (isSuccess($result))
|
||||
$this->terminateWithSuccess($result);
|
||||
else
|
||||
$this->terminateWithError('Error when searching for person');
|
||||
}
|
||||
|
||||
// filters nachname on similarity and vorname/gebdatum are optional
|
||||
public function filterPerson() {
|
||||
$payload = json_decode($this->input->raw_input_stream, TRUE);
|
||||
|
||||
$nachnameString = '';
|
||||
$vornameString = '';
|
||||
$filterUnruly = true;
|
||||
$birthdateString = '';
|
||||
|
||||
if(array_key_exists( 'nachname', $payload) ) {
|
||||
$nachnameString = $payload['nachname'];
|
||||
}
|
||||
|
||||
if(array_key_exists('vorname', $payload)) {
|
||||
$vornameString = $payload['vorname'];
|
||||
}
|
||||
|
||||
if(array_key_exists('unruly', $payload)){
|
||||
$filterUnruly = $payload['unruly'];
|
||||
}
|
||||
|
||||
if(array_key_exists('gebdatum', $payload)) {
|
||||
// TODO: enable if gebdatum filter for unrulys is desired
|
||||
// $birthdateString = $payload['gebdatum'];
|
||||
}
|
||||
|
||||
$parametersArray = array($nachnameString);
|
||||
$where ="p.nachname~* ? ";
|
||||
if (mb_strlen($nachnameString) == 2)
|
||||
{
|
||||
$where = "p.nachname=? ";
|
||||
}
|
||||
|
||||
if(isset($vornameString) && $vornameString != '')
|
||||
{
|
||||
$where.= " AND p.vorname~*?";
|
||||
$parametersArray[] = $vornameString;
|
||||
}
|
||||
|
||||
if(isset($birthdateString) && $birthdateString != '')
|
||||
{
|
||||
$where.=" AND p.gebdatum=?";
|
||||
$parametersArray[] = $birthdateString;
|
||||
}
|
||||
|
||||
if(isset($filterUnruly))
|
||||
{
|
||||
$where.=" AND p.unruly=?";
|
||||
$parametersArray[] = $filterUnruly;
|
||||
}
|
||||
|
||||
$result = $this->_ci->PersonModel->checkUnrulyWhere($where, $parametersArray);
|
||||
|
||||
if (isSuccess($result))
|
||||
$this->terminateWithSuccess($result);
|
||||
else
|
||||
$this->terminateWithError('Error when searching for person');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* FH-Complete
|
||||
*
|
||||
* @package FHC-API
|
||||
* @author FHC-Team
|
||||
* @copyright Copyright (c) 2016, fhcomplete.org
|
||||
* @license GPLv3
|
||||
* @link http://fhcomplete.org
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Lehrveranstaltung extends FHCAPI_Controller
|
||||
{
|
||||
/**
|
||||
* Lehrveranstaltung API constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(array(
|
||||
'getTemplateLvTree' => array(
|
||||
'lehre/lehrveranstaltung:rw'
|
||||
)
|
||||
));
|
||||
|
||||
// Load model LehrveranstaltungModel
|
||||
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Templates and union with all Lehrveranstaltungen of given Studiensemester and Oes of given Berechtigung,
|
||||
* that are assigned to a template. This data structure can be used for nested tabulators' data tree.
|
||||
*
|
||||
* @param null|string $studiensemester_kurzbz
|
||||
* @param null|string $berechtigung
|
||||
* @return array|stdClass|null
|
||||
*/
|
||||
public function getTemplateLvTree()
|
||||
{
|
||||
$studiensemester_kurzbz = $this->input->get('studiensemester_kurzbz');
|
||||
$berechtigung = $this->input->get('berechtigung');
|
||||
|
||||
if ($berechtigung)
|
||||
{
|
||||
$oe_permissions = $this->permissionlib->getOE_isEntitledFor($berechtigung);
|
||||
if(!$oe_permissions) $oe_permissions = [];
|
||||
|
||||
$result = $this->LehrveranstaltungModel->getTemplateLvTree($studiensemester_kurzbz, $oe_permissions);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->LehrveranstaltungModel->getTemplateLvTree($studiensemester_kurzbz);
|
||||
}
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_DB);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess((getData($result) ?: []));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class NotizPerson extends Notiz_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getUid' => ['admin:r', 'assistenz:r'],
|
||||
'getNotizen' => ['admin:r', 'assistenz:r'],
|
||||
'loadNotiz' => ['admin:r', 'assistenz:r'],
|
||||
'addNewNotiz' => ['admin:rw', 'assistenz:rw'],
|
||||
'updateNotiz' => ['admin:rw', 'assistenz:rw'],
|
||||
'deleteNotiz' => ['admin:rw', 'assistenz:rw'],
|
||||
'loadDokumente' => ['admin:r', 'assistenz:r'],
|
||||
'getMitarbeiter' => ['admin:r', 'assistenz:r'],
|
||||
'isBerechtigt' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function isBerechtigt($id, $typeId)
|
||||
{
|
||||
if($typeId != "person_id")
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_typeNotizIdIncorrect'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//TODO define permission
|
||||
if (!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid'))
|
||||
{
|
||||
$result = $this->p->t('lehre', 'error_keineSchreibrechte');
|
||||
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
public function loadDokumente()
|
||||
{
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
|
||||
// TODO(chris): make CI variant of endpoint
|
||||
$this->NotizModel->addSelect($this->NotizModel->escape(base_url('content/notizdokdownload.php?id=')) . ' || campus.tbl_dms_version.dms_id AS preview');
|
||||
|
||||
return parent::loadDokumente();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* FH-Complete
|
||||
*
|
||||
* @package FHC-API
|
||||
* @author FHC-Team
|
||||
* @copyright Copyright (c) 2016, fhcomplete.org
|
||||
* @license GPLv3
|
||||
* @link http://fhcomplete.org
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Studiensemester extends FHCAPI_Controller
|
||||
{
|
||||
/**
|
||||
* Studiensemester API constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
array(
|
||||
'getAll' => self::PERM_LOGGED,
|
||||
'getAktNext' => self::PERM_LOGGED
|
||||
)
|
||||
);
|
||||
// Load model StudiensemesterModel
|
||||
$this->load->model('organisation/studiensemester_model', 'StudiensemesterModel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Studiensemester.
|
||||
*
|
||||
* @param null|string $order Sorting order for the Studiensemester, 'asc' or 'desc'. Defaults to 'asc'.
|
||||
* @param null|string $start Start date of the displayed Studiensemester in the format 'YYYY-MM-DD'.
|
||||
* If provided, only Studiensemester starting from this date onwards will be returned.
|
||||
* eg. '2020-09-01' will start with WS2020.
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
$order = $this->input->get('order');
|
||||
$start = $this->input->get('start');
|
||||
|
||||
if (strcasecmp($order, 'DESC') == 0)
|
||||
{
|
||||
$this->StudiensemesterModel->addOrder('ende', 'DESC');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->StudiensemesterModel->addOrder('ende', 'ASC');
|
||||
}
|
||||
|
||||
if ($start)
|
||||
{
|
||||
$result = $this->StudiensemesterModel->loadWhere([
|
||||
'start >= ' => $start
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->StudiensemesterModel->load();
|
||||
}
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_DB);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess((getData($result) ?: []));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getAktNext()
|
||||
{
|
||||
$semester = $this->input->get('semester');
|
||||
|
||||
$result = null;
|
||||
|
||||
if (!is_numeric($semester))
|
||||
{
|
||||
$result = $this->StudiensemesterModel->loadWhere(array('start <=' => 'NOW()', 'ende >=' => 'NOW()'));
|
||||
}
|
||||
|
||||
if (!hasData($result))
|
||||
{
|
||||
$this->StudiensemesterModel->addOrder('ende');
|
||||
$this->StudiensemesterModel->addLimit(1);
|
||||
|
||||
$whereArray = array('ende >=' => 'NOW()');
|
||||
|
||||
if (is_numeric($semester))
|
||||
{
|
||||
if ($semester % 2 == 0)
|
||||
{
|
||||
$ss = 'SS';
|
||||
}
|
||||
else
|
||||
{
|
||||
$ss = 'WS';
|
||||
}
|
||||
|
||||
$whereArray['SUBSTRING(studiensemester_kurzbz FROM 1 FOR 2) ='] = $ss;
|
||||
}
|
||||
|
||||
$result = $this->StudiensemesterModel->loadWhere($whereArray);
|
||||
}
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_DB);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess((getData($result) ?: ''));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \REST_Controller as REST_Controller;
|
||||
use \Studierendenantrag_model as Studierendenantrag_model;
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the AntragLib (back-end)
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Abmeldung extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Calls the parent's constructor and loads the AntragLib
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getDetailsForNewAntrag' => self::PERM_LOGGED,
|
||||
'getDetailsForAntrag' => self::PERM_LOGGED,
|
||||
'createAntrag' => self::PERM_LOGGED,
|
||||
'cancelAntrag' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
// Libraries
|
||||
$this->load->library('AntragLib');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'studierendenantrag'
|
||||
]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Retrieves data of the current studiengang for the current user
|
||||
*/
|
||||
|
||||
public function getDetailsForNewAntrag($prestudent_id)
|
||||
{
|
||||
if (!$this->antraglib->isEntitledToCreateAntragFor($prestudent_id, true))
|
||||
$this->terminateWithError('Forbidden', self::ERROR_TYPE_AUTH, REST_Controller::HTTP_FORBIDDEN);
|
||||
|
||||
$result = $this->antraglib->getPrestudentAbmeldeBerechtigt($prestudent_id);
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$result) {
|
||||
$this->terminateWithError(
|
||||
$this->p->t('studierendenantrag', 'error_no_student'),
|
||||
self::ERROR_TYPE_AUTH,
|
||||
REST_Controller::HTTP_FORBIDDEN
|
||||
);
|
||||
} elseif ($result == -3) {
|
||||
$this->terminateWithError(
|
||||
$this->p->t('studierendenantrag', 'error_stg_blacklist'),
|
||||
self::ERROR_TYPE_AUTH,
|
||||
REST_Controller::HTTP_FORBIDDEN
|
||||
);
|
||||
} elseif ($result == -1) {
|
||||
$result = $this->antraglib->getDetailsForLastAntrag(
|
||||
$prestudent_id,
|
||||
[
|
||||
Studierendenantrag_model::TYP_ABMELDUNG,
|
||||
Studierendenantrag_model::TYP_ABMELDUNG_STGL
|
||||
]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$data->canCancel = (
|
||||
$data->status == Studierendenantragstatus_model::STATUS_CREATED &&
|
||||
$this->antraglib->isEntitledToCancelAntrag($data->studierendenantrag_id)
|
||||
);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
$result = $this->antraglib->getDetailsForNewAntrag($prestudent_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getDetailsForAntrag($studierendenantrag_id)
|
||||
{
|
||||
if (!$this->antraglib->isEntitledToShowAntrag($studierendenantrag_id))
|
||||
return show_404();
|
||||
|
||||
$result = $this->antraglib->getDetailsForAntrag($studierendenantrag_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if ($data->typ !== Studierendenantrag_model::TYP_ABMELDUNG_STGL && $data->typ !== Studierendenantrag_model::TYP_ABMELDUNG)
|
||||
return show_404();
|
||||
|
||||
$data->canCancel = (
|
||||
$data->status == Studierendenantragstatus_model::STATUS_CREATED &&
|
||||
$this->antraglib->isEntitledToCancelAntrag($data->studierendenantrag_id)
|
||||
);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function createAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('studiensemester', 'Studiensemester', 'required');
|
||||
$this->form_validation->set_rules('prestudent_id', 'Prestudent ID', 'required');
|
||||
$this->form_validation->set_rules('grund', 'Grund', 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$grund = $this->input->post('grund');
|
||||
$studiensemester = $this->input->post('studiensemester');
|
||||
$prestudent_id = $this->input->post('prestudent_id');
|
||||
|
||||
$result = $this->antraglib->getPrestudentAbmeldeBerechtigt($prestudent_id);
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
if (!$result)
|
||||
$this->terminateWithError($this->p->t('studierendenantrag', 'error_no_student'), self::ERROR_TYPE_GENERAL);
|
||||
elseif ($result == -3)
|
||||
$this->terminateWithError($this->p->t('studierendenantrag', 'error_stg_blacklist'), self::ERROR_TYPE_GENERAL);
|
||||
elseif ($result < 0)
|
||||
$this->terminateWithError($this->p->t('studierendenantrag', 'error_antrag_exists'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$result = $this->antraglib->createAbmeldung($prestudent_id, $studiensemester, getAuthUID(), $grund);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$result = $this->antraglib->getDetailsForAntrag($data);
|
||||
if (!hasData($result))
|
||||
return $this->terminateWithSuccess(true);
|
||||
|
||||
$data = getData($result);
|
||||
$data->canCancel = (boolean)$this->antraglib->isEntitledToCancelAntrag($data->studierendenantrag_id);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function cancelAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('antrag_id', 'Antrag ID', 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$antrag_id = $this->input->post('antrag_id');
|
||||
|
||||
if (!$this->antraglib->isEntitledToCancelAntrag($antrag_id))
|
||||
$this->terminateWithError('Forbidden', self::ERROR_TYPE_AUTH, REST_Controller::HTTP_FORBIDDEN);
|
||||
|
||||
$result = $this->antraglib->cancelAntrag($antrag_id, getAuthUID());
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
$result = $this->antraglib->getDetailsForAntrag($antrag_id);
|
||||
if (!hasData($result))
|
||||
$this->terminateWithSuccess($antrag_id);
|
||||
|
||||
$data = getData($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,429 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \stdClass as stdClass;
|
||||
use \Studierendenantrag_model as Studierendenantrag_model;
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the AntragLib (back-end)
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Leitung extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Calls the parent's constructor and loads the AntragLib
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getActiveStgs' => ['student/antragfreigabe:r', 'student/studierendenantrag:r'],
|
||||
'getAntraege' => ['student/antragfreigabe:r', 'student/studierendenantrag:r'],
|
||||
'getHistory' => ['student/antragfreigabe:r', 'student/studierendenantrag:r'],
|
||||
'getPrestudents' => 'student/studierendenantrag:w',
|
||||
'approveAntrag' => 'student/antragfreigabe:w',
|
||||
'rejectAntrag' => 'student/antragfreigabe:w',
|
||||
'reopenAntrag' => 'student/studierendenantrag:w',
|
||||
'pauseAntrag' => ['student/antragfreigabe:w', 'student/studierendenantrag:w'],
|
||||
'unpauseAntrag' => ['student/antragfreigabe:w', 'student/studierendenantrag:w'],
|
||||
'objectAntrag' => ['student/antragfreigabe:w', 'student/studierendenantrag:w'],
|
||||
'approveObjection' => ['student/antragfreigabe:w', 'student/studierendenantrag:w'],
|
||||
'denyObjection' => ['student/antragfreigabe:w', 'student/studierendenantrag:w']
|
||||
]);
|
||||
|
||||
// Libraries
|
||||
$this->load->library('AntragLib');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'studierendenantrag',
|
||||
'lehre'
|
||||
]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
public function getActiveStgs()
|
||||
{
|
||||
$studiengaenge = $this->permissionlib->getSTG_isEntitledFor('student/antragfreigabe') ?: [];
|
||||
$studiengaenge = array_merge($studiengaenge, $this->permissionlib->getSTG_isEntitledFor('student/studierendenantrag') ?: []);
|
||||
|
||||
$result = $this->StudierendenantragModel->loadStgsWithAntraege($studiengaenge);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getAntraege($studiengang = null, $extra = null)
|
||||
{
|
||||
if ($studiengang && $studiengang == 'todo') {
|
||||
$studiengang = $extra;
|
||||
$extra = true;
|
||||
} else {
|
||||
$extra = false;
|
||||
}
|
||||
|
||||
$studiengaenge = $this->permissionlib->getSTG_isEntitledFor('student/antragfreigabe');
|
||||
if(!is_array($studiengaenge))
|
||||
$studiengaenge = [];
|
||||
|
||||
|
||||
$stgsNeuanlage = $this->permissionlib->getSTG_isEntitledFor('student/studierendenantrag');
|
||||
if(!is_array($stgsNeuanlage))
|
||||
$stgsNeuanlage = [];
|
||||
|
||||
$studiengaenge = array_unique(array_merge($studiengaenge, $stgsNeuanlage));
|
||||
|
||||
if ($studiengang) {
|
||||
if (!in_array($studiengang, $studiengaenge))
|
||||
$this->terminateWithError(
|
||||
'Forbidden',
|
||||
self::ERROR_TYPE_AUTH,
|
||||
REST_Controller::HTTP_FORBIDDEN
|
||||
);
|
||||
$studiengaenge = [$studiengang];
|
||||
}
|
||||
|
||||
$antraege = [];
|
||||
if ($studiengaenge) {
|
||||
$result = $extra
|
||||
? $this->StudierendenantragModel->loadActiveForStudiengaenge($studiengaenge)
|
||||
: $this->StudierendenantragModel->loadForStudiengaenge($studiengaenge);
|
||||
|
||||
$antraege = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($antraege ?: []);
|
||||
}
|
||||
|
||||
public function getHistory($studierendenantrag_id)
|
||||
{
|
||||
if (!$this->antraglib->isEntitledToSeeHistoryForAntrag($studierendenantrag_id))
|
||||
$this->terminateWithError(
|
||||
'Forbidden',
|
||||
self::ERROR_TYPE_AUTH,
|
||||
REST_Controller::HTTP_FORBIDDEN
|
||||
);
|
||||
|
||||
$result = $this->antraglib->getAntragHistory($studierendenantrag_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data ?: []);
|
||||
}
|
||||
|
||||
public function getPrestudents()
|
||||
{
|
||||
$query = $this->input->post('query');
|
||||
|
||||
$studiengaenge = $this->permissionlib->getSTG_isEntitledFor('student/studierendenantrag');
|
||||
|
||||
$result = $this->antraglib->getAktivePrestudentenInStgs($studiengaenge, $query);
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithSuccess($result ?: []);
|
||||
}
|
||||
|
||||
public function approveAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
[
|
||||
'required',
|
||||
['isEntitledToApproveAntrag', [$this->antraglib, 'isEntitledToApproveAntrag']],
|
||||
],
|
||||
[
|
||||
'isEntitledToApproveAntrag' => $this->p->t('studierendenantrag', 'error_no_right')
|
||||
]
|
||||
);
|
||||
$this->form_validation->set_rules(
|
||||
'typ',
|
||||
'Typ',
|
||||
'required|in_list[' . implode(',', [
|
||||
Studierendenantrag_model::TYP_ABMELDUNG,
|
||||
Studierendenantrag_model::TYP_ABMELDUNG_STGL,
|
||||
Studierendenantrag_model::TYP_UNTERBRECHUNG,
|
||||
Studierendenantrag_model::TYP_WIEDERHOLUNG
|
||||
]) . ']'
|
||||
);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
switch ($this->input->post('typ')) {
|
||||
case Studierendenantrag_model::TYP_ABMELDUNG:
|
||||
case Studierendenantrag_model::TYP_ABMELDUNG_STGL:
|
||||
$result = $this->antraglib->approveAbmeldung([$studierendenantrag_id], getAuthUID());
|
||||
break;
|
||||
case Studierendenantrag_model::TYP_UNTERBRECHUNG:
|
||||
$result = $this->antraglib->approveUnterbrechung([$studierendenantrag_id], getAuthUID());
|
||||
break;
|
||||
case Studierendenantrag_model::TYP_WIEDERHOLUNG:
|
||||
$result = $this->antraglib->approveWiederholung($studierendenantrag_id, getAuthUID());
|
||||
break;
|
||||
}
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function rejectAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
[
|
||||
'required',
|
||||
['isEntitledToRejectAntrag', [$this->antraglib, 'isEntitledToRejectAntrag']],
|
||||
],
|
||||
[
|
||||
'isEntitledToRejectAntrag' => $this->p->t('studierendenantrag', 'error_no_right')
|
||||
]
|
||||
);
|
||||
$this->form_validation->set_rules('grund', 'Grund', 'required');
|
||||
$this->form_validation->set_rules(
|
||||
'typ',
|
||||
'Typ',
|
||||
'required|in_list[' . implode(',', [
|
||||
Studierendenantrag_model::TYP_UNTERBRECHUNG
|
||||
]) . ']'
|
||||
);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
$grund = $this->input->post('grund');
|
||||
|
||||
$result = $this->antraglib->rejectUnterbrechung([$studierendenantrag_id], getAuthUID(), $grund);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function reopenAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
[
|
||||
'required',
|
||||
['isEntitledToReopenAntrag', [$this->antraglib, 'isEntitledToReopenAntrag']],
|
||||
],
|
||||
[
|
||||
'isEntitledToReopenAntrag' => $this->p->t('studierendenantrag', 'error_no_right')
|
||||
]
|
||||
);
|
||||
$this->form_validation->set_rules(
|
||||
'typ',
|
||||
'Typ',
|
||||
'required|in_list[' . implode(',', [
|
||||
Studierendenantrag_model::TYP_WIEDERHOLUNG
|
||||
]) . ']'
|
||||
);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
|
||||
$result = $this->antraglib->reopenWiederholung($studierendenantrag_id, getAuthUID());
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function pauseAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
[
|
||||
'required',
|
||||
['isEntitledToPauseAntrag', [$this->antraglib, 'isEntitledToPauseAntrag']],
|
||||
['antragCanBeManualPaused', [$this->antraglib, 'antragCanBeManualPaused']]
|
||||
],
|
||||
[
|
||||
'isEntitledToPauseAntrag' => $this->p->t('studierendenantrag', 'error_no_right'),
|
||||
'antragCanBeManualPaused' => $this->p->t(
|
||||
'studierendenantrag',
|
||||
'error_not_pauseable',
|
||||
['id' => $this->input->post('studierendenantrag_id')]
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
|
||||
$result = $this->antraglib->pauseAntrag($studierendenantrag_id, getAuthUID());
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function unpauseAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
[
|
||||
'required',
|
||||
['isEntitledToUnpauseAntrag', [$this->antraglib, 'isEntitledToUnpauseAntrag']],
|
||||
['antragCanBeManualUnpaused', [$this->antraglib, 'antragCanBeManualUnpaused']]
|
||||
],
|
||||
[
|
||||
'isEntitledToUnpauseAntrag' => $this->p->t('studierendenantrag', 'error_no_right'),
|
||||
'antragCanBeManualUnpaused' => $this->p->t(
|
||||
'studierendenantrag',
|
||||
'error_not_paused',
|
||||
['id' => $this->input->post('studierendenantrag_id')]
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
|
||||
$result = $this->antraglib->unpauseAntrag($studierendenantrag_id, getAuthUID());
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function objectAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
[
|
||||
'required',
|
||||
['isEntitledToObjectAntrag', [$this->antraglib, 'isEntitledToObjectAntrag']],
|
||||
['canBeObjected', function ($a) {
|
||||
return $this->antraglib->hasType($a, Studierendenantrag_model::TYP_ABMELDUNG_STGL);
|
||||
}]
|
||||
],
|
||||
[
|
||||
'isEntitledToObjectAntrag' => $this->p->t('studierendenantrag', 'error_no_right'),
|
||||
'canBeObjected' => $this->p->t(
|
||||
'studierendenantrag',
|
||||
'error_no_objection'
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
|
||||
$result = $this->antraglib->objectAbmeldung($studierendenantrag_id, getAuthUID());
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function approveObjection()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
[
|
||||
'required',
|
||||
['isEntitledToObjectAntrag', [$this->antraglib, 'isEntitledToObjectAntrag']],
|
||||
['isObjected', function ($a) {
|
||||
return $this->antraglib->hasStatus($a, Studierendenantragstatus_model::STATUS_OBJECTED);
|
||||
}]
|
||||
],
|
||||
[
|
||||
'isEntitledToObjectAntrag' => $this->p->t('studierendenantrag', 'error_no_right'),
|
||||
'isObjected' => $this->p->t(
|
||||
'studierendenantrag',
|
||||
'error_not_objected'
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
|
||||
$result = $this->antraglib->cancelAntrag($studierendenantrag_id, getAuthUID());
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function denyObjection()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
[
|
||||
'required',
|
||||
['isEntitledToObjectAntrag', [$this->antraglib, 'isEntitledToObjectAntrag']],
|
||||
['isObjected', function ($a) {
|
||||
return $this->antraglib->hasStatus($a, Studierendenantragstatus_model::STATUS_OBJECTED);
|
||||
}]
|
||||
],
|
||||
[
|
||||
'isEntitledToObjectAntrag' => $this->p->t('studierendenantrag', 'error_no_right'),
|
||||
'isObjected' => $this->p->t(
|
||||
'studierendenantrag',
|
||||
'error_not_objected'
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
$grund = $this->input->post('grund');
|
||||
|
||||
$result = $this->antraglib->denyObjectionAbmeldung($studierendenantrag_id, getAuthUID(), $grund);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithSuccess($studierendenantrag_id);
|
||||
}
|
||||
}
|
||||
+87
-94
@@ -1,4 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
@@ -6,23 +22,28 @@ use \Studierendenantrag_model as Studierendenantrag_model;
|
||||
use \DateTime as DateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* This controller operates between (interface) the JS (GUI) and the AntragLib (back-end)
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Unterbrechung extends FHC_Controller
|
||||
class Unterbrechung extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Calls the parent's constructor and loads the FilterCmptLib
|
||||
* Calls the parent's constructor and loads the AntragLib
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
parent::__construct([
|
||||
'getDetailsForNewAntrag' => self::PERM_LOGGED,
|
||||
'getDetailsForAntrag' => self::PERM_LOGGED,
|
||||
'createAntrag' => self::PERM_LOGGED,
|
||||
'cancelAntrag' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
// Configs
|
||||
$this->load->config('studierendenantrag');
|
||||
|
||||
// Libraries
|
||||
$this->load->library('AuthLib');
|
||||
$this->load->library('AntragLib');
|
||||
|
||||
// Load language phrases
|
||||
@@ -38,74 +59,62 @@ class Unterbrechung extends FHC_Controller
|
||||
|
||||
public function getDetailsForNewAntrag($prestudent_id)
|
||||
{
|
||||
if (!$this->antraglib->isEntitledToCreateAntragFor($prestudent_id, false)) {
|
||||
$this->output->set_status_header(403);
|
||||
return $this->outputJsonError('Forbidden');
|
||||
}
|
||||
if (!$this->antraglib->isEntitledToCreateAntragFor($prestudent_id, false))
|
||||
$this->terminateWithError('Forbidden', self::ERROR_TYPE_AUTH, REST_Controller::HTTP_FORBIDDEN);
|
||||
|
||||
$result = $this->antraglib->getPrestudentUnterbrechungsBerechtigt($prestudent_id);
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(500);
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
$result = $result->retval;
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$result) {
|
||||
$this->output->set_status_header(403);
|
||||
return $this->outputJsonError($this->p->t('studierendenantrag', 'error_no_student'));
|
||||
}
|
||||
elseif ($result == -1)
|
||||
{
|
||||
$this->terminateWithError(
|
||||
$this->p->t('studierendenantrag', 'error_no_student'),
|
||||
self::ERROR_TYPE_AUTH,
|
||||
REST_Controller::HTTP_FORBIDDEN
|
||||
);
|
||||
} elseif ($result == -1) {
|
||||
$result = $this->antraglib->getDetailsForLastAntrag($prestudent_id, Studierendenantrag_model::TYP_UNTERBRECHUNG);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->outputJsonSuccess(getData($result));
|
||||
}
|
||||
elseif ($result == -2)
|
||||
{
|
||||
return $this->terminateWithSuccess($data);
|
||||
} elseif ($result == -2) {
|
||||
$result = $this->antraglib->getDetailsForLastAntrag($prestudent_id);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
|
||||
$result = getData($result);
|
||||
$this->output->set_status_header(400);
|
||||
return $this->outputJsonError($this->p->t('studierendenantrag', 'error_antrag_pending', [
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithError($this->p->t('studierendenantrag', 'error_antrag_pending', [
|
||||
'typ' => $this->p->t('studierendenantrag', 'antrag_typ_' . $result->typ)
|
||||
]));
|
||||
}
|
||||
elseif ($result == -3)
|
||||
{
|
||||
$this->output->set_status_header(403);
|
||||
return $this->outputJsonError($this->p->t('studierendenantrag', 'error_stg_blacklist'));
|
||||
}
|
||||
$result = $this->antraglib->getDetailsForNewAntrag($prestudent_id);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(getError($result));
|
||||
} elseif ($result == -3) {
|
||||
$this->terminateWithError(
|
||||
$this->p->t('studierendenantrag', 'error_stg_blacklist'),
|
||||
self::ERROR_TYPE_AUTH,
|
||||
REST_Controller::HTTP_FORBIDDEN
|
||||
);
|
||||
}
|
||||
|
||||
$data = getData($result);
|
||||
$result = $this->antraglib->getDetailsForNewAntrag($prestudent_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$data->studiensemester = $this->antraglib->getSemesterForUnterbrechung($prestudent_id, null);
|
||||
|
||||
$this->outputJsonSuccess($data);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getDetailsForAntrag($studierendenantrag_id)
|
||||
{
|
||||
if (!$this->antraglib->isEntitledToShowAntrag($studierendenantrag_id)) return show_404();
|
||||
if (!$this->antraglib->isEntitledToShowAntrag($studierendenantrag_id))
|
||||
return show_404();
|
||||
|
||||
$result = $this->antraglib->getDetailsForAntrag($studierendenantrag_id);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
|
||||
$data = getData($result);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if ($data->typ !== Studierendenantrag_model::TYP_UNTERBRECHUNG)
|
||||
return show_404();
|
||||
|
||||
$this->outputJsonSuccess($data);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function createAntrag()
|
||||
@@ -125,9 +134,8 @@ class Unterbrechung extends FHC_Controller
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
if (!$this->form_validation->run()) {
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$grund = $this->input->post('grund');
|
||||
@@ -137,25 +145,17 @@ class Unterbrechung extends FHC_Controller
|
||||
$dms_id = null;
|
||||
|
||||
$result = $this->antraglib->getPrestudentUnterbrechungsBerechtigt($prestudent_id, $studiensemester, $datum_wiedereinstieg);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(['db' => getError($result)]);
|
||||
}
|
||||
$result = $result->retval;
|
||||
if (!$result)
|
||||
{
|
||||
return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_no_student')]);
|
||||
}
|
||||
elseif ($result == -3)
|
||||
{
|
||||
return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_stg_blacklist')]);
|
||||
}
|
||||
elseif ($result < 0)
|
||||
{
|
||||
return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_antrag_exists')]);
|
||||
}
|
||||
|
||||
if(isset($_FILES['attachment']) && (!isset($_FILES['attachment']['error']) || $_FILES['attachment']['error'] != UPLOAD_ERR_NO_FILE))
|
||||
{
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$result)
|
||||
$this->terminateWithError($this->p->t('studierendenantrag', 'error_no_student'), self::ERROR_TYPE_GENERAL);
|
||||
elseif ($result == -3)
|
||||
$this->terminateWithError($this->p->t('studierendenantrag', 'error_stg_blacklist'), self::ERROR_TYPE_GENERAL);
|
||||
elseif ($result < 0)
|
||||
$this->terminateWithError($this->p->t('studierendenantrag', 'error_antrag_exists'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (isset($_FILES['attachment']) && (!isset($_FILES['attachment']['error']) || $_FILES['attachment']['error'] != UPLOAD_ERR_NO_FILE)) {
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
$dms = $this->config->item('unterbrechung_dms');
|
||||
@@ -167,53 +167,46 @@ class Unterbrechung extends FHC_Controller
|
||||
|
||||
$allowed_filetypes = $this->config->item('unterbrechung_dms_filetypes') ?: ['*'];
|
||||
$result = $this->dmslib->upload($dms, 'attachment', $allowed_filetypes);
|
||||
if(isError($result))
|
||||
{
|
||||
return $this->outputJsonError(['db' => getError($result)]);
|
||||
}
|
||||
$dms_id = getData($result)['dms_id'];
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$dms_id = $data['dms_id'];
|
||||
}
|
||||
|
||||
$result = $this->antraglib->createUnterbrechung($prestudent_id, $studiensemester, getAuthUID(), $grund, $datum_wiedereinstieg, $dms_id);
|
||||
if(isError($result))
|
||||
{
|
||||
return $this->outputJsonError(['db' => getError($result)]);
|
||||
}
|
||||
|
||||
$antragId = getData($result);
|
||||
$antragId = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$result = $this->antraglib->getDetailsForAntrag($antragId);
|
||||
|
||||
if(!hasData($result))
|
||||
return $this->outputJsonSuccess($antragId);
|
||||
$this->outputJsonSuccess(getData($result));
|
||||
if (!hasData($result))
|
||||
$this->terminateWithSuccess($antragId);
|
||||
|
||||
$this->terminateWithSuccess(getData($result));
|
||||
}
|
||||
|
||||
public function cancelAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules('antrag_id', 'Antrag ID', 'required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
if (!$this->form_validation->run()) {
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$antrag_id = $this->input->post('antrag_id');
|
||||
|
||||
$result = $this->antraglib->cancelAntrag($antrag_id, getAuthUID());
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->outputJsonError(['db' => getError($result)]);
|
||||
}
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
$result = $this->antraglib->getDetailsForAntrag($antrag_id);
|
||||
|
||||
if (!hasData($result))
|
||||
return $this->outputJsonSuccess($antrag_id);
|
||||
$this->outputJsonSuccess(getData($result));
|
||||
return $this->terminateWithSuccess($antrag_id);
|
||||
|
||||
$this->terminateWithSuccess(getData($result));
|
||||
}
|
||||
|
||||
public function isValidDate($date)
|
||||
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \REST_Controller as REST_Controller;
|
||||
use \Studierendenantragstatus_model as Studierendenantragstatus_model;
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the AntragLib (back-end)
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Wiederholung extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Calls the parent's constructor and loads the FilterCmptLib
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getDetailsForNewAntrag' => self::PERM_LOGGED,
|
||||
'createAntrag' => self::PERM_LOGGED,
|
||||
'cancelAntrag' => self::PERM_LOGGED,
|
||||
'getLvs' => self::PERM_LOGGED,
|
||||
'saveLvs' => ['student/studierendenantrag:w']
|
||||
]);
|
||||
|
||||
// Libraries
|
||||
$this->load->library('AntragLib');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'global',
|
||||
'studierendenantrag'
|
||||
]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Retrieves data of the current studiengang for the current user
|
||||
*/
|
||||
|
||||
public function getDetailsForNewAntrag($prestudent_id)
|
||||
{
|
||||
if (!$this->antraglib->isEntitledToCreateAntragFor($prestudent_id, false))
|
||||
$this->terminateWithError('Forbidden', self::ERROR_TYPE_AUTH, REST_Controller::HTTP_FORBIDDEN);
|
||||
|
||||
$result = $this->antraglib->getPrestudentWiederholungsBerechtigt($prestudent_id);
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$result) {
|
||||
$this->terminateWithError(
|
||||
$this->p->t('studierendenantrag', 'error_no_student_no_failed_exam'),
|
||||
self::ERROR_TYPE_AUTH,
|
||||
REST_Controller::HTTP_FORBIDDEN
|
||||
);
|
||||
} elseif ($result == -1) {
|
||||
$result = $this->antraglib->getDetailsForLastAntrag($prestudent_id, Studierendenantrag_model::TYP_WIEDERHOLUNG);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$result = $this->antraglib->getFailedExamForPrestudent($prestudent_id, $data->datum, $data->studiensemester_kurzbz);
|
||||
// NOTE(chris): error handling for this function should already happenden in antraglib->getPrestudentWiederholungsBerechtigt()
|
||||
$pruefungsdata = current(getData($result));
|
||||
|
||||
$data->studiensemester_kurzbz = $pruefungsdata->studiensemester_kurzbz;
|
||||
$data->lvbezeichnung = $pruefungsdata->lvbezeichnung;
|
||||
$data->pruefungsdatum = $pruefungsdata->datum;
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
} elseif ($result == -2) {
|
||||
$result = $this->antraglib->getDetailsForLastAntrag($prestudent_id);
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithError(
|
||||
$this->p->t('studierendenantrag', 'error_antrag_pending', [
|
||||
'typ' => $this->p->t('studierendenantrag', 'antrag_typ_' . $result->typ)
|
||||
]),
|
||||
self::ERROR_TYPE_GENERAL,
|
||||
REST_Controller::HTTP_BAD_REQUEST
|
||||
);
|
||||
} elseif ($result == -3) {
|
||||
$this->terminateWithError(
|
||||
$this->p->t('studierendenantrag', 'error_stg_blacklist'),
|
||||
self::ERROR_TYPE_GENERAL,
|
||||
REST_Controller::HTTP_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
$result = $this->antraglib->getDetailsForNewAntrag($prestudent_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$result = $this->antraglib->getFailedExamForPrestudent($prestudent_id);
|
||||
// NOTE(chris): error handling for this function should already happenden in antraglib->getPrestudentWiederholungsBerechtigt()
|
||||
$pruefungsdata = current(getData($result));
|
||||
|
||||
$data->studiensemester_kurzbz = $pruefungsdata->studiensemester_kurzbz;
|
||||
$data->lvbezeichnung = $pruefungsdata->lvbezeichnung;
|
||||
$data->pruefungsdatum = $pruefungsdata->datum;
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function createAntrag()
|
||||
{
|
||||
$this->createAntragWithStatus(true);
|
||||
}
|
||||
|
||||
public function cancelAntrag()
|
||||
{
|
||||
$this->createAntragWithStatus(false);
|
||||
}
|
||||
|
||||
protected function createAntragWithStatus($repeat)
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('prestudent_id', 'Prestudent ID', 'required');
|
||||
$this->form_validation->set_rules('studiensemester', 'Studiensemester', 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$prestudent_id = $this->input->post('prestudent_id');
|
||||
$studiensemester = $this->input->post('studiensemester');
|
||||
|
||||
$result = $this->antraglib->getPrestudentWiederholungsBerechtigt($prestudent_id);
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$result) {
|
||||
$this->terminateWithError($this->p->t('studierendenantrag', 'error_no_student'), self::ERROR_TYPE_GENERAL);
|
||||
} elseif ($result == -1) {
|
||||
$result = $this->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
if (!$result)
|
||||
$this->terminateWithError($this->p->t('studierendenantrag', 'error_no_prestudentstatus', [
|
||||
'prestudent_id' => $prestudent_id
|
||||
]), self::ERROR_TYPE_GENERAL);
|
||||
if (!in_array(current($result)->status_kurzbz, $this->config->item('antrag_prestudentstatus_whitelist')))
|
||||
$this->terminateWithError($this->p->t('studierendenantrag', 'error_no_student'), self::ERROR_TYPE_GENERAL);
|
||||
} elseif ($result == -2) {
|
||||
$this->terminateWithError($this->p->t('studierendenantrag', 'error_antrag_exists'), self::ERROR_TYPE_GENERAL);
|
||||
} elseif ($result == -3) {
|
||||
$this->terminateWithError($this->p->t('studierendenantrag', 'error_stg_blacklist'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = $this->antraglib->createWiederholung($prestudent_id, $studiensemester, getAuthUID(), $repeat);
|
||||
$antragId = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$result = $this->antraglib->getDetailsForAntrag($antragId);
|
||||
|
||||
if (!hasData($result))
|
||||
$this->terminateWithSuccess(true);
|
||||
|
||||
$data = getData($result);
|
||||
|
||||
$result = $this->antraglib->getFailedExamForPrestudent($prestudent_id);
|
||||
// NOTE(chris): error handling for this function should already happenden in antraglib->getPrestudentWiederholungsBerechtigt()
|
||||
$pruefungsdata = current(getData($result));
|
||||
|
||||
$data->studiensemester_kurzbz = $pruefungsdata->studiensemester_kurzbz;
|
||||
$data->lvbezeichnung = $pruefungsdata->lvbezeichnung;
|
||||
$data->pruefungsdatum = $pruefungsdata->datum;
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
|
||||
public function getLvs($antrag_id)
|
||||
{
|
||||
$result = $this->antraglib->getLvsForAntrag($antrag_id);
|
||||
if (isError($result)) {
|
||||
$error = getError($result);
|
||||
if ($error == 'Forbidden')
|
||||
$this->terminateWithError(
|
||||
$error,
|
||||
self::ERROR_TYPE_AUTH,
|
||||
REST_Controller::HTTP_FORBIDDEN
|
||||
);
|
||||
$this->terminateWithError(
|
||||
$error,
|
||||
self::ERROR_TYPE_GENERAL
|
||||
);
|
||||
}
|
||||
$lvs = getData($result);
|
||||
|
||||
$this->terminateWithSuccess($lvs);
|
||||
}
|
||||
|
||||
public function saveLvs()
|
||||
{
|
||||
$forbiddenLvs = $this->input->post('forbiddenLvs');
|
||||
$mandatoryLvs = $this->input->post('mandatoryLvs');
|
||||
$antragsLvs = array_merge($forbiddenLvs, $mandatoryLvs);
|
||||
|
||||
if (!$antragsLvs)
|
||||
$this->terminateWithError($this->p->t('studierendenantrag', 'error_no_lv'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$insert = array_map(function ($lv) {
|
||||
return [
|
||||
'studierendenantrag_id' => $lv['studierendenantrag_id'],
|
||||
'lehrveranstaltung_id' => $lv['lehrveranstaltung_id'],
|
||||
'note' => $lv['zugelassen']
|
||||
? ($lv['zugelassen'] == 1 ? 0 : $this->config->item('wiederholung_note_angerechnet'))
|
||||
: $this->config->item('wiederholung_note_nicht_zugelassen'),
|
||||
'anmerkung' => $lv['anmerkung'],
|
||||
'insertvon' => getAuthUID(),
|
||||
'studiensemester_kurzbz' => $lv['studiensemester_kurzbz']
|
||||
];
|
||||
}, $antragsLvs);
|
||||
|
||||
$antrag_ids = array_unique(array_map(function ($lv) {
|
||||
return $lv['studierendenantrag_id'];
|
||||
}, $insert));
|
||||
|
||||
foreach ($antrag_ids as $antrag_id) {
|
||||
$result = $this->StudierendenantragModel->loadIdAndStatusWhere([
|
||||
'studierendenantrag_id' => $antrag_id
|
||||
]);
|
||||
$antrag = $this->getDataOrTerminateWithError($result);
|
||||
if (!$antrag)
|
||||
$this->terminateWithError(
|
||||
$this->p->t('studierendenantrag', 'error_no_antrag_found', ['id' => $antrag_id]),
|
||||
self::ERROR_TYPE_GENERAL
|
||||
);
|
||||
$antrag = current($antrag);
|
||||
|
||||
if ($antrag->status != Studierendenantragstatus_model::STATUS_CREATED
|
||||
&& $antrag->status != Studierendenantragstatus_model::STATUS_LVSASSIGNED)
|
||||
$this->terminateWithError(
|
||||
$this->p->t('studierendenantrag', 'error_antrag_locked'),
|
||||
self::ERROR_TYPE_GENERAL
|
||||
);
|
||||
}
|
||||
|
||||
$result = $this->antraglib->saveLvs($insert);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the back-end
|
||||
* Provides data to the ajax get calls about addresses
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Address extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getNations' => self::PERM_LOGGED,
|
||||
'getPlaces' => self::PERM_LOGGED
|
||||
]);
|
||||
}
|
||||
|
||||
public function getNations()
|
||||
{
|
||||
$this->load->model('codex/Nation_model', 'NationModel');
|
||||
|
||||
$this->NationModel->addOrder('kurztext');
|
||||
|
||||
$result = $this->NationModel->load();
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getPlaces($plz)
|
||||
{
|
||||
$this->load->model('codex/Gemeinde_model', 'GemeindeModel');
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_data(['address.plz' => $plz]);
|
||||
|
||||
$this->form_validation->set_rules('address.plz', 'PLZ', 'numeric|less_than[10000]');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$result = $this->GemeindeModel->getGemeindeByPlz($plz);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use CI3_Events as Events;
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the back-end
|
||||
* Provides data to the ajax get calls about the StV Config
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Config extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// TODO(chris): permissions
|
||||
parent::__construct([
|
||||
'student' => ['admin:r', 'assistenz:r'],
|
||||
'students' => ['admin:r', 'assistenz:r']
|
||||
]);
|
||||
|
||||
|
||||
// Load Phrases
|
||||
$this->loadPhrases([
|
||||
'global',
|
||||
'person',
|
||||
'lehre',
|
||||
'stv',
|
||||
'konto'
|
||||
]);
|
||||
}
|
||||
|
||||
public function student()
|
||||
{
|
||||
$result = [];
|
||||
$result['details'] = [
|
||||
'title' => $this->p->t('stv', 'tab_details'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Details.js'
|
||||
];
|
||||
$result['notes'] = [
|
||||
'title' => $this->p->t('stv', 'tab_notes'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Notizen.js'
|
||||
];
|
||||
$result['contact'] = [
|
||||
'title' => $this->p->t('stv', 'tab_contact'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Kontakt.js',
|
||||
'config' => [
|
||||
'showBankaccount' => $this->permissionlib->isBerechtigt('mitarbeiter/bankdaten')
|
||||
|| $this->permissionlib->isBerechtigt('student/bankdaten')
|
||||
]
|
||||
];
|
||||
$result['prestudent'] = [
|
||||
'title' => $this->p->t('stv', 'tab_prestudent'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Prestudent.js'
|
||||
];
|
||||
$result['status'] = [
|
||||
'title' => 'Status',
|
||||
'component' => './Stv/Studentenverwaltung/Details/MultiStatus.js'
|
||||
];
|
||||
$result['banking'] = [
|
||||
'title' => $this->p->t('stv', 'tab_banking'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Konto.js',
|
||||
'config' => [
|
||||
'showZahlungsbestaetigung' => (defined('ZAHLUNGSBESTAETIGUNG_ANZEIGEN') && ZAHLUNGSBESTAETIGUNG_ANZEIGEN),
|
||||
'showBuchungsnr' => $this->permissionlib->isBerechtigt('admin'),
|
||||
'showMahnspanne' => (!defined('FAS_KONTO_SHOW_MAHNSPANNE') || FAS_KONTO_SHOW_MAHNSPANNE===true),
|
||||
'showCreditpoints' => (defined('FAS_KONTO_SHOW_CREDIT_POINTS') && FAS_KONTO_SHOW_CREDIT_POINTS == 'true'),
|
||||
'columns' => $this->kontoColumns(),
|
||||
'additionalCols' => []
|
||||
]
|
||||
];
|
||||
$result['resources'] = [
|
||||
'title' => $this->p->t('stv', 'tab_resources'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Betriebsmittel.js'
|
||||
];
|
||||
/* TODO(chris): Ausgeblendet für Testing
|
||||
$result['grades'] = [
|
||||
'title' => $this->p->t('stv', 'tab_grades'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Noten.js'
|
||||
];
|
||||
*/
|
||||
|
||||
Events::trigger('stv_conf_student', function & () use (&$result) {
|
||||
return $result;
|
||||
});
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function students()
|
||||
{
|
||||
$result = [];
|
||||
$result['banking'] = [
|
||||
'title' => $this->p->t('stv', 'tab_banking'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Konto.js',
|
||||
'config' => [
|
||||
'showZahlungsbestaetigung' => (defined('ZAHLUNGSBESTAETIGUNG_ANZEIGEN') && ZAHLUNGSBESTAETIGUNG_ANZEIGEN),
|
||||
'showBuchungsnr' => $this->permissionlib->isBerechtigt('admin'),
|
||||
'showMahnspanne' => (!defined('FAS_KONTO_SHOW_MAHNSPANNE') || FAS_KONTO_SHOW_MAHNSPANNE===true),
|
||||
'showCreditpoints' => (defined('FAS_KONTO_SHOW_CREDIT_POINTS') && FAS_KONTO_SHOW_CREDIT_POINTS == 'true'),
|
||||
'columns' => $this->kontoColumnsMultiPerson(),
|
||||
'additionalCols' => []
|
||||
]
|
||||
];
|
||||
$result['status'] = [
|
||||
'title' => 'Status',
|
||||
'component' => './Stv/Studentenverwaltung/Details/MultiStatus.js',
|
||||
'config' => [
|
||||
'changeStatusToAbbrecherStgl' => $this->permissionlib->isBerechtigt('admin'),
|
||||
'changeStatusToAbbrecherStud' => $this->permissionlib->isBerechtigt('admin'),
|
||||
'changeStatusToUnterbrecher' => $this->permissionlib->isBerechtigt('admin'),
|
||||
'changeStatusToDiplomand' => $this->permissionlib->isBerechtigt('admin'),
|
||||
'changeStatusToAbsolvent' => $this->permissionlib->isBerechtigt('admin')
|
||||
]
|
||||
];
|
||||
|
||||
Events::trigger('stv_conf_students', function & () use (&$result) {
|
||||
return $result;
|
||||
});
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
protected function kontoColumns()
|
||||
{
|
||||
return [
|
||||
'buchungsdatum' => [
|
||||
'field' => "buchungsdatum",
|
||||
'title' => $this->p->t('konto', 'buchungsdatum')
|
||||
],
|
||||
'buchungstext' => [
|
||||
'field' => "buchungstext",
|
||||
'title' => $this->p->t('konto', 'buchungstext')
|
||||
],
|
||||
'betrag' => [
|
||||
'field' => "betrag",
|
||||
'title' => $this->p->t('konto', 'betrag')
|
||||
],
|
||||
'studiensemester_kurzbz' => [
|
||||
'field' => "studiensemester_kurzbz",
|
||||
'title' => $this->p->t('lehre', 'studiensemester')
|
||||
],
|
||||
'buchungstyp_kurzbz' => [
|
||||
'field' => "buchungstyp_kurzbz",
|
||||
'title' => $this->p->t('konto', 'buchungstyp'),
|
||||
'visible' => false
|
||||
],
|
||||
'buchungsnr' => [
|
||||
'field' => "buchungsnr",
|
||||
'title' => $this->p->t('konto', 'buchungsnr'),
|
||||
'visible' => false
|
||||
],
|
||||
'insertvon' => [
|
||||
'field' => "insertvon",
|
||||
'title' => $this->p->t('global', 'insertvon'),
|
||||
'visible' => false
|
||||
],
|
||||
'insertamum' => [
|
||||
'field' => "insertamum",
|
||||
'title' => $this->p->t('global', 'insertamum'),
|
||||
'visible' => false
|
||||
],
|
||||
'kuerzel' => [
|
||||
'field' => "kuerzel",
|
||||
'title' => $this->p->t('lehre', 'studiengang'),
|
||||
'visible' => false
|
||||
],
|
||||
'anmerkung' => [
|
||||
'field' => "anmerkung",
|
||||
'title' => $this->p->t('global', 'anmerkung')
|
||||
],
|
||||
'actions' => [
|
||||
'title' => $this->p->t('global', 'actions'),
|
||||
'frozen' => true
|
||||
]
|
||||
];
|
||||
}
|
||||
protected function kontoColumnsMultiPerson()
|
||||
{
|
||||
return [
|
||||
'person_id' => [
|
||||
'field' => "person_id",
|
||||
'title' => $this->p->t('person', 'person_id')
|
||||
],
|
||||
'anrede' => [
|
||||
'field' => "anrede",
|
||||
'title' => $this->p->t('person', 'anrede'),
|
||||
'visible' => false
|
||||
],
|
||||
'titelpost' => [
|
||||
'field' => "titelpost",
|
||||
'title' => $this->p->t('person', 'titelpost'),
|
||||
'visible' => false
|
||||
],
|
||||
'titelpre' => [
|
||||
'field' => "titelpre",
|
||||
'title' => $this->p->t('person', 'titelpre'),
|
||||
'visible' => false
|
||||
],
|
||||
'vorname' => [
|
||||
'field' => "vorname",
|
||||
'title' => $this->p->t('person', 'vorname')
|
||||
],
|
||||
'vornamen' => [
|
||||
'field' => "vornamen",
|
||||
'title' => $this->p->t('person', 'vornamen'),
|
||||
'visible' => false
|
||||
],
|
||||
'nachname' => [
|
||||
'field' => "nachname",
|
||||
'title' => $this->p->t('person', 'nachname')
|
||||
]
|
||||
] + $this->kontoColumns();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the back-end
|
||||
* Provides data to the ajax get calls about favorite verbände
|
||||
* Listens to ajax post calls to change the favorite verbände data
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Favorites extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'index' => self::PERM_LOGGED,
|
||||
'set' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
// Load models
|
||||
$this->load->model('system/Variable_model', 'VariableModel');
|
||||
|
||||
// TODO(chris): variable table might be to small to store favorites!
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$result = $this->VariableModel->getVariables(getAuthUID(), ['stv_favorites']);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$data)
|
||||
$this->terminateWithSuccess(null);
|
||||
else
|
||||
$this->terminateWithSuccess($data['stv_favorites']);
|
||||
}
|
||||
|
||||
public function set()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('favorites', 'Favorites', 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$favorites = $this->input->post('favorites');
|
||||
|
||||
$result = $this->VariableModel->setVariable(getAuthUID(), 'stv_favorites', $favorites);
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the back-end
|
||||
* Provides data to the ajax get calls about the Studiengang filter
|
||||
* Listens to ajax post calls to change the Studiengang filter data
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Filter extends FHCAPI_Controller
|
||||
{
|
||||
/**
|
||||
* Calls the parent's constructor and prepares libraries and phrases
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getStg' => self::PERM_LOGGED,
|
||||
'setStg' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
// Load models
|
||||
$this->load->model('system/Variable_model', 'VariableModel');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Get current setting
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getStg()
|
||||
{
|
||||
$result = $this->VariableModel->getVariables(getAuthUID(), ['kontofilterstg']);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data['kontofilterstg'] == 'true');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current setting
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setStg()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$studiengang_kz = $this->input->post('studiengang_kz');
|
||||
|
||||
if ($studiengang_kz === null) {
|
||||
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$result = $this->VariableModel->setVariable(getAuthUID(), 'kontofilterstg', $studiengang_kz ? 'true' : 'false');
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,754 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class Kontakt extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getAdressen' => ['admin:r', 'assistenz:r'],
|
||||
'addNewAddress' => ['admin:rw', 'assistenz:rw'],
|
||||
'addNewContact' => ['admin:rw', 'assistenz:rw'],
|
||||
'addNewBankverbindung' => ['mitarbeiter/bankdaten:rw', 'student/bankdaten:rw'],
|
||||
'updateAddress' => ['admin:rw', 'assistenz:rw'],
|
||||
'updateContact' => ['admin:rw', 'assistenz:rw'],
|
||||
'updateBankverbindung' => ['mitarbeiter/bankdaten:rw', 'student/bankdaten:rw'],
|
||||
'loadAddress' => ['admin:r', 'assistenz:r'],
|
||||
'loadContact' => ['admin:r', 'assistenz:r'],
|
||||
'loadBankverbindung' => ['mitarbeiter/bankdaten:r', 'student/bankdaten:r'],
|
||||
'deleteAddress' => ['admin:rw', 'assistenz:rw'],
|
||||
'deleteContact' => ['admin:rw','assistenz:rw'],
|
||||
'deleteBankverbindung' => ['mitarbeiter/bankdaten:rw','astudent/bankdaten:rw'],
|
||||
'getAdressentypen' => ['admin:r', 'assistenz:r'],
|
||||
'getKontakttypen' => ['admin:r', 'assistenz:r'],
|
||||
'getFirmen' => ['admin:r', 'assistenz:r'],
|
||||
'getStandorte' => ['admin:r', 'assistenz:r'],
|
||||
'getStandorteByFirma' => ['admin:r', 'assistenz:r'],
|
||||
'getKontakte' => ['admin:r', 'assistenz:r'],
|
||||
'getBankverbindung' => ['mitarbeiter/bankdaten:r', 'student/bankdaten:r']
|
||||
]);
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('form_validation');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui',
|
||||
'person'
|
||||
]);
|
||||
|
||||
// Load models
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
$this->load->model('organisation/standort_model', 'StandortModel');
|
||||
$this->load->model('ressource/firma_model', 'FirmaModel');
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
|
||||
// Extra Permissionchecks
|
||||
$permsMa = [];
|
||||
$permsStud = [];
|
||||
switch ($this->router->method) {
|
||||
case 'getBankverbindung':
|
||||
case 'loadBankverbindung':
|
||||
$permsMa = ['mitarbeiter/bankdaten:r'];
|
||||
$permsStud = ['student/bankdaten:r'];
|
||||
break;
|
||||
case 'addNewBankverbindung':
|
||||
case 'updateBankverbindung':
|
||||
case 'deleteBankverbindung':
|
||||
$permsMa = ['mitarbeiter/bankdaten:rw'];
|
||||
$permsStud = ['student/bankdaten:rw'];
|
||||
break;
|
||||
case 'getAdressen':
|
||||
case 'getKontakte':
|
||||
case 'loadAddress':
|
||||
case 'loadContact':
|
||||
$permsMa = $permsStud = ['admin:r', 'assistenz:r'];
|
||||
break;
|
||||
case 'addNewAddress':
|
||||
case 'addNewContact':
|
||||
case 'updateAddress':
|
||||
case 'updateContact':
|
||||
case 'deleteAddress':
|
||||
case 'deleteContact':
|
||||
$permsMa = $permsStud = ['admin:rw', 'assistenz:rw'];
|
||||
break;
|
||||
}
|
||||
if ($this->router->method == 'getAdressen'
|
||||
|| $this->router->method == 'getKontakte'
|
||||
|| $this->router->method == 'getBankverbindung'
|
||||
|| $this->router->method == 'addNewAddress'
|
||||
|| $this->router->method == 'addNewContact'
|
||||
|| $this->router->method == 'addNewBankverbindung'
|
||||
) {
|
||||
$person_id = current(array_slice($this->uri->rsegments, 2));
|
||||
|
||||
$this->checkPermissionsForPerson($person_id, $permsMa, $permsStud);
|
||||
} elseif ($this->router->method == 'loadAddress'
|
||||
|| $this->router->method == 'loadContact'
|
||||
|| $this->router->method == 'loadBankverbindung'
|
||||
|| $this->router->method == 'updateAddress'
|
||||
|| $this->router->method == 'updateContact'
|
||||
|| $this->router->method == 'updateBankverbindung'
|
||||
|| $this->router->method == 'deleteAddress'
|
||||
|| $this->router->method == 'deleteContact'
|
||||
|| $this->router->method == 'deleteBankverbindung'
|
||||
) {
|
||||
$id = current(array_slice($this->uri->rsegments, 2));
|
||||
|
||||
$model = 'person/Adresse_model';
|
||||
if ($this->router->method == 'loadContact'
|
||||
|| $this->router->method == 'updateContact'
|
||||
|| $this->router->method == 'deleteContact'
|
||||
) {
|
||||
$model = 'person/Kontakt_model';
|
||||
} elseif ($this->router->method == 'loadBankverbindung'
|
||||
|| $this->router->method == 'updateBankverbindung'
|
||||
|| $this->router->method == 'deleteBankverbindung'
|
||||
) {
|
||||
$model = 'person/Bankverbindung_model';
|
||||
}
|
||||
|
||||
$this->load->model($model, 'TempModel');
|
||||
$result = $this->TempModel->load($id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
if (!$result)
|
||||
show_404();
|
||||
|
||||
$person_id = current($data)->person_id;
|
||||
|
||||
$this->checkPermissionsForPerson($person_id, $permsMa, $permsStud);
|
||||
}
|
||||
}
|
||||
public function getAdressen($person_id)
|
||||
{
|
||||
$this->AdresseModel->addSelect('public.tbl_adresse.*');
|
||||
$this->AdresseModel->addSelect('t.*');
|
||||
$this->AdresseModel->addSelect('f.firma_id');
|
||||
$this->AdresseModel->addSelect('f.name as firmenname');
|
||||
$this->AdresseModel->addJoin('public.tbl_adressentyp t', 'ON (t.adressentyp_kurzbz = public.tbl_adresse.typ)');
|
||||
$this->AdresseModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = public.tbl_adresse.firma_id)', 'LEFT');
|
||||
|
||||
$result = $this->AdresseModel->loadWhere(
|
||||
array('person_id' => $person_id)
|
||||
);
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess((getData($result) ?: []));
|
||||
}
|
||||
|
||||
public function addNewAddress($person_id)
|
||||
{
|
||||
$this->form_validation->set_rules('plz', 'PLZ', 'required|numeric', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'PLZ']),
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'PLZ'])
|
||||
]);
|
||||
|
||||
if(isset($_POST['gemeinde']) && isset($_POST['ort']))
|
||||
$this->form_validation->set_rules('plz', 'Postleitzahl', 'callback_validateLocationCombination', [
|
||||
'validateLocationCombination' => $this->p->t('ui', 'error_location_combination')
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$uid = getAuthUID();
|
||||
$co_name = isset($_POST['co_name']) ? $_POST['co_name'] : null;
|
||||
$strasse = isset($_POST['strasse']) ? $_POST['strasse'] : null;
|
||||
$ort = isset($_POST['ort']) ? $_POST['ort'] : null;
|
||||
$gemeinde = isset($_POST['gemeinde']) ? $_POST['gemeinde'] : null;
|
||||
$nation = isset($_POST['nation']) ? $_POST['nation'] : null;
|
||||
$name = isset($_POST['name']) ? $_POST['name'] : null;
|
||||
$typ = isset($_POST['typ']) ? $_POST['typ'] : null;
|
||||
$anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null;
|
||||
|
||||
if(isset($_POST['firma']))
|
||||
{
|
||||
$firma_id = $_POST['firma']['firma_id'];
|
||||
}
|
||||
else
|
||||
$firma_id = null;
|
||||
|
||||
$result = $this->AdresseModel->insert(
|
||||
[
|
||||
'person_id' => $person_id,
|
||||
'strasse' => $strasse,
|
||||
'insertvon' => $uid,
|
||||
'insertamum' => date('c'),
|
||||
'plz' => $_POST['plz'],
|
||||
'ort' => $ort,
|
||||
'gemeinde' => $gemeinde,
|
||||
'nation' => $nation,
|
||||
'heimatadresse' => $_POST['heimatadresse'],
|
||||
'zustelladresse' => $_POST['zustelladresse'],
|
||||
'co_name' => $co_name,
|
||||
'typ' => $typ,
|
||||
'firma_id' => $firma_id,
|
||||
'name' => $name,
|
||||
'rechnungsadresse' => $_POST['rechnungsadresse'],
|
||||
'anmerkung' => $anmerkung
|
||||
|
||||
]
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
public function updateAddress($address_id)
|
||||
{
|
||||
$uid = getAuthUID();
|
||||
$this->form_validation->set_rules('plz', 'PLZ', 'required|numeric', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'PLZ']),
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'PLZ'])
|
||||
]);
|
||||
|
||||
if(isset($_POST['gemeinde']) && isset($_POST['ort']))
|
||||
$this->form_validation->set_rules('plz', 'Postleitzahl', 'callback_validateLocationCombination', [
|
||||
'validateLocationCombination' => $this->p->t('ui', 'error_location_combination')
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
|
||||
if(!$address_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Adresse_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if(isset($_POST['firma']))
|
||||
{
|
||||
$firma_id = $_POST['firma']['firma_id'];
|
||||
}
|
||||
elseif(isset($_POST['firma_id']))
|
||||
{
|
||||
$firma_id = $_POST['firma_id'];
|
||||
}
|
||||
else
|
||||
$firma_id = null;
|
||||
|
||||
$person_id = isset($_POST['person_id']) ? $_POST['person_id'] : null;
|
||||
$co_name = isset($_POST['co_name']) ? $_POST['co_name'] : null;
|
||||
$strasse = isset($_POST['strasse']) ? $_POST['strasse'] : null;
|
||||
$ort = isset($_POST['ort']) ? $_POST['ort'] : null;
|
||||
$gemeinde = isset($_POST['gemeinde']) ? $_POST['gemeinde'] : null;
|
||||
$nation = isset($_POST['nation']) ? $_POST['nation'] : null;
|
||||
$name = isset($_POST['name']) ? $_POST['name'] : null;
|
||||
$typ = isset($_POST['typ']) ? $_POST['typ'] : null;
|
||||
$anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null;
|
||||
|
||||
$result = $this->AdresseModel->update(
|
||||
[
|
||||
'adresse_id' => $address_id
|
||||
],
|
||||
[ 'person_id' => $person_id,
|
||||
'strasse' => $strasse,
|
||||
'updatevon' => $uid,
|
||||
'updateamum' => date('c'),
|
||||
'plz' => $_POST['plz'],
|
||||
'ort' => $ort,
|
||||
'gemeinde' => $gemeinde,
|
||||
'nation' => $nation,
|
||||
'heimatadresse' => $_POST['heimatadresse'],
|
||||
'zustelladresse' => $_POST['zustelladresse'],
|
||||
'co_name' => $co_name,
|
||||
'typ' => $typ,
|
||||
'firma_id' => $firma_id,
|
||||
'name' => $name,
|
||||
'rechnungsadresse' => $_POST['rechnungsadresse'],
|
||||
'anmerkung' => $anmerkung
|
||||
]
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
public function loadAddress($adresse_id)
|
||||
{
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
|
||||
$this->AdresseModel->addSelect('public.tbl_adresse.*');
|
||||
$this->AdresseModel->addSelect('t.*');
|
||||
$this->AdresseModel->addSelect('f.firma_id');
|
||||
$this->AdresseModel->addSelect('f.name as firmenname');
|
||||
$this->AdresseModel->addJoin('public.tbl_adressentyp t', 'ON (t.adressentyp_kurzbz = public.tbl_adresse.typ)');
|
||||
$this->AdresseModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = public.tbl_adresse.firma_id)', 'LEFT');
|
||||
|
||||
$this->AdresseModel->addLimit(1);
|
||||
|
||||
$result = $this->AdresseModel->loadWhere(
|
||||
array('adresse_id' => $adresse_id)
|
||||
);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if (!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Adresse_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess(current(getData($result)) ? : null);
|
||||
}
|
||||
|
||||
public function deleteAddress($adresse_id)
|
||||
{
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
$result = $this->AdresseModel->load([
|
||||
'adresse_id'=> $adresse_id,
|
||||
]);
|
||||
if(isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$result = current(getData($result));
|
||||
|
||||
if($result->heimatadresse)
|
||||
|
||||
$this->terminateWithError($this->p->t('person', 'error_deleteHomeAdress'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$result = $this->AdresseModel->delete(
|
||||
array('adresse_id' => $adresse_id)
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if (!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Adresse_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
return $this->terminateWithSuccess(current(getData($result)) ? : null);
|
||||
}
|
||||
|
||||
public function getAdressentypen()
|
||||
{
|
||||
$this->load->model('person/Adressentyp_model', 'AdressentypModel');
|
||||
|
||||
$result = $this->AdressentypModel->load();
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
|
||||
public function getFirmen($searchString)
|
||||
{
|
||||
$this->load->model('ressource/firma_model', 'FirmaModel');
|
||||
|
||||
$result = $this->FirmaModel->searchFirmen($searchString);
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess($result ?: []);
|
||||
}
|
||||
|
||||
public function getStandorte($searchString)
|
||||
{
|
||||
$this->load->model('organisation/standort_model', 'StandortModel');
|
||||
|
||||
$result = $this->StandortModel->searchStandorte($searchString);
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess($result ?: []);
|
||||
}
|
||||
|
||||
public function getStandorteByFirma($firma_id)
|
||||
{
|
||||
$this->load->model('organisation/standort_model', 'StandortModel');
|
||||
|
||||
$result = $this->StandortModel->getStandorteByFirma($firma_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getKontakte($person_id)
|
||||
{
|
||||
$this->KontaktModel->addSelect("public.tbl_kontakt.*,
|
||||
TO_CHAR (CASE
|
||||
WHEN public.tbl_kontakt.updateamum >= public.tbl_kontakt.insertamum
|
||||
THEN public.tbl_kontakt.updateamum
|
||||
ELSE public.tbl_kontakt.insertamum
|
||||
END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate, st.bezeichnung, f.name");
|
||||
$this->StandortModel->addJoin('public.tbl_standort st', 'ON (public.tbl_kontakt.standort_id = st.standort_id)', 'LEFT');
|
||||
$this->FirmaModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = st.firma_id)', 'LEFT');
|
||||
$result = $this->KontaktModel->loadWhere(
|
||||
array('person_id' => $person_id)
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess((getData($result) ?: []));
|
||||
}
|
||||
|
||||
public function getKontakttypen()
|
||||
{
|
||||
$this->load->model('person/Kontakttyp_model', 'KontakttypModel');
|
||||
|
||||
$result = $this->KontakttypModel->load();
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
}
|
||||
|
||||
public function loadContact($kontakt_id)
|
||||
{
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
|
||||
$this->KontaktModel->addSelect('*, public.tbl_kontakt.*');
|
||||
$this->KontaktModel->addSelect('st.kurzbz');
|
||||
$this->KontaktModel->addJoin('public.tbl_standort st', 'ON (public.tbl_kontakt.standort_id = st.standort_id)', 'LEFT');
|
||||
$this->FirmaModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = st.firma_id)', 'LEFT');
|
||||
|
||||
$this->KontaktModel->addLimit(1);
|
||||
|
||||
$result = $this->KontaktModel->loadWhere(
|
||||
array('kontakt_id' => $kontakt_id)
|
||||
);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if (!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Kontakt_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
// $this->outputJsonSuccess(current(getData($result)));
|
||||
$this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
|
||||
public function addNewContact($person_id)
|
||||
{
|
||||
if(($_POST['kontakttyp'] == 'email' && isset($_POST['kontakt'])))
|
||||
{
|
||||
$this->form_validation->set_rules('kontakt', 'Kontakt', 'required|valid_email', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Kontakt']),
|
||||
'valid_email' => $this->p->t('ui', 'error_fieldNoValidEmail', ['field' => 'Kontakt'])
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->form_validation->set_rules('kontakt', 'Kontakt', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Kontakt'])
|
||||
]);
|
||||
}
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
|
||||
$uid = getAuthUID();
|
||||
|
||||
$kontakttyp = $this->input->post('kontakttyp');
|
||||
$anmerkung = $this->input->post('anmerkung');
|
||||
$kontakt = $this->input->post('kontakt');
|
||||
$ext_id = $this->input->post('ext_id');
|
||||
$standort_id = $this->input->post('standort_id');
|
||||
|
||||
$result = $this->KontaktModel->insert(
|
||||
[
|
||||
'person_id' => $person_id,
|
||||
'kontakttyp' => $kontakttyp,
|
||||
'anmerkung' => $anmerkung,
|
||||
'kontakt' => $kontakt,
|
||||
'zustellung' => $_POST['zustellung'],
|
||||
'insertvon' => $uid,
|
||||
'insertamum' => date('c'),
|
||||
'standort_id' => $standort_id,
|
||||
'ext_id' => $ext_id
|
||||
]
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
public function updateContact($kontakt_id)
|
||||
{
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
|
||||
if(!$kontakt_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Kontakt_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if(($_POST['kontakttyp'] == 'email' && isset($_POST['kontakt'])))
|
||||
{
|
||||
$this->form_validation->set_rules('kontakt', 'Kontakt', 'required|valid_email', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Kontakt']),
|
||||
'valid_email' => $this->p->t('ui', 'error_fieldNoValidEmail', ['field' => 'Kontakt'])
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->form_validation->set_rules('kontakt', 'Kontakt', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Kontakt'])
|
||||
]);
|
||||
}
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
/* if(isset($_POST['standort']))
|
||||
{
|
||||
$standort_id = $_POST['standort']['standort_id'];
|
||||
}
|
||||
else
|
||||
$standort_id = null;*/
|
||||
|
||||
$uid = getAuthUID();
|
||||
$kontakttyp = $this->input->post('kontakttyp');
|
||||
$anmerkung = $this->input->post('anmerkung');
|
||||
$kontakt = $this->input->post('kontakt');
|
||||
$ext_id = $this->input->post('ext_id');
|
||||
$person_id = $this->input->post('person_id');
|
||||
$standort_id = $this->input->post('standort_id');
|
||||
|
||||
//return $this->terminateWithError("in update " . $standort_id, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$result = $this->KontaktModel->update(
|
||||
[
|
||||
'kontakt_id' => $kontakt_id
|
||||
],
|
||||
[
|
||||
'person_id' => $person_id,
|
||||
'kontakttyp' => $kontakttyp,
|
||||
'anmerkung' => $anmerkung,
|
||||
'kontakt' => $kontakt,
|
||||
'zustellung' => $_POST['zustellung'],
|
||||
'insertvon' => $uid,
|
||||
'insertamum' => date('c'),
|
||||
'standort_id' => $standort_id,
|
||||
'ext_id' => $ext_id
|
||||
]
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
public function deleteContact($kontakt_id)
|
||||
{
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
|
||||
$result = $this->KontaktModel->delete(
|
||||
array('kontakt_id' => $kontakt_id)
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
elseif (!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Kontakt_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(current(getData($result)) ? : null);
|
||||
}
|
||||
|
||||
public function getBankverbindung($person_id)
|
||||
{
|
||||
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
|
||||
|
||||
$this->BankverbindungModel->addSelect('*');
|
||||
|
||||
$result = $this->BankverbindungModel->loadWhere(
|
||||
array('person_id' => $person_id)
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess((getData($result) ?: []));
|
||||
}
|
||||
|
||||
public function addNewBankverbindung($person_id)
|
||||
{
|
||||
$this->form_validation->set_rules('iban', 'IBAN', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'IBAN'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('typ', 'TYP', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'TYP'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
|
||||
|
||||
$ext_id = $this->input->post('ext_id');
|
||||
$oe_kurzbz = $this->input->post('oe_kurzbz');
|
||||
$orgform_kurzbz = $this->input->post('orgform_kurzbz');
|
||||
$name = $this->input->post('name');
|
||||
$anschrift = $this->input->post('anschrift');
|
||||
$bic = $this->input->post('bic');
|
||||
$blz = $this->input->post('blz');
|
||||
$kontonr = $this->input->post('kontonr');
|
||||
|
||||
$result = $this->BankverbindungModel->insert(
|
||||
[
|
||||
'person_id' => $person_id,
|
||||
'name' => $name,
|
||||
'anschrift' => $anschrift,
|
||||
'bic' => $bic,
|
||||
'iban' => $_POST['iban'],
|
||||
'blz' => $blz,
|
||||
'kontonr' => $kontonr,
|
||||
'insertvon' => 'uid',
|
||||
'insertamum' => date('c'),
|
||||
'typ' => $_POST['typ'],
|
||||
'verrechnung' => $_POST['verrechnung'],
|
||||
'ext_id' => $ext_id,
|
||||
'oe_kurzbz' => $oe_kurzbz,
|
||||
'orgform_kurzbz' => $orgform_kurzbz
|
||||
]
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
public function loadBankverbindung($bankverbindung_id)
|
||||
{
|
||||
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
|
||||
|
||||
$this->BankverbindungModel->addSelect('*');
|
||||
|
||||
$this->BankverbindungModel->addLimit(1);
|
||||
|
||||
$result = $this->BankverbindungModel->loadWhere(
|
||||
array('bankverbindung_id' => $bankverbindung_id)
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if (!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Bankverbindung_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
|
||||
public function updateBankverbindung($bankverbindung_id)
|
||||
{
|
||||
$this->form_validation->set_rules('iban', 'IBAN', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'IBAN'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('typ', 'TYP', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'TYP'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
|
||||
|
||||
if(!$bankverbindung_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Bankverbindung_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$uid = getAuthUID();
|
||||
|
||||
$result = $this->BankverbindungModel->update(
|
||||
[
|
||||
'bankverbindung_id' => $bankverbindung_id
|
||||
],
|
||||
[
|
||||
'person_id' => $_POST['person_id'],
|
||||
'name' => $_POST['name'],
|
||||
'anschrift' => $_POST['anschrift'],
|
||||
'bic' => $_POST['bic'],
|
||||
'iban' => $_POST['iban'],
|
||||
'blz' => $_POST['blz'],
|
||||
'kontonr' => $_POST['kontonr'],
|
||||
'updatevon' => $uid,
|
||||
'updateamum' => date('c'),
|
||||
'typ' => $_POST['typ'],
|
||||
'verrechnung' => $_POST['verrechnung'],
|
||||
'ext_id' => $_POST['ext_id'],
|
||||
'oe_kurzbz' => $_POST['oe_kurzbz'],
|
||||
'orgform_kurzbz' => $_POST['orgform_kurzbz']
|
||||
]
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
public function deleteBankverbindung($bankverbindung_id)
|
||||
{
|
||||
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
|
||||
|
||||
$result = $this->BankverbindungModel->delete(
|
||||
array('bankverbindung_id' => $bankverbindung_id)
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if (!hasData($result))
|
||||
{
|
||||
$this->outputJson($result);
|
||||
}
|
||||
return $this->terminateWithSuccess(current(getData($result)) ? : null);
|
||||
}
|
||||
|
||||
public function validateLocationCombination()
|
||||
{
|
||||
$this->load->model('codex/Gemeinde_model', 'GemeindeModel');
|
||||
|
||||
return $this->GemeindeModel->checkLocation($_POST['plz'], $_POST['gemeinde'], $_POST['ort']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,495 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use CI3_Events as Events;
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the back-end
|
||||
* Provides data to the ajax get calls about a Konto
|
||||
* Listens to ajax post calls to change the Konto data
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Konto extends FHCAPI_Controller
|
||||
{
|
||||
/**
|
||||
* Calls the parent's constructor and prepares libraries and phrases
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'get' => 'student/stammdaten:r',
|
||||
'getBuchungstypen' => self::PERM_LOGGED,
|
||||
'checkDoubles' => ['admin:r', 'assistenz:r'],
|
||||
'insert' => ['admin:w', 'assistenz:w'],
|
||||
'counter' => ['admin:w', 'assistenz:w'],
|
||||
'update' => ['admin:w', 'assistenz:w'],
|
||||
'delete' => ['admin:w', 'assistenz:w']
|
||||
]);
|
||||
|
||||
// Load models
|
||||
$this->load->model('crm/Konto_model', 'KontoModel');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'konto'
|
||||
]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Get details for a prestudent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$person_id = $this->input->post('person_id');
|
||||
if (!$person_id || !is_array($person_id)) {
|
||||
$this->form_validation->set_rules('person_id', 'Person ID', 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
|
||||
$studiengang_kz = $this->input->post('studiengang_kz');
|
||||
|
||||
if ($this->input->post('only_open')) {
|
||||
$result = $this->KontoModel->getOffeneBuchungen($person_id, $studiengang_kz);
|
||||
} else {
|
||||
$result = $this->KontoModel->getAlleBuchungen($person_id, $studiengang_kz);
|
||||
}
|
||||
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
// sort into tree
|
||||
$childs = [];
|
||||
$data = [];
|
||||
foreach ($result as $entry) {
|
||||
if ($entry->buchungsnr_verweis) {
|
||||
if (isset($data[$entry->buchungsnr_verweis])) {
|
||||
if (!isset($data[$entry->buchungsnr_verweis]->_children))
|
||||
$data[$entry->buchungsnr_verweis]->_children = [];
|
||||
$data[$entry->buchungsnr_verweis]->_children[] = $entry;
|
||||
} else {
|
||||
if (!isset($childs[$entry->buchungsnr_verweis]))
|
||||
$childs[$entry->buchungsnr_verweis] = [];
|
||||
$childs[$entry->buchungsnr_verweis][] = $entry;
|
||||
}
|
||||
} else {
|
||||
$data[$entry->buchungsnr] = $entry;
|
||||
if (isset($childs[$entry->buchungsnr]))
|
||||
$entry->_children = $childs[$entry->buchungsnr];
|
||||
}
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess(array_values($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of Buchungstypen
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getBuchungstypen()
|
||||
{
|
||||
$this->load->model('crm/Buchungstyp_model', 'BuchungstypModel');
|
||||
|
||||
$result = $this->BuchungstypModel->load();
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check double Buchungen
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function checkDoubles()
|
||||
{
|
||||
if (!defined('FAS_DOPPELTE_BUCHUNGSTYPEN_CHECK') || !FAS_DOPPELTE_BUCHUNGSTYPEN_CHECK)
|
||||
$this->terminateWithSuccess(false);
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$person_ids = $this->input->post('person_id');
|
||||
|
||||
if (!$person_ids || !is_array($person_ids)) {
|
||||
$person_ids = [$person_ids];
|
||||
$this->form_validation->set_rules('person_id', 'Person ID', 'required');
|
||||
}
|
||||
$this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required');
|
||||
$this->form_validation->set_rules('buchungstyp_kurzbz', 'Buchungstyp', 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
|
||||
$buchungstypen = unserialize(FAS_DOPPELTE_BUCHUNGSTYPEN_CHECK);
|
||||
$buchung = $this->input->post('buchungstyp_kurzbz');
|
||||
|
||||
if (!isset($buchungstypen[$buchung]))
|
||||
$this->terminateWithSuccess(false);
|
||||
|
||||
$result = $this->KontoModel->checkDoubleBuchung($person_ids, $this->input->post('studiensemester_kurzbz'), $buchungstypen[$buchung]);
|
||||
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$result)
|
||||
$this->terminateWithSuccess(false);
|
||||
|
||||
$persons = array_map(function ($row) {
|
||||
return $row->nachname . ' ' . $row->vorname;
|
||||
}, $result);
|
||||
|
||||
$result = $this->p->t('konto', 'confirm_overwrite') . "\n";
|
||||
if (count($persons) > 10) {
|
||||
$result .= "-" . implode("\n-", array_slice($persons, 0, 10)) . "\n";
|
||||
|
||||
if (count($persons) == 11) {
|
||||
$result .= "\n" . $this->p->t('konto', 'confirm_overwrite_1_add_pers');
|
||||
} else {
|
||||
$result .= "\n" . $this->p->t('konto', 'confirm_overwrite_x_add_pers', [
|
||||
'x' => count($persons) - 10
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$result .= "-" . implode("\n-", $persons) . "\n";
|
||||
}
|
||||
$result .= $this->p->t('konto', 'confirm_overwrite_proceed');
|
||||
|
||||
$this->addError($result, 'confirm');
|
||||
|
||||
$this->terminateWithSuccess(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save Buchung
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function insert()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$person_ids = $this->input->post('person_id');
|
||||
|
||||
if (!$person_ids || !is_array($person_ids)) {
|
||||
$person_ids = [$person_ids];
|
||||
$this->form_validation->set_rules('person_id', 'Person ID', 'required');
|
||||
}
|
||||
$this->form_validation->set_rules('betrag', 'Betrag', 'numeric');
|
||||
$this->form_validation->set_rules('buchungsdatum', 'Buchungsdatum', 'is_valid_date');
|
||||
$this->form_validation->set_rules('buchungstext', 'Buchungstext', 'max_length[256]');
|
||||
$this->form_validation->set_rules('mahnspanne', 'Mahnspanne', 'integer');
|
||||
$this->form_validation->set_rules('buchungstyp_kurzbz', 'Buchungstyp', 'required|max_length[32]');
|
||||
$this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required|max_length[16]');
|
||||
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required|has_permissions_for_stg[admin:rw,assistenz:rw]');
|
||||
$this->form_validation->set_rules('credit_points', 'Credit Points', 'numeric');
|
||||
|
||||
Events::trigger('konto_insert_validation', $this->form_validation);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
|
||||
$allowed = [
|
||||
'betrag',
|
||||
'buchungsdatum',
|
||||
'buchungstext',
|
||||
'mahnspanne',
|
||||
'buchungstyp_kurzbz',
|
||||
'studiensemester_kurzbz',
|
||||
'studiengang_kz',
|
||||
'credit_points',
|
||||
'anmerkung'
|
||||
];
|
||||
$data = [
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => getAuthUID()
|
||||
];
|
||||
foreach ($allowed as $field)
|
||||
if ($this->input->post($field) !== null)
|
||||
$data[$field] = $this->input->post($field);
|
||||
|
||||
if (defined('FAS_BUCHUNGSTYP_FIXE_KOSTENSTELLE') && isset(unserialize(FAS_BUCHUNGSTYP_FIXE_KOSTENSTELLE)[$data['buchungstyp_kurzbz']])) {
|
||||
$data['kostenstelle'] = unserialize(FAS_BUCHUNGSTYP_FIXE_KOSTENSTELLE)[$data['buchungstyp_kurzbz']];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($person_ids as $person_id) {
|
||||
$id = $this->KontoModel->insert(array_merge($data, ['person_id' => $person_id]));
|
||||
if (isError($id)) {
|
||||
$this->addError(getError($id), self::ERROR_TYPE_DB);
|
||||
} else {
|
||||
$kontodata = $this->KontoModel->withAdditionalInfo()->load(getData($id));
|
||||
if (isError($kontodata))
|
||||
$this->addError(getError($kontodata), self::ERROR_TYPE_DB);
|
||||
else
|
||||
$result[] = current(getData($kontodata));
|
||||
}
|
||||
}
|
||||
|
||||
if ($result)
|
||||
$this->terminateWithSuccess($result);
|
||||
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Counter Buchung
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function counter()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$buchungsnrs = $this->input->post('buchungsnr');
|
||||
|
||||
if (!$buchungsnrs || !is_array($buchungsnrs)) {
|
||||
$buchungsnrs = $buchungsnrs ? [$buchungsnrs] : [];
|
||||
$this->form_validation->set_rules('buchungsnr', 'Buchungsnr', 'required');
|
||||
}
|
||||
$this->form_validation->set_rules('buchungsdatum', 'Buchungsdatum', 'is_valid_date');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$data = [];
|
||||
$rules = [];
|
||||
foreach ($buchungsnrs as $k => $buchungsnr) {
|
||||
$result = $this->KontoModel->load($buchungsnr);
|
||||
if (isError($result)) {
|
||||
$rules[] = [
|
||||
'field' => 'buchung[' . $k . ']',
|
||||
'label' => 'Buchung #' . $buchungsnr,
|
||||
'rules' => 'required',
|
||||
'errors' => [
|
||||
'required' => getError($result)
|
||||
]
|
||||
];
|
||||
} elseif (!hasData($result)) {
|
||||
$rules[] = [
|
||||
'field' => 'buchung[' . $k . ']',
|
||||
'label' => 'Buchung #' . $buchungsnr,
|
||||
'rules' => 'required'
|
||||
];
|
||||
} else {
|
||||
$data[$k] = get_object_vars(current(getData($result)));
|
||||
$rules[] = [
|
||||
'field' => 'buchung[' . $k . '][buchungsnr]',
|
||||
'label' => 'Buchung # ' . $buchungsnr,
|
||||
'rules' => 'required|numeric'
|
||||
];
|
||||
$rules[] = [
|
||||
'field' => 'buchung[' . $k . '][studiengang_kz]',
|
||||
'label' => 'Buchung # ' . $buchungsnr,
|
||||
'rules' => 'required|has_permissions_for_stg[admin:rw,assistenz:rw]'
|
||||
];
|
||||
$rules[] = [
|
||||
'field' => 'buchung[' . $k . '][buchungsnr_verweis]',
|
||||
'label' => 'Buchung # ' . $buchungsnr,
|
||||
'rules' => 'regex_match[/^$/]',
|
||||
'errors' => [
|
||||
'regex_match' => $this->p->t('konto', 'error_counter_level')
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$this->form_validation->reset_validation();
|
||||
$this->form_validation->set_data(['buchung' => $data]);
|
||||
$this->form_validation->set_rules($rules);
|
||||
|
||||
Events::trigger('konto_counter_validation', $this->form_validation);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$buchungsdatum = $this->input->post('buchungsdatum');
|
||||
|
||||
$newItems = [];
|
||||
foreach ($data as $buchung) {
|
||||
$result = $this->KontoModel->getDifferenz($buchung['buchungsnr']);
|
||||
if (isError($result)) {
|
||||
$this->addError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
continue;
|
||||
}
|
||||
$betrag = $result->retval;
|
||||
if ($betrag === null) {
|
||||
$this->addError($this->p->t(
|
||||
'konto',
|
||||
'error_missing',
|
||||
$buchung
|
||||
), self::ERROR_TYPE_GENERAL);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$result = $this->KontoModel->insert([
|
||||
'person_id' => $buchung['person_id'],
|
||||
'studiengang_kz' => $buchung['studiengang_kz'],
|
||||
'studiensemester_kurzbz' => $buchung['studiensemester_kurzbz'],
|
||||
'buchungstext' => $buchung['buchungstext'],
|
||||
'buchungstyp_kurzbz' => $buchung['buchungstyp_kurzbz'],
|
||||
'credit_points' => $buchung['credit_points'],
|
||||
'zahlungsreferenz' => $buchung['zahlungsreferenz'],
|
||||
'betrag' => $betrag,
|
||||
'buchungsdatum' => $buchungsdatum,
|
||||
'mahnspanne' => '0',
|
||||
'buchungsnr_verweis' => $buchung['buchungsnr'],
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => getAuthUID(),
|
||||
'anmerkung' => ''
|
||||
]);
|
||||
if (isError($result)) {
|
||||
$this->addError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
continue;
|
||||
}
|
||||
|
||||
$newItems = null;
|
||||
// TODO(chris): get as tree?
|
||||
/*$result = $this->KontoModel->withAdditionalInfo()->load($result->retval);
|
||||
if (!hasData($result))
|
||||
$newItems = null;
|
||||
elseif ($newItems !== null)
|
||||
$newItems[] = current(getData($result));*/
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($newItems);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Buchung
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('buchungsnr', 'Buchungsnr', 'required');
|
||||
$this->form_validation->set_rules('betrag', 'Betrag', 'numeric');
|
||||
$this->form_validation->set_rules('buchungsdatum', 'Buchungsdatum', 'is_valid_date');
|
||||
$this->form_validation->set_rules('buchungstext', 'Buchungstext', 'max_length[256]');
|
||||
$this->form_validation->set_rules('mahnspanne', 'Mahnspanne', 'integer');
|
||||
$this->form_validation->set_rules('buchungstyp_kurzbz', 'Buchungstyp', 'required|max_length[32]');
|
||||
$this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required|max_length[16]');
|
||||
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required|has_permissions_for_stg[admin:rw,assistenz:rw]');
|
||||
$this->form_validation->set_rules('credit_points', 'Credit Points', 'numeric');
|
||||
|
||||
Events::trigger('konto_update_validation', $this->form_validation);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
|
||||
$id = $this->input->post('buchungsnr');
|
||||
$allowed = [
|
||||
'betrag',
|
||||
'buchungsdatum',
|
||||
'buchungstext',
|
||||
'mahnspanne',
|
||||
'buchungstyp_kurzbz',
|
||||
'studiensemester_kurzbz',
|
||||
'studiengang_kz',
|
||||
'credit_points',
|
||||
'anmerkung'
|
||||
];
|
||||
$data = [
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID()
|
||||
];
|
||||
foreach ($allowed as $field)
|
||||
if ($this->input->post($field) !== null)
|
||||
$data[$field] = $this->input->post($field);
|
||||
|
||||
$result = $this->KontoModel->update($id, $data);
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
$result = null;
|
||||
// TODO(chris): get as tree?
|
||||
/*$result = $this->KontoModel->withAdditionalInfo()->load($id);
|
||||
|
||||
#$result = $this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$result = $result->retval;*/
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Buchung
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('buchungsnr', 'Buchungsnr', 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
|
||||
$buchungsnr = $this->input->post('buchungsnr');
|
||||
|
||||
$result = $this->KontoModel->load($buchungsnr);
|
||||
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$result)
|
||||
$this->terminateWithError($this->p->t('konto', 'error_missing', [
|
||||
'buchungsnr' => $buchungsnr
|
||||
]));
|
||||
|
||||
$_POST['studiengang_kz'] = current($result)->studiengang_kz;
|
||||
|
||||
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'has_permissions_for_stg[admin:rw,assistenz:rw]');
|
||||
|
||||
Events::trigger('konto_delete_validation', $this->form_validation);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
|
||||
Events::trigger('konto_delete', $buchungsnr);
|
||||
|
||||
$result = $this->KontoModel->delete($buchungsnr);
|
||||
if (isError($result)) {
|
||||
if (getCode($result) != 42)
|
||||
$this->terminateWithError(getError($result));
|
||||
$this->terminateWithError($this->p->t('konto', 'error_delete_level'));
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the back-end
|
||||
* Provides data to the ajax get calls about generally used lists
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Lists extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getStudiensemester' => self::PERM_LOGGED,
|
||||
'getStgs' => self::PERM_LOGGED,
|
||||
'getSprachen' => self::PERM_LOGGED,
|
||||
'getGeschlechter' => self::PERM_LOGGED,
|
||||
'getAusbildungen' => self::PERM_LOGGED,
|
||||
'getOrgforms' => self::PERM_LOGGED,
|
||||
'getStati' => self::PERM_LOGGED
|
||||
]);
|
||||
}
|
||||
|
||||
public function getStudiensemester()
|
||||
{
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
$this->StudiensemesterModel->addOrder('ende');
|
||||
|
||||
$result = $this->StudiensemesterModel->load();
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getStgs()
|
||||
{
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
|
||||
$this->StudiengangModel->addSelect('*');
|
||||
$this->StudiengangModel->addSelect('UPPER(typ || kurzbz) AS kuerzel');
|
||||
|
||||
$this->StudiengangModel->addOrder('typ');
|
||||
$this->StudiengangModel->addOrder('kurzbz');
|
||||
|
||||
$result = $this->StudiengangModel->load();
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getSprachen()
|
||||
{
|
||||
$this->load->model('system/Sprache_model', 'SpracheModel');
|
||||
|
||||
$this->SpracheModel->addOrder('sprache');
|
||||
|
||||
$result = $this->SpracheModel->load();
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getGeschlechter()
|
||||
{
|
||||
$this->load->model('person/Geschlecht_model', 'GeschlechtModel');
|
||||
|
||||
$this->GeschlechtModel->addOrder('sort');
|
||||
$this->GeschlechtModel->addOrder('geschlecht');
|
||||
|
||||
$this->GeschlechtModel->addSelect('*');
|
||||
#$this->GeschlechtModel->addTranslatedSelect("bezeichnung_mehrsprachig", "bezeichnung");
|
||||
$this->GeschlechtModel->addSelect("bezeichnung_mehrsprachig[(SELECT index FROM public.tbl_sprache WHERE sprache=" . $this->GeschlechtModel->escape(DEFAULT_LANGUAGE) . " LIMIT 1)] AS bezeichnung");
|
||||
|
||||
$result = $this->GeschlechtModel->load();
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getAusbildungen()
|
||||
{
|
||||
$this->load->model('codex/Ausbildung_model', 'AusbildungModel');
|
||||
|
||||
$this->AusbildungModel->addOrder('ausbildungcode');
|
||||
|
||||
$result = $this->AusbildungModel->load();
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getOrgforms()
|
||||
{
|
||||
$this->load->model('codex/Orgform_model', 'OrgformModel');
|
||||
|
||||
$this->OrgformModel->addOrder('bezeichnung');
|
||||
|
||||
$result = $this->OrgformModel->loadWhere(['rolle' => true]);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getStati()
|
||||
{
|
||||
$lang = getUserLanguage();
|
||||
$this->load->model('crm/Status_model', 'StatusModel');
|
||||
|
||||
$this->StatusModel->addSelect('*');
|
||||
#$this->StatusModel->addTranslatedSelect('bezeichnung_mehrsprachig', 'bezeichnung');
|
||||
$this->StatusModel->addSelect(
|
||||
'bezeichnung_mehrsprachig[(
|
||||
SELECT index
|
||||
FROM public.tbl_sprache
|
||||
WHERE sprache=' . $this->StatusModel->escape($lang) . '
|
||||
LIMIT 1
|
||||
)] AS bezeichnung',
|
||||
false
|
||||
);
|
||||
#$this->StatusModel->addOrder('ext_id');
|
||||
|
||||
$result = $this->StatusModel->load();
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,384 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class Notiz extends Notiz_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getUid' => ['admin:r', 'assistenz:r'],
|
||||
'getNotizen' => ['admin:r', 'assistenz:r'],
|
||||
'loadNotiz' => ['admin:r', 'assistenz:r'], // TODO(manu): self::PERM_LOGGED
|
||||
'addNewNotiz' => ['admin:rw', 'assistenz:rw'], // TODO(manu): self::PERM_LOGGED
|
||||
'updateNotiz' => ['admin:rw', 'assistenz:rw'], // TODO(manu): self::PERM_LOGGED
|
||||
'deleteNotiz' => ['admin:r', 'assistenz:r'],
|
||||
'loadDokumente' => ['admin:r', 'assistenz:r'],
|
||||
'getMitarbeiter' => ['admin:r', 'assistenz:r']
|
||||
]);
|
||||
|
||||
//Load Models
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
]);
|
||||
}
|
||||
|
||||
/* public function getUid()
|
||||
{
|
||||
$this->terminateWithSuccess(getAuthUID());
|
||||
}*/
|
||||
|
||||
|
||||
public function getNotizen($id, $type)
|
||||
{
|
||||
|
||||
//check if valid type
|
||||
$result = $this->NotizzuordnungModel->isValidType($type);
|
||||
if(isError($result))
|
||||
$this->terminateWithError($result->retval, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
//$this->terminateWithError(" after check type not valid", self::ERROR_TYPE_GENERAL);
|
||||
$result = $this->NotizModel->getNotizWithDocEntries($id, $type);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result) ?: []);
|
||||
|
||||
// return $this->terminateWithError("type not valid", self::ERROR_TYPE_GENERAL);
|
||||
|
||||
}
|
||||
|
||||
/* public function loadNotiz()
|
||||
{
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
|
||||
//$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'notiz_id', 'LEFT');
|
||||
$this->NotizModel->addSelect('*');
|
||||
$this->NotizModel->addSelect("TO_CHAR(CASE WHEN public.tbl_notiz.updateamum >= public.tbl_notiz.insertamum
|
||||
THEN public.tbl_notiz.updateamum ELSE public.tbl_notiz.insertamum END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate");
|
||||
$this->NotizModel->addLimit(1);
|
||||
|
||||
$result = $this->NotizModel->loadWhere(
|
||||
array('notiz_id' => $notiz_id)
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
elseif (!hasData($result))
|
||||
{
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function updateNotiz()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
if (isset($_POST['data']))
|
||||
{
|
||||
$data = json_decode($_POST['data']);
|
||||
unset($_POST['data']);
|
||||
foreach ($data as $k => $v) {
|
||||
$_POST[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
|
||||
if(!$notiz_id)
|
||||
{
|
||||
$this->terminateWithError($this->p->t('ui','error_missingId',['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//Form Validation
|
||||
$this->form_validation->set_rules('titel', 'Titel', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('text', 'Text', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
//update Notiz
|
||||
$uid = getAuthUID();
|
||||
$titel = $this->input->post('titel');
|
||||
$text = $this->input->post('text');
|
||||
$verfasser_uid = $this->input->post('verfasser');
|
||||
$bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid;
|
||||
$erledigt = $this->input->post('erledigt');
|
||||
$start = $this->input->post('start');
|
||||
$ende = $this->input->post('ende');
|
||||
|
||||
$result = $this->NotizModel->update(
|
||||
[
|
||||
'notiz_id' => $notiz_id
|
||||
],
|
||||
[
|
||||
'titel' => $titel,
|
||||
'updatevon' => $uid,
|
||||
'updateamum' => date('c'),
|
||||
'text' => $text,
|
||||
'verfasser_uid' => $verfasser_uid,
|
||||
'bearbeiter_uid' => $bearbeiter_uid,
|
||||
'start' => $start,
|
||||
'ende' => $ende,
|
||||
'erledigt' => $erledigt
|
||||
]
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//update(1) laden aller bereits mit dieser notiz_id verknüpften DMS-Einträge
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
$this->NotizdokumentModel->addJoin('campus.tbl_dms_version', 'dms_id');
|
||||
$dms_uploaded = null;
|
||||
|
||||
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
elseif (!hasData($result))
|
||||
{
|
||||
$dms_id_arr = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = getData($result);
|
||||
foreach($result as $doc) {
|
||||
$dms_id_arr[] = array(
|
||||
'name' => $doc->name,
|
||||
'dms_id' => $doc->dms_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($_FILES as $k => $file)
|
||||
{
|
||||
//update(2) alle neuen files (alle außer type application/x.fhc-dms+json) anhängen
|
||||
if($file["type"] == 'application/x.fhc-dms+json')
|
||||
{
|
||||
$dms_uploaded[] = array(
|
||||
'name' => $file["name"]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'notiz',
|
||||
'version' => 0,
|
||||
'name' => $file["name"],
|
||||
'mimetype' => $file["type"],
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $uid
|
||||
);
|
||||
|
||||
//Todo(manu) check if filetypes weiter eingeschränkt werden sollen
|
||||
//Todo(manu)check name files: nicht gleiches file 2mal hochladen
|
||||
$result = $this->dmslib->upload($dms, $k, array('*'));
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$dms_id = $result->retval['dms_id'];
|
||||
|
||||
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//update(3) check if Dateien gelöscht wurden
|
||||
if(count($dms_uploaded) != count($dms_id_arr))
|
||||
{
|
||||
if (count($dms_uploaded) == 0)
|
||||
{
|
||||
$filesDeleted = $dms_id_arr;
|
||||
}
|
||||
else
|
||||
{
|
||||
$upload_new_names = array_column($dms_uploaded, "name");
|
||||
|
||||
$filesDeleted = array_filter($dms_id_arr, function ($file) use ($upload_new_names) {
|
||||
return !in_array($file["name"], $upload_new_names);
|
||||
});
|
||||
}
|
||||
|
||||
foreach ($filesDeleted as $file)
|
||||
{
|
||||
$result = $this->dmslib->removeAll($file['dms_id']);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
else
|
||||
$this->outputJson($result);
|
||||
}
|
||||
}
|
||||
return $this->terminateWithSuccess($result);
|
||||
}*/
|
||||
|
||||
|
||||
/* public function deleteNotiz()
|
||||
{
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
$type = $this->input->post('type_id');
|
||||
$id = $this->input->post('id');
|
||||
|
||||
//dms_id auslesen aus notizdokument wenn vorhanden
|
||||
$dms_id_arr = [];
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
|
||||
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if(hasData($result))
|
||||
{
|
||||
$result = getData($result);
|
||||
foreach ($result as $doc) {
|
||||
$dms_id_arr[] = $doc->dms_id;
|
||||
}
|
||||
}
|
||||
|
||||
if($dms_id_arr)
|
||||
{
|
||||
$this->load->library('DmsLib');
|
||||
foreach($dms_id_arr as $dms_id)
|
||||
{
|
||||
$result = $this->dmslib->removeAll($dms_id);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->outputJson($result);
|
||||
}
|
||||
}
|
||||
|
||||
//delete Notizzuordnung
|
||||
if($type == "software_id")
|
||||
{
|
||||
// Loads extension Model
|
||||
$this->load->model('extensions/FHC-Core-Softwarebereitstellung/Softwarenotizzuordnung_model', 'ExtensionnotizzuordnungModel');
|
||||
$result = $this->ExtensionnotizzuordnungModel->delete([
|
||||
'notiz_id' => $notiz_id,
|
||||
'id' => strval($id)
|
||||
],
|
||||
[
|
||||
'type_id' => $type
|
||||
]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//notizzuordnungsid!
|
||||
$result = $this->NotizzuordnungModel->delete(['notiz_id' => $notiz_id, $type => $id]);
|
||||
}
|
||||
|
||||
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
//$this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id');
|
||||
|
||||
//TODO (erweitern um Type_id) für Extensions, damit auch Notizzuordnung gelöscht werden kann
|
||||
|
||||
//Löschen von Notiz
|
||||
$result = $this->NotizModel->delete(
|
||||
array('notiz_id' => $notiz_id)
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if(!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
return $this->terminateWithSuccess(current(getData($result)));
|
||||
}*/
|
||||
|
||||
/* public function loadDokumente()
|
||||
{
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
|
||||
$this->NotizModel->addSelect('campus.tbl_dms_version.*');
|
||||
|
||||
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'ON (public.tbl_notiz_dokument.notiz_id = public.tbl_notiz.notiz_id)');
|
||||
$this->NotizModel->addJoin('campus.tbl_dms_version', 'ON (public.tbl_notiz_dokument.dms_id = campus.tbl_dms_version.dms_id)');
|
||||
|
||||
$result = $this->NotizModel->loadWhere(
|
||||
array('public.tbl_notiz.notiz_id' => $notiz_id)
|
||||
);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if(!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result));
|
||||
}*/
|
||||
|
||||
/* public function getMitarbeiter($searchString)
|
||||
{
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
$result = $this->MitarbeiterModel->searchMitarbeiter($searchString);
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess($result);
|
||||
}*/
|
||||
|
||||
public function isBerechtigt($id, $typeId)
|
||||
{
|
||||
if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid'))
|
||||
{
|
||||
$result = $this->p->t('lehre','error_keineSchreibrechte');
|
||||
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return success("berechtigt in überschreibender Funktion");
|
||||
/* return $this->terminateWithError('keine Berechtigung bro', self::ERROR_TYPE_GENERAL);*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class Prestudent extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'get' => ['admin:r', 'assistenz:r'],
|
||||
'updatePrestudent' => ['admin:rw', 'assistenz:rw'],
|
||||
'getHistoryPrestudents' => ['admin:r', 'assistenz:r'],
|
||||
'getBezeichnungZGV' => ['admin:r', 'assistenz:r'],
|
||||
'getBezeichnungDZgv' => ['admin:r', 'assistenz:r'],
|
||||
'getBezeichnungMZgv' => ['admin:r', 'assistenz:r'],
|
||||
'getAusbildung' => ['admin:r', 'assistenz:r'],
|
||||
'getAufmerksamdurch' => ['admin:r', 'assistenz:r'],
|
||||
'getBerufstaetigkeit' => ['admin:r', 'assistenz:r'],
|
||||
'getTypenStg' => ['admin:r', 'assistenz:r'],
|
||||
'getStudienplaene' => ['admin:r', 'assistenz:r'],
|
||||
'getStudiengang' => ['admin:r', 'assistenz:r']
|
||||
]);
|
||||
|
||||
if ($this->router->method == 'updatePrestudent') {
|
||||
$prestudent_id = current(array_slice($this->uri->rsegments, 2));
|
||||
$this->checkPermissionsForPrestudent($prestudent_id, ['admin:rw', 'assistenz:rw']);
|
||||
} elseif ($this->router->method == 'get'
|
||||
|| $this->router->method == 'getStudienplaene'
|
||||
|| $this->router->method == 'getStudiengang'
|
||||
) {
|
||||
$prestudent_id = current(array_slice($this->uri->rsegments, 2));
|
||||
$this->checkPermissionsForPrestudent($prestudent_id, ['admin:r', 'assistenz:r']);
|
||||
} elseif ($this->router->method == 'getHistoryPrestudents') {
|
||||
$person_id = current(array_slice($this->uri->rsegments, 2));
|
||||
$this->checkPermissionsForPerson($person_id, ['admin:r', 'assistenz:r'], ['admin:r', 'assistenz:r']);
|
||||
}
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui', 'studierendenantrag', 'lehre'
|
||||
]);
|
||||
}
|
||||
|
||||
public function get($prestudent_id)
|
||||
{
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
$this->PrestudentModel->addSelect('*');
|
||||
$result = $this->PrestudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if(!hasData($result))
|
||||
{
|
||||
return show_404();
|
||||
}
|
||||
$this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
|
||||
public function updatePrestudent($prestudent_id)
|
||||
{
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
// UDF
|
||||
$this->load->library('UDFLib');
|
||||
|
||||
$result = $this->udflib->getCiValidations($this->PrestudentModel, $this->input->post());
|
||||
$udf_field_validations = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
//Form validation
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules($udf_field_validations);
|
||||
|
||||
$this->form_validation->set_rules('priorisierung', 'Priorisierung', 'numeric', [
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Priorisierung'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$uid = getAuthUID();
|
||||
|
||||
$array_allowed_props_prestudent = [
|
||||
'aufmerksamdurch_kurzbz',
|
||||
'studiengang_kz',
|
||||
'gsstudientyp_kurzbz',
|
||||
'person_id',
|
||||
'berufstaetigkeit_code',
|
||||
'ausbildungcode',
|
||||
'zgv_code',
|
||||
'zgvort',
|
||||
'zgvdatum',
|
||||
'zgvnation',
|
||||
'zgvmas_code',
|
||||
'zgvmaort',
|
||||
'zgvmadatum',
|
||||
'zgvmanation',
|
||||
'facheinschlberuf',
|
||||
'bismelden',
|
||||
'anmerkung',
|
||||
'dual',
|
||||
'zgvdoktor_code',
|
||||
'zgvdoktorort',
|
||||
'zgvdoktordatum',
|
||||
'zgvdoktornation',
|
||||
'aufnahmegruppe_kurzbz',
|
||||
'priorisierung',
|
||||
'foerderrelevant',
|
||||
'zgv_erfuellt',
|
||||
'zgvmas_erfuellt',
|
||||
'zgvdoktor_erfuellt',
|
||||
'mentor',
|
||||
'aufnahmeschluessel',
|
||||
'standort_code'
|
||||
];
|
||||
|
||||
// add UDFs
|
||||
$result = $this->udflib->getDefinitionForModel($this->PrestudentModel);
|
||||
|
||||
$definitions = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
foreach ($definitions as $def)
|
||||
$array_allowed_props_prestudent[] = $def['name'];
|
||||
|
||||
$update_prestudent = array();
|
||||
foreach ($array_allowed_props_prestudent as $prop)
|
||||
{
|
||||
$val = $this->input->post($prop);
|
||||
if ($val !== null || $prop == 'foerderrelevant') {
|
||||
$update_prestudent[$prop] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
$update_prestudent['updateamum'] = date('c');
|
||||
$update_prestudent['updatevon'] = $uid;
|
||||
|
||||
if (count($update_prestudent))
|
||||
{
|
||||
$result = $this->PrestudentModel->update(
|
||||
$prestudent_id,
|
||||
$update_prestudent
|
||||
);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithSuccess(true);
|
||||
}
|
||||
return $this->terminateWithSuccess(false);
|
||||
}
|
||||
|
||||
public function getHistoryPrestudents($person_id)
|
||||
{
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
$result = $this->PrestudentModel->getHistoryPrestudents($person_id);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
|
||||
public function getBezeichnungZGV()
|
||||
{
|
||||
$this->load->model('codex/Zgv_model', 'ZgvModel');
|
||||
|
||||
$this->ZgvModel->addOrder('zgv_code');
|
||||
|
||||
$result = $this->ZgvModel->load();
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
|
||||
public function getBezeichnungDZgv()
|
||||
{
|
||||
$this->load->model('codex/Zgvdoktor_model', 'ZgvdoktorModel');
|
||||
|
||||
$this->ZgvdoktorModel->addOrder('zgvdoktor_code');
|
||||
|
||||
$result = $this->ZgvdoktorModel->load();
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
|
||||
public function getBezeichnungMZgv()
|
||||
{
|
||||
$this->load->model('codex/Zgvmaster_model', 'ZgvmasterModel');
|
||||
|
||||
$this->ZgvmasterModel->addOrder('zgvmas_code');
|
||||
|
||||
$result = $this->ZgvmasterModel->load();
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
|
||||
public function getAusbildung()
|
||||
{
|
||||
$this->load->model('codex/Ausbildung_model', 'AusbildungModel');
|
||||
|
||||
$this->AusbildungModel->addOrder('ausbildungcode');
|
||||
|
||||
$result = $this->AusbildungModel->load();
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
|
||||
public function getAufmerksamdurch()
|
||||
{
|
||||
$this->load->model('codex/Aufmerksamdurch_model', 'AufmerksamdurchModel');
|
||||
|
||||
$this->AufmerksamdurchModel->addOrder('aufmerksamdurch_kurzbz');
|
||||
|
||||
$result = $this->AufmerksamdurchModel->load();
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
|
||||
public function getBerufstaetigkeit()
|
||||
{
|
||||
$this->load->model('codex/Berufstaetigkeit_model', 'BerufstaetigkeitModel');
|
||||
|
||||
$this->BerufstaetigkeitModel->addOrder('berufstaetigkeit_code');
|
||||
|
||||
$result = $this->BerufstaetigkeitModel->load();
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
|
||||
public function getTypenStg()
|
||||
{
|
||||
$this->load->model('education/Gsstudientyp_model', 'GsstudientypModel');
|
||||
|
||||
$this->GsstudientypModel->addOrder('gsstudientyp_kurzbz');
|
||||
|
||||
$result = $this->GsstudientypModel->load();
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
|
||||
public function getStudienplaene($prestudent_id)
|
||||
{
|
||||
$this->load->model('organisation/Studienplan_model', 'StudienplanModel');
|
||||
$result = $this->StudienplanModel->getStudienplaeneByPrestudents($prestudent_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets details for the Studiengang of the Prestudent
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getStudiengang($prestudent_id)
|
||||
{
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
$this->PrestudentModel->addSelect('stg.*');
|
||||
|
||||
$this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz');
|
||||
|
||||
$result = $this->PrestudentModel->load($prestudent_id);
|
||||
|
||||
$stg = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(current($stg));
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,562 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the back-end
|
||||
* Provides data to the ajax get calls about a Student
|
||||
* Listens to ajax post calls to change the Student data
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Student extends FHCAPI_Controller
|
||||
{
|
||||
/**
|
||||
* Calls the parent's constructor and prepares libraries and phrases
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'get' => ['admin:r', 'assistenz:r'],
|
||||
'save' => ['admin:rw', 'assistenz:rw'],
|
||||
'check' => ['admin:rw', 'assistenz:rw'],
|
||||
'add' => ['admin:rw', 'assistenz:rw'] // TODO(chris): extra permissions
|
||||
]);
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
|
||||
if ($this->router->method == 'get'
|
||||
|| $this->router->method == 'save'
|
||||
) {
|
||||
$prestudent_id = current(array_slice($this->uri->rsegments, 2));
|
||||
if ($this->router->method == 'get')
|
||||
$this->checkPermissionsForPrestudent($prestudent_id, ['admin:r', 'assistenz:r']);
|
||||
else
|
||||
$this->checkPermissionsForPrestudent($prestudent_id, ['admin:rw', 'assistenz:rw']);
|
||||
}
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Get details for a prestudent
|
||||
*
|
||||
* @param string $prestudent_id
|
||||
* @return void
|
||||
*/
|
||||
public function get($prestudent_id)
|
||||
{
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
$this->PrestudentModel->addSelect('p.*');
|
||||
$this->PrestudentModel->addSelect('s.student_uid');
|
||||
$this->PrestudentModel->addSelect('matrikelnr');
|
||||
$this->PrestudentModel->addSelect('b.aktiv');
|
||||
$this->PrestudentModel->addSelect('v.semester');
|
||||
$this->PrestudentModel->addSelect('v.verband');
|
||||
$this->PrestudentModel->addSelect('v.gruppe');
|
||||
$this->PrestudentModel->addSelect('b.alias');
|
||||
|
||||
if (defined('ACTIVE_ADDONS') && strpos(ACTIVE_ADDONS, 'bewerbung') !== false) {
|
||||
$this->PrestudentModel->addSelect(
|
||||
"(
|
||||
SELECT kontakt
|
||||
FROM public.tbl_kontakt
|
||||
WHERE kontakttyp='email'
|
||||
AND person_id=p.person_id
|
||||
AND zustellung
|
||||
ORDER BY kontakt_id
|
||||
LIMIT 1
|
||||
) AS email_privat",
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
$this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('public.tbl_benutzer b', 'student_uid = uid', 'LEFT');
|
||||
$this->PrestudentModel->addJoin(
|
||||
'public.tbl_studentlehrverband v',
|
||||
'b.uid = v.student_uid AND v.studiensemester_kurzbz = ' . $this->PrestudentModel->escape($studiensemester_kurzbz),
|
||||
'LEFT'
|
||||
);
|
||||
$this->PrestudentModel->addJoin('public.tbl_person p', 'p.person_id = tbl_prestudent.person_id');
|
||||
|
||||
$result = $this->PrestudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
|
||||
$student = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$student)
|
||||
return show_404();
|
||||
|
||||
$this->terminateWithSuccess(current($student));
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves data to a prestudent
|
||||
*
|
||||
* @param string $prestudent_id
|
||||
* @return void
|
||||
*/
|
||||
public function save($prestudent_id)
|
||||
{
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$this->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel');
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'is_valid_date');
|
||||
|
||||
$this->form_validation->set_rules('semester', 'Semester', 'integer');
|
||||
|
||||
$this->load->library('UDFLib');
|
||||
|
||||
$result = $this->udflib->getCiValidations($this->PersonModel, $this->input->post());
|
||||
|
||||
//TODO(Manu) check with Chris: input number not allowed
|
||||
$udf_field_validations = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->form_validation->set_rules($udf_field_validations);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$result = $this->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
|
||||
$student = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$uid = $student ? current($student)->student_uid : null;
|
||||
|
||||
$result = $this->PrestudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
|
||||
$person = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$person_id = $person ? current($person)->person_id : null;
|
||||
|
||||
|
||||
$array_allowed_props_lehrverband = ['verband', 'semester', 'gruppe'];
|
||||
$update_lehrverband = array();
|
||||
foreach ($array_allowed_props_lehrverband as $prop) {
|
||||
$val = $this->input->post($prop);
|
||||
if ($val !== null) {
|
||||
$update_lehrverband[$prop] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
$array_allowed_props_person = [
|
||||
'anrede',
|
||||
'bpk',
|
||||
'titelpre',
|
||||
'titelpost',
|
||||
'nachname',
|
||||
'vorname',
|
||||
'vornamen',
|
||||
'wahlname',
|
||||
'gebdatum',
|
||||
'gebort',
|
||||
'geburtsnation',
|
||||
'svnr',
|
||||
'ersatzkennzeichen',
|
||||
'staatsbuergerschaft',
|
||||
'matr_nr',
|
||||
'sprache',
|
||||
'geschlecht',
|
||||
'familienstand',
|
||||
'foto',
|
||||
'anmerkung',
|
||||
'homepage'
|
||||
];
|
||||
|
||||
// add UDFs
|
||||
$result = $this->udflib->getDefinitionForModel($this->PersonModel);
|
||||
|
||||
$definitions = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
foreach ($definitions as $def)
|
||||
$array_allowed_props_person[] = $def['name'];
|
||||
|
||||
$update_person = array();
|
||||
foreach ($array_allowed_props_person as $prop) {
|
||||
$val = $this->input->post($prop);
|
||||
if ($val !== null) {
|
||||
$update_person[$prop] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
$array_allowed_props_student = ['matrikelnr'];
|
||||
$update_student = array();
|
||||
foreach ($array_allowed_props_student as $prop) {
|
||||
$val = $this->input->post($prop);
|
||||
if ($val !== null) {
|
||||
$update_student[$prop] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
// Check PKs
|
||||
if (count($update_lehrverband) + count($update_student) && $uid === null) {
|
||||
// TODO(chris): phrase
|
||||
$this->terminateWithValidationErrors(['' => "Kein/e StudentIn vorhanden!"]);
|
||||
}
|
||||
if (count($update_person) && $person_id === null) {
|
||||
// TODO(chris): phrase
|
||||
$this->terminateWithValidationErrors(['' => "Keine Person vorhanden!"]);
|
||||
}
|
||||
|
||||
// Do Updates
|
||||
if (count($update_lehrverband)) {
|
||||
$result = $this->StudentlehrverbandModel->update([
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'student_uid' => $uid
|
||||
], $update_lehrverband);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
|
||||
if (count($update_person)) {
|
||||
$result = $this->PersonModel->update(
|
||||
$person_id,
|
||||
$update_person
|
||||
);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
|
||||
|
||||
if (count($update_student)) {
|
||||
$result = $this->StudentModel->update(
|
||||
[$uid],
|
||||
$update_student
|
||||
);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess(array_fill_keys(array_merge(
|
||||
array_keys($update_lehrverband),
|
||||
array_keys($update_person),
|
||||
array_keys($update_student)
|
||||
), ''));
|
||||
}
|
||||
|
||||
public function check()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'is_valid_date');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$vorname = $this->input->post('vorname');
|
||||
$nachname = $this->input->post('nachname');
|
||||
$gebdatum = $this->input->post('gebdatum');
|
||||
|
||||
if (!$vorname && !$nachname && !$gebdatum)
|
||||
$this->terminateWithValidationErrors(['At least one of vorname, nachname or gebdatum must be set']);
|
||||
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
|
||||
if ($gebdatum)
|
||||
$this->PersonModel->db->where('gebdatum', (new DateTime($gebdatum))->format('Y-m-d'));
|
||||
if ($vorname && $nachname) {
|
||||
$this->PersonModel->db->or_group_start();
|
||||
$this->PersonModel->db->where('LOWER(nachname)', 'LOWER(' . $this->PersonModel->db->escape($nachname) . ')', false);
|
||||
$this->PersonModel->db->where('LOWER(vorname)', 'LOWER(' . $this->PersonModel->db->escape($vorname) . ')', false);
|
||||
$this->PersonModel->db->group_end();
|
||||
} elseif ($nachname) {
|
||||
$this->PersonModel->db->or_where('LOWER(nachname)', 'LOWER(' . $this->PersonModel->escape($nachname) . ')', false);
|
||||
}
|
||||
|
||||
$result = $this->PersonModel->load();
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
if (!$this->input->post('person_id')) {
|
||||
if (!isset($_POST['address']) || !is_array($_POST['address']))
|
||||
$_POST['address'] = [];
|
||||
$_POST['address']['func'] = 1;
|
||||
}
|
||||
if ($this->input->post('incoming')) {
|
||||
$_POST['ausbildungssemester'] = 0;
|
||||
}
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('nachname', 'Nachname', 'callback_requiredIfNotPersonId', [
|
||||
'requiredIfNotPersonId' => $this->p->t('ui', 'error_required')
|
||||
]);
|
||||
$this->form_validation->set_rules('geschlecht', 'Geschlecht', 'callback_requiredIfNotPersonId', [
|
||||
'requiredIfNotPersonId' => $this->p->t('ui', 'error_required')
|
||||
]);
|
||||
$this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'callback_isValidDate', [
|
||||
'isValidDate' => $this->p->t('ui', 'error_invalid_date')
|
||||
]);
|
||||
$this->form_validation->set_rules('address[func]', 'Address', 'required|integer|less_than[2]|greater_than[-2]');
|
||||
$this->form_validation->set_rules('address[plz]', 'PLZ', 'callback_requiredIfAddressFunc', [
|
||||
'requiredIfAddressFunc' => $this->p->t('ui', 'error_required')
|
||||
]);
|
||||
$this->form_validation->set_rules('address[gemeinde]', 'Gemeinde', 'callback_requiredIfAddressFunc', [
|
||||
'requiredIfAddressFunc' => $this->p->t('ui', 'error_required')
|
||||
]);
|
||||
$this->form_validation->set_rules('address[ort]', 'Ort', 'callback_requiredIfAddressFunc', [
|
||||
'requiredIfAddressFunc' => $this->p->t('ui', 'error_required')
|
||||
]);
|
||||
$this->form_validation->set_rules('address[address]', 'Adresse', 'callback_requiredIfAddressFunc', [
|
||||
'requiredIfAddressFunc' => $this->p->t('ui', 'error_required')
|
||||
]);
|
||||
$this->form_validation->set_rules('email', 'E-Mail', 'valid_email');
|
||||
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required');
|
||||
$this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required');
|
||||
$this->form_validation->set_rules('ausbildungssemester', 'Ausbildungssemester', 'required|integer|less_than[9]|greater_than[-1]');
|
||||
// TODO(chris): validate studienplan with studiengang, semester and orgform?
|
||||
// TODO(chris): validate person_id, studiengang_kz, studiensemester_kurzbz, orgform_kurzbz, nation, gemeinde, ort, geschlecht?
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
// TODO(chris): This should be in a library
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
|
||||
|
||||
$this->db->trans_start();
|
||||
|
||||
$result = $this->addInteressent();
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
if ($this->db->trans_status() === FALSE)
|
||||
$this->terminateWithError('TODO(chris): TEXT', self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
protected function addInteressent()
|
||||
{
|
||||
// Person anlegen wenn nötig
|
||||
$person_id = $this->input->post('person_id');
|
||||
if (!$person_id) {
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
|
||||
$data = [
|
||||
'nachname' => $this->input->post('nachname'),
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => getAuthUID(),
|
||||
'zugangscode' => uniqid(),
|
||||
'aktiv' => true
|
||||
];
|
||||
if ($this->input->post('anrede'))
|
||||
$data['anrede'] = $this->input->post('anrede');
|
||||
if ($this->input->post('titelpre'))
|
||||
$data['titelpre'] = $this->input->post('titelpre');
|
||||
if ($this->input->post('titelpost'))
|
||||
$data['titelpost'] = $this->input->post('titelpost');
|
||||
if ($this->input->post('vorname'))
|
||||
$data['vorname'] = $this->input->post('vorname');
|
||||
if ($this->input->post('vornamen'))
|
||||
$data['vornamen'] = $this->input->post('vornamen');
|
||||
if ($this->input->post('wahlname'))
|
||||
$data['wahlname'] = $this->input->post('wahlname');
|
||||
if ($this->input->post('geschlecht'))
|
||||
$data['geschlecht'] = $this->input->post('geschlecht');
|
||||
if ($this->input->post('gebdatum'))
|
||||
$data['gebdatum'] = (new DateTime($this->input->post('datum_obj')))->format('Y-m-d');
|
||||
if ($this->input->post('geburtsnation'))
|
||||
$data['geburtsnation'] = $this->input->post('geburtsnation');
|
||||
if ($this->input->post('staatsbuergerschaft'))
|
||||
$data['staatsbuergerschaft'] = $this->input->post('staatsbuergerschaft');
|
||||
|
||||
$result = $this->PersonModel->insert($data);
|
||||
$person_id = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
|
||||
// Addresse anlegen
|
||||
$anlegen = $this->input->post('address[func]');
|
||||
if ($anlegen) {
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
|
||||
$data = [
|
||||
'nation' => $this->input->post('address[nation]'),
|
||||
'strasse' => $this->input->post('address[address]'),
|
||||
'plz' => $this->input->post('address[plz]'),
|
||||
'ort' => $this->input->post('address[ort]'),
|
||||
'gemeinde' => $this->input->post('address[gemeinde]'),
|
||||
'typ' => 'h',
|
||||
'zustelladresse' => true,
|
||||
];
|
||||
if ($anlegen < 0) { // Überschreiben
|
||||
$this->AdresseModel->addOrder('zustelladresse', 'DESC');
|
||||
$this->AdresseModel->addOrder('sort');
|
||||
$result = $this->AdresseModel->loadWhere([
|
||||
'person_id' => $person_id
|
||||
]);
|
||||
$address = $this->getDataOrTerminateWithError($result);
|
||||
if ($address) {
|
||||
$address = current($address);
|
||||
|
||||
$data['updateamum'] = date('c');
|
||||
$data['updatevon'] = getAuthUID();
|
||||
|
||||
$result = $this->AdresseModel->update($address->adresse_id, $data);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
} else {
|
||||
//Wenn keine Adrese vorhanden ist dann eine neue Anlegen
|
||||
$anlegen = 1;
|
||||
$data['heimatadresse'] = true;
|
||||
}
|
||||
}
|
||||
if ($anlegen > 0) {
|
||||
$data['person_id'] = $person_id;
|
||||
$data['insertamum'] = date('c');
|
||||
$data['insertvon'] = getAuthUID();
|
||||
if (!isset($data['heimatadresse']))
|
||||
$data['heimatadresse'] = !$this->input->post('person_id');
|
||||
|
||||
$result = $this->AdresseModel->insert($data);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
}
|
||||
|
||||
// Kontaktdaten
|
||||
$kontaktdaten = [];
|
||||
foreach (['email', 'telefon', 'mobil'] as $k) {
|
||||
$v = $this->input->post($k);
|
||||
if ($v)
|
||||
$kontaktdaten[$k] = $v;
|
||||
}
|
||||
if (count($kontaktdaten)) {
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
|
||||
foreach ($kontaktdaten as $typ => $kontakt) {
|
||||
$data = [
|
||||
'person_id' => $person_id,
|
||||
'kontakttyp' => $typ,
|
||||
'kontakt' => $kontakt,
|
||||
'zustellung' => true,
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => getAuthUID()
|
||||
];
|
||||
$result = $this->KontaktModel->insert($data);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
}
|
||||
|
||||
// Prestudent anlegen
|
||||
$data = [
|
||||
'aufmerksamdurch_kurzbz' => 'k.A.',
|
||||
'person_id' => $person_id,
|
||||
'studiengang_kz' => $this->input->post('studiengang_kz'),
|
||||
'ausbildungcode' => $this->input->post('letzteausbildung'),
|
||||
'anmerkung' => $this->input->post('anmerkungen'),
|
||||
'reihungstestangetreten' => false,
|
||||
'bismelden' => true
|
||||
];
|
||||
$ausbildungsart = $this->input->post('ausbildungsart');
|
||||
if ($ausbildungsart)
|
||||
$data['anmerkung'] .= ' Ausbildungsart:' . $ausbildungsart;
|
||||
// Incomings und ausserordentliche sind bei Meldung nicht förderrelevant
|
||||
$incoming = $this->input->post('incoming');
|
||||
if ($incoming || substr($data['studiengang_kz'], 0, 1) == '9')
|
||||
$data['foerderrelevant'] = false;
|
||||
// Wenn die Person schon im System erfasst ist, dann die ZGV des Datensatzes uebernehmen
|
||||
$this->PrestudentModel->addOrder('zgvmas_code');
|
||||
$this->PrestudentModel->addOrder('zgv_code', 'DESC');
|
||||
$this->PrestudentModel->addLimit(1);
|
||||
$result = $this->PrestudentModel->loadWhere([
|
||||
'person_id' => $person_id
|
||||
]);
|
||||
$prestudent = $this->getDataOrTerminateWithError($result);
|
||||
if ($prestudent) {
|
||||
$prestudent = current($prestudent);
|
||||
if ($prestudent->zgv_code) {
|
||||
$data['zgv_code'] = $prestudent->zgv_code;
|
||||
$data['zgvort'] = $prestudent->zgvort;
|
||||
$data['zgvdatum'] = $prestudent->zgvdatum;
|
||||
|
||||
$data['zgvmas_code'] = $prestudent->zgvmas_code;
|
||||
$data['zgvmaort'] = $prestudent->zgvmaort;
|
||||
$data['zgvmadatum'] = $prestudent->zgvmadatum;
|
||||
}
|
||||
}
|
||||
// Prestudent speichern
|
||||
$result = $this->PrestudentModel->insert($data);
|
||||
$prestudent_id = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
// Prestudent Rolle Anlegen
|
||||
$data = [
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => $incoming ? 'Incoming' : 'Interessent',
|
||||
'studiensemester_kurzbz' => $this->input->post('studiensemester_kurzbz'),
|
||||
'ausbildungssemester' => $this->input->post('ausbildungssemester') ?: 0,
|
||||
'orgform_kurzbz' => $this->input->post('orgform_kurzbz') ?: null,
|
||||
'studienplan_id' => $this->input->post('studienplan_id') ?: null,
|
||||
'datum' => date('Y-m-d'),
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => getAuthUID()
|
||||
];
|
||||
$result = $this->PrestudentstatusModel->insert($data);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
if ($incoming) {
|
||||
// TODO(chris): IMPLEMENT!
|
||||
//Matrikelnummer und UID generieren
|
||||
//Benutzerdatensatz anlegen
|
||||
//Studentendatensatz anlegen
|
||||
//StudentLehrverband anlegen
|
||||
}
|
||||
|
||||
// TODO(chris): DEBUG
|
||||
/*$result = $this->PrestudentModel->loadWhere([
|
||||
'pestudent_id' => 1
|
||||
]);
|
||||
if (isError($result)) {
|
||||
return $result;
|
||||
}*/
|
||||
|
||||
$this->terminateWithSuccess(true);
|
||||
}
|
||||
|
||||
public function requiredIfNotPersonId($value)
|
||||
{
|
||||
if (isset($_POST['person_id']))
|
||||
return true;
|
||||
return !!$value;
|
||||
}
|
||||
|
||||
public function requiredIfAddressFunc($value)
|
||||
{
|
||||
if (!$_POST['address']['func'])
|
||||
return true;
|
||||
return !!$value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,743 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the back-end
|
||||
* Provides data to the ajax get calls about listing students
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Students extends FHCAPI_Controller
|
||||
{
|
||||
private $allowedStgs = [];
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$permissions = [];
|
||||
$router = load_class('Router');
|
||||
$permissions[$router->method] = ['admin:r', 'assistenz:r'];
|
||||
parent::__construct($permissions);
|
||||
|
||||
$this->allowedStgs = $this->permissionlib->getSTG_isEntitledFor('admin') ?: [];
|
||||
$this->allowedStgs = array_merge($this->allowedStgs, $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: []);
|
||||
|
||||
if (!$this->allowedStgs) {
|
||||
$this->_outputAuthError([$router->method => ['admin:r', 'assistenz:r']]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remap calls:
|
||||
* / => return []
|
||||
* /inout => return []
|
||||
* /inout/incoming => getIncoming
|
||||
* /inout/outgoing => getOutgoing
|
||||
* /inout/gemeinsamestudien => getGemeinsamestudien
|
||||
* /(studiengang_kz) => getStudents
|
||||
* /(studiengang_kz)/prestudent => getPrestudents
|
||||
* /(studiengang_kz)/prestudent/* => getPrestudents
|
||||
* /(studiengang_kz)/(semester) => getStudents
|
||||
* /(studiengang_kz)/(semester)/grp/(gruppe_kurzbz) => getStudents
|
||||
* /(studiengang_kz)/(semester)/(verband) => getStudents
|
||||
* /(studiengang_kz)/(semester)/(verband)/(gruppe) => getStudents
|
||||
* /(studiengang_kz)/(org_form) => getStudents
|
||||
* /(studiengang_kz)/(org_form)/prestudent => getPrestudents
|
||||
* /(studiengang_kz)/(org_form)/prestudent/* => getPrestudents
|
||||
* /(studiengang_kz)/(org_form)/(semester) => getStudents
|
||||
* /(studiengang_kz)/(org_form)/(semester)/grp/(gruppe_kurzbz)
|
||||
* => getStudents
|
||||
* /(studiengang_kz)/(org_form)/(semester)/(verband) => getStudents
|
||||
* /(studiengang_kz)/(org_form)/(semester)/(verband)/(gruppe)
|
||||
* => getStudents
|
||||
* /uid/(student_uid) => getStudent
|
||||
* /prestudent/(prestudent_id) => getPrestudent
|
||||
* /person/(person_id) => getPerson
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $params (optional)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function _remap($method, $params = [])
|
||||
{
|
||||
if ($method == '' || $method == 'index')
|
||||
return $this->terminateWithSuccess([]);
|
||||
|
||||
if ($method == 'inout') {
|
||||
if (!count($params))
|
||||
return $this->terminateWithSuccess([]);
|
||||
switch ($params[0]) {
|
||||
case 'incoming':
|
||||
return $this->getIncoming();
|
||||
case 'outgoing':
|
||||
return $this->getOutgoing();
|
||||
case 'gemeinsamestudien':
|
||||
return $this->getGemeinsamestudien();
|
||||
default:
|
||||
return show_404();
|
||||
}
|
||||
}
|
||||
|
||||
$count = count($params);
|
||||
if (!$count)
|
||||
return $this->getStudents($method);
|
||||
|
||||
if ($method == 'uid' && $count == 1)
|
||||
return $this->getStudent($params[0]);
|
||||
|
||||
if ($method == 'prestudent' && $count == 1)
|
||||
return $this->getPrestudent($params[0]);
|
||||
|
||||
if ($method == 'person' && $count == 1)
|
||||
return $this->getPerson($params[0]);
|
||||
|
||||
if (is_numeric($params[0])) {
|
||||
$sem = $params[0];
|
||||
if ($count == 3 && $params[1] == 'grp') {
|
||||
$g = $params[2];
|
||||
$ver = null;
|
||||
$grp = null;
|
||||
} else {
|
||||
$g = null;
|
||||
$ver = $count > 1 ? $params[1] : null;
|
||||
$grp = $count > 2 ? $params[2] : null;
|
||||
}
|
||||
return $this->getStudents($method, $sem, $ver, $grp, $g);
|
||||
} elseif ($params[0] == 'prestudent') {
|
||||
if ($count == 1)
|
||||
return $this->getPrestudents($method);
|
||||
if ($count == 2)
|
||||
return $this->getPrestudents($method, $params[1]);
|
||||
return $this->getPrestudents($method, $params[1], $params[$count-1]);
|
||||
} else {
|
||||
$org = $params[0];
|
||||
if ($count > 1 && $params[1] == 'prestudent') {
|
||||
if ($count == 2)
|
||||
return $this->getPrestudents($method, null, null, $org);
|
||||
if ($count == 3)
|
||||
return $this->getPrestudents($method, $params[2], null, $org);
|
||||
return $this->getPrestudents($method, $params[2], $params[$count-1], $org);
|
||||
}
|
||||
$sem = $count > 1 ? $params[1] : null;
|
||||
if ($count == 4 && $params[2] == 'grp') {
|
||||
$g = $params[3];
|
||||
$ver = null;
|
||||
$grp = null;
|
||||
} else {
|
||||
$g = null;
|
||||
$ver = $count > 2 ? $params[2] : null;
|
||||
$grp = $count > 3 ? $params[3] : null;
|
||||
}
|
||||
|
||||
return $this->getStudents($method, $sem, $ver, $grp, $g, $org);
|
||||
}
|
||||
|
||||
show_404();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function getIncoming()
|
||||
{
|
||||
// TODO(chris): IMPLEMENT!
|
||||
$this->terminateWithSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function getOutgoing()
|
||||
{
|
||||
// TODO(chris): IMPLEMENT!
|
||||
$this->terminateWithSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function getGemeinsamestudien()
|
||||
{
|
||||
// TODO(chris): IMPLEMENT!
|
||||
$this->terminateWithSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $studiengang_kz
|
||||
* @param string $studiensemester_kurzbz (optional)
|
||||
* @param string $filter (optional)
|
||||
* @param string $orgform_kurzbz (optional)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getPrestudents($studiengang_kz, $studiensemester_kurzbz = null, $filter = null, $orgform_kurzbz = null)
|
||||
{
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
$stdsemEsc = $studiensemester_kurzbz ? $this->PrestudentModel->escape($studiensemester_kurzbz) : 'NULL';
|
||||
|
||||
$selectRT = "
|
||||
SELECT 1
|
||||
FROM public.tbl_rt_person
|
||||
JOIN public.tbl_reihungstest r ON (rt_id = reihungstest_id)
|
||||
WHERE person_id=p.person_id
|
||||
AND studienplan_id IN (
|
||||
SELECT studienplan_id
|
||||
FROM lehre.tbl_studienplan
|
||||
JOIN lehre.tbl_studienordnung o USING(studienordnung_id)
|
||||
WHERE o.studiengang_kz=tbl_prestudent.studiengang_kz
|
||||
)
|
||||
AND r.studiensemester_kurzbz=" . $stdsemEsc;
|
||||
|
||||
|
||||
$where = ['tbl_prestudent.studiengang_kz' => $studiengang_kz];
|
||||
|
||||
if ($orgform_kurzbz) {
|
||||
$where['ps.orgform_kurzbz'] = $orgform_kurzbz;
|
||||
}
|
||||
|
||||
switch ($filter) {
|
||||
case "interessenten":
|
||||
$where['ps.status_kurzbz'] = 'Interessent';
|
||||
break;
|
||||
case "bewerbungnichtabgeschickt":
|
||||
$where['ps.status_kurzbz'] = 'Interessent';
|
||||
$where['bewerbung_abgeschicktamum'] = null;
|
||||
break;
|
||||
case "bewerbungabgeschickt":
|
||||
$where['ps.status_kurzbz'] = 'Interessent';
|
||||
$where['bewerbung_abgeschicktamum IS NOT NULL'] = null;
|
||||
$where['bestaetigtam'] = null;
|
||||
break;
|
||||
case "statusbestaetigt":
|
||||
$where['ps.status_kurzbz'] = 'Interessent';
|
||||
$where['bestaetigtam IS NOT NULL'] = null;
|
||||
break;
|
||||
case "statusbestaetigtrtnichtangemeldet":
|
||||
$where['ps.status_kurzbz'] = 'Interessent';
|
||||
$where['bestaetigtam IS NOT NULL'] = null;
|
||||
$this->PrestudentModel->db->where('NOT EXISTS(' . $selectRT . ')', null, false);
|
||||
break;
|
||||
case "statusbestaetigtrtangemeldet":
|
||||
$where['ps.status_kurzbz'] = 'Interessent';
|
||||
$where['bestaetigtam IS NOT NULL'] = null;
|
||||
$this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false);
|
||||
break;
|
||||
case "zgv":
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
|
||||
$result = $this->StudiengangModel->load($studiengang_kz);
|
||||
|
||||
$stg = $this->getDataOrTerminateWithError($result);
|
||||
if (!$stg)
|
||||
$this->terminateWithValidationErrors(['' => 'Studiengang does not exist']); // TODO(chris): phrase
|
||||
$stg = current($stg);
|
||||
|
||||
$where['ps.status_kurzbz'] = 'Interessent';
|
||||
|
||||
if ($stg->typ == 'm') {
|
||||
$where['zgvmas_code IS NOT NULL'] = null;
|
||||
if (defined('ZGV_ERFUELLT_ANZEIGEN') && ZGV_ERFUELLT_ANZEIGEN)
|
||||
$where['zgvmas_erfuellt'] = true;
|
||||
} elseif ($stg->typ == 'p') {
|
||||
$where['zgvdoktor_code IS NOT NULL'] = null;
|
||||
if (defined('ZGV_DOKTOR_ANZEIGEN') && ZGV_DOKTOR_ANZEIGEN)
|
||||
$where['zgvdoktor_erfuellt'] = true;
|
||||
} else {
|
||||
$where['zgv_code IS NOT NULL'] = null;
|
||||
if (defined('ZGV_ERFUELLT_ANZEIGEN') && ZGV_ERFUELLT_ANZEIGEN)
|
||||
$where['zgv_erfuellt'] = true;
|
||||
}
|
||||
break;
|
||||
case "reihungstestangemeldet":
|
||||
$where['ps.status_kurzbz'] = 'Interessent';
|
||||
$this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false);
|
||||
break;
|
||||
case "reihungstestnichtangemeldet":
|
||||
$where['ps.status_kurzbz'] = 'Interessent';
|
||||
$this->PrestudentModel->db->where('NOT EXISTS(' . $selectRT . ')', null, false);
|
||||
break;
|
||||
case "bewerber":
|
||||
$where['ps.status_kurzbz'] = 'Bewerber';
|
||||
break;
|
||||
case "bewerberrtnichtangemeldet":
|
||||
$where['ps.status_kurzbz'] = 'Bewerber';
|
||||
$this->PrestudentModel->db->where('NOT EXISTS(' . $selectRT . ')', null, false);
|
||||
break;
|
||||
case "bewerberrtangemeldet":
|
||||
$where['ps.status_kurzbz'] = 'Bewerber';
|
||||
$this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false);
|
||||
break;
|
||||
case "bewerberrtangemeldetteilgenommen":
|
||||
$where['ps.status_kurzbz'] = 'Bewerber';
|
||||
$this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false);
|
||||
$where['reihungstestangetreten'] = true;
|
||||
break;
|
||||
case "bewerberrtangemeldetnichtteilgenommen":
|
||||
$where['ps.status_kurzbz'] = 'Bewerber';
|
||||
$this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false);
|
||||
$where['reihungstestangetreten'] = false;
|
||||
break;
|
||||
case "aufgenommen":
|
||||
$where['ps.status_kurzbz'] = 'Aufgenommener';
|
||||
break;
|
||||
case "warteliste":
|
||||
$where['ps.status_kurzbz'] = 'Wartender';
|
||||
break;
|
||||
case "absage":
|
||||
$where['ps.status_kurzbz'] = 'Abgewiesener';
|
||||
break;
|
||||
case "incoming":
|
||||
// NOTE(chris): in FAS it was not filtered for studiengang_kz
|
||||
$where['ps.status_kurzbz'] = 'Incoming';
|
||||
break;
|
||||
case "absolvent":
|
||||
$where['ps.status_kurzbz'] = 'Absolvent';
|
||||
break;
|
||||
case "diplomand":
|
||||
$where['ps.status_kurzbz'] = 'Diplomand';
|
||||
break;
|
||||
default:
|
||||
if (!$studiensemester_kurzbz) {
|
||||
// TODO(chris): this does not work with $orgform_kurzbz != null
|
||||
$where['ps.status_kurzbz'] = null;
|
||||
} else {
|
||||
$this->PrestudentModel->db->where_in('ps.status_kurzbz', [
|
||||
'Interessent',
|
||||
'Bewerber',
|
||||
'Aufgenommener',
|
||||
'Wartender',
|
||||
'Abgewiesener'
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
$this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
|
||||
$this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', '
|
||||
pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL)
|
||||
AND pls.prestudent_id=tbl_prestudent.prestudent_id
|
||||
AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL)
|
||||
AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('public.tbl_prestudentstatus ps', '
|
||||
ps.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')
|
||||
AND ps.prestudent_id=tbl_prestudent.prestudent_id
|
||||
AND ps.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')
|
||||
AND ps.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')', 'LEFT');*/
|
||||
$this->prepareQuery($studiensemester_kurzbz);
|
||||
|
||||
$this->PrestudentModel->addSelect("
|
||||
CASE WHEN ps.status_kurzbz IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent')
|
||||
THEN ps.ausbildungssemester::text
|
||||
ELSE ''::text END AS semester", false);
|
||||
$this->PrestudentModel->addSelect("'' AS verband");
|
||||
$this->PrestudentModel->addSelect("'' AS gruppe");
|
||||
$this->addSelectPrioRel();
|
||||
|
||||
$this->addFilter($studiensemester_kurzbz);
|
||||
|
||||
$result = $this->PrestudentModel->loadWhere($where);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $studiengang_kz
|
||||
* @param integer $semester (optional)
|
||||
* @param string $verband (optional)
|
||||
* @param integer $gruppe (optional)
|
||||
* @param string $gruppe_kurzbz (optional)
|
||||
* @param string $orgform_kurzbz (optional)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getStudents($studiengang_kz, $semester = null, $verband = null, $gruppe = null, $gruppe_kurzbz = null, $orgform_kurzbz = null)
|
||||
{
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
|
||||
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
/*
|
||||
$this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
|
||||
$this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id');
|
||||
$this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', '
|
||||
pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL)
|
||||
AND pls.prestudent_id=tbl_prestudent.prestudent_id
|
||||
AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL)
|
||||
AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid');
|
||||
$this->PrestudentModel->addJoin(
|
||||
'public.tbl_studentlehrverband v',
|
||||
'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz)
|
||||
);*/
|
||||
$this->prepareQuery($studiensemester_kurzbz, '');
|
||||
|
||||
$this->PrestudentModel->addSelect('v.semester');
|
||||
$this->PrestudentModel->addSelect('v.verband');
|
||||
$this->PrestudentModel->addSelect('v.gruppe');
|
||||
$this->PrestudentModel->addSelect("'' AS priorisierung_relativ");
|
||||
|
||||
|
||||
$where = [];
|
||||
|
||||
if ($gruppe_kurzbz !== null) {
|
||||
$this->PrestudentModel->addJoin('public.tbl_benutzergruppe g', 'uid');
|
||||
$where['g.gruppe_kurzbz'] = $gruppe_kurzbz;
|
||||
$where['g.studiensemester_kurzbz'] = $studiensemester_kurzbz;
|
||||
} else {
|
||||
$where['v.studiengang_kz'] = $studiengang_kz;
|
||||
|
||||
if ($semester !== null)
|
||||
$where['v.semester'] = $semester;
|
||||
|
||||
if ($verband !== null)
|
||||
$where['v.verband'] = $verband;
|
||||
|
||||
if ($gruppe !== null)
|
||||
$where['v.gruppe'] = $gruppe;
|
||||
|
||||
if (!$verband && !$gruppe && $orgform_kurzbz !== null) {
|
||||
$this->PrestudentModel->db->where(
|
||||
"(
|
||||
SELECT orgform_kurzbz
|
||||
FROM public.tbl_prestudentstatus
|
||||
WHERE prestudent_id=tbl_prestudent.prestudent_id
|
||||
AND studiensemester_kurzbz=" . $this->PrestudentModel->escape($studiensemester_kurzbz) . "
|
||||
ORDER BY datum DESC, insertamum DESC, ext_id DESC LIMIT 1
|
||||
) =",
|
||||
$this->PrestudentModel->escape($orgform_kurzbz),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->addFilter($studiensemester_kurzbz);
|
||||
|
||||
$result = $this->PrestudentModel->loadWhere($where);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prestudent_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getPrestudent($prestudent_id)
|
||||
{
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
/*
|
||||
$this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
|
||||
$this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', '
|
||||
pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL)
|
||||
AND pls.prestudent_id=tbl_prestudent.prestudent_id
|
||||
AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL)
|
||||
AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid', 'LEFT');
|
||||
$this->PrestudentModel->addJoin(
|
||||
'public.tbl_studentlehrverband v',
|
||||
'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz),
|
||||
'LEFT'
|
||||
);*/
|
||||
$this->prepareQuery($studiensemester_kurzbz);
|
||||
|
||||
$this->PrestudentModel->addSelect("COALESCE(v.semester::text, CASE WHEN public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent') THEN public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)::text ELSE ''::text END) AS semester", false);
|
||||
$this->PrestudentModel->addSelect('v.verband');
|
||||
$this->PrestudentModel->addSelect('v.gruppe');
|
||||
$this->addSelectPrioRel();
|
||||
|
||||
$this->addFilter($studiensemester_kurzbz);
|
||||
|
||||
$result = $this->PrestudentModel->loadWhere([
|
||||
'tbl_prestudent.prestudent_id' => $prestudent_id
|
||||
]);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $student_uid
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getStudent($student_uid)
|
||||
{
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
/*
|
||||
$this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
|
||||
$this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id');
|
||||
$this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', '
|
||||
pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL)
|
||||
AND pls.prestudent_id=tbl_prestudent.prestudent_id
|
||||
AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL)
|
||||
AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid');
|
||||
$this->PrestudentModel->addJoin(
|
||||
'public.tbl_studentlehrverband v',
|
||||
'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz),
|
||||
'LEFT'
|
||||
);*/
|
||||
$this->prepareQuery($studiensemester_kurzbz);
|
||||
|
||||
$this->PrestudentModel->addSelect('v.semester');
|
||||
$this->PrestudentModel->addSelect('v.verband');
|
||||
$this->PrestudentModel->addSelect('v.gruppe');
|
||||
$this->addSelectPrioRel();
|
||||
|
||||
$this->addFilter($studiensemester_kurzbz);
|
||||
|
||||
$result = $this->PrestudentModel->loadWhere([
|
||||
's.student_uid' => $student_uid
|
||||
]);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $person_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getPerson($person_id)
|
||||
{
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
/*
|
||||
$this->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
|
||||
$this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id');
|
||||
$this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid');
|
||||
$this->PrestudentModel->addJoin(
|
||||
'public.tbl_studentlehrverband v',
|
||||
'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz),
|
||||
'LEFT'
|
||||
);*/
|
||||
$this->prepareQuery($studiensemester_kurzbz);
|
||||
|
||||
$this->PrestudentModel->addSelect('v.semester');
|
||||
$this->PrestudentModel->addSelect('v.verband');
|
||||
$this->PrestudentModel->addSelect('v.gruppe');
|
||||
$this->addSelectPrioRel();
|
||||
|
||||
$this->addFilter($studiensemester_kurzbz);
|
||||
|
||||
$result = $this->PrestudentModel->loadWhere([
|
||||
'p.person_id' => $person_id
|
||||
]);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $studiensemester_kurzbz
|
||||
* @param string $type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareQuery($studiensemester_kurzbz, $type = 'LEFT')
|
||||
{
|
||||
$stdsemEsc = $studiensemester_kurzbz ? $this->PrestudentModel->escape($studiensemester_kurzbz) : 'NULL';
|
||||
|
||||
|
||||
$this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
|
||||
$this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id', $type);
|
||||
$this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', '
|
||||
pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL)
|
||||
AND pls.prestudent_id=tbl_prestudent.prestudent_id
|
||||
AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL)
|
||||
AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid', 'LEFT');
|
||||
$this->PrestudentModel->addJoin(
|
||||
'public.tbl_studentlehrverband v',
|
||||
'v.student_uid=s.student_uid AND v.studiensemester_kurzbz' . ($studiensemester_kurzbz ? '=' . $stdsemEsc : ' IS NULL'),
|
||||
$type
|
||||
);
|
||||
$this->PrestudentModel->addJoin('public.tbl_prestudentstatus ps', '
|
||||
ps.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')
|
||||
AND ps.prestudent_id=tbl_prestudent.prestudent_id
|
||||
AND ps.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')
|
||||
AND ps.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')', 'LEFT');
|
||||
|
||||
|
||||
$this->PrestudentModel->addSelect("b.uid");
|
||||
$this->PrestudentModel->addSelect('titelpre');
|
||||
$this->PrestudentModel->addSelect('nachname');
|
||||
$this->PrestudentModel->addSelect('vorname');
|
||||
$this->PrestudentModel->addSelect('wahlname');
|
||||
$this->PrestudentModel->addSelect('vornamen');
|
||||
$this->PrestudentModel->addSelect('titelpost');
|
||||
$this->PrestudentModel->addSelect('svnr');
|
||||
$this->PrestudentModel->addSelect('ersatzkennzeichen');
|
||||
$this->PrestudentModel->addSelect('gebdatum');
|
||||
$this->PrestudentModel->addSelect('geschlecht');
|
||||
|
||||
// semester
|
||||
// verband
|
||||
// gruppe
|
||||
|
||||
$this->PrestudentModel->addSelect('UPPER(stg.typ || stg.kurzbz) AS studiengang');
|
||||
$this->PrestudentModel->addSelect('tbl_prestudent.studiengang_kz');
|
||||
$this->PrestudentModel->addSelect("s.matrikelnr");
|
||||
$this->PrestudentModel->addSelect('p.person_id');
|
||||
$this->PrestudentModel->addSelect('pls.status_kurzbz AS status');
|
||||
$this->PrestudentModel->addSelect('pls.datum AS status_datum');
|
||||
$this->PrestudentModel->addSelect('pls.bestaetigtam AS status_bestaetigung');
|
||||
$this->PrestudentModel->addSelect(
|
||||
"(SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp='email' AND person_id=p.person_id AND zustellung LIMIT 1) AS mail_privat",
|
||||
false
|
||||
);
|
||||
$this->PrestudentModel->addSelect("
|
||||
CASE WHEN b.uid IS NOT NULL AND b.uid<>''
|
||||
THEN b.uid || " . $this->PrestudentModel->escape(DOMAIN) . "
|
||||
ELSE '' END AS mail_intern", false);
|
||||
$this->PrestudentModel->addSelect('p.anmerkung AS anmerkungen');
|
||||
$this->PrestudentModel->addSelect('tbl_prestudent.anmerkung');
|
||||
$this->PrestudentModel->addSelect('pls.orgform_kurzbz');
|
||||
$this->PrestudentModel->addSelect('aufmerksamdurch_kurzbz');
|
||||
$this->PrestudentModel->addSelect(
|
||||
"(SELECT rt_gesamtpunkte AS punkte FROM public.tbl_prestudent WHERE prestudent_id=ps.prestudent_id) AS punkte",
|
||||
false
|
||||
);
|
||||
$this->PrestudentModel->addSelect('tbl_prestudent.aufnahmegruppe_kurzbz');
|
||||
$this->PrestudentModel->addSelect('tbl_prestudent.dual');
|
||||
$this->PrestudentModel->addSelect('p.matr_nr');
|
||||
$this->PrestudentModel->addSelect('sp.bezeichnung AS studienplan_bezeichnung');
|
||||
$this->PrestudentModel->addSelect('tbl_prestudent.prestudent_id');
|
||||
|
||||
// priorisierung_relativ
|
||||
|
||||
$this->PrestudentModel->addSelect('mentor');
|
||||
$this->PrestudentModel->addSelect('b.aktiv AS bnaktiv');
|
||||
|
||||
/*$this->PrestudentModel->addSelect('tbl_prestudent.reihungstest_id');
|
||||
$this->PrestudentModel->addSelect('tbl_prestudent.anmeldungreihungstest');
|
||||
$this->PrestudentModel->addSelect('tbl_prestudent.gsstudientyp_kurzbz');
|
||||
$this->PrestudentModel->addSelect('tbl_prestudent.priorisierung');
|
||||
$this->PrestudentModel->addSelect('p.zugangscode');
|
||||
$this->PrestudentModel->addSelect('p.bpk');*/
|
||||
|
||||
$this->PrestudentModel->db->where_in('tbl_prestudent.studiengang_kz', $this->allowedStgs);
|
||||
|
||||
$this->PrestudentModel->addOrder('nachname');
|
||||
$this->PrestudentModel->addOrder('vorname');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function addSelectPrioRel()
|
||||
{
|
||||
$this->PrestudentModel->addSelect("(
|
||||
SELECT count(*)
|
||||
FROM (
|
||||
SELECT *, public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) AS laststatus
|
||||
FROM PUBLIC.tbl_prestudent pss
|
||||
JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id)
|
||||
WHERE person_id = p.person_id
|
||||
AND studiensemester_kurzbz = (
|
||||
SELECT studiensemester_kurzbz
|
||||
FROM PUBLIC.tbl_prestudentstatus
|
||||
WHERE prestudent_id = tbl_prestudent.prestudent_id
|
||||
AND status_kurzbz = 'Interessent'
|
||||
LIMIT 1
|
||||
)
|
||||
AND status_kurzbz = 'Interessent'
|
||||
) prest
|
||||
WHERE laststatus NOT IN ('Abbrecher', 'Abgewiesener', 'Absolvent')
|
||||
AND priorisierung <= tbl_prestudent.priorisierung
|
||||
) || ' (' || tbl_prestudent.priorisierung || ')' AS priorisierung_relativ", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds additional filters to the query
|
||||
*
|
||||
* @param string $studiensemester_kurzbz
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function addFilter($studiensemester_kurzbz)
|
||||
{
|
||||
$filter = $this->input->get('filter');
|
||||
if (isset($filter['konto_count_0'])) {
|
||||
$bt = $this->PrestudentModel->escape($filter['konto_count_0']);
|
||||
$stdsem = $this->PrestudentModel->escape($studiensemester_kurzbz);
|
||||
|
||||
$this->PrestudentModel->db->where('(
|
||||
SELECT count(*)
|
||||
FROM public.tbl_konto
|
||||
WHERE person_id=tbl_prestudent.person_id
|
||||
AND buchungstyp_kurzbz=' . $bt . '
|
||||
AND studiensemester_kurzbz=' . $stdsem . '
|
||||
) =', 0);
|
||||
$this->PrestudentModel->db->where('get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) !=', 'Incoming');
|
||||
}
|
||||
if (isset($filter['konto_missing_counter'])) {
|
||||
$bt = $this->PrestudentModel->escape($filter['konto_missing_counter']);
|
||||
$stg = '';
|
||||
if ($this->variablelib->getVar('kontofilterstg') == 'true')
|
||||
$stg = ' AND studiengang_kz=tbl_prestudent.studiengang_kz';
|
||||
|
||||
$bt = $bt == 'alle' ? '' : ' AND buchungstyp_kurzbz=' . $bt;
|
||||
|
||||
$this->PrestudentModel->db->where('(
|
||||
SELECT sum(betrag)
|
||||
FROM public.tbl_konto
|
||||
WHERE person_id=tbl_prestudent.person_id' .
|
||||
$bt .
|
||||
$stg . '
|
||||
) !=', 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,493 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the back-end
|
||||
* Provides data to the ajax get calls about verbände
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Verband extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$permissions = [];
|
||||
$router = load_class('Router');
|
||||
$permissions[$router->method] = ['admin:r', 'assistenz:r'];
|
||||
parent::__construct($permissions);
|
||||
|
||||
// Load Models
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remap calls:
|
||||
* /
|
||||
* /(studiengang_kz) => getStudiengang
|
||||
* /(studiengang_kz)/(semester) => getSemester
|
||||
* /(studiengang_kz)/(semester)/(verband) => getVerband
|
||||
* /(studiengang_kz)/(org_form) => getStudiengang
|
||||
* /(studiengang_kz)/(org_form)/(semester) => getSemester
|
||||
* /(studiengang_kz)/(org_form)/(semester)/(verband) => getVerband
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $params (optional)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function _remap($method, $params = [])
|
||||
{
|
||||
if ($method == '' || $method == 'index')
|
||||
return $this->getBase();
|
||||
|
||||
// NOTE(chris): Test if access is allowed ($method is the Studiengang)
|
||||
if (!$this->permissionlib->isBerechtigt('assistenz', 's', $method)
|
||||
&& !$this->permissionlib->isBerechtigt('admin', 's', $method)
|
||||
) {
|
||||
return $this->_outputAuthError([$method => ['admin:r', 'assistenz:r']]);
|
||||
}
|
||||
|
||||
$count = count($params);
|
||||
if (!$count)
|
||||
return $this->getStudiengang($method);
|
||||
|
||||
if ($count == 1) {
|
||||
if (is_numeric($params[0]))
|
||||
return $this->getSemester($method, $params[0]);
|
||||
elseif ($params[0] == 'prestudent')
|
||||
return $this->terminateWithSuccess($this->getStdSem($method . '/prestudent/', $method));
|
||||
else
|
||||
return $this->getStudiengang($method, $params[0]);
|
||||
}
|
||||
if ($count == 2) {
|
||||
if (is_numeric($params[0]))
|
||||
return $this->getVerband($method, $params[0], $params[1]);
|
||||
elseif ($params[1] == 'prestudent')
|
||||
return $this->terminateWithSuccess($this->getStdSem($method . '/' . $params[0] . '/prestudent/', $method));
|
||||
else
|
||||
return $this->getSemester($method, $params[1], $params[0]);
|
||||
}
|
||||
if ($count == 3 && !is_numeric($params[0]) && is_numeric($params[1]) && !is_numeric($params[2]))
|
||||
return $this->getVerband($method, $params[1], $params[2], $params[0]);
|
||||
|
||||
show_404();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function getBase()
|
||||
{
|
||||
$this->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
|
||||
|
||||
$this->StudiengangModel->addDistinct();
|
||||
$this->StudiengangModel->addSelect("v.studiengang_kz AS link");
|
||||
$this->StudiengangModel->addSelect(
|
||||
"CONCAT(kurzbzlang, ' (', UPPER(CONCAT(typ, kurzbz)), ') - ', tbl_studiengang.bezeichnung) AS name",
|
||||
false
|
||||
);
|
||||
$this->StudiengangModel->addSelect('erhalter_kz');
|
||||
$this->StudiengangModel->addSelect('typ');
|
||||
$this->StudiengangModel->addSelect('kurzbz');
|
||||
$this->StudiengangModel->addSelect('studiengang_kz');
|
||||
$this->StudiengangModel->addSelect('studiengang_kz AS stg_kz');
|
||||
|
||||
$this->StudiengangModel->addOrder('erhalter_kz');
|
||||
$this->StudiengangModel->addOrder('typ');
|
||||
$this->StudiengangModel->addOrder('kurzbz');
|
||||
|
||||
$stgs = $this->permissionlib->getSTG_isEntitledFor('admin') ?: [];
|
||||
$stgs = array_merge($stgs, $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: []);
|
||||
|
||||
if (!$stgs)
|
||||
$this->terminateWithSuccess([]);
|
||||
|
||||
$this->StudiengangModel->db->where_in('studiengang_kz', $stgs);
|
||||
|
||||
$result = $this->StudiengangModel->loadWhere(['v.aktiv' => true]);
|
||||
|
||||
$list = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if ($this->permissionlib->isBerechtigt('inout/uebersicht'))
|
||||
$list[] = [
|
||||
'name' => 'International',
|
||||
'link' => 'inout',
|
||||
'children' => [
|
||||
[
|
||||
'name' => 'Incoming',
|
||||
'link' => 'inout/incoming',
|
||||
'leaf' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Outgoing',
|
||||
'link' => 'inout/outgoing',
|
||||
'leaf' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Gemeinsame Studien',
|
||||
'link' => 'inout/gemeinsamestudien',
|
||||
'leaf' => true
|
||||
]
|
||||
]
|
||||
];
|
||||
$this->terminateWithSuccess($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $studiengang_kz
|
||||
* @param string $orgform (optional)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getStudiengang($studiengang_kz, $org_form = null)
|
||||
{
|
||||
$link = $studiengang_kz . '/';
|
||||
if ($org_form !== null)
|
||||
$link .= $org_form . '/';
|
||||
|
||||
$this->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
|
||||
|
||||
$this->StudiengangModel->addDistinct();
|
||||
$this->StudiengangModel->addSelect("CONCAT(" . $this->StudiengangModel->escape($link) . ", semester) AS link", false);
|
||||
$this->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester ORDER BY verband, gruppe LIMIT 1)) AS name", false);
|
||||
|
||||
$this->StudiengangModel->addSelect('semester');
|
||||
$this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false);
|
||||
|
||||
$this->StudiengangModel->addOrder('semester');
|
||||
|
||||
if ($org_form !== null) {
|
||||
$this->StudiengangModel->db->group_start();
|
||||
$this->StudiengangModel->db->where('v.semester', 0);
|
||||
$this->StudiengangModel->db->or_where('v.orgform_kurzbz', $org_form);
|
||||
$this->StudiengangModel->db->group_end();
|
||||
}
|
||||
|
||||
$result = $this->StudiengangModel->loadWhere([
|
||||
'v.studiengang_kz' => $studiengang_kz,
|
||||
'v.aktiv' => true
|
||||
]);
|
||||
$list = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
array_unshift($list, [
|
||||
'name' => 'PreStudent',
|
||||
'link' => $link . 'prestudent',
|
||||
'children' => $this->getStdSem($link . 'prestudent/', $studiengang_kz)
|
||||
]);
|
||||
|
||||
if ($org_form === null) {
|
||||
// NOTE(chris): if mischform show orgforms
|
||||
$result = $this->StudiengangModel->load($studiengang_kz);
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
if ($result) {
|
||||
if (current($result)->mischform) {
|
||||
$this->load->model('organisation/Studienordnung_model', 'StudienordnungModel');
|
||||
|
||||
$this->StudienordnungModel->addDistinct();
|
||||
$this->StudienordnungModel->addSelect("CONCAT(studiengang_kz, '/', p.orgform_kurzbz) AS link");
|
||||
$this->StudienordnungModel->addSelect("p.orgform_kurzbz AS name");
|
||||
|
||||
$this->StudienordnungModel->addJoin('lehre.tbl_studienplan p', 'studienordnung_id');
|
||||
|
||||
$result = $this->StudienordnungModel->loadWhere([
|
||||
'aktiv' => true,
|
||||
'studiengang_kz' => $studiengang_kz,
|
||||
'p.orgform_kurzbz !=' => 'DDP'
|
||||
]);
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$list = array_merge($list, $result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$this->terminateWithSuccess($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $studiengang_kz
|
||||
* @param integer $semester
|
||||
* @param string $orgform
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getSemester($studiengang_kz, $semester, $org_form = null)
|
||||
{
|
||||
$link = $studiengang_kz . '/';
|
||||
if ($org_form !== null)
|
||||
$link .= $org_form . '/';
|
||||
$link .= $semester . '/';
|
||||
|
||||
|
||||
$this->load->model('organisation/Gruppe_model', 'GruppeModel');
|
||||
|
||||
$this->GruppeModel->addDistinct();
|
||||
$this->GruppeModel->addSelect("CONCAT(" . $this->GruppeModel->escape($link . 'grp/') . ", gruppe_kurzbz) AS link", false);
|
||||
$this->GruppeModel->addSelect("CONCAT(gruppe_kurzbz, ' (', bezeichnung, ')') AS name", false);
|
||||
$this->GruppeModel->addSelect("TRUE AS leaf", false);
|
||||
|
||||
$this->GruppeModel->addSelect('sort');
|
||||
$this->GruppeModel->addSelect('gruppe_kurzbz');
|
||||
$this->GruppeModel->addSelect($this->GruppeModel->escape($studiengang_kz) . '::integer AS stg_kz', false);
|
||||
|
||||
$this->GruppeModel->addOrder('sort');
|
||||
$this->GruppeModel->addOrder('gruppe_kurzbz');
|
||||
|
||||
$where = [
|
||||
'studiengang_kz' => $studiengang_kz,
|
||||
'semester' => $semester,
|
||||
'lehre' => true,
|
||||
'sichtbar' => true,
|
||||
'aktiv' => true,
|
||||
'direktinskription' => false
|
||||
];
|
||||
|
||||
if ($org_form !== null)
|
||||
$where['orgform_kurzbz'] = $org_form;
|
||||
|
||||
$result = $this->GruppeModel->loadWhere($where);
|
||||
|
||||
$list = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
|
||||
|
||||
$this->StudiengangModel->addSelect("CONCAT(" . $this->StudiengangModel->escape($link) . ", verband) AS link", false);
|
||||
$this->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, verband, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester AND verband=v.verband ORDER BY gruppe LIMIT 1)) AS name", false);
|
||||
$this->StudiengangModel->addSelect("CASE WHEN MAX(gruppe)='' OR MAX(gruppe)=' ' THEN TRUE ELSE FALSE END AS leaf");
|
||||
|
||||
$this->StudiengangModel->addSelect('verband');
|
||||
$this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false);
|
||||
|
||||
$this->StudiengangModel->addOrder('verband');
|
||||
|
||||
$this->StudiengangModel->addGroupBy('link, name, verband');
|
||||
|
||||
$where = [
|
||||
'v.studiengang_kz' => $studiengang_kz,
|
||||
'v.semester' => $semester,
|
||||
'v.verband !=' => '',
|
||||
'v.aktiv' => true
|
||||
];
|
||||
|
||||
if ($org_form !== null && $semester) // NOTE(chris): on semester 0 show all?
|
||||
$where['v.orgform_kurzbz'] = $org_form;
|
||||
|
||||
$result = $this->StudiengangModel->loadWhere($where);
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$list = array_merge($list, $result);
|
||||
|
||||
$this->terminateWithSuccess($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $studiengang_kz
|
||||
* @param integer $semester
|
||||
* @param integer $verband
|
||||
* @param string $orgform
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getVerband($studiengang_kz, $semester, $verband, $org_form = null)
|
||||
{
|
||||
$link = $studiengang_kz . '/';
|
||||
if ($org_form !== null)
|
||||
$link .= $org_form . '/';
|
||||
$link .= $semester . '/'. $verband . '/';
|
||||
|
||||
|
||||
$this->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
|
||||
|
||||
$this->StudiengangModel->addDistinct();
|
||||
$this->StudiengangModel->addSelect("CONCAT(" . $this->StudiengangModel->escape($link) . ", gruppe) AS link", false);
|
||||
$this->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, verband, gruppe, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester AND verband=v.verband AND gruppe=v.gruppe ORDER BY gruppe LIMIT 1)) AS name", false);
|
||||
$this->StudiengangModel->addSelect("TRUE AS leaf", false);
|
||||
|
||||
$this->StudiengangModel->addSelect('gruppe');
|
||||
$this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false);
|
||||
|
||||
$this->StudiengangModel->addOrder('gruppe');
|
||||
|
||||
$where = [
|
||||
'v.studiengang_kz' => $studiengang_kz,
|
||||
'v.semester' => $semester,
|
||||
'v.verband' => $verband,
|
||||
'v.gruppe !=' => '',
|
||||
'v.aktiv' => true
|
||||
];
|
||||
|
||||
if ($org_form !== null && $semester) // NOTE(chris): on semester 0 show all?
|
||||
$where['v.orgform_kurzbz'] = $org_form;
|
||||
|
||||
$result = $this->StudiengangModel->loadWhere($where);
|
||||
|
||||
$list = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $link
|
||||
* @param integer $studiengang_kz
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getStdSem($link, $studiengang_kz)
|
||||
{
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
$this->load->model('system/Variable_model', 'VariableModel');
|
||||
$result = $this->VariableModel->getVariables(getAuthUID(), ['number_displayed_past_studiensemester']);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$number_displayed_past_studiensemester = $data['number_displayed_past_studiensemester'] ?? null;
|
||||
|
||||
$this->StudiensemesterModel->addPlusMinus(null, $number_displayed_past_studiensemester);
|
||||
$this->StudiensemesterModel->addOrder('ende');
|
||||
$result = $this->StudiensemesterModel->load();
|
||||
|
||||
$studiensemester = $this->getDataOrTerminateWithError($result);
|
||||
$result = [];
|
||||
|
||||
$studiengang_kz = (int)$studiengang_kz;
|
||||
|
||||
foreach ($studiensemester as $sem) {
|
||||
$semlink = $link . $sem->studiensemester_kurzbz;
|
||||
$intlink = $semlink . '/interessenten';
|
||||
$result[] = [
|
||||
'name' => $sem->studiensemester_kurzbz,
|
||||
'link' => $semlink,
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'children' => [
|
||||
[
|
||||
'name' => 'Interessenten',
|
||||
'link' => $intlink,
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'children' => [
|
||||
[
|
||||
'name' => 'Bewerbung nicht abgeschickt',
|
||||
'link' => $intlink . '/bewerbungnichtabgeschickt',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'leaf' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Bewerbung abgeschickt, Status unbestätigt',
|
||||
'link' => $intlink . '/bewerbungabgeschickt',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'leaf' => true
|
||||
],
|
||||
[
|
||||
'name' => 'ZGV erfüllt',
|
||||
'link' => $intlink . '/zgv',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'leaf' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Status bestätigt',
|
||||
'link' => $intlink . '/statusbestaetigt',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'children' => [
|
||||
[
|
||||
'name' => 'Nicht zum Reihungstest angemeldet',
|
||||
'link' => $intlink . '/statusbestaetigtrtnichtangemeldet',
|
||||
'leaf' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Reihungstest angemeldet',
|
||||
'link' => $intlink . '/statusbestaetigtrtangemeldet',
|
||||
'leaf' => true
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'Nicht zum Reihungstest angemeldet',
|
||||
'link' => $intlink . '/reihungstestnichtangemeldet',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'leaf' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Reihungstest angemeldet',
|
||||
'link' => $intlink . '/reihungstestangemeldet',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'leaf' => true
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'Bewerber',
|
||||
'link' => $semlink . '/bewerber',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'children' => [
|
||||
[
|
||||
'name' => 'Nicht zum Reihungstest angemeldet',
|
||||
'link' => $intlink . '/bewerberrtnichtangemeldet',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'leaf' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Reihungstest angemeldet',
|
||||
'link' => $intlink . '/bewerberrtangemeldet',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'children' => [
|
||||
[
|
||||
'name' => 'Teilgenommen',
|
||||
'link' => $intlink . '/bewerberrtangemeldetteilgenommen',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'leaf' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Nicht teilgenommen',
|
||||
'link' => $intlink . '/bewerberrtangemeldetnichtteilgenommen',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'leaf' => true
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'Aufgenommen',
|
||||
'link' => $semlink . '/aufgenommen',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'leaf' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Warteliste',
|
||||
'link' => $semlink . '/warteliste',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'leaf' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Absage',
|
||||
'link' => $semlink . '/absage',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'leaf' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Incoming',
|
||||
'link' => $semlink . '/incoming',
|
||||
'stg_kz' => $studiengang_kz,
|
||||
'leaf' => true
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -264,4 +264,4 @@ class Person extends API_Controller
|
||||
|
||||
return success('Input data are valid');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,12 @@ if (! defined("BASEPATH")) exit("No direct script access allowed");
|
||||
class UHSTAT1 extends FHC_Controller
|
||||
{
|
||||
const BERECHTIGUNG_UHSTAT_VERWALTEN = 'student/uhstat1daten_verwalten';
|
||||
const LOGIN_SESSION_INDEX = 'bewerbung/user';
|
||||
const PERSON_ID_SESSION_INDEX = 'bewerbung/personId';
|
||||
const CODEX_OESTERREICH = 'A';
|
||||
const CODEX_UNKNOWN_YEAR = 9999;
|
||||
const CODEX_UNKNOWN_NATION = 'XXX';
|
||||
const CODEX_UNKNOWN_BILDUNGMAX = 999;
|
||||
const LOWER_BOUNDARY_YEARS = 160;
|
||||
const UPPER_BOUNDARY_YEARS = 20;
|
||||
|
||||
@@ -210,7 +214,9 @@ class UHSTAT1 extends FHC_Controller
|
||||
else
|
||||
return true;
|
||||
|
||||
if (!isset($bildungsstaat)) return true;
|
||||
// if no Bildungsstaat or Bildungmax unknown - valid
|
||||
if (!isset($bildungsstaat) || $bildungmax == self::CODEX_UNKNOWN_BILDUNGMAX) return true;
|
||||
|
||||
|
||||
// find out if abschluss is in Austria
|
||||
$this->AbschlussModel->addSelect("in_oesterreich");
|
||||
@@ -219,8 +225,11 @@ class UHSTAT1 extends FHC_Controller
|
||||
if (hasData($abschlussRes))
|
||||
{
|
||||
$in_oesterreich = getData($abschlussRes)[0]->in_oesterreich;
|
||||
// invalid if abschluss in Austria, but not Bildungsstaat, or abschluss not in Austria, but Bildungsstaat in Austria
|
||||
return ($in_oesterreich && $bildungsstaat == self::CODEX_OESTERREICH) || (!$in_oesterreich && $bildungsstaat != self::CODEX_OESTERREICH);
|
||||
|
||||
// valid if Bildungsstaat and Abschluss in Austria, or Bildungsstaat and Abschluss not in Austria
|
||||
// (or Abschluss not in Austria and Bildungsstaat unknown)
|
||||
return ($in_oesterreich && $bildungsstaat == self::CODEX_OESTERREICH)
|
||||
|| (!$in_oesterreich && ($bildungsstaat != self::CODEX_OESTERREICH || $bildungsstaat == self::CODEX_UNKNOWN_NATION));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -363,7 +372,11 @@ class UHSTAT1 extends FHC_Controller
|
||||
|
||||
// get realistic birth years, dated back from current year
|
||||
$currYear = date("Y");
|
||||
$formMetaData['jahre'] = range($currYear - self::UPPER_BOUNDARY_YEARS, $currYear - self::LOWER_BOUNDARY_YEARS);
|
||||
$yearRange = range($currYear - self::UPPER_BOUNDARY_YEARS, $currYear - self::LOWER_BOUNDARY_YEARS);
|
||||
$formMetaData['jahre'] = array_combine($yearRange, $yearRange);
|
||||
|
||||
// add "unknown" option
|
||||
$formMetaData['jahre'][self::CODEX_UNKNOWN_YEAR] = 'unbekannt';
|
||||
|
||||
return success($formMetaData);
|
||||
}
|
||||
@@ -411,7 +424,10 @@ class UHSTAT1 extends FHC_Controller
|
||||
private function _getValidPersonId($berechtigungsArt)
|
||||
{
|
||||
// if coming from bewerbungstool - person id is in session (person must be logged in bewerbungstool)
|
||||
if (isset($_SESSION[self::PERSON_ID_SESSION_INDEX]) && is_numeric($_SESSION[self::PERSON_ID_SESSION_INDEX]))
|
||||
if (isset($_SESSION[self::PERSON_ID_SESSION_INDEX])
|
||||
&& is_numeric($_SESSION[self::PERSON_ID_SESSION_INDEX])
|
||||
&& isset($_SESSION[self::LOGIN_SESSION_INDEX])
|
||||
)
|
||||
return $_SESSION[self::PERSON_ID_SESSION_INDEX];
|
||||
|
||||
// if person id passed directly...
|
||||
|
||||
@@ -1,218 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \Studierendenantrag_model as Studierendenantrag_model;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Abmeldung extends FHC_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Calls the parent's constructor and loads the FilterCmptLib
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Libraries
|
||||
$this->load->library('AuthLib');
|
||||
$this->load->library('AntragLib');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'studierendenantrag'
|
||||
]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Retrieves data of the current studiengang for the current user
|
||||
*/
|
||||
|
||||
public function getDetailsForNewAntrag($prestudent_id)
|
||||
{
|
||||
if (!$this->antraglib->isEntitledToCreateAntragFor($prestudent_id, true)) {
|
||||
$this->output->set_status_header(403);
|
||||
return $this->outputJsonError('Forbidden');
|
||||
}
|
||||
$result = $this->antraglib->getPrestudentAbmeldeBerechtigt($prestudent_id);
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(500);
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
$result = $result->retval;
|
||||
if (!$result) {
|
||||
$this->output->set_status_header(403);
|
||||
return $this->outputJsonError($this->p->t('studierendenantrag', 'error_no_student'));
|
||||
}
|
||||
elseif ($result == -3)
|
||||
{
|
||||
$this->output->set_status_header(403);
|
||||
return $this->outputJsonError($this->p->t('studierendenantrag', 'error_stg_blacklist'));
|
||||
}
|
||||
elseif ($result == -1)
|
||||
{
|
||||
$result = $this->antraglib->getDetailsForLastAntrag(
|
||||
$prestudent_id,
|
||||
[
|
||||
Studierendenantrag_model::TYP_ABMELDUNG,
|
||||
Studierendenantrag_model::TYP_ABMELDUNG_STGL
|
||||
]
|
||||
);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
|
||||
$data = getData($result);
|
||||
|
||||
$data->canCancel = (
|
||||
$data->status == Studierendenantragstatus_model::STATUS_CREATED &&
|
||||
$this->antraglib->isEntitledToCancelAntrag($data->studierendenantrag_id)
|
||||
);
|
||||
|
||||
return $this->outputJsonSuccess($data);
|
||||
}
|
||||
|
||||
$result = $this->antraglib->getDetailsForNewAntrag($prestudent_id);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
|
||||
$this->outputJsonSuccess(getData($result));
|
||||
}
|
||||
|
||||
public function getDetailsForAntrag($studierendenantrag_id)
|
||||
{
|
||||
if (!$this->antraglib->isEntitledToShowAntrag($studierendenantrag_id)) return show_404();
|
||||
|
||||
$result = $this->antraglib->getDetailsForAntrag($studierendenantrag_id);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
|
||||
$data = getData($result);
|
||||
|
||||
if ($data->typ !== Studierendenantrag_model::TYP_ABMELDUNG_STGL && $data->typ !== Studierendenantrag_model::TYP_ABMELDUNG)
|
||||
return show_404();
|
||||
|
||||
$data->canCancel = (
|
||||
$data->status == Studierendenantragstatus_model::STATUS_CREATED &&
|
||||
$this->antraglib->isEntitledToCancelAntrag($data->studierendenantrag_id)
|
||||
);
|
||||
|
||||
$this->outputJsonSuccess($data);
|
||||
}
|
||||
|
||||
public function createAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules('studiensemester', 'Studiensemester', 'required');
|
||||
$this->form_validation->set_rules('prestudent_id', 'Prestudent ID', 'required');
|
||||
$this->form_validation->set_rules('grund', 'Grund', 'required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$grund = $this->input->post('grund');
|
||||
$studiensemester = $this->input->post('studiensemester');
|
||||
$prestudent_id = $this->input->post('prestudent_id');
|
||||
|
||||
$result = $this->antraglib->getPrestudentAbmeldeBerechtigt($prestudent_id);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(['db' => getError($result)]);
|
||||
}
|
||||
$result = $result->retval;
|
||||
if (!$result)
|
||||
{
|
||||
return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_no_student')]);
|
||||
}
|
||||
elseif ($result == -3)
|
||||
{
|
||||
return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_stg_blacklist')]);
|
||||
}
|
||||
elseif ($result < 0)
|
||||
{
|
||||
return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_antrag_exists')]);
|
||||
}
|
||||
|
||||
$result = $this->antraglib->createAbmeldung($prestudent_id, $studiensemester, getAuthUID(), $grund);
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->outputJsonError(['db' => getError($result)]);
|
||||
}
|
||||
|
||||
$result = $this->antraglib->getDetailsForAntrag(getData($result));
|
||||
if (!hasData($result))
|
||||
return $this->outputJsonSuccess(true);
|
||||
|
||||
$data = getData($result);
|
||||
$data->canCancel = (boolean)$this->antraglib->isEntitledToCancelAntrag($data->studierendenantrag_id);
|
||||
|
||||
$this->outputJsonSuccess($data);
|
||||
}
|
||||
|
||||
public function cancelAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules('antrag_id', 'Antrag ID', 'required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$antrag_id = $this->input->post('antrag_id');
|
||||
if(!$this->antraglib->isEntitledToCancelAntrag($antrag_id))
|
||||
{
|
||||
$this->output->set_status_header(403);
|
||||
|
||||
return $this->outputJsonError('Forbidden');
|
||||
}
|
||||
|
||||
$result = $this->antraglib->cancelAntrag($antrag_id, getAuthUID());
|
||||
if(isError($result))
|
||||
{
|
||||
return $this->outputJsonError(['db' => getError($result)]);
|
||||
}
|
||||
|
||||
$result = $this->antraglib->getDetailsForAntrag($antrag_id);
|
||||
|
||||
if (!hasData($result))
|
||||
return $this->outputJsonSuccess($antrag_id);
|
||||
$this->outputJsonSuccess(getData($result));
|
||||
}
|
||||
|
||||
public function getStudiengaengeAssistenz()
|
||||
{
|
||||
$this->load->library('PermissionLib');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
$query = $this->input->post('query');
|
||||
|
||||
$studiengaenge = $this->permissionlib->getSTG_isEntitledFor('student/studierendenantrag');
|
||||
|
||||
$result = $this->antraglib->getAktivePrestudentenInStgs($studiengaenge, $query);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
$result = getData($result);
|
||||
if (!$result) {
|
||||
return $this->outputJsonSuccess([]);
|
||||
}
|
||||
|
||||
return $this->outputJsonSuccess($result);
|
||||
}
|
||||
}
|
||||
@@ -1,479 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \stdClass as stdClass;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Leitung extends FHC_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Calls the parent's constructor and loads the FilterCmptLib
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Libraries
|
||||
$this->load->library('AuthLib');
|
||||
$this->load->library('AntragLib');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'studierendenantrag'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
public function getActiveStgs()
|
||||
{
|
||||
$studiengaenge = $this->permissionlib->getSTG_isEntitledFor('student/antragfreigabe') ?: [];
|
||||
$studiengaenge = array_merge($studiengaenge, $this->permissionlib->getSTG_isEntitledFor('student/studierendenantrag') ?: []);
|
||||
|
||||
$result = $this->StudierendenantragModel->loadStgsWithAntraege($studiengaenge);
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
$this->outputJson($result);
|
||||
}
|
||||
|
||||
public function getAntraege($studiengang = null, $extra = null)
|
||||
{
|
||||
if ($studiengang && $studiengang == 'todo') {
|
||||
$studiengang = $extra;
|
||||
$extra = true;
|
||||
} else {
|
||||
$extra = false;
|
||||
}
|
||||
|
||||
if ($studiengang) {
|
||||
$studiengaenge = [$studiengang];
|
||||
} else {
|
||||
$studiengaenge =$this->permissionlib->getSTG_isEntitledFor('student/antragfreigabe');
|
||||
if(!is_array($studiengaenge))
|
||||
$studiengaenge = [];
|
||||
|
||||
|
||||
$stgsNeuanlage = $this->permissionlib->getSTG_isEntitledFor('student/studierendenantrag');
|
||||
if(!is_array($stgsNeuanlage))
|
||||
$stgsNeuanlage = [];
|
||||
|
||||
$studiengaenge = array_unique(array_merge($studiengaenge, $stgsNeuanlage));
|
||||
}
|
||||
|
||||
|
||||
$antraege = [];
|
||||
if ($studiengaenge) {
|
||||
$result = $extra
|
||||
? $this->StudierendenantragModel->loadActiveForStudiengaenge($studiengaenge)
|
||||
: $this->StudierendenantragModel->loadForStudiengaenge($studiengaenge);
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(500);
|
||||
return $this->outputJson('Internal Server Error');
|
||||
}
|
||||
if(hasData($result))
|
||||
{
|
||||
$antraege = getData($result);
|
||||
}
|
||||
}
|
||||
|
||||
$this->outputJson($antraege);
|
||||
}
|
||||
|
||||
public function reopenAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
'required|callback_isEntitledToReopenAntrag',
|
||||
[
|
||||
'isEntitledToReopenAntrag' => $this->p->t('studierendenantrag', 'error_no_right')
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
|
||||
$result = $this->antraglib->reopenWiederholung($studierendenantrag_id, getAuthUID());
|
||||
|
||||
if (isError($result))
|
||||
return $this->outputJsonError(['studierendenantrag_id' => getError($result)]);
|
||||
|
||||
$this->outputJsonSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function pauseAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
[
|
||||
'required',
|
||||
[
|
||||
'isEntitledToPauseAntrag',
|
||||
[$this->antraglib, 'isEntitledToPauseAntrag']
|
||||
],
|
||||
[
|
||||
'antragCanBeManualPaused',
|
||||
[$this->antraglib, 'antragCanBeManualPaused']
|
||||
]
|
||||
],
|
||||
[
|
||||
'isEntitledToPauseAntrag' => $this->p->t('studierendenantrag', 'error_no_right'),
|
||||
'antragCanBeManualPaused' => $this->p->t(
|
||||
'studierendenantrag',
|
||||
'error_not_pauseable',
|
||||
['id' => $this->input->post('studierendenantrag_id')]
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
|
||||
$result = $this->antraglib->pauseAntrag($studierendenantrag_id, getAuthUID());
|
||||
|
||||
if (isError($result))
|
||||
return $this->outputJsonError(['studierendenantrag_id' => getError($result)]);
|
||||
|
||||
$this->outputJsonSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function unpauseAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
[
|
||||
'required',
|
||||
[
|
||||
'isEntitledToUnpauseAntrag',
|
||||
[$this->antraglib, 'isEntitledToUnpauseAntrag']
|
||||
],
|
||||
[
|
||||
'antragCanBeManualUnpaused',
|
||||
[$this->antraglib, 'antragCanBeManualUnpaused']
|
||||
]
|
||||
],
|
||||
[
|
||||
'isEntitledToUnpauseAntrag' => $this->p->t('studierendenantrag', 'error_no_right'),
|
||||
'antragCanBeManualUnpaused' => $this->p->t(
|
||||
'studierendenantrag',
|
||||
'error_not_paused',
|
||||
['id' => $this->input->post('studierendenantrag_id')]
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
|
||||
$result = $this->antraglib->unpauseAntrag($studierendenantrag_id, getAuthUID());
|
||||
|
||||
if (isError($result))
|
||||
return $this->outputJsonError(['studierendenantrag_id' => getError($result)]);
|
||||
|
||||
$this->outputJsonSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function objectAntrag()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
'required|callback_isEntitledToObjectAntrag|callback_canBeObjected',
|
||||
[
|
||||
'isEntitledToObjectAntrag' => $this->p->t('studierendenantrag', 'error_no_right'),
|
||||
'canBeObjected' => $this->p->t('studierendenantrag', 'error_no_objection')
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
|
||||
$result = $this->antraglib->objectAbmeldung($studierendenantrag_id, getAuthUID());
|
||||
|
||||
if (isError($result))
|
||||
return $this->outputJsonError(['studierendenantrag_id' => getError($result)]);
|
||||
|
||||
$this->outputJsonSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function objectionDeny()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
'required|callback_isEntitledToObjectAntrag|callback_isObjected',
|
||||
[
|
||||
'isEntitledToObjectAntrag' => $this->p->t('studierendenantrag', 'error_no_right'),
|
||||
'isObjected' => $this->p->t('studierendenantrag', 'error_not_objected')
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
$grund = $this->input->post('grund');
|
||||
|
||||
$result = $this->antraglib->denyObjectionAbmeldung($studierendenantrag_id, getAuthUID(), $grund);
|
||||
|
||||
if (isError($result))
|
||||
return $this->outputJsonError(['studierendenantrag_id' => getError($result)]);
|
||||
|
||||
$this->outputJsonSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function objectionApprove()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
'required|callback_isEntitledToObjectAntrag|callback_isObjected',
|
||||
[
|
||||
'isEntitledToObjectAntrag' => $this->p->t('studierendenantrag', 'error_no_right'),
|
||||
'isObjected' => $this->p->t('studierendenantrag', 'error_not_objected')
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
|
||||
$result = $this->antraglib->cancelAntrag($studierendenantrag_id, getAuthUID());
|
||||
|
||||
if (isError($result))
|
||||
return $this->outputJsonError(['studierendenantrag_id' => getError($result)]);
|
||||
|
||||
$this->outputJsonSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function isEntitledToReopenAntrag($studierendenantrag_id)
|
||||
{
|
||||
return $this->antraglib->isEntitledToReopenAntrag($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function isEntitledToObjectAntrag($studierendenantrag_id)
|
||||
{
|
||||
return $this->antraglib->isEntitledToObjectAntrag($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function isEntitledToRejectAntrag($studierendenantrag_id)
|
||||
{
|
||||
return $this->antraglib->isEntitledToRejectAntrag($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function canBeObjected($studierendenantrag_id)
|
||||
{
|
||||
return $this->antraglib->hasType($studierendenantrag_id, Studierendenantrag_model::TYP_ABMELDUNG_STGL);
|
||||
}
|
||||
|
||||
public function isObjected($studierendenantrag_id)
|
||||
{
|
||||
return $this->antraglib->hasStatus($studierendenantrag_id, Studierendenantragstatus_model::STATUS_OBJECTED);
|
||||
}
|
||||
|
||||
|
||||
public function approveAbmeldung()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
'required|callback_isEntitledToApproveAntrag',
|
||||
[
|
||||
'isEntitledToApproveAntrag' => $this->p->t('studierendenantrag', 'error_no_right')
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
|
||||
$result = $this->antraglib->approveAbmeldung([$studierendenantrag_id], getAuthUID());
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->outputJsonError(['db' => getError($result)]);
|
||||
}
|
||||
|
||||
return $this->outputJsonSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function approveAbmeldungStgl()
|
||||
{
|
||||
return $this->approveAbmeldung();
|
||||
}
|
||||
|
||||
public function approveUnterbrechung()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
'required|callback_isEntitledToApproveAntrag',
|
||||
[
|
||||
'isEntitledToApproveAntrag' => $this->p->t('studierendenantrag', 'error_no_right')
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
|
||||
$result = $this->antraglib->approveUnterbrechung([$studierendenantrag_id], getAuthUID());
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->outputJsonError(['db' => getError($result)]);
|
||||
}
|
||||
|
||||
return $this->outputJsonSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function rejectUnterbrechung()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
'required|callback_isEntitledToRejectAntrag',
|
||||
[
|
||||
'isEntitledToRejectAntrag' => $this->p->t('studierendenantrag', 'error_no_right')
|
||||
]
|
||||
);
|
||||
$this->form_validation->set_rules('grund', 'Grund', 'required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
$grund = $this->input->post('grund');
|
||||
|
||||
$result = $this->antraglib->rejectUnterbrechung([$studierendenantrag_id], getAuthUID(), $grund);
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->outputJsonError(['db' => getError($result)]);
|
||||
}
|
||||
|
||||
return $this->outputJsonSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function approveWiederholung()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules(
|
||||
'studierendenantrag_id',
|
||||
'Studierenden Antrag',
|
||||
'required|callback_isEntitledToApproveAntrag',
|
||||
[
|
||||
'isEntitledToApproveAntrag' => $this->p->t('studierendenantrag', 'error_no_right')
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$studierendenantrag_id = $this->input->post('studierendenantrag_id');
|
||||
|
||||
$result = $this->antraglib->approveWiederholung($studierendenantrag_id, getAuthUID());
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->outputJsonError(['db' => getError($result)]);
|
||||
}
|
||||
|
||||
return $this->outputJsonSuccess($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function isEntitledToApproveAntrag($studierendenantrag_id)
|
||||
{
|
||||
return $this->antraglib->isEntitledToApproveAntrag($studierendenantrag_id);
|
||||
}
|
||||
|
||||
public function getHistory($studierendenantrag_id)
|
||||
{
|
||||
if (!$this->antraglib->isEntitledToSeeHistoryForAntrag($studierendenantrag_id)) {
|
||||
$this->output->set_status_header(403);
|
||||
return $this->outputJson('Forbidden');
|
||||
}
|
||||
|
||||
$result = $this->antraglib->getAntragHistory($studierendenantrag_id);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
|
||||
$this->outputJsonSuccess(getData($result) ?: []);
|
||||
}
|
||||
}
|
||||
@@ -1,384 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \REST_Controller as REST_Controller;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Wiederholung extends FHC_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Calls the parent's constructor and loads the FilterCmptLib
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Configs
|
||||
$this->load->config('studierendenantrag');
|
||||
|
||||
// Libraries
|
||||
$this->load->library('AuthLib');
|
||||
$this->load->library('PermissionLib');
|
||||
$this->load->library('AntragLib');
|
||||
|
||||
$requiredPermissions = [
|
||||
'saveLvs' => ['student/studierendenantrag:w'],
|
||||
'getLvsAsRdf' => ['student/studierendenantrag:r', 'student/noten:r'],
|
||||
'moveLvsToZeugnis' => ['student/studierendenantrag:w', 'student/noten:w']
|
||||
];
|
||||
|
||||
if (isset($requiredPermissions[$this->router->method])) {
|
||||
if (!$this->permissionlib->isEntitled($requiredPermissions, $this->router->method)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_FORBIDDEN);
|
||||
$this->outputJson('Forbidden');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'global',
|
||||
'studierendenantrag'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Retrieves data of the current studiengang for the current user
|
||||
*/
|
||||
|
||||
public function getDetailsForNewAntrag($prestudent_id)
|
||||
{
|
||||
if (!$this->antraglib->isEntitledToCreateAntragFor($prestudent_id, false)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_FORBIDDEN);
|
||||
return $this->outputJsonError('Forbidden');
|
||||
}
|
||||
$result = $this->antraglib->getPrestudentWiederholungsBerechtigt($prestudent_id);
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
$result = $result->retval;
|
||||
if (!$result) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_FORBIDDEN);
|
||||
return $this->outputJsonError($this->p->t('studierendenantrag', 'error_no_student_no_failed_exam'));
|
||||
}
|
||||
elseif ($result == -1)
|
||||
{
|
||||
$result = $this->antraglib->getDetailsForLastAntrag($prestudent_id, Studierendenantrag_model::TYP_WIEDERHOLUNG);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
$data = getData($result);
|
||||
|
||||
$result = $this->antraglib->getFailedExamForPrestudent($prestudent_id, $data->datum, $data->studiensemester_kurzbz);
|
||||
// NOTE(chris): error handling for this function should already happenden in antraglib->getPrestudentWiederholungsBerechtigt()
|
||||
$pruefungsdata = current(getData($result));
|
||||
|
||||
$data->studiensemester_kurzbz = $pruefungsdata->studiensemester_kurzbz;
|
||||
$data->lvbezeichnung = $pruefungsdata->lvbezeichnung;
|
||||
$data->pruefungsdatum = $pruefungsdata->datum;
|
||||
|
||||
return $this->outputJsonSuccess($data);
|
||||
}
|
||||
elseif ($result == -2)
|
||||
{
|
||||
$result = $this->antraglib->getDetailsForLastAntrag($prestudent_id);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
|
||||
$result = getData($result);
|
||||
$this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST);
|
||||
return $this->outputJsonError($this->p->t('studierendenantrag', 'error_antrag_pending', [
|
||||
'typ' => $this->p->t('studierendenantrag', 'antrag_typ_' . $result->typ)
|
||||
]));
|
||||
}
|
||||
elseif ($result == -3)
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST);
|
||||
return $this->outputJsonError($this->p->t('studierendenantrag', 'error_stg_blacklist'));
|
||||
}
|
||||
|
||||
$result = $this->antraglib->getDetailsForNewAntrag($prestudent_id);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
|
||||
$data = getData($result);
|
||||
|
||||
$result = $this->antraglib->getFailedExamForPrestudent($prestudent_id);
|
||||
// NOTE(chris): error handling for this function should already happenden in antraglib->getPrestudentWiederholungsBerechtigt()
|
||||
$pruefungsdata = current(getData($result));
|
||||
|
||||
$data->studiensemester_kurzbz = $pruefungsdata->studiensemester_kurzbz;
|
||||
$data->lvbezeichnung = $pruefungsdata->lvbezeichnung;
|
||||
$data->pruefungsdatum = $pruefungsdata->datum;
|
||||
|
||||
$this->outputJsonSuccess($data);
|
||||
}
|
||||
|
||||
public function createAntrag()
|
||||
{
|
||||
$this->createAntragWithStatus(true);
|
||||
}
|
||||
|
||||
public function cancelAntrag()
|
||||
{
|
||||
$this->createAntragWithStatus(false);
|
||||
}
|
||||
|
||||
protected function createAntragWithStatus($repeat)
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules('prestudent_id', 'Prestudent ID', 'required');
|
||||
$this->form_validation->set_rules('studiensemester', 'Studiensemester', 'required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$prestudent_id = $this->input->post('prestudent_id');
|
||||
$studiensemester = $this->input->post('studiensemester');
|
||||
|
||||
$result = $this->antraglib->getPrestudentWiederholungsBerechtigt($prestudent_id);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(['db' => getError($result)]);
|
||||
}
|
||||
$result = $result->retval;
|
||||
if (!$result)
|
||||
{
|
||||
return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_no_student')]);
|
||||
}
|
||||
elseif ($result == -1)
|
||||
{
|
||||
$result = $this->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
if (isError($result))
|
||||
return $this->outputJsonError(['db' => getError($result)]);
|
||||
if (!hasData($result))
|
||||
return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_no_prestudentstatus', [
|
||||
'prestudent_id' => $prestudent_id
|
||||
])]);
|
||||
if (!in_array(current(getData($result))->status_kurzbz, $this->config->item('antrag_prestudentstatus_whitelist')))
|
||||
return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_no_student')]);
|
||||
}
|
||||
elseif ($result == -2)
|
||||
{
|
||||
return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_antrag_exists')]);
|
||||
}
|
||||
elseif ($result == -3)
|
||||
{
|
||||
return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_stg_blacklist')]);
|
||||
}
|
||||
|
||||
$result = $this->antraglib->createWiederholung($prestudent_id, $studiensemester, getAuthUID(), $repeat);
|
||||
if(isError($result))
|
||||
{
|
||||
return $this->outputJsonError(['db' => getError($result)]);
|
||||
}
|
||||
|
||||
$antragId = getData($result);
|
||||
$result = $this->antraglib->getDetailsForAntrag($antragId);
|
||||
|
||||
if(!hasData($result))
|
||||
return $this->outputJsonSuccess(true);
|
||||
|
||||
$data = getData($result);
|
||||
|
||||
$result = $this->antraglib->getFailedExamForPrestudent($prestudent_id);
|
||||
// NOTE(chris): error handling for this function should already happenden in antraglib->getPrestudentWiederholungsBerechtigt()
|
||||
$pruefungsdata = current(getData($result));
|
||||
|
||||
$data->studiensemester_kurzbz = $pruefungsdata->studiensemester_kurzbz;
|
||||
$data->lvbezeichnung = $pruefungsdata->lvbezeichnung;
|
||||
$data->pruefungsdatum = $pruefungsdata->datum;
|
||||
|
||||
$this->outputJsonSuccess($data);
|
||||
}
|
||||
|
||||
|
||||
public function getLvs($antrag_id)
|
||||
{
|
||||
$result = $this->antraglib->getLvsForAntrag($antrag_id);
|
||||
if (isError($result)) {
|
||||
$error = getError($result);
|
||||
if ($error == 'Forbidden')
|
||||
$this->output->set_status_header(REST_Controller::HTTP_FORBIDDEN);
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
$lvs = getData($result);
|
||||
|
||||
$this->outputJsonSuccess($lvs);
|
||||
}
|
||||
|
||||
public function saveLvs()
|
||||
{
|
||||
$result = $this->getPostJSON();
|
||||
$antragsLvs = array_merge($result->forbiddenLvs, $result->mandatoryLvs);
|
||||
|
||||
$insert = array_map(function ($lv) {
|
||||
return [
|
||||
'studierendenantrag_id' => $lv->studierendenantrag_id,
|
||||
'lehrveranstaltung_id' => $lv->lehrveranstaltung_id,
|
||||
'note' => $lv->zugelassen
|
||||
? ($lv->zugelassen == 1 ? 0 : $this->config->item('wiederholung_note_angerechnet'))
|
||||
: $this->config->item('wiederholung_note_nicht_zugelassen'),
|
||||
'anmerkung' => $lv->anmerkung,
|
||||
'insertvon' => getAuthUID(),
|
||||
'studiensemester_kurzbz' => $lv->studiensemester_kurzbz
|
||||
];
|
||||
}, $antragsLvs);
|
||||
|
||||
$antrag_ids = array_unique(array_map(function ($lv) {
|
||||
return $lv['studierendenantrag_id'];
|
||||
}, $insert));
|
||||
|
||||
foreach ($antrag_ids as $antrag_id) {
|
||||
$result = $this->StudierendenantragModel->loadIdAndStatusWhere([
|
||||
'studierendenantrag_id' => $antrag_id
|
||||
]);
|
||||
if (isError($result))
|
||||
return $this->outputJsonError(getError($result));
|
||||
if (!hasData($result))
|
||||
return $this->outputJsonError($this->p->t('studierendenantrag', 'error_no_antrag_found', ['id' => $antrag_id]));
|
||||
$antrag = current(getData($result));
|
||||
if ($antrag->status != Studierendenantragstatus_model::STATUS_CREATED
|
||||
&& $antrag->status != Studierendenantragstatus_model::STATUS_LVSASSIGNED)
|
||||
return $this->outputJsonError($this->p->t('studierendenantrag', 'error_antrag_locked'));
|
||||
}
|
||||
|
||||
if(!$antragsLvs)
|
||||
return $this->outputJsonError($this->p->t('studierendenantrag', 'error_no_lv'));
|
||||
|
||||
$result = $this->antraglib->saveLvs($insert);
|
||||
|
||||
if (isError($result))
|
||||
return $this->outputJsonError(getError($result));
|
||||
|
||||
$this->outputJsonSuccess(getData($result));
|
||||
}
|
||||
|
||||
public function getLvsAsRdf($prestudent_id)
|
||||
{
|
||||
// header für no cache
|
||||
$this->output->set_header("Cache-Control: no-cache");
|
||||
$this->output->set_header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
$this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
$this->output->set_header("Pragma: no-cache");
|
||||
$this->output->set_header("Content-type: application/xhtml+xml");
|
||||
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$sem_akt = $this->variablelib->getVar('semester_aktuell');
|
||||
|
||||
|
||||
$result = $this->antraglib->getLvsForPrestudent($prestudent_id, $sem_akt);
|
||||
if (isError($result)) {
|
||||
return $this->outputJsonError(getError($result));
|
||||
}
|
||||
|
||||
$lvs = getData($result) ?: [];
|
||||
$rdf_url = 'http://www.technikum-wien.at/antragnote';
|
||||
|
||||
$this->load->view('lehre/Antrag/Wiederholung/getLvs.rdf.php', [
|
||||
'url' => $rdf_url,
|
||||
'lvs' => $lvs
|
||||
]);
|
||||
}
|
||||
|
||||
public function moveLvsToZeugnis()
|
||||
{
|
||||
$anzahl = $this->input->post('anzahl');
|
||||
$student_uid = $this->input->post('student_uid');
|
||||
$this->load->model('education/Studierendenantraglehrveranstaltung_model', 'StudierendenantraglehrveranstaltungModel');
|
||||
$this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel');
|
||||
|
||||
$errormsg = array();
|
||||
|
||||
for($i=0; $i<$anzahl; $i++)
|
||||
{
|
||||
$id = $this->input->post('studierendenantrag_lehrveranstaltung_id_' . $i);
|
||||
$result =$this->StudierendenantraglehrveranstaltungModel->load($id);
|
||||
if(isError($result))
|
||||
{
|
||||
$errormsg[] = getError($result);
|
||||
}
|
||||
elseif(!hasData($result))
|
||||
{
|
||||
$errormsg[] = $this->p->t('studierendenantrag', 'error_no_lv_in_application');
|
||||
}
|
||||
else
|
||||
{
|
||||
$antragLv = getData($result)[0];
|
||||
$result= $this->ZeugnisnoteModel->load([
|
||||
'lehrveranstaltung_id'=> $antragLv->lehrveranstaltung_id,
|
||||
'student_uid'=> $student_uid,
|
||||
'studiensemester_kurzbz' => $antragLv->studiensemester_kurzbz
|
||||
]);
|
||||
if(isError($result))
|
||||
{
|
||||
$errormsg[] = getError($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hasData($result))
|
||||
{
|
||||
$result = $this->ZeugnisnoteModel->update(
|
||||
[
|
||||
'lehrveranstaltung_id'=> $antragLv->lehrveranstaltung_id,
|
||||
'student_uid'=> $student_uid,
|
||||
'studiensemester_kurzbz' => $antragLv->studiensemester_kurzbz
|
||||
],
|
||||
[
|
||||
'note'=> $antragLv->note,
|
||||
'uebernahmedatum' => date('c'),
|
||||
'benotungsdatum' => $antragLv->insertamum,
|
||||
'updateamum' => date('c'),
|
||||
'bemerkung'=>$antragLv->anmerkung,
|
||||
'updatevon'=>getAuthUID()
|
||||
]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->ZeugnisnoteModel->insert([
|
||||
'lehrveranstaltung_id'=> $antragLv->lehrveranstaltung_id,
|
||||
'student_uid'=> $student_uid,
|
||||
'studiensemester_kurzbz' => $antragLv->studiensemester_kurzbz,
|
||||
'note'=> $antragLv->note,
|
||||
'uebernahmedatum' => date('c'),
|
||||
'benotungsdatum' => $antragLv->insertamum,
|
||||
'insertamum' => date('c'),
|
||||
'bemerkung'=>$antragLv->anmerkung,
|
||||
'insertvon'=>getAuthUID()
|
||||
]);
|
||||
}
|
||||
if(isError($result))
|
||||
{
|
||||
$errormsg[] = getError($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($errormsg)
|
||||
$return = false;
|
||||
else
|
||||
$return = true;
|
||||
|
||||
$this->load->view('lehre/Antrag/Wiederholung/moveLvs.rdf.php', [
|
||||
'return' => $return,
|
||||
'errormsg' => $errormsg
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
* NOTE: extends the FHC_Controller instead of the Auth_Controller because the FilterCmpt has its
|
||||
* own permissions check
|
||||
* TODO(chris): deprecated
|
||||
*/
|
||||
class Filter extends FHC_Controller
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
*
|
||||
* TODO(chris): deprecated
|
||||
*/
|
||||
class Phrasen extends FHC_Controller
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
*
|
||||
* TODO(chris): deprecated
|
||||
*/
|
||||
class SearchBar extends FHC_Controller
|
||||
{
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Noten extends Auth_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'get' => 'student/noten:r',
|
||||
'getZeugnis' => 'student/noten:r',
|
||||
'update' => ['admin:w', 'assistenz:w']
|
||||
]);
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
$this->load->model('codex/Note_model', 'NoteModel');
|
||||
|
||||
$result = $this->NoteModel->addOrder('note');
|
||||
|
||||
$result = $this->NoteModel->load();
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
return $this->outputJson($result);
|
||||
}
|
||||
|
||||
public function getZeugnis($prestudent_id, $all = null)
|
||||
{
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel');
|
||||
|
||||
$result = $this->StudentModel->loadWhere([
|
||||
'prestudent_id' => $prestudent_id
|
||||
]);
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson($result);
|
||||
}
|
||||
if (!hasData($result))
|
||||
return $this->outputJsonSuccess(null);
|
||||
|
||||
$student_uid = current(getData($result))->student_uid;
|
||||
|
||||
$studiensemester_kurzbz = ($all === null) ? $this->variablelib->getVar('semester_aktuell') : null;
|
||||
|
||||
$result = $this->ZeugnisnoteModel->getZeugnisnoten($student_uid, $studiensemester_kurzbz);
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
return $this->outputJson($result);
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->load->model('organisation/Studienplan_model', 'StudienplanModel');
|
||||
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
$this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel');
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
|
||||
if (empty($_POST) || !is_array(current($_POST))) {
|
||||
$result = $this->hasPermissionUpdate($this->input->post('lehrveranstaltung_id'), $this->input->post('student_uid'));
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_FORBIDDEN);
|
||||
return $this->outputJson($result);
|
||||
}
|
||||
|
||||
$this->form_validation->set_rules('lehrveranstaltung_id', 'Lehrverantaltung ID', 'required|numeric');
|
||||
$this->form_validation->set_rules('student_uid', 'Student UID', 'required');
|
||||
$this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester Kurzbezeichnung', 'required');
|
||||
$this->form_validation->set_rules('note', 'Note', 'required|numeric');
|
||||
$post = [$_POST];
|
||||
} else {
|
||||
foreach ($_POST as $i => $data) {
|
||||
$lvid = isset($data['lehrveranstaltung_id']) ? $data['lehrveranstaltung_id'] : null;
|
||||
$uid = isset($data['student_uid']) ? $data['student_uid'] : null;
|
||||
$result = $this->hasPermissionUpdate($lvid, $uid);
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_FORBIDDEN);
|
||||
return $this->outputJson($result);
|
||||
}
|
||||
|
||||
$this->form_validation->set_rules($i . '[lehrveranstaltung_id]', '#' . $i . ' Lehrverantaltung ID', 'required|numeric');
|
||||
$this->form_validation->set_rules($i . '[student_uid]', '#' . $i . ' Student UID', 'required');
|
||||
$this->form_validation->set_rules($i . '[studiensemester_kurzbz]', '#' . $i . ' Studiensemester Kurzbezeichnung', 'required');
|
||||
$this->form_validation->set_rules($i . '[note]', '#' . $i . ' Note', 'required|numeric');
|
||||
}
|
||||
$post = $_POST;
|
||||
}
|
||||
if ($this->form_validation->run() == false) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST);
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$final_result = success();
|
||||
$this->ZeugnisnoteModel->db->trans_start();
|
||||
|
||||
foreach ($post as $i => $data) {
|
||||
$note = $data['note'];
|
||||
unset($data['note']);
|
||||
$result = $this->ZeugnisnoteModel->update($data, [
|
||||
'note' => $note,
|
||||
'benotungsdatum' => date('c'),
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID()
|
||||
]);
|
||||
if (isError($result)) {
|
||||
$final_result = $result;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->ZeugnisnoteModel->db->trans_complete();
|
||||
|
||||
if (isError($final_result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
$this->outputJson($final_result);
|
||||
}
|
||||
|
||||
protected function hasPermissionUpdate($lehrveranstaltung_id, $student_uid)
|
||||
{
|
||||
// TODO(chris): error phrases!
|
||||
if ($lehrveranstaltung_id === null || $student_uid === null)
|
||||
return success();
|
||||
$result = $this->StudentModel->load([$student_uid]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error('Fehler beim Ermitteln des Studenten');
|
||||
$student = current(getData($result));
|
||||
|
||||
if ($this->permissionlib->isBerechtigt('admin', 'suid', $student->studiengang_kz))
|
||||
return success();
|
||||
if ($this->permissionlib->isBerechtigt('assistenz', 'suid', $student->studiengang_kz))
|
||||
return success();
|
||||
|
||||
$result = $this->StudienplanModel->getAllOesForLv($lehrveranstaltung_id);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$oes = getData($result) ?: [];
|
||||
$result = $this->LehrveranstaltungModel->getStg($lehrveranstaltung_id);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (hasData($result))
|
||||
$oes[] = current(getData($result));
|
||||
|
||||
foreach ($oes as $oe) {
|
||||
if ($this->permissionlib->isBerechtigt('admin', 'suid', $oe->oe_kurzbz))
|
||||
return success();
|
||||
if ($this->permissionlib->isBerechtigt('assistenz', 'suid', $oe->oe_kurzbz))
|
||||
return success();
|
||||
}
|
||||
|
||||
return error('Forbidden');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Studienplan extends Auth_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// TODO(chris): access!
|
||||
parent::__construct([
|
||||
'get' => self::PERM_LOGGED
|
||||
]);
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
$this->load->model('organisation/Studienplan_model', 'StudienplanModel');
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('studiengang_kz', 'StudiengangKz', 'required|numeric');
|
||||
$this->form_validation->set_rules('studiensemester_kurzbz', 'StudiensemesterKurbz', 'required');
|
||||
$this->form_validation->set_rules('ausbildungssemester', 'Ausbildungssemester', 'numeric');
|
||||
|
||||
if ($this->form_validation->run() == false) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST);
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$studiengang_kz = $this->input->post('studiengang_kz');
|
||||
$studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz');
|
||||
$ausbildungssemester = $this->input->post('ausbildungssemester') ?: null;
|
||||
$orgform_kurzbz = $this->input->post('orgform_kurzbz') ?: null;
|
||||
|
||||
$result = $this->StudienplanModel->getStudienplaeneBySemester($studiengang_kz, $studiensemester_kurzbz, $ausbildungssemester, $orgform_kurzbz);
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
$this->outputJson($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Studiensemester extends Auth_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// TODO(chris): access!
|
||||
parent::__construct([
|
||||
'index' => self::PERM_LOGGED,
|
||||
'now' => self::PERM_LOGGED,
|
||||
'set' => self::PERM_LOGGED
|
||||
]);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
$this->StudiensemesterModel->addOrder('start');
|
||||
|
||||
$result = $this->StudiensemesterModel->load();
|
||||
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
$this->outputJson($result);
|
||||
}
|
||||
|
||||
public function now()
|
||||
{
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
$result = $this->StudiensemesterModel->getNearest();
|
||||
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
$this->outputJson(getError($result));
|
||||
}
|
||||
$result = getData($result) ?: [];
|
||||
|
||||
if (count($result) != 1) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
$this->outputJsonError(count($result) ? 'Mehrere Studiensemester aktiv' : 'Kein Studiensemester aktiv');
|
||||
} else {
|
||||
$this->outputJsonSuccess(current($result)->studiensemester_kurzbz);
|
||||
}
|
||||
}
|
||||
|
||||
public function set()
|
||||
{
|
||||
$this->load->library('AuthLib');
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
|
||||
$this->form_validation->set_rules('studiensemester', 'Studiensemester', 'required');
|
||||
|
||||
if ($this->form_validation->run() == false) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST);
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$stdsem = $this->input->post('studiensemester');
|
||||
|
||||
$this->load->model('system/Variable_model', 'VariableModel');
|
||||
|
||||
$result = $this->VariableModel->setVariable(getAuthUID(), 'semester_aktuell', $stdsem);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson($result);
|
||||
}
|
||||
|
||||
$this->outputJsonSuccess(true);
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,10 @@ class AntragJob extends JOB_Controller
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
$this->loadPhrases([
|
||||
'lehre'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -412,10 +416,12 @@ class AntragJob extends JOB_Controller
|
||||
$this->StudierendenantragModel->addSelect('studiensemester_kurzbz');
|
||||
$this->StudierendenantragModel->addSelect('s.insertamum');
|
||||
$this->StudierendenantragModel->addSelect('s.insertvon');
|
||||
$this->StudierendenantragModel->addJoin('public.tbl_student pts', 'prestudent_id');
|
||||
$this->StudierendenantragModel->addSelect('pts.student_uid');
|
||||
|
||||
$this->StudierendenantragModel->db->where_in(
|
||||
'public.get_rolle_prestudent(prestudent_id, studiensemester_kurzbz)',
|
||||
$this->config->item('antrag_prestudentstatus_whitelist')
|
||||
$this->config->item('antrag_prestudentstatus_whitelist_abmeldung')
|
||||
);
|
||||
|
||||
$result = $this->StudierendenantragModel->getWithLastStatusWhere([
|
||||
@@ -449,11 +455,23 @@ class AntragJob extends JOB_Controller
|
||||
if (isError($result))
|
||||
$this->logError(getError($result));
|
||||
|
||||
$this->load->model('crm/Statusgrund_model', 'StatusgrundModel');
|
||||
$result = $this->StatusgrundModel->loadWhere(['statusgrund_kurzbz' => 'abbrecherStgl']);
|
||||
if (isError($result)) {
|
||||
$this->logError(getError($result));
|
||||
continue;
|
||||
} elseif (!hasData($result)) {
|
||||
$this->logError($this->p->t('lehre', 'error_noStatusgrund', ['statusgrund_kurzbz' => 'abbrecherStgl']));
|
||||
continue;
|
||||
}
|
||||
|
||||
$statusgrund = current(getData($result));
|
||||
|
||||
$result = $this->prestudentlib->setAbbrecher(
|
||||
$antrag->prestudent_id,
|
||||
$antrag->studiensemester_kurzbz,
|
||||
'AntragJob',
|
||||
'abbrecherStgl',
|
||||
$statusgrund->statusgrund_id,
|
||||
$antrag->insertamum,
|
||||
null,
|
||||
$antrag->insertvon ?: $insertvon
|
||||
@@ -484,7 +502,7 @@ class AntragJob extends JOB_Controller
|
||||
$person = current(getData($result));
|
||||
$email = $studiengang->email;
|
||||
$dataMail = array(
|
||||
'prestudent' => $antrag->prestudent_id,
|
||||
'prestudent' => 'UID: ' . $antrag->student_uid . ', PreStudentId: ' . $antrag->prestudent_id,
|
||||
'studiensemester' => $antrag->studiensemester_kurzbz,
|
||||
'name' => trim($person->vorname . ' '. $person->nachname),
|
||||
);
|
||||
|
||||
@@ -9,8 +9,8 @@ class IssueResolver extends IssueResolver_Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// set fehler codes which can be resolved by the job
|
||||
// structure: fehlercode => class (library) name for resolving
|
||||
// set fehler codes which can be resolved by the job, with own resolver defined
|
||||
// structure: fehlercode => class (library) name for resolving in "resolvers" folder
|
||||
$this->_codeLibMappings = array(
|
||||
'CORE_ZGV_0001' => 'CORE_ZGV_0001',
|
||||
'CORE_ZGV_0002' => 'CORE_ZGV_0002',
|
||||
@@ -30,7 +30,6 @@ class IssueResolver extends IssueResolver_Controller
|
||||
'CORE_STG_0002' => 'CORE_STG_0002',
|
||||
'CORE_STG_0003' => 'CORE_STG_0003',
|
||||
'CORE_STG_0004' => 'CORE_STG_0004',
|
||||
'CORE_STUDENTSTATUS_0001' => 'CORE_STUDENTSTATUS_0001',
|
||||
'CORE_STUDENTSTATUS_0002' => 'CORE_STUDENTSTATUS_0002',
|
||||
'CORE_STUDENTSTATUS_0003' => 'CORE_STUDENTSTATUS_0003',
|
||||
'CORE_STUDENTSTATUS_0004' => 'CORE_STUDENTSTATUS_0004',
|
||||
@@ -45,10 +44,17 @@ class IssueResolver extends IssueResolver_Controller
|
||||
'CORE_STUDENTSTATUS_0013' => 'CORE_STUDENTSTATUS_0013',
|
||||
'CORE_STUDENTSTATUS_0014' => 'CORE_STUDENTSTATUS_0014',
|
||||
'CORE_STUDENTSTATUS_0015' => 'CORE_STUDENTSTATUS_0015',
|
||||
'CORE_STUDENTSTATUS_0016' => 'CORE_STUDENTSTATUS_0016',
|
||||
'CORE_PERSON_0001' => 'CORE_PERSON_0001',
|
||||
'CORE_PERSON_0002' => 'CORE_PERSON_0002',
|
||||
'CORE_PERSON_0003' => 'CORE_PERSON_0003',
|
||||
'CORE_PERSON_0004' => 'CORE_PERSON_0004'
|
||||
);
|
||||
|
||||
// fehler which are resolved by the job the same way as they are produced
|
||||
// structure: fehlercode => class (library) name for resolving in "plausichecks" folder
|
||||
$this->_codeProducerLibMappings = array(
|
||||
'CORE_STUDENTSTATUS_0001' => 'AbbrecherAktiv',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class OneTimeMessages extends JOB_Controller
|
||||
FROM public.tbl_prestudent p
|
||||
JOIN public.tbl_prestudentstatus ps USING (prestudent_id)
|
||||
JOIN public.tbl_studiengang s USING (studiengang_kz)
|
||||
WHERE ps.status_kurzbz = \'Wartender\'
|
||||
WHERE get_rolle_prestudent(ps.prestudent_id, NULL) = \'Wartender\'
|
||||
AND ps.studiensemester_kurzbz = ?
|
||||
AND ps.datum <= NOW() - \''.$days.' days\'::interval
|
||||
AND s.typ = ?
|
||||
|
||||
@@ -1023,7 +1023,7 @@ class ReihungstestJob extends JOB_Controller
|
||||
{
|
||||
$studiengang = $this->StudiengangModel->load($stg);
|
||||
$mailcontent = '';
|
||||
|
||||
$content = false;
|
||||
foreach ($orgform AS $art=>$value)
|
||||
{
|
||||
// Orgform nur dazu schreiben, wenn es mehr als Eine gibt
|
||||
@@ -1044,6 +1044,7 @@ class ReihungstestJob extends JOB_Controller
|
||||
$mailcontent .= '<tr><td style="font-family: verdana, sans-serif; border: 1px solid grey; padding: 3px">'.$bewerber.'</td></tr>';
|
||||
}
|
||||
$mailcontent .= '</tbody></table><br><br>';
|
||||
$content = true;
|
||||
}
|
||||
if (isset($value['AufnahmeHoeherePrio']) && !isEmptyArray($value['AufnahmeHoeherePrio']))
|
||||
{
|
||||
@@ -1058,6 +1059,7 @@ class ReihungstestJob extends JOB_Controller
|
||||
$mailcontent .= '<tr><td style="font-family: verdana, sans-serif; border: 1px solid grey; padding: 3px">'.$bewerber.'</td></tr>';
|
||||
}
|
||||
$mailcontent .= '</tbody></table>';
|
||||
$content = true;
|
||||
}
|
||||
if (isset($value['AbgewiesenHoeherePrio']) && !isEmptyArray($value['AbgewiesenHoeherePrio']))
|
||||
{
|
||||
@@ -1071,6 +1073,7 @@ class ReihungstestJob extends JOB_Controller
|
||||
$mailcontent .= '<tr><td style="font-family: verdana, sans-serif; border: 1px solid grey; padding: 3px">'.$bewerber.'</td></tr>';
|
||||
}
|
||||
$mailcontent .= '</tbody></table>';
|
||||
$content = true;
|
||||
}
|
||||
if ($bcc != '' && isset($value['AbgewiesenWeilBewerber']) && !isEmptyArray($value['AbgewiesenWeilBewerber']))
|
||||
{
|
||||
@@ -1085,13 +1088,14 @@ class ReihungstestJob extends JOB_Controller
|
||||
$mailcontent .= '<tr><td style="font-family: verdana, sans-serif; border: 1px solid grey; padding: 3px">'.$bewerber.'</td></tr>';
|
||||
}
|
||||
$mailcontent .= '</tbody></table>';
|
||||
$content = true;
|
||||
}
|
||||
}
|
||||
|
||||
$mailcontent_data_arr['table'] = $mailcontent;
|
||||
|
||||
// Send email in Sancho design
|
||||
if (!isEmptyString($mailcontent))
|
||||
if (!isEmptyString($mailcontent) && $content === true)
|
||||
{
|
||||
sendSanchoMail(
|
||||
'Sancho_ReihungstestteilnehmerJob',
|
||||
|
||||
@@ -21,6 +21,7 @@ class Studierendenantrag extends FHC_Controller
|
||||
|
||||
// Load Models
|
||||
$this->load->model('education/Studierendenantrag_model', 'StudierendenantragModel');
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
@@ -102,6 +103,7 @@ class Studierendenantrag extends FHC_Controller
|
||||
|
||||
public function abmeldungstgl($prestudent_id, $studierendenantrag_id = null)
|
||||
{
|
||||
|
||||
$this->load->view('lehre/Antrag/Create', [
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'studierendenantrag_id' => $studierendenantrag_id,
|
||||
@@ -185,4 +187,4 @@ class Studierendenantrag extends FHC_Controller
|
||||
|
||||
return $strRequiredPermissions;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,8 +111,13 @@ class requestAnrechnung extends Auth_Controller
|
||||
$lehrveranstaltung_id = $this->input->post('lv_id');
|
||||
$studiensemester_kurzbz = $this->input->post('studiensemester');
|
||||
$bestaetigung = $this->input->post('bestaetigung');
|
||||
$begruendung_ects = $this->input->post('begruendung_ects');
|
||||
$begruendung_lvinhalt = $this->input->post('begruendung_lvinhalt');
|
||||
$begruendung_ects = $this->config->item('explain_equivalence') === TRUE
|
||||
? $this->input->post('begruendung_ects')
|
||||
: NULL;
|
||||
$begruendung_lvinhalt = $this->config->item('explain_equivalence') === TRUE
|
||||
? $this->input->post('begruendung_lvinhalt')
|
||||
: NULL;
|
||||
|
||||
|
||||
// Validate data
|
||||
if (empty($_FILES['uploadfile']['name']))
|
||||
@@ -124,8 +129,8 @@ class requestAnrechnung extends Auth_Controller
|
||||
isEmptyString($anmerkung) ||
|
||||
isEmptyString($lehrveranstaltung_id) ||
|
||||
isEmptyString($studiensemester_kurzbz) ||
|
||||
isEmptyString($begruendung_ects) ||
|
||||
isEmptyString($begruendung_lvinhalt))
|
||||
($this->config->item('explain_equivalence') === TRUE && isEmptyString($begruendung_ects)) ||
|
||||
($this->config->item('explain_equivalence') === TRUE && isEmptyString($begruendung_lvinhalt)))
|
||||
{
|
||||
return $this->outputJsonError($this->p->t('ui', 'errorFelderFehlen'));
|
||||
}
|
||||
@@ -168,7 +173,7 @@ class requestAnrechnung extends Auth_Controller
|
||||
|
||||
// Hold just inserted DMS ID
|
||||
$lastInsert_dms_id = $result->retval['dms_id'];
|
||||
|
||||
|
||||
// Save Anrechnung and Anrechnungstatus
|
||||
$result = $this->AnrechnungModel->createAnrechnungsantrag(
|
||||
$prestudent_id,
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class LvTemplateUebersicht extends Auth_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// Set required permissions
|
||||
parent::__construct(
|
||||
array(
|
||||
'index' => 'lehre/lehrveranstaltung:rw',
|
||||
)
|
||||
);
|
||||
|
||||
// Load libraries
|
||||
$this->load->library('AuthLib');
|
||||
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'global',
|
||||
'lehre'
|
||||
)
|
||||
);
|
||||
|
||||
$this->_setAuthUID();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('lehre/lvplanung/lvTemplateUebersicht.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the UID of the logged user and checks if it is valid
|
||||
*/
|
||||
private function _setAuthUID()
|
||||
{
|
||||
$this->_uid = getAuthUID();
|
||||
|
||||
if (!$this->_uid) show_error('User authentification failed');
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,9 @@ class MigrateContract extends CLI_Controller
|
||||
{
|
||||
|
||||
private $matching_ba1_vertragsart;
|
||||
private $OE_DEFAULT = 'gst';
|
||||
private $OE_DEFAULT;
|
||||
|
||||
protected $configerrors;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -28,29 +30,70 @@ class MigrateContract extends CLI_Controller
|
||||
$this->load->model('codex/bisverwendung_model', 'BisVerwendungModel');
|
||||
$this->load->model('person/benutzerfunktion_model', 'BenutzerfunktionModel');
|
||||
|
||||
$this->matching_ba1_vertragsart = array(
|
||||
'101'=>'externerlehrender',
|
||||
'102'=>'DV anderen Gebietskörperschaft',
|
||||
'103'=>'echterdv',
|
||||
'104'=>'studentischehilfskr',
|
||||
'105'=>'externerlehrender',
|
||||
'106'=>'Andere Bildungseinrichtung',
|
||||
'107'=>'werkvertrag',
|
||||
'108'=>'studentischehilfskr',
|
||||
'109'=>'ueberlassungsvertrag',
|
||||
'110'=>'echterfreier',
|
||||
'111'=>'echterdv', //All-In
|
||||
);
|
||||
$this->load->config('migratecontract');
|
||||
|
||||
$this->OE_DEFAULT = $this->config->item('migratecontract_oe_default');
|
||||
$this->matching_ba1_vertragsart = $this->config->item('migratecontract_matching_ba1_vertragsart');
|
||||
$this->configerrors = array();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
public function checkConfig()
|
||||
{
|
||||
echo "OE_DEFAULT: " . $this->OE_DEFAULT . "\n";
|
||||
echo "matching_ba1_vertragsart: " . print_r($this->matching_ba1_vertragsart, true);
|
||||
|
||||
$this->checkOE_DEFAULT();
|
||||
$this->checkMatching_ba1_vertragsart();
|
||||
|
||||
if( count($this->configerrors) > 0 )
|
||||
{
|
||||
foreach($this->configerrors AS $configerror)
|
||||
{
|
||||
echo $configerror . "\n";
|
||||
}
|
||||
die("Fehler in der Konfiguration. Abbruch!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Konfiguration OK.\n";
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkOE_DEFAULT()
|
||||
{
|
||||
$db = new DB_Model();
|
||||
$oesql = 'SELECT * FROM public.tbl_organisationseinheit WHERE oe_kurzbz = ?';
|
||||
$oeres = $db->execReadOnlyQuery($oesql, array($this->OE_DEFAULT));
|
||||
if( !hasData($oeres) )
|
||||
{
|
||||
$this->configerrors[] = 'Default Organisationseinheit: "'
|
||||
. $this->OE_DEFAULT . '" nicht gefunden.';
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkMatching_ba1_vertragsart() {
|
||||
$db = new DB_Model();
|
||||
foreach( $this->matching_ba1_vertragsart AS $vertragsart_kurzbz )
|
||||
{
|
||||
$vasql = 'SELECT * FROM hr.tbl_vertragsart WHERE vertragsart_kurzbz = ?';
|
||||
$vares = $db->execReadOnlyQuery($vasql, array($vertragsart_kurzbz));
|
||||
if( !hasData($vares) )
|
||||
{
|
||||
$this->configerrors[] = 'Vertragsart "' . $vertragsart_kurzbz
|
||||
. '" nicht gefunden.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Everything has a beginning
|
||||
*/
|
||||
public function index($user = null)
|
||||
{
|
||||
$this->checkConfig();
|
||||
|
||||
if (!is_null($user))
|
||||
{
|
||||
$contracts = $this->_transformUser($user);
|
||||
@@ -400,6 +443,11 @@ class MigrateContract extends CLI_Controller
|
||||
*/
|
||||
private function _addVertragsbestandteilZeitaufzeichnung(&$contracts, $dv, $row_verwendung)
|
||||
{
|
||||
if( is_null($row_verwendung->zeitaufzeichnungspflichtig) || is_null($row_verwendung->azgrelevant) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($contracts['dv'][$dv]['vbs']))
|
||||
{
|
||||
foreach ($contracts['dv'][$dv]['vbs'] as $index_vbs=>$row_vbs)
|
||||
|
||||
@@ -4,14 +4,15 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class MigrateHourlyRate extends CLI_Controller
|
||||
{
|
||||
|
||||
CONST DEFAULT_OE = 'gst';
|
||||
CONST DEFAULT_DATE = '1970-01-01';
|
||||
CONST STUNDENSTAZTYP_LEHRE = 'lehre';
|
||||
CONST STUNDENSTAZTYP_KALKULATORISCH = 'kalkulatorisch';
|
||||
|
||||
private $OE_DEFAULT;
|
||||
private $_ci;
|
||||
|
||||
protected $configerrors;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -21,10 +22,38 @@ class MigrateHourlyRate extends CLI_Controller
|
||||
$this->load->model('codex/Bisverwendung_model', 'BisVerwendungModel');
|
||||
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
|
||||
$this->load->model('ressource/Stundensatz_model', 'StundensatzModel');
|
||||
|
||||
$this->load->config('migratecontract');
|
||||
|
||||
$this->OE_DEFAULT = $this->config->item('migratecontract_oe_default');
|
||||
$this->configerrors = array();
|
||||
}
|
||||
|
||||
public function checkConfig()
|
||||
{
|
||||
echo "OE_DEFAULT: " . $this->OE_DEFAULT . "\n";
|
||||
|
||||
$this->checkOE_DEFAULT();
|
||||
|
||||
if( count($this->configerrors) > 0 )
|
||||
{
|
||||
foreach($this->configerrors AS $configerror)
|
||||
{
|
||||
echo $configerror . "\n";
|
||||
}
|
||||
die("Fehler in der Konfiguration. Abbruch!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Konfiguration OK.\n";
|
||||
}
|
||||
}
|
||||
|
||||
public function index($user = null)
|
||||
{
|
||||
$this->checkConfig();
|
||||
|
||||
echo "Lehre Stundensaetze werden migriert.\n";
|
||||
$mitarbeiterResult = $this->_getMitarbeiterStunden($user);
|
||||
if (isError($mitarbeiterResult)) return $mitarbeiterResult;
|
||||
if (!hasData($mitarbeiterResult)) return error('Keine Mitarbeiterstunden gefunden');
|
||||
@@ -38,20 +67,71 @@ class MigrateHourlyRate extends CLI_Controller
|
||||
if (isError($insertResult)) return $insertResult;
|
||||
}
|
||||
|
||||
$sapResult = $this->_getSapStunden($user);
|
||||
if (isError($sapResult)) return $sapResult;
|
||||
if (!hasData($sapResult)) return error('Keinen kalkulatorischen Stundensaetze gefunden');
|
||||
|
||||
$mitarbeiterArray = getData($sapResult);
|
||||
|
||||
foreach ($mitarbeiterArray as $mitarbeiter)
|
||||
if( $this->checkIfSAPSyncTableExists() )
|
||||
{
|
||||
$this->_getUnternehmen($mitarbeiter);
|
||||
$insertResult = $this->_addStundensatz($mitarbeiter, self::STUNDENSTAZTYP_KALKULATORISCH, date_format(date_create($mitarbeiter->beginn), 'Y-m-d'));
|
||||
if (isError($insertResult)) return $insertResult;
|
||||
echo "SAP Sync Tabelle gefunden. SAP Stundensaetze werden migriert.\n";
|
||||
$sapResult = $this->_getSapStunden($user);
|
||||
if (isError($sapResult)) return $sapResult;
|
||||
if (!hasData($sapResult)) return error('Keinen kalkulatorischen Stundensaetze gefunden');
|
||||
|
||||
$mitarbeiterArray = getData($sapResult);
|
||||
|
||||
foreach ($mitarbeiterArray as $mitarbeiter)
|
||||
{
|
||||
$this->_getUnternehmen($mitarbeiter);
|
||||
$insertResult = $this->_addStundensatz($mitarbeiter, self::STUNDENSTAZTYP_KALKULATORISCH, date_format(date_create($mitarbeiter->beginn), 'Y-m-d'));
|
||||
if (isError($insertResult)) return $insertResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "SAP Sync Tabelle nicht gefunden. Ignoriere SAP Stundensaetze.\n";
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkOE_DEFAULT()
|
||||
{
|
||||
$db = new DB_Model();
|
||||
$oesql = 'SELECT * FROM public.tbl_organisationseinheit WHERE oe_kurzbz = ?';
|
||||
$oeres = $db->execReadOnlyQuery($oesql, array($this->OE_DEFAULT));
|
||||
if( !hasData($oeres) )
|
||||
{
|
||||
$this->configerrors[] = 'Default Organisationseinheit: "'
|
||||
. $this->OE_DEFAULT . '" nicht gefunden.';
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkIfSAPSyncTableExists()
|
||||
{
|
||||
$dbModel = new DB_Model();
|
||||
$params = array(
|
||||
DB_NAME,
|
||||
'sync',
|
||||
'tbl_sap_stundensatz'
|
||||
);
|
||||
|
||||
$sql = "SELECT
|
||||
1 AS exists
|
||||
FROM
|
||||
information_schema.tables
|
||||
WHERE
|
||||
table_catalog = ? AND
|
||||
table_schema = ? AND
|
||||
table_name = ?";
|
||||
|
||||
$res = $dbModel->execReadOnlyQuery($sql, $params);
|
||||
|
||||
if( hasData($res) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function _getSapStunden($user = null)
|
||||
{
|
||||
$dbModel = new DB_Model();
|
||||
@@ -127,7 +207,7 @@ class MigrateHourlyRate extends CLI_Controller
|
||||
$unternehmenResult = $this->_findUnternehmen($mitarbeiter->uid, "'kstzuordnung', 'oezuordnung'");
|
||||
}
|
||||
|
||||
$unternehmen = self::DEFAULT_OE;
|
||||
$unternehmen = $this->OE_DEFAULT;
|
||||
|
||||
if (hasData($unternehmenResult))
|
||||
$unternehmen = getData($unternehmenResult)[0]->oe_kurzbz;
|
||||
|
||||
@@ -22,6 +22,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
* This controller operates between (interface) the JS (GUI) and the NavigationLib (back-end)
|
||||
* Provides data to the ajax get calls about the filter
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
* TODO(chris): deprecated
|
||||
*/
|
||||
class Navigation extends FHC_Controller
|
||||
{
|
||||
|
||||
@@ -337,10 +337,13 @@ class InfoCenter extends Auth_Controller
|
||||
$persondata = $this->_loadPersonData($person_id);
|
||||
|
||||
$checkPerson = $this->PersonModel->checkDuplicate($person_id);
|
||||
|
||||
if (isError($checkPerson)) show_error(getError($checkPerson));
|
||||
|
||||
$duplicate = array('duplicated' => getData($checkPerson));
|
||||
$checkUnruly = $this->PersonModel->checkUnruly($persondata['stammdaten']->vorname, $persondata['stammdaten']->nachname, $persondata['stammdaten']->gebdatum);
|
||||
if (isError($checkUnruly)) show_error(getError($checkUnruly));
|
||||
|
||||
$duplicate = array('duplicate' => getData($checkPerson));
|
||||
$unruly = array('unruly' => getData($checkUnruly));
|
||||
|
||||
$prestudentdata = $this->_loadPrestudentData($person_id);
|
||||
|
||||
@@ -351,7 +354,8 @@ class InfoCenter extends Auth_Controller
|
||||
$persondata,
|
||||
$prestudentdata,
|
||||
$dokumentdata,
|
||||
$duplicate
|
||||
$duplicate,
|
||||
$unruly
|
||||
);
|
||||
|
||||
$data[self::FHC_CONTROLLER_ID] = $this->getControllerId();
|
||||
@@ -1285,67 +1289,28 @@ class InfoCenter extends Auth_Controller
|
||||
$this->terminateWithJsonError($this->p->t('ui', 'fehlerBeimSpeichern'));
|
||||
|
||||
$kontakte = $this->input->post('kontakt');
|
||||
foreach ($kontakte as $kontakt)
|
||||
{
|
||||
$kontaktExists = $this->KontaktModel->loadWhere(array(
|
||||
'kontakt_id' => $kontakt['id'],
|
||||
'person_id' => $person_id,
|
||||
));
|
||||
if($kontakte) {
|
||||
|
||||
if (hasData($kontaktExists))
|
||||
{
|
||||
$kontaktExists = getData($kontaktExists)[0];
|
||||
foreach ($kontakte as $kontakt) {
|
||||
$kontaktExists = $this->KontaktModel->loadWhere(array(
|
||||
'kontakt_id' => $kontakt['id'],
|
||||
'person_id' => $person_id,
|
||||
));
|
||||
|
||||
if ($kontaktExists->kontakt === $kontakt['value'])
|
||||
continue;
|
||||
if (hasData($kontaktExists)) {
|
||||
$kontaktExists = getData($kontaktExists)[0];
|
||||
|
||||
$update = $this->KontaktModel->update(
|
||||
array
|
||||
(
|
||||
'kontakt_id' => $kontakt['id']
|
||||
),
|
||||
array
|
||||
(
|
||||
'kontakt' => isEmptyString($kontakt['value']) ? null : $kontakt['value'],
|
||||
'updateamum' => date('Y-m-d H:i:s'),
|
||||
'updatevon' => $this->_uid
|
||||
)
|
||||
);
|
||||
if ($kontaktExists->kontakt === $kontakt['value'])
|
||||
continue;
|
||||
|
||||
if (isError($update))
|
||||
$this->terminateWithJsonError($this->p->t('ui', 'fehlerBeimSpeichern'));
|
||||
}
|
||||
}
|
||||
|
||||
$adressen = $this->input->post('adresse');
|
||||
|
||||
foreach ($adressen as $adresse)
|
||||
{
|
||||
$adresseExists = $this->AdresseModel->loadWhere(array(
|
||||
'adresse_id' => $adresse['id'],
|
||||
'person_id' => $person_id,
|
||||
));
|
||||
|
||||
if (hasData($adresseExists))
|
||||
{
|
||||
$adresse = $adresse['value'];
|
||||
$adresseExists = getData($adresseExists)[0];
|
||||
if ($adresseExists->strasse !== $adresse['strasse'] ||
|
||||
$adresseExists->plz !== $adresse['plz'] ||
|
||||
$adresseExists->ort !== $adresse['ort'] ||
|
||||
$adresseExists->nation !== $adresse['nation'])
|
||||
{
|
||||
$update = $this->AdresseModel->update(
|
||||
$update = $this->KontaktModel->update(
|
||||
array
|
||||
(
|
||||
'adresse_id' => $adresseExists->adresse_id
|
||||
'kontakt_id' => $kontakt['id']
|
||||
),
|
||||
array
|
||||
(
|
||||
'strasse' => isEmptyString($adresse['strasse']) ? null : $adresse['strasse'],
|
||||
'plz' => isEmptyString($adresse['plz']) ? null : $adresse['plz'],
|
||||
'ort' => isEmptyString($adresse['ort']) ? null : $adresse['ort'],
|
||||
'nation' => isEmptyString($adresse['nation']) ? null : $adresse['nation'],
|
||||
'kontakt' => isEmptyString($kontakt['value']) ? null : $kontakt['value'],
|
||||
'updateamum' => date('Y-m-d H:i:s'),
|
||||
'updatevon' => $this->_uid
|
||||
)
|
||||
@@ -1354,7 +1319,48 @@ class InfoCenter extends Auth_Controller
|
||||
if (isError($update))
|
||||
$this->terminateWithJsonError($this->p->t('ui', 'fehlerBeimSpeichern'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$adressen = $this->input->post('adresse');
|
||||
|
||||
if($adressen) {
|
||||
|
||||
foreach ($adressen as $adresse) {
|
||||
$adresseExists = $this->AdresseModel->loadWhere(array(
|
||||
'adresse_id' => $adresse['id'],
|
||||
'person_id' => $person_id,
|
||||
));
|
||||
|
||||
if (hasData($adresseExists)) {
|
||||
$adresse = $adresse['value'];
|
||||
$adresseExists = getData($adresseExists)[0];
|
||||
if ($adresseExists->strasse !== $adresse['strasse'] ||
|
||||
$adresseExists->plz !== $adresse['plz'] ||
|
||||
$adresseExists->ort !== $adresse['ort'] ||
|
||||
$adresseExists->nation !== $adresse['nation']) {
|
||||
$update = $this->AdresseModel->update(
|
||||
array
|
||||
(
|
||||
'adresse_id' => $adresseExists->adresse_id
|
||||
),
|
||||
array
|
||||
(
|
||||
'strasse' => isEmptyString($adresse['strasse']) ? null : $adresse['strasse'],
|
||||
'plz' => isEmptyString($adresse['plz']) ? null : $adresse['plz'],
|
||||
'ort' => isEmptyString($adresse['ort']) ? null : $adresse['ort'],
|
||||
'nation' => isEmptyString($adresse['nation']) ? null : $adresse['nation'],
|
||||
'updateamum' => date('Y-m-d H:i:s'),
|
||||
'updatevon' => $this->_uid
|
||||
)
|
||||
);
|
||||
|
||||
if (isError($update))
|
||||
$this->terminateWithJsonError($this->p->t('ui', 'fehlerBeimSpeichern'));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2383,4 +2389,4 @@ class InfoCenter extends Auth_Controller
|
||||
|
||||
$this->outputJsonSuccess("Success");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,10 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
*/
|
||||
abstract class Auth_Controller extends FHC_Controller
|
||||
{
|
||||
// Special Permissions
|
||||
const PERM_ANONYMOUS = 'anonymous'; // Everyone
|
||||
const PERM_LOGGED = 'logged_in'; // Every registered user
|
||||
|
||||
/**
|
||||
* Extends this controller if authentication is required
|
||||
*/
|
||||
@@ -14,17 +18,41 @@ abstract class Auth_Controller extends FHC_Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Loads authentication library and starts authentication
|
||||
$this->load->library('AuthLib');
|
||||
if (!is_array($requiredPermissions) || isEmptyArray($requiredPermissions))
|
||||
show_error('The given permissions is not a valid array or it is an empty one');
|
||||
|
||||
if (!isset($requiredPermissions[$this->router->method]))
|
||||
show_error('The given permission array does not contain the given method or is not correctly set');
|
||||
|
||||
$anonAllowed = false;
|
||||
if ($requiredPermissions[$this->router->method] == self::PERM_ANONYMOUS)
|
||||
$anonAllowed = true;
|
||||
elseif (is_array($requiredPermissions[$this->router->method])
|
||||
&& in_array(self::PERM_ANONYMOUS, $requiredPermissions[$this->router->method]))
|
||||
$anonAllowed = true;
|
||||
|
||||
// Checks if the caller is allowed to access to this content
|
||||
$this->_isAllowed($requiredPermissions);
|
||||
if ($anonAllowed) {
|
||||
// Loads authentication library without authentication
|
||||
$this->load->library('AuthLib', [false]);
|
||||
|
||||
// Loads helper since it would only be called on authentication
|
||||
$this->load->helper('hlp_authentication');
|
||||
} else {
|
||||
// Loads authentication library and starts authentication
|
||||
$this->load->library('AuthLib');
|
||||
|
||||
// Checks if the caller is allowed to access to this content
|
||||
$this->_isAllowed($requiredPermissions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the caller is allowed to access to this content with the given permissions
|
||||
* If it is not allowed will set the HTTP header with code 401
|
||||
* Wrapper for permissionlib->isEntitled
|
||||
*
|
||||
* @param array $requiredPermissions
|
||||
* @return void
|
||||
*/
|
||||
private function _isAllowed($requiredPermissions)
|
||||
{
|
||||
@@ -34,28 +62,145 @@ abstract class Auth_Controller extends FHC_Controller
|
||||
// Checks if this user is entitled to access to this content
|
||||
if (!$this->permissionlib->isEntitled($requiredPermissions, $this->router->method))
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_UNAUTHORIZED); // set the HTTP header as unauthorized
|
||||
|
||||
$this->load->library('EPrintfLib'); // loads the EPrintfLib to format the output
|
||||
|
||||
// Prints the main error message
|
||||
$this->eprintflib->printError('You are not allowed to access to this content');
|
||||
// Prints the called controller name
|
||||
$this->eprintflib->printInfo('Controller name: '.$this->router->class);
|
||||
// Prints the called controller method name
|
||||
$this->eprintflib->printInfo('Method name: '.$this->router->method);
|
||||
// Prints the required permissions needed to access to this method
|
||||
$this->eprintflib->printInfo('Required permissions: '.$this->_rpsToString($requiredPermissions, $this->router->method));
|
||||
|
||||
$this->_outputAuthError($requiredPermissions);
|
||||
exit; // immediately terminate the execution
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for Permissions depending if the given person is a
|
||||
* Mitarbeiter and/or Student
|
||||
* and exits/outputs an error if they are not met.
|
||||
*
|
||||
* @param integer $person_id
|
||||
* @param array $permMa Perms if the person is a Mitarbeiter
|
||||
* @param array $permStud Perms if the person is a Student
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function checkPermissionsForPerson($person_id, $permMa, $permStud)
|
||||
{
|
||||
$res = $this->hasPermissionsForPerson($person_id, $permMa, $permStud);
|
||||
|
||||
if ($res) {
|
||||
$perm = array_keys(array_flip(array_merge($res|1 ? $permMa : [], $res|2 ? $permStud : [])));
|
||||
$this->_outputAuthError([$this->router->method => $perm]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for Permissions depending on the Studiengang of a Prestudent
|
||||
* and exits/outputs an error if they are not met.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param array $permStud Perms if the person is a Student
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function checkPermissionsForPrestudent($prestudent_id, $permStud)
|
||||
{
|
||||
if (!$this->hasPermissionsForPrestudent($prestudent_id, $permStud)) {
|
||||
$this->_outputAuthError([$this->router->method => $permStud]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for Permissions depending if the given person is a
|
||||
* Mitarbeiter and/or Student
|
||||
* and returns the result.
|
||||
*
|
||||
* @param integer $person_id
|
||||
* @param array $permMa Perms if the person is a Mitarbeiter
|
||||
* @param array $permStud Perms if the person is a Student
|
||||
*
|
||||
* @return integer 0 if permission is granted
|
||||
*/
|
||||
protected function hasPermissionsForPerson($person_id, $permMa, $permStud)
|
||||
{
|
||||
$res = 3;
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
$this->PersonModel->addJoin('public.tbl_benutzer', 'person_id');
|
||||
$this->PersonModel->addJoin('public.tbl_mitarbeiter', 'uid = mitarbeiter_uid');
|
||||
$result = $this->PersonModel->load($person_id);
|
||||
if (hasData($result)) {
|
||||
if ($this->permissionlib->isEntitled(['a' => $permMa], 'a'))
|
||||
return 0;
|
||||
$res = 1;
|
||||
}
|
||||
$this->PersonModel->addJoin('public.tbl_prestudent', 'person_id');
|
||||
$result = $this->PersonModel->load($person_id);
|
||||
if (hasData($result)) {
|
||||
$permStudConverted = [];
|
||||
foreach (getData($result) as $row) {
|
||||
foreach ($permStud as $k => $v) {
|
||||
if (!isset($permStudConverted[$k])) {
|
||||
$permStudConverted[$k] = $this->permissionlib->convertAccessType($v);
|
||||
}
|
||||
if ($this->permissionlib->isBerechtigt($permStudConverted[$k][0], $permStudConverted[$k][1], $row->studiengang_kz))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
$res += 2;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for Permissions depending on the Studiengang of a Prestudent
|
||||
* and returns the result.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param array $permStud Perms if the person is a Student
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function hasPermissionsForPrestudent($prestudent_id, $permStud)
|
||||
{
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$result = $this->PrestudentModel->load($prestudent_id);
|
||||
if (!hasData($result))
|
||||
show_404();
|
||||
$stg = current(getData($result))->studiengang_kz;
|
||||
foreach ($permStud as $k => $v) {
|
||||
$perm = $this->permissionlib->convertAccessType($v);
|
||||
if ($this->permissionlib->isBerechtigt($perm[0], $perm[1], $stg))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs an error message and sets the HTTP Header.
|
||||
* This function is protected so that it can be overwritten.
|
||||
*
|
||||
* @param array $requiredPermissions
|
||||
* @return void
|
||||
*/
|
||||
protected function _outputAuthError($requiredPermissions)
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_UNAUTHORIZED); // set the HTTP header as unauthorized
|
||||
|
||||
$this->load->library('EPrintfLib'); // loads the EPrintfLib to format the output
|
||||
|
||||
// Prints the main error message
|
||||
$this->eprintflib->printError('You are not allowed to access to this content');
|
||||
// Prints the called controller name
|
||||
$this->eprintflib->printInfo('Controller name: '.$this->router->class);
|
||||
// Prints the called controller method name
|
||||
$this->eprintflib->printInfo('Method name: '.$this->router->method);
|
||||
// Prints the required permissions needed to access to this method
|
||||
$this->eprintflib->printInfo('Required permissions: '.$this->_rpsToString($requiredPermissions, $this->router->method));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an array of permissions to a string that contains them as a comma separated list
|
||||
* Ex: "<permission 1>, <permission 2>, <permission 3>"
|
||||
*
|
||||
* @param array $requiredPermissions
|
||||
* @param string $method
|
||||
* @return void
|
||||
*/
|
||||
private function _rpsToString($requiredPermissions, $method)
|
||||
final protected function _rpsToString($requiredPermissions, $method)
|
||||
{
|
||||
$strRequiredPermissions = ''; // string that contains all the required permissions needed to access to this method
|
||||
|
||||
|
||||
@@ -827,6 +827,23 @@ class DB_Model extends CI_Model
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getDbTable()
|
||||
{
|
||||
return $this->dbTable;
|
||||
}
|
||||
|
||||
public function getPk()
|
||||
{
|
||||
return $this->pk;
|
||||
}
|
||||
|
||||
public function getPks()
|
||||
{
|
||||
if (is_array($this->pk))
|
||||
return $this->pk;
|
||||
return [$this->pk];
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
// Protected methods
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* Controller using JSON
|
||||
*/
|
||||
class FHCAPI_Controller extends FHC_Controller
|
||||
class FHCAPI_Controller extends Auth_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -19,12 +19,13 @@ class FHCAPI_Controller extends FHC_Controller
|
||||
/**
|
||||
* Error types
|
||||
*/
|
||||
const ERROR_TYPE_PHP = 'php'; // TODO(chris): php types from severity?
|
||||
const ERROR_TYPE_PHP = 'php';
|
||||
const ERROR_TYPE_EXCEPTION = 'exception';
|
||||
const ERROR_TYPE_GENERAL = 'general';
|
||||
const ERROR_TYPE_404 = '404';
|
||||
const ERROR_TYPE_DB = 'db';
|
||||
const ERROR_TYPE_VALIDATION = 'validation';
|
||||
const ERROR_TYPE_AUTH = 'auth';
|
||||
|
||||
/**
|
||||
* Return Object
|
||||
@@ -45,10 +46,6 @@ class FHCAPI_Controller extends FHC_Controller
|
||||
if (is_cli())
|
||||
show_404();
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->config->set_item('error_views_path', VIEWPATH.'errors'.DIRECTORY_SEPARATOR.'json'.DIRECTORY_SEPARATOR);
|
||||
|
||||
global $g_result;
|
||||
$g_result = $this;
|
||||
|
||||
@@ -74,18 +71,14 @@ class FHCAPI_Controller extends FHC_Controller
|
||||
}
|
||||
}
|
||||
|
||||
#$this->returnObj['test'] = implode('/n', headers_list());
|
||||
|
||||
return json_encode($this->returnObj);
|
||||
});
|
||||
|
||||
// Load libraries
|
||||
$this->load->library('AuthLib');
|
||||
$this->load->library('PermissionLib');
|
||||
|
||||
// Checks if the caller is allowed to access to this content
|
||||
$this->_isAllowed($requiredPermissions);
|
||||
// NOTE(chris): overwrite error_views_path before constructor
|
||||
load_class('Config')->set_item('error_views_path', VIEWPATH.'errors'.DIRECTORY_SEPARATOR.'json'.DIRECTORY_SEPARATOR);
|
||||
|
||||
parent::__construct($requiredPermissions);
|
||||
|
||||
// For JSON Requests (as opposed to multipart/form-data) get the $_POST variable from the input stream instead
|
||||
if ($this->input->get_request_header('Content-Type', true) == 'application/json')
|
||||
$_POST = json_decode($this->security->xss_clean($this->input->raw_input_stream), true);
|
||||
@@ -101,7 +94,7 @@ class FHCAPI_Controller extends FHC_Controller
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param string|array|object $data
|
||||
* @param string $type (optional)
|
||||
* @return void
|
||||
*/
|
||||
@@ -117,6 +110,8 @@ class FHCAPI_Controller extends FHC_Controller
|
||||
$error['messages'] = $data;
|
||||
else
|
||||
$error = $data;
|
||||
} elseif (is_object($data)) {
|
||||
$error = (array)$data;
|
||||
} else {
|
||||
$error['message'] = $data;
|
||||
}
|
||||
@@ -124,6 +119,9 @@ class FHCAPI_Controller extends FHC_Controller
|
||||
if ($type)
|
||||
$error['type'] = $type;
|
||||
|
||||
if (!isset($error['type']))
|
||||
$error['type'] = self::ERROR_TYPE_GENERAL;
|
||||
|
||||
$this->returnObj['errors'][] = $error;
|
||||
}
|
||||
|
||||
@@ -136,15 +134,25 @@ class FHCAPI_Controller extends FHC_Controller
|
||||
$this->returnObj['data'] = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function addMeta($key, $value)
|
||||
{
|
||||
if (!isset($this->returnObj['meta']))
|
||||
$this->returnObj['meta'] = [];
|
||||
$this->returnObj['meta'][$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $status
|
||||
* @return void
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
if (!isset($this->returnObj['meta']))
|
||||
$this->returnObj['meta'] = [];
|
||||
$this->returnObj['meta']['status'] = $status;
|
||||
$this->addMeta('status', $status);
|
||||
}
|
||||
|
||||
|
||||
@@ -152,6 +160,17 @@ class FHCAPI_Controller extends FHC_Controller
|
||||
// Handle Output object - Shortcut functions
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @param mixed $data (optional)
|
||||
* @return void
|
||||
*/
|
||||
protected function terminateWithSuccess($data = null)
|
||||
{
|
||||
$this->setData($data);
|
||||
$this->setStatus(self::STATUS_SUCCESS);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $errors
|
||||
* @return void
|
||||
@@ -164,25 +183,15 @@ class FHCAPI_Controller extends FHC_Controller
|
||||
exit(EXIT_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $data (optional)
|
||||
* @return void
|
||||
*/
|
||||
protected function terminateWithSuccess($data = null)
|
||||
{
|
||||
$this->setData($data);
|
||||
$this->setStatus(self::STATUS_SUCCESS);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $error
|
||||
* @param string $type (optional)
|
||||
* @param integer $status (optional)
|
||||
* @return void
|
||||
*/
|
||||
protected function terminateWithError($error, $type = null)
|
||||
protected function terminateWithError($error, $type = null, $status = REST_Controller::HTTP_INTERNAL_SERVER_ERROR)
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
$this->output->set_status_header($status);
|
||||
$this->addError($error, $type);
|
||||
$this->setStatus(self::STATUS_ERROR);
|
||||
exit;
|
||||
@@ -193,63 +202,35 @@ class FHCAPI_Controller extends FHC_Controller
|
||||
* @param string $errortype
|
||||
* @return void
|
||||
*/
|
||||
protected function checkForErrors($result, $errortype = self::ERROR_TYPE_GENERAL)
|
||||
protected function getDataOrTerminateWithError($result, $errortype = self::ERROR_TYPE_GENERAL)
|
||||
{
|
||||
// TODO(chris): IMPLEMENT!
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), $errortype);
|
||||
}
|
||||
return $result->retval;
|
||||
}
|
||||
|
||||
// TODO(chris): complete list
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Security
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Checks if the caller is allowed to access to this content with the given permissions
|
||||
* If it is not allowed will set the HTTP header with code 401
|
||||
* Wrapper for permissionlib->isEntitled
|
||||
* Outputs an error message and sets the HTTP Header.
|
||||
* This overwrites the default behaviour to output a json object.
|
||||
*
|
||||
* @param array $requiredPermissions
|
||||
* @return void
|
||||
*/
|
||||
protected function _isAllowed($requiredPermissions)
|
||||
protected function _outputAuthError($requiredPermissions)
|
||||
{
|
||||
// Checks if this user is entitled to access to this content
|
||||
if (!$this->permissionlib->isEntitled($requiredPermissions, $this->router->method))
|
||||
{
|
||||
$this->output->set_status_header(isLogged() ? REST_Controller::HTTP_FORBIDDEN : REST_Controller::HTTP_UNAUTHORIZED);
|
||||
$this->output->set_status_header(isLogged() ? REST_Controller::HTTP_FORBIDDEN : REST_Controller::HTTP_UNAUTHORIZED);
|
||||
|
||||
$this->addError([
|
||||
'message' => 'You are not allowed to access to this content',
|
||||
'controller' => $this->router->class,
|
||||
'method' => $this->router->method,
|
||||
'required_permissions' => $this->_rpsToString($requiredPermissions, $this->router->method)
|
||||
]);
|
||||
exit; // immediately terminate the execution
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an array of permissions to a string that contains them as a comma separated list
|
||||
* Ex: "<permission 1>, <permission 2>, <permission 3>"
|
||||
*
|
||||
* @param array $requiredPermissions
|
||||
* @param string $method
|
||||
* @return void
|
||||
*/
|
||||
protected function _rpsToString($requiredPermissions, $method)
|
||||
{
|
||||
if (!isset($requiredPermissions[$method]))
|
||||
return '';
|
||||
|
||||
if (!is_array($requiredPermissions[$method]))
|
||||
return $requiredPermissions[$method];
|
||||
|
||||
return implode(', ', $requiredPermissions[$method]);
|
||||
$this->addError([
|
||||
'message' => 'You are not allowed to access to this content',
|
||||
'controller' => $this->router->class,
|
||||
'method' => $this->router->method,
|
||||
'required_permissions' => $this->_rpsToString($requiredPermissions, $this->router->method)
|
||||
], self::ERROR_TYPE_AUTH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,21 +5,18 @@
|
||||
*/
|
||||
abstract class IssueResolver_Controller extends JOB_Controller
|
||||
{
|
||||
const CI_PATH = 'application';
|
||||
const CI_LIBRARY_FOLDER = 'libraries';
|
||||
const EXTENSIONS_FOLDER = 'extensions';
|
||||
const ISSUE_RESOLVERS_FOLDER = 'issues/resolvers';
|
||||
const CHECK_ISSUE_RESOLVED_METHOD_NAME = 'checkIfIssueIsResolved';
|
||||
// mappings in form fehlercode -> resolverlibrary name, fehler which have explicit resolver class defined
|
||||
protected $_codeLibMappings = [];
|
||||
|
||||
protected $_codeLibMappings;
|
||||
// mappings in form fehlercode -> producer library name, fehler which are resolved the same way they are produced
|
||||
protected $_codeProducerLibMappings = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// pass extension name if calling from extension
|
||||
$this->load->model('system/Issue_model', 'IssueModel');
|
||||
|
||||
$this->load->library('IssuesLib');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,97 +24,29 @@ abstract class IssueResolver_Controller extends JOB_Controller
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->load->library(
|
||||
'issues/PlausicheckResolverLib',
|
||||
[
|
||||
'extensionName' => $this->_extensionName ?? null,
|
||||
'codeLibMappings' => $this->_codeLibMappings,
|
||||
'codeProducerLibMappings' => $this->_codeProducerLibMappings
|
||||
]
|
||||
);
|
||||
|
||||
$this->logInfo("Issue resolve job started");
|
||||
|
||||
// load open issues with given errorcodes
|
||||
$openIssuesRes = $this->IssueModel->getOpenIssues(array_keys($this->_codeLibMappings));
|
||||
$openIssuesRes = $this->IssueModel->getOpenIssues(
|
||||
array_merge(array_keys($this->_codeLibMappings), array_keys($this->_codeProducerLibMappings))
|
||||
);
|
||||
|
||||
// log error if occured
|
||||
if (isError($openIssuesRes))
|
||||
{
|
||||
$this->logError(getError($openIssuesRes));
|
||||
}
|
||||
else
|
||||
{
|
||||
// log info if no data found
|
||||
if (!hasData($openIssuesRes))
|
||||
{
|
||||
$this->logInfo("No open issues found");
|
||||
}
|
||||
else
|
||||
{
|
||||
$openIssues = getData($openIssuesRes);
|
||||
$openIssues = hasData($openIssuesRes) ? getData($openIssuesRes) : [];
|
||||
|
||||
foreach ($openIssues as $issue)
|
||||
{
|
||||
// ignore if Fehlercode is not in libmappings (shouldn't be checked)
|
||||
if (!isset($this->_codeLibMappings[$issue->fehlercode])) continue;
|
||||
$result = $this->plausicheckresolverlib->resolvePlausicheckIssues($openIssues);
|
||||
|
||||
$libName = $this->_codeLibMappings[$issue->fehlercode];
|
||||
|
||||
// add person id and oe kurzbz automatically as params, merge it with additional params
|
||||
// decode bewerbung_parameter into assoc array
|
||||
$params = array_merge(
|
||||
array('issue_id' => $issue->issue_id, 'issue_person_id' => $issue->person_id, 'issue_oe_kurzbz' => $issue->oe_kurzbz),
|
||||
isset($issue->behebung_parameter) ? json_decode($issue->behebung_parameter, true) : array()
|
||||
);
|
||||
|
||||
// if called from extension (extension name set), path includes extension names
|
||||
$libRootPath = isset($this->_extensionName) ? self::EXTENSIONS_FOLDER . '/' . $this->_extensionName . '/' : '';
|
||||
|
||||
// path for loading issue library
|
||||
$issuesLibPath = $libRootPath . self::ISSUE_RESOLVERS_FOLDER . '/';
|
||||
|
||||
// file path of library for check if file exists
|
||||
$issuesLibFilePath = DOC_ROOT . self::CI_PATH
|
||||
. '/' . $libRootPath . self::CI_LIBRARY_FOLDER . '/' . self::ISSUE_RESOLVERS_FOLDER . '/' . $libName . '.php';
|
||||
|
||||
// check if library file exists
|
||||
if (!file_exists($issuesLibFilePath))
|
||||
{
|
||||
// log error and continue with next issue if not
|
||||
$this->logError("Issue library file " . $issuesLibFilePath . " does not exist");
|
||||
continue;
|
||||
}
|
||||
|
||||
// load library connected to fehlercode
|
||||
$this->load->library($issuesLibPath . $libName);
|
||||
|
||||
$lowercaseLibName = mb_strtolower($libName);
|
||||
|
||||
// check if method is defined in library class
|
||||
if (!is_callable(array($this->{$lowercaseLibName}, self::CHECK_ISSUE_RESOLVED_METHOD_NAME)))
|
||||
{
|
||||
// log error and continue with next issue if not
|
||||
$this->logError("Method " . self::CHECK_ISSUE_RESOLVED_METHOD_NAME . " is not defined in library $lowercaseLibName");
|
||||
continue;
|
||||
}
|
||||
|
||||
// call the function for checking for issue resolution
|
||||
$issueResolvedRes = $this->{$lowercaseLibName}->{self::CHECK_ISSUE_RESOLVED_METHOD_NAME}($params);
|
||||
|
||||
if (isError($issueResolvedRes))
|
||||
{
|
||||
$this->logError(getError($issueResolvedRes));
|
||||
}
|
||||
else
|
||||
{
|
||||
$issueResolvedData = getData($issueResolvedRes);
|
||||
|
||||
if ($issueResolvedData === true)
|
||||
{
|
||||
// set issue to resolved if needed
|
||||
$behobenRes = $this->issueslib->setBehoben($issue->issue_id, null);
|
||||
|
||||
if (isError($behobenRes))
|
||||
$this->logError(getError($behobenRes));
|
||||
else
|
||||
$this->logInfo("Issue " . $issue->issue_id . " successfully resolved");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// log if error, or log info if inserted new issue
|
||||
foreach ($result->errors as $error) $this->logError($error);
|
||||
foreach ($result->infos as $info) $this->logInfo($info);
|
||||
|
||||
$this->logInfo("Issue resolve job ended");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,461 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
abstract class Notiz_Controller extends FHCAPI_Controller
|
||||
{
|
||||
const DEFAULT_PERMISSION_R = 'admin:r';
|
||||
const DEFAULT_PERMISSION_RW = 'admin:rw';
|
||||
//public function __construct($zuordnung = 'person/Notizzuordnung_model')
|
||||
public function __construct($permissions)
|
||||
{
|
||||
$default_permissions = [
|
||||
'getUid' => self::DEFAULT_PERMISSION_R,
|
||||
'getNotizen' => self::DEFAULT_PERMISSION_R,
|
||||
'loadNotiz' => self::DEFAULT_PERMISSION_R,
|
||||
'addNewNotiz' => self::DEFAULT_PERMISSION_RW,
|
||||
'updateNotiz' => self::DEFAULT_PERMISSION_RW,
|
||||
'deleteNotiz' => self::DEFAULT_PERMISSION_RW,
|
||||
'loadDokumente' => self::DEFAULT_PERMISSION_R,
|
||||
'getMitarbeiter' => self::DEFAULT_PERMISSION_R,
|
||||
'isBerechtigt' => self::DEFAULT_PERMISSION_R,
|
||||
];
|
||||
|
||||
if(!is_array($permissions))
|
||||
{
|
||||
$this->terminateWithError("Notiz_controller construct: permissions must be an array");
|
||||
}
|
||||
|
||||
$merged_permissions = array_merge($default_permissions, $permissions);
|
||||
|
||||
parent::__construct($merged_permissions);
|
||||
|
||||
//Load Models
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
]);
|
||||
}
|
||||
|
||||
public function getUid()
|
||||
{
|
||||
$this->terminateWithSuccess(getAuthUID());
|
||||
}
|
||||
|
||||
|
||||
//Override function for extensions
|
||||
protected function assignNotiz($notiz_id, $id, $type)
|
||||
{
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
$result = $this->NotizzuordnungModel->isValidType($type);
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$result = $this->NotizzuordnungModel->insert(array('notiz_id' => $notiz_id, $type => $id));
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return success(getData($result));
|
||||
}
|
||||
|
||||
//Override function for extensions
|
||||
protected function deleteNotizzuordnung($notiz_id, $id, $type)
|
||||
{
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
$result = $this->NotizzuordnungModel->isValidType($type);
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError('type not in table notizzuordnung enthalten..', self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = $this->NotizzuordnungModel->delete(['notiz_id' => $notiz_id, $type => $id]);
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return success(getData($result));
|
||||
}
|
||||
|
||||
|
||||
//Override function for extensions
|
||||
public function getNotizen($id, $type)
|
||||
{
|
||||
$result = $this->NotizzuordnungModel->isValidType($type);
|
||||
if(isError($result))
|
||||
$this->terminateWithError($result->retval, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$result = $this->NotizModel->getNotizWithDocEntries($id, $type);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
|
||||
|
||||
//Override function
|
||||
protected function isBerechtigt($id, $typeId){
|
||||
return $this->terminateWithError("in abstract function: define right in extension", self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
public function loadNotiz()
|
||||
{
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
|
||||
//$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'notiz_id', 'LEFT');
|
||||
$this->NotizModel->addSelect('*');
|
||||
$this->NotizModel->addSelect("TO_CHAR(CASE WHEN public.tbl_notiz.updateamum >= public.tbl_notiz.insertamum
|
||||
THEN public.tbl_notiz.updateamum ELSE public.tbl_notiz.insertamum END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate");
|
||||
$this->NotizModel->addLimit(1);
|
||||
|
||||
$result = $this->NotizModel->loadWhere(
|
||||
array('notiz_id' => $notiz_id)
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
elseif (!hasData($result))
|
||||
{
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
}
|
||||
|
||||
public function addNewNotiz($id, $paramTyp = null)
|
||||
{
|
||||
$this->load->library('DmsLib');
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$uid = getAuthUID();
|
||||
|
||||
if (isset($_POST['data']))
|
||||
{
|
||||
$data = json_decode($_POST['data']);
|
||||
unset($_POST['data']);
|
||||
foreach ($data as $k => $v) {
|
||||
$_POST[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
//Form Validation
|
||||
$this->form_validation->set_rules('titel', 'Titel', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('text', 'Text', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$titel = $this->input->post('titel');
|
||||
$text = $this->input->post('text');
|
||||
$erledigt = $this->input->post('erledigt');
|
||||
$verfasser_uid = isset($_POST['verfasser']) ? $_POST['verfasser'] : $uid;
|
||||
$bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : null;
|
||||
$type = $this->input->post('typeId');
|
||||
$start = $this->input->post('start');
|
||||
$ende = $this->input->post('ende');
|
||||
|
||||
// Start DB transaction
|
||||
$this->db->trans_start();
|
||||
|
||||
//Save note
|
||||
$result = $this->NotizModel->insert(array('titel' => $titel, 'text' => $text, 'erledigt' => $erledigt, 'verfasser_uid' => $verfasser_uid,
|
||||
"insertvon" => $verfasser_uid, 'start' => $start, 'ende' => $ende, 'bearbeiter_uid' => $bearbeiter_uid));
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$notiz_id = $result->retval;
|
||||
|
||||
//save Notizzuordnung
|
||||
$result = $this->assignNotiz($notiz_id, $id, $type);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//save Documents
|
||||
$dms_id_arr = [];
|
||||
foreach ($_FILES as $k => $file)
|
||||
{
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'notiz',
|
||||
'version' => 0,
|
||||
'name' => $file["name"],
|
||||
'mimetype' => $file["type"],
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $uid
|
||||
);
|
||||
|
||||
//Todo(manu) check if filetypes weiter eingeschränkt werden sollen
|
||||
//Todo(manu)check name files: nicht gleiches file 2mal hochladen
|
||||
//Todo define in dms component: readFile, downloadFile
|
||||
$result = $this->dmslib->upload($dms, $k, ['*']);
|
||||
/* $result = $this->dmslib->upload($dms, $k, ['application/pdf','application/x.fhc-dms+json']);*/
|
||||
if (isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$dms_id_arr[] = $result->retval['dms_id'];
|
||||
}
|
||||
|
||||
//save entry in Notizdokument
|
||||
if($dms_id_arr)
|
||||
{
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
foreach($dms_id_arr as $dms_id)
|
||||
{
|
||||
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
|
||||
if (isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
return $this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function updateNotiz()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
if (isset($_POST['data']))
|
||||
{
|
||||
$data = json_decode($_POST['data']);
|
||||
unset($_POST['data']);
|
||||
foreach ($data as $k => $v) {
|
||||
$_POST[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
|
||||
if(!$notiz_id)
|
||||
{
|
||||
$this->terminateWithError($this->p->t('ui','error_missingId',['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//Form Validation
|
||||
$this->form_validation->set_rules('titel', 'Titel', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('text', 'Text', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
//update Notiz
|
||||
$uid = getAuthUID();
|
||||
$titel = $this->input->post('titel');
|
||||
$text = $this->input->post('text');
|
||||
$verfasser_uid = isset($_POST['verfasser']) ? $_POST['verfasser'] : $uid;
|
||||
$bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid;
|
||||
$erledigt = $this->input->post('erledigt');
|
||||
$start = $this->input->post('start');
|
||||
$ende = $this->input->post('ende');
|
||||
|
||||
$result = $this->NotizModel->update(
|
||||
[
|
||||
'notiz_id' => $notiz_id
|
||||
],
|
||||
[
|
||||
'titel' => $titel,
|
||||
'updatevon' => $uid,
|
||||
'updateamum' => date('c'),
|
||||
'text' => $text,
|
||||
'verfasser_uid' => $verfasser_uid,
|
||||
'bearbeiter_uid' => $bearbeiter_uid,
|
||||
'start' => $start,
|
||||
'ende' => $ende,
|
||||
'erledigt' => $erledigt
|
||||
]
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//update(1) loading all dms-entries with this notiz_id
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
$this->NotizdokumentModel->addJoin('campus.tbl_dms_version', 'dms_id');
|
||||
|
||||
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
foreach ($result as $doc) {
|
||||
$dms_id_arr[$doc->dms_id] = array(
|
||||
'name' => $doc->name,
|
||||
'dms_id' => $doc->dms_id
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($_FILES as $k => $file)
|
||||
{
|
||||
//update(2) attach all new files (except type application/x.fhc-dms+json)
|
||||
if($file["type"] == 'application/x.fhc-dms+json')
|
||||
{
|
||||
$jsonFile = json_decode(file_get_contents($file['tmp_name']));
|
||||
unset($dms_id_arr[$jsonFile->dms_id]);
|
||||
#$dms_uploaded[] = $jsonFile->dms_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'notiz',
|
||||
'version' => 0,
|
||||
'name' => $file["name"],
|
||||
'mimetype' => $file["type"],
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $uid
|
||||
);
|
||||
|
||||
//Todo(manu) check if filetypes weiter eingeschränkt werden sollen
|
||||
//Todo(manu)check name files: nicht gleiches file 2mal hochladen
|
||||
//Todo define in dms component: readFile, downloadFile
|
||||
$result = $this->dmslib->upload($dms, $k, array('*'));
|
||||
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
$dms_id = $result['dms_id'];
|
||||
|
||||
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
}
|
||||
|
||||
//update(3) check if all files have been deleted
|
||||
foreach ($dms_id_arr as $file)
|
||||
{
|
||||
$result = $this->dmslib->removeAll($file['dms_id']);
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
|
||||
return $this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function deleteNotiz()
|
||||
{
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
$typeId = $this->input->post('type_id');
|
||||
$id = $this->input->post('id');
|
||||
|
||||
//TODO(manu): define Permissions for deletion document if filecomponent finished
|
||||
|
||||
//get dms_id from notizdokument
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
|
||||
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
|
||||
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
// Start DB transaction
|
||||
$this->db->trans_start();
|
||||
|
||||
if ($result)
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
foreach ($result as $doc) {
|
||||
$res = $this->dmslib->removeAll($doc->dms_id);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
//delete Notizzuordnung
|
||||
$result = $this-> deleteNotizzuordnung($notiz_id, $id, $typeId);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
|
||||
//Delete Note
|
||||
$result = $this->NotizModel->delete($notiz_id);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if(!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->db->trans_complete();
|
||||
return $this->terminateWithSuccess(getData($result));
|
||||
}
|
||||
|
||||
public function loadDokumente()
|
||||
{
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
|
||||
$this->NotizModel->addSelect('campus.tbl_dms_version.*');
|
||||
|
||||
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'ON (public.tbl_notiz_dokument.notiz_id = public.tbl_notiz.notiz_id)');
|
||||
$this->NotizModel->addJoin('campus.tbl_dms_version', 'ON (public.tbl_notiz_dokument.dms_id = campus.tbl_dms_version.dms_id)');
|
||||
|
||||
$result = $this->NotizModel->loadWhere(
|
||||
array('public.tbl_notiz.notiz_id' => $notiz_id)
|
||||
);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if(!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result));
|
||||
}
|
||||
|
||||
public function getMitarbeiter($searchString)
|
||||
{
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
$result = $this->MitarbeiterModel->searchMitarbeiter($searchString);
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,61 +5,23 @@
|
||||
*/
|
||||
abstract class PlausiIssueProducer_Controller extends JOB_Controller
|
||||
{
|
||||
protected $_fehlerLibMappings;
|
||||
protected $_fehlerLibMappings = [];
|
||||
protected $_app;
|
||||
|
||||
public function __construct($app = null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// pass extension name if calling from extension
|
||||
$extensionName = isset($this->_extensionName) ? $this->_extensionName : null;
|
||||
|
||||
// load libraries
|
||||
$this->load->library('issues/PlausicheckProducerLib', array('extensionName' => $extensionName, 'app' => $this->_app));
|
||||
$this->load->library('IssuesLib');
|
||||
}
|
||||
|
||||
protected function producePlausicheckIssues($params)
|
||||
{
|
||||
$this->load->library(
|
||||
'issues/PlausicheckProducerLib',
|
||||
['extensionName' => $this->_extensionName ?? null, 'app' => $this->_app, 'fehlerLibMappings' => $this->_fehlerLibMappings]
|
||||
);
|
||||
|
||||
$this->logInfo("Plausicheck issue producer job started");
|
||||
|
||||
// get the data returned by Plausicheck
|
||||
foreach ($this->_fehlerLibMappings as $fehler_kurzbz => $libName)
|
||||
{
|
||||
// execute the check
|
||||
$this->logInfo("Checking " . $fehler_kurzbz . "...");
|
||||
$plausicheckRes = $this->plausicheckproducerlib->producePlausicheckIssue(
|
||||
$libName,
|
||||
$fehler_kurzbz,
|
||||
$params
|
||||
);
|
||||
$result = $this->plausicheckproducerlib->producePlausicheckIssues($params);
|
||||
|
||||
if (isError($plausicheckRes)) $this->logError(getError($plausicheckRes));
|
||||
|
||||
if (hasData($plausicheckRes))
|
||||
{
|
||||
$plausicheckData = getData($plausicheckRes);
|
||||
|
||||
foreach ($plausicheckData as $plausiData)
|
||||
{
|
||||
// get the data needed for issue production
|
||||
$person_id = isset($plausiData['person_id']) ? $plausiData['person_id'] : null;
|
||||
$oe_kurzbz = isset($plausiData['oe_kurzbz']) ? $plausiData['oe_kurzbz'] : null;
|
||||
$fehlertext_params = isset($plausiData['fehlertext_params']) ? $plausiData['fehlertext_params'] : null;
|
||||
$resolution_params = isset($plausiData['resolution_params']) ? $plausiData['resolution_params'] : null;
|
||||
|
||||
// write the issue
|
||||
$addIssueRes = $this->issueslib->addFhcIssue($fehler_kurzbz, $person_id, $oe_kurzbz, $fehlertext_params, $resolution_params);
|
||||
|
||||
// log if error, or log info if inserted new issue
|
||||
if (isError($addIssueRes))
|
||||
$this->logError(getError($addIssueRes));
|
||||
elseif (hasData($addIssueRes) && is_integer(getData($addIssueRes)))
|
||||
$this->logInfo("Plausicheck issue " . $fehler_kurzbz . " successfully produced, person_id: " . $person_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
// log if error, or log info if inserted new issue
|
||||
foreach ($result->errors as $error) $this->logError($error);
|
||||
foreach ($result->infos as $info) $this->logInfo($info);
|
||||
|
||||
$this->logInfo("Plausicheck issue producer job stopped");
|
||||
}
|
||||
|
||||
@@ -422,3 +422,79 @@ function isValidDate($dateString)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Collection of utility functions for form validation purposes
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* check if string can be converted to a date
|
||||
*/
|
||||
function is_valid_date($dateString)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (new DateTime($dateString)) !== false;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check if given permissions are met
|
||||
*/
|
||||
function has_write_permissions($value, $permissions = '')
|
||||
{
|
||||
if (!$permissions)
|
||||
$permissions = $value;
|
||||
$permissions = explode(',', $permissions);
|
||||
|
||||
$CI =& get_instance();
|
||||
$CI->load->library('AuthLib');
|
||||
$CI->load->library('PermissionLib');
|
||||
|
||||
return $CI->permissionlib->hasAtLeastOne(
|
||||
$permissions,
|
||||
'sometable',
|
||||
PermissionLib::WRITE_RIGHT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if has permissions for a studiengang_kz
|
||||
*/
|
||||
function has_permissions_for_stg($studiengang_kz, $permissions = '')
|
||||
{
|
||||
if (!$permissions)
|
||||
return false;
|
||||
$permissions = explode(',', $permissions);
|
||||
|
||||
$CI =& get_instance();
|
||||
$CI->load->library('AuthLib');
|
||||
$CI->load->library('PermissionLib');
|
||||
|
||||
foreach ($permissions as $perm) {
|
||||
if (strpos($perm, PermissionLib::PERMISSION_SEPARATOR) === false) {
|
||||
$CI->addError(
|
||||
'The given permission does not use the correct format',
|
||||
FHCAPI_Controller::ERROR_TYPE_GENERAL
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
list($perm, $accesstype) = explode(PermissionLib::PERMISSION_SEPARATOR, $perm);
|
||||
$at = '';
|
||||
if (strpos($accesstype, PermissionLib::READ_RIGHT) !== false)
|
||||
$at = PermissionLib::SELECT_RIGHT; // S
|
||||
if (strpos($accesstype, PermissionLib::WRITE_RIGHT) !== false)
|
||||
$at .= PermissionLib::REPLACE_RIGHT.PermissionLib::DELETE_RIGHT; // UID
|
||||
|
||||
if ($CI->permissionlib->isBerechtigt($perm, $at, $studiengang_kz))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 - 2022, CodeIgniter Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||
* @copyright Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
*/
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
$lang['form_validation_has_write_permissions'] = 'You have no rights to edit {field} field.';
|
||||
$lang['form_validation_is_valid_date'] = 'The date format is invalid or out of range.';
|
||||
$lang['form_validation_has_permissions_for_stg'] = 'You have no rights for stg {field}.';
|
||||
@@ -121,7 +121,7 @@ class AntragLib
|
||||
public function unpauseAntrag($antrag_id, $insertvon)
|
||||
{
|
||||
if ($insertvon == Studierendenantragstatus_model::INSERTVON_DEREGISTERED)
|
||||
return error($this->p->t('studierendenantrag', 'error_no_right'));
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_right'));
|
||||
if ($insertvon == Studierendenantragstatus_model::INSERTVON_ABMELDUNGSTGL) {
|
||||
return $this->_ci->StudierendenantragstatusModel->resumeAntraegeForAbmeldungStgl($antrag_id);
|
||||
}
|
||||
@@ -257,18 +257,28 @@ class AntragLib
|
||||
if (isError($result))
|
||||
$errors[] = getError($result);
|
||||
|
||||
$this->_ci->load->model('crm/Statusgrund_model', 'StatusgrundModel');
|
||||
$result = $this->_ci->StatusgrundModel->loadWhere(['statusgrund_kurzbz' => 'abbrecherStud']);
|
||||
if (isError($result)) {
|
||||
$errors[] = getError($result);
|
||||
continue;
|
||||
} elseif (!hasData($result)) {
|
||||
$errors[] = $this->_ci->p->t('lehre', 'error_noStatusgrund', ['statusgrund_kurzbz' => 'abbrecherStud']);
|
||||
continue;
|
||||
}
|
||||
$statusgrund = current(getData($result));
|
||||
|
||||
$result = $this->_ci->prestudentlib->setAbbrecher(
|
||||
$antrag->prestudent_id,
|
||||
$antrag->studiensemester_kurzbz,
|
||||
$insertvon,
|
||||
'abbrecherStud',
|
||||
$statusgrund->statusgrund_id,
|
||||
$antrag->datum,
|
||||
$insertam
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
if (isError($result)) {
|
||||
$errors[] = getError($result);
|
||||
return $errors;
|
||||
continue;
|
||||
}
|
||||
|
||||
$result = $this->_ci->PersonModel->loadPrestudent($antrag->prestudent_id);
|
||||
@@ -421,11 +431,20 @@ class AntragLib
|
||||
// NOTE(chris): here we should have error handling but at the
|
||||
// moment there is no way to notify the user for "soft" errors
|
||||
|
||||
$this->_ci->load->model('crm/Statusgrund_model', 'StatusgrundModel');
|
||||
$result = $this->_ci->StatusgrundModel->loadWhere(['statusgrund_kurzbz' => 'abbrecherStgl']);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error($this->_ci->p->t('lehre', 'error_noStatusgrund', ['statusgrund_kurzbz' => 'abbrecherStgl']));
|
||||
|
||||
$statusgrund = current(getData($result));
|
||||
|
||||
$result = $this->_ci->prestudentlib->setAbbrecher(
|
||||
$antrag->prestudent_id,
|
||||
$antrag->studiensemester_kurzbz,
|
||||
$insertvon,
|
||||
'abbrecherStgl',
|
||||
$statusgrund->statusgrund_id,
|
||||
$status->insertamum
|
||||
);
|
||||
|
||||
@@ -911,7 +930,7 @@ class AntragLib
|
||||
public function createWiederholung($prestudent_id, $studiensemester_kurzbz, $insertvon, $repeat)
|
||||
{
|
||||
$result = $this->_ci->StudierendenantragModel->loadIdAndStatusWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'tbl_studierendenantrag.prestudent_id' => $prestudent_id,
|
||||
'studiensemester_kurzbz'=> $studiensemester_kurzbz,
|
||||
'typ' => Studierendenantrag_model::TYP_WIEDERHOLUNG
|
||||
]);
|
||||
@@ -1341,7 +1360,7 @@ class AntragLib
|
||||
|
||||
if (!in_array($result->status_kurzbz, $this->_ci->config->item('antrag_prestudentstatus_whitelist_abmeldung'))) {
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'tbl_studierendenantrag.prestudent_id' => $prestudent_id,
|
||||
's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_APPROVED
|
||||
], [
|
||||
Studierendenantrag_model::TYP_ABMELDUNG,
|
||||
@@ -1353,7 +1372,7 @@ class AntragLib
|
||||
return success(-1);
|
||||
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'tbl_studierendenantrag.prestudent_id' => $prestudent_id,
|
||||
's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_PAUSE
|
||||
], [
|
||||
Studierendenantrag_model::TYP_ABMELDUNG,
|
||||
@@ -1367,7 +1386,7 @@ class AntragLib
|
||||
return success(0);
|
||||
}
|
||||
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['prestudent_id' => $prestudent_id]);
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['tbl_studierendenantrag.prestudent_id' => $prestudent_id]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
@@ -1428,7 +1447,7 @@ class AntragLib
|
||||
&& $result->status_kurzbz != 'Unterbrecher') {
|
||||
return success(0);
|
||||
}
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['prestudent_id' => $prestudent_id]);
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['tbl_studierendenantrag.prestudent_id' => $prestudent_id]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
@@ -1444,12 +1463,6 @@ class AntragLib
|
||||
elseif($antrag->status == Studierendenantragstatus_model::STATUS_APPROVED && $antrag->datum > $datumStatus)
|
||||
return success(-2);
|
||||
}
|
||||
if ($antrag->typ == Studierendenantrag_model::TYP_UNTERBRECHUNG)
|
||||
{
|
||||
// NOTE(chris): Ignore canceled ones
|
||||
if ($antrag->status == Studierendenantragstatus_model::STATUS_CANCELLED)
|
||||
continue;
|
||||
}
|
||||
if ($antrag->typ == Studierendenantrag_model::TYP_WIEDERHOLUNG)
|
||||
{
|
||||
if($antrag->status == Studierendenantragstatus_model::STATUS_PASS)
|
||||
@@ -1510,7 +1523,7 @@ class AntragLib
|
||||
$datumStatus = $result->datum;
|
||||
if (!in_array($result->status_kurzbz, $this->_ci->config->item('antrag_prestudentstatus_whitelist'))) {
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'tbl_studierendenantrag.prestudent_id' => $prestudent_id,
|
||||
'typ' => Studierendenantrag_model::TYP_WIEDERHOLUNG,
|
||||
's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_APPROVED
|
||||
]);
|
||||
@@ -1520,7 +1533,7 @@ class AntragLib
|
||||
return success(-1);
|
||||
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'tbl_studierendenantrag.prestudent_id' => $prestudent_id,
|
||||
'typ' => Studierendenantrag_model::TYP_WIEDERHOLUNG,
|
||||
's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_DEREGISTERED
|
||||
]);
|
||||
@@ -1530,7 +1543,7 @@ class AntragLib
|
||||
return success(-1);
|
||||
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'tbl_studierendenantrag.prestudent_id' => $prestudent_id,
|
||||
'typ' => Studierendenantrag_model::TYP_WIEDERHOLUNG,
|
||||
's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_PAUSE
|
||||
]);
|
||||
@@ -1541,7 +1554,7 @@ class AntragLib
|
||||
|
||||
return success(0);
|
||||
}
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['prestudent_id' => $prestudent_id]);
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['tbl_studierendenantrag.prestudent_id' => $prestudent_id]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
@@ -1594,7 +1607,7 @@ class AntragLib
|
||||
public function getDetailsForLastAntrag($prestudent_id, $typ = null)
|
||||
{
|
||||
$where = [
|
||||
'prestudent_id' => $prestudent_id
|
||||
'tbl_studierendenantrag.prestudent_id' => $prestudent_id
|
||||
];
|
||||
$types = null;
|
||||
if ($typ) {
|
||||
@@ -2058,7 +2071,7 @@ class AntragLib
|
||||
*/
|
||||
public function isEntitledToUnpauseAntrag($antrag_id)
|
||||
{
|
||||
return $this->hasAccessToAntrag($antrag_id, 'student/studierendenantrag');
|
||||
return ($this->hasAccessToAntrag($antrag_id, 'student/antragfreigabe') || $this->hasAccessToAntrag($antrag_id, 'student/studierendenantrag'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2180,4 +2193,4 @@ class AntragLib
|
||||
$result = $this->_ci->StudierendenantraglehrveranstaltungModel->getLvsForPrestudent($prestudent_id, $studiensemester_kurzbz);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,7 +246,27 @@ class IssuesLib
|
||||
$fehlertext = vsprintf($fehlertextVorlage, $fehlertext_params);
|
||||
}
|
||||
|
||||
$openIssuesCountRes = $this->_ci->IssueModel->getOpenIssueCount($fehlercode, $person_id, $oe_kurzbz, $fehlercode_extern);
|
||||
if (isset($resolution_params))
|
||||
{
|
||||
if (is_array($resolution_params))
|
||||
{
|
||||
foreach ($resolution_params as $resolution_key => $resolution_param)
|
||||
{
|
||||
if (!is_string($resolution_key))
|
||||
return error("Invalid parameter for resolution, must be an associative array");
|
||||
}
|
||||
}
|
||||
else
|
||||
return error("Invalid parameters for resolution");
|
||||
}
|
||||
|
||||
$openIssuesCountRes = $this->_ci->IssueModel->getOpenIssueCount(
|
||||
$fehlercode,
|
||||
$person_id,
|
||||
$oe_kurzbz,
|
||||
$fehlercode_extern,
|
||||
$resolution_params
|
||||
);
|
||||
|
||||
if (hasData($openIssuesCountRes))
|
||||
{
|
||||
@@ -256,20 +276,6 @@ class IssuesLib
|
||||
|
||||
if ($openIssueCount == 0)
|
||||
{
|
||||
if (isset($resolution_params))
|
||||
{
|
||||
if (is_array($resolution_params))
|
||||
{
|
||||
foreach ($resolution_params as $resolution_key => $resolution_param)
|
||||
{
|
||||
if (!is_string($resolution_key))
|
||||
return error("Invalid parameter for resolution, must be an associative array");
|
||||
}
|
||||
}
|
||||
else
|
||||
return error("Invalid parameters for resolution");
|
||||
}
|
||||
|
||||
// insert new issue
|
||||
return $this->_ci->IssueModel->insert(
|
||||
array(
|
||||
|
||||
@@ -21,6 +21,8 @@ require_once(FHCPATH.'include/functions.inc.php');
|
||||
require_once(FHCPATH.'include/wawi_kostenstelle.class.php');
|
||||
require_once(FHCPATH.'include/benutzerberechtigung.class.php');
|
||||
|
||||
use \benutzerberechtigung as benutzerberechtigung;
|
||||
|
||||
class PermissionLib
|
||||
{
|
||||
// Available rights in the DB
|
||||
@@ -65,8 +67,10 @@ class PermissionLib
|
||||
if (!is_cli())
|
||||
{
|
||||
// API Caller rights initialization
|
||||
$authObj = $this->_ci->authlib->getAuthObj();
|
||||
self::$bb = new benutzerberechtigung();
|
||||
self::$bb->getBerechtigungen(($this->_ci->authlib->getAuthObj())->{AuthLib::AO_USERNAME});
|
||||
if ($authObj)
|
||||
self::$bb->getBerechtigungen($authObj->{AuthLib::AO_USERNAME});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,19 +147,7 @@ class PermissionLib
|
||||
if (strpos($permissions[$pCounter], PermissionLib::PERMISSION_SEPARATOR) !== false)
|
||||
{
|
||||
// Retrieves permission and required access type from the $requiredPermissions array
|
||||
list($permission, $requiredAccessType) = explode(PermissionLib::PERMISSION_SEPARATOR, $permissions[$pCounter]);
|
||||
|
||||
$accessType = '';
|
||||
|
||||
// Set the access type
|
||||
if (strpos($requiredAccessType, PermissionLib::READ_RIGHT) !== false)
|
||||
{
|
||||
$accessType = PermissionLib::SELECT_RIGHT; // S
|
||||
}
|
||||
if (strpos($requiredAccessType, PermissionLib::WRITE_RIGHT) !== false)
|
||||
{
|
||||
$accessType .= PermissionLib::REPLACE_RIGHT.PermissionLib::DELETE_RIGHT; // UID
|
||||
}
|
||||
list($permission, $accessType) = $this->convertAccessType($permissions[$pCounter]);
|
||||
|
||||
if (!isEmptyString($accessType)) // if compliant
|
||||
{
|
||||
@@ -166,6 +158,16 @@ class PermissionLib
|
||||
if ($checkPermissions === true) break;
|
||||
}
|
||||
}
|
||||
elseif ($permissions[$pCounter] == Auth_Controller::PERM_ANONYMOUS)
|
||||
{
|
||||
$checkPermissions = true;
|
||||
break;
|
||||
}
|
||||
elseif ($permissions[$pCounter] == Auth_Controller::PERM_LOGGED)
|
||||
{
|
||||
$checkPermissions = isLogged();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error('The given permission does not use the correct format');
|
||||
@@ -195,6 +197,24 @@ class PermissionLib
|
||||
return $checkPermissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves permission and required access type from the newly formatted permission string
|
||||
*
|
||||
* @param string $permission
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function convertAccessType($permission)
|
||||
{
|
||||
list($permission, $reqAccessType) = explode(PermissionLib::PERMISSION_SEPARATOR, $permission);
|
||||
$accessType = '';
|
||||
if (strpos($reqAccessType, PermissionLib::READ_RIGHT) !== false)
|
||||
$accessType = PermissionLib::SELECT_RIGHT;
|
||||
if (strpos($reqAccessType, PermissionLib::WRITE_RIGHT) !== false)
|
||||
$accessType = PermissionLib::REPLACE_RIGHT.PermissionLib::DELETE_RIGHT;
|
||||
return [$permission, $accessType];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if at least one of the permissions given as parameter (requiredPermissions) belongs to the authenticated user
|
||||
* It checks the given permissions against a given method (controller method name) and a given permission type (R and/or W)
|
||||
|
||||
@@ -35,8 +35,15 @@ class PrestudentLib
|
||||
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
}
|
||||
|
||||
public function setAbbrecher($prestudent_id, $studiensemester_kurzbz, $insertvon = null, $statusgrund_kurzbz = null, $datum = null, $bestaetigtam = null, $bestaetigtvon = null)
|
||||
{
|
||||
public function setAbbrecher(
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$insertvon = null,
|
||||
$statusgrund_id = null,
|
||||
$datum = null,
|
||||
$bestaetigtam = null,
|
||||
$bestaetigtvon = null
|
||||
) {
|
||||
if (!$insertvon)
|
||||
$insertvon = getAuthUID();
|
||||
if (!$bestaetigtvon)
|
||||
@@ -70,8 +77,8 @@ class PrestudentLib
|
||||
if(!$bestaetigtam)
|
||||
$bestaetigtam = date('c');
|
||||
|
||||
//Status und Statusgrund updaten
|
||||
$result = $this->_ci->PrestudentstatusModel->withGrund($statusgrund_kurzbz)->insert([
|
||||
// Status und Statusgrund updaten
|
||||
$result = $this->_ci->PrestudentstatusModel->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_ABBRECHER,
|
||||
'studiensemester_kurzbz' => $prestudent_status->studiensemester_kurzbz,
|
||||
@@ -82,13 +89,13 @@ class PrestudentLib
|
||||
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
|
||||
'studienplan_id'=> $prestudent_status->studienplan_id,
|
||||
'bestaetigtvon' => $bestaetigtvon,
|
||||
'bestaetigtam' => $bestaetigtam
|
||||
'bestaetigtam' => $bestaetigtam,
|
||||
'statusgrund_id' => $statusgrund_id
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
//Verband anlegen
|
||||
$result = $this->_ci->LehrverbandModel->load([
|
||||
'studiengang_kz' => $student->studiengang_kz,
|
||||
@@ -134,7 +141,7 @@ class PrestudentLib
|
||||
]);
|
||||
}
|
||||
|
||||
//noch nicht eingetragene Zeugnisnoten auf 9 setzen
|
||||
// noch nicht eingetragene Zeugnisnoten auf 9 setzen
|
||||
$result = $this->_ci->ZeugnisnoteModel->getZeugnisnoten($student->student_uid, $prestudent_status->studiensemester_kurzbz);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
@@ -166,9 +173,9 @@ class PrestudentLib
|
||||
}
|
||||
|
||||
|
||||
//Update Aktionen
|
||||
// Update Aktionen
|
||||
|
||||
//StudentModel updaten
|
||||
// StudentModel updaten
|
||||
$this->_ci->StudentModel->update([
|
||||
'student_uid' => $student->student_uid
|
||||
], [
|
||||
@@ -192,7 +199,7 @@ class PrestudentLib
|
||||
'updatevon' => $insertvon
|
||||
]);
|
||||
|
||||
//Benutzer inaktiv setzen
|
||||
// Benutzer inaktiv setzen
|
||||
$this->_ci->BenutzerModel->update([
|
||||
'uid' => $student->student_uid
|
||||
], [
|
||||
@@ -206,17 +213,28 @@ class PrestudentLib
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setUnterbrecher($prestudent_id, $studiensemester_kurzbz, $studierendenantrag_id, $insertvon = null)
|
||||
{
|
||||
public function setUnterbrecher(
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$studierendenantrag_id = null,
|
||||
$insertvon = null,
|
||||
$ausbildungssemester = null,
|
||||
$statusgrund_id = null
|
||||
) {
|
||||
$ausbildungssemester_plus = 0;
|
||||
|
||||
if (!$insertvon)
|
||||
$insertvon = getAuthUID();
|
||||
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id, $studiensemester_kurzbz);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
$result = getData($result);
|
||||
if (!$result) {
|
||||
|
||||
if (!$result) { // NOTE(chris): no status in target stdsem
|
||||
//NOTE(manu): only valid if nextSemester focus max
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
@@ -224,7 +242,7 @@ class PrestudentLib
|
||||
return $result;
|
||||
$result = getData($result);
|
||||
|
||||
//check if ausbildungssemester is last
|
||||
// check if ausbildungssemester is last
|
||||
$this->_ci->StudiengangModel->addJoin('public.tbl_prestudent p', 'studiengang_kz');
|
||||
$res = $this->_ci->StudiengangModel->loadWhere(['p.prestudent_id' => $prestudent_id]);
|
||||
if(isError($res))
|
||||
@@ -236,7 +254,7 @@ class PrestudentLib
|
||||
|
||||
$studiengang = current(getData($res));
|
||||
$prestudent_status = current($result);
|
||||
if($prestudent_status->ausbildungssemester + 1 < $studiengang->max_semester)
|
||||
if ($prestudent_status->status_kurzbz != Prestudentstatus_model::STATUS_UNTERBRECHER && $prestudent_status->ausbildungssemester + 1 < $studiengang->max_semester)
|
||||
$ausbildungssemester_plus = 1;
|
||||
|
||||
if(!$result)
|
||||
@@ -246,34 +264,79 @@ class PrestudentLib
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz
|
||||
]));
|
||||
}
|
||||
} elseif (current($result)->status_kurzbz == Prestudentstatus_model::STATUS_UNTERBRECHER) {
|
||||
if ($studierendenantrag_id)
|
||||
{
|
||||
$resultAntrag = $this->_ci->StudierendenantragModel->load($studierendenantrag_id);
|
||||
if (isError($resultAntrag))
|
||||
return $resultAntrag;
|
||||
$resultAntrag = getData($resultAntrag);
|
||||
if (!$resultAntrag)
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_antrag_found', ['id' => $studierendenantrag_id]));
|
||||
|
||||
$antrag = current($resultAntrag);
|
||||
$anmerkung = current($result)->anmerkung . ' Wiedereinstieg ' . $antrag->datum_wiedereinstieg;
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->update([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_UNTERBRECHER,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'ausbildungssemester' => current($result)->ausbildungssemester
|
||||
], [
|
||||
'updatevon' => $insertvon,
|
||||
'updateamum' => date('c'),
|
||||
'anmerkung'=> $anmerkung
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
$prestudent_status = current($result);
|
||||
|
||||
|
||||
$result = $this->_ci->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
$result = getData($result);
|
||||
|
||||
if (!$result)
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_student_for_prestudent', ['prestudent_id' => $prestudent_id]));
|
||||
|
||||
$student = current($result);
|
||||
|
||||
$resultAntrag = $this->_ci->StudierendenantragModel->load($studierendenantrag_id);
|
||||
if (isError($resultAntrag))
|
||||
return $resultAntrag;
|
||||
$resultAntrag = getData($resultAntrag);
|
||||
if (!$resultAntrag)
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_antrag_found', ['id' => $studierendenantrag_id]));
|
||||
|
||||
$antrag = current($resultAntrag);
|
||||
if ($studierendenantrag_id)
|
||||
{
|
||||
$resultAntrag = $this->_ci->StudierendenantragModel->load($studierendenantrag_id);
|
||||
if (isError($resultAntrag))
|
||||
return $resultAntrag;
|
||||
$resultAntrag = getData($resultAntrag);
|
||||
if (!$resultAntrag)
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_antrag_found', ['id' => $studierendenantrag_id]));
|
||||
|
||||
//Status updaten
|
||||
$antrag = current($resultAntrag);
|
||||
$anmerkung = 'Wiedereinstieg ' . $antrag->datum_wiedereinstieg;
|
||||
}
|
||||
else
|
||||
$anmerkung = '';
|
||||
|
||||
if ($ausbildungssemester)
|
||||
$semester = $ausbildungssemester;
|
||||
else
|
||||
$semester = $prestudent_status->ausbildungssemester + $ausbildungssemester_plus;
|
||||
|
||||
// Status updaten
|
||||
$result = $this->_ci->PrestudentstatusModel->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_UNTERBRECHER,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'ausbildungssemester' => $prestudent_status->ausbildungssemester + $ausbildungssemester_plus,
|
||||
'ausbildungssemester' => $semester,
|
||||
'datum' => date('c'),
|
||||
'insertvon' => $insertvon,
|
||||
'insertamum' => date('c'),
|
||||
@@ -281,7 +344,8 @@ class PrestudentLib
|
||||
'studienplan_id'=> $prestudent_status->studienplan_id,
|
||||
'bestaetigtvon' => $insertvon,
|
||||
'bestaetigtam' => date('c'),
|
||||
'anmerkung'=> 'Wiedereinstieg ' . $antrag->datum_wiedereinstieg
|
||||
'anmerkung'=> $anmerkung,
|
||||
'statusgrund_id' => $statusgrund_id
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
@@ -332,7 +396,7 @@ class PrestudentLib
|
||||
]);
|
||||
}
|
||||
|
||||
//noch nicht eingetragene Zeugnisnoten auf 9 setzen
|
||||
// noch nicht eingetragene Zeugnisnoten auf 9 setzen
|
||||
$result = $this->_ci->ZeugnisnoteModel->getZeugnisnoten($student->student_uid, $studiensemester_kurzbz);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
@@ -363,10 +427,9 @@ class PrestudentLib
|
||||
}
|
||||
}
|
||||
|
||||
// Update Aktionen
|
||||
|
||||
//Update Aktionen
|
||||
|
||||
//StudentModel updaten
|
||||
// StudentModel updaten
|
||||
$this->_ci->StudentModel->update([
|
||||
'student_uid' => $student->student_uid
|
||||
], [
|
||||
@@ -409,4 +472,463 @@ class PrestudentLib
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setStudent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
|
||||
{
|
||||
$authUID = getAuthUID();
|
||||
$now = date('c');
|
||||
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_prestudentstatus', [
|
||||
'prestudent_id' => $prestudent_id
|
||||
]));
|
||||
|
||||
$prestudent_status = current(getData($result));
|
||||
|
||||
|
||||
$result = $this->_ci->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_student_for_prestudent', ['prestudent_id' => $prestudent_id]));
|
||||
|
||||
$student = current(getData($result));
|
||||
|
||||
|
||||
$this->_ci->load->library('VariableLib', ['uid' => $authUID]);
|
||||
$semester_aktuell = $this->_ci->variablelib->getVar('semester_aktuell');
|
||||
|
||||
|
||||
// Update Aktionen
|
||||
|
||||
// Status updaten
|
||||
$result = $this->_ci->PrestudentstatusModel->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_STUDENT,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'statusgrund_id' => $statusgrund_id,
|
||||
'ausbildungssemester' => $ausbildungssemester,
|
||||
'datum' => $now,
|
||||
'insertvon' => $authUID,
|
||||
'insertamum' => $now,
|
||||
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
|
||||
'studienplan_id'=> $prestudent_status->studienplan_id,
|
||||
'bestaetigtvon' => $authUID,
|
||||
'bestaetigtam' => $now
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Student updaten
|
||||
$result = $this->_ci->StudentModel->update([
|
||||
'student_uid' => $student->student_uid
|
||||
], [
|
||||
'semester' => $ausbildungssemester,
|
||||
'verband' => '',
|
||||
'gruppe' => '',
|
||||
'updatevon' => $authUID,
|
||||
'updateamum' => $now
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Studentlehrverband updaten
|
||||
$result = $this->_ci->StudentlehrverbandModel->update([
|
||||
'student_uid' => $student->student_uid,
|
||||
'studiensemester_kurzbz' => $semester_aktuell
|
||||
], [
|
||||
'semester' => $ausbildungssemester,
|
||||
'verband' => '',
|
||||
'gruppe' => '',
|
||||
'updatevon' => $authUID,
|
||||
'updateamum' => $now
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Benutzer updaten
|
||||
$result = $this->_ci->BenutzerModel->load([$student->student_uid]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error($this->_ci->p->t('person', 'error_noBenutzer'));
|
||||
|
||||
$benutzer = current(getData($result));
|
||||
$updateData = [
|
||||
'aktiv' => true,
|
||||
'updateamum' => $now,
|
||||
'updatevon' => $authUID
|
||||
];
|
||||
if (!$benutzer->aktiv) {
|
||||
$updateData['updateaktivam'] = $now;
|
||||
$updateData['updateaktivvon'] = $authUID;
|
||||
}
|
||||
|
||||
|
||||
$this->_ci->BenutzerModel->update([$student->student_uid], $updateData);
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setFirstStudent(
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$ausbildungssemester,
|
||||
$orgform_kurzbz,
|
||||
$studienplan_id,
|
||||
$statusgrund_id
|
||||
) {
|
||||
$this->_ci->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
|
||||
$this->_ci->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz');
|
||||
$result = $this->_ci->PrestudentModel->load($prestudent_id);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
if (!hasData($result))
|
||||
return error('No prestudent');
|
||||
|
||||
$student_data = current(getData($result));
|
||||
|
||||
|
||||
$authUID = getAuthUID();
|
||||
$now = date('c');
|
||||
$today = date('Y-m-d');
|
||||
|
||||
$jahr = mb_substr($studiensemester_kurzbz, 4, 2);
|
||||
|
||||
|
||||
// Genererate Personenkennzeichen
|
||||
$personenkennzeichen = $this->_ci->StudentModel->generateMatrikelnummer2(
|
||||
$student_data->studiengang_kz,
|
||||
$studiensemester_kurzbz,
|
||||
$student_data->typ
|
||||
);
|
||||
if (isError($personenkennzeichen))
|
||||
return $personenkennzeichen;
|
||||
$personenkennzeichen = getData($personenkennzeichen);
|
||||
|
||||
|
||||
// Generate UID
|
||||
$uid = $this->_ci->StudentModel->generateUID(
|
||||
$student_data->kurzbz,
|
||||
$jahr,
|
||||
$student_data->typ,
|
||||
$personenkennzeichen,
|
||||
$student_data->vorname,
|
||||
$student_data->nachname
|
||||
);
|
||||
if (isError($uid))
|
||||
return $uid;
|
||||
$uid = getData($uid);
|
||||
|
||||
|
||||
// Generate Matrikelnummer
|
||||
$matrikelnummer = $this->_ci->BenutzerModel->generateMatrikelnummer(
|
||||
$student_data->oe_kurzbz
|
||||
);
|
||||
if (isError($matrikelnummer))
|
||||
return $matrikelnummer;
|
||||
$matrikelnummer = getData($matrikelnummer);
|
||||
|
||||
|
||||
// Generate Alias
|
||||
$alias = '';
|
||||
if (!defined('GENERATE_ALIAS_STUDENT')
|
||||
|| GENERATE_ALIAS_STUDENT === true
|
||||
) {
|
||||
$result = $this->_ci->BenutzerModel->generateAliasFromName($student_data->vorname, $student_data->nachname);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$alias = getData($result);
|
||||
}
|
||||
|
||||
// Generate Activation Key
|
||||
$activationkey = $this->_ci->BenutzerModel->generateActivationkey();
|
||||
|
||||
|
||||
// Overwrite stuff
|
||||
if (defined('SET_UID_AS_MATRIKELNUMMER')
|
||||
&& SET_UID_AS_MATRIKELNUMMER)
|
||||
$matrikelnummer = $uid;
|
||||
if (defined('SET_UID_AS_PERSONENKENNZEICHEN')
|
||||
&& SET_UID_AS_PERSONENKENNZEICHEN)
|
||||
$personenkennzeichen = $uid;
|
||||
|
||||
|
||||
// Update Person
|
||||
$this->_ci->load->model('person/Person_model', 'PersonModel');
|
||||
$result = $this->_ci->PersonModel->update([
|
||||
'person_id' => $student_data->person_id,
|
||||
'matr_nr' => null
|
||||
], [
|
||||
'matr_nr' => $matrikelnummer
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Add Benutzer
|
||||
$result = $this->_ci->BenutzerModel->insert([
|
||||
'uid' => $uid,
|
||||
'person_id' => $student_data->person_id,
|
||||
'aktiv' => true,
|
||||
'aktivierungscode' => $activationkey,
|
||||
'alias' => $alias,
|
||||
'insertvon' => $authUID,
|
||||
'insertamum' => $now,
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Add Student
|
||||
$result = $this->_ci->StudentModel->insert([
|
||||
'student_uid' => $uid,
|
||||
'matrikelnr' => $personenkennzeichen,
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'studiengang_kz' => $student_data->studiengang_kz,
|
||||
'semester' => $ausbildungssemester,
|
||||
'verband' => ' ',
|
||||
'gruppe' => ' ',
|
||||
'insertvon' => $authUID,
|
||||
'insertamum' => $now
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Add Lehrverband if it does not exist
|
||||
$result = $this->_ci->LehrverbandModel->load([' ', ' ', $ausbildungssemester, $student_data->studiengang_kz]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
if (!hasData($result)) {
|
||||
$result = $this->_ci->LehrverbandModel->insert([
|
||||
'studiengang_kz' => $student_data->studiengang_kz,
|
||||
'semester' => $ausbildungssemester,
|
||||
'verband' => ' ',
|
||||
'gruppe' => ' ',
|
||||
'aktiv' => true
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
// Add Rolle
|
||||
$result = $this->_ci->PrestudentstatusModel->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_STUDENT,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'ausbildungssemester' => $ausbildungssemester,
|
||||
'orgform_kurzbz'=> $orgform_kurzbz,
|
||||
'studienplan_id'=> $studienplan_id,
|
||||
'datum' => $today,
|
||||
'insertamum' => $now,
|
||||
'insertvon' => $authUID,
|
||||
'bestaetigtam' => $today,
|
||||
'bestaetigtvon' => $authUID,
|
||||
'statusgrund_id' => $statusgrund_id
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Add Studentlehrverband
|
||||
$result = $this->_ci->StudentlehrverbandModel->insert([
|
||||
'student_uid' => $uid,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'studiengang_kz' => $student_data->studiengang_kz,
|
||||
'semester' => $ausbildungssemester,
|
||||
'verband' => ' ',
|
||||
'gruppe' => ' ',
|
||||
'insertamum' => $now,
|
||||
'insertvon' => $authUID
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setDiplomand($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
|
||||
{
|
||||
return $this->setBasic(
|
||||
getAuthUID(),
|
||||
date('c'),
|
||||
Prestudentstatus_model::STATUS_DIPLOMAND,
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$ausbildungssemester,
|
||||
$statusgrund_id
|
||||
);
|
||||
}
|
||||
|
||||
public function setAbsolvent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
|
||||
{
|
||||
$authUID = getAuthUID();
|
||||
$now = date('c');
|
||||
|
||||
|
||||
$result = $this->setBasic(
|
||||
$authUID,
|
||||
$now,
|
||||
Prestudentstatus_model::STATUS_ABSOLVENT,
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$ausbildungssemester,
|
||||
$statusgrund_id
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Load Student
|
||||
$result = $this->_ci->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_student_for_prestudent', ['prestudent_id' => $prestudent_id]));
|
||||
|
||||
$student = current(getData($result));
|
||||
|
||||
|
||||
// Benutzer inaktiv setzen
|
||||
$this->_ci->BenutzerModel->update([
|
||||
'uid' => $student->student_uid
|
||||
], [
|
||||
'aktiv' => false,
|
||||
'updateaktivvon' => $authUID,
|
||||
'updateaktivam' => $now,
|
||||
'updatevon' => $authUID,
|
||||
'updateamum' => $now
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setBewerber($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
|
||||
{
|
||||
$result = $this->setBasic(
|
||||
getAuthUID(),
|
||||
date('c'),
|
||||
Prestudentstatus_model::STATUS_BEWERBER,
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$ausbildungssemester,
|
||||
$statusgrund_id
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
if (SEND_BEWERBER_INFOMAIL) {
|
||||
// TODO(chris): IMPLEMENT!
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setAufgenommener($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
|
||||
{
|
||||
return $this->setBasic(
|
||||
getAuthUID(),
|
||||
date('c'),
|
||||
Prestudentstatus_model::STATUS_AUFGENOMMENER,
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$ausbildungssemester,
|
||||
$statusgrund_id
|
||||
);
|
||||
}
|
||||
|
||||
public function setAbgewiesener($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
|
||||
{
|
||||
return $this->setBasic(
|
||||
getAuthUID(),
|
||||
date('c'),
|
||||
Prestudentstatus_model::STATUS_ABGEWIESENER,
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$ausbildungssemester,
|
||||
$statusgrund_id
|
||||
);
|
||||
}
|
||||
|
||||
public function setWartender($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
|
||||
{
|
||||
return $this->setBasic(
|
||||
getAuthUID(),
|
||||
date('c'),
|
||||
Prestudentstatus_model::STATUS_WARTENDER,
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$ausbildungssemester,
|
||||
$statusgrund_id
|
||||
);
|
||||
}
|
||||
|
||||
protected function setBasic($authUID, $now, $status_kurzbz, $prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id = null)
|
||||
{
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_prestudentstatus', [
|
||||
'prestudent_id' => $prestudent_id
|
||||
]));
|
||||
|
||||
$prestudent_status = current(getData($result));
|
||||
|
||||
|
||||
// Update Aktionen
|
||||
|
||||
// Status updaten
|
||||
$result = $this->_ci->PrestudentstatusModel->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => $status_kurzbz,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'ausbildungssemester' => $ausbildungssemester,
|
||||
'datum' => $now,
|
||||
'insertvon' => $authUID,
|
||||
'insertamum' => $now,
|
||||
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
|
||||
'studienplan_id'=> $prestudent_status->studienplan_id,
|
||||
'bestaetigtvon' => $authUID,
|
||||
'bestaetigtam' => $now,
|
||||
'statusgrund_id' => $statusgrund_id
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,922 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class PrestudentstatusCheckLib
|
||||
{
|
||||
const INTERESSENT_STATUS = 'Interessent';
|
||||
const BEWERBER_STATUS = 'Bewerber';
|
||||
const AUFGENOMMENER_STATUS = 'Aufgenommener';
|
||||
const UNTERBRECHER_STATUS = 'Unterbrecher';
|
||||
const STUDENT_STATUS = 'Student';
|
||||
const DIPLOMAND_STATUS = 'Diplomand';
|
||||
const ABSOLVENT_STATUS = 'Absolvent';
|
||||
const ABBRECHER_STATUS = 'Abbrecher';
|
||||
|
||||
private $_ci;
|
||||
private $_statusAbfolgeVorStudent = [self::INTERESSENT_STATUS, self::BEWERBER_STATUS, self::AUFGENOMMENER_STATUS];
|
||||
private $_endStatusArr = [self::ABSOLVENT_STATUS, self::ABBRECHER_STATUS];
|
||||
|
||||
private $_cache_history = [];
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
$this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
$this->_ci->load->model('person/Person_model', 'PersonModel');
|
||||
$this->_ci->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
|
||||
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$this->_ci->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->_ci->load->model('organisation/Studienplan_model', 'StudienplanModel');
|
||||
$this->_ci->load->model('codex/Bismeldestichtag_model', 'BismeldestichtagModel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a status add is valid.
|
||||
* @return object error if invalid
|
||||
*/
|
||||
public function checkStatusAdd(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_status_studiensemester_kurzbz,
|
||||
$new_status_datum,
|
||||
$new_status_ausbildungssemester,
|
||||
$new_studienplan_id
|
||||
) {
|
||||
$studentName = '';
|
||||
|
||||
$nameRes = $this->_ci->PersonModel->loadPrestudent($prestudent_id);
|
||||
|
||||
if (hasData($nameRes))
|
||||
{
|
||||
$nameData = getData($nameRes)[0];
|
||||
$studentName = $nameData->vorname.' '.$nameData->nachname;
|
||||
}
|
||||
|
||||
// Datum des neuen Status darf nicht in Vergangenheit liegen, sonst Probleme wenn neues Datum < Bismeldedatum
|
||||
if (new DateTime($new_status_datum) < new DateTime('today'))
|
||||
return error($studentName . $this->_ci->p->t('lehre', 'error_entryInPast'));
|
||||
|
||||
return $this->_checkIfValidStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_status_studiensemester_kurzbz,
|
||||
$new_status_datum,
|
||||
$new_status_ausbildungssemester,
|
||||
$new_studienplan_id
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a status update is valid.
|
||||
* @return error if invalid
|
||||
*/
|
||||
public function checkStatusUpdate(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_status_studiensemester_kurzbz,
|
||||
$new_status_datum,
|
||||
$new_status_ausbildungssemester,
|
||||
$new_studienplan_id,
|
||||
$old_status_studiensemester,
|
||||
$old_status_ausbildungssemester
|
||||
) {
|
||||
|
||||
return $this->_checkIfValidStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_status_studiensemester_kurzbz,
|
||||
$new_status_datum,
|
||||
$new_status_ausbildungssemester,
|
||||
$new_studienplan_id,
|
||||
$old_status_studiensemester,
|
||||
$old_status_ausbildungssemester
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a student already exists.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfExistingStudent($prestudent_id)
|
||||
{
|
||||
$result = $this->_ci->StudentModel->loadWhere([
|
||||
'prestudent_id' => $prestudent_id
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(hasData($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Reihungstest was admitted
|
||||
*
|
||||
* @param stdClass $prestudent
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfAngetreten($prestudent)
|
||||
{
|
||||
return success($prestudent->reihungstestangetreten);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if ZGV-Code is registered
|
||||
*
|
||||
* @param stdClass $prestudent
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfZGVEingetragen($prestudent_person)
|
||||
{
|
||||
return success((boolean)$prestudent_person->zgv_code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Master ZGV-Code is registered
|
||||
*
|
||||
* @param stdClass $prestudent
|
||||
*
|
||||
* @return booleans $zgv_code, error if not registered
|
||||
*/
|
||||
public function checkIfZGVEingetragenMaster($prestudent)
|
||||
{
|
||||
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$result = $this->_ci->StudiengangModel->load($prestudent->studiengang_kz);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_stg', ['studiengang_kz' => $prestudent->studiengang_kz]));
|
||||
|
||||
if (current($result->retval)->typ != 'm')
|
||||
return success(true); // NOTE(chris): we only test master stgs, all other stgs should default to true
|
||||
|
||||
return success((boolean)$prestudent->zgvmas_code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a bewerber status already exists.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfExistingBewerberstatus($prestudent_id)
|
||||
{
|
||||
$result = $this->_ci->PrestudentstatusModel->loadWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_BEWERBER
|
||||
]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(hasData($result));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if status aufgenommen already exists.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfExistingAufgenommenerstatus($prestudent_id)
|
||||
{
|
||||
$result = $this->_ci->PrestudentstatusModel->loadWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_AUFGENOMMENER
|
||||
]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(hasData($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the last Bewerber status and the last Aufgenommener status
|
||||
* have the same studiensemester and ausbildungssemester.
|
||||
*
|
||||
* Attention:
|
||||
* If one of those two status is missing the function returns true!
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfLastBewerberAndAufgenommenerShareSemesters($prestudent_id)
|
||||
{
|
||||
$this->_ci->PrestudentstatusModel->addOrder('datum', 'DESC');
|
||||
$this->_ci->PrestudentstatusModel->addOrder('insertamum', 'DESC');
|
||||
$this->_ci->PrestudentstatusModel->addLimit(1);
|
||||
$result = $this->_ci->PrestudentstatusModel->loadWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_BEWERBER
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return success(true);
|
||||
|
||||
$bewerber = current(getData($result));
|
||||
|
||||
$this->_ci->PrestudentstatusModel->addOrder('datum', 'DESC');
|
||||
$this->_ci->PrestudentstatusModel->addOrder('insertamum', 'DESC');
|
||||
$this->_ci->PrestudentstatusModel->addLimit(1);
|
||||
$result = $this->_ci->PrestudentstatusModel->loadWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_AUFGENOMMENER
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return success(true);
|
||||
|
||||
$aufgenommener = current(getData($result));
|
||||
|
||||
return success(
|
||||
$bewerber->studiensemester_kurzbz == $aufgenommener->studiensemester_kurzbz
|
||||
&& $bewerber->ausbildungssemester == $aufgenommener->ausbildungssemester
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Bismeldestichtag erreicht
|
||||
*
|
||||
* @param DateTime $statusDatum
|
||||
* @param string $studiensemester_kurzbz
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfMeldestichtagErreicht($statusDatum, $studiensemester_kurzbz = null)
|
||||
{
|
||||
$result = $this->_ci->BismeldestichtagModel->checkIfMeldestichtagErreicht($statusDatum, $studiensemester_kurzbz);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(getData($result) == "1");
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs all checks on Status History and saves it in cache.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
protected function prepareStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
// Generate key for caching
|
||||
$primary = implode('|', [
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date->format('Y-m-d'),
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
]);
|
||||
|
||||
if (isset($this->_cache_history[$primary]))
|
||||
return $this->_cache_history[$primary];
|
||||
|
||||
$this->_ci->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
|
||||
|
||||
// Get the history
|
||||
$result = $this->_ci->PrestudentstatusModel->getHistoryWithNewOrEditedState(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
if (!hasData($result))
|
||||
return error('This is impossible');
|
||||
|
||||
$history = getData($result);
|
||||
$historyCount = count($history);
|
||||
|
||||
// Run checks
|
||||
$checks = [
|
||||
'timesequence' => true,
|
||||
'laststatus' => true,
|
||||
'unterbrechersemester' => true,
|
||||
'abbrechersemester' => true,
|
||||
'diplomant' => true,
|
||||
'student' => true
|
||||
];
|
||||
|
||||
for ($n = 0, $c = 1; $c < $historyCount; $n++, $c++) {
|
||||
if (!$checks['timesequence']
|
||||
&& !$checks['laststatus']
|
||||
&& !$checks['unterbrechersemester']
|
||||
&& !$checks['abbrechersemester']
|
||||
&& !$checks['diplomant']
|
||||
&& !$checks['student']
|
||||
)
|
||||
break; // early out
|
||||
|
||||
$next = $history[$n];
|
||||
$current = $history[$c];
|
||||
|
||||
// Zeitabfolge ungültig?
|
||||
if ($checks['timesequence']
|
||||
&& $next->start < $current->start
|
||||
)
|
||||
$checks['timesequence'] = false;
|
||||
|
||||
// Abbrecher- oder Absolventenstatus muss Endstatus sein
|
||||
if ($checks['laststatus']
|
||||
&& in_array($current->status_kurzbz, [self::ABSOLVENT_STATUS, self::ABBRECHER_STATUS])
|
||||
)
|
||||
$checks['laststatus'] = false;
|
||||
|
||||
// wenn Unterbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein
|
||||
if ($checks['unterbrechersemester']
|
||||
&& $current->status_kurzbz == self::UNTERBRECHER_STATUS
|
||||
&& $next->status_kurzbz == self::UNTERBRECHER_STATUS
|
||||
&& $current->ausbildungssemester != $next->ausbildungssemester
|
||||
)
|
||||
$checks['unterbrechersemester'] = false;
|
||||
|
||||
// wenn Abbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein
|
||||
if ($checks['abbrechersemester']
|
||||
&& $current->status_kurzbz == self::UNTERBRECHER_STATUS
|
||||
&& $next->status_kurzbz == self::ABBRECHER_STATUS
|
||||
&& $current->ausbildungssemester != $next->ausbildungssemester
|
||||
)
|
||||
$checks['abbrechersemester'] = false;
|
||||
|
||||
if (($checks['diplomant']
|
||||
|| $checks['student'])
|
||||
&& $next->status_kurzbz == self::STUDENT_STATUS
|
||||
) {
|
||||
$restl_stati = array_unique(array_column(array_slice($history, $c), 'status_kurzbz'));
|
||||
|
||||
// keine Studenten nach Diplomand Status
|
||||
if ($checks['diplomant']
|
||||
&& in_array(self::DIPLOMAND_STATUS, $restl_stati)
|
||||
)
|
||||
$checks['diplomant'] = false;
|
||||
|
||||
// vor Studentenstatus müssen bestimmte Status vorhanden sein
|
||||
if ($checks['student']
|
||||
&& array_values(array_intersect($restl_stati, $this->_statusAbfolgeVorStudent)) != array_values($this->_statusAbfolgeVorStudent)
|
||||
)
|
||||
$checks['student'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_cache_history[$primary] = success($checks);
|
||||
|
||||
return success($checks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the time sequence of the status history is valid.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkStatusHistoryTimesequence(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
$result = $this->prepareStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(getData($result)['timesequence']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the last status of the status history is not Abbrecher or
|
||||
* Absolvent.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkStatusHistoryLaststatus(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
$result = $this->prepareStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(getData($result)['laststatus']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if two consecutively Unterbrecher have the same
|
||||
* ausbildungssemester in the status history.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkStatusHistoryUnterbrechersemester(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
$result = $this->prepareStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(getData($result)['unterbrechersemester']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an Unterbrecher followed by an Abbrecher have the same
|
||||
* ausbildungssemester in the status history.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkStatusHistoryAbbrechersemester(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
$result = $this->prepareStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(getData($result)['abbrechersemester']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if no Diplomant is followed by a Student in the status history.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkStatusHistoryDiplomant(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
$result = $this->prepareStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(getData($result)['diplomant']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a Student precedes given stati in the status history.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkStatusHistoryStudent(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
// TODO(chris): TEST
|
||||
$result = $this->prepareStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(getData($result)['student']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if Personenkennzeichen is set correctly.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkPersonenkennzeichen($prestudent_id)
|
||||
{
|
||||
// TODO(chris): TEST
|
||||
$this->_ci->PrestudentstatusModel->addSelect('tbl_prestudentstatus.prestudent_id');
|
||||
$this->_ci->PrestudentstatusModel->addSelect('tbl_student.matrikelnr');
|
||||
|
||||
$this->_ci->PrestudentstatusModel->addJoin('public.tbl_student', 'prestudent_id');
|
||||
|
||||
$this->_ci->PrestudentstatusModel->addOrder('tbl_prestudentstatus.datum', 'DESC');
|
||||
$this->_ci->PrestudentstatusModel->addOrder('tbl_prestudentstatus.insertamum', 'DESC');
|
||||
$this->_ci->PrestudentstatusModel->addOrder('tbl_prestudentstatus.ext_id', 'DESC');
|
||||
|
||||
$this->_ci->PrestudentstatusModel->addLimit(1);
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->loadWhere([
|
||||
'tbl_prestudentstatus.prestudent_id' => $prestudent_id,
|
||||
'tbl_prestudentstatus.status_kurzbz' => self::STATUS_STUDENT
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
if (!hasData($result))
|
||||
return success(true); // Not a student yet so no wrong personenkennzeichen
|
||||
|
||||
$data = current(getData($result));
|
||||
|
||||
$jahr = $this->_ci->StudiensemesterModel->getStudienjahrNumberFromStudiensemester($data->studiensemester_kurzbz);
|
||||
|
||||
|
||||
return success($jahr == mb_substr($data->matrikelnr, 0, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if Orgform of Student status and Bewerber status match.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkStudentOrgform($prestudent_id)
|
||||
{
|
||||
// TODO(chris): TEST
|
||||
$result = $this->_ci->PrestudentstatusModel->getBewerberWhereOrgformNotStudent($prestudent_id);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(!hasData($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if History of StatusData is valid
|
||||
* @param integer $prestudent_id
|
||||
* @return error if not valid, array StatusArr if valid
|
||||
*/
|
||||
private function _checkIfValidStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_status_studiensemester_kurzbz,
|
||||
$new_status_datum,
|
||||
$new_status_ausbildungssemester,
|
||||
$new_studienplan_id,
|
||||
$old_status_studiensemester = null,
|
||||
$old_status_ausbildungssemester = null
|
||||
) {
|
||||
//get start studiensemester
|
||||
$semResult = $this->_ci->StudiensemesterModel->load([
|
||||
'studiensemester_kurzbz' => $new_status_studiensemester_kurzbz
|
||||
]);
|
||||
|
||||
if (isError($semResult))
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson(getError($semResult));
|
||||
}
|
||||
|
||||
if (!hasData($semResult)) {
|
||||
return error($this->_ci->p->t('lehre', 'error_noStudiensemester') . $new_status_studiensemester_kurzbz);
|
||||
}
|
||||
|
||||
$studiensemester = getData($semResult)[0];
|
||||
$new_status_semesterstart = $studiensemester->start;
|
||||
|
||||
// get studienplan orgform
|
||||
$new_studienplan_orgform_kurzbz = '';
|
||||
$this->_ci->StudienplanModel->addSelect('orgform_kurzbz');
|
||||
$stplResult = $this->_ci->StudienplanModel->load([
|
||||
'studienplan_id' => $new_studienplan_id
|
||||
]);
|
||||
|
||||
if (isError($stplResult))
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson(getError($stplResult));
|
||||
}
|
||||
|
||||
if (hasData($stplResult)) $new_studienplan_orgform_kurzbz = getData($stplResult)[0]->orgform_kurzbz;
|
||||
|
||||
|
||||
//get all prestudentstati
|
||||
$resultPs = $this->_ci->PrestudentstatusModel->getAllPrestudentstatiWithStudiensemester($prestudent_id);
|
||||
|
||||
if (isError($resultPs)) return $resultPs;
|
||||
|
||||
$resultArr = hasData($resultPs) ? getData($resultPs) : [];
|
||||
$statusArr = [];
|
||||
|
||||
$newStatusInserted = false;
|
||||
$new_status_datum_form = new DateTime($new_status_datum);
|
||||
$new_status_semesterstart_form = new DateTime($new_status_semesterstart);
|
||||
|
||||
if (!isEmptyArray($resultArr))
|
||||
{
|
||||
// neuen Status zum Hinzufügen
|
||||
$first_status = $resultArr[0];
|
||||
$neuer_status = new stdClass();
|
||||
$neuer_status->status_kurzbz = $status_kurzbz;
|
||||
$neuer_status->studiensemester_kurzbz = $new_status_studiensemester_kurzbz;
|
||||
$neuer_status->datum = $new_status_datum;
|
||||
$neuer_status->ausbildungssemester = $new_status_ausbildungssemester;
|
||||
$neuer_status->studienplan_orgform_kurzbz = $new_studienplan_orgform_kurzbz;
|
||||
$neuer_status->matrikelnr = $first_status->matrikelnr;
|
||||
$neuer_status->vorname = $first_status->vorname;
|
||||
$neuer_status->nachname = $first_status->nachname;
|
||||
|
||||
// Status, welcher gerade geändert wird, holen
|
||||
$status_to_change = array_filter(
|
||||
$resultArr,
|
||||
function ($status) use ($status_kurzbz, $old_status_studiensemester, $old_status_ausbildungssemester) {
|
||||
return
|
||||
$status->status_kurzbz == $status_kurzbz
|
||||
&& $status->studiensemester_kurzbz == $old_status_studiensemester
|
||||
&& $status->ausbildungssemester == $old_status_ausbildungssemester;
|
||||
}
|
||||
);
|
||||
|
||||
if (!isEmptyArray($status_to_change))
|
||||
{
|
||||
$status_to_change_index = key($status_to_change);
|
||||
|
||||
// wenn sich Studiensemester und Ausbildungssemester nicht geändert haben...
|
||||
if ($new_status_studiensemester_kurzbz == $old_status_studiensemester
|
||||
&& $new_status_ausbildungssemester == $old_status_ausbildungssemester)
|
||||
{
|
||||
// ...neuen status an selber stelle einfügen wie zu ändernder Status
|
||||
$resultArr[$status_to_change_index] = (object)array_merge((array)$resultArr[$status_to_change_index], (array)$neuer_status);
|
||||
$newStatusInserted = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// bei Status mit neuem Semester: alten Status entfernen
|
||||
unset($resultArr[$status_to_change_index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($resultArr as $row)
|
||||
{
|
||||
$studiensemester_start = new DateTime($row->studiensemester_start);
|
||||
$status_datum = new DateTime($row->datum);
|
||||
|
||||
if ($new_status_datum_form >= $status_datum && $new_status_semesterstart_form >= $studiensemester_start)
|
||||
{
|
||||
if (!$newStatusInserted)
|
||||
{
|
||||
// neuer Status erstmals größer als Datum eines bestehenden Status -> neuen Status EINMALIG einfügen für spätere Statusprüfung
|
||||
$statusArr[] = $neuer_status;
|
||||
$newStatusInserted = true;
|
||||
}
|
||||
$statusArr[] = $row;
|
||||
}
|
||||
elseif ($new_status_datum_form <= $status_datum && $new_status_semesterstart_form <= $studiensemester_start)
|
||||
{
|
||||
$statusArr[] = $row;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Zeitabfolge ungültig, Fehler
|
||||
return error($this->_ci->p->t('lehre', 'error_statuseintrag_zeitabfolge'));
|
||||
}
|
||||
}
|
||||
|
||||
// erster Studentstatus
|
||||
$ersterStudent = null;
|
||||
|
||||
// Über alle gespeicherten Status gehen und Statusabfolge prüfen
|
||||
for ($i = 0; $i < count($statusArr); $i++)
|
||||
{
|
||||
$curr_status = $statusArr[$i];
|
||||
$curr_status_kurzbz = $curr_status->status_kurzbz;
|
||||
$curr_status_ausbildungssemester = $curr_status->ausbildungssemester;
|
||||
$next_idx = $i - 1; //absteigend sortiert, nächster Status ist vorheriger Eintrag
|
||||
$next_status = isset($statusArr[$next_idx]) ? $statusArr[$next_idx] : null;
|
||||
|
||||
$studentName = $curr_status->vorname . ' ' . $curr_status->nachname;
|
||||
|
||||
if ($curr_status_kurzbz == self::STUDENT_STATUS) $ersterStudent = $curr_status;
|
||||
|
||||
// Abbrecher- oder Absolventenstatus muss Endstatus sein
|
||||
if (isset($next_status) && in_array($curr_status_kurzbz, $this->_endStatusArr))
|
||||
{
|
||||
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_endstatus'));
|
||||
}
|
||||
|
||||
// wenn Unterbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein
|
||||
if
|
||||
($curr_status_kurzbz == self::UNTERBRECHER_STATUS && isset($next_status) && $next_status->status_kurzbz == self::UNTERBRECHER_STATUS
|
||||
&& $curr_status_ausbildungssemester != $next_status->ausbildungssemester)
|
||||
{
|
||||
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_consecutiveUnterbrecher'));
|
||||
}
|
||||
|
||||
// wenn Abbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein
|
||||
if (isset($next_status)
|
||||
&& $curr_status_kurzbz == self::UNTERBRECHER_STATUS
|
||||
&& $next_status->status_kurzbz == self::ABBRECHER_STATUS && $curr_status_ausbildungssemester != $next_status->ausbildungssemester)
|
||||
{
|
||||
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_consecutiveUnterbrecherAbbrecher'));
|
||||
}
|
||||
|
||||
if (isset($next_status) && $next_status->status_kurzbz == self::STUDENT_STATUS)
|
||||
{
|
||||
$restliche_status_obj = array_slice($statusArr, $i);
|
||||
$restliche_status = array_unique(array_column($restliche_status_obj, 'status_kurzbz'));
|
||||
$status_intersected = array_intersect($restliche_status, $this->_statusAbfolgeVorStudent);
|
||||
|
||||
// Vor Studentstatus darf kein Diplomand Status vorhanden sein
|
||||
if (in_array(self::DIPLOMAND_STATUS, $restliche_status))
|
||||
{
|
||||
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_consecutiveDiplomandStudent'));
|
||||
}
|
||||
|
||||
// Vor Studentstatus müssen bestimmte Status vorhanden sein
|
||||
if (array_values($status_intersected) != array_values(array_reverse($this->_statusAbfolgeVorStudent)))
|
||||
{
|
||||
return error(
|
||||
$studentName . ' '
|
||||
. $this->_ci->p->t('lehre', 'error_wrongStatusOrderBeforeStudent', array(implode(', ', $this->_statusAbfolgeVorStudent)))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($ersterStudent))
|
||||
{
|
||||
$studentName = $ersterStudent->vorname . ' ' . $ersterStudent->nachname;
|
||||
|
||||
// wenn erster Studentstatus, checken ob Personenkennzeichen passt
|
||||
$studienjahrNumber = $this->_ci->StudiensemesterModel->getStudienjahrNumberFromStudiensemester($ersterStudent->studiensemester_kurzbz);
|
||||
|
||||
if ($studienjahrNumber != mb_substr($ersterStudent->matrikelnr, 0, 2))
|
||||
{
|
||||
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_personenkennzeichenPasstNichtZuStudiensemester'));
|
||||
}
|
||||
|
||||
// wenn erster Studentstatus, checken ob Orgform des Bewerbers mit Studenten übereinstimmt
|
||||
if (!isEmptyArray(
|
||||
array_filter(
|
||||
$restliche_status_obj,
|
||||
function ($s) use ($ersterStudent) {
|
||||
return
|
||||
$s->status_kurzbz == self::BEWERBER_STATUS
|
||||
&& (
|
||||
$s->studienplan_orgform_kurzbz != $ersterStudent->studienplan_orgform_kurzbz
|
||||
);
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_bewerberOrgformUngleichStudentOrgform'));
|
||||
}
|
||||
}
|
||||
|
||||
return $resultPs;
|
||||
}
|
||||
}
|
||||
@@ -358,6 +358,35 @@ EOSC;
|
||||
*/
|
||||
private function _student($searchstr, $type)
|
||||
{
|
||||
$dbModel = new DB_Model();
|
||||
|
||||
$students = $dbModel->execReadOnlyQuery('
|
||||
SELECT
|
||||
\''.$type.'\' AS type,
|
||||
s.student_uid AS uid,
|
||||
s.matrikelnr,
|
||||
p.person_id AS person_id,
|
||||
p.vorname || \' \' || p.nachname AS name,
|
||||
k.kontakt as email ,
|
||||
p.foto
|
||||
FROM public.tbl_student s
|
||||
JOIN public.tbl_benutzer b ON(b.uid = s.student_uid)
|
||||
JOIN public.tbl_person p USING(person_id)
|
||||
LEFT JOIN (
|
||||
SELECT kontakt, person_id
|
||||
FROM public.tbl_kontakt
|
||||
WHERE kontakttyp = \'email\'
|
||||
) as k USING(person_id)
|
||||
WHERE b.uid ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR p.vorname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR p.nachname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
GROUP BY type, s.student_uid, s.matrikelnr, p.person_id, name, email, p.foto
|
||||
');
|
||||
|
||||
// If something has been found then return it
|
||||
if (hasData($students)) return getData($students);
|
||||
|
||||
// Otherwise return an empty array
|
||||
return array();
|
||||
}
|
||||
|
||||
@@ -366,6 +395,41 @@ EOSC;
|
||||
*/
|
||||
private function _prestudent($searchstr, $type)
|
||||
{
|
||||
$dbModel = new DB_Model();
|
||||
|
||||
$prestudent = $dbModel->execReadOnlyQuery('
|
||||
SELECT
|
||||
\''.$type.'\' AS type,
|
||||
ps.prestudent_id,
|
||||
ps.studiengang_kz,
|
||||
p.person_id AS person_id,
|
||||
b.uid,
|
||||
p.vorname || \' \' || p.nachname AS name,
|
||||
(
|
||||
SELECT kontakt
|
||||
FROM public.tbl_kontakt
|
||||
WHERE kontakttyp = \'email\'
|
||||
AND person_id = p.person_id
|
||||
LIMIT 1
|
||||
) as email,
|
||||
p.foto,
|
||||
sg.bezeichnung
|
||||
FROM public.tbl_prestudent ps
|
||||
LEFT JOIN public.tbl_student s USING (prestudent_id)
|
||||
LEFT JOIN public.tbl_benutzer b ON (b.uid = s.student_uid)
|
||||
JOIN public.tbl_person p ON (p.person_id = ps.person_id)
|
||||
LEFT JOIN public.tbl_studiengang sg ON (sg.studiengang_kz = ps.studiengang_kz)
|
||||
WHERE b.uid ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR p.vorname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR p.nachname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
or cast(ps.prestudent_id as text) ILIKE \'%'.$dbModel->escapeLIKE($searchstr).'%\'
|
||||
GROUP BY type, b.uid, ps.prestudent_id, ps.studiengang_kz, sg.bezeichnung, s.student_uid, s.matrikelnr, p.person_id, name, email, p.foto
|
||||
');
|
||||
|
||||
// If something has been found then return it
|
||||
if (hasData($prestudent)) return getData($prestudent);
|
||||
|
||||
// Otherwise return an empty array
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,8 @@ class UDFLib
|
||||
|
||||
private $_udfUniqueId; // Property that contains the UDF widget unique id
|
||||
|
||||
private $_definition_cache = [];
|
||||
|
||||
/**
|
||||
* Gets CI instance
|
||||
*/
|
||||
@@ -157,7 +159,7 @@ class UDFLib
|
||||
$found = false; // used to check if the field is found or not in the json schema
|
||||
|
||||
$this->_sortJsonSchemas($jsonSchemasArray); // Sort the list of UDF by sort property
|
||||
|
||||
|
||||
// Loops through json schemas
|
||||
foreach ($jsonSchemasArray as $jsonSchema)
|
||||
{
|
||||
@@ -292,7 +294,7 @@ class UDFLib
|
||||
// Checks if the requiredPermissions is available and it is a valid array or a valid string
|
||||
if (isset($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
|
||||
&& (!isEmptyArray($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
|
||||
|| !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})))
|
||||
|| !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})))
|
||||
{
|
||||
// Then check if the user has the permissions to read such UDF
|
||||
if (!$this->_readAllowed($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}))
|
||||
@@ -353,7 +355,7 @@ class UDFLib
|
||||
// Checks if the requiredPermissions is available and it is a valid array or a valid string
|
||||
if (isset($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
|
||||
&& (!isEmptyArray($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
|
||||
|| !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})))
|
||||
|| !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})))
|
||||
{
|
||||
// Then check if the user has the permissions to write such UDF
|
||||
if (!$this->_writeAllowed($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}))
|
||||
@@ -613,6 +615,162 @@ class UDFLib
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the UDF definitions for a model
|
||||
*
|
||||
* @param DB_Model $targetModel
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getDefinitionForModel($targetModel)
|
||||
{
|
||||
$dbTable = $targetModel->getDbTable();
|
||||
if (!isset($this->_definition_cache[$dbTable])) {
|
||||
$this->_ci->load->model('system/UDF_model', 'UDFModel');
|
||||
list($schema, $table) = explode('.', $dbTable);
|
||||
$result = $this->_ci->UDFModel->loadWhere([
|
||||
'schema' => $schema,
|
||||
'table' => $table
|
||||
]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
$this->_definition_cache[$dbTable] = [];
|
||||
else
|
||||
$this->_definition_cache[$dbTable] = json_decode(current($result->retval)->jsons, true);
|
||||
}
|
||||
return success($this->_definition_cache[$dbTable]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the UDFs for db entry with translated params and resolved listValues for dropdowns
|
||||
*
|
||||
* @param DB_Model $targetModel
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getFieldArray($targetModel, $id)
|
||||
{
|
||||
// Load Libraries
|
||||
$this->_ci->load->library('PhrasesLib');
|
||||
$this->_ci->load->library('PermissionLib');
|
||||
|
||||
$result = $this->getDefinitionForModel($targetModel);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$definitions = $result->retval;
|
||||
|
||||
usort($definitions, function ($a, $b) {
|
||||
return $a[self::SORT] - $b[self::SORT];
|
||||
});
|
||||
|
||||
$values = $targetModel->getUDFs($id);
|
||||
|
||||
$fields = [];
|
||||
foreach ($definitions as $field) {
|
||||
// check read permissions
|
||||
if (!$this->_ci->permissionlib->hasAtLeastOne(
|
||||
$field[self::REQUIRED_PERMISSIONS_PARAMETER],
|
||||
self::PERMISSION_TABLE_METHOD,
|
||||
self::PERMISSION_TYPE_READ
|
||||
))
|
||||
continue;
|
||||
|
||||
// set value
|
||||
if (isset($values[$field[self::NAME]])) {
|
||||
$field['value'] = $values[$field[self::NAME]];
|
||||
} elseif (isset($field['defaultValue'])) {
|
||||
$field['value'] = $field['defaultValue'];
|
||||
} elseif (isset($field[self::TYPE]) && $field[self::TYPE] == 'checkbox') {
|
||||
$field['value'] = false;
|
||||
} else {
|
||||
$field['value'] = '';
|
||||
}
|
||||
|
||||
// translate params
|
||||
foreach ([self::LABEL, self::TITLE, self::PLACEHOLDER] as $key) {
|
||||
if (isset($field[$key])) {
|
||||
$res = $this->_ci->phraseslib->getPhrases(self::PHRASES_APP_NAME, getUserLanguage(), $field[$key], null, null, 'no');
|
||||
if (hasData($res))
|
||||
$field[$key] = current(getData($res))->text;
|
||||
}
|
||||
}
|
||||
|
||||
// check write permissions
|
||||
$field['disabled'] = !$this->_ci->permissionlib->hasAtLeastOne(
|
||||
$field[self::REQUIRED_PERMISSIONS_PARAMETER],
|
||||
self::PERMISSION_TABLE_METHOD,
|
||||
self::PERMISSION_TYPE_WRITE
|
||||
);
|
||||
|
||||
// set listValues for dropdowns
|
||||
if (isset($field[self::LIST_VALUES])) {
|
||||
if (isset($field[self::LIST_VALUES]['enum'])) {
|
||||
$field['options'] = $field[self::LIST_VALUES]['enum'];
|
||||
} elseif (isset($field[self::LIST_VALUES]['sql'])) {
|
||||
$res = $this->_ci->UDFModel->execReadOnlyQuery($field[self::LIST_VALUES]['sql']);
|
||||
$field['options'] = hasData($res) ? getData($res) : [];
|
||||
}
|
||||
}
|
||||
|
||||
// add to array
|
||||
$fields[] = $field;
|
||||
}
|
||||
return success($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a validation config array for CI form_validation
|
||||
*
|
||||
* @param DB_Model $targetModel
|
||||
* @param array (optional) $filter
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getCiValidations($targetModel, $filter = null)
|
||||
{
|
||||
$result = $this->getDefinitionForModel($targetModel);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$definitions = getData($result);
|
||||
|
||||
$result = [];
|
||||
foreach ($definitions as $def) {
|
||||
if ($filter && !isset($filter[$def['name']]))
|
||||
continue;
|
||||
$validations = [];
|
||||
if (isset($def['requiredPermissions']))
|
||||
$validations[] = 'has_write_permissions[' . implode(',', $def['requiredPermissions']) . ']';
|
||||
if (isset($def['required']))
|
||||
$validations[] = 'required';
|
||||
if (isset($def['validation'])) {
|
||||
if (isset($def['validation']['max-value']))
|
||||
$validations[] = 'less_than_equal_to[' . $def['validation']['max-value'] . ']';
|
||||
if (isset($def['validation']['min-value']))
|
||||
$validations[] = 'greater_than_equal_to[' . $def['validation']['min-value'] . ']';
|
||||
if (isset($def['validation']['max-length']))
|
||||
$validations[] = 'max_length[' . $def['validation']['max-length'] . ']';
|
||||
if (isset($def['validation']['min-length']))
|
||||
$validations[] = 'min_length[' . $def['validation']['min-length'] . ']';
|
||||
if (isset($def['validation']['regex']) && is_array($def['validation']['regex'])) {
|
||||
foreach ($def['validation']['regex'] as $regex) {
|
||||
if ($regex['language'] == 'php') {
|
||||
$validations[] = 'regex_match[' . $regex['expression'] . ']';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($validations)
|
||||
$result[] = [
|
||||
'field' => $def['name'],
|
||||
'label' => $def['title'],
|
||||
'rules' => $validations
|
||||
];
|
||||
}
|
||||
return success($result);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
//
|
||||
@@ -841,7 +999,7 @@ class UDFLib
|
||||
$htmlParameters[HTMLWidget::HTML_ID] = $jsonSchema->{self::NAME};
|
||||
$htmlParameters[HTMLWidget::HTML_NAME] = $jsonSchema->{self::NAME};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sort the list of UDF by sort property
|
||||
*/
|
||||
@@ -864,7 +1022,7 @@ class UDFLib
|
||||
return ($a->{self::SORT} < $b->{self::SORT}) ? -1 : 1;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads the UDF description by the given schema and table
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,6 @@ class PlausicheckDefinitionLib
|
||||
'AktSemesterNull' => 'AktSemesterNull',
|
||||
'AktiverStudentOhneStatus' => 'AktiverStudentOhneStatus',
|
||||
'AusbildungssemPrestudentUngleichAusbildungssemStatus' => 'AusbildungssemPrestudentUngleichAusbildungssemStatus',
|
||||
'BewerberNichtZumRtAngetreten' => 'BewerberNichtZumRtAngetreten',
|
||||
'DatumAbschlusspruefungFehlt' => 'DatumAbschlusspruefungFehlt',
|
||||
'DatumSponsionFehlt' => 'DatumSponsionFehlt',
|
||||
'DatumStudiensemesterFalscheReihenfolge' => 'DatumStudiensemesterFalscheReihenfolge',
|
||||
@@ -33,8 +32,10 @@ class PlausicheckDefinitionLib
|
||||
'PrestudentMischformOhneOrgform' => 'PrestudentMischformOhneOrgform',
|
||||
'StgPrestudentUngleichStgStudienplan' => 'StgPrestudentUngleichStgStudienplan',
|
||||
'StgPrestudentUngleichStgStudent' => 'StgPrestudentUngleichStgStudent',
|
||||
'StudentstatusNachAbbrecher' => 'StudentstatusNachAbbrecher'
|
||||
'StudentstatusNachAbbrecher' => 'StudentstatusNachAbbrecher',
|
||||
'DualesStudiumOhneMarkierung' => 'DualesStudiumOhneMarkierung'
|
||||
//'StudienplanUngueltig' => 'StudienplanUngueltig'
|
||||
//'BewerberNichtZumRtAngetreten' => 'BewerberNichtZumRtAngetreten'
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,19 +12,25 @@ class PlausicheckProducerLib
|
||||
|
||||
private $_ci; // ci instance
|
||||
private $_extensionName; // name of extension
|
||||
private $_app; // name of application
|
||||
private $_konfiguration = array(); // konfigratio parameters
|
||||
private $_konfiguration = []; // configuration parameters
|
||||
private $_fehlerLibMappings = []; // mappings of fehler and libraries for producing them
|
||||
private $_isForResolutionCheck = false; // mappings of fehler and libraries for producing them
|
||||
|
||||
public function __construct($params = null)
|
||||
{
|
||||
// set extension name if called from extension
|
||||
if (isset($params['extensionName'])) $this->_extensionName = $params['extensionName'];
|
||||
if (isset($params['fehlerLibMappings'])) $this->_fehlerLibMappings = $params['fehlerLibMappings'];
|
||||
if (isset($params['isForResolutionCheck'])) $this->_isForResolutionCheck = $params['isForResolutionCheck'];
|
||||
|
||||
// set application
|
||||
$app = isset($params['app']) ? $params['app'] : null;
|
||||
|
||||
$this->_ci =& get_instance(); // get ci instance
|
||||
|
||||
// load libraries
|
||||
$this->_ci->load->library('IssuesLib');
|
||||
|
||||
// load models
|
||||
$this->_ci->load->model('system/Fehlerkonfiguration_model', 'FehlerkonfigurationModel');
|
||||
|
||||
@@ -42,6 +48,52 @@ class PlausicheckProducerLib
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces multiple plausicheck issues at once and saved them to db.
|
||||
* @param array $params passed to each plausicheck
|
||||
* @return result object with occured error and info
|
||||
*/
|
||||
public function producePlausicheckIssues($params)
|
||||
{
|
||||
$result = new StdClass();
|
||||
$result->errors = [];
|
||||
$result->infos = [];
|
||||
|
||||
foreach ($this->_fehlerLibMappings as $fehler_kurzbz => $libName)
|
||||
{
|
||||
$plausicheckRes = $this->producePlausicheckIssue(
|
||||
$libName,
|
||||
$fehler_kurzbz,
|
||||
$params
|
||||
);
|
||||
|
||||
if (hasData($plausicheckRes))
|
||||
{
|
||||
$plausicheckData = getData($plausicheckRes);
|
||||
|
||||
foreach ($plausicheckData as $plausiData)
|
||||
{
|
||||
// get the data needed for issue production
|
||||
$person_id = isset($plausiData['person_id']) ? $plausiData['person_id'] : null;
|
||||
$oe_kurzbz = isset($plausiData['oe_kurzbz']) ? $plausiData['oe_kurzbz'] : null;
|
||||
$fehlertext_params = isset($plausiData['fehlertext_params']) ? $plausiData['fehlertext_params'] : null;
|
||||
$resolution_params = isset($plausiData['resolution_params']) ? $plausiData['resolution_params'] : null;
|
||||
|
||||
// write the issue
|
||||
$addIssueRes = $this->_ci->issueslib->addFhcIssue($fehler_kurzbz, $person_id, $oe_kurzbz, $fehlertext_params, $resolution_params);
|
||||
|
||||
// log if error, or log info if inserted new issue
|
||||
if (isError($addIssueRes))
|
||||
$result->errors[] = getError($addIssueRes);
|
||||
elseif (hasData($addIssueRes) && is_integer(getData($addIssueRes)))
|
||||
$result->infos[] = "Plausicheck issue " . $fehler_kurzbz . " successfully produced, person_id: " . $person_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes plausicheck using a given library, returns the result.
|
||||
* @param $libName string name of library producing the issue
|
||||
@@ -67,7 +119,10 @@ class PlausicheckProducerLib
|
||||
$config = isset($this->_konfiguration[$fehler_kurzbz]) ? $this->_konfiguration[$fehler_kurzbz] : null;
|
||||
|
||||
// load library connected to fehlercode
|
||||
$this->_ci->load->library($issuesLibPath . $libName, $config);
|
||||
$this->_ci->load->library(
|
||||
$issuesLibPath . $libName,
|
||||
['configurationParams' => $config, 'isForResolutionCheck' => $this->_isForResolutionCheck]
|
||||
);
|
||||
|
||||
$lowercaseLibName = mb_strtolower($libName);
|
||||
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class PlausicheckResolverLib
|
||||
{
|
||||
const CI_PATH = 'application';
|
||||
const CI_LIBRARY_FOLDER = 'libraries';
|
||||
const EXTENSIONS_FOLDER = 'extensions';
|
||||
const ISSUE_RESOLVERS_FOLDER = 'issues/resolvers';
|
||||
const CHECK_ISSUE_RESOLVED_METHOD_NAME = 'checkIfIssueIsResolved';
|
||||
|
||||
private $_ci; // ci instance
|
||||
private $_extensionName; // name of extension
|
||||
private $_codeLibMappings = []; // mappings for issues which explicitly defined resolver
|
||||
private $_codeProducerLibMappings = []; // mappings for issues which are resolved as produced
|
||||
|
||||
public function __construct($params = null)
|
||||
{
|
||||
// set extension name if called from extension
|
||||
if (isset($params['extensionName'])) $this->_extensionName = $params['extensionName'];
|
||||
if (isset($params['codeLibMappings'])) $this->_codeLibMappings = $params['codeLibMappings'];
|
||||
if (isset($params['codeProducerLibMappings'])) $this->_codeProducerLibMappings = $params['codeProducerLibMappings'];
|
||||
|
||||
$this->_ci =& get_instance(); // get ci instance
|
||||
|
||||
$this->_ci->load->library('IssuesLib');
|
||||
$this->_ci->load->library('issues/PlausicheckProducerLib', ['extensionName' => $this->_extensionName, 'isForResolutionCheck' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reseolves multiple plausicheck issues at once.
|
||||
* @param array $codeLibMappings contains fehler type to check and library responsible for check (fehlercode => libName)
|
||||
* @param array $openIssues passed issues to resolve
|
||||
* @return result object with occured error and info
|
||||
*/
|
||||
public function resolvePlausicheckIssues($openIssues)
|
||||
{
|
||||
$result = new StdClass();
|
||||
$result->errors = [];
|
||||
$result->infos = [];
|
||||
|
||||
foreach ($openIssues as $issue)
|
||||
{
|
||||
// add person id and oe kurzbz automatically as params, merge it with additional params
|
||||
// decode bewerbung_parameter into assoc array
|
||||
$params = array_merge(
|
||||
array('issue_id' => $issue->issue_id, 'issue_person_id' => $issue->person_id, 'issue_oe_kurzbz' => $issue->oe_kurzbz),
|
||||
isset($issue->behebung_parameter) ? json_decode($issue->behebung_parameter, true) : array()
|
||||
);
|
||||
|
||||
$issueResolved = false;
|
||||
|
||||
// ignore if Fehlercode is not in libmappings (shouldn't be checked)
|
||||
if (isset($this->_codeLibMappings[$issue->fehlercode]))
|
||||
{
|
||||
$libName = $this->_codeLibMappings[$issue->fehlercode];
|
||||
|
||||
// if called from extension (extension name set), path includes extension names
|
||||
$libRootPath = isset($this->_extensionName) ? self::EXTENSIONS_FOLDER . '/' . $this->_extensionName . '/' : '';
|
||||
|
||||
// path for loading issue library
|
||||
$issuesLibPath = $libRootPath . self::ISSUE_RESOLVERS_FOLDER . '/';
|
||||
|
||||
// file path of library for check if file exists
|
||||
$issuesLibFilePath = DOC_ROOT . self::CI_PATH
|
||||
. '/' . $libRootPath . self::CI_LIBRARY_FOLDER . '/' . self::ISSUE_RESOLVERS_FOLDER . '/' . $libName . '.php';
|
||||
|
||||
// check if library file exists
|
||||
if (!file_exists($issuesLibFilePath))
|
||||
{
|
||||
// log error and continue with next issue if not
|
||||
$result->errors[] = "Issue library file " . $issuesLibFilePath . " does not exist";
|
||||
continue;
|
||||
}
|
||||
|
||||
// load library connected to fehlercode
|
||||
$this->_ci->load->library($issuesLibPath . $libName);
|
||||
|
||||
$lowercaseLibName = mb_strtolower($libName);
|
||||
|
||||
// check if method is defined in library class
|
||||
if (!is_callable(array($this->_ci->{$lowercaseLibName}, self::CHECK_ISSUE_RESOLVED_METHOD_NAME)))
|
||||
{
|
||||
// log error and continue with next issue if not
|
||||
$result->errors[] = "Method " . self::CHECK_ISSUE_RESOLVED_METHOD_NAME . " is not defined in library $lowercaseLibName";
|
||||
continue;
|
||||
}
|
||||
|
||||
// call the function for checking for issue resolution
|
||||
$issueResolvedRes = $this->_ci->{$lowercaseLibName}->{self::CHECK_ISSUE_RESOLVED_METHOD_NAME}($params);
|
||||
|
||||
if (isError($issueResolvedRes))
|
||||
{
|
||||
$result->errors[] = getError($issueResolvedRes);
|
||||
}
|
||||
else
|
||||
{
|
||||
$issueResolved = getData($issueResolvedRes) === true;
|
||||
}
|
||||
}
|
||||
elseif (isset($this->_codeProducerLibMappings[$issue->fehlercode]))
|
||||
{
|
||||
$libName = $this->_codeProducerLibMappings[$issue->fehlercode];
|
||||
|
||||
$issueResolvedRes = $this->_ci->plausicheckproducerlib->producePlausicheckIssue(
|
||||
$libName,
|
||||
$issue->fehler_kurzbz,
|
||||
$params
|
||||
);
|
||||
|
||||
if (isError($issueResolvedRes))
|
||||
{
|
||||
$result->errors[] = getError($issueResolvedRes);
|
||||
}
|
||||
else
|
||||
{
|
||||
$issueResolved = !hasData($issueResolvedRes);
|
||||
}
|
||||
}
|
||||
|
||||
// set issue to resolved if needed
|
||||
if ($issueResolved)
|
||||
{
|
||||
$behobenRes = $this->_ci->issueslib->setBehoben($issue->issue_id, null);
|
||||
|
||||
if (isError($behobenRes))
|
||||
$result->errors[] = getError($behobenRes);
|
||||
else
|
||||
$result->infos[] = "Issue " . $issue->issue_id . " successfully resolved";
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -9,83 +9,21 @@ require_once('PlausiChecker.php');
|
||||
*/
|
||||
class AbbrecherAktiv extends PlausiChecker
|
||||
{
|
||||
public function executePlausiCheck($params)
|
||||
{
|
||||
$results = array();
|
||||
protected $_base_sql = "
|
||||
SELECT
|
||||
pre.person_id, pre.prestudent_id, stg.oe_kurzbz AS prestudent_stg_oe_kurzbz
|
||||
FROM
|
||||
public.tbl_prestudentstatus pre_status
|
||||
JOIN public.tbl_prestudent pre USING(prestudent_id)
|
||||
JOIN public.tbl_student student USING(prestudent_id)
|
||||
JOIN public.tbl_benutzer benutzer on(benutzer.uid=student.student_uid)
|
||||
JOIN public.tbl_studiengang stg ON pre.studiengang_kz = stg.studiengang_kz
|
||||
WHERE
|
||||
pre_status.status_kurzbz ='Abbrecher'
|
||||
AND benutzer.aktiv=true";
|
||||
|
||||
// get parameters from config
|
||||
$exkludierte_studiengang_kz = isset($this->_config['exkludierteStudiengaenge']) ? $this->_config['exkludierteStudiengaenge'] : null;
|
||||
|
||||
// pass parameters needed for plausicheck
|
||||
$studiengang_kz = isset($params['studiengang_kz']) ? $params['studiengang_kz'] : null;
|
||||
|
||||
// get all students failing the plausicheck
|
||||
$prestudentRes = $this->getAbbrecherAktiv($studiengang_kz, null, $exkludierte_studiengang_kz);
|
||||
|
||||
if (isError($prestudentRes)) return $prestudentRes;
|
||||
|
||||
if (hasData($prestudentRes))
|
||||
{
|
||||
$prestudents = getData($prestudentRes);
|
||||
|
||||
// populate results with data necessary for writing issues
|
||||
foreach ($prestudents as $prestudent)
|
||||
{
|
||||
$results[] = array(
|
||||
'person_id' => $prestudent->person_id,
|
||||
'oe_kurzbz' => $prestudent->prestudent_stg_oe_kurzbz,
|
||||
'fehlertext_params' => array('prestudent_id' => $prestudent->prestudent_id),
|
||||
'resolution_params' => array('prestudent_id' => $prestudent->prestudent_id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// return the results
|
||||
return success($results);
|
||||
}
|
||||
|
||||
/**
|
||||
* Abbrecher cannot be active.
|
||||
* @param studiengang_kz int if check is to be executed for certain Studiengang
|
||||
* @param prestudent_id int if check is to be executed only for one prestudent
|
||||
* @param exkludierte_studiengang_kz array if certain Studiengänge have to be excluded from check
|
||||
* @return success with prestudents or error
|
||||
*/
|
||||
public function getAbbrecherAktiv($studiengang_kz = null, $prestudent_id = null, $exkludierte_studiengang_kz = null)
|
||||
{
|
||||
$params = array();
|
||||
|
||||
$qry = "
|
||||
SELECT
|
||||
pre.person_id, pre.prestudent_id, stg.oe_kurzbz AS prestudent_stg_oe_kurzbz
|
||||
FROM
|
||||
public.tbl_prestudentstatus pre_status
|
||||
JOIN public.tbl_prestudent pre USING(prestudent_id)
|
||||
JOIN public.tbl_student student USING(prestudent_id)
|
||||
JOIN public.tbl_benutzer benutzer on(benutzer.uid=student.student_uid)
|
||||
JOIN public.tbl_studiengang stg ON pre.studiengang_kz = stg.studiengang_kz
|
||||
WHERE
|
||||
pre_status.status_kurzbz ='Abbrecher'
|
||||
AND benutzer.aktiv=true";
|
||||
|
||||
if (isset($studiengang_kz))
|
||||
{
|
||||
$qry .= " AND stg.studiengang_kz = ?";
|
||||
$params[] = $studiengang_kz;
|
||||
}
|
||||
|
||||
if (isset($prestudent_id))
|
||||
{
|
||||
$qry .= " AND pre.prestudent_id = ?";
|
||||
$params[] = $prestudent_id;
|
||||
}
|
||||
|
||||
if (isset($exkludierte_studiengang_kz) && !isEmptyArray($exkludierte_studiengang_kz))
|
||||
{
|
||||
$qry .= " AND stg.studiengang_kz NOT IN ?";
|
||||
$params[] = $exkludierte_studiengang_kz;
|
||||
}
|
||||
|
||||
return $this->_db->execReadOnlyQuery($qry, $params);
|
||||
}
|
||||
protected $_config_params = ['exkludierteStudiengaenge' => " AND stg.studiengang_kz NOT IN ?"];
|
||||
protected $_params_for_checking = ['studiengang_kz' => " AND stg.studiengang_kz = ?", 'prestudent_id' => " AND pre.prestudent_id = ?"];
|
||||
protected $_fehlertext_params = ['prestudent_id'];
|
||||
protected $_resolution_params = ['prestudent_id'];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
require_once('PlausiChecker.php');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class DualesStudiumOhneMarkierung extends PlausiChecker
|
||||
{
|
||||
public function executePlausiCheck($params)
|
||||
{
|
||||
$results = array();
|
||||
|
||||
// get parameters from config
|
||||
$exkludierte_studiengang_kz = isset($this->_config['exkludierteStudiengaenge']) ? $this->_config['exkludierteStudiengaenge'] : null;
|
||||
|
||||
// pass parameters needed for plausicheck
|
||||
$studiensemester_kurzbz = isset($params['studiensemester_kurzbz']) ? $params['studiensemester_kurzbz'] : null;
|
||||
$studiengang_kz = isset($params['studiengang_kz']) ? $params['studiengang_kz'] : null;
|
||||
|
||||
// get all students failing the plausicheck
|
||||
$prestudentRes = $this->getDualesStudiumOhneMarkierung(
|
||||
$studiensemester_kurzbz,
|
||||
$studiengang_kz,
|
||||
null,
|
||||
$exkludierte_studiengang_kz
|
||||
);
|
||||
|
||||
if (isError($prestudentRes)) return $prestudentRes;
|
||||
|
||||
if (hasData($prestudentRes))
|
||||
{
|
||||
$prestudents = getData($prestudentRes);
|
||||
|
||||
// populate results with data necessary for writing issues
|
||||
foreach ($prestudents as $prestudent)
|
||||
{
|
||||
$results[] = array(
|
||||
'person_id' => $prestudent->person_id,
|
||||
'oe_kurzbz' => $prestudent->prestudent_stg_oe_kurzbz,
|
||||
'fehlertext_params' => array(
|
||||
'prestudent_id' => $prestudent->prestudent_id,
|
||||
'studienplan' => $prestudent->studienplan
|
||||
),
|
||||
'resolution_params' => array(
|
||||
'prestudent_id' => $prestudent->prestudent_id,
|
||||
'studiensemester_kurzbz' => $prestudent->studiensemester_kurzbz
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// return the results
|
||||
return success($results);
|
||||
}
|
||||
|
||||
/**
|
||||
* All prestudents in dual Studiengang should have set the dual flag to true.
|
||||
* @param studiensemester_kurzbz string check is to be executed for certain Studiensemester
|
||||
* @param studiengang_kz int if check is to be executed for certain Studiengang
|
||||
* @param prestudent_id int if check is to be executed only for one prestudent
|
||||
* @param exkludierte_studiengang_kz array if certain Studiengänge have to be excluded from check
|
||||
* @return success with prestudents or error
|
||||
*/
|
||||
public function getDualesStudiumOhneMarkierung(
|
||||
$studiensemester_kurzbz,
|
||||
$studiengang_kz = null,
|
||||
$prestudent_id = null,
|
||||
$exkludierte_studiengang_kz = null
|
||||
) {
|
||||
$params = array($studiensemester_kurzbz);
|
||||
|
||||
$qry = "
|
||||
SELECT
|
||||
DISTINCT pre.person_id, pre.prestudent_id,
|
||||
stpl.bezeichnung AS studienplan,
|
||||
status.studiensemester_kurzbz,
|
||||
status.ausbildungssemester,
|
||||
stg.oe_kurzbz AS prestudent_stg_oe_kurzbz
|
||||
FROM
|
||||
public.tbl_prestudent pre
|
||||
JOIN public.tbl_prestudentstatus status USING(prestudent_id)
|
||||
JOIN public.tbl_person USING(person_id)
|
||||
JOIN lehre.tbl_studienplan stpl USING(studienplan_id)
|
||||
JOIN public.tbl_studiengang stg ON pre.studiengang_kz = stg.studiengang_kz
|
||||
JOIN public.tbl_studiensemester sem USING(studiensemester_kurzbz)
|
||||
WHERE
|
||||
(stpl.orgform_kurzbz = 'DUA' OR status.orgform_kurzbz = 'DUA')
|
||||
AND pre.dual = FALSE
|
||||
AND status.studiensemester_kurzbz=?
|
||||
AND pre.bismelden
|
||||
AND stg.melderelevant
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM
|
||||
public.tbl_prestudentstatus
|
||||
JOIN lehre.tbl_studienplan USING(studienplan_id)
|
||||
JOIN public.tbl_studiensemester USING(studiensemester_kurzbz)
|
||||
WHERE
|
||||
prestudent_id = pre.prestudent_id
|
||||
AND
|
||||
(
|
||||
-- if there is a newer non-dual status, dual has not to be set
|
||||
(
|
||||
(
|
||||
tbl_studienplan.orgform_kurzbz <> stpl.orgform_kurzbz
|
||||
OR status.orgform_kurzbz <> tbl_prestudentstatus.orgform_kurzbz
|
||||
)
|
||||
AND
|
||||
(
|
||||
tbl_studiensemester.ende::date > sem.ende::date
|
||||
OR (tbl_studiensemester.ende::date = sem.ende::date AND tbl_prestudentstatus.datum::date > status.datum::date)
|
||||
)
|
||||
)
|
||||
OR
|
||||
-- exclude Abgewiesene - they are not reported
|
||||
tbl_prestudentstatus.status_kurzbz = 'Abgewiesener'
|
||||
)
|
||||
)";
|
||||
|
||||
if (isset($studiengang_kz))
|
||||
{
|
||||
$qry .= " AND stg.studiengang_kz = ?";
|
||||
$params[] = $studiengang_kz;
|
||||
}
|
||||
|
||||
if (isset($prestudent_id))
|
||||
{
|
||||
$qry .= " AND pre.prestudent_id = ?";
|
||||
$params[] = $prestudent_id;
|
||||
}
|
||||
|
||||
if (isset($exkludierte_studiengang_kz) && !isEmptyArray($exkludierte_studiengang_kz))
|
||||
{
|
||||
$qry .= " AND stg.studiengang_kz NOT IN ?";
|
||||
$params[] = $exkludierte_studiengang_kz;
|
||||
}
|
||||
|
||||
return $this->_db->execReadOnlyQuery($qry, $params);
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,7 @@ class InaktiverStudentAktiverStatus extends PlausiChecker
|
||||
$prestudent_id = null,
|
||||
$exkludierte_studiengang_kz = null
|
||||
) {
|
||||
$this->_ci->load->model('organisation/studiensemester_model', 'StudiensemesterModel');
|
||||
$aktStudiensemesterRes = $this->_ci->StudiensemesterModel->getAkt();
|
||||
|
||||
if (isError($aktStudiensemesterRes)) return $aktStudiensemesterRes;
|
||||
|
||||
@@ -6,15 +6,25 @@
|
||||
abstract class PlausiChecker
|
||||
{
|
||||
protected $_ci; // code igniter instance
|
||||
protected $_config; // configuration parameters for this plausicheck
|
||||
protected $_config; // all applicable configuration parameters for this plausicheck
|
||||
protected $_db; // database for queries
|
||||
|
||||
public function __construct($configurationParams = null)
|
||||
protected $_isForResolutionCheck; // if true, additional parameters only needed for resolution are checked
|
||||
|
||||
protected $_config_params = []; // name of all config params which should be applied for this plausicheck, with sql [name] => [sql]
|
||||
protected $_params_for_checking = []; // name of all passed params for checking, with sql [name] => [sql]
|
||||
|
||||
protected $_fehlertext_params = []; // parameter names for fehlertext params used for this plausicheck
|
||||
protected $_resolution_params = []; // parameter names for resolution params used for this plausicheck
|
||||
|
||||
public function __construct($params = null)
|
||||
{
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
// set configuration
|
||||
$this->_config = $configurationParams;
|
||||
$this->_config = $params['configurationParams'] ?? [];
|
||||
|
||||
$this->_isForResolutionCheck = $params['isForResolutionCheck'] ?? false;
|
||||
|
||||
// get database for queries
|
||||
$this->_db = new DB_Model();
|
||||
@@ -25,5 +35,83 @@ abstract class PlausiChecker
|
||||
* @param $paramsForChecking array parameters needed for executing the check
|
||||
* @return array with objects which failed the plausi check
|
||||
*/
|
||||
abstract public function executePlausiCheck($paramsForChecking);
|
||||
public function executePlausiCheck($paramsForChecking)
|
||||
{
|
||||
$results = [];
|
||||
$params = [];
|
||||
$qry = $this->_base_sql;
|
||||
|
||||
if ($this->_isForResolutionCheck == true)
|
||||
{
|
||||
foreach ($this->_resolution_params as $resParam)
|
||||
{
|
||||
if (!isset($paramsForChecking[$resParam]))
|
||||
return error("$resParam missing".(isset($paramsForChecking['issue_id']) ? ", issue ID: ".$paramsForChecking['issue_id'] : ""));
|
||||
}
|
||||
}
|
||||
|
||||
// add config params to query
|
||||
if (isset($this->_config_params) && !isEmptyArray($this->_config_params))
|
||||
{
|
||||
foreach ($this->_config_params as $param_name => $param_sql)
|
||||
{
|
||||
if (isset($this->_config[$param_name]))
|
||||
{
|
||||
$qry .= $param_sql;
|
||||
$params[] = $this->_config[$param_name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add check params to query
|
||||
if (isset($this->_params_for_checking) && !isEmptyArray($this->_params_for_checking))
|
||||
{
|
||||
foreach ($this->_params_for_checking as $param_name => $param_sql)
|
||||
{
|
||||
if (isset($paramsForChecking[$param_name]))
|
||||
{
|
||||
$qry .= $param_sql;
|
||||
$params[] = $paramsForChecking[$param_name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->_db->execReadOnlyQuery($qry, $params);
|
||||
|
||||
if (isError($result)) return $result;
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$data = getData($result);
|
||||
|
||||
// populate results with data necessary for writing issues
|
||||
foreach ($data as $d)
|
||||
{
|
||||
$fehlertext_params = [];
|
||||
$resolution_params = [];
|
||||
|
||||
// add params for error texts
|
||||
foreach ($this->_fehlertext_params as $param)
|
||||
{
|
||||
if (isset($d->{$param})) $fehlertext_params[$param] = $d->{$param};
|
||||
}
|
||||
|
||||
// add params for resolution of issue
|
||||
foreach ($this->_resolution_params as $param)
|
||||
{
|
||||
if (isset($d->{$param})) $resolution_params[$param] = $d->{$param};
|
||||
}
|
||||
|
||||
$results[] = array(
|
||||
'person_id' => $d->person_id,
|
||||
'oe_kurzbz' => $d->prestudent_stg_oe_kurzbz,
|
||||
'fehlertext_params' => $fehlertext_params,
|
||||
'resolution_params' => $resolution_params
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// return the results
|
||||
return success($results);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Student in dual Studiengang should have set the dual flag to true.
|
||||
*/
|
||||
class CORE_STUDENTSTATUS_0016 implements IIssueResolvedChecker
|
||||
{
|
||||
public function checkIfIssueIsResolved($params)
|
||||
{
|
||||
if (!isset($params['prestudent_id']) || !is_numeric($params['prestudent_id']))
|
||||
return error('Prestudent Id missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
if (!isset($params['studiensemester_kurzbz']) || isEmptyString($params['studiensemester_kurzbz']))
|
||||
return error('Studiensemester missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
$this->_ci->load->library('issues/plausichecks/DualesStudiumOhneMarkierung');
|
||||
|
||||
// check if issue persists
|
||||
$checkRes = $this->_ci->dualesstudiumohnemarkierung->getDualesStudiumOhneMarkierung(
|
||||
$params['studiensemester_kurzbz'],
|
||||
null,
|
||||
$params['prestudent_id']
|
||||
);
|
||||
|
||||
if (isError($checkRes)) return $checkRes;
|
||||
|
||||
if (hasData($checkRes))
|
||||
return success(false); // not resolved if issue is still present
|
||||
else
|
||||
return success(true); // resolved otherwise
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,9 @@ class Dienstverhaeltnis extends AbstractBestandteil {
|
||||
protected $updateamum;
|
||||
protected $updatevon;
|
||||
|
||||
protected $dvendegrund_kurzbz;
|
||||
protected $dvendegrund_anmerkung;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -49,6 +52,8 @@ class Dienstverhaeltnis extends AbstractBestandteil {
|
||||
isset($data->insertvon) && $this->setInsertvon($data->insertvon);
|
||||
isset($data->updateamum) && $this->setUpdateamum($data->updateamum);
|
||||
isset($data->updatevon) && $this->setUpdatevon($data->updatevon);
|
||||
isset($data->dvendegrund_kurzbz) && $this->setDvendegrund_kurzbz($data->dvendegrund_kurzbz);
|
||||
isset($data->dvendegrund_anmerkung) && $this->setDvendegrund_anmerkung($data->dvendegrund_anmerkung);
|
||||
$this->fromdb = false;
|
||||
}
|
||||
|
||||
@@ -64,7 +69,9 @@ class Dienstverhaeltnis extends AbstractBestandteil {
|
||||
'insertamum' => $this->getInsertamum(),
|
||||
'insertvon' => $this->getInsertvon(),
|
||||
'updateamum' => $this->getUpdateamum(),
|
||||
'updatevon' => $this->getUpdatevon()
|
||||
'updatevon' => $this->getUpdatevon(),
|
||||
'dvendegrund_kurzbz' => $this->getDvendegrund_kurzbz(),
|
||||
'dvendegrund_anmerkung' => $this->getDvendegrund_anmerkung()
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($k) {
|
||||
@@ -139,6 +146,16 @@ EOTXT;
|
||||
return $this->updatevon;
|
||||
}
|
||||
|
||||
public function getDvendegrund_kurzbz()
|
||||
{
|
||||
return $this->dvendegrund_kurzbz;
|
||||
}
|
||||
|
||||
public function getDvendegrund_anmerkung()
|
||||
{
|
||||
return $this->dvendegrund_anmerkung;
|
||||
}
|
||||
|
||||
public function setDienstverhaeltnis_id($dienstverhaeltnis_id)
|
||||
{
|
||||
$this->markDirty('dienstverhaeltnis_id', $this->dienstverhaeltnis_id, $dienstverhaeltnis_id);
|
||||
@@ -214,6 +231,20 @@ EOTXT;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDvendegrund_kurzbz($dvendegrund_kurzbz)
|
||||
{
|
||||
$this->markDirty('dvendegrund_kurzbz', $this->dvendegrund_kurzbz, $dvendegrund_kurzbz);
|
||||
$this->dvendegrund_kurzbz = $dvendegrund_kurzbz;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDvendegrund_anmerkung($dvendegrund_anmerkung)
|
||||
{
|
||||
$this->markDirty('dvendegrund_anmerkung', $this->dvendegrund_anmerkung, $dvendegrund_anmerkung);
|
||||
$this->dvendegrund_anmerkung = $dvendegrund_anmerkung;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function validate() {
|
||||
//do Validation here
|
||||
$ci = get_instance();
|
||||
|
||||
@@ -435,7 +435,7 @@ class VertragsbestandteilLib
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function endDienstverhaeltnis(Dienstverhaeltnis $dv, $enddate)
|
||||
public function endDienstverhaeltnis(Dienstverhaeltnis $dv, $enddate, $dvendegrund_kurzbz=null, $dvendegrund_anmerkung=null)
|
||||
{
|
||||
if( $dv->getBis() !== null && $dv->getBis() < $enddate )
|
||||
{
|
||||
@@ -460,6 +460,14 @@ class VertragsbestandteilLib
|
||||
$this->endVertragsbestandteil($vb, $enddate);
|
||||
}
|
||||
|
||||
if( $dvendegrund_kurzbz !== null )
|
||||
{
|
||||
$dv->setDvendegrund_kurzbz($dvendegrund_kurzbz);
|
||||
}
|
||||
if( $dvendegrund_anmerkung !== null )
|
||||
{
|
||||
$dv->setDvendegrund_anmerkung($dvendegrund_anmerkung);
|
||||
}
|
||||
$dv->setBis($enddate);
|
||||
$this->updateDienstverhaeltnis($dv);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
class Bismeldestichtag_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -12,6 +11,105 @@ class Bismeldestichtag_model extends DB_Model
|
||||
$this->pk = 'meldestichtag_id';
|
||||
}
|
||||
|
||||
public function getLastReachedMeldestichtag($studiensemester_kurzbz = null)
|
||||
{
|
||||
$this->addSelect('meldestichtag_id');
|
||||
$this->addSelect('meldestichtag');
|
||||
$this->addSelect('studiensemester_kurzbz');
|
||||
$this->addSelect('insertamum');
|
||||
$this->addSelect('insertvon');
|
||||
$this->addSelect('updateamum');
|
||||
$this->addSelect('updatevon');
|
||||
|
||||
if ($studiensemester_kurzbz) {
|
||||
$this->db->where('studiensemester_kurzbz', $studiensemester_kurzbz);
|
||||
}
|
||||
|
||||
$this->addOrder('meldestichtag', 'DESC');
|
||||
$this->addLimit(1);
|
||||
|
||||
return $this->loadWhere([
|
||||
'meldestichtag < NOW()' => null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Liefert nächstliegenden Bismeldestichtag.
|
||||
* @return object success or error
|
||||
*/
|
||||
public function getNextMeldestichtag()
|
||||
{
|
||||
$this->addSelect('meldestichtag');
|
||||
$this->addSelect('studiensemester_kurzbz');
|
||||
|
||||
$this->addOrder('meldestichtag', 'ASC');
|
||||
$this->addLimit(1);
|
||||
|
||||
return $this->loadWhere([
|
||||
'meldestichtag >= NOW()' => null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft, ob Meldestichtag für ein bestimmtes Statusdatum und Studiensemester erreicht ist.
|
||||
*
|
||||
* @param $status_datum
|
||||
* @return boolean true wenn erreicht, oder false
|
||||
*/
|
||||
public function checkIfMeldestichtagErreicht($status_datum, $studiensemester_kurzbz = null)
|
||||
{
|
||||
$erreicht = false;
|
||||
|
||||
if (isset($studiensemester_kurzbz))
|
||||
{
|
||||
// Studiensemesterende holen
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
$result = $this->StudiensemesterModel->loadWhere(
|
||||
array(
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz
|
||||
)
|
||||
);
|
||||
if(isError($result))
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
$result = current(getData($result));
|
||||
|
||||
$studiensemester_ende = new DateTime($result->ende);
|
||||
}
|
||||
|
||||
// letztes erreichtes Bismeldedatum holen
|
||||
$result = $this->getLastReachedMeldestichtag();
|
||||
if (isError($result))
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
if (!hasData($result)) {
|
||||
return success("0",'No Statusdata vorhanden');
|
||||
}
|
||||
$stichtag = current(getData($result));
|
||||
$stichtag = new DateTime($stichtag->meldestichtag);
|
||||
|
||||
$statusDatum = new DateTime($status_datum);
|
||||
|
||||
// Prüfen, ob Studentstatusdatum oder Studiensemester vor dem Stichtagsdatum liegen
|
||||
if (isset($statusDatum))
|
||||
{
|
||||
if (isset($stichtag))
|
||||
$erreicht = $statusDatum < $stichtag;
|
||||
}
|
||||
|
||||
if (isset($studiensemester_ende))
|
||||
{
|
||||
$erreicht = $erreicht || $studiensemester_ende < $stichtag;
|
||||
}
|
||||
|
||||
if ($erreicht)
|
||||
return success("1", "Studentstatus mit Datum oder Semesterende vor erreichtem Meldestichtag können nicht hinzugefügt werden");
|
||||
|
||||
return success("0", "Meldestatus nicht erreicht");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets last Bismeldestichtag for a Studiensemester.
|
||||
* @param $studiensemester_kurzbz
|
||||
|
||||
@@ -19,4 +19,13 @@ class Gemeinde_model extends DB_Model
|
||||
|
||||
return $this->loadWhere(array("plz" => $plz));
|
||||
}
|
||||
|
||||
public function checkLocation($plz, $gemeinde, $ort)
|
||||
{
|
||||
$this->db->where('ortschaftsname', $ort);
|
||||
$this->db->where('name', $gemeinde);
|
||||
$this->db->where('plz', $plz);
|
||||
|
||||
return (boolean)$this->db->count_all_results($this->dbTable);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use CI3_Events as Events;
|
||||
|
||||
class Konto_model extends DB_Model
|
||||
{
|
||||
|
||||
@@ -12,6 +15,218 @@ class Konto_model extends DB_Model
|
||||
$this->pk = 'buchungsnr';
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert Data into DB-Table
|
||||
*
|
||||
* @param array $data DataArray for Insert
|
||||
* @return stdClass
|
||||
*/
|
||||
public function insert($data, $encryptedColumns = null)
|
||||
{
|
||||
if (isset($data['buchungsnr_verweis']) && $data['buchungsnr_verweis'])
|
||||
return parent::insert($data, $encryptedColumns);
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
$result = parent::insert($data, $encryptedColumns);
|
||||
if (isError($result)) {
|
||||
$this->db->trans_rollback();
|
||||
return $result;
|
||||
}
|
||||
|
||||
$buchungsnr = $result->retval;
|
||||
// If studiengang_kz is not present in $data it will fail above since it is a not null field
|
||||
$studiengang_kz = $data['studiengang_kz'];
|
||||
|
||||
|
||||
$zahlungsreferenz = false;
|
||||
Events::trigger('generate_zahlungsreferenz', $buchungsnr, $data, function ($value) use ($zahlungsreferenz) {
|
||||
$zahlungsreferenz = $value;
|
||||
});
|
||||
|
||||
if ($zahlungsreferenz === false) {
|
||||
$result = $this->execQuery('SELECT UPPER(oe_kurzbz) || ? as zahlungsreferenz
|
||||
FROM public.tbl_studiengang
|
||||
WHERE studiengang_kz=?', [$buchungsnr, $studiengang_kz]);
|
||||
if (isError($result)) {
|
||||
$this->db->trans_rollback();
|
||||
return $result;
|
||||
}
|
||||
$zahlungsreferenz = current(getData($result))->zahlungsreferenz;
|
||||
} elseif (isError($zahlungsreferenz)) {
|
||||
$this->db->trans_rollback();
|
||||
return $zahlungsreferenz;
|
||||
}
|
||||
|
||||
|
||||
$result = $this->update($buchungsnr, [
|
||||
'zahlungsreferenz' => $zahlungsreferenz
|
||||
]);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->db->trans_rollback();
|
||||
return $result;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
|
||||
return success($buchungsnr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete data from DB-Table
|
||||
*
|
||||
* @param string $id Primary Key for DELETE
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$this->db->where('buchungsnr_verweis', $id);
|
||||
if ($this->db->count_all_results($this->dbTable))
|
||||
return error('Bitte zuerst die zugeordneten Buchungen loeschen', 42);
|
||||
return parent::delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds additional fields to the Query
|
||||
*
|
||||
* @return Konto_model
|
||||
*/
|
||||
public function withAdditionalInfo()
|
||||
{
|
||||
$this->addSelect($this->dbTable . '.*');
|
||||
$this->addSelect('UPPER(typ::varchar(1) || kurzbz) AS kuerzel');
|
||||
$this->addSelect('person.anrede');
|
||||
$this->addSelect('person.titelpost');
|
||||
$this->addSelect('person.titelpre');
|
||||
$this->addSelect('person.vorname');
|
||||
$this->addSelect('person.vornamen');
|
||||
$this->addSelect('person.nachname');
|
||||
|
||||
$this->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
|
||||
$this->addJoin('public.tbl_person person', 'person_id', 'LEFT');
|
||||
|
||||
Events::trigger('konto_query');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all accounting entries for a person optionally filtered by Studiengang
|
||||
*
|
||||
* @param integer|array $person_id
|
||||
* @param string (optional) $studiengang_kz
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getAlleBuchungen($person_id, $studiengang_kz = '')
|
||||
{
|
||||
$this->withAdditionalInfo();
|
||||
|
||||
$this->addOrder('buchungsdatum');
|
||||
|
||||
if (is_array($person_id))
|
||||
$this->db->where_in('person_id', $person_id);
|
||||
else
|
||||
$this->db->where('person_id', $person_id);
|
||||
|
||||
if ($studiengang_kz)
|
||||
return $this->loadWhere([
|
||||
'studiengang_kz' => $studiengang_kz
|
||||
]);
|
||||
return $this->load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all open accounting entries for a person optionally filtered by Studiengang
|
||||
*
|
||||
* @param integer|array $person_id
|
||||
* @param string (optional) $studiengang_kz
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getOffeneBuchungen($person_id, $studiengang_kz = '')
|
||||
{
|
||||
$this->addSelect('buchungsnr');
|
||||
$this->db->where('(betrag + (
|
||||
SELECT CASE WHEN sum(betrag) is null THEN 0 ELSE sum(betrag) END
|
||||
FROM ' . $this->dbTable . '
|
||||
WHERE buchungsnr_verweis=konto_a.buchungsnr
|
||||
)) !=', 0, false);
|
||||
if (is_array($person_id))
|
||||
$this->db->where_in('person_id', $person_id);
|
||||
else
|
||||
$this->db->where('person_id', $person_id);
|
||||
$sql = $this->db->get_compiled_select($this->dbTable . ' konto_a');
|
||||
|
||||
$this->db->group_start();
|
||||
$this->db->where_in('buchungsnr', $sql, false);
|
||||
$this->db->or_where_in('buchungsnr_verweis', $sql, false);
|
||||
$this->db->group_end();
|
||||
|
||||
return $this->getAlleBuchungen($person_id, $studiengang_kz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check double Buchungen
|
||||
*
|
||||
* @param array $person_ids
|
||||
* @param string $studiensemester_kurzbz
|
||||
* @param array $buchungstyp_kurzbzs
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkDoubleBuchung($person_ids, $studiensemester_kurzbz, $buchungstyp_kurzbzs)
|
||||
{
|
||||
$this->addSelect('vorname');
|
||||
$this->addSelect('nachname');
|
||||
|
||||
$this->addJoin('public.tbl_person', 'person_id');
|
||||
|
||||
$this->db->where_in('person_id', $person_ids);
|
||||
$this->db->where_in('buchungstyp_kurzbz', $buchungstyp_kurzbzs);
|
||||
|
||||
$this->addGroupBy('vorname, nachname');
|
||||
$this->addOrder('nachname');
|
||||
$this->addOrder('vorname');
|
||||
|
||||
return $this->loadWhere([
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Berechnet den offenen Betrag einer Buchung
|
||||
*
|
||||
* @param integer $buchungsnr
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getDifferenz($buchungsnr)
|
||||
{
|
||||
$this->addSelect('buchungsnr_verweis');
|
||||
$this->db->where('buchungsnr', $buchungsnr);
|
||||
$sql = $this->db->get_compiled_select($this->dbTable);
|
||||
|
||||
$this->addSelect('buchungsnr_verweis');
|
||||
$this->db->where('buchungsnr', $buchungsnr);
|
||||
$this->db->or_where('buchungsnr_verweis', '(' . $sql . ')', false);
|
||||
$sql = $this->db->get_compiled_select($this->dbTable);
|
||||
|
||||
$this->addSelect('sum(betrag) differenz');
|
||||
$this->db->where('buchungsnr', $buchungsnr);
|
||||
$this->db->or_where('buchungsnr_verweis', $buchungsnr);
|
||||
$this->db->or_where('buchungsnr', '(' . $sql . ')', false);
|
||||
|
||||
$result = $this->load();
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return success(null);
|
||||
return success(current(getData($result))->differenz * -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a Payment as paid
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,39 @@ class Prestudent_model extends DB_Model
|
||||
$this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Data in DB-Table
|
||||
*
|
||||
* @param string $id PK for DB-Table
|
||||
* @param array $data DataArray for Insert
|
||||
* @return array
|
||||
*/
|
||||
public function update($id, $data, $encryptedColumns = null)
|
||||
{
|
||||
if (isset($data['zgvmas_code'])
|
||||
|| isset($data['zgvmanation'])
|
||||
|| isset($data['zgv_code'])
|
||||
|| isset($data['zgvnation'])
|
||||
) {
|
||||
/**
|
||||
* Falls ZGV vorhanden, setze Ausstellungsstaat (für BIS-Meldung)
|
||||
* auf Nation der höchsten angegebenen ZGV
|
||||
*/
|
||||
$case = '(CASE
|
||||
WHEN zgvmas_code IS NOT NULL AND zgvmanation IS NOT NULL THEN zgvmanation
|
||||
WHEN zgv_code IS NOT NULL AND zgvnation IS NOT NULL THEN zgvnation
|
||||
ELSE NULL END)';
|
||||
|
||||
foreach (['zgvmas_code', 'zgvmanation', 'zgv_code', 'zgvnation'] as $key)
|
||||
if (isset($data[$key]))
|
||||
$case = str_replace($key, $this->escape($data[$key]), $case);
|
||||
|
||||
$this->db->set('ausstellungsstaat', $case, false);
|
||||
}
|
||||
|
||||
return parent::update($id, $data, $encryptedColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
* getLastStatuses
|
||||
*/
|
||||
@@ -700,4 +733,33 @@ class Prestudent_model extends DB_Model
|
||||
return $this->execQuery($query, array($prestudent_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets history of all prestudents, person_id given
|
||||
* @param int $person_id
|
||||
* @return object
|
||||
*/
|
||||
public function getHistoryPrestudents($person_id)
|
||||
{
|
||||
|
||||
$query = "
|
||||
SELECT ps.studiensemester_kurzbz, p.priorisierung, p.studiengang_kz, sg.kurzbzlang, ps.orgform_kurzbz,
|
||||
ps.status_kurzbz, s.student_uid, sp.bezeichnung, ps.ausbildungssemester,
|
||||
CONCAT(ps.status_kurzbz, ' (', ps.ausbildungssemester, '. Semester)') as status, p.prestudent_id
|
||||
FROM public.tbl_prestudent p
|
||||
JOIN (
|
||||
SELECT DISTINCT ON(prestudent_id) *
|
||||
FROM public.tbl_prestudentstatus
|
||||
WHERE prestudent_id IN (SELECT prestudent_id FROM public.tbl_prestudent WHERE person_id = ?)
|
||||
ORDER BY prestudent_id, datum desc, insertamum desc
|
||||
) ps USING(prestudent_id)
|
||||
JOIN public.tbl_status USING(status_kurzbz)
|
||||
LEFT JOIN public.tbl_status_grund g USING (statusgrund_id)
|
||||
JOIN public.tbl_studiengang sg USING(studiengang_kz)
|
||||
LEFT JOIN lehre.tbl_studienplan sp USING (studienplan_id)
|
||||
LEFT JOIN public.tbl_student s USING (prestudent_id)
|
||||
ORDER BY p.priorisierung
|
||||
";
|
||||
|
||||
return $this->execQuery($query, array($person_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,15 @@ class Prestudentstatus_model extends DB_Model
|
||||
|
||||
const STATUS_ABBRECHER = 'Abbrecher';
|
||||
const STATUS_UNTERBRECHER = 'Unterbrecher';
|
||||
const STATUS_STUDENT = 'Student';
|
||||
const STATUS_DIPLOMAND = 'Diplomand';
|
||||
const STATUS_ABSOLVENT = 'Absolvent';
|
||||
const STATUS_BEWERBER = 'Bewerber';
|
||||
const STATUS_AUFGENOMMENER = 'Aufgenommener';
|
||||
const STATUS_WARTENDER = 'Wartender';
|
||||
const STATUS_ABGEWIESENER = 'Abgewiesener';
|
||||
const STATUS_INTERESSENT = 'Interessent';
|
||||
const STATUS_INCOMING = 'Incoming';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -280,6 +289,7 @@ class Prestudentstatus_model extends DB_Model
|
||||
$this->addSelect('ss.studienjahr_kurzbz');
|
||||
$this->addSelect('pers.vorname');
|
||||
$this->addSelect('pers.nachname');
|
||||
$this->addSelect('pers.unruly');
|
||||
$this->addSelect('TRIM(CONCAT(pers.vorname, \' \', pers.nachname)) AS name');
|
||||
$this->addSelect('pers.person_id');
|
||||
$this->addSelect('g.studiengang_kz');
|
||||
@@ -330,13 +340,252 @@ class Prestudentstatus_model extends DB_Model
|
||||
*/
|
||||
public function withGrund($statusgrund_kurzbz)
|
||||
{
|
||||
if($statusgrund_kurzbz)
|
||||
if ($statusgrund_kurzbz)
|
||||
$this->db->set(
|
||||
'statusgrund_id',
|
||||
'(SELECT statusgrund_id FROM public.tbl_status_grund WHERE statusgrund_kurzbz =' . $this->db->escape($statusgrund_kurzbz) .')',
|
||||
'(SELECT statusgrund_id FROM public.tbl_status_grund WHERE statusgrund_kurzbz=' . $this->db->escape($statusgrund_kurzbz) . ')',
|
||||
false
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there is only one prestudentstatus left
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $studiensemester_kurzbz
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfLastStatusEntry($prestudent_id, $studiensemester_kurzbz = null)
|
||||
{
|
||||
$this->addSelect('COUNT(*) AS anzahl', false);
|
||||
|
||||
if ($studiensemester_kurzbz)
|
||||
$this->db->where('studiensemester_kurzbz', $studiensemester_kurzbz);
|
||||
|
||||
$result = $this->loadWhere([
|
||||
'prestudent_id' => $prestudent_id
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
$resultObject = current($result->retval);
|
||||
|
||||
$anzahl = (int)$resultObject->anzahl;
|
||||
|
||||
if ($anzahl <= 1)
|
||||
return success(true, $this->p->t('lehre', 'error_lastRole'));
|
||||
|
||||
return success(false, $this->p->t('lehre', 'anzahl_existingRoles', ['anzahl' => $anzahl]));
|
||||
}
|
||||
|
||||
public function getAllPrestudentstatiWithStudiensemester($prestudent_id)
|
||||
{
|
||||
$qry = "
|
||||
SELECT
|
||||
tbl_prestudentstatus.status_kurzbz,
|
||||
tbl_prestudentstatus.studiensemester_kurzbz,
|
||||
tbl_prestudentstatus.ausbildungssemester,
|
||||
tbl_prestudentstatus.datum,
|
||||
s.start AS studiensemester_start,
|
||||
pl.orgform_kurzbz AS studienplan_orgform_kurzbz,
|
||||
stud.matrikelnr,
|
||||
pers.vorname,
|
||||
pers.nachname
|
||||
FROM
|
||||
public.tbl_prestudentstatus
|
||||
JOIN public.tbl_studiensemester s USING (studiensemester_kurzbz)
|
||||
JOIN public.tbl_prestudent USING (prestudent_id)
|
||||
JOIN public.tbl_person pers USING (person_id)
|
||||
LEFT JOIN public.tbl_student stud USING (prestudent_id)
|
||||
LEFT JOIN lehre.tbl_studienplan pl USING (studienplan_id)
|
||||
WHERE
|
||||
prestudent_id = ?
|
||||
ORDER BY
|
||||
public.tbl_prestudentstatus.datum DESC,
|
||||
public.tbl_prestudentstatus.insertamum DESC,
|
||||
public.tbl_prestudentstatus.ext_id DESC
|
||||
";
|
||||
|
||||
return $this->execQuery($qry, array($prestudent_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets status history of a prestudent
|
||||
* This function uses the language of the logged in user to
|
||||
* translate the given statusgrund
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getHistoryPrestudent($prestudent_id)
|
||||
{
|
||||
$lang= getUserLanguage();
|
||||
$this->addSelect('tbl_prestudentstatus.prestudent_id');
|
||||
$this->addSelect('tbl_prestudentstatus.status_kurzbz');
|
||||
$this->addSelect('tbl_prestudentstatus.studiensemester_kurzbz');
|
||||
$this->addSelect('tbl_prestudentstatus.ausbildungssemester');
|
||||
$this->addSelect('tbl_prestudentstatus.datum');
|
||||
$this->addSelect("TO_CHAR(tbl_prestudentstatus.datum::timestamp, 'DD.MM.YYYY') AS format_datum");
|
||||
$this->addSelect('tbl_prestudentstatus.insertamum');
|
||||
$this->addSelect('tbl_prestudentstatus.insertvon');
|
||||
$this->addSelect('tbl_prestudentstatus.updateamum');
|
||||
$this->addSelect('tbl_prestudentstatus.updatevon');
|
||||
$this->addSelect('tbl_prestudentstatus.orgform_kurzbz');
|
||||
$this->addSelect('tbl_prestudentstatus.bestaetigtam');
|
||||
$this->addSelect("TO_CHAR(tbl_prestudentstatus.bestaetigtam::timestamp, 'DD.MM.YYYY') AS format_bestaetigtam");
|
||||
$this->addSelect('tbl_prestudentstatus.bestaetigtvon');
|
||||
$this->addSelect('tbl_prestudentstatus.bewerbung_abgeschicktamum');
|
||||
$this->addSelect("TO_CHAR(tbl_prestudentstatus.bewerbung_abgeschicktamum::timestamp, 'DD.MM.YYYY') AS format_bewerbung_abgeschicktamum");
|
||||
$this->addSelect('tbl_prestudentstatus.anmerkung');
|
||||
$this->addSelect('plan.studienplan_id');
|
||||
$this->addSelect('plan.bezeichnung');
|
||||
|
||||
$this->addSelect('grund.beschreibung[(
|
||||
SELECT index
|
||||
FROM public.tbl_sprache
|
||||
WHERE sprache=' . $this->escape($lang) . '
|
||||
)] AS statusgrund_bezeichnung', false);
|
||||
$this->addSelect("CASE
|
||||
WHEN s.student_uid IS NOT NULL
|
||||
AND tbl_prestudentstatus.status_kurzbz IN (" . implode(",", $this->escape([
|
||||
'Student',
|
||||
'Diplomand',
|
||||
'Abbrecher',
|
||||
'Absolvent',
|
||||
'Ausserodentlicher',
|
||||
'Incoming',
|
||||
'Outgoing',
|
||||
'Unterbrecher'
|
||||
])) . ")
|
||||
THEN lv.semester || lv.verband || lv.gruppe
|
||||
ELSE '-'
|
||||
END AS lehrverband", false);
|
||||
|
||||
|
||||
$this->addJoin('lehre.tbl_studienplan plan', 'studienplan_id', 'LEFT');
|
||||
$this->addJoin('public.tbl_status_grund grund', 'statusgrund_id', 'LEFT');
|
||||
$this->addJoin('public.tbl_student s', 'prestudent_id', 'LEFT');
|
||||
$this->addJoin(
|
||||
'public.tbl_studentlehrverband lv',
|
||||
's.student_uid IS NOT NULL AND s.student_uid=lv.student_uid AND tbl_prestudentstatus.studiensemester_kurzbz=lv.studiensemester_kurzbz',
|
||||
'LEFT'
|
||||
);
|
||||
|
||||
$this->addOrder('tbl_prestudentstatus.datum', 'DESC');
|
||||
$this->addOrder('tbl_prestudentstatus.insertamum', 'DESC');
|
||||
$this->addOrder('tbl_prestudentstatus.ext_id', 'DESC');
|
||||
|
||||
return $this->loadWhere([
|
||||
'tbl_prestudentstatus.prestudent_id' => $prestudent_id
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets status history of a prestudent for checking purposes.
|
||||
* This function adds the new state or replaces the edited.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getHistoryWithNewOrEditedState(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
$new_date = $new_date->format('Y-m-d');
|
||||
|
||||
$this->addSelect('status_kurzbz');
|
||||
$this->addSelect('studiensemester_kurzbz');
|
||||
$this->addSelect('ausbildungssemester');
|
||||
$this->addSelect('datum');
|
||||
$this->addSelect('insertamum');
|
||||
$this->addSelect('ext_id');
|
||||
|
||||
if ($old_studiensemester_kurzbz || $old_ausbildungssemester) {
|
||||
$this->db->not_group_start();
|
||||
$this->db->where('status_kurzbz', $status_kurzbz);
|
||||
$this->db->where('studiensemester_kurzbz', $old_studiensemester_kurzbz);
|
||||
$this->db->where('ausbildungssemester', $old_ausbildungssemester);
|
||||
$this->db->group_end();
|
||||
}
|
||||
|
||||
$this->db->where('prestudent_id', $prestudent_id);
|
||||
|
||||
$tmpTable = $this->db->get_compiled_select($this->dbTable);
|
||||
|
||||
$tmpTable .= "UNION
|
||||
SELECT " .
|
||||
$this->escape($status_kurzbz) . " AS status_kurzbz, " .
|
||||
$this->escape($new_studiensemester_kurzbz) . " AS studiensemester_kurzbz, " .
|
||||
$this->escape($new_ausbildungssemester) . " AS ausbildungssemester, " .
|
||||
$this->escape($new_date) . "::date AS datum," .
|
||||
$this->escape(date('c')) . "::date AS insertamum," .
|
||||
"NULL AS ext_id";
|
||||
|
||||
$this->addJoin('public.tbl_studiensemester sem', 'studiensemester_kurzbz');
|
||||
|
||||
$this->addOrder('s.datum', 'DESC');
|
||||
$this->addOrder('s.insertamum', 'DESC');
|
||||
$this->addOrder('s.ext_id', 'DESC');
|
||||
|
||||
$dbTable = $this->dbTable;
|
||||
$this->dbTable = "(" . $tmpTable . ") s";
|
||||
|
||||
$result = $this->load();
|
||||
|
||||
$this->dbTable = $dbTable;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* For checks if Orgform of Student status and Bewerber status match.
|
||||
* Returns any Bewerber status that does not match the first Student
|
||||
* status' Orgform.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getBewerberWhereOrgformNotStudent($prestudent_id)
|
||||
{
|
||||
$this->addSelect('plan.orgform_kurzbz');
|
||||
|
||||
$this->addJoin('lehre.tbl_studienplan plan', 'studienplan_id', 'LEFT');
|
||||
|
||||
$this->addOrder('tbl_prestudentstatus.datum', 'DESC');
|
||||
$this->addOrder('tbl_prestudentstatus.insertamum', 'DESC');
|
||||
$this->addOrder('tbl_prestudentstatus.ext_id', 'DESC');
|
||||
|
||||
$this->addLimit(1);
|
||||
|
||||
$this->db->where('prestudent_id', $prestudent_id);
|
||||
$this->db->where('status_kurzbz', self::STATUS_STUDENT);
|
||||
|
||||
$sql = $this->db->get_compiled_select($this->dbTable);
|
||||
|
||||
$this->addJoin('lehre.tbl_studienplan plan', 'studienplan_id', 'LEFT');
|
||||
|
||||
$this->db->where('plan.orgform_kurzbz !=', '(' . $sql . ')', false);
|
||||
return $this->loadWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => self::STATUS_BEWERBER
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,21 @@ class Status_model extends DB_Model
|
||||
$this->dbTable = 'public.tbl_status';
|
||||
$this->pk = 'status_kurzbz';
|
||||
}
|
||||
|
||||
public function getAllStatiWithStatusgruende()
|
||||
{
|
||||
$lang = '[(SELECT index FROM public.tbl_sprache WHERE sprache=' . $this->escape(getUserLanguage()) . ' LIMIT 1)]';
|
||||
|
||||
$this->addSelect('sg.status_kurzbz');
|
||||
|
||||
$this->addSelect('statusgrund_id');
|
||||
$this->addSelect('sg.bezeichnung_mehrsprachig' . $lang . ' AS bezeichnung');
|
||||
$this->addSelect('sg.beschreibung' . $lang . ' AS beschreibung');
|
||||
|
||||
$this->addJoin('public.tbl_status_grund sg', 'ON (sg.status_kurzbz = public.tbl_status.status_kurzbz)', 'LEFT');
|
||||
|
||||
return $this->loadWhere([
|
||||
'aktiv'=> true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,19 @@ class Statusgrund_model extends DB_Model
|
||||
|
||||
return success($status->retval);
|
||||
}
|
||||
|
||||
public function getAktiveGruende()
|
||||
{
|
||||
$lang = '[(SELECT index FROM public.tbl_sprache WHERE sprache=' . $this->escape(getUserLanguage()) . ' LIMIT 1)]';
|
||||
|
||||
$this->addSelect('tbl_status_grund.*');
|
||||
$this->addSelect('bezeichnung_mehrsprachig' . $lang . ' AS bezeichnung');
|
||||
$this->addSelect('beschreibung' . $lang . ' AS beschreibung');
|
||||
|
||||
$this->addOrder('bezeichnung_mehrsprachig' . $lang);
|
||||
|
||||
return $this->loadWhere([
|
||||
'aktiv' => true
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<?php
|
||||
|
||||
use \InvalidArgumentException as InvalidArgumentException;
|
||||
use \CI3_Events as Events;
|
||||
|
||||
class Student_model extends DB_Model
|
||||
{
|
||||
|
||||
@@ -43,9 +47,169 @@ class Student_model extends DB_Model
|
||||
$max = 0;
|
||||
|
||||
$max += 1;
|
||||
|
||||
return $matrikelnummer.sprintf("%03d", $max);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generiert die Matrikelnummer
|
||||
* FORMAT: 0710254001
|
||||
* 07 = Jahr
|
||||
* 1/2/0 = WS/SS/incoming
|
||||
* 0254 = Studiengangskennzahl vierstellig
|
||||
* 001 = Laufende Nummer
|
||||
* copy of generateMatrikelnummer plus
|
||||
* logic FH Burgenland
|
||||
*
|
||||
* TODO(chris): replace function above with this?
|
||||
* TODO(chris): rename to generatePersonenkennzeichen?
|
||||
*
|
||||
* @param integer $studiengang_kz
|
||||
* @param string $studiensemester_kurzbz
|
||||
* @param string $typ
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function generateMatrikelnummer2($studiengang_kz, $studiensemester_kurzbz, $typ = null)
|
||||
{
|
||||
$personenkennzeichen = false;
|
||||
|
||||
Events::trigger(
|
||||
'generate_personenkennzeichen',
|
||||
function ($value) use ($personenkennzeichen) {
|
||||
$personenkennzeichen = $value;
|
||||
},
|
||||
$studiengang_kz,
|
||||
$studiensemester_kurzbz,
|
||||
$typ
|
||||
);
|
||||
|
||||
if ($personenkennzeichen !== false)
|
||||
return success($personenkennzeichen);
|
||||
|
||||
// Validierung der Eingabewerte
|
||||
if (strlen($studiensemester_kurzbz) < 6) {
|
||||
throw new InvalidArgumentException("Ungültiges studiensemester_kurzbz Format.");
|
||||
}
|
||||
|
||||
$jahr = mb_substr($studiensemester_kurzbz, 4);
|
||||
$art = substr($studiensemester_kurzbz, 0, 2);
|
||||
|
||||
if (($studiengang_kz < 0) || (isset($typ) && ($typ == 'l')))
|
||||
{
|
||||
$studiengang_kz=abs($studiengang_kz);
|
||||
//Lehrgang
|
||||
switch($art)
|
||||
{
|
||||
case 'WS':
|
||||
$art = '3';
|
||||
break;
|
||||
case 'SS':
|
||||
$art = '4';
|
||||
break;
|
||||
default:
|
||||
$art = '0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Studiengang
|
||||
switch($art)
|
||||
{
|
||||
case 'WS':
|
||||
$art = '1';
|
||||
break;
|
||||
case 'SS':
|
||||
$art = '2';
|
||||
break;
|
||||
default:
|
||||
$art = '0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($art=='2' || $art=='4')
|
||||
$jahr = $jahr-1;
|
||||
|
||||
//FH-Burgenland - weil leider die AO Studiengänge aufgeteilt sind
|
||||
//(AO sind normal 9+erhalter Nummer, matrikelnr/personenkz wird auch im DVUH Extension berücksichtigt)
|
||||
if ($studiengang_kz >= 90010 && $studiengang_kz <= 90019)
|
||||
{
|
||||
$matrikelnummer = sprintf("%02d", $jahr).$art.substr($studiengang_kz, 0, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
$matrikelnummer = sprintf("%02d", $jahr).$art.sprintf("%04d", $studiengang_kz);
|
||||
}
|
||||
|
||||
$qry = "SELECT matrikelnr FROM public.tbl_student WHERE matrikelnr LIKE ? ORDER BY matrikelnr DESC LIMIT 1";
|
||||
$matrikelnrres = $this->execQuery($qry, array($matrikelnummer.'%'));
|
||||
|
||||
$max = 0;
|
||||
if ($matrikelnrres && hasData($matrikelnrres)) {
|
||||
$max = mb_substr($matrikelnrres->retval[0]->matrikelnr, 7);
|
||||
if (!is_numeric($max)) {
|
||||
$max = (int)$max;
|
||||
}
|
||||
}
|
||||
|
||||
$max += 1;
|
||||
return success($matrikelnummer.sprintf("%03d", $max));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generiert die UID
|
||||
* FORMAT: el07b001
|
||||
* $stgkzl: el = studiengangskuerzel
|
||||
* $jahr: 07 = Jahr
|
||||
* $stgtyp: b/m/d/x = Bachelor/Master/Diplom/Incoming
|
||||
* $matrikelnummer
|
||||
* 001 = Laufende Nummer Wenn StSem==SS dann wird zur Nummer 500 dazugezaehlt
|
||||
* Bei Incoming im Masterstudiengang wird auch 500 dazugezaehlt
|
||||
*
|
||||
* @param string $stgkzl
|
||||
* @param string $jahr
|
||||
* @param string $stgtyp
|
||||
* @param string $matrikelnummer
|
||||
* @param string $vorname
|
||||
* @param string $nachname
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function generateUID($stgkzl, $jahr, $stgtyp, $matrikelnummer, $vorname, $nachname)
|
||||
{
|
||||
$uid = false;
|
||||
|
||||
Events::trigger(
|
||||
'generate_student_uid',
|
||||
function ($value) use ($uid) {
|
||||
$uid = $value;
|
||||
},
|
||||
$stgkzl,
|
||||
$jahr,
|
||||
$stgtyp,
|
||||
$matrikelnummer,
|
||||
$vorname,
|
||||
$nachname
|
||||
);
|
||||
|
||||
if ($uid !== false)
|
||||
return success($uid);
|
||||
|
||||
$art = mb_substr($matrikelnummer, 2, 1);
|
||||
$nr = mb_substr($matrikelnummer, mb_strlen(trim($matrikelnummer))-3);
|
||||
if($art=='2') //Sommersemester
|
||||
$nr = $nr+500;
|
||||
elseif($art=='0' && $stgtyp=='m') //Incoming im Masterstudiengang
|
||||
$nr = $nr+500;
|
||||
elseif($art=='4' && $stgtyp=='l') // Lehrgangsteilnehmer im Sommersemester
|
||||
$nr = $nr+500;
|
||||
|
||||
|
||||
return success(mb_strtolower($stgkzl.$jahr.($art!='0'?$stgtyp:'x').$nr));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get students UID by PrestudentID.
|
||||
* @param $prestudent_id
|
||||
@@ -78,7 +242,8 @@ class Student_model extends DB_Model
|
||||
OR lower(person.nachname) like ".$this->db->escape('%'.$filter.'%')."
|
||||
OR lower(person.vorname) like ".$this->db->escape('%'.$filter.'%')."
|
||||
OR lower(person.nachname || ' ' || person.vorname) like ".$this->db->escape('%'.$filter.'%')."
|
||||
OR lower(person.vorname || ' ' || person.nachname) like ".$this->db->escape('%'.$filter.'%'));
|
||||
OR lower(person.vorname || ' ' || person.nachname) like ".$this->db->escape('%'.$filter.'%')
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Gsstudientyp_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'bis.tbl_gsstudientyp';
|
||||
$this->pk = 'gsstudientyp_kurzbz';
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,297 @@ class Lehrveranstaltung_model extends DB_Model
|
||||
$this->load->model('organisation/studiensemester_model', 'StudiensemesterModel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Lehrveranstaltungen by eventQuery string. Use with autocomplete event queries.
|
||||
* @param $eventQuery String
|
||||
* @param string $studiensemester_kurzbz Filter by Studiensemester
|
||||
* @param array $oes Filter by Organisationseinheiten
|
||||
* @return array
|
||||
*/
|
||||
public function getAutocompleteSuggestions($eventQuery, $studiensemester_kurzbz = null, $oes = null)
|
||||
{
|
||||
$subQry = $this->_getQryLvsByStudienplan($studiensemester_kurzbz, $oes);
|
||||
$params = [];
|
||||
|
||||
/* filter by input string */
|
||||
if (is_string($eventQuery)) {
|
||||
$subQry.= ' AND lv.bezeichnung ILIKE ?';
|
||||
$params[] = '%' . $eventQuery . '%';
|
||||
}
|
||||
|
||||
$qry = 'SELECT DISTINCT ON (lehrveranstaltung_id) * FROM ('. $subQry. ') AS tmp';
|
||||
|
||||
return $this->execQuery($qry, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Lehrveranstaltungen with its Stg, OE and OE-type.
|
||||
* Filter by Studiensemester and Organisationseinheiten if necessary.
|
||||
* @param $eventQuery String
|
||||
* @param string $studiensemester_kurzbz Filter by Studiensemester
|
||||
* @param array $oes Filter by Organisationseinheiten
|
||||
* @param array $lv_ids Filter by Lehrveranstaltung-Ids
|
||||
* @return array
|
||||
*/
|
||||
public function getLvsByStudienplan($studiensemester_kurzbz = null, $oes = null, $lv_ids = null)
|
||||
{
|
||||
$subQry = $this->_getQryLvsByStudienplan($studiensemester_kurzbz, $oes);
|
||||
$qry = 'SELECT * FROM ('. $subQry. ') AS tmp';
|
||||
|
||||
if (isset($lv_ids) && is_array($lv_ids))
|
||||
{
|
||||
/* filter by lv_ids */
|
||||
$implodedLvIds = "'". implode("', '", $lv_ids). "'";
|
||||
$qry.= ' WHERE lehrveranstaltung_id IN ('. $implodedLvIds. ')';
|
||||
}
|
||||
|
||||
$qry.= ' ORDER BY stg_typ_kurzbz, orgform_kurzbz DESC';
|
||||
|
||||
return $this->execQuery($qry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get basic query to retrieve Lehrveranstaltungen according to the Orgforms and Ausbildungssemesters actual Studienplan.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _getQryLvsByStudienplan($studiensemester_kurzbz = null, $oes = null, $lehrtyp_kurzbz = 'lv')
|
||||
{
|
||||
$qry = '
|
||||
SELECT
|
||||
lv.oe_kurzbz AS lv_oe_kurzbz,
|
||||
CASE
|
||||
WHEN oe.organisationseinheittyp_kurzbz = \'Kompetenzfeld\' THEN (\'KF \' || oe.bezeichnung)
|
||||
WHEN oe.organisationseinheittyp_kurzbz = \'Department\' THEN (\'DEP \' || oe.bezeichnung)
|
||||
ELSE (oe.organisationseinheittyp_kurzbz || \' \' || oe.bezeichnung)
|
||||
END AS lv_oe_bezeichnung,
|
||||
stplsem.studiensemester_kurzbz,
|
||||
studienordnung_id,
|
||||
sto.studiengang_kz,
|
||||
stpl.studienplan_id,
|
||||
stplsem.semester,
|
||||
stpl.orgform_kurzbz,
|
||||
upper(stg.typ || stg.kurzbz) AS stg_typ_kurzbz,
|
||||
stg.bezeichnung AS stg_bezeichnung,
|
||||
stgtyp.bezeichnung AS stg_typ_bezeichnung,
|
||||
lv.lehrveranstaltung_id,
|
||||
lv.semester,
|
||||
lv.bezeichnung AS lv_bezeichnung,
|
||||
(
|
||||
-- comma seperated string of all lehreinheitgruppen
|
||||
SELECT string_agg(bezeichnung, \', \') AS lehreinheitgruppe_bezeichnung
|
||||
FROM(
|
||||
-- distinct bezeichnung, as may come multiple times from different lehreinheiten
|
||||
SELECT DISTINCT ON (studiengang_kz, bezeichnung) studiengang_kz, bezeichnung FROM
|
||||
(
|
||||
-- distinct lehreinheitgruppe, as may come multiple times from different lehrform
|
||||
SELECT DISTINCT ON (legr.lehreinheitgruppe_id) legr.studiengang_kz,
|
||||
-- get Spezialgruppe or Lehrverbandgruppe
|
||||
COALESCE(
|
||||
legr.gruppe_kurzbz,
|
||||
CONCAT( UPPER(stg1.typ), UPPER(stg1.kurzbz), \'-\', legr.semester, legr.verband, legr.gruppe )
|
||||
) as bezeichnung
|
||||
FROM lehre.tbl_lehreinheitgruppe legr
|
||||
JOIN lehre.tbl_lehreinheit le USING (lehreinheit_id)
|
||||
JOIN lehre.tbl_lehrveranstaltung lv1 USING (lehrveranstaltung_id)
|
||||
JOIN public.tbl_studiengang stg1 ON stg1.studiengang_kz = legr.studiengang_kz
|
||||
WHERE lv1.lehrveranstaltung_id = lv.lehrveranstaltung_id
|
||||
AND le.studiensemester_kurzbz = stplsem.studiensemester_kurzbz
|
||||
) AS lehreinheitgruppen
|
||||
GROUP BY studiengang_kz, bezeichnung
|
||||
ORDER BY studiengang_kz DESC
|
||||
) AS uniqueLehreinheitgruppen_bezeichnung
|
||||
) AS lehreinheitgruppen_bezeichnung
|
||||
FROM
|
||||
lehre.tbl_studienplan stpl
|
||||
JOIN lehre.tbl_studienordnung sto USING (studienordnung_id)
|
||||
JOIN lehre.tbl_studienplan_semester stplsem USING (studienplan_id)
|
||||
JOIN lehre.tbl_studienplan_lehrveranstaltung stpllv ON (stpllv.studienplan_id = stpl.studienplan_id AND stpllv.semester = stplsem.semester)
|
||||
JOIN lehre.tbl_lehrveranstaltung lv USING (lehrveranstaltung_id)
|
||||
JOIN public.tbl_organisationseinheit oe USING (oe_kurzbz)
|
||||
JOIN public.tbl_studiengang stg ON stg.studiengang_kz = sto.studiengang_kz
|
||||
JOIN public.tbl_studiengangstyp stgtyp ON stgtyp.typ = stg.typ
|
||||
/* filter by lehrtyp_kurzbz, default is lvs only */
|
||||
WHERE
|
||||
lehrtyp_kurzbz = '. $this->db->escape($lehrtyp_kurzbz);
|
||||
|
||||
if (isset($studiensemester_kurzbz) && is_string($studiensemester_kurzbz))
|
||||
{
|
||||
/* filter by studiensemester */
|
||||
$qry.= ' AND stplsem.studiensemester_kurzbz = '. $this->db->escape($studiensemester_kurzbz);
|
||||
|
||||
}
|
||||
|
||||
if (isset($oes) && is_array($oes))
|
||||
{
|
||||
/* filter by organisationseinheit */
|
||||
$implodedOes = "'". implode("', '", $oes). "'";
|
||||
$qry.= ' AND lv.oe_kurzbz IN ('. $implodedOes. ')';
|
||||
}
|
||||
|
||||
return $qry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Templates and union with all Lehrveranstaltungen of given Studiensemester and Oes, that are assigned to
|
||||
* a template. This data structure can be used for nested tabulator data tree.
|
||||
*
|
||||
* @param null|string $studiensemester_kurzbz
|
||||
* @param null|array $oes
|
||||
* @return array|stdClass|null
|
||||
*/
|
||||
public function getTemplateLvTree($studiensemester_kurzbz = null, $oes = null){
|
||||
$params = [];
|
||||
$qry = '
|
||||
WITH
|
||||
-- All Lvs that are assigned to a template in given Studiensemester for given Oes
|
||||
-- joining via actual Studienplan
|
||||
standardisierteLvs AS (
|
||||
SELECT
|
||||
lv.*,
|
||||
stpl.studienplan_id::text as studienplan_id,
|
||||
stpl.bezeichnung AS studienplan_bezeichnung,
|
||||
stplsem.studiensemester_kurzbz
|
||||
FROM
|
||||
lehre.tbl_studienplan stpl
|
||||
JOIN lehre.tbl_studienordnung sto USING (studienordnung_id)
|
||||
JOIN lehre.tbl_studienplan_semester stplsem USING (studienplan_id)
|
||||
JOIN lehre.tbl_studienplan_lehrveranstaltung stpllv ON (stpllv.studienplan_id = stpl.studienplan_id AND stpllv.semester = stplsem.semester)
|
||||
JOIN lehre.tbl_lehrveranstaltung lv USING (lehrveranstaltung_id)
|
||||
JOIN public.tbl_organisationseinheit oe USING (oe_kurzbz)
|
||||
JOIN public.tbl_studiengang stg ON stg.studiengang_kz = sto.studiengang_kz
|
||||
JOIN public.tbl_studiengangstyp stgtyp ON stgtyp.typ = stg.typ
|
||||
WHERE
|
||||
-- filter type lv
|
||||
lehrtyp_kurzbz = \'lv\'
|
||||
-- filter lvs assigned to template (= standardisierte lv)
|
||||
AND lehrveranstaltung_template_id IS NOT NULL';
|
||||
|
||||
if (is_string($studiensemester_kurzbz))
|
||||
{
|
||||
/* filter by studiensemester */
|
||||
$params[]= $studiensemester_kurzbz;
|
||||
$qry.= ' AND stplsem.studiensemester_kurzbz = ? ';
|
||||
|
||||
}
|
||||
|
||||
if (is_array($oes))
|
||||
{
|
||||
/* filter by organisationseinheit */
|
||||
$params[]= $oes;
|
||||
$qry.= ' AND lv.oe_kurzbz IN ? ';
|
||||
}
|
||||
$qry.= '
|
||||
),
|
||||
-- All templates
|
||||
templateLvs AS (
|
||||
SELECT
|
||||
lv.*,
|
||||
NULL AS studienplan_id,
|
||||
(
|
||||
SELECT string_agg(stpl_bezeichnung, \', \')
|
||||
FROM
|
||||
(
|
||||
SELECT stlv.studienplan_bezeichnung AS stpl_bezeichnung
|
||||
FROM standardisierteLvs stlv
|
||||
WHERE stlv.lehrveranstaltung_template_id = lv.lehrveranstaltung_id
|
||||
) AS studienplaene
|
||||
) AS studienplan_bezeichnung,
|
||||
NULL AS studiensemester_kurzbz
|
||||
FROM
|
||||
lehre.tbl_lehrveranstaltung lv
|
||||
WHERE
|
||||
-- filter type template
|
||||
lehrtyp_kurzbz = \'tpl\'
|
||||
-- filter semester that were retrieved by standardisierte lvs semester for selected studiensemester
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM standardisierteLvs std
|
||||
WHERE std.lehrveranstaltung_template_id = lv.lehrveranstaltung_id
|
||||
)';
|
||||
|
||||
if (is_array($oes))
|
||||
{
|
||||
/* filter by organisationseinheit */
|
||||
$params[]= $oes;
|
||||
$qry.= ' AND lv.oe_kurzbz IN ? ';
|
||||
}
|
||||
$qry.= '
|
||||
)
|
||||
';
|
||||
|
||||
$qry.= '
|
||||
SELECT
|
||||
lv.lehrveranstaltung_id,
|
||||
lv.kurzbz,
|
||||
lv.lehrtyp_kurzbz,
|
||||
lv.bezeichnung AS lv_bezeichnung,
|
||||
lv.bezeichnung_english,
|
||||
lv.studiengang_kz,
|
||||
lv.semester,
|
||||
lv.oe_kurzbz,
|
||||
lv.ects,
|
||||
lv.lehrform_kurzbz,
|
||||
lv.orgform_kurzbz,
|
||||
lv.sprache,
|
||||
lv.aktiv,
|
||||
lv.lehrveranstaltung_template_id,
|
||||
lv.studienplan_id,
|
||||
lv.studienplan_bezeichnung,
|
||||
lv.studiensemester_kurzbz,
|
||||
upper(stg.typ || stg.kurzbz) AS "stg_typ_kurzbz",
|
||||
stg.bezeichnung AS "stg_bezeichnung",
|
||||
stgtyp.bezeichnung AS "stg_typ_bezeichnung",
|
||||
CASE
|
||||
WHEN oe.organisationseinheittyp_kurzbz = \'Kompetenzfeld\' THEN (\'KF \' || oe.bezeichnung)
|
||||
WHEN oe.organisationseinheittyp_kurzbz = \'Department\' THEN (\'DEP \' || oe.bezeichnung)
|
||||
ELSE (oe.organisationseinheittyp_kurzbz || \' \' || oe.bezeichnung)
|
||||
END AS "lv_oe_bezeichnung",
|
||||
(
|
||||
-- comma seperated string of all lehreinheitgruppen
|
||||
SELECT string_agg(bezeichnung, \', \') AS lehreinheitgruppe_bezeichnung
|
||||
FROM(
|
||||
-- distinct bezeichnung, as may come multiple times from different lehreinheiten
|
||||
SELECT DISTINCT ON (studiengang_kz, bezeichnung) studiengang_kz, bezeichnung FROM
|
||||
(
|
||||
-- distinct lehreinheitgruppe, as may come multiple times from different lehrform
|
||||
SELECT DISTINCT ON (legr.lehreinheitgruppe_id) legr.studiengang_kz,
|
||||
-- get Spezialgruppe or Lehrverbandgruppe
|
||||
COALESCE(
|
||||
legr.gruppe_kurzbz,
|
||||
CONCAT( UPPER(stg1.typ), UPPER(stg1.kurzbz), \'-\', legr.semester, legr.verband, legr.gruppe )
|
||||
) as bezeichnung
|
||||
FROM lehre.tbl_lehreinheitgruppe legr
|
||||
JOIN lehre.tbl_lehreinheit le USING (lehreinheit_id)
|
||||
JOIN lehre.tbl_lehrveranstaltung lv1 USING (lehrveranstaltung_id)
|
||||
JOIN public.tbl_studiengang stg1 ON stg1.studiengang_kz = legr.studiengang_kz
|
||||
WHERE lv1.lehrveranstaltung_id = lv.lehrveranstaltung_id
|
||||
AND le.studiensemester_kurzbz = lv.studiensemester_kurzbz
|
||||
) AS lehreinheitgruppen
|
||||
GROUP BY studiengang_kz, bezeichnung
|
||||
ORDER BY studiengang_kz DESC
|
||||
) AS uniqueLehreinheitgruppen_bezeichnung
|
||||
) AS lehreinheitgruppen_bezeichnung
|
||||
FROM (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
standardisierteLvs
|
||||
UNION
|
||||
SELECT
|
||||
*
|
||||
FROM templateLvs
|
||||
) AS lv
|
||||
JOIN public.tbl_studiengang stg ON stg.studiengang_kz = lv.studiengang_kz
|
||||
JOIN public.tbl_studiengangstyp stgtyp ON stgtyp.typ = stg.typ
|
||||
JOIN public.tbl_organisationseinheit oe ON oe.oe_kurzbz = lv.oe_kurzbz
|
||||
ORDER BY
|
||||
oe.bezeichnung, lv.semester, lv.bezeichnung
|
||||
';
|
||||
|
||||
return $this->execQuery($qry, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets unique Groupstrings for Lehrveranstaltungen, e.g. WS2018_BIF_1_PRJM_VZ_LV12345
|
||||
* @param string $studiensemester_kurzbz
|
||||
@@ -493,4 +784,11 @@ class Lehrveranstaltung_model extends DB_Model
|
||||
|
||||
return $this->execQuery($qry, array($student_uid));
|
||||
}
|
||||
|
||||
public function getStg($lehrveranstaltung_id)
|
||||
{
|
||||
$this->addSelect('stg.*');
|
||||
$this->addJoin('public.tbl_studiengang stg', 'studiengang_kz');
|
||||
return $this->load($lehrveranstaltung_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,5 +10,6 @@ class Lvgesamtnote_model extends DB_Model
|
||||
parent::__construct();
|
||||
$this->dbTable = 'campus.tbl_lvgesamtnote';
|
||||
$this->pk = array('student_uid', 'studiensemester_kurzbz', 'lehrveranstaltung_id');
|
||||
$this->hasSequence = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class Paabgabe_model extends DB_Model
|
||||
WHERE projektarbeit_id = ?
|
||||
AND paabgabetyp_kurzbz = 'end'
|
||||
AND paabg.abgabedatum IS NOT NULL
|
||||
ORDER BY paabg.abgabedatum, paabg.datum DESC
|
||||
ORDER BY paabg.abgabedatum DESC, paabg.datum DESC
|
||||
LIMIT 1";
|
||||
|
||||
return $this->execQuery($qry, array($projektarbeit_id));
|
||||
|
||||
@@ -175,6 +175,8 @@ class Pruefung_model extends DB_Model
|
||||
$this->addSelect('campus.get_status_studierendenantrag(a.studierendenantrag_id) status');
|
||||
$this->addSelect('pss.ausbildungssemester');
|
||||
|
||||
$this->addJoin('(SELECT MAX(datum) AS datum, lehreinheit_id AS le_id, student_uid AS stud_uid FROM lehre.tbl_pruefung p WHERE pruefungstyp_kurzbz IN (\'kommPruef\', \'zusKommPruef\') GROUP BY lehreinheit_id, student_uid) lpd',
|
||||
'p.datum = lpd.datum AND p.lehreinheit_id = lpd.le_id AND p.student_uid = lpd.stud_uid');
|
||||
$this->addJoin('lehre.tbl_lehreinheit le', 'lehreinheit_id');
|
||||
$this->addJoin('lehre.tbl_lehrveranstaltung lv', 'lehrveranstaltung_id');
|
||||
$this->addJoin('public.tbl_student s', 'student_uid');
|
||||
|
||||
@@ -11,5 +11,7 @@ class Studentlehrverband_model extends DB_Model
|
||||
$this->dbTable = 'public.tbl_studentlehrverband';
|
||||
$this->pk = array('studiensemester_kurzbz', 'student_uid');
|
||||
$this->hasSequence = false;
|
||||
|
||||
$this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ class Studierendenantrag_model extends DB_Model
|
||||
$this->addSelect('studienjahr_kurzbz');
|
||||
$this->addSelect('vorname');
|
||||
$this->addSelect('nachname');
|
||||
$this->addSelect('unruly');
|
||||
$this->addSelect('p.prestudent_id');
|
||||
$this->addSelect('p.studiengang_kz');
|
||||
$this->addSelect('semester');
|
||||
@@ -96,7 +97,8 @@ class Studierendenantrag_model extends DB_Model
|
||||
Studierendenantragstatus_model::STATUS_REJECTED,
|
||||
Studierendenantragstatus_model::STATUS_OBJECTION_DENIED,
|
||||
Studierendenantragstatus_model::STATUS_DEREGISTERED,
|
||||
Studierendenantragstatus_model::STATUS_PAUSE
|
||||
Studierendenantragstatus_model::STATUS_PAUSE,
|
||||
Studierendenantragstatus_model::STATUS_REMINDERSENT
|
||||
]);
|
||||
$this->db->or_group_start();
|
||||
$this->db->where('s.studierendenantrag_statustyp_kurzbz', Studierendenantragstatus_model::STATUS_APPROVED);
|
||||
@@ -148,6 +150,7 @@ class Studierendenantrag_model extends DB_Model
|
||||
$this->addSelect('s.studierendenantrag_statustyp_kurzbz status');
|
||||
$this->addSelect('s.insertvon status_insertvon');
|
||||
$this->addSelect('t.bezeichnung[(' . $lang . ')] statustyp');
|
||||
$this->addSelect('p.unruly AS unruly');
|
||||
|
||||
$this->addJoin(
|
||||
'campus.tbl_studierendenantrag_status s',
|
||||
@@ -157,6 +160,18 @@ class Studierendenantrag_model extends DB_Model
|
||||
'campus.tbl_studierendenantrag_statustyp t',
|
||||
's.studierendenantrag_statustyp_kurzbz=t.studierendenantrag_statustyp_kurzbz'
|
||||
);
|
||||
$this->addJoin(
|
||||
'public.tbl_student st',
|
||||
'st.prestudent_id=tbl_studierendenantrag.prestudent_id'
|
||||
);
|
||||
$this->addJoin(
|
||||
'public.tbl_benutzer b',
|
||||
'st.student_uid=b.uid'
|
||||
);
|
||||
$this->addJoin(
|
||||
'public.tbl_person p',
|
||||
'b.person_id=p.person_id'
|
||||
);
|
||||
|
||||
if ($types && is_array($types)) {
|
||||
$this->db->where_in('typ', $types);
|
||||
@@ -354,7 +369,7 @@ class Studierendenantrag_model extends DB_Model
|
||||
$this->db->where([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'typ' => Studierendenantrag_model::TYP_UNTERBRECHUNG,
|
||||
'campus.get_status_studierendenantrag(studierendenantrag_id) !=' => Studierendenantragstatus_model::STATUS_CANCELLED,
|
||||
'campus.get_status_studierendenantrag(studierendenantrag_id) NOT IN (\'' . Studierendenantragstatus_model::STATUS_CANCELLED . '\', \'' . Studierendenantragstatus_model::STATUS_REJECTED . '\')' => null,
|
||||
'start < ' . $end => null,
|
||||
'datum_wiedereinstieg > ' . $start => null,
|
||||
]);
|
||||
@@ -410,7 +425,7 @@ class Studierendenantrag_model extends DB_Model
|
||||
FROM campus.tbl_studierendenantrag
|
||||
LEFT JOIN public.tbl_studiensemester USING(studiensemester_kurzbz)
|
||||
WHERE typ=?
|
||||
AND campus.get_status_studierendenantrag(studierendenantrag_id) != ?
|
||||
AND campus.get_status_studierendenantrag(studierendenantrag_id) NOT IN ?
|
||||
AND prestudent_id=?
|
||||
) a ON (s.start < a.ende AND s.ende > a.start)
|
||||
WHERE s.start >= (" . $subquery . ")
|
||||
@@ -420,7 +435,10 @@ class Studierendenantrag_model extends DB_Model
|
||||
return $this->execQuery($sql, [
|
||||
$max_length,
|
||||
self::TYP_UNTERBRECHUNG,
|
||||
Studierendenantragstatus_model::STATUS_CANCELLED,
|
||||
array(
|
||||
Studierendenantragstatus_model::STATUS_CANCELLED,
|
||||
Studierendenantragstatus_model::STATUS_REJECTED
|
||||
),
|
||||
$prestudent_id,
|
||||
$studiensemester ?: $prestudent_id,
|
||||
$max_length * $max_starters
|
||||
@@ -471,4 +489,4 @@ class Studierendenantrag_model extends DB_Model
|
||||
|
||||
return hasData($this->load());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,11 +32,20 @@ class Geschaeftsjahr_model extends DB_Model
|
||||
* Gets next Geschaeftsjahr, as determined by its start date
|
||||
* @return array|null
|
||||
*/
|
||||
public function getNextGeschaeftsjahr()
|
||||
public function getNextGeschaeftsjahr($offsetDays=null)
|
||||
{
|
||||
$query = 'SELECT *
|
||||
FROM public.tbl_geschaeftsjahr
|
||||
WHERE start > now()
|
||||
FROM public.tbl_geschaeftsjahr WHERE ';
|
||||
|
||||
if(!is_null($offsetDays))
|
||||
{
|
||||
$query .= "start > now() - '".$offsetDays." days'::interval";
|
||||
}
|
||||
else
|
||||
{
|
||||
$query .= 'start > now()';
|
||||
}
|
||||
$query .= '
|
||||
ORDER BY start
|
||||
LIMIT 1';
|
||||
|
||||
|
||||
@@ -11,4 +11,34 @@ class Lehrverband_model extends DB_Model
|
||||
$this->dbTable = 'public.tbl_lehrverband';
|
||||
$this->pk = array('gruppe', 'verband', 'semester', 'studiengang_kz');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum possible semester for one or more Studiengaenge.
|
||||
* If there are more than one Studiengang each maximum is calculated and
|
||||
* the smallest result is returned.
|
||||
*
|
||||
* @param array $studiengang_kzs
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getMaxSemester($studiengang_kzs)
|
||||
{
|
||||
$sqls = [];
|
||||
foreach ($studiengang_kzs as $studiengang_kz) {
|
||||
$this->addSelect('MAX(semester) AS maxsem');
|
||||
$this->db->where('studiengang_kz', $studiengang_kz);
|
||||
$sqls[] = $this->db->get_compiled_select($this->dbTable);
|
||||
}
|
||||
|
||||
$this->addSelect('MIN(a.maxsem) AS maxsem');
|
||||
|
||||
$dbTable = $this->dbTable;
|
||||
$this->dbTable = '(' . implode(' UNION ', $sqls) . ') AS a';
|
||||
|
||||
$result = $this->load();
|
||||
|
||||
$this->dbTable = $dbTable;
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,4 +188,20 @@ class Organisationseinheit_model extends DB_Model
|
||||
}
|
||||
return $this->loadWhere($condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OEs by eventQuery string. Use with autocomplete event queries.
|
||||
* @param $eventQuery String
|
||||
* @return array
|
||||
*/
|
||||
public function getAutocompleteSuggestions($eventQuery)
|
||||
{
|
||||
$this->addSelect('oe_kurzbz');
|
||||
$this->addSelect('organisationseinheittyp_kurzbz, oe_kurzbz, bezeichnung, aktiv, lehre');
|
||||
$this->addOrder('organisationseinheittyp_kurzbz, bezeichnung');
|
||||
|
||||
return $this->loadWhere("
|
||||
oe_kurzbz ILIKE '%". $this->escapeLike($eventQuery). "%'
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,29 @@ class Standort_model extends DB_Model
|
||||
$this->dbTable = 'public.tbl_standort';
|
||||
$this->pk = 'standort_id';
|
||||
}
|
||||
|
||||
public function searchStandorte($filter)
|
||||
{
|
||||
$filter = strtoLower($filter);
|
||||
$qry = "
|
||||
SELECT
|
||||
s.kurzbz, s.standort_id
|
||||
FROM
|
||||
public.tbl_standort s
|
||||
WHERE
|
||||
lower (s.kurzbz) LIKE '%". $this->db->escape_like_str($filter)."%'
|
||||
OR
|
||||
lower (s.bezeichnung) LIKE '%". $this->db->escape_like_str($filter)."%'";
|
||||
|
||||
|
||||
return $this->execQuery($qry);
|
||||
}
|
||||
|
||||
public function getStandorteByFirma($firma_id)
|
||||
{
|
||||
$this->addSelect("DISTINCT ON (standort_id) bezeichnung, standort_id");
|
||||
|
||||
return $this->loadWhere(array("firma_id" => $firma_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -563,7 +563,7 @@ class Studiengang_model extends DB_Model
|
||||
$this->addJoin('public.tbl_student stud', 'p.prestudent_id=stud.prestudent_id', 'LEFT');
|
||||
|
||||
$this->db->where_in($this->dbTable . '.studiengang_kz', $studiengang_kzs);
|
||||
$this->db->where_in('ps.status_kurzbz', $this->config->item('antrag_prestudentstatus_whitelist'));
|
||||
$this->db->where_in('ps.status_kurzbz', $this->config->item('antrag_prestudentstatus_whitelist_abmeldung'));
|
||||
$this->db->where($this->dbTable . ".aktiv", true);
|
||||
|
||||
if ($not_antrag_typ !== null && is_array($not_antrag_typ)) {
|
||||
|
||||
@@ -29,4 +29,54 @@ class Studienjahr_model extends DB_Model
|
||||
|
||||
return $this->execQuery($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current Studienjahr. During the summer term, continue using the previous Studienjahr.
|
||||
*
|
||||
* @param int $days
|
||||
* @return array|stdClass|null
|
||||
*/
|
||||
public function getLastOrAktStudienjahr($days = 60)
|
||||
{
|
||||
if (!is_numeric($days))
|
||||
{
|
||||
$days = 60;
|
||||
}
|
||||
|
||||
$query = '
|
||||
SELECT *
|
||||
FROM public.tbl_studienjahr
|
||||
JOIN public.tbl_studiensemester USING (studienjahr_kurzbz)
|
||||
WHERE start < NOW() - \'' . $days . ' DAYS\'::INTERVAL
|
||||
ORDER by start DESC
|
||||
LIMIT 1
|
||||
';
|
||||
|
||||
return $this->execQuery($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current Studienjahr. During the summer term, get the upcoming next Studienjahr.
|
||||
*
|
||||
* @param int $days
|
||||
* @return array|stdClass|null
|
||||
*/
|
||||
public function getAktOrNextStudienjahr($days = 62)
|
||||
{
|
||||
if (!is_numeric($days))
|
||||
{
|
||||
$days = 62;
|
||||
}
|
||||
|
||||
$query = '
|
||||
SELECT *
|
||||
FROM public.tbl_studienjahr
|
||||
JOIN public.tbl_studiensemester using(studienjahr_kurzbz)
|
||||
WHERE start < NOW() + \'' . $days . ' DAYS\'::INTERVAL
|
||||
ORDER by start DESC
|
||||
LIMIT 1
|
||||
';
|
||||
|
||||
return $this->execQuery($query);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user