Compare commits
3090 Commits
v0.1-beta
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d86bc9253f | ||
| 3c94239da7 | |||
| 7e6c8224a5 | |||
| 8bc1289206 | |||
| 75390f10cd | |||
| 7468e63299 | |||
| 4c88de77a7 | |||
| c7502b853c | |||
| 249ab13004 | |||
| fce67286fd | |||
| f841639ec3 | |||
| c270017111 | |||
| 0ee317b0fc | |||
| f606b9cdd5 | |||
| 412b4d6794 | |||
| c045cabcf7 | |||
| f5adc203f3 | |||
| f3362bab00 | |||
| 268e2fdbee | |||
| 6d38e6fc8c | |||
| 99ff081b05 | |||
| 5b88887f53 | |||
| 669f716112 | |||
| addd34cb82 | |||
| c77a6e7af6 | |||
| 28ca917d5d | |||
| 1196abb0a0 | |||
| 68560e4e35 | |||
| a4eb7b9ad3 | |||
| 35591ab04c | |||
| 339b1063c6 | |||
| 83592117d1 | |||
| ff1e396fbc | |||
| 5471ccfa17 | |||
| c0aa379d37 | |||
| 3da0cec4a1 | |||
| bca5179cc3 | |||
| c075112810 | |||
| 57d01028cf | |||
| bef633434c | |||
| 6afba02675 | |||
| 4ac1ef0e73 | |||
| 0b0faf26d2 | |||
| d49695e7e8 | |||
| 0e96905213 | |||
| 57d9d4b99b | |||
| f77e6874d0 | |||
| daa72ff60c | |||
| 8bd44c10b8 | |||
| f4c77eee00 | |||
| 5b11c5b629 | |||
| 2e1f28c8c5 | |||
| 7bc2b82837 | |||
| f6f73cbb94 | |||
| 411b005dee | |||
| aacf2fc830 | |||
| e498a2b202 | |||
| 3853a81fba | |||
| 7b26a021e1 | |||
| b310799bf0 | |||
| 1a44be502a | |||
| 103a41c0ff | |||
| 9e5e3720b5 | |||
| baf7c2130e | |||
| c889960805 | |||
| 9462aea45f | |||
| f26ba1d75c | |||
| 2d575dd86b | |||
| 5db70758cb | |||
| 8f2036eecc | |||
| 083422047c | |||
| dda65951b3 | |||
| dbd30021f9 | |||
| c69416ee88 | |||
| 03b0c71708 | |||
| d4214ee4bf | |||
| c70999100b | |||
| eceac30f4b | |||
| 736eb6feba | |||
| cd0710c428 | |||
| bd03a983a2 | |||
| 4c3896cbee | |||
| c362de7589 | |||
| c17af03ef3 | |||
| 2fbf72df61 | |||
| 55b0002688 | |||
| 2a3a86f185 | |||
| 82072f18dc | |||
| 7bfc30e50d | |||
| 109d70363d | |||
| 0ef8dca814 | |||
| 9685d7ee8a | |||
| 1dd6b73632 | |||
| 1a591b202c | |||
| ddda064033 | |||
| 48b5955e16 | |||
| a877e28da9 | |||
| f0ec279ea5 | |||
| 254931998c | |||
| 9ad22c03a8 | |||
| 1210c71484 | |||
| bd4b5e8a83 | |||
| 3b02745302 | |||
| 2349f1031c | |||
| 8ea29296bd | |||
| 68ce69ec70 | |||
| 814db0307a | |||
| 0aaddbe9ad | |||
| 5fcca05d2b | |||
| 8f6be2c87e | |||
| 8749ce8848 | |||
| ac0ca03845 | |||
| 568928c98f | |||
| 8fb4b979c3 | |||
| 23739baa7c | |||
| c7ce7a9351 | |||
| 74f4c21244 | |||
| 996ff6e6aa | |||
| 918d9129f4 | |||
| 27f782f659 | |||
| 17b1db88c1 | |||
| 27e05fdfde | |||
| a07151f507 | |||
| 94c4cf760a | |||
| 20cc7f22dc | |||
| 49257e4cf4 | |||
| bc0b3336c5 | |||
| fadf93b425 | |||
| 0815b43797 | |||
| 55185bae5b | |||
| 4030166118 | |||
| f179cbedd7 | |||
| 20bb89f388 | |||
| e4ccf5190b | |||
| 38b0b8f63f | |||
| dedbcc6c84 | |||
| cef0f7632d | |||
| 7af4457c6a | |||
| 9e851e1a10 | |||
| b322f9a8a6 | |||
| 02722c3146 | |||
| 8405913e84 | |||
| 5d5b23b25b | |||
| e3e10952a6 | |||
| 58e2dcdcc9 | |||
| 936fca0667 | |||
| e777d7e816 | |||
| 5472c99b15 | |||
| 2848102b79 | |||
| d3fae0711f | |||
| 0f05abc0ae | |||
| e52071f1f8 | |||
| f65b7380dc | |||
| 96f84d69e2 | |||
| 8f23d0a1b0 | |||
| 1058cf4a9a | |||
| dae26c74ee | |||
| 5a35b3f6a5 | |||
| 79936f7030 | |||
| 734b16d8a6 | |||
| e0940ac9bc | |||
| 843e3806fb | |||
| 13e99bd4a9 | |||
| bce8363a53 | |||
| e536c55439 | |||
| d474c71c88 | |||
| 0df5bc06fe | |||
| d221f9a49f | |||
| 371e4af00f | |||
| 27508e468c | |||
| 20af2287c4 | |||
| 5433bee74d | |||
| 291d7bfeaa | |||
| 1803ea1343 | |||
| 014cdbcf75 | |||
| d91622b6d3 | |||
| 2d96396687 | |||
| 27b16d7595 | |||
| 265923aa84 | |||
| e8bbcfcfad | |||
| 9e963d581e | |||
| 6843f99a1f | |||
| 1c0f4392b2 | |||
| 8d3c122d93 | |||
| e57ab1a0fb | |||
| a0e6fc6157 | |||
| d842e7bc02 | |||
| a3dfb2bbe6 | |||
| 932911a746 | |||
| 3f3c169555 | |||
| 6b8123d650 | |||
| ac885c5e3f | |||
| 8c44bdac05 | |||
| bb65968afe | |||
| 44d3ea2468 | |||
| 3f76dd78cb | |||
| 9c1d94cdc0 | |||
| e322ceb622 | |||
| 1a24d95d31 | |||
| 2e159063b5 | |||
| 1be8be97aa | |||
| 565693d911 | |||
| 87cfcf3dd2 | |||
| 45b1be2b9f | |||
| bb85db9c3b | |||
| f506f9275d | |||
| 973a8a7ebb | |||
| 86534dea29 | |||
| 353d8c5183 | |||
| 3b02dfb1c7 | |||
| f78b9eddb9 | |||
| 30ea561714 | |||
| db557162af | |||
| 76b19c6ff5 | |||
| df5f29566d | |||
| 82d815adbb | |||
| d54b735986 | |||
| fbfb43040c | |||
| b332ac8acf | |||
| 61a6836a67 | |||
| 5a6a1a19c4 | |||
| 120bb5edc9 | |||
| d14bbc1d22 | |||
| 10c5a8c75c | |||
| 51da1dbbc3 | |||
| 89e4110ab0 | |||
| c06beae86f | |||
| bc59b580b0 | |||
| e1ea9fe4f4 | |||
| 5acb0aa92c | |||
| 7c2952899b | |||
| e925c6bed9 | |||
| a715a7c022 | |||
| b94c39923f | |||
| ce5bd50939 | |||
| ecbd6e1c6d | |||
| debe3f8025 | |||
| b1e4edad3b | |||
| 3ad6ed8bfa | |||
| 41b78a0599 | |||
| f3dc18b8ac | |||
| 427fc40edb | |||
| 90218eafe0 | |||
| 751a412185 | |||
| c3becc324b | |||
| 43ad853b60 | |||
| 955a5581a3 | |||
| f1be291c1c | |||
| aeee78a888 | |||
| 98db7a3ec2 | |||
| c0d65d55d1 | |||
| 7c14c15841 | |||
| 1c46ef4161 | |||
| 39f7fbbb99 | |||
| da95ee481d | |||
| 8153235f1f | |||
| 00f814152d | |||
| f28fa7d0e2 | |||
| 2361f5dc1c | |||
| e75fd81e27 | |||
| 265336ef3d | |||
| 7c9b0caded | |||
| a59d9bf6a9 | |||
| 657b96dadf | |||
| c8ee950fd0 | |||
| da7f69adae | |||
| da4457eba6 | |||
| b149a1f492 | |||
| ee7e149c35 | |||
| adee63564d | |||
| b00a1eb082 | |||
| 56e2c3fa9c | |||
| 6ea56238a8 | |||
| 678f066a97 | |||
| 20d1c5f027 | |||
| 9a797a159d | |||
| 63a06e78e1 | |||
| 96d068307f | |||
| 1f18d21069 | |||
| cb9fdaeb63 | |||
| b82fbd3ce3 | |||
| a3c07b2a84 | |||
| 772f149e81 | |||
| 75a72826fd | |||
| ec50817657 | |||
| d9d447bf54 | |||
| 9293564235 | |||
| 211d463288 | |||
| c3a8393c84 | |||
| 50e69755eb | |||
| 2cf1f7ff72 | |||
| af7c7344b4 | |||
| 58258a070e | |||
| 75a91c93e8 | |||
| 7a46e8684f | |||
| 1052c6241e | |||
| 0107f24de8 | |||
| fbcd7dd957 | |||
| 3e8bd39737 | |||
| e61aed425c | |||
| 0847e03b27 | |||
| 05626aac35 | |||
| 77818e9431 | |||
| abde239ff7 | |||
| 872afe444f | |||
| 4bd57ccd0b | |||
| 2191dadf47 | |||
| b48b118032 | |||
| 8d5ba9c42e | |||
| 565f51e81c | |||
| 0872d2f61a | |||
| 63a54c78e2 | |||
| 7d31892c57 | |||
| 33df24e1af | |||
| fe9547f78d | |||
| e24f431893 | |||
| 11ac571abb | |||
| 9c9575396b | |||
| 817ae1a452 | |||
| 32716cc81c | |||
| e949b1d717 | |||
| c089beae10 | |||
| 3332d6a36c | |||
| 4f1ae7fad8 | |||
| 12970c3830 | |||
| 6b5f51eed7 | |||
| 88f46d8dec | |||
| 5abbe10cf9 | |||
| ba92152daa | |||
| e248cd036c | |||
| f5531ac121 | |||
| 13c4f5ea3a | |||
| cd96aa8377 | |||
| 13f3e8e8f9 | |||
| 8c580827b4 | |||
| 0093b8d841 | |||
| 2071021cdd | |||
| 34cf203c01 | |||
| 9aa8c53b23 | |||
| 5973a5deda | |||
| 3237e80fb4 | |||
| da97d9b85c | |||
| 562093f22c | |||
| 65314bad77 | |||
| 31fbeee1cf | |||
| 5085ef140b | |||
| 1c4406a6eb | |||
| d815c15176 | |||
| a3a3cc1b7c | |||
| f266d781ac | |||
| f0962b0779 | |||
| d9cbd4ef93 | |||
| 6c90f9f642 | |||
| c341d21bbe | |||
| 91ebc9972c | |||
| 3fe6be6a57 | |||
| de0071734b | |||
| a0c0186337 | |||
| f3c317b505 | |||
| 09d0d57630 | |||
| b44ebfc0b6 | |||
| 3d054535db | |||
| c5b8c50923 | |||
| de60682f40 | |||
| 3d5b224e20 | |||
| d447f6f34d | |||
| 44e969d24b | |||
| ec933737cf | |||
| 97109cfd08 | |||
| 96507b7d7e | |||
| 9c5f9e3844 | |||
| cee7f07d76 | |||
| 87951b5ca6 | |||
| 6a3c69393e | |||
| b75d554cd7 | |||
| fb029dd813 | |||
| bb5df086de | |||
| a83131ba5e | |||
| 655b1a3a94 | |||
| 976e220859 | |||
| ae4436d3f1 | |||
| fdbc7ddf1b | |||
| 266aa3387c | |||
| adbf3297c4 | |||
| 9aae7e44ec | |||
| d3d27cf251 | |||
| 229aa84426 | |||
| 19447c6a11 | |||
| bd86e1ab05 | |||
| 6f97f0927c | |||
| 21d1a566f3 | |||
| ec73828eea | |||
| d62b4b3790 | |||
| c77b7e3821 | |||
| 9cce52b8ba | |||
| 5f2ba4133d | |||
| 4539056ec5 | |||
| 19b837a993 | |||
| 87891ac059 | |||
| e92c9d304d | |||
| 26c484d30c | |||
| e21fcd784c | |||
| 75544ef6bb | |||
| a084072f98 | |||
| 70fea18829 | |||
| 0b65005f9d | |||
| 54b25480e2 | |||
| 86783a0b56 | |||
| 8a2efb21a0 | |||
| cab5a4b2ed | |||
| 9bd0f3a296 | |||
| febe377eec | |||
| a497a8bb16 | |||
| b667348f5d | |||
| e67e90c96c | |||
| aff5831350 | |||
| dcf214b324 | |||
| 701b449517 | |||
| c1782cacfe | |||
| b0aa5e3fec | |||
| f06675dd2b | |||
| bd8872a785 | |||
| fbf48ef906 | |||
| 51f7d3990f | |||
| cd99acb61b | |||
| 1884ada219 | |||
| 3991ce3e9a | |||
| eb8c84b0c5 | |||
| c8f85b0ccd | |||
| a1e1ae261a | |||
| f9b4e9a898 | |||
| 2fd7a805eb | |||
| 1a443a4ab8 | |||
| c5b8957253 | |||
| 4b554f97ae | |||
| 38176274ff | |||
| 3c1278db82 | |||
| 0e4f9b91e5 | |||
| 7a658b7bfa | |||
| 4667b31dd8 | |||
| 39b0a8c372 | |||
| 40ed5dd5a5 | |||
| e6022ded9c | |||
| 6ad975e199 | |||
| 59cda8d129 | |||
| 311aec7847 | |||
| 2d7e1ec7bf | |||
| ecd7b08b27 | |||
| e2b94eea77 | |||
| 04e7a78575 | |||
| e232e03ef7 | |||
| 7f718555ac | |||
| b74c513271 | |||
| 794f358353 | |||
| 49aab1b97a | |||
| 374181c82c | |||
| 6b0f805adc | |||
| 4730bea74c | |||
| 49b9093f1b | |||
| 906fabe23f | |||
| d65adb904d | |||
| 5f91bcb221 | |||
| b37767f30d | |||
| 6613c985cd | |||
| 60d511d3c1 | |||
| f12e298298 | |||
| 0772488a50 | |||
| 2ff1897f60 | |||
| bd0170e094 | |||
| 8609b55797 | |||
| 31d4267d9f | |||
| c176c32668 | |||
| d3a9f33769 | |||
| 89ffa516c5 | |||
| 82aa1f88b4 | |||
| c51b1a72a9 | |||
| fa7889d7d5 | |||
| 3271200312 | |||
| 33719f8456 | |||
| 92ea143a92 | |||
| 8178af420a | |||
| c964fd1485 | |||
| 039fa1d44e | |||
| 78c05aadd3 | |||
| 6fd6db2d1d | |||
| b7600757a0 | |||
| 1527201bdb | |||
| cf7848b966 | |||
| ea855611e3 | |||
| 9b1140b8f9 | |||
| 4298a1f53e | |||
| 3623fd636b | |||
| 482b65e026 | |||
| ff6fed66ef | |||
| 40de3073f6 | |||
| 69892f4a6e | |||
| 5a68c84430 | |||
| 24a76fb092 | |||
| 2cd41593a5 | |||
| a2a9b31a25 | |||
| 45b2269920 | |||
| 4c99703290 | |||
| e39bcab748 | |||
| c2d06472e3 | |||
| 12cd0c7d74 | |||
| 0a22ba67c5 | |||
| 223a457f93 | |||
| 9c773bc635 | |||
| d0529330e5 | |||
| c7bc18c9aa | |||
| 0694940507 | |||
| c6b5f01c55 | |||
| 0a0d6bc998 | |||
| c3df293ddf | |||
| 71071d61ce | |||
| 356cee060a | |||
| f662bb7cb2 | |||
| 431ef40793 | |||
| 690203d818 | |||
| 6372a89d30 | |||
| ddae475a6c | |||
| ac617e8795 | |||
| fc1efa8d61 | |||
| c7fbb2ae0e | |||
| abc34b315a | |||
| e2289f1727 | |||
| 1a61f7939b | |||
| aa7e170aaf | |||
| da619f261e | |||
| ded58ea79a | |||
| 2da297facd | |||
| a253bb1aaf | |||
| dcfbfe4801 | |||
| cf6c601bcf | |||
| 3e24f71987 | |||
| b68bcfec03 | |||
| dd64010236 | |||
| d7d98b5195 | |||
| 9798f8296b | |||
| 68aafab377 | |||
| e4115b64ff | |||
| 3be42738d7 | |||
| da08630a1f | |||
| 001ff9e4e3 | |||
| a69e09efeb | |||
| 0a4090650d | |||
| 671da7e617 | |||
| 3f8bcfd588 | |||
| f036aa61f7 | |||
| d926a0fd98 | |||
| 21c73270fe | |||
| 97e4eb46eb | |||
| ad36ee9441 | |||
| c6557bab38 | |||
| 30cd115050 | |||
| 3dc10f41c8 | |||
| 466a1750bd | |||
| 7aee591a2c | |||
| 8ee98c06c2 | |||
| b91925a3f6 | |||
| c27a9c3f85 | |||
| ec9a2a2ce0 | |||
| 42ba7f3036 | |||
| db11b6255b | |||
| ce99ad9cf9 | |||
| 36ae8f27bb | |||
| 3fcceb0649 | |||
| d607f403ec | |||
| 4005b0f90c | |||
| 87bbc1a8e4 | |||
| 79c3e3382a | |||
| 2e178c8b16 | |||
| 62e159c1f2 | |||
| 2e57663f7c | |||
| 403cbfb6bb | |||
| 466751c13f | |||
| 2d6e6e4537 | |||
| 7231d54fa2 | |||
| 61224e5611 | |||
| 85d39b867b | |||
| 8f30c3a42d | |||
| 011e53054d | |||
| 2972b9a301 | |||
| e9c78c7e77 | |||
| 341117dfe9 | |||
| 3efa2138c5 | |||
| a5c6ad343b | |||
| f282ade0b3 | |||
| 252deff4c2 | |||
| f7312a97b0 | |||
| ade9da5be7 | |||
| 0c5b9aeb19 | |||
| f306ee161c | |||
| 0ee3699b44 | |||
| 4c281934ff | |||
| 507f4f8a73 | |||
| a158bad0bf | |||
| a3e9bf9aab | |||
| b23d7195c5 | |||
| 0af6824866 | |||
| d66fa052fb | |||
| adadd7994e | |||
| aae582344e | |||
| 4db6dac439 | |||
| 91bde37441 | |||
| 044450e448 | |||
| 56ebd398ab | |||
| 6d5eb98614 | |||
| 434179ba18 | |||
| 9e4b8deb78 | |||
| 4688af0cb4 | |||
| d44edffa1b | |||
| ceb7ed4949 | |||
| 4b94ed2a51 | |||
| 9feba2916a | |||
| 4f15afb3ce | |||
| eb54b7ba0a | |||
| 5895f34c39 | |||
| ad6cfcb41f | |||
| a95c052ba0 | |||
| cc5bcbb97d | |||
| 94a30377f5 | |||
| 46da349088 | |||
| 667c7bfd49 | |||
| ebedcc903e | |||
| 425e430f8b | |||
| 8809c49c46 | |||
| c68b419964 | |||
| 2483ca525b | |||
| 7cccd77c8a | |||
| 1ccdfdac79 | |||
| fd899b1849 | |||
| c37d9fb949 | |||
| 85368ee09a | |||
| 2d9a3ce448 | |||
| 30d3a329dc | |||
| 8cff027f67 | |||
| c42f166eb1 | |||
| b8bd954b02 | |||
| 8945431457 | |||
| d799aad4f8 | |||
| 18b14f48bd | |||
| 856bab0a92 | |||
| 90c0accf58 | |||
| 5a640c3595 | |||
| 41a1abc9cb | |||
| 48dd5b81e3 | |||
| 6aa16464f8 | |||
| a3558fe4ef | |||
| 1d08027c11 | |||
| 9f7397feea | |||
| d2126bff48 | |||
| acb66d4a66 | |||
| 8d658aef1f | |||
| 62b2cc1003 | |||
| f642c759e2 | |||
| 350fd07efd | |||
| 1fbb438afa | |||
| b58e9e2820 | |||
| 28ef697b42 | |||
| 7dd625edb9 | |||
| fdb06996e5 | |||
| 36a33e86ff | |||
| 0c59a6527e | |||
| a1c6c4fd25 | |||
| 67c8d6161a | |||
| 1e55be001a | |||
| 7d3bd6d5f2 | |||
| aa25ce4be3 | |||
| 23111d727a | |||
| 4862deac95 | |||
| e185fd7b56 | |||
| 4855ac34f4 | |||
| fcf823663f | |||
| 27148dae22 | |||
| 1e40d8e0c9 | |||
| 4c513b7625 | |||
| 01f0a49bb4 | |||
| 1b949fca39 | |||
| 79de6a93fa | |||
| 3a18237502 | |||
| 8371c49e3d | |||
| e4a88303bb | |||
| c1595845f9 | |||
| 0b15850c15 | |||
| 75bfc0daf2 | |||
| 0f6b965066 | |||
| 68d04b338a | |||
| 674d026e51 | |||
| 137522fd02 | |||
| 186c79c8d3 | |||
| e2939629d5 | |||
| 25d0b8ae98 | |||
| 1156107243 | |||
| 460e7db116 | |||
| b746853520 | |||
| cd474b7e7f | |||
| 918107acab | |||
| 6dff921d5f | |||
| 9f1de2300e | |||
| 6d178b1b90 | |||
| 78234a9243 | |||
| ea60c5561d | |||
| 860863c8d5 | |||
| 0fb6bea722 | |||
| 693c66cf12 | |||
| 59868bb63a | |||
| e23c97f455 | |||
| a590dc43bb | |||
| 5c062ebe50 | |||
| 3bd1b2053b | |||
| d050563fb9 | |||
| 468eba7d2a | |||
| 8ebfc9fc34 | |||
| 77896aae9a | |||
| e12bfb75e9 | |||
| 22307c120f | |||
| 12b754a752 | |||
| 716a71d680 | |||
| d98ef78771 | |||
| e76e7a6298 | |||
| 225e6f74ec | |||
| 17bd69bf7c | |||
| 6d55eeae45 | |||
| 523e345350 | |||
| ca9612d830 | |||
| 9bfaab8ffc | |||
| c5cd63114d | |||
| e3f1e140e0 | |||
| 84d38d3803 | |||
| 2718b575a4 | |||
| 1451e97f31 | |||
| d031305111 | |||
| f270cf3134 | |||
| 16bca41d5d | |||
| 5df56e7f4f | |||
| bd068037cd | |||
| e794ef7a05 | |||
| a98c1e764f | |||
| b4ab55fc89 | |||
| fdf6c6a54f | |||
| 2d0241c8ad | |||
| b6853e8f3b | |||
| 14a37e869c | |||
| 9fc70ba03f | |||
| b092522d3a | |||
| d4b5ed3319 | |||
| 9cdf9cebfd | |||
| b538a7216c | |||
| 7be778ec01 | |||
| dedd050920 | |||
| 0b03b4ee4a | |||
| b75a7809de | |||
| fc07e8d968 | |||
| e3c9459017 | |||
| cb3a6b26e9 | |||
| f10196abb7 | |||
| 1743ffc14f | |||
| fc7dde27c4 | |||
| 7ebc49607d | |||
| f62f6239c0 | |||
| fa9d89ebe9 | |||
| af06c943c7 | |||
| 41b64ac646 | |||
| 8e72c71071 | |||
| 01bff58169 | |||
| 23873033bf | |||
| fcb0dbc7a0 | |||
| 896f6896e7 | |||
| e7c8b71ea4 | |||
| ed529b49df | |||
| 1a0e956d00 | |||
| 6bfa5873a8 | |||
| ff879833be | |||
| 525dddf52b | |||
| 71a567e923 | |||
| f179c7e671 | |||
| 40a4ce6fcc | |||
| c95f6835ca | |||
| 27a9715aa4 | |||
| 1717b464af | |||
| 7103791378 | |||
| bb1cb4a6fc | |||
| 65bd6022ac | |||
| 7be3bfeebc | |||
| a1e43596c2 | |||
| 02db5ce9a1 | |||
| e14f9c0764 | |||
| 5aafbc9ce0 | |||
| aa384fc171 | |||
| 93d9b2bf98 | |||
| 4cb79433c1 | |||
| 3725c40d03 | |||
| a4b665f525 | |||
| 5bbfaf1515 | |||
| 7aaf2afc5a | |||
| 8b827fe05b | |||
| d3db43de8b | |||
| 8f64a98e2d | |||
| f21d0dbf65 | |||
| 96c4b03481 | |||
| 3d04e3e62a | |||
| 51bb819409 | |||
| ecb33befdd | |||
| 5844dc5b93 | |||
| d71e05303d | |||
| 908197ae07 | |||
| 0aade82862 | |||
| fef8533ae0 | |||
| 376c9f9b91 | |||
| 92e7084cec | |||
| 7e932123d3 | |||
| 5e002d47a5 | |||
| f8a02c0933 | |||
| b94e39b53c | |||
| eaa56c31b6 | |||
| 4a117c6390 | |||
| 05db82f3cb | |||
| 99d5ef9220 | |||
| 8a4615b5a8 | |||
| fd20fb8725 | |||
| d521a0e593 | |||
| bb90a2ccc2 | |||
| f447bd6666 | |||
| f66604ba6a | |||
| ae37aa5856 | |||
| 4955a1a66a | |||
| 0da231827e | |||
| 5bd545efbe | |||
| 653c80cb87 | |||
| bea3cdd1a4 | |||
| 21aa932bd4 | |||
| 0b43349fac | |||
| 337cf04334 | |||
| 612f0925bf | |||
| 4b72a59e62 | |||
| 8af676c32a | |||
| 5cf8667c47 | |||
| 9dd0bbc536 | |||
| 63c7a04998 | |||
| 2026ea2c00 | |||
| 917641e469 | |||
| 925b9739da | |||
| 4da6e98c49 | |||
| b621e60316 | |||
| c35645df42 | |||
| f922289c03 | |||
| 2ab5f7d7bd | |||
| d4cf2afd1b | |||
| 86bd6cdd3b | |||
| 52af89800e | |||
| 830c360664 | |||
| 3231c4c1aa | |||
| d1aadb1f2d | |||
| 3c831b6b16 | |||
| a3d22ab179 | |||
| 5bb8853714 | |||
| 8e42f49d8f | |||
| a550240f08 | |||
| 32a19cb9d6 | |||
| b27dd18951 | |||
| 2a25fcf1b3 | |||
| 28fbf15706 | |||
| 2a5870ce9b | |||
| d5eb1a1bb9 | |||
| 9688e80a6b | |||
| 2212d34dd1 | |||
| 4eaab96848 | |||
| 15988c5588 | |||
| 81978d524f | |||
| 4f5c0e9c81 | |||
| 7a63f1370f | |||
| d54bb575ba | |||
| 2110cbff32 | |||
| 67af1f5b50 | |||
| 078d32cc31 | |||
| 6fcf9eba4a | |||
| 6d7864751f | |||
| 153588738d | |||
| e951285456 | |||
| 344974362c | |||
| b74e28388a | |||
| 509b0efdcd | |||
| 7901708be7 | |||
| 9f7a3500dc | |||
| 2bd74359ba | |||
| 84bac3431b | |||
| 84259f2bf7 | |||
| 23b3858a89 | |||
| 9c9f6c61fe | |||
| e8cf2810a0 | |||
| 5be7ef76bd | |||
| 8aa3d6177e | |||
| e7f564054c | |||
| 6a6151bff8 | |||
| 0ce7d24f69 | |||
| 6e7ec0564f | |||
| 5de85508a3 | |||
| 7d7ae6ffa9 | |||
| cfea3f4b90 | |||
| 17c31d9968 | |||
| 3de8c8b47d | |||
| 078067b6a7 | |||
| 8453b0c846 | |||
| 5a65b67245 | |||
| 6d75548144 | |||
| cb6da0c090 | |||
| f6c93028cc | |||
| 3d301f58c2 | |||
| 492a049797 | |||
| 3c776bc01e | |||
| 5cf77c6b18 | |||
| e16569b26b | |||
| d976d191cb | |||
| 6e623b5793 | |||
| a818452857 | |||
| dd5c1f4c2d | |||
| 338bd52f28 | |||
| 97e80c0456 | |||
| f1dca60e54 | |||
| ab8d501cb8 | |||
| 849b60841d | |||
| 1cbd2e7c87 | |||
| 17239b3a35 | |||
| e88728125e | |||
| f8426666ee | |||
| 0a11a5d23d | |||
| cf1876e43f | |||
| ac5ccadc55 | |||
| 75cc0b2355 | |||
| d8a198809e | |||
| a4b5ba0594 | |||
| 18fe063ef8 | |||
| a26db2652c | |||
| ab1730cfa3 | |||
| 8dbe424ad4 | |||
| bb4736187f | |||
| 62f661efa5 | |||
| 8178327828 | |||
| 19730208a6 | |||
| 90fcabc59b | |||
| eabbf5ce58 | |||
| 8ab88d29f3 | |||
| 0bb5f4cabf | |||
| e8649811f2 | |||
| df510b8680 | |||
| 3ff24118a5 | |||
| d4954bc7bf | |||
| 416f4abd03 | |||
| 314dd1c931 | |||
| 0e6ee620cc | |||
| 997e6a9cde | |||
| 23b78d709f | |||
| 46f95aa6f2 | |||
| 672d555c78 | |||
| ebbfd1a327 | |||
| 8ac0157cc6 | |||
| c55a5a1ba4 | |||
| ee8ab5c2f3 | |||
| 451119c743 | |||
| 20a0aecee1 | |||
| cc3ebc8af8 | |||
| b6efe4e54c | |||
| b598189626 | |||
| 70b3162964 | |||
| 66dbdef629 | |||
| c00324a03c | |||
| 2e8f2923ef | |||
| 3a33fa7faa | |||
| 38823b96ce | |||
| 9efb326b5f | |||
| f327b14fca | |||
| 6d88c9b703 | |||
| a5532120e9 | |||
| 34422925f1 | |||
| 70b24695f5 | |||
| af05210a48 | |||
| cfa01428ee | |||
| d84326742f | |||
| 722311eb89 | |||
| f11360e5e8 | |||
| 07b724ec55 | |||
| 5ef8fe188b | |||
| fda7c64c3a | |||
| b7e265088a | |||
| 017f72b42e | |||
| 0ddd298350 | |||
| 516105c492 | |||
| e7b3093986 | |||
| 064cd2244b | |||
| b0bf2a107b | |||
| 09413522bb | |||
| 69d92960d9 | |||
| 3f5ce7dbf4 | |||
| 76658b85f1 | |||
| cbf2c3f9e4 | |||
| 120c0808bb | |||
| e6ac3e9056 | |||
| 52be26a099 | |||
| c75107e34a | |||
| 05c613bf61 | |||
| 5528a0e024 | |||
| 98e69fcc25 | |||
| d3f33979e4 | |||
| 46ee5cf3b1 | |||
| 7c72944d7d | |||
| f665050d66 | |||
| 393a412784 | |||
| 30e859b552 | |||
| a70c0bf4e9 | |||
| e745502542 | |||
| 55acc5e487 | |||
| c0d2348fc3 | |||
| e5a225a687 | |||
| 257a6e3eb6 | |||
| 7b5268f0a3 | |||
| b6fcbd1b4a | |||
| c19b417a5d | |||
| 94307d105d | |||
| 16e5a9808b | |||
| 2239ec16a8 | |||
| 0e6109c09a | |||
| a242bffb28 | |||
| 6717cbad48 | |||
| b7762cc18d | |||
| 6ee0d8fef1 | |||
| 58ef54e859 | |||
| 076079f981 | |||
| 22d0171e13 | |||
| 12b6f8b98c | |||
| 978a028553 | |||
| 685dabede3 | |||
| b7bfe880f4 | |||
| 72502ae53f | |||
| 5688f6ebb8 | |||
| b916d0364c | |||
| 15ec617fec | |||
| cd7428e3c3 | |||
| 6023f9801f | |||
| 5dad7a0427 | |||
| d156c69992 | |||
| 82c755409d | |||
| 2f7aee4aad | |||
| 1824deecae | |||
| 2d5a1194bf | |||
| e936fc721e | |||
| 4ba1dd8a11 | |||
| 716371200b | |||
| ed7e2c9bb4 | |||
| 57fbc092c8 | |||
| 5fd183f95c | |||
| 8dd1377090 | |||
| bb63f9697e | |||
| 99f63627b2 | |||
| a50182b1e5 | |||
| d5c57aca1c | |||
| 273cb2b775 | |||
| ec315dc63f | |||
| 4c0126bf4b | |||
| 40135f5861 | |||
| 76cbe6a073 | |||
| a08959980a | |||
| 4e1a454d4e | |||
| eef0d65d44 | |||
| bb84b15f3b | |||
| 0f108a709c | |||
| eb6c1c7c3b | |||
| bb026d2cd9 | |||
| 955e494e05 | |||
| 7d07bde52c | |||
| 8a7e84ebb8 | |||
| 075ec5f6bf | |||
| aa0d510b05 | |||
| 0962ffb372 | |||
| ea75ac6d25 | |||
| d0c16d60cd | |||
| fdebf19a26 | |||
| 6367b1593d | |||
| 7c9e5e8491 | |||
| 9e90e785a3 | |||
| 0474936bfc | |||
| 430432a18b | |||
| 9d45b67c73 | |||
| 3bd7b9c2fd | |||
| 3b5952cd44 | |||
| 910e32809f | |||
| c888741aef | |||
| 8f74542371 | |||
| e86e7f62d3 | |||
| 9054c47777 | |||
| 735ca514bc | |||
| f008087b71 | |||
| 3f510e40e7 | |||
| 03f00518c3 | |||
| c512629637 | |||
| c38ffd3643 | |||
| 4f8c08011a | |||
| d476978cde | |||
| b32812217b | |||
| 8cf4c98633 | |||
| cf98e875ee | |||
| 427759a98e | |||
| b537aa6ea1 | |||
| c079ae3c60 | |||
| 4043037d87 | |||
| 9a9b71f479 | |||
| 77429e2013 | |||
| 7e8ae3ab68 | |||
| 838aa1612a | |||
| 204a6c10dc | |||
| 936a8831fa | |||
| 7c86d0d9df | |||
| 60814f7c1c | |||
| f4a193ec91 | |||
| 686ff34a11 | |||
| 00ac338981 | |||
| b9af1cb074 | |||
| 8c885636de | |||
| b114a16bed | |||
| a096edb88f | |||
| 890c805f37 | |||
| 9fe794543e | |||
| bda6d5bdee | |||
| 997d29c88a | |||
| 2d2395a97d | |||
| cc04244df8 | |||
| fd21d72887 | |||
| 52ae227085 | |||
| e264f23237 | |||
| 854438a2ee | |||
| 9fc304040a | |||
| bf5748d58e | |||
| e9ed06dbf3 | |||
| 510fe5257a | |||
| 9b4e2fabfa | |||
| 0dae280d9f | |||
| 75e20fb5d9 | |||
| 0c1174d113 | |||
| 50ddedb652 | |||
| 4a39921355 | |||
| 5fb5503d3e | |||
| c50bbe8c25 | |||
| dd82f8cb8b | |||
| d2570cec55 | |||
| 01435c6cea | |||
| ddf7ec0c27 | |||
| 400b777484 | |||
| fbbd4409d0 | |||
| 37865e134c | |||
| e010cf1327 | |||
| da5d642505 | |||
| 1f1c001fde | |||
| fc5261a645 | |||
| 4c3da5c4b1 | |||
| 163c57c600 | |||
| 545a691387 | |||
| f8a77b7c29 | |||
| f2c3507355 | |||
| 6cbe808b89 | |||
| bed71908ae | |||
| 5a48e6af32 | |||
| 4c8e9d58fd | |||
| 31d79bcc32 | |||
| db91d9410c | |||
| 405a785b65 | |||
| 6994cb1e94 | |||
| 49e1ec3638 | |||
| 60d47747ba | |||
| 375b121eb8 | |||
| 27939b153f | |||
| 18d1eee592 | |||
| 284c81a2e1 | |||
| 13be193591 | |||
| ecaa9f8e86 | |||
| 2f09747222 | |||
| cc0f7427b3 | |||
| 87a7b255ce | |||
| f01e25a9c2 | |||
| a36eaee54e | |||
| 0b06fea8ac | |||
| 57ee594dd0 | |||
| 9fb94f1fd4 | |||
| 3c8ac639f8 | |||
| 99f12b493b | |||
| 8008fac0ff | |||
| c56dde238d | |||
| a5ff733311 | |||
| 3d6a2a67ad | |||
| 1717cd9d3b | |||
| d9619f17d0 | |||
| 6f3d9fd7ff | |||
| 9c53f969e6 | |||
| 8211de1954 | |||
| cfcebf8b73 | |||
| 99cec351ec | |||
| 9a56ffb829 | |||
| a54c8ed9a4 | |||
| 29ef5527a9 | |||
| b073e6fac7 | |||
| 3b64aaca66 | |||
| 7cc3788f77 | |||
| dcaa848b0f | |||
| 3b29dd2a91 | |||
| 90d8245ab2 | |||
| d1308b6908 | |||
| 1d875f2ce1 | |||
| 6e95e7dd06 | |||
| 4ff5a0b0a8 | |||
| b9aab0981e | |||
| 41c9e22121 | |||
| b6f0da41e8 | |||
| 60604f208c | |||
| f0650c2c29 | |||
| b82afbbb14 | |||
| c729b33852 | |||
| 26df4f4875 | |||
| 09ce007f9a | |||
| a2d17fcd2a | |||
| 56762f42af | |||
| dbbe8139b7 | |||
| af9a8e955b | |||
| 9b7eb27e01 | |||
| cde4f3b6c7 | |||
| 7e248c7055 | |||
| d70ec78cae | |||
| cb0fcbc582 | |||
| 3b11dae932 | |||
| aec0671b4a | |||
| 6853ae9881 | |||
| 14b59ed418 | |||
| f83f908cfa | |||
| 3243bb8702 | |||
| bff5dbef07 | |||
| eb88bc7950 | |||
| ef86ba749d | |||
| 8a21604adb | |||
| 0cde363e96 | |||
| 246c691ad5 | |||
| 85b3f74741 | |||
| 2e356404f9 | |||
| d0876e9411 | |||
| bc29df33b5 | |||
| 84e600fa52 | |||
| 685681617c | |||
| 14acf05c03 | |||
| 9b74fd45a2 | |||
| 61f5467c65 | |||
| 15f420ffe8 | |||
| e6c6baeb8f | |||
| 5874e88ee0 | |||
| 765072e413 | |||
| 2e3468fe74 | |||
| cce69f79c0 | |||
| 562802ec56 | |||
| e052d624f4 | |||
| e7424b9272 | |||
| 128172b597 | |||
| 911d69044a | |||
| 9696a15e02 | |||
| a70f45938a | |||
| 5f3639e945 | |||
| 7ea6735167 | |||
| c736d1d4bf | |||
| 580968a4a3 | |||
| 75c3705fb0 | |||
| 9fe4b47349 | |||
| 419f529a29 | |||
| 7438545e29 | |||
| 43b3357834 | |||
| 4c89da8248 | |||
| 9175fac141 | |||
| fde062134d | |||
| 4c72b585c6 | |||
| b98820b7c9 | |||
| 8b4ee2315c | |||
| 3a994fdcde | |||
| 297304e176 | |||
| 01f18e6dfc | |||
| 48c52f14e3 | |||
| 817108aaf1 | |||
| c3a390c28d | |||
| 6142eb9ba5 | |||
| 66dab8c1b8 | |||
| 5da41d4d04 | |||
| d25d566790 | |||
| fc01cbc636 | |||
| a3a8def860 | |||
| b2bba1bf5f | |||
| 5b959f9d6a | |||
| 77a6e6b688 | |||
| 7abd2dece9 | |||
| d08e6f5f8f | |||
| 32e17c30eb | |||
| 5b746a3e22 | |||
| a84ea90c79 | |||
| fbd7c37ccf | |||
| 7f1fa7c101 | |||
| 7f5c40b996 | |||
| 5d12167324 | |||
| 2a08fd71a2 | |||
| 774d8b866e | |||
| e2db5ea804 | |||
| 5e435bdf1a | |||
| 47b0949290 | |||
| 50441d6152 | |||
| 3230e2fec0 | |||
| 39c934cdbe | |||
| c6ad585d49 | |||
| a3b712d709 | |||
| 1b811aacdd | |||
| c4c52af1d3 | |||
| 11cf735961 | |||
| ab9f6e5b52 | |||
| da39f990a5 | |||
| 806b872465 | |||
| 6f00ffe0e8 | |||
| 7217b5aeec | |||
| 307741a0e1 | |||
| ad6a90d623 | |||
| 7a89b65b15 | |||
| cea92f1c70 | |||
| f9676665de | |||
| acb55a1ecb | |||
| 95a4636414 | |||
| 67f751f8d5 | |||
| 79b43acc40 | |||
| 719f54f90a | |||
| 1525d1095c | |||
| f3e3406e04 | |||
| 08844a50f7 | |||
| 524f2051ea | |||
| cd7f6f4876 | |||
| e855350b7f | |||
| 50b2e91ec6 | |||
| b7291a93b7 | |||
| 1d19732eeb | |||
| 09f9e39e8b | |||
| 16f808ae53 | |||
| b01bb72c1d | |||
| b8b01e87d1 | |||
| 40e18ccb7a | |||
| 8e93eececf | |||
| c6f807ebad | |||
| db6876cdca | |||
| 7df8a0e6ef | |||
| cf56300676 | |||
| 1f3954cfe0 | |||
| 9c7dbbf1ba | |||
| 15f60534f1 | |||
| 6ef087b841 | |||
| 6506c11ec1 | |||
| b56850956b | |||
| 96a2fb1c3e | |||
| f501514aa2 | |||
| 5607763fd4 | |||
| cf00909444 | |||
| 09e56371e6 | |||
| cf1d121fb3 | |||
| b00fd7d177 | |||
| 59c29e3a40 | |||
| a493043aa4 | |||
| 9d54cc06a1 | |||
| 5f23fa3a19 | |||
| ace2648480 | |||
| aa3a2811e9 | |||
| 5859db3f67 | |||
| d3ee45da2b | |||
| 1a277a7881 | |||
| e0f83179fd | |||
| 3c50143dd4 | |||
| cc4c01be6d | |||
| 125b2aed97 | |||
| dd6c235df8 | |||
| 902fde2467 | |||
| 9561a076d7 | |||
| d796512f6a | |||
| e3905253b7 | |||
| 6887b3c135 | |||
| 7a23437a87 | |||
| a19bf7eac1 | |||
| c1d7c53d57 | |||
| 7f81830ae8 | |||
| 5b64bd910a | |||
| c578512188 | |||
| 73abaa1f66 | |||
| 4bf274196e | |||
| 4ea3064a37 | |||
| c1785a4618 | |||
| 6528b15449 | |||
| 01c3f52d62 | |||
| 538f4a9ea6 | |||
| e1e67f47ec | |||
| ec694c23b5 | |||
| e92a1a5647 | |||
| aaefdb2a59 | |||
| 398b2f5c4f | |||
| c26a23b36c | |||
| 45c2297de7 | |||
| 6fdfc4467e | |||
| 36368fa260 | |||
| 4b875454d8 | |||
| 346fcd746f | |||
| 754fbb9aad | |||
| 66896ab73e | |||
| 5cc9914c38 | |||
| 468cfd8810 | |||
| b2de6fa5cd | |||
| 8cf41c5c36 | |||
| 59c0de75c4 | |||
| 6a26f4bc6e | |||
| d08eaa2da8 | |||
| 9140edb031 | |||
| b71e44bd01 | |||
| 5a2de99035 | |||
| cfbccbf443 | |||
| a5a894e6d6 | |||
| 4fa31759c3 | |||
| 5b92fba23a | |||
| 932c8e1c58 | |||
| 1845ee9d81 | |||
| 762af28ae0 | |||
| cea3c47caf | |||
| e568347ea4 | |||
| 766e6f64f1 | |||
| 472b2b0bc2 | |||
| 2507c5c60e | |||
| d42d0c9d73 | |||
| f2771e2bed | |||
| c56bc9fb9d | |||
| 921632789b | |||
| 7b0da0f96e | |||
| de09e811c6 | |||
| 48042df9d5 | |||
| 3ae603a789 | |||
| 519cca30b5 | |||
| 96e0710d8a | |||
| f88232fdd3 | |||
| 861f3654d2 | |||
| 2d6989ed1c | |||
| dd0fb8eff0 | |||
| 649e9cff13 | |||
| f2b11b038e | |||
| dbf5115c0c | |||
| f349094e10 | |||
| e597ec1b69 | |||
| 8511a6cb41 | |||
| 3f61ad8f99 | |||
| d2fbac3a70 | |||
| f13326f7d3 | |||
| 4bd2d2c3ee | |||
| 5a45af6d40 | |||
| b53610f6fa | |||
| ee4b67c03c | |||
| 445f8a7660 | |||
| 750652c068 | |||
| 67115a2dd8 | |||
| f6034240d8 | |||
| 5a590f7530 | |||
| e005ab6211 | |||
| 6e5a63b3a1 | |||
| 01dd27c088 | |||
| 2883d2a35b | |||
| be6b13a7ae | |||
| 80364a3cbf | |||
| 548d37a14d | |||
| 1f96c3a175 | |||
| 7bdbc95a19 | |||
| 6a4bd749a8 | |||
| 60a0dcc5a2 | |||
| 1b88380e38 | |||
| 81b0634e1b | |||
| b8be6a1bc0 | |||
| 807a567db4 | |||
| 5105246f07 | |||
| 51727bc05b | |||
| 9ba5d665f1 | |||
| b9f814de1e | |||
| f3912bab13 | |||
| 0847be02de | |||
| bb86f32e3a | |||
| 12b97490e3 | |||
| 59d7072ab4 | |||
| 896687f735 | |||
| 8ef67e3087 | |||
| 652d141608 | |||
| 8161b11b38 | |||
| 6890e2580a | |||
| 216f7ad6de | |||
| ae9fbd89c1 | |||
| 51d34b4208 | |||
| abb7e43033 | |||
| 48c5dc4db7 | |||
| a259764743 | |||
| d7dafdaeab | |||
| 7320fe363d | |||
| 603e39ca54 | |||
| 0e616fc86f | |||
| 7b96be5be8 | |||
| 034df21bf4 | |||
| 06dd0669fe | |||
| a2673187d3 | |||
| 943735a7c7 | |||
| 73d27ba44f | |||
| c1d2d897a1 | |||
| 1944f651e5 | |||
| 4b56fb9025 | |||
| e8a077c0df | |||
| a16f72e9ae | |||
| 2b5f89b239 | |||
| fa8775e440 | |||
| 9ff3c46a07 | |||
| 76b4fc559c | |||
| d4032ce27c | |||
| e4171ad06e | |||
| 597e2e80e2 | |||
| 9050d7b612 | |||
| ea1ed80816 | |||
| 2adaf192da | |||
| 01715d5791 | |||
| 37e2a82e92 | |||
| cc1b82c76f | |||
| ee0ba02610 | |||
| e1ce9227c0 | |||
| c6cb7e3b2c | |||
| fc0f2686e6 | |||
| 37b5e6ace4 | |||
| dd6ebb366b | |||
| fd4dcf88a9 | |||
| dab3aa3ca6 | |||
| 233c2f46b8 | |||
| 583ceb1427 | |||
| 22a4d26b87 | |||
| 68a4caa163 | |||
| 5d2e9755ec | |||
| 7788f468f2 | |||
| 18517dcb6d | |||
| 20427231eb | |||
| 1da477236c | |||
| 2b1f35a36f | |||
| 089944622e | |||
| 09a73adb6a | |||
| ff7d88bccf | |||
| b292f3c86c | |||
| a6bda7887f | |||
| f970aa0c5b | |||
| 955662f139 | |||
| 7d6e77a879 | |||
| 3bfbde740b | |||
| 5fb231207f | |||
| fb6c0deff7 | |||
| 98a88d8bf5 | |||
| 06fe3b1cdc | |||
| e630c22843 | |||
| 5a5c10bbee | |||
| b919c9a086 | |||
| a41a025a1a | |||
| b84d6ab58d | |||
| 63f1f93ddd | |||
| 18a1a8cdc6 | |||
| 1c265427a7 | |||
| 4aa9154920 | |||
| 161ee30130 | |||
| a87404a224 | |||
| ac4aea0844 | |||
| 1e47a3cbaf | |||
| c825089886 | |||
| 83490cc7be | |||
| c95b8787c0 | |||
| 62c16e356b | |||
| a5be5a31e6 | |||
| 5d2f7686cc | |||
| cffb3c24f1 | |||
| e80374e618 | |||
| 0ea25686e4 | |||
| 73687d7353 | |||
| f6c689dd6c | |||
| 2960346805 | |||
| 6fdabd7269 | |||
| 4ada4e7f6e | |||
| f464080639 | |||
| c2e8b07de0 | |||
| 6f1e2c7ad9 | |||
| 05691f0d2d | |||
| e5bf5692c1 | |||
| e07956a276 | |||
| 9313112b5e | |||
| 6bbbd388d7 | |||
| 700d3ab5f1 | |||
| b4e20bdc8d | |||
| 0ff2ddbbea | |||
| bec56e4219 | |||
| d57e40a3db | |||
| 27e99bd091 | |||
| 1034822f35 | |||
| 61c7aa77eb | |||
| 12c4640c53 | |||
| 24a4bbecff | |||
| f262e02beb | |||
| 44c1225b21 | |||
| 69b3941776 | |||
| ba4b303554 | |||
| dcbcef9f05 | |||
| 57d229148d | |||
| 1c6b596ba8 | |||
| 6644982444 | |||
| a521fe613c | |||
| e83163ff7c | |||
| a1e356beaf | |||
| 9c3b4ccaf6 | |||
| 2b2d8f98cd | |||
| 822469803d | |||
| 4b169395fb | |||
| b54e718378 | |||
| f0a581eadb | |||
| aabf0ae6c1 | |||
| d61245daf3 | |||
| b5e1c7d100 | |||
| 4ba7812b9b | |||
| 98a6574596 | |||
| 61e051800b | |||
| 77ed3d8f83 | |||
| 8df497b356 | |||
| 2169e0bd1a | |||
| 825cd9a9f0 | |||
| ef280382a8 | |||
| 8e090379cc | |||
| ca06012678 | |||
| 11c5414f44 | |||
| f1dc70b963 | |||
| be59d7100b | |||
| b1786652ae | |||
| f819b0318a | |||
| 70c037d33d | |||
| 7615cb8cf1 | |||
| 6d10755f27 | |||
| ee2160fa8a | |||
| c5c4b7af5d | |||
| 8b4408e6fd | |||
| 0085f7deaf | |||
| 9eae8bfff9 | |||
| f6c1454ed5 | |||
| 7725c32567 | |||
| 3e854da56d | |||
| 5ad0f3448f | |||
| 288ca42ee1 | |||
| 0f2e41a222 | |||
| 0a26a7f3c5 | |||
| 07ad2d5be7 | |||
| a714d2bf21 | |||
| 0c00eb9b2f | |||
| c5b3fb5c86 | |||
| feab4dd020 | |||
| a461e62bf8 | |||
| 7368c137cc | |||
| 5b131567f7 | |||
| f437a4128b | |||
| 8962883e69 | |||
| 9b465eb45f | |||
| 96211eef3a | |||
| ea875b05a7 | |||
| a55a99e5bb | |||
| 0df2cea80c | |||
| 9588b0ee34 | |||
| 4299ec13da | |||
| fb44225163 | |||
| f34da4ff5d | |||
| 30595d6c08 | |||
| ae3147cec8 | |||
| 3f99f327f6 | |||
| 188ef7bff5 | |||
| ff8b19c75b | |||
| 88697d30c5 | |||
| 34448d56d2 | |||
| 3de3e992f7 | |||
| 7f1da17750 | |||
| 18500aa23f | |||
| 282bffa140 | |||
| 517d7aa868 | |||
| e1c63db7a3 | |||
| b571781578 | |||
| 4ae8a747b4 | |||
| 91d46fe0a7 | |||
| bc3a3e2f03 | |||
| 38e636c779 | |||
| 543b5be1c7 | |||
| 3292b369de | |||
| b9044b077f | |||
| cfe58f07a9 | |||
| 10254bfd6b | |||
| 842ae29199 | |||
| 358a99a8fb | |||
| 6ffcb83e1e | |||
| a2c8c14ef9 | |||
| c2ab369601 | |||
| 39caf1417e | |||
| 1723fc7258 | |||
| 5a03fc639b | |||
| 9641df10a7 | |||
| 92e8a12f81 | |||
| b91d477c26 | |||
| 39f215bea9 | |||
| 7c5ebac3d6 | |||
| a2e8ea4ffd | |||
| efb53579a8 | |||
| fc57039c00 | |||
| 17eced109d | |||
| 34ca85a72e | |||
| f0060c8442 | |||
| 6589486eca | |||
| 5a936d8364 | |||
| 602b85fcfd | |||
| 4a0f0d7c99 | |||
| 0a6f1d8f73 | |||
| 8c2008891f | |||
| 98bda601c5 | |||
| 22eadc832c | |||
| 577bb0e299 | |||
| 01f2049399 | |||
| 2981262277 | |||
| 94adec97b2 | |||
| 4652e293b1 | |||
| 9c4d0bc46f | |||
| c9dc812ff6 | |||
| 6b33141962 | |||
| b4c5db6b79 | |||
| 33dec64955 | |||
| 84627eb0a6 | |||
| ef61dae0f1 | |||
| dd5a26b959 | |||
| 49f513f025 | |||
| f183738a62 | |||
| 7bf659c2f5 | |||
| 0c18935f20 | |||
| 66438d574e | |||
| 5217bb52ad | |||
| bea1b222ae | |||
| 0013a92f6f | |||
| 4557632b97 | |||
| e7029952c0 | |||
| ca04aa5e12 | |||
| 96dbf70e59 | |||
| 87a0d82980 | |||
| 35f911b6d6 | |||
| d911bc32d0 | |||
| cb39026564 | |||
| e19157a60c | |||
| c2a5858967 | |||
| af6b1d198d | |||
| 75dfaa21da | |||
| b8d46e1b26 | |||
| f0df3d577a | |||
| dc1220f443 | |||
| 384a875945 | |||
| 0f7c290cb6 | |||
| 940892b3ab | |||
| a70e5b7e62 | |||
| 018d1d73ec | |||
| ba1b9e8b01 | |||
| c41e6f54b8 | |||
| d78661cf02 | |||
| f2f427cce6 | |||
| c5283cfecd | |||
| a3e940fd79 | |||
| 203b2085ef | |||
| 12b6f0120b | |||
| e2a3794016 | |||
| 34d0e062f3 | |||
| c8bca6d0de | |||
| 1db723de19 | |||
| ab7e91e06d | |||
| 50748ebdc9 | |||
| b3d708de0d | |||
| 09cf7b46dd | |||
| 52ebcf0041 | |||
| f1c3544fd2 | |||
| bc93af2cae | |||
| d14c097e30 | |||
| 2fcbfb3cd3 | |||
| 456d05fdcb | |||
| 8072046773 | |||
| cb58fb6af5 | |||
| f8d16ddaaa | |||
| b78ce01f57 | |||
| 6e7e4cd8f5 | |||
| 8c199d8ee8 | |||
| 9f3f4030dc | |||
| 40b4cc0f63 | |||
| 4cdff38675 | |||
| 76f54226de | |||
| 2c62f3018e | |||
| afe989f0e5 | |||
| cf357d9a5b | |||
| 0f3b8652ef | |||
| 42edfa8aa8 | |||
| 013fa36513 | |||
| 154d97c441 | |||
| a345b0a37e | |||
| 67c864a357 | |||
| e36348b039 | |||
| 62eda6a8e5 | |||
| a22f5a1349 | |||
| 149e6472f3 | |||
| 0da53b41c3 | |||
| 1a91302ac8 | |||
| 96bbb1afc3 | |||
| b329e3a089 | |||
| e2e15a6877 | |||
| 088812a7eb | |||
| 4ebb9a7a3f | |||
| 6db126e1f5 | |||
| 8ced378e34 | |||
| adb52cd062 | |||
| 942adcc721 | |||
| d8fce0c18f | |||
| 727bd30f84 | |||
| aac90b4be8 | |||
| f9e69bfd24 | |||
| c96991739f | |||
| 5c17e25e47 | |||
| 8944219804 | |||
| 4ec22e1917 | |||
| a3762a90ed | |||
| e827571eeb | |||
| d4f2834b75 | |||
| a2c47b87b9 | |||
| f199d633b1 | |||
| cd53f8515a | |||
| 86a519eeaa | |||
| 37f9b2a6e7 | |||
| d7fdfab9f1 | |||
| caaaa85354 | |||
| 52c93c9616 | |||
| ed81bc72ef | |||
| e72b06249e | |||
| 5e397c06c6 | |||
| 4f4cb8ee39 | |||
| 5ae722b6a4 | |||
| 84991d26a5 | |||
| 6f1bd0538a | |||
| 14880a54bb | |||
| fac1da9a06 | |||
| 24f3751ab0 | |||
| d76b8c965a | |||
| 1f2686ed28 | |||
| 4215dea758 | |||
| ccf89919f1 | |||
| 0184eebcd2 | |||
| fa839e6046 | |||
| bcafa912f0 | |||
| cfc18d8ee2 | |||
| 7bf0c61066 | |||
| ed4daeda4f | |||
| 7a503e642a | |||
| acbe6b6868 | |||
| 413388e7b4 | |||
| 50c9e85b01 | |||
| 06256f223c | |||
| ad421a809a | |||
| 7dbaa41389 | |||
| c1e0eb1b36 | |||
| 8ea488209c | |||
| 026f9b6a1d | |||
| 606348f5db | |||
| a52d0453bb | |||
| 2e396f4ec7 | |||
| 3418cc6c90 | |||
| 9b76f90725 | |||
| 393a3c5842 | |||
| 9d75415ebd | |||
| 60c0cf82d9 | |||
| d9dc35b543 | |||
| b9255b90ba | |||
| 875b3ca090 | |||
| 6474d7b9c2 | |||
| 7a9f7c4c44 | |||
| 19d000d3d0 | |||
| 9fc4751e8b | |||
| 61be896b08 | |||
| 3f782dfc36 | |||
| d6e0b6715c | |||
| d09edd0e49 | |||
| 464a32bf2a | |||
| a6df57f087 | |||
| f9960cc15e | |||
| a31a7383a4 | |||
| c90a352dee | |||
| 6a270146b7 | |||
| d8a7ae1748 | |||
| 4d54225434 | |||
| 3c59ac6708 | |||
| c166eac472 | |||
| f70e8ded6f | |||
| bee4b637b9 | |||
| 7e7c3dc217 | |||
| 74d1c96ca6 | |||
| a2d7747ed8 | |||
| 2d6108d7a8 | |||
| cf3b444a87 | |||
| 7f54d992ea | |||
| 85da1351d1 | |||
| 16f94aac77 | |||
| 5fbea70f92 | |||
| efe499456a | |||
| 0721850bd7 | |||
| 466febeb13 | |||
| 1f2d68600b | |||
| e54a2c1c5f | |||
| d38bd692af | |||
| eaa7281374 | |||
| 38947493a1 | |||
| f27e24e746 | |||
| dc042d982c | |||
| c0b1db3ea1 | |||
| ee631b5e5e | |||
| 8fecd0ab7c | |||
| e332d4e55d | |||
| 2367438d2e | |||
| 1fd0103a43 | |||
| 55cba30f17 | |||
| 3af4db41ac | |||
| dee4e0d751 | |||
| 0b587aaec6 | |||
| 5261645c40 | |||
| e6a15c04c8 | |||
| 3b04fff2c8 | |||
| fcfff0be06 | |||
| add7f637ee | |||
| d4b64055d0 | |||
| dbfdc41029 | |||
| 22d5d4692d | |||
| 896b3bb13a | |||
| 120e9b6304 | |||
| 7d31230870 | |||
| 332c093820 | |||
| eabf2373fb | |||
| 35de697cde | |||
| 24fc7cf3e2 | |||
| cdd9bd53ae | |||
| 4dd667bcb2 | |||
| 7056d40449 | |||
| 6bf2a1d733 | |||
| de8da1ab15 | |||
| 685e38818b | |||
| 9fb6ce40ba | |||
| b2fb22a890 | |||
| 4be9e32e8a | |||
| 567e303394 | |||
| db5b4085ca | |||
| 25c77a8ee0 | |||
| 30333873ca | |||
| 523bbf013f | |||
| 0cedb506c9 | |||
| 9aeaa0231a | |||
| d4b2d3f05b | |||
| 2de8d78094 | |||
| af3da4d5a0 | |||
| 5686665255 | |||
| a257bd79b5 | |||
| fff53c312b | |||
| 770994cf22 | |||
| 88964a36dc | |||
| dbb6d57d7c | |||
| 7ac12d3278 | |||
| 65ef5695d5 | |||
| 00513e1eef | |||
| 472fd7f49f | |||
| 0162ee44ef | |||
| 0721e41d5a | |||
| 499a0dfbd8 | |||
| cb39cda33e | |||
| e0f1aefa73 | |||
| 6a6100f11f | |||
| 1a40c9038b | |||
| 18ca40fac7 | |||
| c630cd0e59 | |||
| 297f041a0e | |||
| 308164f7f4 | |||
| 29c1986204 | |||
| 95e58ab6d1 | |||
| 42c70759d0 | |||
| 8055e5ee60 | |||
| 4462e13533 | |||
| a210eb5e81 | |||
| dd8f85a356 | |||
| b3db5ab69f | |||
| e7a7bd32ef | |||
| 9c36a10864 | |||
| 766236a78c | |||
| 98669eae02 | |||
| de9c20ac58 | |||
| 1ae5a6fcec | |||
| f852eb5631 | |||
| 1956a1db11 | |||
| 4ceff1c046 | |||
| 91f9b318ad | |||
| 5205184d6e | |||
| 15139add20 | |||
| d20f59313d | |||
| 5307758ebe | |||
| 5ded4dc3a3 | |||
| 87f405d57e | |||
| 3bb922955e | |||
| 04b58ece21 | |||
| afb145aac1 | |||
| ed419ada89 | |||
| fff6bdd624 | |||
| c56264b130 | |||
| 92f1de9155 | |||
| 826294b438 | |||
| 198c338892 | |||
| 36cbac5070 | |||
| 733841cfc1 | |||
| 3484ebf04e | |||
| b50a9b5406 | |||
| 21a85add82 | |||
| e6173a7f17 | |||
| 89f614fe77 | |||
| ac65d8423b | |||
| c8fe6053cf | |||
| 86993f455c | |||
| 502aa59192 | |||
| e209a2bdc5 | |||
| a3d3a2649d | |||
| 336077d24d | |||
| 487187cbb5 | |||
| 8c1061f34d | |||
| 2fecc22822 | |||
| b45b11f927 | |||
| 32cfb6b93c | |||
| 4848ef379a | |||
| a52b17985e | |||
| 8c87e1433c | |||
| 1a6577539f | |||
| 7a5da1e4c2 | |||
| 9b71df8ee4 | |||
| c201578191 | |||
| a1ced2ace6 | |||
| 9e47568e67 | |||
| 55225fdea3 | |||
| 8447319514 | |||
| a2b54aee0f | |||
| 99c736660d | |||
| 4e97b0964f | |||
| 2f404bee72 | |||
| 581fb45795 | |||
| afa2a45fe9 | |||
| dae302f6e3 | |||
| 583769ff5f | |||
| 2d1c6e5ed4 | |||
| 90ae3117ab | |||
| e7d98028a3 | |||
| 2e785222e9 | |||
| 4c9bc24ac7 | |||
| 7498657419 | |||
| b24b0e553d | |||
| 3ccee32232 | |||
| cdabb5772d | |||
| 5ca78942d1 | |||
| 485d2b01e3 | |||
| 1748dad9ea | |||
| 6d38990fd3 | |||
| f0255af222 | |||
| 0a2e94d3d7 | |||
| 241a73c2d0 | |||
| 738b916ab5 | |||
| 7189773694 | |||
| 7e626a2ad1 | |||
| 93a1f568c8 | |||
| 34da40dc59 | |||
| f0395fa6a9 | |||
| 3ca9dcbb88 | |||
| 0204f19541 | |||
| eea884e11a | |||
| cf55c4809c | |||
| ea9a2776b7 | |||
| ec95c84d87 | |||
| 677469e112 | |||
| c0237ab13c | |||
| 90c6c629d3 | |||
| 525b34d28c | |||
| b137c41d7a | |||
| 8e72fbdc0e | |||
| b14301711b | |||
| 3d4dd88c07 | |||
| 2b2db423a0 | |||
| 8087102482 | |||
| 5ccd44de5d | |||
| 389c0bcd9a | |||
| c9a99eecc1 | |||
| 8c4851b831 | |||
| ce75c5ee47 | |||
| f4be75e116 | |||
| a3dc388abb | |||
| d700910cfd | |||
| e9adf4fa4b | |||
| 0f4cd267f2 | |||
| 4fc5b437ae | |||
| 5635fbf57b | |||
| a2b6a9198f | |||
| b064f73b12 | |||
| 82580edb8c | |||
| 3cbb3bd26f | |||
| 31104d7f62 | |||
| bea6cac46b | |||
| 479492726a | |||
| 957c947929 | |||
| b042286edb | |||
| 8459660d90 | |||
| 45763a4223 | |||
| 8b1093d552 | |||
| b341801e16 | |||
| 153e17ee4a | |||
| b642ab0379 | |||
| 69121d25f3 | |||
| b317fce919 | |||
| a538c3cf9b | |||
| d95b3ba9f7 | |||
| fde6190226 | |||
| bb1d986113 | |||
| ebb3789d51 | |||
| 43b5f579c3 | |||
| 9ef5ff1dac | |||
| d41d678df3 | |||
| 3c43289e98 | |||
| b78675718d | |||
| 5038eed34e | |||
| fbfb79c328 | |||
| de14043c5c | |||
| eb0d1364b8 | |||
| ddcd082fee | |||
| eef64b414e | |||
| 410f28a4c3 | |||
| 4918e49b3f | |||
| f2212f5e9d | |||
| 52937d4d51 | |||
| 67b9f10156 | |||
| 11c9bd6a32 | |||
| 0ab18c9ebe | |||
| 6e12870182 | |||
| aaab8310b8 | |||
| 829eb8428d | |||
| 9c927e025d | |||
| 43e5ca50a6 | |||
| b5da5dbde6 | |||
| 75c3f2a522 | |||
| 4932d4d8e7 | |||
| c5d7c2b05a | |||
| 54cd34d0b9 | |||
| cd5d844d25 | |||
| 790fc6a042 | |||
| d16e028276 | |||
| 6b3df0e5bd | |||
| 321991b4b8 | |||
| f33d1b5407 | |||
| eab7ac809d | |||
| 61bd162177 | |||
| 2677bc6eb7 | |||
| 4b3f4e84a7 | |||
| 18239d4b79 | |||
| 5f6c8f4085 | |||
| 0f59440ce4 | |||
| c11b774c63 | |||
| cd86a66b0e | |||
| c400f78398 | |||
| d3d06806a3 | |||
| 8c8ff49513 | |||
| b7bdd265c6 | |||
| a5fdc49548 | |||
| 9c8e38e469 | |||
| 3115ab75a5 | |||
| fa199eef05 | |||
| c65653ef1e | |||
| 0fb0cca948 | |||
| 10acc10a16 | |||
| 3a40a92573 | |||
| 17e4ee9603 | |||
| 2c8bc106fb | |||
| 0cb3698fe6 | |||
| 9928727bd7 | |||
| 2455899373 | |||
| 8d0736e54c | |||
| 096378bdd3 | |||
| 863c7080d3 | |||
| 09ea2a5511 | |||
| 77dd47c435 | |||
| a7dd4f3c20 | |||
| 6ea342d983 | |||
| d59b35df11 | |||
| 5bb4068dbc | |||
| 4dba3fa998 | |||
| ca69b278c2 | |||
| 245a73b5b0 | |||
| 66e52c52bd | |||
| b18b68d124 | |||
| 04faa42987 | |||
| 93db789a0f | |||
| f48f75ab79 | |||
| 088488bb3a | |||
| 8cacabf1c9 | |||
| e3e9d39858 | |||
| c980326a4e | |||
| e203f6e0d5 | |||
| 1922c88306 | |||
| dc8179a23a | |||
| 28b9f0734a | |||
| 6a38286d45 | |||
| 6afd6f4f4f | |||
| 0c3e22e17d | |||
| ea4a58095d | |||
| 9ad3a2ea33 | |||
| d59e35ac86 | |||
| e2ba9d29ee | |||
| b037372619 | |||
| 22637f9d34 | |||
| e0128f2e6b | |||
| 1b0c301452 | |||
| 86ad4be8d0 | |||
| 8159810613 | |||
| efc4c4e5bd | |||
| 390208ecd4 | |||
| 054935a95d | |||
| c0c8b6fb32 | |||
| da8834fe96 | |||
| ae93aeb070 | |||
| c369c3487f | |||
| 3531140a13 | |||
| 0dc04a4901 | |||
| 5a7176c493 | |||
| 87a160fb58 | |||
| 4d86c77ced | |||
| 8c972a140b | |||
| a19a756750 | |||
| 5542c6ea11 | |||
| b8b1dad2de | |||
| cfaebed0fe | |||
| 9619fde4ed | |||
| d47b7c9f1c | |||
| 7eee0b66c6 | |||
| 92109f91fd | |||
| c0ba6415e2 | |||
| 32e2a40592 | |||
| 9d40ca26e0 | |||
| 632457ff3a | |||
| 550a6a5d7b | |||
| 9fa08f77bd | |||
| 52705775ce | |||
| ac14c6fa13 | |||
| 1ec7760d12 | |||
| 2dabefa2e1 | |||
| 43fb5573f4 | |||
| c410c05c82 | |||
| 37b99b8146 | |||
| 41228bc857 | |||
| 5566409ffa | |||
| 813cb7de13 | |||
| 490e215971 | |||
| f9e6b84fd9 | |||
| 36b977a53e | |||
| 087fe8e50f | |||
| 2d683bfcd2 | |||
| 113a446cd6 | |||
| 4e2ff481f5 | |||
| 70e2c022bb | |||
| a9105b05eb | |||
| 02b57d226a | |||
| 062901dbe8 | |||
| 4b280e3a91 | |||
| cc5b8576f6 | |||
| a87786d223 | |||
| 562826f0e1 | |||
| 3e1eace056 | |||
| cc4f921fd6 | |||
| e76794172d | |||
| d3f8389cfb | |||
| 31420ed236 | |||
| 17c0ca97ae | |||
| 3257389188 | |||
| 0862183467 | |||
| 4ef0f1ce91 | |||
| 79caad0d54 | |||
| dc2522ab7c | |||
| 324a3ca7da | |||
| a7d3bbb858 | |||
| b153607e32 | |||
| 6ac2db146e | |||
| fddf85e7a6 | |||
| 2ea19ad84d | |||
| 1cfb33ce42 | |||
| 83377eda4a | |||
| ae87e5b01b | |||
| fa4f642498 | |||
| 4220d1c5e3 | |||
| f50e1ddaa2 | |||
| 9f6af14b76 | |||
| 742189907c | |||
| 94041e307d | |||
| 8a8b5cef7a | |||
| c25850ec3a | |||
| 414eca717c | |||
| 3e30c3ae92 | |||
| 80052803cc | |||
| fba2459052 | |||
| 966e8f94d8 | |||
| aeb7bfc2e4 | |||
| 8fed630c0b | |||
| 403c05d061 | |||
| cdd70ee3fa | |||
| 289b6859b6 | |||
| b9f4678d70 | |||
| 960435f874 | |||
| 48d5304f0b | |||
| 918645b05e | |||
| e781554059 | |||
| 9cb42d38cb | |||
| 324311b767 | |||
| 6356de7cf2 | |||
| 76b1fa3775 | |||
| 6980865015 | |||
| d7696e83d6 | |||
| b9984b7236 | |||
| ad43ecbc84 | |||
| fbc6df6f87 | |||
| 87ecbb9407 | |||
| 3712ae9395 | |||
| a6e1b4cccc | |||
| 64d323570c | |||
| 9e98025f24 | |||
| 6c040538f5 | |||
| 0d4ae999d2 | |||
| 4be3f9b33d | |||
| 0c768874ae | |||
| 337ee3ec2c | |||
| b9fa079eb7 | |||
| 85295cb03f | |||
| 3ee138d81d | |||
| 4218731441 | |||
| ba3419d692 | |||
| a6d3e7855b | |||
| e047cfbbf4 | |||
| aaa721447a | |||
| 004eb146bf | |||
| cf300efdaa | |||
| 750333990d | |||
| 036d98a169 | |||
| 02e7f738fc | |||
| 26f5f854be | |||
| 41f9ebf886 | |||
| 53945b0846 | |||
| fd9fda9f47 | |||
| 0328f969dc | |||
| a6cfc6b011 | |||
| 4997560046 | |||
| d770a4866a | |||
| 16e7244065 | |||
| c45766f2d9 | |||
| 4f5c2ef090 | |||
| 7c99a9c67c | |||
| 5b1e580a4f | |||
| 6d312ba589 | |||
| ac22a31427 | |||
| 368906787c | |||
| 7ace3b7d91 | |||
| 6bf3149bea | |||
| a275c608a4 | |||
| 41d433b7c8 | |||
| 7950d7d5ea | |||
| 97801653fe | |||
| 9099997b2c | |||
| 7f02874923 | |||
| 84d02f8ec4 | |||
| a897d095cf | |||
| 2d9a6ab24e | |||
| f671c5a958 | |||
| 8fcf31a349 | |||
| ddb99a311f | |||
| eef6bde7fe | |||
| 8ceea4b491 | |||
| dfc5337b06 | |||
| 396d02e7a3 | |||
| 4701abc691 | |||
| 7d78c0532b | |||
| b65d00c8b4 | |||
| 70f1f5d2a8 | |||
| abe870ece1 | |||
| 7a2701d72d | |||
| b09f48ccdc | |||
| 9192ffa63f | |||
| e6b05806f0 | |||
| 7698a02a31 | |||
| 6e3c51cd97 | |||
| 27ff27a057 | |||
| 00094f8850 | |||
| 6c6321aa03 | |||
| 8cd1f1bcc7 | |||
| c9e1d090ff | |||
| c47917efc4 | |||
| 84824d1ada | |||
| 15e8d7fb6c | |||
| 00424b2384 | |||
| 09ea177d89 | |||
| d58aebf7f6 | |||
| c0506f87f7 | |||
| ec4fc33137 | |||
| 73613d901f | |||
| 1c579bd6e7 | |||
| 937300fad3 | |||
| f9b16e7671 | |||
| d7d865a6c9 | |||
| 489f3603de | |||
| 6f355d2859 | |||
| ad1b690fe1 | |||
| b5920bfc6e | |||
| ca9ae4ca6b | |||
| e5b6ff8301 | |||
| 90db71b2e3 | |||
| 59808c1374 | |||
| ad22fea86d | |||
| d13ab10d4d | |||
| 4b7feb9b5b | |||
| e899dad637 | |||
| 8502a22ffa | |||
| 742735ea39 | |||
| ac56b3e432 | |||
| b7666c1dc8 | |||
| 90020f8152 | |||
| 45615e8f75 | |||
| f61e4d1964 | |||
| a16f225746 | |||
| 7fe19b8c26 | |||
| 5c4aecab55 | |||
| f366bd56b9 | |||
| 171c35d23c | |||
| 53d9453e8b | |||
| 522e75cea6 | |||
| 3164b1a879 | |||
| 2c13fbaca4 | |||
| 9a4abe0da2 | |||
| cc28e24e02 | |||
| 943fd3d174 | |||
| edeb09ffc6 | |||
| 1dc0b4e2af | |||
| f698ba4e38 | |||
| 9401f80108 | |||
| 5dcd19c681 | |||
| 0a41760a24 | |||
| 0069b7639b | |||
| 85191ed0b2 | |||
| f8f8a50418 | |||
| a6a9ddfa02 | |||
| 1558e78b2b | |||
| bcf16ad669 | |||
| 6f13d9c0ae | |||
| 935b7b3ef1 | |||
| 66d6928e4d | |||
| 78cd3abe15 | |||
| cb793fee58 | |||
| d677d52274 | |||
| 551cbf0049 | |||
| ed1355bb4f | |||
| 92d3810a2b | |||
| 49c6c3767f | |||
| e5131bf9f7 | |||
| e6d8a7cb87 | |||
| 772d091425 | |||
| 9d524b07ec | |||
| 37cb24c46e | |||
| c9fc3113a2 | |||
| 7159e3d336 | |||
| b2e9301cc6 | |||
| 460b2c947e | |||
| 92369f9165 | |||
| 119a6eaa17 | |||
| 7f49fbc107 | |||
| 9e198c3102 | |||
| 9ac70f9dfd | |||
| 7ab25c0207 | |||
| 60e0bc52e6 | |||
| 71c3b530cb | |||
| e5771980ba | |||
| d7d30d30f5 | |||
| 6a67df768a | |||
| 9c8cd51b18 | |||
| cb9447ed5b | |||
| be2c8efbf6 | |||
| 79a89c22b9 | |||
| f48171b11a | |||
| 9b8b2fcba7 | |||
| 51c9d85aef | |||
| db45c71636 | |||
| 73034f2f74 | |||
| 0deae9e495 | |||
| 30be401b30 | |||
| 0bb0ae7888 | |||
| d81ca33b0a | |||
| f194d91d90 | |||
| aa86effe5d | |||
| d5b47d1beb | |||
| 16df3e3238 | |||
| 84303b93d2 | |||
| 5521abbf95 | |||
| 77d490c9c3 | |||
| d9de481c39 | |||
| ccd12b57ed | |||
| 2d9a9ab046 | |||
| f5b59a7a22 | |||
| a212b15068 | |||
| 24d578d392 | |||
| 669b599707 | |||
| f0cb91a21f | |||
| 5645ca17e8 | |||
| 12cffcc75d | |||
| 2b5451d3ce | |||
| 1d209c5be9 | |||
| 48d38ff110 | |||
| 06bcaac67d | |||
| 86c8adc3d9 | |||
| 1c67419483 | |||
| 1516e27c5a | |||
| f71a835d1b | |||
| 42b283e956 | |||
| b30a5eeed6 | |||
| 9f9a190cc9 | |||
| b2bd070c9c | |||
| c029cd8cc6 | |||
| 860cea2369 | |||
| d1b132d267 | |||
| a3892b183e | |||
| 94cce31f47 | |||
| 92b79b124f | |||
| b76e0aae32 | |||
| ce18606949 | |||
| e8ec110ecd | |||
| 1594536d01 | |||
| 37d05afd24 | |||
| 746257b831 | |||
| cadef48cb5 | |||
| c26dbba312 | |||
| 3b6eab2b46 | |||
| 0bb0e9d037 | |||
| dc36be558c | |||
| 699af576e3 | |||
| 207b32e600 | |||
| 5b2c692d95 | |||
| 6e9a13b44e | |||
| 22a62ab082 | |||
| 01d3e44d95 | |||
| 3e83a041e9 | |||
| a00332328b | |||
| 4a38bc2fee | |||
| 7eceef4818 | |||
| 88daa2b01a | |||
| dbd92a9df9 | |||
| 366e293e9f | |||
| 5222413c57 | |||
| ead25a3533 | |||
| dac296f8b9 | |||
| 098c1585a1 | |||
| 27c1e0f1c1 | |||
| ec8d5d774f | |||
| e9d0a8a9df | |||
| d19202de9b | |||
| c27a157ebb | |||
| ec7c02db77 | |||
| 0b752a7886 | |||
| 7742b7ba1a | |||
| ff545f4dbc | |||
| 2e7369ee51 | |||
| 2f68ef43da | |||
| fd747d49fb | |||
| 5b80258418 | |||
| 5b1110a3ed | |||
| 9664cb239e | |||
| 24cf162f9b | |||
| af08d5c239 | |||
| dc3d536f0b | |||
| dafebfadc5 | |||
| cb10515c13 | |||
| 156783af7c | |||
| 46c526a515 | |||
| 8724d60d60 | |||
| 2c4e25be59 | |||
| 952d6e83e3 | |||
| 6334865d3f | |||
| d894216c54 | |||
| b9e89e3ffb | |||
| c385228d73 | |||
| 5fcb71dfd1 | |||
| 8322858e20 | |||
| 4e9a289692 | |||
| a097138299 | |||
| 8a53f53d99 | |||
| f0543da790 | |||
| 472c22fcfb | |||
| eb2f2f86f0 | |||
| 72147c7edf | |||
| 2a360d32a6 | |||
| 2eaea8ee26 | |||
| 254562f940 | |||
| fa4367e8d9 | |||
| 0820aa5675 | |||
| 7f13150557 | |||
| a0a4fd136f | |||
| 6c3402fa8d | |||
| eb1ca9d7b1 | |||
| f7d2a5f23b | |||
| abc9364afb | |||
| e027147c99 | |||
| ce2fc54e66 | |||
| a8e39e3125 | |||
| 821e4d7a87 | |||
| 6404c2d99f | |||
| a6be5844e6 | |||
| e40fedb812 | |||
| 09c5091d1c | |||
| 727100f942 | |||
| 574a95fd14 | |||
| 10a00750d7 | |||
| 0b40903ae3 | |||
| 556b62065a | |||
| 51c926c20b | |||
| 96e5c0120e | |||
| 4bebbc204e | |||
| 51912bf3a8 | |||
| 9c4b23905d | |||
| 8d1c597131 | |||
| 8a2bb2e993 | |||
| 0586488d90 | |||
| 176de41288 | |||
| 92f4b78801 | |||
| a9d4c6399f | |||
| d31e1e4bfd | |||
| a39dce4cf8 | |||
| 044d0253ca | |||
| 036de5de95 | |||
| c3c07e2ccb | |||
| 4fe7155f0c | |||
| 83fbe8d881 | |||
| c610352868 | |||
| 217ec34a70 | |||
| 4ddd5dbf03 | |||
| 217f0f47ac | |||
| 8d37376fb1 | |||
| bfebdd2632 | |||
| ee2068eda5 | |||
| 5a6c7da549 | |||
| a29be94d08 | |||
| 20ec956b77 | |||
| 8335e4de96 | |||
| d53e0fbdd7 | |||
| d39be76f0f | |||
| ee1dd570d0 | |||
| 78a51b6817 | |||
| b089ccc39c | |||
| c8a1ccef30 | |||
| 3d93013f75 | |||
| 77c19504be | |||
| 5f7c942354 | |||
| ebb41422f3 | |||
| b4a728213d | |||
| fde47de5ed | |||
| 78d2f447eb | |||
| 702d4f62bb | |||
| a4eb4d58ae | |||
| 80fd882815 | |||
| 3c993c576e | |||
| c3eeadece5 | |||
| 95dad78a7f | |||
| 0498009a42 | |||
| f068a2a9ee | |||
| 3cb2432d14 | |||
| fa3b1d014f | |||
| 8438fa568d | |||
| f1f74019b4 | |||
| c68a5320a3 | |||
| 2581b09ae5 | |||
| 5794c541b0 | |||
| 4ceb989884 | |||
| 7e22e3548e | |||
| 13714677d3 | |||
| f3e730b131 | |||
| 216553f526 | |||
| 2c9ac0c7c2 | |||
| 47dc48555e | |||
| 892f748610 | |||
| 7a221e0cb3 | |||
| 741a707994 | |||
| a9734c90d9 | |||
| 9c36c7be4e | |||
| 72e604bd43 | |||
| 9326f2c4d0 | |||
| 489161437a | |||
| 8fb69b7e9c | |||
| b73149ad67 | |||
| 71f99e68e6 | |||
| eab0548b44 | |||
| 87d27b22f9 | |||
| 928eb4f32c | |||
| 506201f037 | |||
| 6009314efd | |||
| 20ceef0889 | |||
| ebad574330 | |||
| 853e34b12b | |||
| 3a9b16512a | |||
| 25ade94314 | |||
| d5790c5c15 | |||
| d49e9ef89b | |||
| 84e3712e22 | |||
| 3b3a5faad4 | |||
| b55d6a2c24 | |||
| 701c633cc5 | |||
| 3eac154ab6 | |||
| 34bd7e66ec | |||
| f965acaf27 | |||
| 9338532c8c | |||
| 89ebf6e9b5 | |||
| d519f4c04c | |||
| 4cb79807c6 | |||
| e765a5e9c8 | |||
| 100f952a92 | |||
| 6c220b5de5 | |||
| 21d14a0ecd | |||
| 74c69a42c9 | |||
| 677cf8e3d1 | |||
| 7c73bf17b9 | |||
| afa2a653d4 | |||
| 6374b1a81c | |||
| 66e64e3af3 | |||
| b82f20302a | |||
| b4c4ac6c03 | |||
| 19d681b08b | |||
| 475c7d6dc9 | |||
| 4abb6526f3 | |||
| a6a14a3457 | |||
| 1d524a1e5b | |||
| 56c6aaaef0 | |||
| 74102312d0 | |||
| e0db4dac3e | |||
| 05de378cdd | |||
| cd62300547 | |||
| 9302b1c8a5 | |||
| 7de3eb1153 | |||
| 60d2f5da1c | |||
| 0fcf6638c4 | |||
| 005b504422 | |||
| bb7c3bd337 | |||
| d12ac42513 | |||
| d0adc9ea4f | |||
| e09000480c | |||
| 7be6317e5e | |||
| ec2f7f0451 | |||
| 3546c0f1f1 | |||
| fe23b239db | |||
| 46694f67da | |||
| c68ee2d74e | |||
| 4f77a335e8 | |||
| 691a930893 | |||
| b0da66f2e8 | |||
| 74479dc5b9 | |||
| 7369f01d26 | |||
| c675bed506 | |||
| 3e78565e1d | |||
| 04cd7a74fa | |||
| 2d53f3c70f | |||
| 7745643c97 | |||
| 956a4ff911 | |||
| 59693bec9c | |||
| 4e2b937740 | |||
| 4d45778805 | |||
| c3d0a41918 | |||
| c0dd6ef480 | |||
| cd2123e555 | |||
| 76831f65ce | |||
| 0f7e2d5bad | |||
| 079169d8aa | |||
| e9efe70112 | |||
| fc2380d68c | |||
| 6b8a289908 | |||
| 2f8f286788 | |||
| fd10a41ec5 | |||
| 510f1cc570 | |||
| 3558205135 | |||
| 2b148a1982 | |||
| a3f894359e | |||
| 6cb9ccddfa | |||
| 9ff565927e | |||
| cca05eb926 | |||
| 90fbcb18ba | |||
| d5032e4fee | |||
| ec4506ebf4 | |||
| a56db5ea2b | |||
| 520e443712 | |||
| ca4f94ee57 | |||
| a722a18482 | |||
| 56e8c3b4a9 | |||
| 08312733eb | |||
| b55ae5f4c4 | |||
| 6604204b51 | |||
| 74f0305960 | |||
| 1778b61018 | |||
| 78271d7ffa | |||
| 88cc80db16 | |||
| 90d765d224 | |||
| 15db4490ce | |||
| 35357b8dc7 | |||
| dbece52cc3 | |||
| 5d981328db | |||
| 8498cf7b8d | |||
| f360a72e75 | |||
| 7ad40daeb9 | |||
| 676117c053 | |||
| fe837da592 | |||
| 0ce34f4135 | |||
| 2f333dac32 | |||
| c55c333bec | |||
| 2065553f97 | |||
| b6bbd1532c | |||
| a8143e235d | |||
| 9fac05d49e | |||
| e0b1d7c49c | |||
| 0b1ed7343f | |||
| d734872dfa | |||
| 50840eaa90 | |||
| e71ce2b338 | |||
| f8addc663b | |||
| eed78f7639 | |||
| 1cd41d9bec | |||
| 2c8b4cafe6 | |||
| 3a6a8afb41 | |||
| 5ab72d9d7a | |||
| ba289865ac | |||
| b8e6e71da6 | |||
| cff50a10fa | |||
| cb5b8f9a93 | |||
| 606325439f | |||
| e9ed64608f | |||
| 36330f6d46 | |||
| eb40b899e0 | |||
| 23640cd8bd | |||
| 21e8761d48 | |||
| d1249b4e4b | |||
| 34334fd160 | |||
| 82f91861f4 | |||
| 4b4e013212 | |||
| 177942648d | |||
| 57fa3b4912 | |||
| f1ec6785f6 | |||
| 4abcf45ff4 | |||
| 899866e595 | |||
| 722aa7d601 | |||
| 6f84148434 | |||
| 0dca9f0088 | |||
| 25c7ded898 | |||
| 722f034830 | |||
| 87f3e767e4 | |||
| a914dbc469 | |||
| 545480056a | |||
| 3ef3b12197 | |||
| 1a2c0419d8 | |||
| 7e90cfd4fd | |||
| 6e0e906369 | |||
| 492d007314 | |||
| 586f2795e3 | |||
| e5247170aa | |||
| 565c84ba71 | |||
| c07869e928 | |||
| ae18c8ddac | |||
| 1a43114f27 | |||
| 6e2c5a0ec7 | |||
| 4f272fc3a1 | |||
| 57dc1f2c4d | |||
| e225dd622c | |||
| 1efc8519e0 | |||
| 142797926d | |||
| d2520ade06 | |||
| 415ae401fd | |||
| 894fec8ab5 | |||
| d01980515b | |||
| 7fffa955ae | |||
| b3ec73fc75 | |||
| 4b23781a75 | |||
| 7cdce584eb | |||
| 710c894c5d | |||
| 8fd6fa14ca | |||
| 6ec855e93c | |||
| 41457c4c43 | |||
| d4804a5d83 | |||
| 39919f5045 | |||
| 82c9f6d762 | |||
| 2ae0b3f97d | |||
| 857f088da4 | |||
| 1ac9181942 | |||
| 0cdb77f2ad | |||
| d34d5040fb | |||
| 765fc00aa2 | |||
| 3d61ab45ec | |||
| 443d4d1e9b | |||
| 45cfdcdbd6 | |||
| acf591faca | |||
| abcc07c7ba | |||
| 220e473224 | |||
| 3b87ab5bcd | |||
| fce1b4c584 | |||
| 86719ec3d2 | |||
| 3a23e7ecd6 | |||
| ff5f6cd37c | |||
| 378e00147e | |||
| 482c96f0f3 | |||
| 497f0a2233 | |||
| f1c0261cea | |||
| e59d49af03 | |||
| 2d800082b2 | |||
| 352c081f03 | |||
| a786730ca6 | |||
| df21c42353 | |||
| 155f9326b5 | |||
| 5405dbfe39 | |||
| d7fd89c993 | |||
| 6f85366c9c | |||
| 943eee0b9d | |||
| 427769f56c | |||
| 6de678649c | |||
| cb63745b5a | |||
| 1ceb8dacb6 | |||
| 8b2055b352 | |||
| a2e67b71e3 | |||
| 81272c4fe8 | |||
| 6527b66c24 | |||
| 6baa4b94aa | |||
| eca04d4a81 | |||
| 7622801c40 | |||
| 954ddc8f6f | |||
| 94e3fa058f | |||
| 3cc393816e | |||
| acc7da2c07 | |||
| ea1b802f77 | |||
| d354b2ac07 | |||
| e5292a1504 | |||
| d1e7ed388f | |||
| e02cc37a63 | |||
| d285b22161 | |||
| b633518630 | |||
| 1923f3d2e1 | |||
| 5a245f9f36 | |||
| 9d1bb9e670 | |||
| ce0a94dd90 | |||
| 40348ffd22 | |||
| 4d8936f989 | |||
| 82e55421d6 | |||
| e95a89c86a | |||
| f39ef910aa | |||
| 93aa8d5d00 | |||
| 723b18abb9 | |||
| 07a3edf5b4 | |||
| 576ff0b407 | |||
| 73e9341ee7 | |||
| 34aaa563b2 | |||
| ea8ef913b4 | |||
| fd00d9ee6b | |||
| 92d7bc2fa2 | |||
| 765b534ba8 | |||
| ca6829a3ba | |||
| 35555e3d7c | |||
| 38a30553b4 | |||
| f479a7066c | |||
| 1e43122c3d | |||
| 414f35e353 | |||
| c5039c3152 | |||
| b2d60b70f0 | |||
| c6d7c66a8c | |||
| ab4d13fa14 | |||
| 29d5595ec8 | |||
| 852f6610f8 | |||
| 4fddb75f05 | |||
| 4650ca57fb | |||
| 9526c6f9cc | |||
| 8d095ea2f3 | |||
| 47d9efd1ec | |||
| 514f4be140 | |||
| 7eaf2531de | |||
| 293d768f8b | |||
| 8f3e9eefb0 | |||
| 610256f839 | |||
| 8077f8731f | |||
| ec6954733d | |||
| ab9a19d4f1 | |||
| 5e43913915 | |||
| 3ac8912cd5 | |||
| 4994c2a17b | |||
| c708d35b7a | |||
| 41d7b861e0 | |||
| b1fcd54fe0 | |||
| 060d921cbc | |||
| 885f1fe08b | |||
| 1c3c0ea9d4 | |||
| 69d27e1049 | |||
| ee4b64febe | |||
| 65ad6b5085 | |||
| 273d32f2ec | |||
| fdd9aba29a | |||
| 28cd165561 | |||
| 0e7183062e | |||
| 11c11884e7 | |||
| e65c238d37 | |||
| d29069256d | |||
| bc7ae51ce8 | |||
| a0fbc55607 | |||
| 8e359831e9 | |||
| d758950189 | |||
| a76c04b993 | |||
| 5300a3c289 | |||
| 509230445f | |||
| 98241c47c6 | |||
| e4feb4d1e8 | |||
| c93e8e26e4 | |||
| c5a7a9e3ea | |||
| 85d1c30e81 | |||
| 1aff8da252 | |||
| 5aa4a7a513 | |||
| 8f4213678f | |||
| e65fff3ac0 | |||
| 34ee987b03 | |||
| de5c31b605 | |||
| 2e4c98e4bf | |||
| e7bf9ec5e4 | |||
| 3826bcd8c8 | |||
| f166b72b7d | |||
| 2319197b81 | |||
| 7fa63850fc | |||
| c0d16b9d89 | |||
| ec6889d815 | |||
| 249d1d7323 | |||
| fba7c28051 | |||
| 25cd1e9a7f | |||
| 9c26a9dd94 | |||
| 94cb7cd030 | |||
| bc900f87cc | |||
| 2c9ab8fdfc | |||
| 88ad16668d | |||
| 644866f3ef | |||
| dae0f5b159 | |||
| 0323763e83 | |||
| feb1ad2ac0 | |||
| af51db6b7f | |||
| 56d564c1c1 | |||
| 58f163837f | |||
| ab7410a02b | |||
| 96f8fa3375 | |||
| 30d2b3679a | |||
| c304c32b28 | |||
| 54c9ff63f5 | |||
| 4e56114d3c | |||
| c3959d8513 | |||
| bfdbbe8de4 | |||
| 830aa15d24 | |||
| 2d2b28e49a | |||
| fa3a3a4492 | |||
| c6e317f93d | |||
| ebcb93ee7d | |||
| abcca7bf0b | |||
| 85e104adfd | |||
| dab6c21957 | |||
| d56b6c1420 | |||
| e9487fa58a | |||
| 901d16349e | |||
| a67899adb5 | |||
| 978c6040f8 | |||
| fee295810b | |||
| 95151048b9 | |||
| 3b13a6a4ee | |||
| b29d557e5b | |||
| 2d0ba17044 | |||
| c9cb3f10a8 | |||
| 8b0c60cd2d | |||
| 490714f5c0 | |||
| a9e338ba72 | |||
| ef7fc8173b | |||
| 828510a39d | |||
| 5ad0d51001 | |||
| 619315b533 | |||
| 740a9517ab | |||
| bd43e03d1b | |||
| deeb585e40 | |||
| e8399e4590 | |||
| 85a000b8df | |||
| a3bafa610f | |||
| c36e49c7df | |||
| 1e36c38d24 | |||
| 0c4977dc13 | |||
| e264cc0f1f | |||
| 34e42d3846 |
36
.env
36
.env
@@ -2,22 +2,24 @@ APP_NAME='W4RP Services'
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:PBOxrGFJAtwj9SDF4F0DZ1J+6MjrJmRiPZJQwRdy3XQ=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
APP_URL=https://services.w4rp.space
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_CHANNEL=daily
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=w4rpservices2
|
||||
DB_USERNAME=minerva
|
||||
DB_PASSWORD=strtmage
|
||||
DB_PASSWORD=FuckingShit12
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
CACHE_DRIVER=redis
|
||||
CACHE_PREFIX=w4rpservices_cache
|
||||
|
||||
QUEUE_CONNECTION=database
|
||||
QUEUE_DRIVER=database
|
||||
QUEUE_DRIVER=redis
|
||||
QUEUE_CONNECTION=redis
|
||||
QUEUE_PREFIX=w4rpservices_queue
|
||||
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
@@ -25,6 +27,8 @@ SESSION_LIFETIME=120
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
REDIS_DATABASE=0
|
||||
REDIS_CACHE_DB=1
|
||||
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_HOST=smtp.mailtrap.io
|
||||
@@ -33,19 +37,11 @@ MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
ESI_CLIENT_ID=e5848fea3618427a8ee0dccb6a04fc62
|
||||
ESI_SECRET_KEY=TdnNGRM8RTNSifZdaIc9yHTTkYPgYEEXHRIbT6oY
|
||||
ESI_CLIENT_ID=91a051aea72742068b51801042397c38
|
||||
ESI_SECRET_KEY=1co6qRMoXyx1dG2iBbAZ1z6NUOoaJWyQnqEnsqoj
|
||||
ESI_USERAGENT='W4RP Services'
|
||||
ESI_CALLBACK_URI='http://services.w4rp.space/callback'
|
||||
ESI_CALLBACK_URI=https://services.w4rp.space/callback/
|
||||
ESI_PRIMARY_CHAR=93738489
|
||||
ESI_ALLIANCE=99004116
|
||||
|
||||
EVEONLINE_CLIENT_ID=e5848fea3618427a8ee0dccb6a04fc62
|
||||
EVEONLINE_CLIENT_SECRET=TdnNGRM8RTNSifZdaIc9yHTTkYPgYEEXHRIbT6oY
|
||||
EVEONLINE_REDIRECT='https://services.w4rp.space/callback'
|
||||
HORIZON_PREFIX=w4rpservices_horizon
|
||||
|
||||
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,4 +1,11 @@
|
||||
/node_modules
|
||||
/logs
|
||||
.editorconfig
|
||||
/.editorconfig
|
||||
/cache
|
||||
/public/logs/*
|
||||
worker.log
|
||||
/public/cache/*
|
||||
.env
|
||||
.vscode
|
||||
/storage/logs
|
||||
worker.log
|
||||
172
app/Console/Commands/Data/CleanStaleDataCommand.php
Normal file
172
app/Console/Commands/Data/CleanStaleDataCommand.php
Normal file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Data;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Models
|
||||
use App\Models\Lookups\AllianceLookup;
|
||||
use App\Models\Lookups\CharacterLookup;
|
||||
use App\Models\Lookups\CorporationLookup;
|
||||
use App\Models\Lookups\ItemLookup;
|
||||
use App\Models\Finances\AllianceMarketJournal;
|
||||
use App\Models\Finances\JumpBridgeJournal;
|
||||
use App\Models\Finances\OfficeFeesJournal;
|
||||
use App\Models\Finances\PISaleJournal;
|
||||
use App\Models\Finances\PlanetProductionTaxJournal;
|
||||
use App\Models\Finances\ReprocessingTaxJournal;
|
||||
use App\Models\Finances\SovBillJournal;
|
||||
use App\Models\Finances\StructureIndustryTaxJournal;
|
||||
|
||||
class CleanStaleDataCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'data:CleanData';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Clean old database data';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Empty the item lookup table
|
||||
ItemLookup::truncate();
|
||||
|
||||
//Empty the character lookup table
|
||||
CharacterLookup::truncate();
|
||||
|
||||
//Empty the corporation lookup table
|
||||
CorporationLookup::truncate();
|
||||
|
||||
//Empty the alliance lookup table
|
||||
AllianceLookup::truncate();
|
||||
|
||||
//Setup today's carbon date
|
||||
$today = Carbon::now();
|
||||
$ago = $today->subMonths(6);
|
||||
|
||||
//Clean old data from the Alliance Market Tax Journal
|
||||
$markets = AllianceMarketJournal::all();
|
||||
foreach($markets as $market) {
|
||||
$date = new Carbon($market->created_at);
|
||||
if($date->lessThan($ago)) {
|
||||
AllianceMarketJournal::where([
|
||||
'id' => $market->id,
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
//Clean old data from Jump Bridge Journal
|
||||
$jumps = JumpBridgeJournal::all();
|
||||
foreach($jumps as $jump) {
|
||||
$date = new Carbon($jump->created_at);
|
||||
if($date->lessThan($ago)) {
|
||||
JumpBridgeJournal::where([
|
||||
'id' => $jump->id,
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
//Clean old data from office fees journal
|
||||
$offices = OfficeFeesJournal::all();
|
||||
foreach($offices as $office) {
|
||||
$date = new Carbon($office->created_at);
|
||||
if($date->lessThan($ago)) {
|
||||
OfficeFeesJournal::where([
|
||||
'id' => $office->id,
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
//Clean old data from pi sale journal
|
||||
$pisales = PISaleJournal::all();
|
||||
foreach($pisales as $sale) {
|
||||
$date = new Carbon($sale->created_at);
|
||||
if($date->lessThan($ago)) {
|
||||
PISaleJournal::where([
|
||||
'id' => $sale->id,
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
//Clean old data from planet production tax journal
|
||||
$pis = PlanetProductionTaxJournal::all();
|
||||
foreach($pis as $pi) {
|
||||
$date = new Carbon($pi->created_at);
|
||||
if($date->lessThan($ago)) {
|
||||
PlanetProductionTaxJournal::where([
|
||||
'id' => $pi->id,
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
//Clean old data from player donation journal
|
||||
$donations = PlayerDonationJournal::all();
|
||||
foreach($donations as $donation) {
|
||||
$date = new Carbon($donation->created_at);
|
||||
if($date->lessThan($ago)) {
|
||||
PlayerDonationJournal::where([
|
||||
'id' => $donation->id,
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
//Clean old data from Reprocessing Tax Journal
|
||||
$reps = ReprocessingTaxJournal::all();
|
||||
foreach($reps as $rep) {
|
||||
$date = new Carbon($rep->created_at);
|
||||
if($date->lessThan($ago)) {
|
||||
ReprocessingTaxJournal::where([
|
||||
'id' => $rep->id,
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
//Clean old sov bill journal data
|
||||
$sovs = SovBillJournal::all();
|
||||
foreach($sovs as $sov) {
|
||||
$date = new Carbon($sov->created_at);
|
||||
if($date->lessThan($ago)) {
|
||||
SovBillJournal::where([
|
||||
'id' => $sov->id,
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
//Clean old structure industry tax journal data
|
||||
$industrys = StructureIndustryTaxJournal::all();
|
||||
foreach($industrys as $indy) {
|
||||
$date = new Carbon($indy->created_at);
|
||||
if($date->lessThan($ago)) {
|
||||
StructureIndustryTaxJournal::where([
|
||||
'id' => $indy->id,
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
50
app/Console/Commands/Data/EmptyJumpBridges.php
Normal file
50
app/Console/Commands/Data/EmptyJumpBridges.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Data;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
//Models
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Service;
|
||||
use App\Models\Structure\Asset;
|
||||
|
||||
class EmptyJumpBridges extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'data:EmptyJumpBridges';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Reset the jump bridge fuel related tables.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Structure::truncate();
|
||||
Service::truncate();
|
||||
Asset::truncate();
|
||||
}
|
||||
}
|
||||
80
app/Console/Commands/Data/GetCorpsCommand.php
Normal file
80
app/Console/Commands/Data/GetCorpsCommand.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Data;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
//Models
|
||||
use App\Models\Corporation\AllianceCorp;
|
||||
use App\Models\ScheduledTask\ScheduleJob;
|
||||
|
||||
//Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
class GetCorpsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'data:GetCorps';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get corporations in alliance and store in db.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
$esi = $esiHelper->SetupEsiAuthentication();
|
||||
|
||||
//try the esi call to get all of the corporations in the alliance
|
||||
try {
|
||||
$corporations = $esi->invoke('get', '/alliances/{alliance_id}/corporations/', [
|
||||
'alliance_id' => 99004116,
|
||||
]);
|
||||
} catch(RequestFailedException $e){
|
||||
dd($e->getEsiResponse());
|
||||
}
|
||||
//Delete all of the entries in the AllianceCorps table
|
||||
AllianceCorp::truncate();
|
||||
|
||||
//Foreach corporation, make entries into the database.
|
||||
foreach($corporations as $corp) {
|
||||
try {
|
||||
$corpInfo = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $corp,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
}
|
||||
$entry = new AllianceCorp;
|
||||
$entry->corporation_id = $corp;
|
||||
$entry->name = $corpInfo->name;
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
46
app/Console/Commands/Data/PurgeCorpMoonLedgers.php
Normal file
46
app/Console/Commands/Data/PurgeCorpMoonLedgers.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Data;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Moons\PurgeMoonLedgerJob;
|
||||
|
||||
class PurgeCorpMoonLedgers extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'data:PurgeCorpLedgers';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Purge old corp ledgers data';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
PurgeMoonLedgerJob::dispatch();
|
||||
}
|
||||
}
|
||||
192
app/Console/Commands/Data/PurgeUsers.php
Normal file
192
app/Console/Commands/Data/PurgeUsers.php
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Data;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
//Libraries
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserAlt;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
|
||||
/**
|
||||
* The PurgeUsers command takes care of updating any user changes in terms of login role, as well as purging any users without at least
|
||||
* the 'User' role. This command heavily relies on ESI being available. If no ESI is available, then the function does nothing, in order to prevent
|
||||
* unwanted changes.
|
||||
*/
|
||||
class PurgeUsers extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'data:PurgeUsers';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update and purge users from the database.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup the esi variable
|
||||
$esi = $esiHelper->SetupEsiAuthentication();
|
||||
|
||||
//Get all of the users from the database
|
||||
$users = User::all();
|
||||
|
||||
//Get the allowed logins
|
||||
$legacy = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_id')->toArray();
|
||||
$renter = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_id')->toArray();
|
||||
|
||||
//Cycle through all of the users, and either update their role, or delete them.
|
||||
foreach($users as $user) {
|
||||
//Set the fail bit to false for the next user to check
|
||||
$failed = false;
|
||||
|
||||
//Note a screen entry for when doing cli stuff
|
||||
printf("Processing character with id of " . $user->character_id . "\r\n");
|
||||
|
||||
//Get the character information
|
||||
try {
|
||||
$character_info = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $user->character_id,
|
||||
]);
|
||||
|
||||
$corp_info = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $character_info->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get character information in purge user command for user ' . $user->character_id);
|
||||
$failed = true;
|
||||
}
|
||||
|
||||
//If the fail bit is still false, then continue
|
||||
if($failed === false) {
|
||||
//Get the user's role
|
||||
$role = UserRole::where(['character_id' => $user->character_id])->first();
|
||||
|
||||
//We don't want to modify Admin and SuperUsers. Admins and SuperUsers are removed via a different process.
|
||||
if($role->role != 'Admin') {
|
||||
//Check if the user is allowed to login
|
||||
if(isset($corp_info->alliance_id)) {
|
||||
//Warped Intentions is allowed to login
|
||||
if($corp_info->alliance_id == '99004116') {
|
||||
//If the alliance is Warped Intentions, then modify the role if we need to
|
||||
if($role->role != 'User') {
|
||||
//Upate the role of the user
|
||||
UserRole::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'role' => 'User',
|
||||
]);
|
||||
|
||||
//Update the user type
|
||||
User::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'user_type' => 'W4RP',
|
||||
]);
|
||||
}
|
||||
} else if(in_array($corp_info->alliance_id, $legacy)) { //Legacy Users
|
||||
if($role->role != 'User') {
|
||||
//Update the role of the user
|
||||
UserRole::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'role' => 'User',
|
||||
]);
|
||||
|
||||
//Update the user type
|
||||
User::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'user_type' => 'Legacy',
|
||||
]);
|
||||
}
|
||||
} else if(in_array($corp_info->alliance_id, $renter)) { //Renter Users
|
||||
if($role->role != 'Renter') {
|
||||
//Update the role of the user
|
||||
UserRole::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'role' => 'Renter',
|
||||
]);
|
||||
|
||||
//Update the user type
|
||||
User::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'user_type' => 'Renter',
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
//If the user is part of no valid login group, then delete the user.
|
||||
//Delete all of the permissions first
|
||||
UserPermission::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
|
||||
//Delete the user's role
|
||||
UserRole::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
|
||||
//Delete any alts the user might have registered.
|
||||
$altCount = UserAlt::where(['main_id' => $user->character_id])->count();
|
||||
if($altCount > 0) {
|
||||
UserAlt::where([
|
||||
'main_id' => $user->character_id,
|
||||
])->delete();
|
||||
}
|
||||
|
||||
//Delete the user from the user table
|
||||
User::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
|
||||
EsiScope::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
|
||||
EsiToken::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
70
app/Console/Commands/Data/Test.php
Normal file
70
app/Console/Commands/Data/Test.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Data;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
use App\Models\MoonRental\AllianceMoon;
|
||||
use App\Models\MoonRental\AllianceMoonOre;
|
||||
|
||||
class Test extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'data:test';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Test ESI stuff.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
$mHelper = new MoonCalc;
|
||||
$months = 3;
|
||||
$rentalTax = 0.25;
|
||||
$worth1;
|
||||
$worth2;
|
||||
|
||||
$moons = AllianceMoon::all();
|
||||
|
||||
foreach($moons as $moon) {
|
||||
//Declare the arrays needed
|
||||
$ores = array();
|
||||
|
||||
$ores = AllianceMoonOre::where([
|
||||
'moon_id' => $moon->moon_id,
|
||||
])->get(['ore_type_id', 'quantity'])->toArray();
|
||||
|
||||
dd($ores);
|
||||
}
|
||||
}
|
||||
}
|
||||
54
app/Console/Commands/Eve/ItemPricesUpdateCommand.php
Normal file
54
app/Console/Commands/Eve/ItemPricesUpdateCommand.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Eve;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
//Job
|
||||
use App\Jobs\Commands\Eve\ItemPricesUpdateJob;
|
||||
|
||||
class ItemPricesUpdateCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:ItemPriceUpdate';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update mineral and ore prices';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$moonHelper = new MoonCalc;
|
||||
|
||||
//Fetch new prices from fuzzwork.co.uk for the item pricing schemes
|
||||
$moonHelper->FetchNewPrices();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
152
app/Console/Commands/Files/ImportAllianceMoons.php
Normal file
152
app/Console/Commands/Files/ImportAllianceMoons.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
//Namespace
|
||||
namespace App\Console\Commands\Files;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Http\File;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use DB;
|
||||
|
||||
//Application Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRental\AllianceMoonOre;
|
||||
use App\Models\MoonRental\AllianceMoon;
|
||||
|
||||
class ImportAllianceMoons extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'files:import:moons';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Import moons from tab-delimited text.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
///universe/moons/{moon_id}/
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
$mHelper = new MoonCalc;
|
||||
//Create the collection of lines for the input file.
|
||||
$moons = new Collection;
|
||||
|
||||
//Create the file handler
|
||||
$data = Storage::get('public/alliance_moons.txt');
|
||||
//Split the string into separate arrays based on the line
|
||||
$lines = preg_split("/\n/", $data);
|
||||
//Take each line and split it again by tabs
|
||||
foreach($lines as $temp) {
|
||||
//Split the lines into separate arrays by tabs
|
||||
$separated = preg_split("/\t/", $temp);
|
||||
//Push the tabbed array into the collection
|
||||
$moons->push($separated);
|
||||
}
|
||||
|
||||
/**
|
||||
* The first pass through the collection of data is to get all of the ore data
|
||||
* and store it in the database. From the database moon ore, we will create a list
|
||||
* of moons and store those in the database. After the list of moons are created in the
|
||||
* database, the function will then update the value of all the moons.
|
||||
*/
|
||||
|
||||
//Start working our way through all of the moons
|
||||
//and saving the data to the database
|
||||
foreach($moons as $moon) {
|
||||
//If the first array is null then we are dealing with an ore
|
||||
if($moon[0] == null) {
|
||||
$moonInfo = $lookup->GetMoonInfo($moon[6]);
|
||||
$solarName = $lookup->SystemIdToName($moonInfo->system_id);
|
||||
|
||||
$moonType = $mHelper->IsRMoonGoo($moon[1]);
|
||||
|
||||
if(AllianceMoon::where(['moon_id' => $moonInfo->moon_id])->count() == 0) {
|
||||
//Save the moon into the database
|
||||
$newMoon = new AllianceMoon;
|
||||
$newMoon->moon_id = $moonInfo->moon_id;
|
||||
$newMoon->name = $moonInfo->name;
|
||||
$newMoon->system_id = $moonInfo->system_id;
|
||||
$newMoon->system_name = $solarName;
|
||||
$newMoon->moon_type = $moonType;
|
||||
$newMoon->worth_amount = 0.00;
|
||||
$newMoon->rented = 'No';
|
||||
$newMoon->rental_amount = 0.00;
|
||||
$newMoon->save();
|
||||
} else {
|
||||
$current = AllianceMoon::where([
|
||||
'moon_id' => $moonInfo->moon_id,
|
||||
])->first();
|
||||
|
||||
if($current->moon_type == 'R4' && ($moonType == 'R8' || $moonType == 'R16' || $moonType == 'R32' || $moonType == 'R64')) {
|
||||
AllianceMoon::where([
|
||||
'moon_id' => $moonInfo->moon_id,
|
||||
])->update([
|
||||
'moon_type' => $moonType,
|
||||
]);
|
||||
} else if($current->moon_type == 'R8' && ($moonType == 'R16' || $moonType == 'R32' || $moonType == 'R64')) {
|
||||
AllianceMoon::where([
|
||||
'moon_id' => $moonInfo->moon_id,
|
||||
])->update([
|
||||
'moon_type' => $moonType,
|
||||
]);
|
||||
} else if($current->moon_type == 'R16' && ($moonType == 'R32' || $moonType == 'R64')) {
|
||||
AllianceMoon::where([
|
||||
'moon_id' => $moonInfo->moon_id,
|
||||
])->update([
|
||||
'moon_type' => $moonType,
|
||||
]);
|
||||
} else if($current->moon_type == 'R32' && $moonType == 'R64') {
|
||||
AllianceMoon::where([
|
||||
'moon_id' => $moonInfo->moon_id,
|
||||
])->update([
|
||||
'moon_type' => $moonType,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//Save a new entry into the database
|
||||
$ore = new AllianceMoonOre;
|
||||
$ore->moon_id = $moon[6];
|
||||
$ore->moon_name = $moonInfo->name;
|
||||
$ore->ore_type_id = $moon[3];
|
||||
$ore->ore_name = $moon[1];
|
||||
$ore->quantity = $moon[2];
|
||||
$ore->solar_system_id = $moon[4];
|
||||
$ore->planet_id = $moon[5];
|
||||
$ore->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
81
app/Console/Commands/Files/MoonFormatter.php
Normal file
81
app/Console/Commands/Files/MoonFormatter.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Files;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Http\File;
|
||||
|
||||
class MoonFormatter extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'file:moons';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a text file to put into sql to update the moons';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$lines = array();
|
||||
|
||||
//Create the file handler
|
||||
$data = Storage::get('public/moon_data.txt');
|
||||
//Split the string into separate arrays based on the line
|
||||
$data = preg_split("/\n/", $data);
|
||||
|
||||
//For each array of data, let's separate the data into more arrays built in arrays
|
||||
for($i = 0; $i < sizeof($data); $i++) {
|
||||
//Strip the beginning [ from the line
|
||||
$temp = str_replace('[', '', $data[$i]);
|
||||
//Strip the ending ] from the line
|
||||
$temp = str_replace(']', '', $temp);
|
||||
//Remove the spacees from the line
|
||||
$temp = str_replace(' ', '', $temp);
|
||||
//Remove the quotes from the line
|
||||
$temp = str_replace("'", '', $temp);
|
||||
//Split up the line into separate arrays after each comma
|
||||
$lines[$i] = preg_split("/,/", $temp);
|
||||
}
|
||||
|
||||
/**
|
||||
* The output within the lines array
|
||||
* 0 => System
|
||||
* 1 => Planet
|
||||
* 2 => Moon
|
||||
* 3 => FirstOre
|
||||
* 4 => FirstQuan
|
||||
* 5 => SecondOre
|
||||
* 6 => SecondQuan
|
||||
* 7 => ThirdOre
|
||||
* 8 => ThirdQuan
|
||||
* 9 => FourthOre
|
||||
* 10 => FourthQuan
|
||||
*/
|
||||
|
||||
var_dump($lines);
|
||||
dd();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Files;
|
||||
|
||||
//Internal Stuff
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class UpdateItemCompositionFromSDECommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'sde:update:ItemCompositions';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Updates item compositions from sql file.';
|
||||
|
||||
/**
|
||||
* The SDE storage path
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
protected $storage_path;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the sql file for the related database information
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Start by warning the user about the command which will be run
|
||||
$this->comment('Warning! This Laravel command uses exec() to execute a ');
|
||||
$this->comment('mysql shell command to import an extracted dump. Due');
|
||||
$this->comment('to the way the command is constructed, should someone ');
|
||||
$this->comment('view the current running processes of your server, they ');
|
||||
$this->comment('will be able to see your SeAT database users password.');
|
||||
$this->line('');
|
||||
$this->line('Ensure that you understand this before continuing.');
|
||||
|
||||
//Test we have valid database parameters
|
||||
DB::connection()->getDatabaseName();
|
||||
|
||||
//Warn the user about the operation to begin
|
||||
if (! $this->confirm('Are you sure you want to update to the latest EVE SDE?', true)) {
|
||||
$this->warn('Exiting');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$fileName = $this->getSde();
|
||||
$this->importSde($fileName);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the EVE Sde from Fuzzwork and save it
|
||||
* in the storage_path/sde folder
|
||||
*/
|
||||
public function getSde() {
|
||||
|
||||
|
||||
return $fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the SDE file downloaded and run the MySQL command to import the table into the database
|
||||
*/
|
||||
public function importSde($fileName) {
|
||||
$import_command = 'mysql -u username -p password database < ' . $file;
|
||||
|
||||
//run the command
|
||||
exec($import_command, $output, $exit_code);
|
||||
|
||||
if($exit_code !== 0) {
|
||||
$this->error('Warning: Import failed with exit code ' .
|
||||
$exit_code . ' and command outut: ' . implode('\n', $output));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Finances;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Helpers\FinanceHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Finances\UpdateAllianceWalletJournalJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\AllianceWalletJournal;
|
||||
|
||||
class UpdateAllianceWalletJournal extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'finances:UpdateJournals';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = "Update the holding corporation's finance journal.";
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
UpdateAllianceWalletJournalJob::dispatch()->onQueue('finances');
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Commands\Library;
|
||||
|
||||
//Internal Libraries
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\ScheduledTask\ScheduleJob;
|
||||
|
||||
class CommandHelper {
|
||||
|
||||
private $job_name;
|
||||
private $job_state;
|
||||
private $system_time;
|
||||
|
||||
public function __construct($name) {
|
||||
$this->job_name = $name;
|
||||
$this->job_state = 'Starting';
|
||||
$this->system_time = Carbon::now();
|
||||
}
|
||||
|
||||
public function SetStartStatus() {
|
||||
//Add an entry into the jobs table
|
||||
$job = new ScheduleJob;
|
||||
$job->job_name = $this->job_name;
|
||||
$job->job_state = $this->job_state;
|
||||
$job->system_time = $this->system_time;
|
||||
$job->save();
|
||||
}
|
||||
|
||||
public function SetStopStatus() {
|
||||
//Mark the job as finished
|
||||
DB::table('schedule_jobs')->where([
|
||||
'system_time' => $this->system_time,
|
||||
'job_name' => $this->job_name,
|
||||
])->update([
|
||||
'job_state' => 'Finished',
|
||||
]);
|
||||
}
|
||||
|
||||
public function CleanJobStatusTable() {
|
||||
DB::table('schedule_jobs')->where('system_time', '<', Carbon::now()->subMonths(3))->delete();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use App\Jobs\Commands\MiningTaxes\PreFetchMiningTaxesLedgers as PreFetch;
|
||||
|
||||
class ExecuteMiningTaxesLedgersCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mt:ledgers';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Execute mining taxes ledgers jobs.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
PreFetch::dispatch();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesObservers as FetchObservers;
|
||||
|
||||
class ExecuteMiningTaxesObserversCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mt:observer';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Dispatch a mining tax observer job.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
FetchObservers::dispatch();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use App\Jobs\Commands\MiningTaxes\ProcessMiningTaxesPayments as PMTP;
|
||||
|
||||
class ExecuteProcesssMiningTaxesPaymentsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mt:payments';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Process Mining Taxes payments from the console.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
PMTP::dispatch();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use App\Jobs\Commands\MiningTaxes\MiningTaxesWeeklyInvoicing as SendInvoice;
|
||||
|
||||
class ExecuteSendMiningTaxesInvoiceCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mt:send';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Execute send mining tax invoices.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
SendInvoice::dispatch();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ExecuteSendMoonRentalInvoices extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mr:invoice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Execute command to send moon rental invoices job';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MoonRental;
|
||||
|
||||
//Application Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Internal Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRental\AllianceMoon;
|
||||
use App\Models\MoonRental\AllianceMoonOre;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\MoonRental\UpdateAllianceMoonRentalWorth;
|
||||
|
||||
class ExecuteUpdateAllianceMoonRentalWorth extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mr:worth';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update alliance moon rental worth.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
UpdateAllianceMoonRentalWorth::dispatch();
|
||||
|
||||
/*
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
$mHelper = new MoonCalc;
|
||||
$months = 3;
|
||||
$rentalTax = 0.25;
|
||||
|
||||
$moons = AllianceMoon::all();
|
||||
|
||||
foreach($moons as $moon) {
|
||||
//Declare the arrays needed
|
||||
$ores = array();
|
||||
$worth = 0.00;
|
||||
|
||||
$ores = AllianceMoonOre::where([
|
||||
'moon_id' => $moon->moon_id,
|
||||
])->get(['ore_name', 'quantity'])->toArray();
|
||||
|
||||
if(sizeof($ores) == 1) {
|
||||
$ores[1]["ore_name"] = null;
|
||||
$ores[1]["quantity"] = 0.00;
|
||||
$ores[2]["ore_name"] = null;
|
||||
$ores[2]["quantity"] = 0.00;
|
||||
$ores[3]["ore_name"] = null;
|
||||
$ores[3]["quantity"] = 0.00;
|
||||
} else if(sizeof($ores) == 2) {
|
||||
$ores[2]["ore_name"] = null;
|
||||
$ores[2]["quantity"] = 0.00;
|
||||
$ores[3]["ore_name"] = null;
|
||||
$ores[3]["quantity"] = 0.00;
|
||||
} else if(sizeof($ores) == 3) {
|
||||
$ores[3]["ore_name"] = null;
|
||||
$ores[3]["quantity"] = 0.00;
|
||||
}
|
||||
|
||||
//one of these two ways will work
|
||||
$worth = $mHelper->MoonTotalWorth($ores[0]["ore_name"], $ores[0]["quantity"],
|
||||
$ores[1]["ore_name"], $ores[1]["quantity"],
|
||||
$ores[2]["ore_name"], $ores[2]["quantity"],
|
||||
$ores[3]["ore_name"], $ores[3]["quantity"]);
|
||||
|
||||
$rentalAmount = $worth * $rentalTax * $months;
|
||||
|
||||
AllianceMoon::where([
|
||||
'moon_id' => $moon->moon_id,
|
||||
])->update([
|
||||
'worth_amount' => $worth,
|
||||
'rental_amount' => $rentalAmount,
|
||||
]);
|
||||
}
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Structures;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use App\Jobs\Commands\Assets\FetchAllianceAssets as FAA;
|
||||
|
||||
class ExecuteFetchAllianceAssetsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'structure:assets';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Execute fetch alliance command.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
FAA::dispatch();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Structures;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use App\Jobs\Commands\Structures\FetchAllianceStructures as FAS;
|
||||
|
||||
class ExecuteFetchAllianceStructuresCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'structure:structure';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Fetch alliance structures command.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
FAS::dispatch();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\SupplyChain;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Contracts\SupplyChainContract;
|
||||
|
||||
//Job
|
||||
use App\Jobs\Commands\SupplyChain\EndSupplyChainContractJob;
|
||||
|
||||
class EndSupplyChainContractCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:supplychain';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Checks and ends any supply chain contracts needs to be closed.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$today = Carbon::now();
|
||||
|
||||
//Get the supply chain contracts which are open, but need to be closed.
|
||||
$contracts = SupplyChainContract::where([
|
||||
'state' => 'open',
|
||||
])->where('end_date', '>', $today)->get();
|
||||
|
||||
//Create jobs to complete each contract
|
||||
foreach($contracts as $contract) {
|
||||
EndSupplyChainContractJob::dispatch($contract)->onQueue('default');
|
||||
}
|
||||
}
|
||||
}
|
||||
42
app/Console/Commands/TestCommand.php
Normal file
42
app/Console/Commands/TestCommand.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class TestCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'command:name';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
class UpdateMoonPriceCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:UpdateMoonPrice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update moon pricing on a scheduled basis';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('CorpJournal');
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
$moonCalc = new MoonCalc();
|
||||
$moonCalc->FetchNewPrices();
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class UpdateMoonRental extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:UpdateMoonRental';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\SendEveMailJob;
|
||||
|
||||
//Libraries
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
use App\Library\Structures\StructureTaxHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Market\MonthlyMarketTax;
|
||||
use App\Models\ScheduledTask\ScheduleJob;
|
||||
use App\Models\Corporation\CorpStructure;
|
||||
use App\Models\User\UserToCorporation;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
|
||||
class CalculateMarketTaxCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:CalculateMarketTax';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Calculate the market taxes owed to the holding corporation and store in the database.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('CorpJournal');
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Setup helper classes
|
||||
$hFinances = new FinanceHelper();
|
||||
$sHelper = new StructureTaxHelper();
|
||||
$start = Carbon::now()->startOfMonth()->subMonth();
|
||||
$end = Carbon::now()->endOfMOnth()->subMonth();
|
||||
$end->hour = 23;
|
||||
$end->minute = 59;
|
||||
$end->second = 59;
|
||||
|
||||
//Get the set of corporations from the structure table
|
||||
$corps = CorpStructure::select('corporation_id')->groupBy('corporation_id')->get();
|
||||
$this->line('Got all of the corps with markets.' . sizeof($corps));
|
||||
foreach($corps as $corp) {
|
||||
if($corp->corporation_id != 98287666) {
|
||||
$finalTaxes = $sHelper->GetTaxes($corp->corporation_id, 'Market', $start, $end);
|
||||
if($finalTaxes < 0.00) {
|
||||
$finalTaxes = 0.00;
|
||||
}
|
||||
|
||||
//Get the info about the structures from the database
|
||||
$info = CorpStructure::where(['corporation_id' => $corp->corporation_id])->first();
|
||||
|
||||
$character = UserToCorporation::where(['character_id' => $info->character_id])->first();
|
||||
|
||||
$mail = new JobSendEveMail;
|
||||
$mail->sender = 93738489;
|
||||
$mail->subject = 'Market Taxes Owed';
|
||||
$mail->body = 'Year ' . $start->year . ' ' .
|
||||
'Month: ' .
|
||||
$start->month .
|
||||
'<br>Market Taxes Owed: ' .
|
||||
number_format($finalTaxes, 2, '.', ',') .
|
||||
'<br>Please remit to Spatial Forces';
|
||||
$mail->recipient = (int)$info->character_id;
|
||||
$mail->recipient_type = 'character';
|
||||
SendEveMailJob::dispatch($mail);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessWalletJournalJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Corporation\CorpStructure;
|
||||
use App\Models\Jobs\JobProcessWalletJournal;
|
||||
|
||||
class CorpJournalCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:CorpJournal';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Grabs the corporation journals and deposit in db.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('CorpJournal');
|
||||
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Setup the Finances Container
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
//Setup an array to store corporations which have been logged so we don't keep calling the same ones. We need
|
||||
//this step in order to save time during the cronjob.
|
||||
$finishedCorps = array();
|
||||
$corpCompleted = false;
|
||||
|
||||
//Get the corps with structures logged in the database
|
||||
$corps = CorpStructure::select('corporation_id')->groupBy('corporation_id')->get();
|
||||
|
||||
//For all of the corporations, go through each structure and get wallet data
|
||||
foreach($corps as $corp) {
|
||||
//If the corporation isn't the holding corporation, then process the data.
|
||||
//We process holding corporation data elsewhere.
|
||||
if($corp->corporation_id != 98287666) {
|
||||
$structure = CorpStructure::where(['corporation_id' => $corp->corporation_id])->first();
|
||||
$pages = $finance->GetJournalPageCount(1, $structure->character_id);
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
$job = new JobProcessWalletJournal;
|
||||
$job->division = 1;
|
||||
$job->charId = $structure->character_id;
|
||||
$job->page = $i;
|
||||
ProcessWalletJournalJob::dispatch($job);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use DB;
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
use App\Models\Corporation\AllianceCorp;
|
||||
use App\Models\ScheduledTask\ScheduleJob;
|
||||
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
|
||||
class GetCorpsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:GetCorps';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get corporations in alliance and store in db.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('CorpJournal');
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Create the ESI container
|
||||
$esi = new Eseye();
|
||||
//try the esi call to get all of the corporations in the alliance
|
||||
try {
|
||||
$corporations = $esi->invoke('get', '/alliances/{alliance_id}/corporations/', [
|
||||
'alliance_id' => 99004116,
|
||||
]);
|
||||
} catch(\Seat\Eseye\Exceptions\RequestFailedException $e){
|
||||
dd($e->getEsiResponse());
|
||||
}
|
||||
//Delete all of the entries in the AllianceCorps table
|
||||
DB::table('AllianceCorps')->delete();
|
||||
foreach($corporations as $corp) {
|
||||
try {
|
||||
$corpInfo = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $corp,
|
||||
]);
|
||||
} catch(\Seat\Eseye\Exceptions\RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
}
|
||||
$entry = new AllianceCorp;
|
||||
$entry->corporation_id = $corp;
|
||||
$entry->name = $corpInfo->name;
|
||||
$entry->save();
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessWalletJournalJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Jobs\JobProcessWalletJournal;
|
||||
|
||||
class HoldingFinancesCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:HoldingJournal';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get the holding corps finances.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('HoldingFinances');
|
||||
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Setup the Finances container
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
//Get the total pages for the journal for the holding corporation
|
||||
$pages = $finance->GetJournalPageCount(1, 93738489);
|
||||
|
||||
//Dispatch a single job for each page to process
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
$job = new JobProcessWalletJournal;
|
||||
$job->division = 1;
|
||||
$job->charId = 93738489;
|
||||
$job->page = $i;
|
||||
ProcessWalletJournalJob::dispatch($job);
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,224 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\SendEveMailJob;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Moons\MoonMailer;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\Moon;
|
||||
use App\Models\MoonRent\MoonRental;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
use App\Models\Mail\SentMail;
|
||||
|
||||
class MoonMailerCommand extends Command
|
||||
{
|
||||
/**
|
||||
* Next update will include checking for if the moon has been paid in advance.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:MoonMailer';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Mail out the moon rental bills automatically';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the new command helper container
|
||||
$task = new CommandHelper('MoonMailer');
|
||||
//Add the entry into the jobs table saying the job has started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Declare the moon calc class variable to utilize the library to update the price
|
||||
$mailer = new MoonMailer;
|
||||
|
||||
//Create other variables
|
||||
$body = null;
|
||||
|
||||
//Get today's date.
|
||||
$today = Carbon::now();
|
||||
$today->second = 1;
|
||||
$today->minute = 0;
|
||||
$today->hour = 0;
|
||||
|
||||
//Get all contacts from the rentals group
|
||||
$contacts = MoonRental::select('Contact')->groupBy('Contact')->get();
|
||||
|
||||
//For each of the contacts totalize the moon rental, and create the mail to send to them,
|
||||
//then update parameters of the moon
|
||||
foreach($contacts as $contact) {
|
||||
//Get the moons the renter is renting
|
||||
$rentals = $this->GetRentalMoons($contact);
|
||||
|
||||
//Totalize the cost of the moons
|
||||
$cost = $this->TotalizeMoonCost($rentals);
|
||||
|
||||
//Get the list of moons in a list format
|
||||
$listItems = $this->GetMoonList($rentals);
|
||||
|
||||
//Build the mail body
|
||||
$body = "Moon Rent is due for the following moons:<br>";
|
||||
foreach($listItems as $item) {
|
||||
$body .= $item . "<br>";
|
||||
}
|
||||
$body .= "The price for the next month's rent is " . $cost . "<br>";
|
||||
$body .= "Please remit payment to Spatial Forces on the 1st should you continue to wish to rent the moon.<br>";
|
||||
$body .= "Sincerely,<br>";
|
||||
$body .= "Warped Intentions Leadership<br>";
|
||||
|
||||
//Dispatch the mail job
|
||||
$mail = new JobSendEveMail;
|
||||
$mail->sender = 93738489;
|
||||
$mail->subject = "Warped Intentions Moon Rental Payment Due";
|
||||
$mail->body = $body;
|
||||
$mail->recipient = (int)$contact;
|
||||
$mail->recipient_type = 'character';
|
||||
SendEveMailJob::dispatch($mail);
|
||||
|
||||
//After the mail is dispatched, saved the sent mail record
|
||||
$this->SaveSentRecord($mail->sender, $mail->subject, $mail->body, $mail->recipient, $mail->recipient_type);
|
||||
|
||||
//Update the moon as not being paid for the next month?
|
||||
foreach($rentals as $rental) {
|
||||
if($today > $rental->Paid_Until)
|
||||
$this->UpdateNotPaid($rental);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
|
||||
private function UpdateNotPaid(MoonRental $rental) {
|
||||
$today = Carbon::now();
|
||||
|
||||
if($today >= $rental->Paid_Until) {
|
||||
MoonRental::where([
|
||||
'System' => $rental->System,
|
||||
'Planet'=> $rental->Planet,
|
||||
'Moon'=> $rental->Moon,
|
||||
])->update([
|
||||
'Paid' => 'No',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
|
||||
$sentmail = new SentMail;
|
||||
$sentmail->sender = $sender;
|
||||
$sentmail->subject = $subject;
|
||||
$sentmail->body = $body;
|
||||
$sentmail->recipient = $recipient;
|
||||
$sentmail->recipient_type = $recipientType;
|
||||
$sentmail->save();
|
||||
}
|
||||
|
||||
private function GetMoonList(MoonRental $moons) {
|
||||
//Declare the variable to be used as a global part of the function
|
||||
$list = array();
|
||||
|
||||
//For each of the moons, build the System Planet and Moon.
|
||||
foreach($moons as $moon) {
|
||||
$temp = 'System: ' . $moon->System;
|
||||
$temp .= 'Planet: ' . $moon->Planet;
|
||||
$temp .= 'Moon: ' . $moon->Moon;
|
||||
//Push the new string onto the array list
|
||||
array_push($list, $temp);
|
||||
}
|
||||
|
||||
//Return the list
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function GetRentalMoons($contact) {
|
||||
$rentals = MoonRental::where([
|
||||
'Contact' => $contact,
|
||||
])->get();
|
||||
|
||||
return $rentals;
|
||||
}
|
||||
|
||||
private function TotalizeMoonCost($rentals) {
|
||||
//Delcare variables and classes
|
||||
$moonCalc = new MoonCalc;
|
||||
$totalCost = 0.00;
|
||||
|
||||
foreach($rentals as $rental) {
|
||||
$moon = Moon::where([
|
||||
'System' => $rental->System,
|
||||
'Planet' => $rental->Planet,
|
||||
'Moon' => $rental->Moon,
|
||||
])->first();
|
||||
|
||||
//Get the updated price for the moon
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
//Check the type and figure out which price to add in
|
||||
if($rental->Type == 'alliance') {
|
||||
$totalCost += $price['alliance'];
|
||||
} else{
|
||||
$totalCost += $price['outofalliance'];
|
||||
}
|
||||
}
|
||||
|
||||
//Return the total cost back to the calling function
|
||||
return $totalCost;
|
||||
}
|
||||
|
||||
private function GetRentalType($rentals) {
|
||||
$alliance = 0;
|
||||
$outofalliance = 0;
|
||||
|
||||
//Go through the data and log whether the renter is in the alliance,
|
||||
//or the renter is out of the alliance
|
||||
foreach($rentals as $rental) {
|
||||
if($rental->Type == 'alliance') {
|
||||
$alliance++;
|
||||
} else {
|
||||
$outofalliance++;
|
||||
}
|
||||
}
|
||||
|
||||
//Return the rental type
|
||||
if($alliance > $outofalliance) {
|
||||
return 'alliance';
|
||||
} else {
|
||||
return 'outofalliance';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessWalletTransactionJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Jobs\JobProcessWalletTransaction;
|
||||
|
||||
class PiTransactionsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:PiTransactions';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get the transactions from the market alt for the alliance';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('PiTransactions');
|
||||
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Setup the Finances container
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
$job = new JobProcessWalletTransaction;
|
||||
$job->division = 3;
|
||||
$job->charId = 94415555;
|
||||
ProcessWalletTransactionJob::dispatch($job);
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,26 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\MiningTaxes\PreFetchMiningTaxesLedgers;
|
||||
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesObservers;
|
||||
use App\Jobs\Commands\MiningTaxes\ProcessMiningTaxesPayments;
|
||||
use App\Jobs\Commands\MiningTaxes\Invoices\UpdateMiningTaxesLateInvoices1st;
|
||||
use App\Jobs\Commands\MiningTaxes\Invoices\UpdateMiningTaxesLateInvoices15th;
|
||||
use App\Jobs\Commands\MiningTaxes\MiningTaxesWeeklyInvoicing;
|
||||
use App\Jobs\Commands\Finances\UpdateAllianceWalletJournalJob;
|
||||
use App\Jobs\Commands\Finances\UpdateItemPrices as UpdateItemPricesJob;
|
||||
use App\Jobs\Commands\Data\PurgeUsers as PurgeUsersJob;
|
||||
use App\Jobs\Commands\Structures\FetchAllianceStructures;
|
||||
use App\Jobs\Commands\Structures\PurgeAllianceStructures;
|
||||
use App\Jobs\Commands\Assets\FetchAllianceAssets;
|
||||
use App\Jobs\Commands\Assets\PurgeAllianceAssets;
|
||||
use App\Jobs\Commands\MoonRental\UpdateAllianceMoonRentalWorth as UpdateAMRW;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
@@ -13,13 +30,18 @@ class Kernel extends ConsoleKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
Commands\CorpJournalCommand::class,
|
||||
Commands\GetCorpsCommand::class,
|
||||
Commands\UpdateMoonPriceCommand::class,
|
||||
Commands\CalculateMarketTaxCommand::class,
|
||||
Commands\HoldingFinancesCommand::class,
|
||||
Commands\MoonMailerCommand::class,
|
||||
Commands\PiTransactionsCommand::class,
|
||||
Commands\Data\PurgeUsers::class,
|
||||
Commands\Data\Test::class,
|
||||
Commands\Eve\ItemPricesUpdateCommand::class,
|
||||
Commands\Finances\UpdateAllianceWalletJournal::class,
|
||||
Commands\MiningTaxes\ExecuteMiningTaxesObserversCommand::class,
|
||||
Commands\MiningTaxes\ExecuteMiningTaxesLedgersCommand::class,
|
||||
Commands\MiningTaxes\ExecuteSendMiningTaxesInvoiceCommand::class,
|
||||
Commands\MiningTaxes\ExecuteProcesssMiningTaxesPaymentsCommand::class,
|
||||
Commands\Structures\ExecuteFetchAllianceStructuresCommand::class,
|
||||
Commands\Structures\ExecuteFetchAllianceAssetsCommand::class,
|
||||
Commands\Files\ImportAllianceMoons::class,
|
||||
Commands\MoonRental\ExecuteUpdateAllianceMoonRentalWorth::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -30,27 +52,74 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('services:CorpJournal')
|
||||
->hourly()
|
||||
//Schedule Monitor Jobs
|
||||
$schedule->command('schedule-monitor:sync')->dailyAt('04:56');
|
||||
$schedule->command('schedule-monitor:clean')->daily();
|
||||
|
||||
//Horizon Graph Schedule
|
||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||
|
||||
/**
|
||||
* Purge Data Schedule
|
||||
*/
|
||||
$schedule->job(new PurgeUsersJob)
|
||||
->weekly();
|
||||
|
||||
/**
|
||||
* Finances Update Schedule
|
||||
*/
|
||||
$schedule->job(new UpdateAllianceWalletJournalJob)
|
||||
->hourlyAt('45')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:HoldingJournal')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:UpdateMoonPrice')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:GetCorps')
|
||||
->monthlyOn(1, '09:00')
|
||||
|
||||
/**
|
||||
* Item Update Schedule
|
||||
*/
|
||||
$schedule->job(new UpdateItemPricesJob)
|
||||
->hourlyAT('30')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:CalculateMarketTax')
|
||||
->monthlyOn(1, '08:00')
|
||||
|
||||
/**
|
||||
* Mining Tax Schedule
|
||||
*/
|
||||
$schedule->job(new FetchMiningTaxesObservers)
|
||||
->dailyAt('20:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:MoonMailer')
|
||||
->monthlyOn(1, '00:01')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:PiTransactions')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
$schedule->job(new PreFetchMiningTaxesLedgers)
|
||||
->dailyAt('22:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->job(new MiningTaxesWeeklyInvoicing)
|
||||
->weeklyOn(1, '06:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->job(new ProcessMiningTaxesPayments)
|
||||
->hourlyAt('15')
|
||||
->withoutOverlapping();
|
||||
$schedule->job(new UpdateMiningTaxesLateInvoices1st)
|
||||
->monthlyOn(1, '16:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->job(new UpdateMiningTaxesLateInvoices15th)
|
||||
->monthlyOn(15, '16:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->job(new UpdateAMRW)
|
||||
->dailyAt('13:00')
|
||||
->withoutOverlapping();
|
||||
|
||||
/**
|
||||
* Alliance Structure and Assets Schedule
|
||||
*/
|
||||
$schedule->job(new FetchAllianceStructures)
|
||||
->dailyAt('21:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->job(new FetchAllianceAssets)
|
||||
->hourlyAt('15')
|
||||
->withoutOverlapping();
|
||||
$schedule->job(new PurgeAllianceStructures)
|
||||
->monthlyOn(2, '14:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->job(new PurgeAllianceAssets)
|
||||
->monthlyOn(2, '15:00')
|
||||
->withoutOverlapping();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,4 +133,14 @@ class Kernel extends ConsoleKernel
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the timezone that should be used by default for scheduled events.
|
||||
*
|
||||
* @return \DateTimeZone|string|null
|
||||
*/
|
||||
protected function scheduleTimezone()
|
||||
{
|
||||
return 'UTC';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
//use Exception;
|
||||
use Throwable;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
@@ -32,7 +33,7 @@ class Handler extends ExceptionHandler
|
||||
* @param \Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
public function report(Throwable $exception)
|
||||
{
|
||||
parent::report($exception);
|
||||
}
|
||||
@@ -44,7 +45,7 @@ class Handler extends ExceptionHandler
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
public function render($request, Throwable $exception)
|
||||
{
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\AfterActionReports;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AfterActionReportsAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:fc.lead');
|
||||
}
|
||||
|
||||
public function DeleteReport() {
|
||||
|
||||
}
|
||||
|
||||
public function DeleteComment() {
|
||||
|
||||
}
|
||||
|
||||
public function PruneReports() {
|
||||
|
||||
}
|
||||
|
||||
public function DisplayStastics() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\AfterActionReports;
|
||||
|
||||
//Internal Library
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\AfterActionReports\AfterActionReport;
|
||||
use App\Models\AfterActionReports\AfterActionReportComment;
|
||||
|
||||
class AfterActionReportsController extends Controller
|
||||
{
|
||||
public function __contstruct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:fc.team');
|
||||
}
|
||||
|
||||
public function DisplayReportForm() {
|
||||
return view('reports.user.form.report');
|
||||
}
|
||||
|
||||
public function StoreReport(Request $request) {
|
||||
$this->validate($request, [
|
||||
'location' => 'required',
|
||||
'time' => 'required',
|
||||
'comms' => 'required',
|
||||
'doctrine' => 'required',
|
||||
'objective' => 'required',
|
||||
'result' => 'required',
|
||||
'summary' => 'required',
|
||||
'improvements' => 'required',
|
||||
'well' => 'required',
|
||||
'comments' => 'required',
|
||||
]);
|
||||
|
||||
$report = new AfterActionReport;
|
||||
$report->fc_id = auth()->user()->getId();
|
||||
$report->fc_name = auth()->user()->getName();
|
||||
$report->formup_time = $request->time;
|
||||
$report->formup_location = $request->location;
|
||||
$report->comms = $request->comms;
|
||||
$report->doctrine = $request->doctrine;
|
||||
$report->objective = $request->objective;
|
||||
$report->objective_result = $request->result;
|
||||
$report->summary = $request->summary;
|
||||
$report->improvements = $request->improvements;
|
||||
$report->worked_well = $request->well;
|
||||
$report->additonal_comments = $request->comments;
|
||||
$report->save();
|
||||
|
||||
return redirect('/reports/display/all')->with('success', 'Added report to the database.');
|
||||
}
|
||||
|
||||
public function DisplayCommentForm($id) {
|
||||
return view('reports.user.form.comment')->with('id', $id);
|
||||
}
|
||||
|
||||
public function StoreComment(Request $request) {
|
||||
$this->validate($request, [
|
||||
'reportId' => 'required',
|
||||
'comments' => 'required',
|
||||
]);
|
||||
|
||||
$comment = new AfterActionReportComment;
|
||||
$comment->report_id = $request->reportId;
|
||||
$comment->character_id = auth()->user()->getId();
|
||||
$comment->character_name = auth()->user()->getName();
|
||||
$comment->comments = $required->comments;
|
||||
$comment->save();
|
||||
|
||||
return redirect('/reports/display/all')->with('success', 'Added comemnt to the report.');
|
||||
}
|
||||
|
||||
public function DisplayAllReports() {
|
||||
//Grab all the reports
|
||||
$reports = AfterActionReport::where('created_at', '>=', Carbon::now()->subDays(30));
|
||||
$comments = AfterActionReportComment::where('created_at', '>=', Carbon::now()->subDays(30));
|
||||
$reportCount = AfterActionReport::where('created_at', '>=', Carbon::now()->subDays(30))->count();
|
||||
|
||||
return view('reports.user.displayreports')->with('reports', $reports)
|
||||
->with('comments', $comments)
|
||||
->with('reportCount', $reportCount);
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,15 @@
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
//Internal Library
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use DB;
|
||||
use Socialite;
|
||||
use Auth;
|
||||
|
||||
use App\User;
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
class EsiScopeController extends Controller
|
||||
{
|
||||
@@ -20,7 +21,10 @@ class EsiScopeController extends Controller
|
||||
|
||||
public function displayScopes() {
|
||||
//Get the ESI Scopes for the user
|
||||
$scopes = DB::table('EsiScopes')->where('character_id', Auth::user()->character_id)->get();
|
||||
$scopes = EsiScope::where([
|
||||
'character_id' => Auth::user()->character_id,
|
||||
])->get();
|
||||
|
||||
return view('scopes.select')->with('scopes', $scopes);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,23 +2,29 @@
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
//Internal Library
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Socialite;
|
||||
use Auth;
|
||||
use Laravel\Socialite\Contracts\Factory as Socialite;
|
||||
use Laravel\Socialite\Two\User as SocialiteUser;
|
||||
|
||||
use App\User;
|
||||
//Library
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
use App\Models\User\UserAlt;
|
||||
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
@@ -69,21 +75,128 @@ class LoginController extends Controller
|
||||
*
|
||||
* @return Socialite
|
||||
*/
|
||||
public function redirectToProvider() {
|
||||
return Socialite::driver('eveonline')->redirect();
|
||||
public function redirectToProvider($profile = null, Socialite $social) {
|
||||
//The default scope is public data for everyone due to OAuth2 Tokens
|
||||
//We also add the send mail scope in order to be able to send mails more efficiently through jobs when other scopes are required.
|
||||
$scopes = ['publicData', 'esi-mail.send_mail.v1'];
|
||||
|
||||
//Collect any other scopes we need if we are logged in.
|
||||
//If we are logged in we are linking another character to this one.
|
||||
//Attempt to use the same scopes for this character as the original one
|
||||
if(Auth::check()) {
|
||||
$extraScopes = EsiScope::where([
|
||||
'character_id' => auth()->user()->getId(),
|
||||
])->get(['scope']);
|
||||
|
||||
//Pop each scope onto the array of scopes
|
||||
foreach($extraScopes as $extra) {
|
||||
array_push($scopes, $extra->scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* Place the scopes in the session.
|
||||
* Place the original character id in the session.
|
||||
*/
|
||||
session()->put('scopes', $scopes);
|
||||
session()->put('orgCharacter', auth()->user()->getId());
|
||||
}
|
||||
|
||||
return $social->driver('eveonline')
|
||||
->scopes($scopes)
|
||||
->redirect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get token from callback
|
||||
* Redirect to the dashboard if logging in successfully.
|
||||
*/
|
||||
public function handleProviderCallback() {
|
||||
$ssoUser = Socialite::driver('eveonline')->user();
|
||||
$user = $this->createOrGetUser($ssoUser);
|
||||
public function handleProviderCallback(Socialite $social) {
|
||||
//Get the sso user from the socialite driver
|
||||
$ssoUser = $social->driver('eveonline')->user();
|
||||
|
||||
auth()->login($user, true);
|
||||
$scpSession = session()->pull('scopes');
|
||||
|
||||
return redirect()->to('/dashboard')->with('success', 'Successfully Logged In or Updated ESI.');
|
||||
//If the user was already logged in, let's do some checks to see if we are adding
|
||||
//additional scopes to the user's account
|
||||
if(Auth::check()) {
|
||||
//If we are logged in already and the session contains the original characters, then we are creating an alt
|
||||
//for the original character
|
||||
if(session()->has('orgCharacter')) {
|
||||
$orgCharacter = session()->pull('orgCharacter');
|
||||
|
||||
if($this->createAlt($ssoUser, $orgCharacter)) {
|
||||
return redirect()->to('/profile')->with('success', 'Alt registered.');
|
||||
} else {
|
||||
return redirect()->to('/profile')->with('error', 'Unable to register alt or it was previously registered.');
|
||||
}
|
||||
} else {
|
||||
if(sizeof($ssoUser->scopes) > 1) {
|
||||
$tokenCount = EsiToken::where([
|
||||
'character_id' => $ssoUser->id,
|
||||
])->count();
|
||||
if($tokenCount > 0) {
|
||||
$this->UpdateEsiToken($ssoUser);
|
||||
} else {
|
||||
$this->SaveEsiToken($ssoUser);
|
||||
}
|
||||
$this->SetScopes($ssoUser->scopes, $ssoUser->id);
|
||||
return redirect()->to('/dashboard')->with('success', 'Successfully updated ESI scopes.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//If the user wasn't logged in, then create a new user
|
||||
$user = $this->createOrGetUser($ssoUser);
|
||||
//Login in the new user
|
||||
auth()->login($user, true);
|
||||
//Redirect back to the dashboard
|
||||
return redirect()->to('/dashboard')->with('success', 'Successfully Logged In.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an alt exists in the database, else, create and
|
||||
* return the user object.
|
||||
*
|
||||
* @param \Laravel\Socialite\Two\User $user
|
||||
*/
|
||||
private function createAlt($user, $orgCharacter) {
|
||||
//Check to see if the alt is already in the database
|
||||
$altCount = UserAlt::where(['character_id' => $user->id])->count();
|
||||
|
||||
//Check to see if the new character being added is already a main character
|
||||
$mainCount = User::where(['character_id' => $user->id])->count();
|
||||
|
||||
//If not already in the database, then add the new character
|
||||
if($altCount == 0 && $mainCount == 0) {
|
||||
//Create the new alt in the table
|
||||
$newAlt = new UserAlt;
|
||||
$newAlt->name = $user->getName();
|
||||
$newAlt->main_id = $orgCharacter;
|
||||
$newAlt->character_id = $user->id;
|
||||
$newAlt->avatar = $user->avatar;
|
||||
$newAlt->access_token = $user->token;
|
||||
$newAlt->owner_hash = $user->owner_hash;
|
||||
$newAlt->inserted_at = time();
|
||||
$newAlt->expires_in = $user->expiresIn;
|
||||
$newAlt->save();
|
||||
|
||||
//Create the entry into the EsiToken table
|
||||
if(EsiToken::where(['character_id' => $user->id])->count() == 0) {
|
||||
$this->SaveEsiToken($user);
|
||||
} else {
|
||||
$this->UpdateEsiToken($user);
|
||||
}
|
||||
|
||||
//Create the entry into the EsiScopes table
|
||||
if(sizeof($user->scopes) > 1) {
|
||||
$this->SetScopes($user->scopes, $user->id);
|
||||
}
|
||||
//Return the successfull conclusion of the function
|
||||
return 1;
|
||||
} else {
|
||||
//Return the unsuccessfull conclusion of the function
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,96 +205,153 @@ class LoginController extends Controller
|
||||
*
|
||||
* @param \Laravel\Socialite\Two\User $user
|
||||
*/
|
||||
private function createOrGetUser($eve_user) {
|
||||
//Search for user in the database
|
||||
$authUser = User::where('character_id', $eve_user->id)->first();
|
||||
private function createOrGetUser($eveUser) {
|
||||
$authUser = null;
|
||||
|
||||
//Search to see if we have a matching user in the database.
|
||||
//At this point we don't care about the information
|
||||
$userCount = User::where([
|
||||
'character_id' => $eveUser->id,
|
||||
])->count();
|
||||
|
||||
//If the user is found, do more checks to see what type of login we are doing
|
||||
if($authUser) {
|
||||
//if a refresh token is present, then we are doing a scope callback to update scopes for an access token
|
||||
if($eve_user->refreshToken !== null) {
|
||||
//Check if the owner hash has changed to call the user type if it needs to be updated
|
||||
if($this->OwnerHasChanged($authUser->owner_hash, $eve_user->owner_hash)) {
|
||||
//Get the right role for the user
|
||||
$role = $this->GetRole(null, $eve_user->id);
|
||||
//Set the role for the user
|
||||
$this->SetRole($role, $eve_user->id);
|
||||
if($userCount > 0) {
|
||||
//Search for user in the database
|
||||
$authUser = User::where([
|
||||
'character_id' => $eveUser->id,
|
||||
])->first();
|
||||
|
||||
//Update the user information never the less.
|
||||
User::where('character_id', $eve_user->id)->update([
|
||||
'avatar' => $eve_user->avatar,
|
||||
'owner_hash' => $eve_user->owner_hash,
|
||||
'role' => $role,
|
||||
]);
|
||||
//Update the user's roles and permission
|
||||
UserPermission::where(['character_id' => $eve_user->id])->delete();
|
||||
$perm = new UserPermission();
|
||||
$perm->character_id = $eve_user->id;
|
||||
$perm->permission = $role;
|
||||
$perm->save();
|
||||
} else {
|
||||
//Update the user information never the less.
|
||||
User::where('character_id', $eve_user->id)->update([
|
||||
'avatar' => $eve_user->avatar,
|
||||
]);
|
||||
}
|
||||
//Check to see if the owner has changed
|
||||
//If the owner has changed, then update their roles and permissions
|
||||
if($this->OwnerHasChanged($authUser->owner_hash, $eveUser->owner_hash)) {
|
||||
//Get the right role for the user
|
||||
$role = $this->GetRole(null, $eveUser->id);
|
||||
//Set the role for the user
|
||||
$this->SetRole($role, $eveUser->id);
|
||||
|
||||
//See if we have an access token for the user.
|
||||
//If we have a token update the token, if not create an entry into the database
|
||||
$token = EsiToken::where('character_id', $eve_user->id)->first();
|
||||
if($token) {
|
||||
//Update the ESI Token
|
||||
EsiToken::where('character_id', $eve_user->id)->update([
|
||||
'character_id' => $eve_user->getId(),
|
||||
'access_token' => $eve_user->token,
|
||||
'refresh_token' => $eve_user->refreshToken,
|
||||
'expires_in' => $eve_user->expiresIn,
|
||||
]);
|
||||
} else { //If a token entry is not found, then we create a new token entry into the database
|
||||
//Save the ESI Token in the database
|
||||
$token = new EsiToken;
|
||||
$token->character_id = $eve_user->id;
|
||||
$token->access_token = $eve_user->token;
|
||||
$token->refresh_token = $eve_user->refreshToken;
|
||||
$token->expires_in = $eve_user->expiresIn;
|
||||
$token->save();
|
||||
}
|
||||
//Update the user information never the less.
|
||||
$this->UpdateUser($eveUser, $role);
|
||||
|
||||
//After creating the token, we need to update the table for scopes
|
||||
//First we look for all the scopes, then if need be add entries or delete entries from the database
|
||||
$this->SetScopes($eve_user->user['Scopes'], $eve_user->id);
|
||||
|
||||
} else {
|
||||
//If the user is already in the database, but no refresh token was present in the callback, then just update the user
|
||||
User::where('character_id', $eve_user->id)->update([
|
||||
'avatar' => $eve_user->avatar,
|
||||
]);
|
||||
//Update the user's roles and permission
|
||||
$this->UpdatePermission($eveUser, $role);
|
||||
}
|
||||
|
||||
//Return the user to the calling auth function
|
||||
return $authUser;
|
||||
} else {
|
||||
//Get the role for the character to be stored in the database
|
||||
$role = $this->GetRole(null, $eve_user->id);
|
||||
$role = $this->GetRole(null, $eveUser->id);
|
||||
|
||||
//Create the user account
|
||||
$user = User::create([
|
||||
'name' => $eve_user->getName(),
|
||||
'email' => null,
|
||||
'avatar' => $eve_user->avatar,
|
||||
'owner_hash' => $eve_user->owner_hash,
|
||||
'character_id'=> $eve_user->getId(),
|
||||
'expires_in' => $eve_user->expiresIn,
|
||||
'access_token' => $eve_user->token,
|
||||
'user_type' => $this->GetAccountType(null, $eve_user->id),
|
||||
]);
|
||||
$user = $this->CreateNewUser($eveUser);
|
||||
|
||||
//Set the role for the user
|
||||
$this->SetRole($role, $eve_user->id);
|
||||
$this->SetRole($role, $eveUser->id);
|
||||
|
||||
//Create a user account
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ESI Token
|
||||
*/
|
||||
private function UpdateEsiToken($eveUser) {
|
||||
EsiToken::where('character_id', $eveUser->id)->update([
|
||||
'character_id' => $eveUser->getId(),
|
||||
'access_token' => $eveUser->token,
|
||||
'refresh_token' => $eveUser->refreshToken,
|
||||
'inserted_at' => time(),
|
||||
'expires_in' => $eveUser->expiresIn,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ESI Token in the database
|
||||
*/
|
||||
private function SaveEsiToken($eveUser) {
|
||||
$token = new EsiToken;
|
||||
$token->character_id = $eveUser->id;
|
||||
$token->access_token = $eveUser->token;
|
||||
$token->refresh_token = $eveUser->refreshToken;
|
||||
$token->inserted_at = time();
|
||||
$token->expires_in = $eveUser->expiresIn;
|
||||
$token->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update avatar
|
||||
*/
|
||||
private function UpdateAvatar($eveUser) {
|
||||
User::where('character_id', $eveUser->id)->update([
|
||||
'avatar' => $eveUser->avatar,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update user permission
|
||||
*/
|
||||
private function UpdatePermission($eveUser, $role) {
|
||||
UserPermission::where(['character_id' => $eveUser->id])->delete();
|
||||
$perm = new UserPermission();
|
||||
$perm->character_id = $eveUser->id;
|
||||
$perm->permission = $role;
|
||||
$perm->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the user
|
||||
*/
|
||||
private function UpdateUser($eveUser, $role) {
|
||||
User::where('character_id', $eveUser->id)->update([
|
||||
'avatar' => $eveUser->avatar,
|
||||
'owner_hash' => $eveUser->owner_hash,
|
||||
'role' => $role,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user account
|
||||
*/
|
||||
private function CreateNewUser($eveUser) {
|
||||
$user = User::create([
|
||||
'name' => $eveUser->getName(),
|
||||
'avatar' => $eveUser->avatar,
|
||||
'owner_hash' => $eveUser->owner_hash,
|
||||
'character_id' => $eveUser->getId(),
|
||||
'inserted_at' => time(),
|
||||
'expires_in' => $eveUser->expiresIn,
|
||||
'user_type' => $this->GetAccountType(null, $eveUser->id),
|
||||
]);
|
||||
|
||||
//Look for an existing token for the characters
|
||||
$tokenFound = EsiToken::where([
|
||||
'character_id' => $eveUser->id,
|
||||
])->count();
|
||||
|
||||
if($tokenFound == 0) {
|
||||
$token = new EsiToken;
|
||||
$token->character_id = $eveUser->id;
|
||||
$token->access_token = $eveUser->token;
|
||||
$token->refresh_token = $eveUser->refreshToken;
|
||||
$token->inserted_at = time();
|
||||
$token->expires_in = $eveUser->expiresIn;
|
||||
$token->save();
|
||||
} else {
|
||||
EsiToken::where([
|
||||
'character_id' => $eveUser->id,
|
||||
])->update([
|
||||
'character_id' => $eveUser->id,
|
||||
'access_token' => $eveUser->token,
|
||||
'refresh_token' => $eveUser->refreshToken,
|
||||
'inserted_at' => time(),
|
||||
'expires_in' => $eveUser->expiresIn,
|
||||
]);
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user role in the database
|
||||
*
|
||||
@@ -204,7 +374,6 @@ class LoginController extends Controller
|
||||
private function SetScopes($scopes, $charId) {
|
||||
//Delete the current scopes, so we can add new scopes into the database
|
||||
EsiScope::where('character_id', $charId)->delete();
|
||||
$scopes = explode(' ', $scopes);
|
||||
foreach($scopes as $scope) {
|
||||
$data = new EsiScope;
|
||||
$data->character_id = $charId;
|
||||
@@ -259,22 +428,26 @@ class LoginController extends Controller
|
||||
* @return text
|
||||
*/
|
||||
private function GetAccountType($refreshToken, $charId) {
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//Instantiate a new ESI isntance
|
||||
$esi = $esiHelper->SetupEsiAuthentication();
|
||||
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
// Instantiate a new ESI instance
|
||||
$esi = new Eseye();
|
||||
|
||||
//Get the character information
|
||||
$character_info = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
$character_info = $lookup->GetCharacterInfo($charId);
|
||||
|
||||
//Get the corporation information
|
||||
$corp_info = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $character_info->corporation_id,
|
||||
]);
|
||||
$corp_info = $lookup->GetCorporationInfo($character_info->corporation_id);
|
||||
|
||||
if($character_info == null || $corp_info == null) {
|
||||
return redirect('/')->with('error', 'Could not create user at this time.');
|
||||
}
|
||||
|
||||
$legacy = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_id')->toArray();
|
||||
$renter = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_id')->toArray();
|
||||
|
||||
174
app/Http/Controllers/Blacklist/BlacklistController.php
Normal file
174
app/Http/Controllers/Blacklist/BlacklistController.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Blacklist;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Log;
|
||||
use DB;
|
||||
|
||||
//Library
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Blacklist\BlacklistEntity;
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\User\UserPermission;
|
||||
|
||||
class BlacklistController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function DisplayAddToBlacklist() {
|
||||
return view('blacklist.add');
|
||||
}
|
||||
|
||||
public function DisplayRemoveFromBlacklist() {
|
||||
return view('blacklist.remove');
|
||||
}
|
||||
|
||||
public function DisplaySearch() {
|
||||
return view('blacklist.search');
|
||||
}
|
||||
|
||||
public function AddToBlacklist(Request $request) {
|
||||
//Middleware needed for the function
|
||||
$this->middleware('permission:blacklist.admin');
|
||||
|
||||
//Validate the user input
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'type' => 'required',
|
||||
'reason' => 'required',
|
||||
]);
|
||||
|
||||
//Create the library variable
|
||||
$lookup = new LookupHelper;
|
||||
//Declare other necessary variables
|
||||
$charId = null;
|
||||
$corporationId = null;
|
||||
$allianceId = null;
|
||||
$entityId = null;
|
||||
$entityType = null;
|
||||
|
||||
//See if the entity is already on the list
|
||||
$count = BlacklistEntity::where([
|
||||
'entity_name' => $request->name,
|
||||
])->count();
|
||||
|
||||
//If the count is 0, then add the character to the blacklist
|
||||
if($count === 0) {
|
||||
if($request->type == 'Character') {
|
||||
//Get the character id from the universe end point
|
||||
$entityId = $lookup->CharacterNameToId($request->name);
|
||||
} else if($request->type == 'Corporation') {
|
||||
//Get the corporation id from the universe end point
|
||||
$entityId = $lookup->CorporationNameToId($request->name);
|
||||
} else if($request->type == 'Alliance') {
|
||||
//Get the alliance id from the universe end point
|
||||
$entityId = $lookup->AllianceNameToId($request->name);
|
||||
} else {
|
||||
//Redirect back to the view
|
||||
return redirect('/blacklist/display/add')->with('error', 'Entity Type not allowed.');
|
||||
}
|
||||
|
||||
//If all id's are null, then we couldn't find the entity
|
||||
if($entityId == null) {
|
||||
//Redirect back to the view
|
||||
return redirect('/blacklist/display/add')->with('error', 'Entity Id was not found.');
|
||||
}
|
||||
|
||||
//Store the entity in the table
|
||||
$blacklist = new BlacklistEntity;
|
||||
$blacklist->entity_id = $entityId;
|
||||
$blacklist->entity_name = $request->name;
|
||||
$blacklist->entity_type = $request->type;
|
||||
$blacklist->reason = $request->reason;
|
||||
$blacklist->alts = $request->alts;
|
||||
$blacklist->lister_id = auth()->user()->getId();
|
||||
$blacklist->lister_name = auth()->user()->getName();
|
||||
$blacklist->validity = 'Valid';
|
||||
$blacklist->save();
|
||||
|
||||
//Return to the view
|
||||
return redirect('/blacklist/display/add')->with('success', $request->name . ' added to the blacklist.');
|
||||
|
||||
} else {
|
||||
//Return the view
|
||||
return view('blacklist.add')->with('error', 'Entity of type '. $request->entity_type . ' is already on the black list.');
|
||||
}
|
||||
|
||||
//If we get back to this point redirect to the blacklist with a general error.
|
||||
return redirect('/blacklist/display/add')->with('error', 'General Error. Contact Support.');
|
||||
}
|
||||
|
||||
public function RemoveFromBlacklist(Request $request) {
|
||||
//Middleware needed
|
||||
$this->middleware('permission:blacklist.admin');
|
||||
|
||||
//Validate the input request
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
]);
|
||||
|
||||
//Set the character on the blacklist to removed
|
||||
BlacklistEntity::where([
|
||||
'entity_name' => $request->name,
|
||||
])->update([
|
||||
'validity' => 'Invalid',
|
||||
'removed_by_id' => auth()->user()->getId(),
|
||||
'removed_by_name' => auth()->user()->getName(),
|
||||
'removed_notes' => $request->notes,
|
||||
]);
|
||||
|
||||
//Return the view
|
||||
return redirect('/blacklist/display')->with('success', 'Character removed from the blacklist.');
|
||||
}
|
||||
|
||||
public function DisplayBlacklist() {
|
||||
|
||||
//Get the entire blacklist
|
||||
$blacklist = BlacklistEntity::where([
|
||||
'validity' => 'Valid',
|
||||
])->orderBy('entity_name', 'asc')->paginate(50);
|
||||
|
||||
//Return the view with the data
|
||||
return view('blacklist.list')->with('blacklist', $blacklist);
|
||||
}
|
||||
|
||||
public function SearchInBlacklist(Request $request) {
|
||||
|
||||
//Validate the input from the form
|
||||
$this->validate($request, [
|
||||
'parameter' => 'required',
|
||||
]);
|
||||
|
||||
$blacklist = DB::table('alliance_blacklist')->where('entity_name', 'like', $request->parameter . "%")
|
||||
->orWhere('entity_type', 'like', "%" . $request->parameter . "%")
|
||||
->orWhere('alts', 'like', "%" . $request->parameter . "%")
|
||||
->orWhere('reason', 'like', "%" . $request->parameter . "%")
|
||||
->orderBy('entity_name', 'asc')
|
||||
->paginate(50);
|
||||
|
||||
$blacklistCount = sizeof($blacklist);
|
||||
|
||||
//If the count for the blacklist is greater than 0, then get the details, and send it to the view
|
||||
if($blacklistCount > 0) {
|
||||
|
||||
//Send the data to the view
|
||||
return view('blacklist.list')->with('blacklist', $blacklist)
|
||||
->with('success', 'Results were found on the blacklist');
|
||||
} else {
|
||||
//If they aren't found, then null out the blacklist variable, and send to the view
|
||||
$blacklist = null;
|
||||
|
||||
return view('blacklist.list')->with('blacklist', $blacklist)
|
||||
->with('error', 'Results were not found on the blacklist.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Contracts;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Esi\Mail;
|
||||
|
||||
//Models
|
||||
use App\User;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\Contracts\Contract;
|
||||
use App\Models\Contracts\Bid;
|
||||
use App\Models\Contracts\AcceptedBid;
|
||||
|
||||
class ContractAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:contract.admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Contract display functions
|
||||
*/
|
||||
public function displayContractDashboard() {
|
||||
$contracts = Contract::where(['finished' => false])->get();
|
||||
|
||||
return view('contracts.admin.contractpanel')->with('contracts', $contracts);
|
||||
}
|
||||
|
||||
public function displayPastContracts() {
|
||||
$contracts = Contract::where(['finished' => true])->get();
|
||||
|
||||
return view('contracs.admin.past')->with('contracts', $contracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* New contract functionality
|
||||
*/
|
||||
public function displayNewContract() {
|
||||
return view('contracts.admin.newcontract');
|
||||
}
|
||||
|
||||
public function storeNewContract(Request $request) {
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'date' => 'required',
|
||||
'body' => 'required',
|
||||
'type' => 'required',
|
||||
]);
|
||||
|
||||
$date = new Carbon($request->date);
|
||||
$body = nl2br($request->body);
|
||||
|
||||
//Store the contract in the database
|
||||
$contract = new Contract;
|
||||
$contract->title = $request->name;
|
||||
$contract->end_date = $request->date;
|
||||
$contract->body = $body;
|
||||
$contract->type = $request->type;
|
||||
$contract->save();
|
||||
|
||||
return redirect('/contracts/admin/display')->with('success', 'Contract written.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to store a finished contract in the database
|
||||
*/
|
||||
public function storeAcceptContract(Request $request) {
|
||||
$this->validate($request, [
|
||||
'contract_id' => 'required',
|
||||
'bid_id' => 'required',
|
||||
'character_id' => 'required',
|
||||
'bid_amount' => 'required',
|
||||
]);
|
||||
|
||||
//Update the contract
|
||||
Contract::where([
|
||||
'contract_id' => $request->contract_id,
|
||||
])->update([
|
||||
'finished' => true,
|
||||
'final_cost' => $request->bid_amount,
|
||||
]);
|
||||
|
||||
//Save the accepted bid in the database
|
||||
$accepted = new AcceptedBid;
|
||||
$accepted->contract_id = $request->contract_id;
|
||||
$accepted->bid_id = $request->bid_id;
|
||||
$accepted->bid_amount = $request->bid_amount;
|
||||
$accepted->save();
|
||||
|
||||
return redirect('/contracts/admin/display')->with('success', 'Contract accepted and closed.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a contract from every user
|
||||
*/
|
||||
public function deleteContract($id) {
|
||||
|
||||
Contract::where(['contract_id' => $id])->delete();
|
||||
|
||||
Bid::where(['contract_id' => $id])->delete();
|
||||
|
||||
return redirect('/contracts/admin/display')->with('success', 'Contract has been deleted.');
|
||||
}
|
||||
|
||||
/**
|
||||
* End Contract Functionality
|
||||
*/
|
||||
public function displayEndContract($id) {
|
||||
//Gather the information for the contract, and all bids on the contract
|
||||
$contract = Contract::where(['contract_id' => $id])->first()->toArray();
|
||||
$bids = Bid::where(['contract_id' => $id])->get()->toArray();
|
||||
|
||||
return view('contracts.admin.displayend')->with('contract', $contract)
|
||||
->with('bids', $bids);
|
||||
}
|
||||
|
||||
public function storeEndContract(Request $request) {
|
||||
$this->validate($request, [
|
||||
'contract_id' => 'required',
|
||||
'accept' => 'required',
|
||||
]);
|
||||
|
||||
//Declare class variables
|
||||
$mail = new Mail;
|
||||
$tries = 1;
|
||||
|
||||
$contract = Contract::where(['contract_id' => $request->contract_id])->first()->toArray();
|
||||
$bid = Bid::where(['id' => $request->accept, 'contract_id' => $request->contract_id])->first()->toArray();
|
||||
|
||||
//Send mail out to winner of the contract
|
||||
$subject = 'Contract Won';
|
||||
$body = 'You have been accepted to perform the following contract:<br>';
|
||||
$body .= $contract['contract_id'] . ' : ' . $contract['title'] . '<br>';
|
||||
$body .= 'Notes:<br>';
|
||||
$body .= $contract['body'] . '<br>';
|
||||
$body .= 'Please remit contract when the items are ready to Spatial Forces. Description should be the contract identification number. Request ISK should be the bid amount.';
|
||||
$body .= 'Sincerely,<br>Spatial Forces Contracting Department';
|
||||
while($mail->SendMail($bid['character_id'], 'character', $subject, $body)) {
|
||||
$tries++;
|
||||
if($tries == 5) {
|
||||
TidyContract($contract, $bid);
|
||||
|
||||
return redirect('/contracts/admin/display')->with('error', 'Could not deliver mail. Please manually send the mail to the winner.');
|
||||
}
|
||||
}
|
||||
|
||||
TidyContract($contract, $bid);
|
||||
|
||||
return redirect('/contracts/admin/display')->with('success', 'Contract finalized. Mail took ' . $tries . ' attempt to send to the winner.');
|
||||
}
|
||||
|
||||
private function TidyContract($contract, $bid) {
|
||||
Contract::where(['contract_id' => $contract['contract_id']])->update([
|
||||
'finished' => true,
|
||||
]);
|
||||
|
||||
//Create the accepted contract entry into the table
|
||||
$accepted = new AcceptedBid;
|
||||
$accepted->contract_id = $contract['contract_id'];
|
||||
$accepted->bid_id = $bid['id'];
|
||||
$accepted->bid_amount = $bid['bid_amount'];
|
||||
$accepted->notes = $bid['notes'];
|
||||
$accepted->save();
|
||||
}
|
||||
}
|
||||
@@ -1,316 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Contracts;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
//use App\Library\Contracts\ContractHelper;
|
||||
|
||||
//Models
|
||||
use App\User;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\Contracts\Contract;
|
||||
use App\Models\Contracts\Bid;
|
||||
|
||||
class ContractController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:contract.canbid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display the bids placed on contracts
|
||||
*/
|
||||
public function displayBids($id) {
|
||||
$bids = Bids::where(['contract_id' => $id, 'character_name' => auth()->user()->getName()])->get();
|
||||
|
||||
return view('contracts.bids')->with('bids', $bids);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Controller function to display all current open contracts
|
||||
*
|
||||
*/
|
||||
public function displayContracts() {
|
||||
//Calculate today's date to know which contracts to display
|
||||
$today = Carbon::now();
|
||||
|
||||
//Declare our array variables
|
||||
$bids = array();
|
||||
$contracts = array();
|
||||
$i = 0;
|
||||
|
||||
//Fetch all of the current contracts from the database
|
||||
$contractsTemp = Contract::where('end_date', '>=', $today)
|
||||
->where(['finished' => false])->get()->toArray();
|
||||
|
||||
//Count the number of bids, and add them to the arrays
|
||||
for($i = 0; $i < sizeof($contractsTemp); $i++) {
|
||||
$tempCount = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->count('contract_id');
|
||||
$bids = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->get()->toArray();
|
||||
|
||||
//Assemble the finaly array
|
||||
$contracts[$i] = $contractsTemp[$i];
|
||||
$contracts[$i]['bid_count'] = $tempCount;
|
||||
$contracts[$i]['bids'] = $bids;
|
||||
}
|
||||
|
||||
//Call for the view to be displayed
|
||||
return view('contracts.allcontracts')->with('contracts', $contracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display all current public contracts
|
||||
*/
|
||||
public function displayPublicContracts() {
|
||||
//Calculate today's date to know which contracts to display
|
||||
$today = Carbon::now();
|
||||
|
||||
//Declare our array variables
|
||||
$bids = array();
|
||||
$contracts = array();
|
||||
$i = 0;
|
||||
$lowestBid = null;
|
||||
$lowestCorp = null;
|
||||
|
||||
//Fetch all of the current contracts from the database
|
||||
$contractsTemp = Contract::where('end_date', '>=', $today)
|
||||
->where(['type' => 'Public', 'finished' => false])->get()->toArray();
|
||||
|
||||
//Count the number of bids, and add them to the arrays
|
||||
for($i = 0; $i < sizeof($contractsTemp); $i++) {
|
||||
$tempCount = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->count('contract_id');
|
||||
$bids = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->get()->toArray();
|
||||
|
||||
foreach($bids as $bid) {
|
||||
if($lowestBid == null) {
|
||||
$lowestBid = $bid['bid_amount'];
|
||||
$lowestCorp = $bid['corporation_name'];
|
||||
} else {
|
||||
if($bid['bid_amount'] < $lowestBid) {
|
||||
$lowestBid = $bid['bid_amount'];
|
||||
$lowestCorp = $bid['corporation_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($lowestBid == null) {
|
||||
$lowestBid = 'No Bids Placed.';
|
||||
$lowestCorp = 'No Corporation has placed a bid.';
|
||||
}
|
||||
|
||||
//Assemble the finaly array
|
||||
$contracts[$i] = $contractsTemp[$i];
|
||||
$contracts[$i]['bid_count'] = $tempCount;
|
||||
$contracts[$i]['bids'] = $bids;
|
||||
$contracts[$i]['lowestbid'] = $lowestBid;
|
||||
$contracts[$i]['lowestcorp'] = $lowestCorp;
|
||||
|
||||
}
|
||||
|
||||
//Call for the view to be displayed
|
||||
return view('contracts.publiccontracts')->with('contracts', $contracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display current private contracts
|
||||
*/
|
||||
public function displayPrivateContracts() {
|
||||
//Declare our array variables
|
||||
$bids = array();
|
||||
$contracts = array();
|
||||
$lowestBid = null;
|
||||
|
||||
//Calucate today's date to know which contracts to display
|
||||
$today = Carbon::now();
|
||||
|
||||
//Fetch all of the current contracts from the database
|
||||
$contractsTemp = Contract::where('end_date', '>=', $today)
|
||||
->where(['type' => 'Private', 'finished' => false])->get();
|
||||
|
||||
//Count the number of bids, and add them to the arrays
|
||||
for($i = 0; $i < sizeof($contractsTemp); $i++) {
|
||||
$tempCount = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->count('contract_id');
|
||||
$bids = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->get()->toArray();
|
||||
|
||||
foreach($bids as $bid) {
|
||||
if($lowestBid == null) {
|
||||
$lowestBid = $bid['bid_amount'];
|
||||
} else {
|
||||
if($bid['bid_amount'] < $lowestBid) {
|
||||
$lowestBid = $bid['bid_amount'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($lowestBid == null) {
|
||||
$lowestBid = 'No Bids Placed.';
|
||||
}
|
||||
|
||||
//Assemble the finaly array
|
||||
$contracts[$i] = $contractsTemp[$i];
|
||||
$contracts[$i]['bid_count'] = $tempCount;
|
||||
$contracts[$i]['bids'] = $bids;
|
||||
$contracts[$i]['lowestbid'] = $lowestBid;
|
||||
}
|
||||
|
||||
return view ('contracts.privatecontracts')->with('contracts', $contracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display expired contracts
|
||||
*
|
||||
*/
|
||||
public function displayExpiredContracts() {
|
||||
//Calculate today's date to know which contracts to display
|
||||
$today = Carbon::now();
|
||||
|
||||
//Retrieve the contracts from the database
|
||||
$contracts = Contract::where('end_date', '<', $today)->get();
|
||||
|
||||
return view('contracts.expiredcontracts')->with('contracts', $contracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display a page to allow a bid
|
||||
*
|
||||
*/
|
||||
public function displayNewBid($id) {
|
||||
|
||||
$contractId = $id;
|
||||
|
||||
return view('contracts.enterbid')->with('contractId', $contractId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to store a new bid
|
||||
*/
|
||||
public function storeBid(Request $request) {
|
||||
//Valid the request from the enter bid page
|
||||
$this->validate($request, [
|
||||
'contract_id' => 'required',
|
||||
'bid' => 'required',
|
||||
]);
|
||||
|
||||
//Delcare some class variables we will need
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
$amount = 0.00;
|
||||
|
||||
//Convert the amount to a whole number from abbreviations
|
||||
if($request->suffix == 'B') {
|
||||
$amount = $request->bid * 1000000000.00;
|
||||
} else if($request->suffix == 'M') {
|
||||
$amount = $request->bid * 1000000.00;
|
||||
} else {
|
||||
$amount = $request->bid * 1.00;
|
||||
}
|
||||
|
||||
if(isset($request->notes)) {
|
||||
$notes = nl2br($request->notes);
|
||||
} else {
|
||||
$notes = null;
|
||||
}
|
||||
|
||||
//Get the character id and character name from the auth of the user calling
|
||||
//this function
|
||||
$characterId = auth()->user()->getId();
|
||||
$characterName = auth()->user()->getName();
|
||||
//Use the lookup helper in order to find the user's corporation id and name
|
||||
$corporationId = $lookup->LookupCharacter($characterId);
|
||||
$corporationName = $lookup->LookupCorporationName($corporationId);
|
||||
|
||||
//Before saving a bid let's check to see if the user already placed a bid on the contract
|
||||
$found = Bid::where([
|
||||
'contract_id' => $request->contract_id,
|
||||
'character_id' => $characterId,
|
||||
])->first();
|
||||
|
||||
if(isset($found->contract_id)) {
|
||||
return redirect('/contracts/display/all')->with('error', 'You have already placed a bid for this contract. Please modify the existing bid.');
|
||||
} else {
|
||||
//Create the model object to save data to
|
||||
$bid = new Bid;
|
||||
$bid->contract_id = $request->contract_id;
|
||||
$bid->bid_amount = $amount;
|
||||
$bid->character_id = $characterId;
|
||||
$bid->character_name = $characterName;
|
||||
$bid->corporation_id = $corporationId;
|
||||
$bid->corporation_name = $corporationName;
|
||||
$bid->notes = $notes;
|
||||
$bid->save();
|
||||
|
||||
//Redirect to the correct page
|
||||
return redirect('/contracts/display/all')->with('success', 'Bid accepted.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to delete a bid
|
||||
*/
|
||||
public function deleteBid($id) {
|
||||
//Delete the bid entry from the database
|
||||
Bid::where([
|
||||
'id' => $id,
|
||||
])->delete();
|
||||
|
||||
return redirect('/contracts/display/public')->with('success', 'Bid deleted.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display modify bid page
|
||||
*/
|
||||
public function displayModifyBid($id) {
|
||||
//With the bid id number, look up the bid in the database to get the contract information
|
||||
$bid = Bid::where(['id' => $id])->first();
|
||||
|
||||
//Retrieve the contract from the database
|
||||
$contract = Contract::where(['contract_id' => $bid->contract_id])->first()->toArray();
|
||||
|
||||
return view('contracts.modifybid')->with('contract', $contract)
|
||||
->with('bid', $bid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to modify a bid
|
||||
*/
|
||||
public function modifyBid(Request $request) {
|
||||
$this->validate($request, [
|
||||
'bid' => 'required',
|
||||
]);
|
||||
|
||||
$amount = $request->bid;
|
||||
$type = $request->type;
|
||||
$contractId = $request->contract_id;
|
||||
|
||||
if($request->suffix == 'B') {
|
||||
$amount = $amount * 1000000000.00;
|
||||
} else if($request->suffix == 'M') {
|
||||
$amount = $amount * 1000000.00;
|
||||
} else {
|
||||
$amount = $amount * 1.00;
|
||||
}
|
||||
|
||||
Bid::where([
|
||||
'character_id' => auth()->user()->getId(),
|
||||
'contract_id' => $contractId,
|
||||
])->update([
|
||||
'bid_amount' => $amount,
|
||||
]);
|
||||
|
||||
if($type == 'public') {
|
||||
return redirect('/contracts/display/public')->with('success', 'Bid modified.');
|
||||
} else {
|
||||
return redirect('/contracts/display/private')->with('success', 'Bid modified');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
501
app/Http/Controllers/Contracts/SupplyChainController.php
Normal file
501
app/Http/Controllers/Contracts/SupplyChainController.php
Normal file
@@ -0,0 +1,501 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Contracts;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\Contracts\SupplyChainBid;
|
||||
use App\Models\Contracts\SupplyChainContract;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\SendEveMail;
|
||||
|
||||
class SupplyChainController extends Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the supply chain dashboard
|
||||
* Should contain a section for open contracts, closed contracts, and expired contracts.
|
||||
*/
|
||||
public function displaySupplyChainDashboard() {
|
||||
$openContracts = SupplyChainContract::where([
|
||||
'state' => 'open',
|
||||
])->get();
|
||||
|
||||
$closedContracts = SupplyChainContract::where([
|
||||
'state' => 'closed',
|
||||
])->get();
|
||||
|
||||
$completedContracts = SupplyChainContract::where([
|
||||
'state' => 'completed',
|
||||
])->get();
|
||||
|
||||
return view('supplychain.dashboard.main')->with('openContracts', $openContracts)
|
||||
->with('closedContracts', $closedContracts)
|
||||
->with('completedContracts', $completedContracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display my supply chain contracts dashboard
|
||||
* Should contain a section for open contracts, closed contracts, and expired contracts
|
||||
*/
|
||||
public function displayMySupplyChainDashboard() {
|
||||
$openContracts = SupplyChainContract::where([
|
||||
'issuer_id' => auth()->user()->getId(),
|
||||
'state' => 'open',
|
||||
])->get();
|
||||
|
||||
$closedContracts = SupplyChainContract::where([
|
||||
'issuer_id' => auth()->user()->getId(),
|
||||
'state' => 'closed',
|
||||
])->get();
|
||||
|
||||
$completedContracts = SupplyChainContract::where([
|
||||
'issuer_id' => auth()->user()->getId(),
|
||||
'state' => 'completed',
|
||||
])->get();
|
||||
|
||||
return view('supplychain.dashboard.main')->with('openContracts', $openContracts)
|
||||
->with('closedContracts', $closedContracts)
|
||||
->with('completedContracts', $completedContracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display new contract page
|
||||
*/
|
||||
public function displayNewSupplyChainContract() {
|
||||
return view('supplychain.forms.newcontract');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store new contract page
|
||||
*/
|
||||
public function storeNewSupplyChainContract(Request $request) {
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'date' => 'required',
|
||||
'delivery' => 'required',
|
||||
'body' => 'required',
|
||||
]);
|
||||
|
||||
$contract = new SupplyChainContract;
|
||||
$contract->issuer_id = auth()->user()->getId();
|
||||
$contract->issuer_name = auth()->user()->getName();
|
||||
$contract->title = $request->name;
|
||||
$contract->end_date = $request->date;
|
||||
$contract->delivery_by = $request->delivery;
|
||||
$contract->body = $request->body;
|
||||
$contract->state = 'open';
|
||||
$contract->bids = 0;
|
||||
$contract->save();
|
||||
|
||||
$this->NewSupplyChainContractMail($contract);
|
||||
|
||||
return redirect('/supplychain/dashboard')->with('success', 'New Contract created.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the delete contract page
|
||||
*/
|
||||
public function displayDeleteSupplyChainContract() {
|
||||
$contracts = SupplyChainContract::where([
|
||||
'issuer_id' => auth()->user()->getId(),
|
||||
'state' => 'open',
|
||||
])->get();
|
||||
|
||||
return view('supplychain.forms.delete')->with('contracts', $contracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a supply chain contract
|
||||
*/
|
||||
public function deleteSupplyChainContract(Request $request) {
|
||||
$this->validate($request, [
|
||||
'contractId' => 'required',
|
||||
]);
|
||||
|
||||
$contractId = $request->contractId;
|
||||
|
||||
/**
|
||||
* Remove the supply chain contract if it's yours.
|
||||
*/
|
||||
$count = SupplyChainContract::where([
|
||||
'issuer_id' => auth()->user()->getId(),
|
||||
'contract_id' => $contractId,
|
||||
])->count();
|
||||
|
||||
if($count > 0) {
|
||||
//Remove the supply chain contract
|
||||
SupplyChainContract::where([
|
||||
'issuer_id' => auth()->user()->getId(),
|
||||
'contract_id' => $contractId,
|
||||
])->delete();
|
||||
|
||||
//Remove all bids associated with the supply chain contract
|
||||
SupplyChainBid::where([
|
||||
'contract_id' => $contractId,
|
||||
])->delete();
|
||||
|
||||
return redirect('/supplychain/dashboard')->with('success', 'Supply Chain Contract deleted successfully.');
|
||||
} else {
|
||||
return redirect('/supplychain/dashboard')->with('error', 'Unable to delete supply chain contract.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the end supply chain contrage page
|
||||
*/
|
||||
public function displayEndSupplyChainContract() {
|
||||
return view('supplychain.forms.end');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the end supply chain contract page
|
||||
*/
|
||||
public function storeEndSupplyChainContract(Request $request) {
|
||||
$this->validate($request, [
|
||||
'accept' => 'required',
|
||||
'contractId' => 'required',
|
||||
]);
|
||||
|
||||
//Check to make sure the user owns the contract
|
||||
$count = SupplyChainContract::where([
|
||||
'issuer_name' => auth()->user()->getName(),
|
||||
'contract_id' => $request->contractId,
|
||||
])->count();
|
||||
|
||||
//If the count is greater than 0, the user owns the contract.
|
||||
//Proceed with ending the contract
|
||||
if($count > 0) {
|
||||
SupplyChainContract::where([
|
||||
|
||||
])->update([
|
||||
|
||||
]);
|
||||
|
||||
SupplyChainBid::where([
|
||||
|
||||
])->update([
|
||||
|
||||
]);
|
||||
|
||||
return redirect('/supplychain/dashboard')->with('success', 'Contract ended, and mails sent to the winning bidder.');
|
||||
} else {
|
||||
//If the count is zero, then redirect with error messsage
|
||||
return redirect('/supplychain/dashboard')->with('error', 'Contract was not yours to end.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display supply chain contract bids page
|
||||
*/
|
||||
public function displaySupplyChainBids() {
|
||||
//Display bids for the user on a page
|
||||
$bids = array();
|
||||
|
||||
$bidsCount = SupplyChainBid::where([
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
'bid_type' => 'pending',
|
||||
])->count();
|
||||
|
||||
$myBids = SupplyChainBid::where([
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
'bid_type' => 'pending',
|
||||
])->get();
|
||||
|
||||
foreach($myBids as $bid) {
|
||||
//Declare the temporary array
|
||||
$temp = array();
|
||||
|
||||
//Get the contract information for the bid
|
||||
$contract = SupplyChainContract::where([
|
||||
'contract_id' => $bid->contract_id,
|
||||
])->first();
|
||||
|
||||
$temp['bid_id'] = $bid->bid_id;
|
||||
$temp['contract_id'] = $bid->contract_id;
|
||||
$temp['issuer_name'] = $contract->issuer_name;
|
||||
$temp['title'] = $contract->title;
|
||||
$temp['end_date'] = $contract->end_date;
|
||||
$temp['body'] = $contract->body;
|
||||
$temp['bid_amount'] = $bid->bid_amount;
|
||||
|
||||
array_push($bids, $temp);
|
||||
}
|
||||
|
||||
return view('supplychain.dashboard.bids')->with('bids', $bids)
|
||||
->with('bidsCount', $bidsCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display expired supply chain contracts page
|
||||
*/
|
||||
public function displayExpiredSupplyChainContracts() {
|
||||
|
||||
return view('supplychain.dashboard.expired');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the new bid on a supply chain contract page
|
||||
*/
|
||||
public function displaySupplyChainContractBid($contract) {
|
||||
$contractId = $contract;
|
||||
|
||||
return view('supplychain.forms.enterbid')->with('contractId', $contractId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter a new bid on a supply chain contract
|
||||
*/
|
||||
public function storeSupplyChainContractBid(Request $request) {
|
||||
$this->validate($request, [
|
||||
'bid' => 'required',
|
||||
'contract_id' => 'required',
|
||||
]);
|
||||
|
||||
//Declare some needed variables
|
||||
$bidAmount = 0.00;
|
||||
|
||||
//See if a bid has been placed by the user for this contract
|
||||
$count = SupplyChainBid::where([
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
'entity_name' => auth()->user()->getName(),
|
||||
'contract_id' => $request->contract_id,
|
||||
])->count();
|
||||
|
||||
//If the person already has a bid in, then deny them the option to place another bid on the same contract.
|
||||
//Otherwise, enter the bid into the database
|
||||
if($count > 0) {
|
||||
return redirect('/supplychain/dashboard')->with('error', 'Unable to insert bid as one is already present for the supply chain contract.');
|
||||
} else {
|
||||
//Sanitize the bid amount
|
||||
if(preg_match('(m|M|b|B)', $request->bid) === 1) {
|
||||
if(preg_match('(m|M)', $request->bid) === 1) {
|
||||
$cStringSize = strlen($request->bid);
|
||||
$tempCol = str_split($request->bid, $cStringSize - 1);
|
||||
$bidAmount = $tempCol[0];
|
||||
$bidAmount = $bidAmount * 1000000.00;
|
||||
} else if(preg_match('(b|B)', $request->bid) === 1) {
|
||||
$cStringSize = strlen($request->bid);
|
||||
$tempCol = str_split($request->bid, $cStringSize - 1);
|
||||
$bidAmount = $tempCol[0];
|
||||
$bidAmount = $bidAmount * 1000000000.00;
|
||||
}
|
||||
} else {
|
||||
$bidAmount = $request->bid;
|
||||
}
|
||||
|
||||
//Create the database entry
|
||||
$bid = new SupplyChainBid;
|
||||
$bid->contract_id = $request->contract_id;
|
||||
$bid->bid_amount = $bidAmount;
|
||||
$bid->entity_id = auth()->user()->getId();
|
||||
$bid->entity_name = auth()->user()->getName();
|
||||
$bid->entity_type = 'character';
|
||||
if(isset($request->notes)) {
|
||||
$bid->bid_note = $request->notes;
|
||||
}
|
||||
$bid->bid_type = 'pending';
|
||||
$bid->save();
|
||||
|
||||
//Update the database entry for the supply chain contract bid number
|
||||
$num = SupplyChainContract::where([
|
||||
'contract_id' => $request->contract_id,
|
||||
])->select('bids')->first();
|
||||
|
||||
//Increment the number of bids
|
||||
$numBids = $num->bids + 1;
|
||||
|
||||
//Update the database
|
||||
SupplyChainContract::where([
|
||||
'contract_id' => $request->contract_id,
|
||||
])->update([
|
||||
'bids' => $numBids,
|
||||
]);
|
||||
|
||||
return redirect('/supplychain/dashboard')->with('success', 'Bid succesfully entered into the contract.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a bid on a supply chain contract
|
||||
*
|
||||
* @var contractId
|
||||
* @var bidId
|
||||
*/
|
||||
public function deleteSupplyChainContractBid($contractId, $bidId) {
|
||||
|
||||
//See if the user has put in a bid. If not, then redirect to failure.
|
||||
$count = SupplyChainBid::where([
|
||||
'contract_id' => $contractId,
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
'bid_id' => $bidId,
|
||||
])->count();
|
||||
|
||||
if($count > 0) {
|
||||
SupplyChainBid::where([
|
||||
'contract_id' => $contractId,
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
'bid_id' => $bidId,
|
||||
])->delete();
|
||||
|
||||
//Update the database entry for the supply chain contract bid number
|
||||
$num = SupplyChainContract::where([
|
||||
'contract_id' => $contractId,
|
||||
])->select('bids')->first();
|
||||
|
||||
//Decrement the number of bids
|
||||
$numBids = $num->bids - 1;
|
||||
|
||||
//Update the database
|
||||
SupplyChainContract::where([
|
||||
'contract_id' => $contractId,
|
||||
])->update([
|
||||
'bids' => $numBids,
|
||||
]);
|
||||
|
||||
return redirect('/supplychain/dashboard')->with('success', 'Deleted supply chain contract bid.');
|
||||
} else {
|
||||
return redirect('/supplychain/dashboard')->with('error', 'No bid found to delete.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the modify a bid on supply chain contract page
|
||||
*/
|
||||
public function displayModifySupplyChainContractBid(Request $request) {
|
||||
$this->validate($request, [
|
||||
'contract_id' => 'required',
|
||||
]);
|
||||
|
||||
//Get the contract id
|
||||
$contractId = $request->contract_id;
|
||||
//Get the bid id to be modified later
|
||||
$bid = SupplyChainBid::where([
|
||||
'contract_id' => $contractId,
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
])->first();
|
||||
|
||||
$bidId = $bid->id;
|
||||
|
||||
return view('supplychain.forms.modifybid')->with('contractId', $contractId)
|
||||
->with('bidId', $bidId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify a bid on a supply chain contract
|
||||
*/
|
||||
public function modifySupplyChainContractBid(Request $request) {
|
||||
$this->validate($request, [
|
||||
'bid_id' => 'required',
|
||||
'contract_id' => 'required',
|
||||
'bid_amount' => 'required',
|
||||
]);
|
||||
|
||||
//Check for the owner of the bid
|
||||
$count = SupplyChainBid::where([
|
||||
'bid_id' => $request->bid_id,
|
||||
'contract_id' => $request->contract_id,
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
])->count();
|
||||
|
||||
if($count > 0) {
|
||||
if(isset($request->bid_note)) {
|
||||
SupplyChainBid::where([
|
||||
'bid_id' => $request->bid_id,
|
||||
'contract_id' => $request->contract_id,
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
])->update([
|
||||
'bid_amount' => $request->bid_amount,
|
||||
'bid_note' => $request->bid_note,
|
||||
]);
|
||||
} else {
|
||||
SupplyChainBid::where([
|
||||
'bid_id' => $request->bid_id,
|
||||
'contract_id' => $request->contract_id,
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
])->update([
|
||||
'bid_amount' => $request->bid_amount,
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect('/supplychain/dashboard')->with('success', 'Modified supply chain contract bid.');
|
||||
} else {
|
||||
return redirect('/supplychain/dashboard')->with('error', 'Not able to modify supply chain contract bid.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out a new supply chain contract mail
|
||||
*/
|
||||
private function NewSupplyChainContractMail(SupplyChainContract $contract) {
|
||||
//Get the config for the esi
|
||||
$config = config('esi');
|
||||
$todayDate = Carbon::now()->toFormattedDateString();
|
||||
|
||||
$subject = 'New Supply Chain Contract ' . $todayDate;
|
||||
$body = "A supply chain contract is available.<br>";
|
||||
$body .= "Contract: " . $contract->title . "<br>";
|
||||
$body .= "Notes: " . $contract->body . "<br>";
|
||||
$body .= "Delivery Date: " . $contract->delivery_date . "<br>";
|
||||
$body .= "<br>Sincerely on behalf of,<br>" . $contract->issuer_name . "<br>";
|
||||
SendEveMail::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->delay(Carbon::now()->addSeconds(30));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out a mail when the supply chain contract has been deleted
|
||||
*/
|
||||
private function DeleteSupplyChainContractMail($contract) {
|
||||
//Get the esi config
|
||||
$config = config('esi');
|
||||
|
||||
$subject = 'Production Contract Removal';
|
||||
$body = "A production contract has been deleted.<br>";
|
||||
$body .= "Contract: " . $contract->title . "<br>";
|
||||
$body .= "Notes: " . $contract->note . "<br>";
|
||||
$body .= "<br>Sincerely on behalf of,<br>" . $contract->issuer_name;
|
||||
SendEveMail::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->delay(Carbon::now()->addSeconds(30));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tidy up datatables from a completed supply chain contract
|
||||
*/
|
||||
private function TidySupplyChainContract($contract, $bid) {
|
||||
//Set the contract as finished
|
||||
SupplyChainContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'state' => 'finished',
|
||||
]);
|
||||
|
||||
//Set all of the bids as not_accepted as default
|
||||
SupplyChainBid::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'bid_type' => 'not_accepted',
|
||||
]);
|
||||
|
||||
//Set the correct bid as accepted
|
||||
SupplyChainBid::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
'bid_id' => $bid->bid_id,
|
||||
])->update([
|
||||
'bid_type' => 'accepted',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use DB;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
|
||||
//Models
|
||||
use App\User;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\AvailableUserPermission;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
|
||||
class AdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
public function displayDashboard() {
|
||||
//Declare variables needed for displaying items on the page
|
||||
$months = 3;
|
||||
$pi = array();
|
||||
$industry = array();
|
||||
$reprocessing = array();
|
||||
$office = array();
|
||||
$user = array();
|
||||
$permission = array();
|
||||
$entities = array();
|
||||
$corpId = 98287666;
|
||||
|
||||
/** Taxes Pane */
|
||||
//Declare classes needed for displaying items on the page
|
||||
$tHelper = new TaxesHelper();
|
||||
//Get the dates for the tab panes
|
||||
$dates = $tHelper->GetTimeFrameInMonths($months);
|
||||
//Get the data for the Taxes Pane
|
||||
foreach($dates as $date) {
|
||||
//Get the pi taxes for the date range
|
||||
$pis[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetPIGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the industry taxes for the date range
|
||||
$industrys[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetIndustryGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the reprocessing taxes for the date range
|
||||
$reprocessings[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetReprocessingGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the office taxes for the date range
|
||||
$offices[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetOfficeGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the market taxes for the date range
|
||||
$markets[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetMarketGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the jump gate taxes for the date range
|
||||
$jumpgates[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetJumpGateGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
$pigross[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetPiSalesGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
}
|
||||
|
||||
/** Users & Permissions Pane */
|
||||
//Get the users from the database to allow a selection of users for various parts of the webpage
|
||||
$users = User::pluck('name')->all();
|
||||
//Get the available permissions from the database to allow a selection of permissions
|
||||
$permissions = AvailableUserPermission::pluck('permission')->all();
|
||||
//Create the user key value pairs
|
||||
foreach($users as $key => $value) {
|
||||
$user[$value] = $value;
|
||||
}
|
||||
//Create the permission key value pairs
|
||||
foreach($permissions as $key => $value) {
|
||||
$permission[$value] = $value;
|
||||
}
|
||||
//Create the data array
|
||||
$data = [
|
||||
'users' => $user,
|
||||
'permissions' => $permission,
|
||||
];
|
||||
|
||||
/** Entities for allowed logins */
|
||||
$legacys = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_name')->toArray();
|
||||
$renters = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_name')->toArray();
|
||||
//Compile a list of entities by their entity_id
|
||||
foreach($legacys as $legacy) {
|
||||
$entities[] = $legacy;
|
||||
}
|
||||
foreach($renters as $renter) {
|
||||
$entities[] = $renter;
|
||||
}
|
||||
|
||||
return view('admin.dashboard')->with('data', $data)
|
||||
->with('pis', $pis)
|
||||
->with('industrys', $industrys)
|
||||
->with('offices', $offices)
|
||||
->with('markets', $markets)
|
||||
->with('jumpgates', $jumpgates)
|
||||
->with('reprocessings', $reprocessings)
|
||||
->with('entities', $entities)
|
||||
->with('pigross', $pigross);
|
||||
}
|
||||
|
||||
public function modifyRole(Request $request) {
|
||||
return redirect('/admin/dashboard')->with('error', 'Not implemented yet.');
|
||||
}
|
||||
|
||||
public function addPermission(Request $request) {
|
||||
//Get the user and permission from the form
|
||||
$user = $request->user;
|
||||
$permission = $request->permission;
|
||||
|
||||
//Get the character id from the username using the user table
|
||||
$character = User::where(['name' => $user])->get(['character_id']);
|
||||
|
||||
//Check to see if the character already has the permission
|
||||
$check = UserPermission::where(['character_id' => $character[0]->character_id, 'permission' => $permission])->get(['permission']);
|
||||
|
||||
if(!isset($check[0]->permission)) {
|
||||
$perm = new UserPermission;
|
||||
$perm->character_id = $character[0]->character_id;
|
||||
$perm->permission = $permission;
|
||||
$perm->save();
|
||||
|
||||
return redirect('/admin/dashboard')->with('success', 'User udpated!');
|
||||
} else {
|
||||
return redirect('/admin/dashboard')->with('error', 'User not updated or already has the permission.');
|
||||
}
|
||||
}
|
||||
|
||||
public function removeUser(Request $request) {
|
||||
//Get the user from the form to delete
|
||||
$user = $request->user;
|
||||
|
||||
//Get the user data from the table
|
||||
$data = User::where(['name' => $user])->get();
|
||||
|
||||
//Delete the user's ESI Scopes
|
||||
DB::table('EsiScopes')->where(['character_id' => $data[0]->character_id])->delete();
|
||||
|
||||
//Delete the user's ESI Token
|
||||
DB::table('EsiTokens')->where(['character_id' => $data[0]->character_id])->delete();
|
||||
|
||||
//Delete the user's role from the roles table
|
||||
DB::table('user_roles')->where(['character_id' => $data[0]->character_id])->delete();
|
||||
|
||||
//Delete the user from the user table
|
||||
DB::table('users')->where(['character_id' => $data[0]->character_id])->delete();
|
||||
|
||||
return redirect('/admin/dashboard')->with('success', 'User deleted from the site.');
|
||||
}
|
||||
|
||||
public function addAllowedLogin(Request $request) {
|
||||
//Set the parameters to validate the form
|
||||
$this->validate($request, [
|
||||
'allowedEntityId' => 'required',
|
||||
'allowedEntityType' => 'required',
|
||||
'allowedEntityName' => 'required',
|
||||
'allowedLoginType' => 'required',
|
||||
]);
|
||||
|
||||
//Check to see if the entity exists in the database already
|
||||
$found = AllowedLogin::where([
|
||||
'entity_type' => $request->allowedentityType,
|
||||
'entity_name' => $request->allowedEntityName,
|
||||
])->get();
|
||||
if($found != null) {
|
||||
AllowedLogin::where([
|
||||
'entity_type' => $request->allowedEntityType,
|
||||
'entity_name' => $request->allowedEntityName,
|
||||
])->update([
|
||||
'entity_id' => $request->allowedEntityId,
|
||||
'entity_type' => $request->allowedEntityType,
|
||||
'entity_name' => $request->allowedEntityName,
|
||||
'login_type' => $request->allowedLoginType,
|
||||
]);
|
||||
} else {
|
||||
$login = new AllowedLogin;
|
||||
$login->entity_id = $request->allowedEntityId;
|
||||
$login->entity_name = $request->allowedEntityName;
|
||||
$login->entity_type = $request->allowedEntityType;
|
||||
$login->login_type = $request->allowedLoginType;
|
||||
}
|
||||
|
||||
return redirect('/admin/dashboard')->with('success', 'Entity added to allowed login list.');
|
||||
}
|
||||
|
||||
public function removeAllowedLogin(Request $request) {
|
||||
//Set the parameters to validate the form
|
||||
$this->validate($request, [
|
||||
'removeAllowedLogin' => 'required',
|
||||
]);
|
||||
|
||||
AllowedLogin::where([
|
||||
'entity_name' => $request->removeAllowedLogin,
|
||||
])->delete();
|
||||
|
||||
return redirect('/admin/dashboard')->with('success', 'Entity removed from allowed login list.');
|
||||
}
|
||||
}
|
||||
440
app/Http/Controllers/Dashboard/AdminDashboardController.php
Normal file
440
app/Http/Controllers/Dashboard/AdminDashboardController.php
Normal file
@@ -0,0 +1,440 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Helpers\TaxesHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Helpers\SRPHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\AvailableUserPermission;
|
||||
use App\Models\User\AvailableUserRole;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
use App\Models\Finances\AllianceWalletJournal;
|
||||
|
||||
class AdminDashboardController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the administration dashboard.
|
||||
*/
|
||||
public function displayAdminDashboard() {
|
||||
if(auth()->user()->hasRole('Admin') ||
|
||||
auth()->user()->hasPermission('srp.admin') ||
|
||||
auth()->user()->hasPermission('contract.admin' ||
|
||||
auth()->user()->hasPermission('mining.officer'))) {
|
||||
//Do nothing and continue on
|
||||
} else {
|
||||
redirect('/dashboard');
|
||||
}
|
||||
|
||||
|
||||
return view('admin.dashboards.dashboard');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display users in a paginated format
|
||||
*/
|
||||
public function displayUsersPaginated() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare array variables
|
||||
$user = array();
|
||||
$permission = array();
|
||||
$userArr = array();
|
||||
$permString = null;
|
||||
|
||||
$usersArr = User::orderBy('name', 'asc')->paginate(50);
|
||||
|
||||
foreach($usersArr as $user) {
|
||||
$user->role = $user->getRole();
|
||||
|
||||
$permCount = UserPermission::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->count();
|
||||
|
||||
if($permCount > 0) {
|
||||
$perms = UserPermission::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->get('permission')->toArray();
|
||||
|
||||
foreach($perms as $perm) {
|
||||
$permString .= $perm['permission'] . ', ';
|
||||
}
|
||||
|
||||
$user->permission = $permString;
|
||||
} else {
|
||||
$user->permission = 'No Permissions';
|
||||
}
|
||||
}
|
||||
|
||||
return view('admin.dashboards.userspaged')->with('usersArr', $usersArr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search users for a specific user
|
||||
*/
|
||||
public function searchUsers(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare array variables
|
||||
$user = array();
|
||||
$permission = array();
|
||||
$userArr = array();
|
||||
$permString = null;
|
||||
|
||||
//Validate the input from the form
|
||||
$this->validate($request, [
|
||||
'parameter' => 'required',
|
||||
]);
|
||||
|
||||
$usersArr = User::where('name', 'like', $request->parameter . "%")->paginate(50);
|
||||
|
||||
foreach($usersArr as $user) {
|
||||
$user->role = $user->getRole();
|
||||
|
||||
$permCount = UserPermission::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->count();
|
||||
|
||||
if($permCount > 0) {
|
||||
$perms = UserPermission::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->get('permission')->toArray();
|
||||
|
||||
foreach($perms as $perm) {
|
||||
$permString .= $perm['permission'] . ', ';
|
||||
}
|
||||
|
||||
$user->permission = $permString;
|
||||
} else {
|
||||
$user->permission = 'No Permissions';
|
||||
}
|
||||
}
|
||||
|
||||
return view('admin.dashboards.users.searched')->with('usersArr', $usersArr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the allowed logins
|
||||
*/
|
||||
public function displayAllowedLogins() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare array variables
|
||||
$entities = array();
|
||||
|
||||
/** Entities for allowed logins */
|
||||
$legacys = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_name')->toArray();
|
||||
$renters = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_name')->toArray();
|
||||
//Compile a list of entities by their entity_id
|
||||
foreach($legacys as $legacy) {
|
||||
$entities[] = $legacy;
|
||||
}
|
||||
foreach($renters as $renter) {
|
||||
$entities[] = $renter;
|
||||
}
|
||||
|
||||
return view('admin.dashboards.allowed_logins')->with('entities', $entities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the taxes for the alliance
|
||||
*
|
||||
*/
|
||||
public function displayTaxes() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare variables needed for displaying items on the page
|
||||
$months = 6;
|
||||
$pi = array();
|
||||
$industry = array();
|
||||
$reprocessing = array();
|
||||
$office = array();
|
||||
$corpId = 98287666;
|
||||
$srpActual = array();
|
||||
$srpLoss = array();
|
||||
$miningTaxes = array();
|
||||
$miningTaxesLate = array();
|
||||
|
||||
/** Taxes Pane */
|
||||
//Declare classes needed for displaying items on the page
|
||||
$tHelper = new TaxesHelper();
|
||||
$srpHelper = new SRPHelper();
|
||||
//Get the dates for the tab panes
|
||||
$dates = $tHelper->GetTimeFrameInMonths($months);
|
||||
|
||||
//Get the data for the Taxes Pane
|
||||
foreach($dates as $date) {
|
||||
//Get the srp actual pay out for the date range
|
||||
$srpActual[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($srpHelper->GetAllianceSRPActual($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
//Get the srp loss value for the date range
|
||||
$srpLoss[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($srpHelper->GetAllianceSRPLoss($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
//Get the pi taxes for the date range
|
||||
$pis[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetPIGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the industry taxes for the date range
|
||||
$industrys[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetIndustryGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the reprocessing taxes for the date range
|
||||
$reprocessings[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetReprocessingGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the office taxes for the date range
|
||||
$offices[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetOfficeGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the market taxes for the date range
|
||||
$markets[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetAllianceMarketGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the jump gate taxes for the date range
|
||||
$jumpgates[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetJumpGateGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
$miningTaxes[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetMoonMiningTaxesGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
$miningTaxesLate[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetMoonMiningTaxesLateGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
$moonRentalTaxes[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetMoonRentalTaxesGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
}
|
||||
|
||||
return view('admin.dashboards.taxes')->with('pis', $pis)
|
||||
->with('industrys', $industrys)
|
||||
->with('offices', $offices)
|
||||
->with('markets', $markets)
|
||||
->with('jumpgates', $jumpgates)
|
||||
->with('reprocessings', $reprocessings)
|
||||
->with('srpActual', $srpActual)
|
||||
->with('srpLoss', $srpLoss)
|
||||
->with('miningTaxes', $miningTaxes)
|
||||
->with('miningTaxesLate', $miningTaxesLate)
|
||||
->with('moonRentalTaxes', $moonRentalTaxes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the modify user form
|
||||
*/
|
||||
public function displayModifyUser(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$permissions = array();
|
||||
$roles = array();
|
||||
|
||||
$name = $request->user;
|
||||
|
||||
//Get the user information from the name
|
||||
$user = User::where(['name' => $name])->first();
|
||||
|
||||
$perms = AvailableUserPermission::all();
|
||||
foreach($perms as $p) {
|
||||
$permissions[$p->permission] = $p->permission;
|
||||
}
|
||||
|
||||
$tempRoles = AvailableUserRole::all();
|
||||
|
||||
foreach($tempRoles as $tempRole) {
|
||||
array_push($roles, [
|
||||
$tempRole['role'] => $tempRole['role']
|
||||
]);
|
||||
}
|
||||
|
||||
$role = $user->getRole();
|
||||
|
||||
//Pass the user information to the page for hidden text entries
|
||||
return view('admin.user.modify')->with('user', $user)
|
||||
->with('permissions', $permissions)
|
||||
->with('role', $role)
|
||||
->with('roles', $roles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify a user's role
|
||||
*/
|
||||
public function modifyRole(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$this->validate($request, [
|
||||
'user' => 'required',
|
||||
'role' => 'required',
|
||||
]);
|
||||
|
||||
UserRole::where(['character_id' => $request->user])->update([
|
||||
'role' => $request->role,
|
||||
]);
|
||||
|
||||
return redirect('/admin/dashboard/users')->with('success', "User: " . $request->user . " has been modified to a new role: " . $request->role . ".");
|
||||
}
|
||||
|
||||
public function addPermission(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Get the user and permission from the form
|
||||
$character = $request->user;
|
||||
$permission = $request->permission;
|
||||
|
||||
//Check to see if the character already has the permission
|
||||
$check = UserPermission::where(['character_id' => $character, 'permission' => $permission])->get(['permission']);
|
||||
|
||||
if(!isset($check[0]->permission)) {
|
||||
$perm = new UserPermission;
|
||||
$perm->character_id = $character;
|
||||
$perm->permission = $permission;
|
||||
$perm->save();
|
||||
|
||||
return redirect('/admin/dashboard/users')->with('success', 'User udpated!');
|
||||
} else {
|
||||
return redirect('/admin/dashboard/users')->with('error', 'User not updated or already has the permission.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a user to reset their permissions
|
||||
*/
|
||||
public function removeUser(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Get the user from the form to delete
|
||||
$user = $request->user;
|
||||
|
||||
//Get the user data from the table
|
||||
$data = User::where(['name' => $user])->get();
|
||||
|
||||
//Delete the user's ESI Scopes
|
||||
DB::table('EsiScopes')->where(['character_id' => $data[0]->character_id])->delete();
|
||||
|
||||
//Delete the user's ESI Token
|
||||
DB::table('EsiTokens')->where(['character_id' => $data[0]->character_id])->delete();
|
||||
|
||||
//Delete the user's role from the roles table
|
||||
DB::table('user_roles')->where(['character_id' => $data[0]->character_id])->delete();
|
||||
|
||||
//Delete the user from the user table
|
||||
DB::table('users')->where(['character_id' => $data[0]->character_id])->delete();
|
||||
|
||||
return redirect('/admin/dashboard/users')->with('success', 'User deleted from the site.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an entity to the allowed login table
|
||||
*/
|
||||
public function addAllowedLogin(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Set the parameters to validate the form
|
||||
$this->validate($request, [
|
||||
'allowedEntityId' => 'required',
|
||||
'allowedEntityType' => 'required',
|
||||
'allowedEntityName' => 'required',
|
||||
'allowedLoginType' => 'required',
|
||||
]);
|
||||
|
||||
//Check to see if the entity exists in the database already
|
||||
$found = AllowedLogin::where([
|
||||
'entity_type' => $request->allowedentityType,
|
||||
'entity_name' => $request->allowedEntityName,
|
||||
])->count();
|
||||
if($found != 0) {
|
||||
AllowedLogin::where([
|
||||
'entity_type' => $request->allowedEntityType,
|
||||
'entity_name' => $request->allowedEntityName,
|
||||
])->update([
|
||||
'entity_id' => $request->allowedEntityId,
|
||||
'entity_type' => $request->allowedEntityType,
|
||||
'entity_name' => $request->allowedEntityName,
|
||||
'login_type' => $request->allowedLoginType,
|
||||
]);
|
||||
} else {
|
||||
$login = new AllowedLogin;
|
||||
$login->entity_id = $request->allowedEntityId;
|
||||
$login->entity_name = $request->allowedEntityName;
|
||||
$login->entity_type = $request->allowedEntityType;
|
||||
$login->login_type = $request->allowedLoginType;
|
||||
$login->save();
|
||||
}
|
||||
|
||||
return redirect('/admin/dashboard')->with('success', 'Entity added to allowed login list.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an entity from the allowed login table
|
||||
*/
|
||||
public function removeAllowedLogin(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Set the parameters to validate the form
|
||||
$this->validate($request, [
|
||||
'removeAllowedLogin' => 'required',
|
||||
]);
|
||||
|
||||
AllowedLogin::where([
|
||||
'entity_name' => $request->removeAllowedLogin,
|
||||
])->delete();
|
||||
|
||||
return redirect('/admin/dashboard')->with('success', 'Entity removed from allowed login list.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show journal entries in a table for admins from alliance wallets
|
||||
*/
|
||||
public function displayJournalEntries() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$date = Carbon::now()->subDays(60);
|
||||
|
||||
$journal = AllianceWalletJournal::where('date', '>=', $date)
|
||||
->where([
|
||||
'corporation_id' => 98287666,
|
||||
'ref_type' => 'player_donation',
|
||||
])->orderByDesc('date',)->get(['amount', 'reason', 'description', 'date']);
|
||||
|
||||
return view('admin.dashboards.walletjournal')->with('journal', $journal);
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,27 @@
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
//Internal Libraries
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\StructureHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\SRP\SRPShip;
|
||||
use App\Models\User\UserAlt;
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
@@ -22,7 +34,7 @@ class DashboardController extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Guest');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,7 +44,250 @@ class DashboardController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard');
|
||||
//Set some variables to be used in if statements
|
||||
$open = array();
|
||||
$approved = array();
|
||||
$denied = array();
|
||||
$ores = array();
|
||||
$altCount = null;
|
||||
$alts = null;
|
||||
$structures = array();
|
||||
$esiHelper = new Esi;
|
||||
$config = config('esi');
|
||||
$sHelper = new StructureHelper($config['primary'], $config['corporation']);
|
||||
$lava = new Lavacharts;
|
||||
|
||||
|
||||
/**
|
||||
* Alt Counts
|
||||
*/
|
||||
//Get the number of the user's alt which are registered so we can process the alt's on the main dashboard page
|
||||
$altCount = UserAlt::where([
|
||||
'main_id' => auth()->user()->character_id,
|
||||
])->count();
|
||||
|
||||
//If the alt count is greater than 0 get all of the alt accounts
|
||||
if($altCount > 0) {
|
||||
$alts = UserAlt::where([
|
||||
'main_id' => auth()->user()->character_id,
|
||||
])->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* SRP Items
|
||||
*/
|
||||
//See if we can get all of the open SRP requests
|
||||
$openCount = SRPShip::where([
|
||||
'character_id' => auth()->user()->character_id,
|
||||
'approved' => 'Under Review',
|
||||
])->count();
|
||||
if($openCount > 0) {
|
||||
$open = SRPShip::where([
|
||||
'character_id' => auth()->user()->character_id,
|
||||
'approved' => 'Under Review'
|
||||
])->get()->toArray();
|
||||
}
|
||||
|
||||
//See if we can get all of the closed and approved SRP requests
|
||||
$approvedCount = SRPShip::where([
|
||||
'character_id' => auth()->user()->character_id,
|
||||
'approved' => 'Approved',
|
||||
])->count();
|
||||
if($approvedCount > 0) {
|
||||
$approved = SRPShip::where([
|
||||
'character_id' => auth()->user()->character_id,
|
||||
'approved' => 'Approved',
|
||||
])->take(10)->get()->toArray();
|
||||
}
|
||||
|
||||
//See if we can get all of the closed and denied SRP requests
|
||||
$deniedCount = SRPShip::where([
|
||||
'character_id' => auth()->user()->character_id,
|
||||
'approved' => 'Denied',
|
||||
])->count();
|
||||
if($deniedCount > 0) {
|
||||
$denied = SRPShip::where([
|
||||
'character_id' => auth()->user()->character_id,
|
||||
'approved' => 'Denied',
|
||||
])->take(10)->get()->toArray();
|
||||
}
|
||||
|
||||
//Process all types of srp requests for the alt of the main and add to the main's page
|
||||
if($altCount > 0) {
|
||||
//For each alt, get the open requests, and increment the open request counter
|
||||
foreach($alts as $alt) {
|
||||
$altOpenCount = SRPShip::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'approved' => 'Under Review',
|
||||
])->count();
|
||||
if($altOpenCount > 0) {
|
||||
//If the number of open requests is greater than zero, add to the open count
|
||||
$openCount += $altOpenCount;
|
||||
|
||||
//Get the alt's open srp requests
|
||||
$altOpen = SRPShip::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'approved' => 'Under Review',
|
||||
])->get()->toArray();
|
||||
|
||||
//Add the alt's open requests to the open requests array
|
||||
foreach($altOpen as $aOpen) {
|
||||
array_push($open, $aOpen);
|
||||
}
|
||||
}
|
||||
|
||||
$altApprovedCount = SRPShip::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'approved' => 'Approved',
|
||||
])->count();
|
||||
if($altApprovedCount > 0) {
|
||||
//If the number of approved requests is greater than zero, add to the approved count
|
||||
$approvedCount += $altApprovedCount;
|
||||
|
||||
//Get the alt's approved srp request
|
||||
$altApproved = SRPShip::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'approved' => 'Approved',
|
||||
])->take(5)->get()->toArray();
|
||||
|
||||
//For each alt add it to the array
|
||||
foreach($altApproved as $aApproved) {
|
||||
array_push($approved, $aApproved);
|
||||
}
|
||||
}
|
||||
|
||||
$altDeniedCount = SRPShip::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'approved' => 'Denied',
|
||||
])->count();
|
||||
if($altDeniedCount > 0) {
|
||||
//If the denied count is greater then zero for the alt, add it to the count
|
||||
$deniedCount += $altDeniedCount;
|
||||
|
||||
//Get the denied alt's srp requests
|
||||
$altDenied = SRPShip::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'approved' => 'Denied',
|
||||
])->take(5)->get()->toArray();
|
||||
|
||||
//For each alt's denied request add it to the array
|
||||
foreach($altDenied as $aDenied) {
|
||||
array_push($denied, $aDenied);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Create a chart of number of approved, denied, and open requests via a fuel gauge chart
|
||||
$adur = $lava->DataTable();
|
||||
|
||||
$adur->addStringColumn('Type')
|
||||
->addNumberColumn('Number')
|
||||
->addRow(['SRP', $openCount]);
|
||||
|
||||
$lava->GaugeChart('SRP', $adur, [
|
||||
'width' => 200,
|
||||
'max' => 15,
|
||||
'greenFrom' => 0,
|
||||
'greenTo' => 5,
|
||||
'yellowFrom' => 5,
|
||||
'yellowTo' => 10,
|
||||
'redFrom' => 10,
|
||||
'redTo' => 15,
|
||||
'majorTicks' => [
|
||||
'Safe',
|
||||
'Warning',
|
||||
'Critical',
|
||||
],
|
||||
]);
|
||||
|
||||
/**
|
||||
* Mining Tax Items
|
||||
*/
|
||||
//Check for the correct scopes
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
||||
return redirect('/dashboard')->with('error', 'Tell the nub Minerva to register the correct scopes for the services site.');
|
||||
}
|
||||
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Get the esi data for extractions
|
||||
try {
|
||||
$extractions = $esi->invoke('get', '/corporation/{corporation_id}/mining/extractions', [
|
||||
'corporation_id' => $config['corporation'],
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical('Could not retrieve the extractions from ESI in DisplayExtractionCalendar in MiningTaxesController');
|
||||
return redirect('/dashboard')->with('error', 'Failed to get extraction data from ESI');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a 3 month calendar for the past, current, and future extractions
|
||||
*/
|
||||
//Create the data tables
|
||||
$calendar = $lava->DataTable();
|
||||
|
||||
$calendar->addDateTimeColumn('Date')
|
||||
->addNumberColumn('Total');
|
||||
|
||||
foreach($extractions as $extraction) {
|
||||
$sInfo = $sHelper->GetStructureInfo($extraction->structure_id);
|
||||
array_push($structures, [
|
||||
'date' => $esiHelper->DecodeDate($extraction->chunk_arrival_time),
|
||||
'total' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
foreach($extractions as $extraction) {
|
||||
for($i = 0; $i < sizeof($structures); $i++) {
|
||||
//Create the dates in a carbon object, then only get the Y-m-d to compare.
|
||||
$tempStructureDate = Carbon::createFromFormat('Y-m-d H:i:s', $structures[$i]['date'])->toDateString();
|
||||
$extractionDate = Carbon::createFromFormat('Y-m-d H:i:s', $esiHelper->DecodeDate($extraction->chunk_arrival_time))->toDateString();
|
||||
//check if the dates are equal then increase the total by 1
|
||||
if($tempStructureDate == $extractionDate) {
|
||||
$structures[$i]['total'] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($structures as $structure) {
|
||||
$calendar->addRow([
|
||||
$structure['date'],
|
||||
$structure['total'],
|
||||
]);
|
||||
}
|
||||
|
||||
$lava->CalendarChart('Extractions', $calendar, [
|
||||
'title' => 'Upcoming Extractions',
|
||||
'unusedMonthOutlineColor' => [
|
||||
'stroke' => '#ECECEC',
|
||||
'strokeOpacity' => 0.75,
|
||||
'strokeWidth' => 1,
|
||||
],
|
||||
'dayOfWeekLabel' => [
|
||||
'color' => '#4f5b0d',
|
||||
'fontSize' => 16,
|
||||
'italic' => true,
|
||||
],
|
||||
'noDataPattern' => [
|
||||
'color' => '#DDD',
|
||||
'backgroundColor' => '#11FFFF',
|
||||
],
|
||||
'colorAxis' => [
|
||||
'values' => [0, 5],
|
||||
'colors' => ['green', 'red'],
|
||||
],
|
||||
]);
|
||||
|
||||
return view('dashboard')->with('openCount', $openCount)
|
||||
->with('approvedCount', $approvedCount)
|
||||
->with('deniedCount', $deniedCount)
|
||||
->with('open', $open)
|
||||
->with('approved', $approved)
|
||||
->with('denied', $denied)
|
||||
->with('lava', $lava)
|
||||
->with('calendar', $calendar);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,16 +297,57 @@ class DashboardController extends Controller
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function profile() {
|
||||
$scopes = EsiScope::where('character_id', Auth()->user()->character_id)->get();
|
||||
$permissions = UserPermission::where('character_id', Auth()->user()->characer_id)->get();
|
||||
$roles = UserRole::where('character_id', Auth()->user()->character_id)->get();
|
||||
//Declare some variables
|
||||
$alts = null;
|
||||
$scopes = null;
|
||||
$permissions = null;
|
||||
$roles = null;
|
||||
|
||||
$data = [
|
||||
'scopes' => $scopes,
|
||||
'permissions' => $permissions,
|
||||
'roles' => $roles,
|
||||
];
|
||||
//Get the Esi scopes, user permission set, and roles
|
||||
$scopeCount = EsiScope::where('character_id', Auth()->user()->character_id)->count();
|
||||
if($scopeCount > 0) {
|
||||
$scopes = EsiScope::where('character_id', Auth()->user()->character_id)->get();
|
||||
}
|
||||
|
||||
return view('dashboard.profile')->with('data', $data);
|
||||
//Get the permission count and permission of the user
|
||||
$permissionCount = UserPermission::where('character_id', auth()->user()->character_id)->count();
|
||||
if($permissionCount > 0) {
|
||||
$permissions = UserPermission::where('character_id', auth()->user()->character_id)->get();
|
||||
}
|
||||
|
||||
//Get the roles and role count of the user
|
||||
$roleCount = UserRole::where('character_id', Auth()->user()->character_id)->count();
|
||||
if($roleCount > 0) {
|
||||
$roles = UserRole::where('character_id', Auth()->user()->character_id)->get();
|
||||
}
|
||||
|
||||
//Get the alt count and alts of the user
|
||||
$altCount = UserAlt::where('main_id', Auth()->user()->character_id)->count();
|
||||
if($altCount > 0) {
|
||||
$alts = UserAlt::where(['main_id' => Auth()->user()->character_id])->get();
|
||||
}
|
||||
|
||||
//Return the view with that data
|
||||
return view('dashboard.profile')->with('scopeCount', $scopeCount)
|
||||
->with('scopes', $scopes)
|
||||
->with('permissionCount', $permissionCount)
|
||||
->with('permissions', $permissions)
|
||||
->with('roleCount', $roleCount)
|
||||
->with('roles', $roles)
|
||||
->with('altCount', $altCount)
|
||||
->with('alts', $alts);
|
||||
}
|
||||
|
||||
public function removeAlt(Request $request) {
|
||||
$this->validate($request, [
|
||||
'character' => 'required',
|
||||
]);
|
||||
|
||||
UserAlt::where([
|
||||
'main_id' => auth()->user()->character_id,
|
||||
'character_id' => $request->character,
|
||||
])->delete();
|
||||
|
||||
return redirect('/dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
322
app/Http/Controllers/Finances/FinanceController.php
Normal file
322
app/Http/Controllers/Finances/FinanceController.php
Normal file
@@ -0,0 +1,322 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Finances;
|
||||
|
||||
//Internal Libraries
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Helpers\TaxesHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Helpers\SRPHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
|
||||
class FinanceController extends Controller
|
||||
{
|
||||
//Construct
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:ceo');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the finances of the alliance with cards like the admin dashboard
|
||||
*/
|
||||
public function displayCards() {
|
||||
$months = 3;
|
||||
|
||||
$pi = array();
|
||||
$industry = array();
|
||||
$reprocessing = array();
|
||||
$office = array();
|
||||
$corpId = 98287666;
|
||||
$srpActual = array();
|
||||
$srpLoss = array();
|
||||
$miningTaxes = array();
|
||||
$miningTaxesLate = array();
|
||||
|
||||
/** Taxes Pane */
|
||||
//Declare classes needed for displaying items on the page
|
||||
$tHelper = new TaxesHelper();
|
||||
$srpHelper = new SRPHelper();
|
||||
//Get the dates for the tab panes
|
||||
$dates = $tHelper->GetTimeFrameInMonths($months);
|
||||
|
||||
//Get the data for the Taxes Pane
|
||||
foreach($dates as $date) {
|
||||
//Get the srp actual pay out for the date range
|
||||
$srpActual[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($srpHelper->GetAllianceSRPActual($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
//Get the srp loss value for the date range
|
||||
$srpLoss[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($srpHelper->GetAllianceSRPLoss($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
//Get the pi taxes for the date range
|
||||
$pis[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetPIGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the industry taxes for the date range
|
||||
$industrys[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetIndustryGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the reprocessing taxes for the date range
|
||||
$reprocessings[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetReprocessingGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the office taxes for the date range
|
||||
$offices[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetOfficeGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the market taxes for the date range
|
||||
$markets[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetAllianceMarketGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the jump gate taxes for the date range
|
||||
$jumpgates[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetJumpGateGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
$miningTaxes[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetMoonMiningTaxesGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
$miningTaxesLate[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetMoonMiningTaxesLateGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
$moonRentalTaxes[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetMoonRentalTaxesGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
return view('finances.display.card')->with('pis', $pis)
|
||||
->with('industrys', $industrys)
|
||||
->with('offices', $offices)
|
||||
->with('markets', $markets)
|
||||
->with('jumpgates', $jumpgates)
|
||||
->with('reprocessings', $reprocessings)
|
||||
->with('srpActual', $srpActual)
|
||||
->with('srpLoss', $srpLoss)
|
||||
->with('miningTaxes', $miningTaxes)
|
||||
->with('miningTaxesLate', $miningTaxesLate)
|
||||
->with('moonRentalTaxes', $moonRentalTaxes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a graph of the financial outlook of the alliance
|
||||
*/
|
||||
public function displayOutlook() {
|
||||
$months = 12;
|
||||
$income = array();
|
||||
$expenses = array();
|
||||
$totalPi = 0.00;
|
||||
$totalIndustry = 0.00;
|
||||
$totalReprocessing = 0.00;
|
||||
$totalOffices = 0.00;
|
||||
$totalMarket = 0.00;
|
||||
$totalJumpGate = 0.00;
|
||||
$totalMiningTaxes = 0.00;
|
||||
$totalMoonRentals = 0.00;
|
||||
$totalSrp = 0.00;
|
||||
$totalCapEx = 0.00;
|
||||
$totalSovExpenses = 0.00;
|
||||
|
||||
/**
|
||||
* Declare classes needed for displaying items on the page
|
||||
*/
|
||||
$tHelper = new TaxesHelper();
|
||||
$srpHelper = new SRPHelper();
|
||||
//Get the dates to process
|
||||
$dates = $tHelper->GetTimeFrameInMonths($months);
|
||||
|
||||
/**
|
||||
* Setup the chart variables
|
||||
*/
|
||||
$lava = new Lavacharts;
|
||||
$finances = $lava->DataTable();
|
||||
$incomeStreams = $lava->DataTable();
|
||||
$expenseStreams = $lava->DataTable();
|
||||
|
||||
$finances->addDateColumn('Month')
|
||||
->addNumberColumn('Income')
|
||||
->addNumberColumn('Expenses')
|
||||
->addNumberColumn('Difference')
|
||||
->setDateTimeFormat('Y');
|
||||
|
||||
/**
|
||||
* Get the income and expenses data for date range
|
||||
*/
|
||||
foreach($dates as $date) {
|
||||
/**
|
||||
* Get the individual expenses.
|
||||
* Will totalize later in the foreach loop
|
||||
*/
|
||||
$srpActual = $srpHelper->GetAllianceSRPActual($date['start'], $date['end']);
|
||||
$capEx = 0.00;
|
||||
$sovExpenses = 3000000000.00;
|
||||
|
||||
/**
|
||||
* Get the individual incomes.
|
||||
* Will totalize later in the foreach loop
|
||||
*/
|
||||
$pi = $tHelper->GetPIGross($date['start'], $date['end']);
|
||||
$industry = $tHelper->GetIndustryGross($date['start'], $date['end']);
|
||||
$reprocessing = $tHelper->GetReprocessingGross($date['start'], $date['end']);
|
||||
$offices = $tHelper->GetOfficeGross($date['start'], $date['end']);
|
||||
$market = $tHelper->GetAllianceMarketGross($date['start'], $date['end']);
|
||||
$jumpgate = $tHelper->GetJumpGateGross($date['start'], $date['end']);
|
||||
$miningTaxes = $tHelper->GetMoonMiningTaxesGross($date['start'], $date['end']) + $tHelper->GetMoonMiningTaxesLateGross($date['start'], $date['end']);
|
||||
$moonRentals = $tHelper->GetMoonRentalTaxesGross($date['start'], $date['end']);
|
||||
|
||||
/**
|
||||
* Totalize the expenses
|
||||
*/
|
||||
$expenses = (($srpActual + $capEx + $sovExpenses) / 1000000.00);
|
||||
|
||||
/**
|
||||
* Totalize the incomes
|
||||
*/
|
||||
$incomes = (($pi +
|
||||
$industry +
|
||||
$reprocessing +
|
||||
$offices +
|
||||
$market +
|
||||
$jumpgate +
|
||||
$miningTaxes +
|
||||
$moonRentals) / 1000000.00);
|
||||
|
||||
/**
|
||||
* Get the difference between income and expenses
|
||||
*/
|
||||
$difference = $incomes - $expenses;
|
||||
|
||||
//Add the rows for the combo column chart
|
||||
$finances->addRow([$date['start'], $incomes, $expenses, $difference]);
|
||||
|
||||
//Add up each of the income streams, then the expenses
|
||||
$totalPi += $pi;
|
||||
$totalIndustry += $industry;
|
||||
$totalReprocessing += $reprocessing;
|
||||
$totalOffices += $offices;
|
||||
$totalMarket += $market;
|
||||
$totalJumpGate += $jumpgate;
|
||||
$totalMiningTaxes += $miningTaxes;
|
||||
$totalMoonRentals += $moonRentals;
|
||||
$totalSrp += $srpActual;
|
||||
$totalCapEx = $capEx;
|
||||
$totalSovExpenses += $sovExpenses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish setting up the lava chart before passing it to the blade template
|
||||
*/
|
||||
$lava->ComboChart('Finances', $finances, [
|
||||
'title' => 'Alliance Finances',
|
||||
'titleTextStyle' => [
|
||||
'color' => 'rgb(123, 65, 80)',
|
||||
'fontSize' => 16,
|
||||
],
|
||||
'legend' => [
|
||||
'position' => 'in',
|
||||
],
|
||||
'seriesType' => 'bars',
|
||||
'series' => [
|
||||
2 => [
|
||||
'type' => 'line',
|
||||
],
|
||||
],
|
||||
'height' => 360,
|
||||
]);
|
||||
|
||||
/**
|
||||
* Setup the 3d pie chart for income streams
|
||||
*/
|
||||
$incomeStreams->addStringColumn('Incomes')
|
||||
->addNumberColumn('ISK')
|
||||
->addRow(['PI', $totalPi])
|
||||
->addRow(['Industry', $totalIndustry])
|
||||
->addRow(['Reprocessing', $totalReprocessing])
|
||||
->addRow(['Offices', $totalOffices])
|
||||
->addRow(['Market', $totalMarket])
|
||||
->addRow(['Jump Gate', $totalJumpGate])
|
||||
->addRow(['Mining Taxes', $totalMiningTaxes])
|
||||
->addRow(['Moon Rentals', $totalMoonRentals]);
|
||||
|
||||
/**
|
||||
* Setup the 3d pie chart for expense streams
|
||||
*/
|
||||
$expenseStreams->addStringColumn('Expenses')
|
||||
->addNumberColumn('ISK')
|
||||
->addRow(['SRP', $totalSrp])
|
||||
->addRow(['Cap Ex', $totalCapEx])
|
||||
->addRow(['Sov Expenses', $totalSovExpenses]);
|
||||
|
||||
/**
|
||||
* Setup the pie chart data for income streams
|
||||
*/
|
||||
$lava->PieChart('Incomes', $incomeStreams, [
|
||||
'title' => 'Alliance Income Streams',
|
||||
'is3D' => true,
|
||||
'height' => 360,
|
||||
]);
|
||||
|
||||
/**
|
||||
* Setup the pie chart data for expenses
|
||||
*/
|
||||
$lava->PieChart('Expenses', $expenseStreams, [
|
||||
'title' => 'Alliance Expenses',
|
||||
'is3D' => true,
|
||||
'height' => 360,
|
||||
'slices' => [
|
||||
['offset' => 0.15],
|
||||
['offset' => 0.25],
|
||||
],
|
||||
]);
|
||||
|
||||
return view('finances.display.outlook')->with('lava', $lava);
|
||||
}
|
||||
|
||||
/**
|
||||
* Request an amount of ISK to fund a capital project
|
||||
*/
|
||||
public function requestFundingDisplay() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the request for the capital project
|
||||
*/
|
||||
public function storeFundingRequest() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a request for the capital project
|
||||
*/
|
||||
public function deleteFundingRequest() {
|
||||
|
||||
}
|
||||
}
|
||||
88
app/Http/Controllers/Logistics/FuelController.php
Normal file
88
app/Http/Controllers/Logistics/FuelController.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Logistics;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
use Auth;
|
||||
use Charts;
|
||||
|
||||
//Library Helpers
|
||||
use App\Library\Helpers\AssetHelper;
|
||||
use App\Library\Helpers\StructureHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Asset;
|
||||
use App\Models\Structure\Service;
|
||||
|
||||
class FuelController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function displayStructures() {
|
||||
//Declare variables
|
||||
$jumpGates = array();
|
||||
$lava = new Lavacharts;
|
||||
|
||||
//Declare the class helpers
|
||||
$sHelper = new StructureHelper(null, null, null);
|
||||
$aHelper = new AssetHelper(null, null, null);
|
||||
|
||||
//Setup the charts
|
||||
$gauge = $lava->DataTable();
|
||||
$gauge->addStringColumn('Fuel')
|
||||
->addNumberColumn('Units');
|
||||
|
||||
//Get all of the jump gates
|
||||
$gates = $sHelper->GetStructuresByType('Ansiblex Jump Gate');
|
||||
|
||||
foreach($gates as $gate) {
|
||||
$liquidOzone = $aHelper->GetAssetByType(16273, $gate->structure_id);
|
||||
$temp = [
|
||||
'name' => $gate->structure_name,
|
||||
'system' => $gate->solar_system_name,
|
||||
'fuel_expires' => $gate->fuel_expires,
|
||||
'liquid_ozone' => $liquidOzone,
|
||||
'link' => '/logistics/fuel/display/' . $gate->structure_id . '/',
|
||||
];
|
||||
|
||||
array_push($jumpGates, $temp);
|
||||
|
||||
if($liquidOzone > 1000000) {
|
||||
$liquidOzone = 1000000;
|
||||
}
|
||||
|
||||
$gauge->addRow([$gate->solar_system_name, $liquidOzone]);
|
||||
}
|
||||
|
||||
$lava->GaugeChart('Liquid Ozone', $gauge, [
|
||||
'min' => 0,
|
||||
'max' => 1000000,
|
||||
'greenFrom' => 0,
|
||||
'greenTo' => 150000,
|
||||
'greenColor' => '#DC3912',
|
||||
'yellowFrom' => 150000,
|
||||
'yellowTo' => 300000,
|
||||
'yellowColor' => '#FF9900',
|
||||
'redFrom' => 300000,
|
||||
'redTo' => 1000000,
|
||||
'redColor' => '#109618',
|
||||
'majorTicks' => [
|
||||
'Empty',
|
||||
'Full',
|
||||
],
|
||||
]);
|
||||
|
||||
return view('logistics.fuel')->with('jumpGates', $jumpGates)
|
||||
->with('lava', $lava);
|
||||
}
|
||||
}
|
||||
308
app/Http/Controllers/MiningTaxes/MiningTaxesAdminController.php
Normal file
308
app/Http/Controllers/MiningTaxes/MiningTaxesAdminController.php
Normal file
@@ -0,0 +1,308 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
use Auth;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Helpers\StructureHelper;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\MiningTax\Observer;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
use App\Models\MiningTax\Payment;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Moon\MineralPrice;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\MiningTax\MiningOperation;
|
||||
|
||||
class MiningTaxesAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:mining.officer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the form for mining operations held by the alliance
|
||||
*/
|
||||
public function displayMiningOperationForm() {
|
||||
//Declare variables
|
||||
$config = config('esi');
|
||||
$lookup = new LookupHelper;
|
||||
$sHelper = new StructureHelper($config['primary'], $config['corporation']);
|
||||
$coll = new Collection;
|
||||
$structures = new Collection;
|
||||
|
||||
//Get all of the structures
|
||||
$athanors = $sHelper->GetStructuresByType('Athanor');
|
||||
$tataras = $sHelper->GetStructuresByType('Tatara');
|
||||
|
||||
//Cycle through each athanor and add it to the stack
|
||||
foreach($athanors as $athanor) {
|
||||
$structures->push([
|
||||
$athanor->structure_id => $athanor->structure_name,
|
||||
]);
|
||||
}
|
||||
//Cycle through each tatara and add it to the stack
|
||||
foreach($tataras as $tatara) {
|
||||
$structures->push([
|
||||
$tatara->structure_id => $tatara->structure_name,
|
||||
]);
|
||||
}
|
||||
//Sort all of the structures
|
||||
$structures->sort();
|
||||
|
||||
//Get the current mining operations.
|
||||
$operations = MiningOperation::where([
|
||||
'processed' => 'No',
|
||||
])->get();
|
||||
|
||||
return view('miningtax.admin.display.miningops.form')->with('structures', $structures)
|
||||
->with('operations', $operations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the results from the mining operations form
|
||||
*/
|
||||
public function storeMiningOperationForm(Request $request) {
|
||||
//Validate the data
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'date' => 'required',
|
||||
'structure' => 'required',
|
||||
]);
|
||||
|
||||
$config = config('esi');
|
||||
$sHelper = new StructureHelper($config['primary'], $config['corporation']);
|
||||
|
||||
//Get the name of the structure from the database
|
||||
$m = $sHelper->GetStructureInfo($request->structure);
|
||||
|
||||
//Save the mining operation into the database
|
||||
$operation = new MiningOperation;
|
||||
$operation->structure_id = $request->structure;
|
||||
$operation->structure_name = $m->structure_name;
|
||||
$operation->authorized_by_id = auth()->user()->getId();
|
||||
$operation->authorized_by_name = auth()->user()->getName();
|
||||
$operation->operation_name = $request->name;
|
||||
$operation->operation_date = $request->date;
|
||||
$operation->processed = 'No';
|
||||
$operation->processed_on = null;
|
||||
$operation->save();
|
||||
|
||||
return redirect('/admin/dashboard')->with('success', 'Operation added successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the page to approve corporation moon rentals
|
||||
*/
|
||||
public function DisplayMoonRentalRequests() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve a moon rental from the form
|
||||
*/
|
||||
public function storeApproveMoonRentalRequest() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the page to setup the form for corporations to rent a moon
|
||||
*/
|
||||
public function DisplayMoonRentalForm() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the details for the form for corporations renting a specific moon
|
||||
*/
|
||||
public function StoreMoonRentalForm() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a moon from being rented from a specific corporation
|
||||
*/
|
||||
public function DeleteMoonRental(Request $request) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display an invoice based on it's id
|
||||
*
|
||||
* @var $invoiceId
|
||||
*/
|
||||
public function displayInvoice($invoiceId) {
|
||||
$ores = array();
|
||||
$moons = array();
|
||||
$totalPrice = 0.00;
|
||||
$config = config('esi');
|
||||
$structure = new StructureHelper($config['primary'], $config['corporation']);
|
||||
|
||||
//Get the invoice from the database
|
||||
$invoice = Invoice::where([
|
||||
'invoice_id' => $invoiceId,
|
||||
])->first();
|
||||
|
||||
//Get the line items for the ledger for the invoice
|
||||
$items = Ledger::where([
|
||||
'invoice_id' => $invoiceId,
|
||||
])->get();
|
||||
|
||||
//Build the total ores table for the display page
|
||||
foreach($items as $item) {
|
||||
if(!isset($ores[$item['ore_name']])) {
|
||||
$ores[$item['ore_name']] = 0;
|
||||
}
|
||||
$ores[$item['ore_name']] = $ores[$item['ore_name']] + $item['quantity'];
|
||||
|
||||
$totalPrice += $item['amount'];
|
||||
}
|
||||
|
||||
//Print out the lines of the ledger line by line for another table
|
||||
foreach($items as $item) {
|
||||
//Get the structure info from the database or esi
|
||||
$tempObserverInfo = $structure->GetStructureInfo($item['observer_id']);
|
||||
|
||||
if(isset($tempObserverInfo->name)) {
|
||||
array_push($moons, [
|
||||
'character_name' => $item['character_name'],
|
||||
'observer_name' => $tempObserverInfo->name,
|
||||
'type_id' => $item['type_id'],
|
||||
'ore_name' => $item['ore_name'],
|
||||
'quantity' => $item['quantity'],
|
||||
'amount' => $item['amount'],
|
||||
'tax_amount' => $item['amount'] * $config['public_mining_tax'],
|
||||
]);
|
||||
} else {
|
||||
array_push($moons, [
|
||||
'character_name' => $item['character_name'],
|
||||
'observer_name' => $tempObserverInfo->structure_name,
|
||||
'type_id' => $item['type_id'],
|
||||
'ore_name' => $item['ore_name'],
|
||||
'quantity' => $item['quantity'],
|
||||
'amount' => $item['amount'],
|
||||
'tax_amount' => $item['amount'] * $config['public_mining_tax'],
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return view('miningtax.admin.display.details.invoice')->with('ores', $ores)
|
||||
->with('moons', $moons)
|
||||
->with('invoice', $invoice)
|
||||
->with('totalPrice', $totalPrice);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display current unpaid invoices
|
||||
*/
|
||||
public function DisplayUnpaidInvoice() {
|
||||
$invoices = Invoice::where([
|
||||
'status' => 'Pending',
|
||||
])->orWhere([
|
||||
'status' => 'Late',
|
||||
])->orWhere([
|
||||
'status' => 'Deferred',
|
||||
])->orderByDesc('invoice_id')->paginate(50);
|
||||
|
||||
$totalAmount = Invoice::where([
|
||||
'status' => 'Pending',
|
||||
])->orWhere([
|
||||
'status' => 'Late',
|
||||
])->orWhere([
|
||||
'status' => 'Deferred',
|
||||
])->sum('invoice_amount');
|
||||
|
||||
return view('miningtax.admin.display.unpaid')->with('invoices', $invoices);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search unpaid invoices
|
||||
*/
|
||||
public function SearchUnpaidInvoice(Request $request) {
|
||||
$invoices = Invoice::where('invoice_id', 'LIKE', '%' . $request->q . '%')
|
||||
->where(['status' => 'Pending'])
|
||||
->orWhere(['status' => 'Late'])
|
||||
->orWhere(['status' => 'Deferred'])
|
||||
->orderByDesc('invoice_id')
|
||||
->paginate(25);
|
||||
|
||||
if(count($invoices) > 0) {
|
||||
return view('miningtax.admin.display.unpaid')->with('invoices', $invoices);
|
||||
}
|
||||
|
||||
return view('miningtax.admin.display.unpaid')->with('error', 'No invoices found');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display page to modify an unpaid invoice
|
||||
*/
|
||||
public function DisplayModifyInvoice() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify an unpaid invoice
|
||||
*/
|
||||
public function ProcessModifyInvoice() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark an invoice paid
|
||||
*/
|
||||
public function UpdateInvoice(Request $request) {
|
||||
$this->validate($request, [
|
||||
'invoiceId' => 'required',
|
||||
'status' => 'required',
|
||||
]);
|
||||
|
||||
Invoice::where([
|
||||
'invoice_id' => $request->invoiceId,
|
||||
])->update([
|
||||
'status' => $request->status,
|
||||
'modified_by_id' => auth()->user()->getId(),
|
||||
'modified_by_name' => auth()->user()->getName(),
|
||||
]);
|
||||
|
||||
return redirect('/miningtax/admin/display/unpaid')->with('success', 'Invoice successfully updated.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display past paid invoices
|
||||
*/
|
||||
public function DisplayPaidInvoices() {
|
||||
$invoices = Invoice::where([
|
||||
'status' => 'Paid',
|
||||
])->orWhere([
|
||||
'status' => 'Paid Late',
|
||||
])->paginate(50);
|
||||
|
||||
$totalAmount = Invoice::where([
|
||||
'status' => 'Paid',
|
||||
])->orWhere([
|
||||
'status' => 'Paid Late',
|
||||
])->sum('invoice_amount');
|
||||
|
||||
return view('miningtax.admin.display.paidinvoices')->with('invoices', $invoices)
|
||||
->with('totalAmount', $totalAmount);
|
||||
}
|
||||
}
|
||||
635
app/Http/Controllers/MiningTaxes/MiningTaxesController.php
Normal file
635
app/Http/Controllers/MiningTaxes/MiningTaxesController.php
Normal file
@@ -0,0 +1,635 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use DB;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
use Auth;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
//Library Helpers
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Helpers\StructureHelper;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Moon\MineralPrice;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
use App\Models\MiningTax\Observer;
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\User\User;
|
||||
use App\Models\MoonRental\AllianceMoon;
|
||||
use App\Models\MoonRental\AllianceMoonOre;
|
||||
use App\Models\MoonRental\AllianceMoonRental;
|
||||
|
||||
class MiningTaxesController extends Controller
|
||||
{
|
||||
/**
|
||||
* Construct to deal with middleware and other items
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the moons either the person is renting, or their corp are renting
|
||||
*/
|
||||
public function DisplayRentedMoons() {
|
||||
$moons = array();
|
||||
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
$userId = auth()->user()->getId();
|
||||
$charInfo = $lookup->GetCharacterInfo(auth()->user()->getId());
|
||||
$corpId = $charInfo->corporation_id;
|
||||
|
||||
|
||||
$tempMoons = AllianceMoonRental::where([
|
||||
'entity_id' => $userId,
|
||||
])->orWhere([
|
||||
'entity_id' => $corpId,
|
||||
])->get();
|
||||
|
||||
//Foreach of the moons we got let's build the moon info and the ore data
|
||||
foreach($tempMoons as $tempMoon) {
|
||||
//Get the ores for the moon
|
||||
$ores = AllianceMoonOre::where([
|
||||
'moon_id' => $tempMoon->moon_id,
|
||||
])->get()->toArray();
|
||||
|
||||
$moons->push([
|
||||
'moon_id' => $tempMoon->moon_id,
|
||||
'system' => $tempMoon->system_name,
|
||||
'moon_name' => $tempMoon->name,
|
||||
'ores' => $ores,
|
||||
'worth_amount' => $tempMoon->worth_amount,
|
||||
'rental_amount' => $tempMoon->rental_amount,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('miningtax.user.display.rentedmoons')->with('moons', $moons)
|
||||
->with('ores', $ores);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the page with the moon rental form
|
||||
*/
|
||||
public function DisplayMoonRentalForm(Request $request) {
|
||||
$this->validate($request, [
|
||||
'moon_id' => 'required',
|
||||
'moon_name' => 'required',
|
||||
'worth_amount' => 'required',
|
||||
'rental_amount' => 'required',
|
||||
]);
|
||||
|
||||
$moon = AllianceMoon::where([
|
||||
'moon_id' => $request->moon_id,
|
||||
])->first();
|
||||
|
||||
$ores = AllianceMoonOre::where([
|
||||
'moon_id' => $request->moon_id,
|
||||
])->get();
|
||||
|
||||
return view('miningtax.user.display.moonrentals.form')->with('moon', $moon)
|
||||
->with('ores', $ores);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the information from the moon rental form
|
||||
*/
|
||||
public function storeMoonRentalForm(Request $request) {
|
||||
$this->validate($request, [
|
||||
'moon_id' => 'required',
|
||||
'rental_start' => 'required',
|
||||
'rental_end' => 'required',
|
||||
'entity_name' => 'required',
|
||||
'entity_type' => 'required',
|
||||
]);
|
||||
|
||||
$lookup = new LookupHelper;
|
||||
$entityId = null;
|
||||
|
||||
//From the name and type of the entity get the entity id.
|
||||
if($request->entity_type == 'Character') {
|
||||
$entityId = $lookup->CharacterNameToId($request->entity_name);
|
||||
} else if($request->entity_type == 'Corporation') {
|
||||
$entityId = $lookup->CorporationNameToId($request->entity_name);
|
||||
} else if($request->entity_type == 'Alliance') {
|
||||
$entityId = $lookup->AllianceNameToId($request->entity_name);
|
||||
} else {
|
||||
return redirect('/dashboard')->with('error', 'Moon Rental error. Please contact the site admin.');
|
||||
}
|
||||
|
||||
//Create the next billing date from a Carbon date 3 months from the rental start
|
||||
$nextBillingDate = Carbon::create($request->rental_start)->addMonths(3);
|
||||
|
||||
//Create the uniqid for the billing cycle.
|
||||
$invoiceId = "MR" . uniqid();
|
||||
|
||||
//Get the moon's information from the database so we know how much to make the bill for
|
||||
$moon = AllianceMoon::where([
|
||||
'moon_id' => $request->moon_id,
|
||||
])->first();
|
||||
|
||||
//Update the data on the Alliance Moon
|
||||
AllianceMoon::where([
|
||||
'moon_id' => $request->moon_id,
|
||||
])->update([
|
||||
'rented' => 'Yes',
|
||||
]);
|
||||
|
||||
//Insert a new moon rental into the database
|
||||
AllianceMoonRental::insert([
|
||||
'moon_id' => $moon->moon_id,
|
||||
'moon_name' => $moon->name,
|
||||
'rental_amount' => $moon->rental_amount,
|
||||
'rental_start' => $request->rental_start,
|
||||
'rental_end' => $request->rental_end,
|
||||
'next_billing_date' => $nextBillingDate,
|
||||
'entity_id' => $entityId,
|
||||
'entity_name' => $request->entity_name,
|
||||
'entity_type' => $request->entity_type,
|
||||
]);
|
||||
|
||||
return redirect('/dashboard')->with('success', 'Before placing a structure please send the ISK to the holding corp with the description of ' . $invoiceId);
|
||||
}
|
||||
|
||||
public function displayAvailableMoons() {
|
||||
//Declare variables
|
||||
$moons = new Collection;
|
||||
$mHelper = new MoonCalc;
|
||||
$lookup = new LookupHelper;
|
||||
$system = array();
|
||||
|
||||
/**
|
||||
* Declare our different flavors of moon goo for the blade
|
||||
*/
|
||||
$r4Goo = [
|
||||
'Zeolites',
|
||||
'Sylvite',
|
||||
'Bitumens',
|
||||
'Coesite',
|
||||
];
|
||||
|
||||
$r8Goo = [
|
||||
'Cobaltite',
|
||||
'Euxenite',
|
||||
'Titanite',
|
||||
'Scheelite',
|
||||
];
|
||||
|
||||
$r16Goo = [
|
||||
'Otavite',
|
||||
'Sperrylite',
|
||||
'Vanadinite',
|
||||
'Chromite',
|
||||
];
|
||||
|
||||
$r32Goo = [
|
||||
'Carnotite',
|
||||
'Zircon',
|
||||
'Pollucite',
|
||||
'Cinnabar',
|
||||
];
|
||||
|
||||
$r64Goo = [
|
||||
'Xenotime',
|
||||
'Monazite',
|
||||
'Loparite',
|
||||
'Ytterbite',
|
||||
];
|
||||
|
||||
//Get all of the system names from the database by plucking all the non-rented moon system names
|
||||
$systems = AllianceMoon::where([
|
||||
'rented' => 'No',
|
||||
])->pluck('system_name')->unique()->toArray();
|
||||
|
||||
//Get all of the moons which are not rented
|
||||
$allyMoons = AllianceMoon::where([
|
||||
'rented' => 'No',
|
||||
])->get();
|
||||
|
||||
//Cycle through all of the moons to create arrays of data
|
||||
foreach($allyMoons as $moon) {
|
||||
$ores = AllianceMoonOre::where([
|
||||
'moon_id' => $moon->moon_id,
|
||||
])->get(['ore_name', 'quantity'])->toArray();
|
||||
|
||||
if($moon->moon_type != 'R32' && $moon->moon_type != 'R64') {
|
||||
$moons->push([
|
||||
'system' => $moon->system_name,
|
||||
'moon_name' => $moon->name,
|
||||
'ores' => $ores,
|
||||
'worth_amount' => $moon->worth_amount,
|
||||
'rental_amount' => $moon->rental_amount,
|
||||
'moon_id' => $moon->moon_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return view('miningtax.user.display.moons.availablemoons')->with('moons', $moons)
|
||||
->with('systems', $systems)
|
||||
->with('r4Goo', $r4Goo)
|
||||
->with('r8Goo', $r8Goo)
|
||||
->with('r16Goo', $r16Goo)
|
||||
->with('r32Goo', $r32Goo)
|
||||
->with('r64Goo', $r64Goo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display all the moons in Warped Intentions Sovreignty
|
||||
*/
|
||||
public function displayAllMoons() {
|
||||
//Declare variables
|
||||
$moons = new Collection;
|
||||
$mHelper = new MoonCalc;
|
||||
$lookup = new LookupHelper;
|
||||
$system = array();
|
||||
|
||||
/**
|
||||
* Declare our different flavors of moon goo for the blade
|
||||
*/
|
||||
$r4Goo = [
|
||||
'Zeolites',
|
||||
'Sylvite',
|
||||
'Bitumens',
|
||||
'Coesite',
|
||||
];
|
||||
|
||||
$r8Goo = [
|
||||
'Cobaltite',
|
||||
'Euxenite',
|
||||
'Titanite',
|
||||
'Scheelite',
|
||||
];
|
||||
|
||||
$r16Goo = [
|
||||
'Otavite',
|
||||
'Sperrylite',
|
||||
'Vanadinite',
|
||||
'Chromite',
|
||||
];
|
||||
|
||||
$r32Goo = [
|
||||
'Carnotite',
|
||||
'Zircon',
|
||||
'Pollucite',
|
||||
'Cinnabar',
|
||||
];
|
||||
|
||||
$r64Goo = [
|
||||
'Xenotime',
|
||||
'Monazite',
|
||||
'Loparite',
|
||||
'Ytterbite',
|
||||
];
|
||||
|
||||
$systems = [
|
||||
'0-NTIS',
|
||||
'1-NJLK',
|
||||
'35-JWD',
|
||||
'8KR9-5',
|
||||
'EIMJ-M',
|
||||
'F-M1FU',
|
||||
'G-C8QO',
|
||||
'I6M-9U',
|
||||
'L5D-ZL',
|
||||
'L-YMYU',
|
||||
'VQE-CN',
|
||||
'VR-YIQ',
|
||||
'XZ-SKZ',
|
||||
'Y-CWQY',
|
||||
];
|
||||
|
||||
//Get all of the moons which are not rented
|
||||
$allyMoons = AllianceMoon::all();
|
||||
|
||||
foreach($allyMoons as $moon) {
|
||||
$ores = AllianceMoonOre::where([
|
||||
'moon_id' => $moon->moon_id,
|
||||
])->get(['ore_name', 'quantity'])->toArray();
|
||||
|
||||
$moons->push([
|
||||
'system' => $moon->system_name,
|
||||
'moon_name' => $moon->name,
|
||||
'ores' => $ores,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('miningtax.user.display.moons.allmoons')->with('moons', $moons)
|
||||
->with('systems', $systems)
|
||||
->with('r4Goo', $r4Goo)
|
||||
->with('r8Goo', $r8Goo)
|
||||
->with('r16Goo', $r16Goo)
|
||||
->with('r32Goo', $r32Goo)
|
||||
->with('r64Goo', $r64Goo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display an invoice based on it's id
|
||||
*
|
||||
* @var $invoiceId
|
||||
*/
|
||||
public function displayInvoice($invoiceId) {
|
||||
$ores = array();
|
||||
$moons = array();
|
||||
$totalPrice = 0.00;
|
||||
$config = config('esi');
|
||||
$structure = new StructureHelper($config['primary'], $config['corporation']);
|
||||
|
||||
$systems = AllianceMoon::where([
|
||||
'rented' => 'No',
|
||||
])->pluck('system_name')->unique()->toArray();
|
||||
|
||||
//Get the invoice from the database
|
||||
$invoice = Invoice::where([
|
||||
'invoice_id' => $invoiceId,
|
||||
])->first();
|
||||
|
||||
//Get the line items for the ledger for the invoice
|
||||
$items = Ledger::where([
|
||||
'invoice_id' => $invoiceId,
|
||||
])->get();
|
||||
|
||||
//Build the total ores table for the display page
|
||||
foreach($items as $item) {
|
||||
if(!isset($ores[$item['ore_name']])) {
|
||||
$ores[$item['ore_name']] = 0;
|
||||
}
|
||||
$ores[$item['ore_name']] = $ores[$item['ore_name']] + $item['quantity'];
|
||||
|
||||
$totalPrice += $item['amount'];
|
||||
}
|
||||
|
||||
//Print out the lines of the ledger line by line for another table
|
||||
foreach($items as $item) {
|
||||
//Get the structure info from the database or esi
|
||||
$tempObserverInfo = $structure->GetStructureInfo($item['observer_id']);
|
||||
|
||||
//Create the array for the line by line
|
||||
array_push($moons, [
|
||||
'character_name' => $item['character_name'],
|
||||
'observer_name' => $tempObserverInfo->structure_name,
|
||||
'type_id' => $item['type_id'],
|
||||
'ore_name' => $item['ore_name'],
|
||||
'quantity' => $item['quantity'],
|
||||
'amount' => $item['amount'],
|
||||
'tax_amount' => $item['amount'] * $config['public_mining_tax'],
|
||||
]);
|
||||
}
|
||||
|
||||
return view('miningtax.user.display.details.invoice')->with('ores', $ores)
|
||||
->with('moons', $moons)
|
||||
->with('invoice', $invoice)
|
||||
->with('totalPrice', $totalPrice);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the users invoices
|
||||
*/
|
||||
public function DisplayInvoices() {
|
||||
//Declare variables
|
||||
$paidAmount = 0.00;
|
||||
$unpaidAmount = 0.00;
|
||||
|
||||
//Get the unpaid invoices
|
||||
$unpaid = Invoice::where([
|
||||
'status' => 'Pending',
|
||||
'character_id' => auth()->user()->getId(),
|
||||
])->paginate(15);
|
||||
|
||||
//Get the late invoices
|
||||
$late = Invoice::where([
|
||||
'status' => 'Late',
|
||||
'character_id' => auth()->user()->getId(),
|
||||
])->paginate(10);
|
||||
|
||||
//Get the deferred invoices
|
||||
$deferred = Invoice::where([
|
||||
'status' => 'Deferred',
|
||||
'character_id' => auth()->user()->getId(),
|
||||
])->paginate(10);
|
||||
|
||||
//Get the paid invoices
|
||||
$paid = Invoice::where([
|
||||
'status' => 'Paid',
|
||||
'character_id' => auth()->user()->getId(),
|
||||
])->paginate(15);
|
||||
|
||||
//Total up the unpaid invoices
|
||||
foreach($unpaid as $un) {
|
||||
$unpaidAmount += $un->invoice_amount;
|
||||
}
|
||||
|
||||
//Total up the paid invoices
|
||||
foreach($paid as $p) {
|
||||
$paidAmount += $p->invoice_amount;
|
||||
}
|
||||
|
||||
return view('miningtax.user.display.invoices.invoices')->with('unpaid', $unpaid)
|
||||
->with('late', $late)
|
||||
->with('deferred', $deferred)
|
||||
->with('paid', $paid)
|
||||
->with('unpaidAmount', $unpaidAmount)
|
||||
->with('paidAmount', $paidAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display all of the upcoming extractions
|
||||
*/
|
||||
public function DisplayUpcomingExtractions() {
|
||||
|
||||
//Declare variables
|
||||
$structures = array();
|
||||
$esiHelper = new Esi;
|
||||
$config = config('esi');
|
||||
$sHelper = new StructureHelper($config['primary'], $config['corporation']);
|
||||
$structures = array();
|
||||
$structuresCalendar = array();
|
||||
$lava = new Lavacharts;
|
||||
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
||||
return redirect('/dashboard')->with('error', 'Tell the nub Minerva to register the correct scopes for the services site.');
|
||||
}
|
||||
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Get the esi data for extractions
|
||||
try {
|
||||
$extractions = $esi->invoke('get', '/corporation/{corporation_id}/mining/extractions/', [
|
||||
'corporation_id' => $config['corporation'],
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Could not retrieve extractions from ESI in MiningTaxesController.php');
|
||||
return redirect('/dashboard')->with('error', "Could not pull extractions from ESI data.");
|
||||
}
|
||||
|
||||
//Basically get the structure info and attach it to the variable set
|
||||
foreach($extractions as $ex) {
|
||||
$sName = $sHelper->GetStructureInfo($ex->structure_id);
|
||||
//Add the information into the structures array to go to the page to be displayed
|
||||
array_push($structures, [
|
||||
'structure_name' => $sName->structure_name,
|
||||
'start_time' => $esiHelper->DecodeDate($ex->extraction_start_time),
|
||||
'arrival_time' => $esiHelper->DecodeDate($ex->chunk_arrival_time),
|
||||
'decay_time' => $esiHelper->DecodeDate($ex->natural_decay_time),
|
||||
]);
|
||||
}
|
||||
|
||||
//Sort extractions by arrival time
|
||||
$structuresCollection = collect($structures);
|
||||
$sorted = $structuresCollection->sortBy('arrival_time');
|
||||
//Store the sorted collection back into the variable before being used again.
|
||||
$structures = $sorted->all();
|
||||
|
||||
/**
|
||||
* Create a 3 month calendar for the past, current, and future extractions
|
||||
*/
|
||||
//Create the data tables
|
||||
$calendar = $lava->DataTable();
|
||||
|
||||
$calendar->addDateTimeColumn('Date')
|
||||
->addNumberColumn('Total');
|
||||
|
||||
foreach($extractions as $extraction) {
|
||||
array_push($structuresCalendar, [
|
||||
'date' => $esiHelper->DecodeDate($extraction->chunk_arrival_time),
|
||||
'total' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
foreach($extractions as $extraction) {
|
||||
for($i = 0; $i < sizeof($structuresCalendar); $i++) {
|
||||
//Create the dates in a carbon object, then only get the Y-m-d to compare.
|
||||
$tempStructureDate = Carbon::createFromFormat('Y-m-d H:i:s', $structuresCalendar[$i]['date'])->toDateString();
|
||||
$extractionDate = Carbon::createFromFormat('Y-m-d H:i:s', $esiHelper->DecodeDate($extraction->chunk_arrival_time))->toDateString();
|
||||
//check if the dates are equal then increase the total by 1
|
||||
if($tempStructureDate == $extractionDate) {
|
||||
$structuresCalendar[$i]['total'] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($structuresCalendar as $structureC) {
|
||||
$calendar->addRow([
|
||||
$structureC['date'],
|
||||
$structureC['total'],
|
||||
]);
|
||||
}
|
||||
|
||||
$lava->CalendarChart('Extractions', $calendar, [
|
||||
'title' => 'Upcoming Extractions',
|
||||
'unusedMonthOutlineColor' => [
|
||||
'stroke' => '#ECECEC',
|
||||
'strokeOpacity' => 0.75,
|
||||
'strokeWidth' => 1,
|
||||
],
|
||||
'dayOfWeekLabel' => [
|
||||
'color' => '#4f5b0d',
|
||||
'fontSize' => 16,
|
||||
'italic' => true,
|
||||
],
|
||||
'noDataPattern' => [
|
||||
'color' => '#DDD',
|
||||
'backgroundColor' => '#11FFFF',
|
||||
],
|
||||
'colorAxis' => [
|
||||
'values' => [0, 5],
|
||||
'colors' => ['green', 'red'],
|
||||
],
|
||||
]);
|
||||
|
||||
//Return the view with the extractions variable for html processing
|
||||
return view('miningtax.user.display.pulls.upcoming')->with('structures', $structures)
|
||||
->with('lava', $lava)
|
||||
->with('calendar', $calendar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the ledger for the moons.
|
||||
*/
|
||||
public function DisplayMoonLedgers() {
|
||||
//Declare variables
|
||||
$structures = array();
|
||||
$tempLedgers = array();
|
||||
$miningLedgers = array();
|
||||
$ledgers = array();
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
$config = config('esi');
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
||||
return redirect('/dashboard')->with('error', 'Tell the nub Minerva to register the ESI for the holding corp for corp mining.');
|
||||
} else {
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1')) {
|
||||
return redirect('/dashboard')->with('error', 'Tell the nub Minerva to register the ESI for the holding corp for structures.');
|
||||
}
|
||||
}
|
||||
|
||||
//Get the refresh token if scope checks have passed
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
|
||||
//Setup the esi container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
//Declare the structure helper after the esi container has been created
|
||||
$sHelper = new StructureHelper($config['primary'], $config['corporation'], $esi);
|
||||
|
||||
//Get the character data from the lookup table if possible or esi
|
||||
$character = $lookup->GetCharacterInfo($config['primary']);
|
||||
|
||||
//Get the corporation information from the character id
|
||||
$corpInfo = $lookup->GetCorporationInfo($character->corporation_id);
|
||||
|
||||
//Get the observers from the database
|
||||
$observers = Observer::all();
|
||||
|
||||
//Get the ledgers for each structure one at a time
|
||||
foreach($observers as $obs) {
|
||||
//Get the structure information
|
||||
$structureInfo = $sHelper->GetStructureInfo($obs->observer_id);
|
||||
|
||||
//Add the name to the structures array
|
||||
array_push($structures, $structureInfo->name);
|
||||
/**
|
||||
* Get the ledger from each observer.
|
||||
* We don't care about observer type as it can only be an Athanor or Tatara
|
||||
*/
|
||||
$ledgers = Ledger::where([
|
||||
'observer_id' => $obs->observer_id,
|
||||
'character_id' => auth()->user()->getId(),
|
||||
])->where('last_updated', '>=', Carbon::now()->subDays(30))->get();
|
||||
|
||||
if($ledgers->count() > 0) {
|
||||
foreach($ledgers as $ledger) {
|
||||
//Foreach ledger add it to the array
|
||||
array_push($miningLedgers, [
|
||||
'structure' => $structureInfo->name,
|
||||
'character' => auth()->user()->getName(),
|
||||
'corpTicker' => $corpInfo->ticker,
|
||||
'ore' => $ledger->ore_name,
|
||||
'quantity' => $ledger->quantity,
|
||||
'updated' => $ledger->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Return the view
|
||||
return view('miningtax.user.display.details.ledger')->with('miningLedgers', $miningLedgers)
|
||||
->with('structures', $structures);
|
||||
}
|
||||
}
|
||||
@@ -1,420 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Moons;
|
||||
|
||||
//Internal Library
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\Config;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Moon\Moon;
|
||||
use App\Models\Moon\OrePrice;
|
||||
use App\Models\Moon\Price;
|
||||
use App\Models\MoonRent\MoonRental;
|
||||
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
class MoonsAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
public function showJournalEntries() {
|
||||
$dateInit = Carbon::now();
|
||||
$date = $dateInit->subDays(30);
|
||||
|
||||
$journal = DB::select('SELECT amount,reason,description,date FROM `player_donation_journal` WHERE corporation_id=98287666 AND date >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) ORDER BY date DESC');
|
||||
|
||||
return view('moons.admin.moonjournal')->with('journal', $journal);
|
||||
}
|
||||
|
||||
public function updateMoon() {
|
||||
//Return the view and the form from the blade display
|
||||
return view('moons.admin.updatemoon');
|
||||
}
|
||||
|
||||
public function storeUpdateMoonRental(Request $request) {
|
||||
$moonCalc = new MoonCalc;
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
$this->validate($request, [
|
||||
'system' => 'required',
|
||||
'planet' => 'required',
|
||||
'moon' => 'required',
|
||||
'renter' => 'required',
|
||||
'date' => 'required',
|
||||
'contact' => 'required',
|
||||
]);
|
||||
|
||||
//Take the contact name and create a character_id from it
|
||||
if($request->contact == 'None') {
|
||||
$contact = 'None';
|
||||
} else {
|
||||
$contact = $lookup->CharacterNameToId($request->contact);
|
||||
}
|
||||
|
||||
if(isset($request->Paid_Until)) {
|
||||
$paidUntil = $request->Paid_Until;
|
||||
} else {
|
||||
$paidUntil = null;
|
||||
}
|
||||
|
||||
//Let's find the corporation and alliance information to ascertain whethery they are in Warped Intentions or another Legacy Alliance
|
||||
$allianceId = $lookup->LookupCorporation($lookup->LookupCharacter($contact));
|
||||
|
||||
//Create the date
|
||||
$date = new Carbon($request->date . '00:00:01');
|
||||
|
||||
$found = MoonRental::where([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'Contact' => $contact,
|
||||
])->first();
|
||||
|
||||
//If the entry is found, we are most likely just updating an entry to include new paid until data
|
||||
if($found) {
|
||||
if($allianceId = 99004116) {
|
||||
MoonRental::where([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'Contact' => $contact,
|
||||
])->update([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['alliance'],
|
||||
'Type' => 'alliance',
|
||||
'Paid' => $paid,
|
||||
'Paid_Until' => $request->paid_until,
|
||||
]);
|
||||
} else {
|
||||
MoonRental::where([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'Contact' => $contact,
|
||||
])->update([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['outofalliance'],
|
||||
'Type' => 'alliance',
|
||||
'Paid' => $paid,
|
||||
'Paid_Until' => $request->paid_until,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
//If the entry is not found, then attempt to delete whatever existing data is there, then
|
||||
//insert the new data
|
||||
MoonRental::where([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
])->delete();
|
||||
|
||||
if($allianceId = 99004116) {
|
||||
MoonRental::insert([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['alliance'],
|
||||
'Type' => 'alliance',
|
||||
'Paid' => 'No',
|
||||
]);
|
||||
} else {
|
||||
MoonRental::insert([
|
||||
'System' =>$request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['outofalliance'],
|
||||
'Type' => 'outofalliance',
|
||||
'Paid' => 'No',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//Redirect to the update moon page
|
||||
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Updated');
|
||||
}
|
||||
|
||||
public function storeUpdateMoon(Request $request) {
|
||||
$moonCalc = new MoonCalc();
|
||||
$lookup = new LookupHelper();
|
||||
|
||||
$this->validate($request, [
|
||||
'system' => 'required',
|
||||
'planet' => 'required',
|
||||
'moon' => 'required',
|
||||
'renter' => 'required',
|
||||
'date' => 'required',
|
||||
'contact' => 'required',
|
||||
'paid' => 'required',
|
||||
]);
|
||||
|
||||
//Take the contact name and create a character id from it
|
||||
if($request->contact == 'None') {
|
||||
$contact = 'None';
|
||||
} else {
|
||||
$contact = $lookup->CharacterNameToId($request->contact);
|
||||
}
|
||||
//Let's find the corporation and alliance information to ascertain whether they are in Warped Intentions or another Legacy Alliance
|
||||
$corpId = $lookup->LookupCharacter($contact);
|
||||
$allianceId = $lookup->LookupCorporation($corpId);
|
||||
|
||||
//Create the date
|
||||
$date = new Carbon($request->date . '00:00:01');
|
||||
//Calculate the moon price
|
||||
$moon = Moon::where([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
])->first();
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
$date = new Carbon($request->date . '00:00:01');
|
||||
//Update the database entry
|
||||
Moon::where([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
])->update([
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
]);
|
||||
|
||||
//Going to store moon price in a table for future reference
|
||||
//We need to insert a price based on whether part of Legacy or part of Warped Intentions
|
||||
//Will need an if then else statement to complete this operation
|
||||
if($allianceId = 99004116) {
|
||||
MoonRental::insert([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['alliance'],
|
||||
'Type' => 'alliance',
|
||||
'Paid' => $request->paid,
|
||||
]);
|
||||
} else {
|
||||
MoonRental::insert([
|
||||
'System' =>$request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['outofalliance'],
|
||||
'Type' => 'outofalliance',
|
||||
'Paid' => $request->paid,
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the moons to admins
|
||||
*/
|
||||
public function displayMoonsAdmin() {
|
||||
$lookup = new LookupHelper;
|
||||
$contact = '';
|
||||
$paid = '';
|
||||
$rentalEnd = '';
|
||||
$renter = '';
|
||||
$ticker = '';
|
||||
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
//Update the prices for the moon
|
||||
$moonCalc->FetchNewPrices();
|
||||
//get all of the moons from the database
|
||||
$moons = Moon::orderBy('System', 'asc')->get();
|
||||
//declare the html variable and set it to null
|
||||
$table = array();
|
||||
foreach($moons as $moon) {
|
||||
//Get the rental data for the moon
|
||||
$rental = MoonRental::where([
|
||||
'System' => $moon->System,
|
||||
'Planet' => $moon->Planet,
|
||||
'Moon' => $moon->Moon,
|
||||
])->first();
|
||||
|
||||
//Check if their is a current rental for a moon going on
|
||||
if($rental == false) {
|
||||
//If we don't find a rental record, mark the moon as not paid
|
||||
$paid = 'No';
|
||||
|
||||
//If we don't find a rental record, set the rental date as last month
|
||||
$rentalTemp = Carbon::now()->subMonth();
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Set the contact info
|
||||
$contact = 'None';
|
||||
|
||||
//Set the renter info
|
||||
$renter = 'None';
|
||||
|
||||
$ticker = 'N/A';
|
||||
} else {
|
||||
//If we find a rental record, mark the moon as whether it's paid or not
|
||||
$paid = $rental->Paid;
|
||||
|
||||
//Set the rental date up
|
||||
$rentalTemp = new Carbon($rental->RentalEnd);
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Set the contact name
|
||||
$contact = $lookup->CharacterName($rental->Contact);
|
||||
|
||||
//Set up the renter whether it's W4RP or another corporation
|
||||
$corpId = $lookup->LookupCorporationId($rental->Contact);
|
||||
$allianceId = $lookup->LookupCorporation($corpId);
|
||||
$ticker = $lookup->LookupAllianceTicker($allianceId);
|
||||
}
|
||||
|
||||
//Set the color for the table
|
||||
$today = Carbon::now();
|
||||
if($rentalTemp->diffInDays($today) < 3 ) {
|
||||
$color = 'table-warning';
|
||||
} else if( $today > $rentalTemp) {
|
||||
$color = 'table-primary';
|
||||
} else {
|
||||
$color = 'table-danger';
|
||||
}
|
||||
|
||||
//Calculate hte price of the moon based on what is in the moon
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity, $moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
//Add the data to the html string to be passed to the view
|
||||
array_push($table, [
|
||||
'SPM' => $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon,
|
||||
'StructureName' => $moon->StructureName,
|
||||
'AlliancePrice' => $price['alliance'],
|
||||
'OutOfAlliancePrice' => $price['outofalliance'],
|
||||
'RentalEnd' => $rentalEnd,
|
||||
'RowColor' => $color,
|
||||
'Paid' => $paid,
|
||||
'Contact' => $contact,
|
||||
'Renter' => $ticker,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('moons.admin.adminmoon')->with('table', $table);
|
||||
}
|
||||
|
||||
public function UpdateMoonPaid(Request $request) {
|
||||
$this->validate($request, [
|
||||
'paid' => 'required',
|
||||
]);
|
||||
|
||||
$str_array = explode(" - ", $request->paid);
|
||||
|
||||
//Decode the value for the SPM into a system, planet, and moon for the database to update
|
||||
$system = $str_array[0];
|
||||
$planet = $str_array[1];
|
||||
$moon = $str_array[2];
|
||||
|
||||
//Update the paid status of the moon
|
||||
MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $moon,
|
||||
])->update([
|
||||
'Paid' => 'Yes',
|
||||
]);
|
||||
|
||||
//Redirect back to the moon page, which should call the page to be displayed correctly
|
||||
return redirect('/moons/admin/display');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display function for adding a new rental moon to the pool
|
||||
*
|
||||
*/
|
||||
public function addMoon() {
|
||||
return view('moons.admin.addmoon');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new moon into the database
|
||||
*
|
||||
* @return \Illuminate\Http\Reponse
|
||||
*/
|
||||
public function storeMoon(Request $request) {
|
||||
$this->validate($request, [
|
||||
'region' => 'required',
|
||||
'system' => 'required',
|
||||
'structure' => 'required',
|
||||
]);
|
||||
|
||||
if($request->input('firstquan') < 1.00) {
|
||||
$firstQuan = $request->input('firstquan') * 100.00;
|
||||
} else {
|
||||
$firstQuan = $request->input('firstquan');
|
||||
}
|
||||
|
||||
if($request->input('secondquan') < 1.00) {
|
||||
$firstQuan = $request->input('secondquan') * 100.00;
|
||||
} else {
|
||||
$firstQuan = $request->input('secondquan');
|
||||
}
|
||||
|
||||
if($request->input('thirdquan') < 1.00) {
|
||||
$firstQuan = $request->input('thirdquan') * 100.00;
|
||||
} else {
|
||||
$firstQuan = $request->input('thirdquan');
|
||||
}
|
||||
|
||||
if($request->input('fourthquan') < 1.00) {
|
||||
$firstQuan = $request->input('fourthquan') * 100.00;
|
||||
} else {
|
||||
$firstQuan = $request->input('fourthquan');
|
||||
}
|
||||
|
||||
// Add new moon
|
||||
$moon = new Moon;
|
||||
$moon->Region = $request->input('region');
|
||||
$moon->System = $request->input('system');
|
||||
$moon->Planet = $request->input('planet');
|
||||
$moon->Moon = $request->input('moon');
|
||||
$moon->StructureName = $request->input('structure');
|
||||
$moon->FirstOre = $request->input('firstore');
|
||||
$moon->FirstQuantity = $request->input('firstquan');
|
||||
$moon->SecondOre = $request->input('secondore');
|
||||
$moon->SecondQuantity = $request->input('secondquan');
|
||||
$moon->ThirdOre = $request->input('thirdore');
|
||||
$moon->ThirdQuantity = $request->input('thirdquan');
|
||||
$moon->FourthOre = $request->input('fourthore');
|
||||
$moon->FourthQuantity = $request->input('fourthquan');
|
||||
$moon->save();
|
||||
|
||||
return redirect('/dashboard')->with('success', 'Moon Added');
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Moons;
|
||||
|
||||
//Internal Library
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\Config;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Moon\Moon;
|
||||
use App\Models\Moon\OrePrice;
|
||||
use App\Models\Moon\Price;
|
||||
use App\Models\MoonRent\MoonRental;
|
||||
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
class MoonsController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Renter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the moons and pass data to the blade template
|
||||
*/
|
||||
public function displayMoons() {
|
||||
$rentalEnd = '';
|
||||
|
||||
//Get the user type from the user Auth class
|
||||
$type = Auth::user()->user_type;
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
//Update the prices for the moon
|
||||
$moonCalc->FetchNewPrices();
|
||||
//get all of the moons from the database
|
||||
$moons = DB::table('Moons')->orderBy('System', 'asc')->get();
|
||||
//declare the html variable and set it to null
|
||||
|
||||
$table = array();
|
||||
$moonprice = null;
|
||||
foreach($moons as $moon) {
|
||||
//get the rental data for the moon
|
||||
$rental = MoonRental::where([
|
||||
'System' => $moon->System,
|
||||
'Planet' => $moon->Planet,
|
||||
'Moon' => $moon->Moon,
|
||||
])->first();
|
||||
|
||||
if($rental == false) {
|
||||
//If we don't find a rental record, set the rental date as last month
|
||||
$rentalTemp = Carbon::now()->subMonth();
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
} else {
|
||||
//Set the rental date up
|
||||
$rentalTemp = new Carbon($rental->RentalEnd);
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
}
|
||||
|
||||
//mark today's date in carbon format
|
||||
$today = Carbon::now();
|
||||
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
$worth = $moonCalc->SpatialMoonsTotalWorth($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
if($type == 'W4RP') {
|
||||
$moonprice = $price['alliance'];
|
||||
} else {
|
||||
$moonprice = $price['outofalliance'];
|
||||
}
|
||||
|
||||
if($rentalTemp->diffInDays($today) < 3 ) {
|
||||
$color = 'table-warning';
|
||||
} else if( $today > $rentalTemp) {
|
||||
$color = 'table-primary';
|
||||
} else {
|
||||
$color = 'table-danger';
|
||||
}
|
||||
|
||||
//Add the data to the html string to be passed to the view
|
||||
array_push($table, [
|
||||
'SPM' => $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon,
|
||||
'StructureName' => $moon->StructureName,
|
||||
'FirstOre' => $moon->FirstOre,
|
||||
'FirstQuantity' => $moon->FirstQuantity,
|
||||
'SecondOre' => $moon->SecondOre,
|
||||
'SecondQuantity' => $moon->SecondQuantity,
|
||||
'ThirdOre' => $moon->ThirdOre,
|
||||
'ThirdQuantity' => $moon->ThirdQuantity,
|
||||
'FourthOre' => $moon->FourthOre,
|
||||
'FourthQuantity' => $moon->FourthQuantity,
|
||||
'Price' => $moonprice,
|
||||
'Worth' => number_format($worth, "2", ".", ","),
|
||||
'RentalEnd' => $rentalEnd,
|
||||
'RowColor' => $color,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('moons.user.moon')->with('table', $table);
|
||||
}
|
||||
|
||||
public function displayTotalWorthForm() {
|
||||
return view('moons.user.formTotalWorth');
|
||||
}
|
||||
|
||||
public function displayTotalWorth(Request $request) {
|
||||
$firstOre = $request->firstOre;
|
||||
$firstQuantity = $request->firstQuantity;
|
||||
$secondOre = $request->secondOre;
|
||||
$secondQuantity = $request->secondQuantity;
|
||||
$thirdOre = $request->thirdOre;
|
||||
$thirdQuantity = $request->thirdQuantity;
|
||||
$fourthOre = $request->fourthOre;
|
||||
$fourthQuantity = $request->fourthQuantity;
|
||||
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
//Update the prices for the moon
|
||||
$moonCalc->FetchNewPrices();
|
||||
|
||||
$totalGoo = $moonCalc->SpatialMoonsOnlyGooTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
||||
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
|
||||
$totalGoo = number_format($totalGoo, 2, ".", ",");
|
||||
|
||||
$totalWorth = $moonCalc->SpatialMoonsTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
||||
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
|
||||
$totalWorth = number_format($totalWorth, 2, ".", ",");
|
||||
|
||||
return view('moons.user.displayTotalWorth')->with(['totalWorth' => $totalWorth, 'totalGoo' => $totalGoo]);
|
||||
}
|
||||
}
|
||||
531
app/Http/Controllers/SRP/SRPAdminController.php
Normal file
531
app/Http/Controllers/SRP/SRPAdminController.php
Normal file
@@ -0,0 +1,531 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SRP;
|
||||
|
||||
//Laravel Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//User Libraries
|
||||
use App\Library\Helpers\SRPHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\SRP\SRPShip;
|
||||
use App\Models\User\User;
|
||||
use App\Models\SRP\SrpFleetType;
|
||||
use App\Models\SRP\SrpShipType;
|
||||
use App\Models\SRP\SrpPayout;
|
||||
|
||||
class SRPAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:srp.admin');
|
||||
}
|
||||
|
||||
public function displaySRPRequests() {
|
||||
//Middleware needed for permissions
|
||||
$this->middleware('permission:srp.admin');
|
||||
|
||||
//Create the array
|
||||
$requests = array();
|
||||
$viewShipTypes = array();
|
||||
|
||||
//Declare variables for use later.
|
||||
$sum_actual = 0.00;
|
||||
$sum_loss = 0.00;
|
||||
|
||||
//Get the ship types from the database
|
||||
$shipTypes = SrpShipType::all();
|
||||
|
||||
//Setup the viewShipTypes variable
|
||||
$tempShipTypes = SrpShipType::groupBy('code')->pluck('code');
|
||||
foreach($tempShipTypes as $key => $value) {
|
||||
$viewShipTypes[$value] = $value;
|
||||
}
|
||||
|
||||
//Get the fleet types from the database
|
||||
$fleetTypes = SrpFleetType::all();
|
||||
|
||||
//Get the payouts from the database
|
||||
$payouts = SrpPayout::all();
|
||||
|
||||
//Get the SRP ship count to see how many requests are avaiable "Under Review" in the database
|
||||
$count = SRPShip::where(['approved' => 'Under Review'])->count();
|
||||
//If the count is 0 then there are no requests
|
||||
if($count === 0) {
|
||||
$requests = null;
|
||||
} else { //Process each request
|
||||
$reqs = SRPShip::where(['approved' => 'Under Review'])->get()->toArray();
|
||||
foreach($reqs as $r) {
|
||||
$temp['id'] = $r['id'];
|
||||
$temp['created_at'] = $r['created_at'];
|
||||
$temp['character_name'] = $r['character_name'];
|
||||
$temp['fleet_commander_name'] = $r['fleet_commander_name'];
|
||||
$temp['zkillboard'] = $r['zkillboard'];
|
||||
$temp['loss_value'] = $r['loss_value'];
|
||||
$sum_loss += $temp['loss_value'];
|
||||
//Get the ship type
|
||||
foreach($shipTypes as $s) {
|
||||
if($r['ship_type'] == $s->code) {
|
||||
$temp['ship_type'] = $s->description;
|
||||
$temp['cost_code'] = $s->code;
|
||||
}
|
||||
}
|
||||
//Get the fleet type
|
||||
foreach($fleetTypes as $f) {
|
||||
if($r['fleet_type'] == $f->code) {
|
||||
$temp['fleet_type'] = $f->description;
|
||||
}
|
||||
}
|
||||
//Calculate the recommended srp amount
|
||||
foreach($payouts as $p) {
|
||||
if($r['ship_type'] == $p->code) {
|
||||
$payout = $p->payout;
|
||||
if($temp['character_name'] == $temp['fleet_commander_name']) {
|
||||
$payout = 100.00;
|
||||
}
|
||||
|
||||
$temp['actual_srp'] = $r['loss_value'] * ($payout / 100.00 );
|
||||
$temp['payout_percentage'] = $payout;
|
||||
$sum_actual += $temp['actual_srp'];
|
||||
}
|
||||
}
|
||||
|
||||
//Push the calculations into the array
|
||||
array_push($requests, $temp);
|
||||
}
|
||||
}
|
||||
|
||||
$sum_actual = number_format($sum_actual, 2, '.', ',');
|
||||
$sum_loss = number_format($sum_loss, 2, '.', ',');
|
||||
|
||||
//Return the view with the variables
|
||||
return view('srp.admin.process')->with('requests', $requests)
|
||||
->with('sum_actual', $sum_actual)
|
||||
->with('sum_loss', $sum_loss)
|
||||
->with('viewShipTypes', $viewShipTypes);
|
||||
}
|
||||
|
||||
public function updateLossValue($id, $value) {
|
||||
//Convert the string into a decimal style number to be stored correctly
|
||||
$lossValue = str_replace(',', '', $value);
|
||||
$lossValue = floatval($lossValue);
|
||||
|
||||
SRPShip::where(['id' => $id])->update([
|
||||
'loss_value' => $lossValue,
|
||||
]);
|
||||
|
||||
return redirect('/srp/admin/display');
|
||||
}
|
||||
|
||||
public function updateShipType($id, $value) {
|
||||
SRPShip::where(['id' => $id])->update([
|
||||
'ship_type' => $value,
|
||||
]);
|
||||
|
||||
return redirect('/srp/admin/display');
|
||||
}
|
||||
|
||||
public function processSRPRequest(Request $request) {
|
||||
//Validate the request
|
||||
$this->validate($request, [
|
||||
'id' => 'required',
|
||||
'approved' => 'required',
|
||||
'paid_value' => 'required',
|
||||
]);
|
||||
|
||||
//Get the total loss value from the form and convert it to the right format
|
||||
$paidLoss = str_replace(',', '', $request->paid_value);
|
||||
$paidLoss = floatval($paidLoss);
|
||||
|
||||
//If the notes are not null update like this.
|
||||
if($request->notes != null) {
|
||||
$srp = SRPShip::where(['id' => $request->id])->update([
|
||||
'approved' => $request->approved,
|
||||
'paid_by_id' => auth()->user()->character_id,
|
||||
'paid_by_name' => auth()->user()->name,
|
||||
'notes' => $request->notes,
|
||||
'paid_value' => $paidLoss,
|
||||
]);
|
||||
} else {
|
||||
$srp = SRPShip::where(['id' => $request->id])->update([
|
||||
'approved' => $request->approved,
|
||||
'paid_by_id' => auth()->user()->character_id,
|
||||
'paid_by_name' => auth()->user()->name,
|
||||
'paid_value' => $paidLoss,
|
||||
]);
|
||||
}
|
||||
|
||||
if($request->approved == 'Approved') {
|
||||
return redirect('/srp/admin/display')->with('success', 'SRP Marked as Paid');
|
||||
} else {
|
||||
return redirect('/srp/admin/display')->with('error', 'SRP Request Denied.');
|
||||
}
|
||||
}
|
||||
|
||||
public function displayHistory() {
|
||||
|
||||
$srpApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
])->orderBy('created_at', 'desc')->paginate(25);
|
||||
|
||||
$srpDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
])->orderBy('created_at', 'desc')->paginate(25);
|
||||
|
||||
return view('srp.admin.history')->with('srpApproved', $srpApproved)
|
||||
->with('srpDenied', $srpDenied);
|
||||
}
|
||||
|
||||
public function displayStatistics() {
|
||||
$months = 3;
|
||||
$barChartData = array();
|
||||
$start = Carbon::now()->toDateTimeString();
|
||||
$end = Carbon::now()->subMonths(1)->toDateTimeString();
|
||||
|
||||
//Declare the Lavacharts variable
|
||||
$lava = new Lavacharts;
|
||||
|
||||
//We need a function from this library rather than recreating a new library
|
||||
$srpHelper = new SRPHelper();
|
||||
|
||||
/**
|
||||
* Pie chart for the number of approved, denied, and under review payouts currently in the system.
|
||||
*/
|
||||
//Get the count of open srp requests
|
||||
$pieOpen = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
['created_at', '>=', $end],
|
||||
])->count();
|
||||
//Get the count of approved srp requests
|
||||
$pieApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
['created_at', '>=', $end],
|
||||
])->count();
|
||||
//Get the count of denied srp requests
|
||||
$pieDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
['created_at', '>=', $end],
|
||||
])->count();
|
||||
|
||||
//Create a new datatable for the lavachart.
|
||||
$srp = $lava->DataTable();
|
||||
//Add string columns, number columns, and data rows for the chart
|
||||
$srp->addStringColumn('ISK Value')
|
||||
->addNumberColumn('ISK')
|
||||
->addRow(['Approved', $pieApproved])
|
||||
->addRow(['Denied', $pieDenied])
|
||||
->addRow(['Under Review', $pieOpen]);
|
||||
//Create the pie chart in memory with any options needed to render the chart
|
||||
$lava->PieChart('SRP Stats', $srp, [
|
||||
'title' => 'SRP Stats',
|
||||
'is3D' => true,
|
||||
]);
|
||||
|
||||
/**
|
||||
* Gauage chart for showing number of open srp requests
|
||||
*/
|
||||
//Create a new datatable in the
|
||||
$adur = $lava->DataTable();
|
||||
//Add string columns, number columns, and data row for the chart
|
||||
$adur->addStringColumn('Type')
|
||||
->addNumberColumn('Value')
|
||||
->addRow(['Under Review', $pieOpen]);
|
||||
//Create the gauge chart with any options needed to render the chart
|
||||
$lava->GaugeChart('SRP', $adur, [
|
||||
'width' => 400,
|
||||
'greenFrom' => 0,
|
||||
'greenTo' => 20,
|
||||
'yellowFrom' => 20,
|
||||
'yellowTo' => 40,
|
||||
'redFrom' => 40,
|
||||
'redTo' => 100,
|
||||
'majorTicks' => [
|
||||
'Safe',
|
||||
'Critical',
|
||||
],
|
||||
]);
|
||||
|
||||
/**
|
||||
* Create a vertical chart of all of the cost codes for the ships being SRP'ed.
|
||||
* The chart will be by cost code of ships being replaced
|
||||
*/
|
||||
//Declare the data table
|
||||
$costCodeChart = $lava->DataTable();
|
||||
|
||||
//Get the approved, under review, and denied cost codes and amounts
|
||||
$t1fdcApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1FDC',
|
||||
])->sum('paid_value');
|
||||
$t1fdcUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1FDC',
|
||||
])->sum('loss_value');
|
||||
$t1fdcDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1FDC',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t1bcApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1BC',
|
||||
])->sum('paid_value');
|
||||
$t1bcUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1BC',
|
||||
])->sum('loss_value');
|
||||
$t1bcDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1BC',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t2fdApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T2FD',
|
||||
])->sum('paid_value');
|
||||
$t2fdUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T2FD',
|
||||
])->sum('loss_value');
|
||||
$t2fdDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T2FD',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t3dApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T3D',
|
||||
])->sum('paid_value');
|
||||
$t3dUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T3D',
|
||||
])->sum('loss_value');
|
||||
$t3dDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T3D',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t1t2logiApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1T2Logi',
|
||||
])->sum('paid_value');
|
||||
$t1t2logiUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1T2Logi',
|
||||
])->sum('loss_value');
|
||||
$t1t2logiDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1T2Logi',
|
||||
])->sum('loss_value');
|
||||
|
||||
$reconsApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'REC',
|
||||
])->sum('paid_value');
|
||||
$reconsUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'REC',
|
||||
])->sum('loss_value');
|
||||
$reconsDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'REC',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t2cApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T2C',
|
||||
])->sum('paid_value');
|
||||
$t2cUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T2C',
|
||||
])->sum('loss_value');
|
||||
$t2cDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T2C',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t3cApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T3C',
|
||||
])->sum('paid_value');
|
||||
$t3cUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T3C',
|
||||
])->sum('loss_value');
|
||||
$t3cDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T3C',
|
||||
])->sum('loss_value');
|
||||
|
||||
$commandApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'COM',
|
||||
])->sum('paid_value');
|
||||
$commandUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'COM',
|
||||
])->sum('loss_value');
|
||||
$commandDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'COM',
|
||||
])->sum('loss_value');
|
||||
|
||||
$interdictorApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'INTD',
|
||||
])->sum('paid_value');
|
||||
$interdictorUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'INTD',
|
||||
])->sum('loss_value');
|
||||
$interdictorDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'INTD',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t1bsApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1BS',
|
||||
])->sum('paid_value');
|
||||
$t1bsUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1BS',
|
||||
])->sum('loss_value');
|
||||
$t1bsDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1BS',
|
||||
])->sum('loss_value');
|
||||
|
||||
$dksApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'DKS',
|
||||
])->sum('paid_value');
|
||||
$dksUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'DKS',
|
||||
])->sum('loss_value');
|
||||
$dksDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'DKS',
|
||||
])->sum('loss_value');
|
||||
|
||||
|
||||
//Add string column, number columns.
|
||||
$costCodeChart->addStringColumn('SRP Costs')
|
||||
->addNumberColumn('Approved')
|
||||
->addNumberColumn('Under Review')
|
||||
->addNumberColumn('Denied')
|
||||
->addRow(['T1FDC', $t1fdcApproved, $t1fdcUnderReview, $t1fdcDenied])
|
||||
->addRow(['T1BC', $t1bcApproved, $t1bcUnderReview, $t1bcDenied])
|
||||
->addRow(['T1BS', $t1bsApproved, $t1bsUnderReview, $t1bsDenied])
|
||||
->addRow(['T2FD', $t2fdApproved, $t2fdUnderReview, $t2fdDenied])
|
||||
->addRow(['T2C', $t2cApproved, $t2cUnderReview, $t2cDenied])
|
||||
->addRow(['T1T2Logi', $t1t2logiApproved, $t1t2logiUnderReview, $t1t2logiDenied])
|
||||
->addRow(['T3D', $t3dApproved, $t3dUnderReview, $t3dDenied])
|
||||
->addRow(['T3C', $t3cApproved, $t3cUnderReview, $t3cDenied])
|
||||
->addRow(['RECON', $reconsApproved, $reconsUnderReview, $reconsDenied])
|
||||
->addRow(['COMMAND', $commandApproved, $commandUnderReview, $commandDenied])
|
||||
->addRow(['DKS', $dksApproved, $dksUnderReview, $dksDenied]);
|
||||
|
||||
$lava->ColumnChart('Cost Codes', $costCodeChart, [
|
||||
'columns' => 4,
|
||||
'title' => 'Cost Code SRP Chart',
|
||||
'titleTextStyle' => [
|
||||
'color' => '#eb6b2c',
|
||||
'fontSize' => 14,
|
||||
],
|
||||
]);
|
||||
|
||||
return view('srp.admin.statistics')->with('lava', $lava);
|
||||
}
|
||||
|
||||
public function displayCostCodes() {
|
||||
//Declare some variables
|
||||
$costcodes = array();
|
||||
$count = 0;
|
||||
$shipType = SrpShipType::all();
|
||||
$srpPayout = SrpPayout::all();
|
||||
|
||||
foreach($shipType as $ship) {
|
||||
//Don't process if the code is None
|
||||
if($ship->code != 'None') {
|
||||
$tempCode = $ship->code;
|
||||
$tempDescription = $ship->description;
|
||||
$temp = SrpPayout::where(['code' => $ship->code])->first();
|
||||
$tempPayout = $temp->payout;
|
||||
//Store the data in a temporary variable
|
||||
$block = [
|
||||
'code' => $tempCode,
|
||||
'description' => $tempDescription,
|
||||
'payout' => $tempPayout,
|
||||
];
|
||||
|
||||
//Push the data into the array
|
||||
array_push($costcodes, $block);
|
||||
}
|
||||
}
|
||||
|
||||
return view('srp.admin.costcodes.display')->with('costcodes', $costcodes);
|
||||
}
|
||||
|
||||
public function displayAddCostCode() {
|
||||
return view('srp.admin.costcodes.add');
|
||||
}
|
||||
|
||||
public function addCostCode(Request $request) {
|
||||
$this->validate($request, [
|
||||
'code' => 'required',
|
||||
'description' => 'required',
|
||||
'payout' => 'required',
|
||||
]);
|
||||
|
||||
$code = $request->code;
|
||||
$description = $request->description;
|
||||
$payout = $request->payout;
|
||||
|
||||
$payoutCount = SrpPayout::where(['code' => $code])->count();
|
||||
$shipTypeCount = SrpShipType::where(['code' => $code])->count();
|
||||
|
||||
//If we don't find the cost code, let's add it. otherwise send an error.
|
||||
if($payoutCount == 0 && $shipTypeCount == 0) {
|
||||
$payoutTable = new SrpPayout;
|
||||
$payoutTable->code = $code;
|
||||
$payoutTable->payout = $payout;
|
||||
$payoutTable->save();
|
||||
|
||||
$shipType = new SrpShipType;
|
||||
$shipType->code = $code;
|
||||
$shipType->description = $description;
|
||||
$shipType->save();
|
||||
|
||||
return redirect('/srp/admin/display')->with('success', 'Cost code added.');
|
||||
} else {
|
||||
return redirect('/srp/admin/display')->with('error', 'Cost code already exists in the database.');
|
||||
}
|
||||
}
|
||||
|
||||
public function modifyCostCodes(Request $request) {
|
||||
$this->validate($request, [
|
||||
'description' => 'required',
|
||||
'payout' => 'required',
|
||||
]);
|
||||
|
||||
//Update the SrpShipType
|
||||
SrpShipType::where(['code' => $request->code])->update([
|
||||
'description' => $request->description,
|
||||
]);
|
||||
|
||||
//Update the payout
|
||||
SrpPayout::where(['code' => $request->code])->update([
|
||||
'payout' => $request->payout,
|
||||
]);
|
||||
|
||||
return redirect('/srp/admin/display')->with('success', 'Payout and Description updated.');
|
||||
}
|
||||
}
|
||||
157
app/Http/Controllers/SRP/SRPController.php
Normal file
157
app/Http/Controllers/SRP/SRPController.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SRP;
|
||||
|
||||
//Laravel Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
|
||||
//Application Libraries
|
||||
use App\Library\Helpers\SRPHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\SRP\SRPShip;
|
||||
use App\Models\User\User;
|
||||
use App\Models\SRP\SrpFleetType;
|
||||
use App\Models\SRP\SrpShipType;
|
||||
use App\Models\User\UserAlt;
|
||||
use App\Models\SRP\SrpPayout;
|
||||
|
||||
class SRPController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function displaySrpHistory() {
|
||||
|
||||
}
|
||||
|
||||
public function displayPayoutAmounts() {
|
||||
$payouts = array();
|
||||
$count = 0;
|
||||
$shipType = SrpShipType::all();
|
||||
$srpPayout = SrpPayout::all();
|
||||
|
||||
foreach($shipType as $ship) {
|
||||
//Don't process if the code is None
|
||||
if($ship->code != 'None') {
|
||||
$tempCode = $ship->code;
|
||||
$tempDescription = $ship->description;
|
||||
$temp = SrpPayout::where(['code' => $ship->code])->first();
|
||||
|
||||
$tempPayout = $temp->payout;
|
||||
|
||||
$block = [
|
||||
'code' => $tempCode,
|
||||
'description' => $tempDescription,
|
||||
'payout' => $tempPayout,
|
||||
];
|
||||
|
||||
array_push($payouts, $block);
|
||||
}
|
||||
}
|
||||
|
||||
return view('srp.payouts')->with('payouts', $payouts);
|
||||
}
|
||||
|
||||
public function displaySrpForm() {
|
||||
$shipTypes = array();
|
||||
$fleetTypes = array();
|
||||
$characters = array();
|
||||
$temp = array();
|
||||
$alts = null;
|
||||
|
||||
//Get all the ship types
|
||||
$shipTypesTemp = SrpShipType::all();
|
||||
|
||||
//Get all of the fleet types
|
||||
$fleetTypesTemp = SrpFleetType::all();
|
||||
|
||||
//Process the ship types and store in the array
|
||||
foreach($shipTypesTemp as $type) {
|
||||
$shipTypes[$type->code] = $type->description;
|
||||
}
|
||||
|
||||
//Process the fleet types and store in the array
|
||||
foreach($fleetTypesTemp as $type) {
|
||||
$fleetTypes[$type->code] = $type->description;
|
||||
}
|
||||
|
||||
//Get the user id and name, and store in the array
|
||||
$characters[auth()->user()->character_id] = auth()->user()->getName();
|
||||
|
||||
//Get the alts and store in the array
|
||||
$altCount = UserAlt::where(['main_id' => auth()->user()->character_id])->count();
|
||||
if($altCount > 0) {
|
||||
$alts = UserAlt::where([
|
||||
'main_id' => auth()->user()->character_id,
|
||||
])->get();
|
||||
|
||||
foreach($alts as $alt) {
|
||||
$characters[$alt->character_id] = $alt->name;
|
||||
}
|
||||
}
|
||||
|
||||
return view('srp.srpform')->with('fleetTypes', $fleetTypes)
|
||||
->with('shipTypes', $shipTypes)
|
||||
->with('characters', $characters);
|
||||
}
|
||||
|
||||
public function storeSRPFile(Request $request) {
|
||||
$name = null;
|
||||
|
||||
$this->validate($request, [
|
||||
'character' => 'required',
|
||||
'FC' => 'required',
|
||||
'FleetType' => 'required',
|
||||
'zKillboard' => 'required',
|
||||
'LossValue' => 'required',
|
||||
'ShipType' => 'required',
|
||||
]);
|
||||
|
||||
//See if the FC Name ties to a user on the services site
|
||||
$fcId = User::where(['name' => $request->FC])->get(['character_id']);
|
||||
|
||||
//Take the loss value and remove ' ISK' from it. Convert the string to a number
|
||||
//May need to work on some locale stuff here but will think about it first.
|
||||
$lossValue = str_replace(' ISK', '', $request->LossValue);
|
||||
$lossValue = str_replace(',', '', $lossValue);
|
||||
$lossValue = floatval($lossValue);
|
||||
|
||||
//Convert the FC name to a regular case of characters
|
||||
$tempFcName = strtolower($request->FC);
|
||||
$tempFcName = ucwords($tempFcName);
|
||||
|
||||
$userCount = User::where(['character_id' => $request->character])->count();
|
||||
$altCount = UserAlt::where(['character_id' => $request->character])->count();
|
||||
|
||||
if($userCount > 0) {
|
||||
$tempUser = User::where(['character_id' => $request->character])->first();
|
||||
$name = $tempUser->name;
|
||||
} else if($altCount > 0) {
|
||||
$tempAlt = UserAlt::where(['character_id' => $request->character])->first();
|
||||
$name = $tempAlt->name;
|
||||
} else {
|
||||
$name = 'None';
|
||||
}
|
||||
|
||||
$ship = new SRPShip;
|
||||
$ship->character_id = $request->character;
|
||||
$ship->character_name = $name;
|
||||
$ship->fleet_commander_name = $tempFcName;
|
||||
if(isset($fcId[0])) {
|
||||
$ship->fleet_commander_id = $fcId[0]->character_id;
|
||||
}
|
||||
$ship->zkillboard = $request->zKillboard;
|
||||
$ship->fleet_type = $request->FleetType;
|
||||
$ship->ship_type = $request->ShipType;
|
||||
$ship->loss_value = $lossValue;
|
||||
$ship->save();
|
||||
|
||||
return redirect('/dashboard')->with('success', 'SRP Form Submitted.');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Structures;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
use DB;
|
||||
|
||||
use App\Models\Corporation\CorpStructure;
|
||||
use App\Models\Corporation\CorpTaxRatio;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
class RegisterStructureController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:structure.operator');
|
||||
}
|
||||
|
||||
public function displayRegisterStructure() {
|
||||
//Check to see if the user has the read corp journal esi scope before allowing to register a structure
|
||||
if(Auth()->user()->hasEsiScope('esi-wallet.read_corporation_wallets.v1')) {
|
||||
return view('structures.register.register');
|
||||
} else {
|
||||
return view('dashboard')->with('error', 'You need to setup your esi scope for read corporation wallets');
|
||||
}
|
||||
}
|
||||
|
||||
public function storeStructure(Request $request) {
|
||||
$this->validate($request, [
|
||||
'system' => 'required',
|
||||
'structure_name' => 'required',
|
||||
'tax' => 'required',
|
||||
'structure_type' => 'required',
|
||||
]);
|
||||
|
||||
$eHelper = new Esi;
|
||||
|
||||
$tax = floatval($request->tax);
|
||||
|
||||
$structure = new CorpStructure();
|
||||
$structure->character_id = Auth::user()->character_id;
|
||||
$structure->corporation_id = $eHelper->FindCorporationId(Auth::user()->character_id);
|
||||
$structure->corporation_name = $eHelper->FindCorporationName(Auth::user()->character_id);
|
||||
$structure->region = $request->region;
|
||||
$structure->system = $request->system;
|
||||
$structure->structure_name = $request->structure_name;
|
||||
$structure->structure_type = $request->structure_type;
|
||||
$structure->save();
|
||||
|
||||
//Return the view and the message of user updated
|
||||
return redirect('/dashboard')->with('success', 'Structure Added to Database');
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Structures;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class StructureAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
public function displayDashboard() {
|
||||
return view('structures.admin.dashboard');
|
||||
}
|
||||
|
||||
public function storeTaxRatio(Request $request) {
|
||||
$this->validate($request, [
|
||||
'corpId',
|
||||
'corporation',
|
||||
'type',
|
||||
'ratio',
|
||||
]);
|
||||
|
||||
$ratio = new CorpTaxRatio;
|
||||
$ratio->corporation_id = $request->corpId;
|
||||
$ratio->corporation_name = $request->corporation;
|
||||
$ratio->structure_type = $request->type;
|
||||
$ratio->ratio = $request->ratio;
|
||||
$ratio->save();
|
||||
|
||||
return redirect('structure.admin.dashboard');
|
||||
}
|
||||
|
||||
public function updateTaxRatio(Request $request) {
|
||||
$this->validate($request, [
|
||||
'corporation',
|
||||
'type',
|
||||
'ratio',
|
||||
]);
|
||||
|
||||
CorpTaxRatio::where([
|
||||
'corporation_name' => $request->corporation,
|
||||
'structure_type' => $request->type,
|
||||
])->update([
|
||||
'ratio' => $request->ratio,
|
||||
]);
|
||||
|
||||
return redirect('/structure/admin/dashboard')->with('success', 'Tax Ratio updated for structure type: ' . $request->type . ' and corporation: ' . $request->corporation);
|
||||
}
|
||||
|
||||
public function displayTaxRatios() {
|
||||
$taxRatios = CorpTaxRation::all();
|
||||
|
||||
return view('structure.admin.taxratios')->with('structures', $structures);
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Structures;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Auth;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Library\Structures\StructureTaxHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
use App\User;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\Corporation\CorpStructure;
|
||||
use App\Models\Finances\StructureIndustryTaxJournal;
|
||||
use App\Models\Esi\EsiToken;
|
||||
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
class StructureController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:structure.operator');
|
||||
}
|
||||
|
||||
public function chooseCorpTaxes() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$corps = CorpStructure::pluck('corporation_name', 'corporation_id');
|
||||
return view('structures.admin.choosecorporation')->with('corps', $corps);
|
||||
}
|
||||
|
||||
public function displayCorpTaxes(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$corpId = $request->corpId;
|
||||
$months = 3;
|
||||
|
||||
//Declare the structure tax helper class
|
||||
$sHelper = new StructureTaxHelper();
|
||||
|
||||
//Get the dates we are working with
|
||||
$dates = $sHelper->GetTimeFrameInMonths($months);
|
||||
|
||||
foreach($dates as $date) {
|
||||
$totalTaxes[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'tax' => number_format($sHelper->GetTaxes($corpId, 'Market', $date['start'], $date['end']), 2, '.', ','),
|
||||
'revenue' => number_format($sHelper->GetRevenue($corpId, 'Market', $date['start'], $date['end']), 2, '.', ',')
|
||||
];
|
||||
}
|
||||
|
||||
//Return the view with the data passed to it
|
||||
return view('structures.admin.choosecorptaxes')->with('totalTaxes', $totalTaxes);
|
||||
}
|
||||
|
||||
public function displayTaxes() {
|
||||
//Declare new Lookup helper
|
||||
$helper = new LookupHelper();
|
||||
|
||||
//Declare the structure tax helper class
|
||||
$sHelper = new StructureTaxHelper();
|
||||
|
||||
$months = 3;
|
||||
$totalTaxes = array();
|
||||
|
||||
//Get the character's corporation from the lookup table or esi
|
||||
$corpId = $helper->LookupCharacter(Auth::user()->character_id);
|
||||
|
||||
|
||||
//Get the dates we are working with
|
||||
$dates = $sHelper->GetTimeFrameInMonths($months);
|
||||
|
||||
//Get the market taxes for this month from the database
|
||||
foreach($dates as $date) {
|
||||
$totalTaxes[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'tax' => number_format($sHelper->GetTaxes($corpId, 'Market', $date['start'], $date['end']), 2, '.', ','),
|
||||
'revenue' => number_format($sHelper->GetRevenue($corpId, 'Market', $date['start'], $date['end']), 2, '.', ',')
|
||||
];
|
||||
}
|
||||
|
||||
return view('structures.user.taxes')->with('totalTaxes', $totalTaxes);
|
||||
}
|
||||
|
||||
public function displayTaxHistory(Request $request) {
|
||||
//Declare new Lookup helper
|
||||
$helper = new LookupHelper();
|
||||
|
||||
//Get the months from the request
|
||||
$months = $request->months;
|
||||
|
||||
//Get the character's corporation from the lookup table or esi
|
||||
$corpId = $helper->LookupCharacter(Auth::user()->character_id);
|
||||
|
||||
//Declare the structure tax helper class
|
||||
$sHelper = new StructureTaxHelper();
|
||||
|
||||
//Get the dates we are working with
|
||||
$dates = $sHelper->GetTimeFrameInMonths($months);
|
||||
|
||||
//Build the array for displaying the data on the view
|
||||
$totalTaxes = array();
|
||||
|
||||
foreach($dates as $date) {
|
||||
$totalTaxes[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'tax' => number_format($sHelper->GetTaxes($corpId, 'Market', $date['start'], $date['end']), 2, '.', ','),
|
||||
'revenue' => number_format($sHelper->GetRevenue($corpId, 'Market', $date['start'], $date['end']), 2, '.', ',')
|
||||
];
|
||||
}
|
||||
|
||||
return view('structures.user.taxhistory')->with(compact('totalTaxes', 'months'));
|
||||
}
|
||||
}
|
||||
366
app/Http/Controllers/Test/TestController.php
Normal file
366
app/Http/Controllers/Test/TestController.php
Normal file
@@ -0,0 +1,366 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Test;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRental\AllianceMoon;
|
||||
use App\Models\MoonRental\AllianceMoonOre;
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
use App\Models\MiningTax\Observer;
|
||||
use App\Models\User\UserAlt;
|
||||
use App\Models\User\User;
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
public function displayCharTest() {
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
$config = config('esi');
|
||||
|
||||
$char = $lookup->GetCharacterInfo($config['primary']);
|
||||
|
||||
return view('test.char.display')->with('char', $char);
|
||||
}
|
||||
|
||||
public function DebugMiningTaxesInvoices() {
|
||||
//Declare variables
|
||||
$mailDelay = 15;
|
||||
$mains = new Collection;
|
||||
$perms = null;
|
||||
$config = config('esi');
|
||||
$bodies = new Collection;
|
||||
|
||||
/**
|
||||
* This section will determine if users are mains or alts of a main.
|
||||
* If they are mains, we keep the key. If they are alts of a main, then we delete
|
||||
* the key from the collection.
|
||||
*/
|
||||
|
||||
//Pluck all the users from the database of ledgers to determine if they are mains or alts.
|
||||
$tempMains = Ledger::where([
|
||||
'invoiced' => 'Yes',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->pluck('character_id');
|
||||
|
||||
//Get the unique character ids from the ledgers in the previous statement
|
||||
$tempMains = $tempMains->unique()->values()->all();
|
||||
|
||||
//Cycle through the array of mains, and remove any characters which are in the User Alt table,
|
||||
//as those characters will be grouped with their correct main later.
|
||||
for($i = 0; $i < sizeof($tempMains); $i++) {
|
||||
if(UserAlt::where(['character_id' => $tempMains[$i]])->count() == 0) {
|
||||
$mains->push($tempMains[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For each of the users, let's determine if there are any ledgers,
|
||||
* then determine if there are any alts and ledgers associated with the alts.
|
||||
*/
|
||||
foreach($mains as $main) {
|
||||
//Declare some variables for each run through the for loop
|
||||
$ledgers = new Collection;
|
||||
|
||||
//Count the ledgers for the main
|
||||
$mainLedgerCount = Ledger::where([
|
||||
'character_id' => $main,
|
||||
'invoiced' => 'Yes',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->count();
|
||||
|
||||
//If there are ledgers for the main, then let's grab them
|
||||
if($mainLedgerCount > 0) {
|
||||
$mainLedgers = Ledger::where([
|
||||
'character_id' => $main,
|
||||
'invoiced' => 'Yes',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->get();
|
||||
|
||||
//Cycle through the entries, and add them to the ledger to send with the invoice
|
||||
foreach($mainLedgers as $row) {
|
||||
$ledgers->push([
|
||||
'character_id' => $row->character_id,
|
||||
'character_name' => $row->character_name,
|
||||
'observer_id' => $row->observer_id,
|
||||
'type_id' => $row->type_id,
|
||||
'ore_name' => $row->ore_name,
|
||||
'quantity' => (int)$row->quantity,
|
||||
'amount' => (float)$row->amount,
|
||||
'last_updated' => $row->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//Get the alt count for the main character
|
||||
$altCount = UserAlt::where(['main_id' => $main])->count();
|
||||
//If more than 0 alts, grab all the alts.
|
||||
if($altCount > 0) {
|
||||
$alts = UserAlt::where([
|
||||
'main_id' => $main,
|
||||
])->get();
|
||||
|
||||
//Cycle through the alts, and get the ledgers, and push onto the stack
|
||||
foreach($alts as $alt) {
|
||||
$altLedgerCount = Ledger::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'invoiced' => 'Yes',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->count();
|
||||
|
||||
if($altLedgerCount > 0) {
|
||||
$altLedgers = Ledger::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'invoiced' => 'Yes',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->get();
|
||||
|
||||
foreach($altLedgers as $row) {
|
||||
$ledgers->push([
|
||||
'character_id' => $row->character_id,
|
||||
'character_name' => $row->character_name,
|
||||
'observer_id' => $row->observer_id,
|
||||
'type_id' => $row->type_id,
|
||||
'ore_name' => $row->ore_name,
|
||||
'quantity' => (int)$row->quantity,
|
||||
'amount' => (float)$row->amount,
|
||||
'last_updated' => $row->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the collected information over to the function to send the actual mail
|
||||
*/
|
||||
if($ledgers->count() > 0) {
|
||||
$body = $this->CreateInvoice($main, $ledgers, $mailDelay);
|
||||
$bodies->push($body);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return view('test.miningtax.invoice')->with('bodies', $bodies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the invoice to the mail out
|
||||
*
|
||||
* @var charId
|
||||
* @var ledgers
|
||||
* @var mailDelay
|
||||
*/
|
||||
private function CreateInvoice($charId, Collection $ledgers, int &$mailDelay) {
|
||||
$ores = array();
|
||||
$characters = array();
|
||||
$characterIds = array();
|
||||
$totalPrice = 0.00;
|
||||
$body = null;
|
||||
$lookup = new LookupHelper;
|
||||
$config = config('esi');
|
||||
|
||||
//Create an invoice id
|
||||
$invoiceId = "M" . uniqid();
|
||||
|
||||
//Collect the total price of all of the ledgers
|
||||
$totalPrice = round((float)$ledgers->sum('amount'), 2);
|
||||
|
||||
//Get the sum of all the ledgers
|
||||
$invoiceAmount = round(((float)$ledgers->sum('amount') * (float)$config['mining_tax']), 2);
|
||||
|
||||
//Get the character name from the lookup table
|
||||
$charName = $lookup->CharacterIdToName($charId);
|
||||
|
||||
//Create the date due and the invoice date
|
||||
$dateDue = Carbon::now()->addDays(7);
|
||||
$invoiceDate = Carbon::now();
|
||||
|
||||
//Set the mining tax from the config file
|
||||
$numberMiningTax = number_format(((float)$config['mining_tax'] * (float)100.00), 2, ".", ",");
|
||||
|
||||
//Create the list of ores to put in the mail
|
||||
$temp = $ledgers->toArray();
|
||||
foreach($temp as $t) {
|
||||
//If the key isn't set, set it to the default of 0
|
||||
if(!isset($ores[$t['type_id']])) {
|
||||
$ores[$t['type_id']] = (int)0;
|
||||
}
|
||||
|
||||
//Add the quantity into the ores array
|
||||
$ores[$t['type_id']] += (int)$t['quantity'];
|
||||
|
||||
//Create a list of character names
|
||||
if(!isset($characters[$t['character_name']])) {
|
||||
$characters[$t['character_name']] = $t['character_name'];
|
||||
}
|
||||
|
||||
//Create a list of character ids
|
||||
if(!isset($characterIds[$t['character_id']])) {
|
||||
$characterIds[$t['character_id']] = $t['character_id'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the mail body to send to the main character
|
||||
*/
|
||||
$body .= "Dear " . $charName . ",<br><br>";
|
||||
$body .= "Mining Taxes are due for the following ores mined from alliance moons: <br>";
|
||||
foreach($ores as $ore => $quantity) {
|
||||
$oreName = $lookup->ItemIdToName($ore);
|
||||
$body .= $oreName . ": " . number_format($quantity, 0, ".", ",") . "<br>";
|
||||
}
|
||||
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
|
||||
$body .= "<br><br>";
|
||||
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces by " . $dateDue . "<br>";
|
||||
$body .= "Set the reason for transfer as " . $invoiceId . "<br>";
|
||||
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
|
||||
$body .= "<br><br>";
|
||||
$body .= "You can also send a contract with the following ores in the contract with the reason set as: " . $invoiceId . "<br>";
|
||||
foreach($ores as $ore => $quantity) {
|
||||
$oreName = $lookup->ItemIdToName($ore);
|
||||
$body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), 0, ".", ",") . "<br>";
|
||||
}
|
||||
$body .= "<br>";
|
||||
$body .= "Characters Processed: <br>";
|
||||
foreach($characters as $character) {
|
||||
$body .= $character . "<br>";
|
||||
}
|
||||
$body .= "<br>";
|
||||
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||
|
||||
//Check if the mail body is greater than 2000 characters. If greater than 2,000 characters, then
|
||||
if(strlen($body) > 2000) {
|
||||
$body = "Dear " . $charName . "<br><br>";
|
||||
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
|
||||
$body .= "<br><br>";
|
||||
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces by " . $dateDue . "<br>";
|
||||
$body .= "Set the reason for transfer as: " . $invoiceId . "<br>";
|
||||
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
|
||||
$body .= "<br>";
|
||||
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the mail delay for the next cycle
|
||||
*/
|
||||
$mailDelay += 20;
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function DebugMiningObservers() {
|
||||
//Declare variables
|
||||
$mailDelay = 15;
|
||||
$config = config('esi');
|
||||
$mains = new Collection;
|
||||
|
||||
/**
|
||||
* This section will determine if users are mains or alts of a main.
|
||||
* If they are mains, we keep the key. If they are alts of a main, then we delete
|
||||
* the key from the collection.
|
||||
*/
|
||||
|
||||
//Pluck all the users from the database of ledgers to determine if they are mains or alts.
|
||||
$tempMains = Ledger::where([
|
||||
'invoiced' => 'Yes',
|
||||
])->where('last_updated', '>', Carbon::now()->subMonths(3))->pluck('character_id');
|
||||
|
||||
//Get the unique character ids from the ledgers in the previous statement
|
||||
$tempMains = $tempMains->unique()->values()->all();
|
||||
|
||||
for($i = 0; $i < sizeof($tempMains); $i++) {
|
||||
if(UserAlt::where(['character_id' => $tempMains[$i]])->count() == 0) {
|
||||
$mains->push($tempMains[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For each of the users, let's determine if there are any ledgers,
|
||||
* then determine if there are any alts and ledgers associated with the alts.
|
||||
*/
|
||||
foreach($mains as $main) {
|
||||
//Declare some variables for each run through the for loop
|
||||
$mainLedgerCount = 0;
|
||||
$ledgers = new Collection;
|
||||
|
||||
//Count the ledgers for the main
|
||||
$mainLedgerCount = Ledger::where([
|
||||
'character_id' => $main,
|
||||
'invoiced' => 'Yes',
|
||||
])->where('last_updated', '>', Carbon::now()->subMonths(3))->count();
|
||||
|
||||
//If there are ledgers for the main, then let's grab them
|
||||
if($mainLedgerCount > 0) {
|
||||
$mainLedgers = Ledger::where([
|
||||
'character_id' => $main,
|
||||
'invoiced' => 'Yes',
|
||||
])->where('last_updated', '>', Carbon::now()->subMonths(3))->get();
|
||||
|
||||
//Cycle through the entries, and add them to the ledger to send with the invoice
|
||||
foreach($mainLedgers as $row) {
|
||||
$ledgers->push([
|
||||
'character_id' => $row->character_id,
|
||||
'character_name' => $row->character_name,
|
||||
'observer_id' => $row->observer_id,
|
||||
'type_id' => $row->type_id,
|
||||
'ore_name' => $row->ore_name,
|
||||
'quantity' => $row->quantity,
|
||||
'amount' => (float)$row->amount,
|
||||
'last_updated' => $row->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//Get the alt count for the main character
|
||||
$altCount = UserAlt::where(['main_id' => $main])->count();
|
||||
//If more than 0 alts, grab all the alts.
|
||||
if($altCount > 0) {
|
||||
$alts = UserAlt::where([
|
||||
'main_id' => $main,
|
||||
])->get();
|
||||
|
||||
//Cycle through the alts, and get the ledgers, and push onto the stack
|
||||
foreach($alts as $alt) {
|
||||
$altLedgerCount = Ledger::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'invoiced' => 'Yes',
|
||||
])->where('last_updated', '>', Carbon::now()->subMonths(3))->count();
|
||||
|
||||
if($altLedgerCount > 0) {
|
||||
$altLedgers = Ledger::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'invoiced' => 'Yes',
|
||||
])->where('last_updated', '>', Carbon::now()->subMonths(3))->get();
|
||||
|
||||
foreach($altLedgers as $row) {
|
||||
$ledgers->push([
|
||||
'character_id' => $row->character_id,
|
||||
'character_name' => $row->character_name,
|
||||
'observer_id' => $row->observer_id,
|
||||
'type_id' => $row->type_id,
|
||||
'ore_name' => $row->ore_name,
|
||||
'quantity' => $row->quantity,
|
||||
'amount' => (float)$row->amount,
|
||||
'last_updated' => $row->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($ledgers->count() > 0) {
|
||||
var_dump($ledgers);
|
||||
var_dump(round(((float)$ledgers->sum('amount') * (float)$config['mining_tax']), 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wiki;
|
||||
|
||||
//Laravel libraries
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use DB;
|
||||
use Auth;
|
||||
|
||||
//User Libraries
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Doku\DokuGroupNames;
|
||||
use App\Models\Doku\DokuMember;
|
||||
use App\Models\Doku\DokuUser;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
|
||||
class WikiController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Renter');
|
||||
}
|
||||
|
||||
public function purgeUsers() {
|
||||
//Declare helper classes
|
||||
$helper = new LookupHelper;
|
||||
|
||||
//Get all the users from the database
|
||||
$users = DokuUser::pluck('name')->all();
|
||||
|
||||
$legacy = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_id')->toArray();
|
||||
$renter = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_id')->toArray();
|
||||
|
||||
//Search the names and verify against the lookup table
|
||||
//to find the corporation and / or alliance they belong to.
|
||||
foreach($users as $user) {
|
||||
$charId = $helper->CharacterNameToId($user);
|
||||
$corpId = $helper->LookupCharacter($charId);
|
||||
$allianceId = $helper->LookupCorporation($corpId);
|
||||
if(in_array($allianceId, $legacy) || in_array($allianceId, $renter) || $allianceId == 99004116) {
|
||||
//Do nothing
|
||||
} else {
|
||||
DokuUser::where(['name' => $user])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
return view('admin.dashboard')->with('success', 'Wiki has been purged.');
|
||||
}
|
||||
|
||||
public function displayRegister() {
|
||||
//make user name syntax like we want it.
|
||||
$name = Auth::user()->name;
|
||||
$name = strtolower($name);
|
||||
$name = str_replace(' ', '_', $name);
|
||||
|
||||
//Check to see if the user is already registered in the database
|
||||
$check = DB::select('SELECT login FROM wiki_user WHERE login = ?', [$name]);
|
||||
if(isset($check[0]) && ($check[0]->login === $name)) {
|
||||
return redirect('/dashboard')->with('error', 'Already registered for the wiki!');
|
||||
}
|
||||
|
||||
return view('wiki.user.register')->with('name', $name);
|
||||
}
|
||||
|
||||
public function storeRegister(Request $request) {
|
||||
$this->validate($request, [
|
||||
'password' => 'required',
|
||||
'password2' => 'required',
|
||||
]);
|
||||
|
||||
$password = '';
|
||||
|
||||
//Check to make sure the password matches
|
||||
if($request->password !== $request->password2) {
|
||||
return view('/dashboard')->with('error');
|
||||
} else {
|
||||
$password = md5($request->password);
|
||||
}
|
||||
|
||||
if(Auth::user()->hasRole('User')) {
|
||||
$role = 1; //User role id from wiki_groupname table
|
||||
} else if(Auth::user()->hasRole('Renter')) {
|
||||
$role = 8; //Renter role id from wiki_groupname table
|
||||
}
|
||||
|
||||
//Load the model
|
||||
$user = new DokuUser;
|
||||
$member = new DokuMember;
|
||||
|
||||
//make user name syntax like we want it.
|
||||
$name = Auth::user()->name;
|
||||
$name = strtolower($name);
|
||||
$name = str_replace(' ', '_', $name);
|
||||
|
||||
//Add the new user to the wiki
|
||||
$user->login = $name;
|
||||
$user->pass = $password;
|
||||
$user->name = Auth::user()->name;
|
||||
$user->save();
|
||||
|
||||
//Get the user from the table to get the uid
|
||||
$uid = DB::select('SELECT id FROM wiki_user WHERE login = ?', [$name]);
|
||||
$member->uid = $uid[0]->id;
|
||||
$member->gid = $role;
|
||||
$member->save();
|
||||
//Return to the dashboard view
|
||||
return redirect('/dashboard')->with('success', 'Registration successful. Your username is: ' . $name);
|
||||
}
|
||||
|
||||
public function displayChangePassword() {
|
||||
$name = Auth::user()->name;
|
||||
$name = strtolower($name);
|
||||
$name = str_replace(' ', '_', $name);
|
||||
$check = DB::select('SELECT login FROM wiki_user WHERE login = ?', [$name]);
|
||||
if(!isset($check[0])) {
|
||||
return redirect('/dashboard')->with('error', 'Login Not Found!');
|
||||
}
|
||||
|
||||
return view('wiki.user.changepassword')->with('name', $name);
|
||||
}
|
||||
|
||||
public function changePassword(Request $request) {
|
||||
$this->validate($request, [
|
||||
'password' => 'required',
|
||||
'password2' => 'required',
|
||||
]);
|
||||
|
||||
//Check for a valid password
|
||||
$password = '';
|
||||
if($request->password !== $request->password2) {
|
||||
return redirect('/wiki/changepassword')->with('error', 'Passwords did not match');
|
||||
} else {
|
||||
$password = md5($request->password);
|
||||
}
|
||||
//Get a model ready for the database
|
||||
$user = new DokuUser;
|
||||
//Find the username for the database through the character name in auth
|
||||
$name = Auth::user()->name;
|
||||
$name = strtolower($name);
|
||||
$name = str_replace(' ', '_', $name);
|
||||
//Update the password for the login name
|
||||
DB::table('wiki_user')
|
||||
->where('login', $name)
|
||||
->update(['pass' => $password]);
|
||||
|
||||
return redirect('/dashboard')->with('success', 'Password changed successfully. Your username is: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the page to add a user to a certain group
|
||||
*/
|
||||
public function displayAddUserToGroup() {
|
||||
return view('wiki.displayaddug');
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the modifications to the user to add to a group to give permissions
|
||||
*
|
||||
* @param uid
|
||||
* @param gid
|
||||
* @param gname
|
||||
*/
|
||||
public function storeAddUserToGroup($uid, $gid, $gname) {
|
||||
|
||||
return redirect('/dashboard')->with('success', 'User added to the group: ' . $gid . ' with name of ' . $gname);
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,6 @@ class Kernel extends HttpKernel
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'callback' => \App\Http\Middleware\Callback::class,
|
||||
'role' => \App\Http\Middleware\RequireRole::class,
|
||||
'permission' => \App\Http\Middleware\RequirePermission::class,
|
||||
];
|
||||
|
||||
@@ -15,7 +15,7 @@ class Authenticate extends Middleware
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if(!$this->auth->check()){
|
||||
return route('/');
|
||||
return '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use Socialite;
|
||||
use DB;
|
||||
use App\User;
|
||||
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
|
||||
class Callback
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use Socialite;
|
||||
use DB;
|
||||
use App\User;
|
||||
use App\Models\User\User;
|
||||
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
@@ -6,6 +6,7 @@ use Closure;
|
||||
use DB;
|
||||
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\UserRole;
|
||||
|
||||
class RequirePermission
|
||||
{
|
||||
@@ -18,9 +19,15 @@ class RequirePermission
|
||||
*/
|
||||
public function handle($request, Closure $next, $permission)
|
||||
{
|
||||
$perms = UserPermission::where(['character_id' => auth()->user()->character_id, 'permission'=> $permission])->get(['permission']);
|
||||
$role = UserRole::where([
|
||||
'character_id' => auth()->user()->character_id,
|
||||
])->get(['role']);
|
||||
|
||||
abort_unless(auth()->check() && isset($perms[0]->permission), 403, "You don't have the correct permission to be in this area.");
|
||||
if($role[0]->role != "Admin") {
|
||||
$perms = UserPermission::where(['character_id' => auth()->user()->character_id, 'permission'=> $permission])->get(['permission']);
|
||||
|
||||
abort_unless(auth()->check() && isset($perms[0]->permission), 403, "You don't have the correct permission to be in this area.");
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Middleware;
|
||||
use Closure;
|
||||
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\User\AvailableUserRole;
|
||||
|
||||
class RequireRole
|
||||
{
|
||||
@@ -17,21 +18,17 @@ class RequireRole
|
||||
*/
|
||||
public function handle($request, Closure $next, $role)
|
||||
{
|
||||
$confirmed = false;
|
||||
$ranking = array();
|
||||
$roles = AvailableUserRole::all();
|
||||
|
||||
$ranking = [
|
||||
'None' => 0,
|
||||
'Guest' => 1,
|
||||
'Renter' => 2,
|
||||
'User' => 3,
|
||||
'Admin' => 4,
|
||||
'SuperUser' => 5,
|
||||
];
|
||||
foreach($roles as $r) {
|
||||
$ranking[$r->role] = $r->rank;
|
||||
}
|
||||
|
||||
$check = UserRole::where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
|
||||
if(!isset($check[0]->role)) {
|
||||
abort(403, "You don't any roles. You don't belong here.");
|
||||
abort(403, "You don't have any roles. You don't belong here.");
|
||||
}
|
||||
|
||||
if($ranking[$check[0]->role] < $ranking[$role]) {
|
||||
|
||||
@@ -12,7 +12,6 @@ class TrimStrings extends Middleware
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
10
app/Http/Requests/Request.php
Normal file
10
app/Http/Requests/Request.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
abstract class Request extends FormRequest
|
||||
{
|
||||
//
|
||||
}
|
||||
176
app/Jobs/Commands/Assets/FetchAllianceAssets.php
Normal file
176
app/Jobs/Commands/Assets/FetchAllianceAssets.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Assets;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
//Models
|
||||
use App\Models\Structure\Asset;
|
||||
|
||||
class FetchAllianceAssets implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('assets');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$config = config('esi');
|
||||
$corpId = 98287666;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||
//Create the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Check the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-assets.read_corporation_assets.v1')) {
|
||||
Log::critical("Scope check failed in FetchAllianceAssets for esi-assets.read_corporation_assets.v1");
|
||||
}
|
||||
|
||||
//Set the current page
|
||||
$currentPage = 1;
|
||||
//Set our default pages
|
||||
$totalPages = 1;
|
||||
|
||||
do {
|
||||
if($esiHelper->TokenExpired($token)) {
|
||||
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||
$esi = $esiHelper->SetupAuthenticationToken($token);
|
||||
}
|
||||
|
||||
//Attempt to get the assets
|
||||
$assets = $esi->page($currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/assets/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
|
||||
//If on the first page, then update the total number of pages
|
||||
if($currentPage == 1) {
|
||||
$totalPages = $assets->pages;
|
||||
}
|
||||
|
||||
//For each asset retrieved, let's process it.
|
||||
foreach($assets as $a) {
|
||||
ProcessAllianceAssets::dispatch($a);
|
||||
}
|
||||
|
||||
//Increment the current page
|
||||
$currentPage++;
|
||||
} while($currentPage <= $totalPages);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The job failed to process
|
||||
* @param Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function failed($exception) {
|
||||
if(!exception instanceof RequestFailedException) {
|
||||
//If not a failure due to ESI, then log it. Otherwise,
|
||||
//deduce why the exception occurred.
|
||||
Log::critical($exception);
|
||||
}
|
||||
|
||||
if ((is_object($exception->getEsiResponse()) && (stristr($exception->getEsiResponse()->error, 'Too many errors') || stristr($exception->getEsiResponse()->error, 'This software has exceeded the error limit for ESI'))) ||
|
||||
(is_string($exception->getEsiResponse()) && (stristr($exception->getEsiResponse(), 'Too many errors') || stristr($exception->getEsiResponse(), 'This software has exceeded the error limit for ESI')))) {
|
||||
|
||||
//We have hit the error rate limiter, wait 120 seconds before releasing the job back into the queue.
|
||||
Log::info('FetchAllianceAssets has hit the error rate limiter. Releasing the job back into the wild in 2 minutes.');
|
||||
$this->release(120);
|
||||
} else {
|
||||
$errorCode = $exception->getEsiResponse()->getErrorCode();
|
||||
|
||||
switch($errorCode) {
|
||||
case 400: //Bad Request
|
||||
Log::critical("Bad request has occurred in FetchAllianceAssets. Job has been discarded");
|
||||
break;
|
||||
case 401: //Unauthorized Request
|
||||
Log::critical("Unauthorized request has occurred in FetchAllianceAssets at " . Carbon::now()->toDateTimeString() . ".\r\nCancelling the job.");
|
||||
$this->delete();
|
||||
break;
|
||||
case 403: //Forbidden
|
||||
Log::critical("FetchAllianceAssets has incurred a forbidden error. Cancelling the job.");
|
||||
$this->delete();
|
||||
break;
|
||||
case 420: //Error Limited
|
||||
Log::warning("Error rate limit occurred in FetchAllianceAssets. Restarting job in 120 seconds.");
|
||||
$this->release(120);
|
||||
break;
|
||||
case 500: //Internal Server Error
|
||||
Log::critical("Internal Server Error for ESI in FetchAllianceAssets. Attempting a restart in 120 seconds.");
|
||||
$this->release(120);
|
||||
break;
|
||||
case 503: //Service Unavailable
|
||||
Log::critical("Service Unavailabe for ESI in FetchAllianceAssets. Releasing the job back to the queue in 30 seconds.");
|
||||
$this->release(30);
|
||||
break;
|
||||
case 504: //Gateway Timeout
|
||||
Log::critical("Gateway timeout in FetchAllianceAssets. Releasing the job back to the queue in 30 seconds.");
|
||||
$this->release(30);
|
||||
break;
|
||||
case 201:
|
||||
//Good response code
|
||||
$this->delete();
|
||||
break;
|
||||
//If no code is given, then log and break out of switch.
|
||||
default:
|
||||
Log::warning("No response code received from esi call in FetchAllianceAssets.\r\n");
|
||||
$this->delete();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tags for jobs
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['FetchAllianceAssets', 'AllianceStructures', 'Assets'];
|
||||
}
|
||||
}
|
||||
109
app/Jobs/Commands/Assets/ProcessAllianceAssets.php
Normal file
109
app/Jobs/Commands/Assets/ProcessAllianceAssets.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Assets;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
|
||||
//Models
|
||||
use App\Models\Structure\Asset;
|
||||
|
||||
class ProcessAllianceAssets implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
//Private variable
|
||||
private $asset;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($a)
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('assets');
|
||||
|
||||
$this->asset = $a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
/**
|
||||
* If the asset is not in the database, then let's save it to the database,
|
||||
* otherwise, we just update the old asset
|
||||
*/
|
||||
$count = Asset::where([
|
||||
'item_id' => $this->asset->item_id,
|
||||
])->count();
|
||||
|
||||
if($count == 0) {
|
||||
$as = new Asset;
|
||||
if(isset($this->asset->is_blueprint_copy)) {
|
||||
$as->is_blueprint_copy = $this->asset->is_blueprint_copy;
|
||||
}
|
||||
$as->is_singleton = $this->asset->is_singleton;
|
||||
$as->item_id = $this->asset->item_id;
|
||||
$as->location_flag = $this->asset->location_flag;
|
||||
$as->location_id = $this->asset->location_id;
|
||||
$as->location_type = $this->asset->location_type;
|
||||
$as->quantity = $this->asset->quantity;
|
||||
$as->type_id = $this->asset->type_id;
|
||||
$as->save();
|
||||
} else {
|
||||
//Update the previously found asset
|
||||
Asset::where([
|
||||
'item_id' => $this->asset->item_id,
|
||||
])->update([
|
||||
'is_singleton' => $this->asset->is_singleton,
|
||||
'location_flag' => $this->asset->location_flag,
|
||||
'location_id' => $this->asset->location_id,
|
||||
'location_type' => $this->asset->location_type,
|
||||
'quantity' => $this->asset->quantity,
|
||||
'type_id' => $this->asset->type_id,
|
||||
]);
|
||||
|
||||
if(isset($this->asset->is_blueprint_copy)) {
|
||||
Asset::where([
|
||||
'item_id' => $this->asset->item_id,
|
||||
])->update([
|
||||
'is_blueprint_copy' => $this->asset->is_blueprint_copy,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tags for jobs
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['FetchAllianceAssets', 'AllianceStructures', 'Assets'];
|
||||
}
|
||||
}
|
||||
59
app/Jobs/Commands/Assets/PurgeAllianceAssets.php
Normal file
59
app/Jobs/Commands/Assets/PurgeAllianceAssets.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Assets;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Assets\FetchAllianceAssets;
|
||||
|
||||
//Models
|
||||
use App\Models\Structure\Asset;
|
||||
|
||||
class PurgeAllianceAssets implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('assets');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Asset::truncate();
|
||||
|
||||
FetchAllianceAssets::dispatch()->delay(Carbon::now()->addSeconds(30));
|
||||
}
|
||||
}
|
||||
205
app/Jobs/Commands/Data/PurgeUsers.php
Normal file
205
app/Jobs/Commands/Data/PurgeUsers.php
Normal file
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Data;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserAlt;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
|
||||
class PurgeUsers implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup the esi variable
|
||||
$esi = $esiHelper->SetupEsiAuthentication();
|
||||
|
||||
//Get all of the users from the database
|
||||
$users = User::all();
|
||||
|
||||
//Get the allowed logins
|
||||
$legacy = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_id')->toArray();
|
||||
$renter = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_id')->toArray();
|
||||
|
||||
//Cycle through all of the users, and either update their role, or delete them.
|
||||
foreach($users as $user) {
|
||||
//Set the fail bit to false for the next user to check
|
||||
$failed = false;
|
||||
|
||||
//Note a screen entry for when doing cli stuff
|
||||
printf("Processing character with id of " . $user->character_id . "\r\n");
|
||||
|
||||
//Get the character information
|
||||
try {
|
||||
$character_info = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $user->character_id,
|
||||
]);
|
||||
|
||||
$corp_info = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $character_info->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get character information in purge user command for user ' . $user->character_id);
|
||||
$failed = true;
|
||||
}
|
||||
|
||||
//If the fail bit is still false, then continue
|
||||
if($failed === false) {
|
||||
//Get the user's role
|
||||
$role = UserRole::where(['character_id' => $user->character_id])->first();
|
||||
|
||||
//We don't want to modify Admin and SuperUsers. Admins and SuperUsers are removed via a different process.
|
||||
if($role->role != 'Admin') {
|
||||
//Check if the user is allowed to login
|
||||
if(isset($corp_info->alliance_id)) {
|
||||
//Warped Intentions is allowed to login
|
||||
if($corp_info->alliance_id == '99004116') {
|
||||
//If the alliance is Warped Intentions, then modify the role if we need to
|
||||
if($role->role != 'User') {
|
||||
//Upate the role of the user
|
||||
UserRole::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'role' => 'User',
|
||||
]);
|
||||
|
||||
//Update the user type
|
||||
User::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'user_type' => 'W4RP',
|
||||
]);
|
||||
}
|
||||
} else if(in_array($corp_info->alliance_id, $legacy)) { //Legacy Users
|
||||
if($role->role != 'User') {
|
||||
//Update the role of the user
|
||||
UserRole::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'role' => 'User',
|
||||
]);
|
||||
|
||||
//Update the user type
|
||||
User::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'user_type' => 'Legacy',
|
||||
]);
|
||||
}
|
||||
} else if(in_array($corp_info->alliance_id, $renter)) { //Renter Users
|
||||
if($role->role != 'Renter') {
|
||||
//Update the role of the user
|
||||
UserRole::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'role' => 'Renter',
|
||||
]);
|
||||
|
||||
//Update the user type
|
||||
User::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'user_type' => 'Renter',
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
//If the user is part of no valid login group, then delete the user.
|
||||
//Delete all of the permissions first
|
||||
UserPermission::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
|
||||
//Delete the user's role
|
||||
UserRole::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
|
||||
//Delete any alts the user might have registered.
|
||||
$altCount = UserAlt::where(['main_id' => $user->character_id])->count();
|
||||
if($altCount > 0) {
|
||||
UserAlt::where([
|
||||
'main_id' => $user->character_id,
|
||||
])->delete();
|
||||
}
|
||||
|
||||
//Delete the user's esi scopes
|
||||
EsiScope::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
|
||||
//Delete the user's esi token
|
||||
EsiToken::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
|
||||
//Delete the user from the user table
|
||||
User::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horzion
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['Data', 'PurgeUsers'];
|
||||
}
|
||||
}
|
||||
64
app/Jobs/Commands/Eve/ItemPricesUpdate.php
Normal file
64
app/Jobs/Commands/Eve/ItemPricesUpdate.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Eve;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
class ItemPricesUpdate implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$moonHelper = new MoonCalc;
|
||||
|
||||
$moonHelper->FetchNewPrices();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horzion
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['Eve', 'ItemPricesUpdate'];
|
||||
}
|
||||
}
|
||||
216
app/Jobs/Commands/Eve/SendEveMail.php
Normal file
216
app/Jobs/Commands/Eve/SendEveMail.php
Normal file
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Eve;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Spatie\RateLimitedMiddleware\RateLimited;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Mail\SentMail;
|
||||
use Seat\Eseye\Containers\EsiResponse;
|
||||
|
||||
class SendEveMail implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
* With new rate limiting, we need a retry basis versus timeout basis
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 1;
|
||||
|
||||
private $sender;
|
||||
private $body;
|
||||
private $recipient;
|
||||
private $recipient_type;
|
||||
private $subject;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($body, $recipient, $recipient_type, $subject, $sender) {
|
||||
//Set the connection
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('mail');
|
||||
|
||||
//Set the middleware for the job
|
||||
$this->middleware = $this->middleware();
|
||||
|
||||
//Private variables
|
||||
$this->body = $body;
|
||||
$this->recipient = $recipient;
|
||||
$this->recipient_type = $recipient_type;
|
||||
$this->subject = $subject;
|
||||
$this->sender = $sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* Utilized by using SendEveMail::dispatch($mail);
|
||||
* The model is passed into the dispatch function, then added to the queue
|
||||
* for processing.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
$errorCode = null;
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Retrieve the token for main character to send mails from
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
//Create the ESI authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Check to see if the token is valid or not
|
||||
if($esiHelper->TokenExpired($refreshToken)) {
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
}
|
||||
|
||||
|
||||
$esi->setBody([
|
||||
'approved_cost' => 10000,
|
||||
'body' => $this->body,
|
||||
'recipients' => [[
|
||||
'recipient_id' => $this->recipient,
|
||||
'recipient_type' => $this->recipient_type,
|
||||
]],
|
||||
'subject' => $this->subject,
|
||||
])->invoke('post', '/characters/{character_id}/mail/', [
|
||||
'character_id'=> $this->sender,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Middleware to only allow 4 jobs to be run per minute
|
||||
* After a failed job, the job is released back into the queue for at least 1 minute x the number of times attempted
|
||||
*
|
||||
*/
|
||||
public function middleware() {
|
||||
|
||||
//Allow 4 jobs per minute, and implement a rate limited backoff on failed jobs
|
||||
$rateLimitedMiddleware = (new RateLimited())
|
||||
->enabled()
|
||||
->key('psemj')
|
||||
->connectionName('default')
|
||||
->allow(4)
|
||||
->everySeconds(60)
|
||||
->releaseAfterOneMinute()
|
||||
->releaseAfterBackoff($this->attempts());
|
||||
|
||||
return [$rateLimitedMiddleware];
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the time at which the job should timeout.
|
||||
*
|
||||
*/
|
||||
public function retryUntil() : \DateTime
|
||||
{
|
||||
return Carbon::now()->addDay();
|
||||
}
|
||||
|
||||
/**
|
||||
* The job failed to process.
|
||||
*
|
||||
* @param Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function failed($exception)
|
||||
{
|
||||
if(!exception instanceof RequestFailedException) {
|
||||
//If not a failure due to ESI, then log it. Otherwise,
|
||||
//deduce why the exception occurred.
|
||||
Log::critical($exception);
|
||||
}
|
||||
|
||||
if ((is_object($exception->getEsiResponse()) && (stristr($exception->getEsiResponse()->error, 'Too many errors') || stristr($exception->getEsiResponse()->error, 'This software has exceeded the error limit for ESI'))) ||
|
||||
(is_string($exception->getEsiResponse()) && (stristr($exception->getEsiResponse(), 'Too many errors') || stristr($exception->getEsiResponse(), 'This software has exceeded the error limit for ESI')))) {
|
||||
|
||||
//We have hit the error rate limiter, wait 120 seconds before releasing the job back into the queue.
|
||||
Log::info('SendEveMail has hit the error rate limiter. Releasing the job back into the wild in 2 minutes.');
|
||||
$this->release(120);
|
||||
} else {
|
||||
$errorCode = $exception->getEsiResponse()->getErrorCode();
|
||||
|
||||
switch($errorCode) {
|
||||
case 400: //Bad Request
|
||||
Log::critical("Bad request has occurred in SendEveMail. Job has been discarded");
|
||||
break;
|
||||
case 401: //Unauthorized Request
|
||||
Log::critical("Unauthorized request has occurred in SendEveMail at " . Carbon::now()->toDateTimeString() . ".\r\nCancelling the job.");
|
||||
break;
|
||||
case 403: //Forbidden
|
||||
Log::critical("SendEveMail has incurred a forbidden error. Cancelling the job.");
|
||||
break;
|
||||
case 420: //Error Limited
|
||||
Log::warning("Error rate limit occurred in SendEveMail. Restarting job in 120 seconds.");
|
||||
$this->release(120);
|
||||
break;
|
||||
case 500: //Internal Server Error
|
||||
Log::critical("Internal Server Error for ESI in SendEveMail. Attempting a restart in 120 seconds.");
|
||||
$this->release(120);
|
||||
break;
|
||||
case 503: //Service Unavailable
|
||||
Log::critical("Service Unavailabe for ESI in SendEveMail. Releasing the job back to the queue in 30 seconds.");
|
||||
$this->release(30);
|
||||
break;
|
||||
case 504: //Gateway Timeout
|
||||
Log::critical("Gateway timeout in SendEveMail. Releasing the job back to the queue in 30 seconds.");
|
||||
$this->release(30);
|
||||
break;
|
||||
case 520: //Internal Error -- Mostly comes when rate limited hit
|
||||
Log::warning("Rate limit hit for SendEveMail. Releasing the job back to the queue in 30 seconds.");
|
||||
$this->release(30);
|
||||
break;
|
||||
case 201: //Good response code
|
||||
$this->SaveSentRecord($this->sender, $this->subject, $this->body, $this->recipient, $this->recipient_type);
|
||||
$this->delete();
|
||||
break;
|
||||
//If no code is given, then log and break out of switch.
|
||||
default:
|
||||
Log::warning("No response code received from esi call in SendEveMail.\r\n");
|
||||
$this->delete();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function tags() {
|
||||
return ['ProcessEveMails'];
|
||||
}
|
||||
|
||||
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
|
||||
$sentmail = new SentMail;
|
||||
$sentmail->sender = $sender;
|
||||
$sentmail->subject = $subject;
|
||||
$sentmail->body = $body;
|
||||
$sentmail->recipient = $recipient;
|
||||
$sentmail->recipient_type = $recipientType;
|
||||
$sentmail->save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Finances;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Helpers\FinanceHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\AllianceWalletJournal;
|
||||
|
||||
class UpdateAllianceWalletJournalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 1800;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('finances');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$fHelper = new FinanceHelper;
|
||||
$config = config('esi');
|
||||
|
||||
$pages = $fHelper->GetAllianceWalletJournalPages(1, $config['primary']);
|
||||
|
||||
//If the number of pages received is zero there is an error in the job.
|
||||
if($pages == 0) {
|
||||
Log::critical('Failed to get the number of pages in the job.');
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
UpdateAllianceWalletJournalPage::dispatch(1, $config['primary'], $i)->onQueue('journal');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horzion
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['UpdateAllianceWalletJournal', 'Finances'];
|
||||
}
|
||||
}
|
||||
226
app/Jobs/Commands/Finances/UpdateAllianceWalletJournalPage.php
Normal file
226
app/Jobs/Commands/Finances/UpdateAllianceWalletJournalPage.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Finances;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
|
||||
//Application Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\AllianceWalletJournal;
|
||||
|
||||
class UpdateAllianceWalletJournalPage implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
private $division;
|
||||
private $charId;
|
||||
private $page;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($division, $charId, $page)
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('finances');
|
||||
|
||||
$this->division = $division;
|
||||
$this->charId = $charId;
|
||||
$this->page = $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables in the handler
|
||||
$lookup = new LookupHelper;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup the esi container.
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Check the scope
|
||||
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-wallet.read_corporation_wallets.v1')) {
|
||||
Log::critical('Scope check failed for esi-wallet.read_corporation_wallets.v1 for character id: ' . $charId);
|
||||
return null;
|
||||
}
|
||||
|
||||
if($esiHelper->TokenExpired($token)) {
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
}
|
||||
|
||||
//Reference the character id to the corporation id
|
||||
$char = $lookup->GetCharacterInfo($this->charId);
|
||||
$corpId = $char->corporation_id;
|
||||
|
||||
/**
|
||||
* Attempt to get the data from the esi api. If it fails, we skip the page, and go onto the next page, unless
|
||||
* the failed page is the first page.
|
||||
*/
|
||||
$journals = $esi->page($this->page)
|
||||
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => $this->division,
|
||||
]);
|
||||
|
||||
//Decode the json data, and return it as an array
|
||||
$wallet = json_decode($journals->raw, true);
|
||||
|
||||
//Foreach journal entry, add the journal entry to the table
|
||||
foreach($wallet as $entry) {
|
||||
//See if we find the entry id in the database already
|
||||
$found = AllianceWalletJournal::where([
|
||||
'id' => $entry['id'],
|
||||
])->count();
|
||||
|
||||
if($found == 0) {
|
||||
$awj = new AllianceWalletJournal;
|
||||
$awj->id = $entry['id'];
|
||||
$awj->corporation_id = $corpId;
|
||||
$awj->division = $this->division;
|
||||
if(isset($entry['amount'])) {
|
||||
$awj->amount = $entry['amount'];
|
||||
}
|
||||
if(isset($entry['balance'])) {
|
||||
$awj->balance = $entry['balance'];
|
||||
}
|
||||
if(isset($entry['context_id'])) {
|
||||
$awj->context_id = $entry['context_id'];
|
||||
}
|
||||
if(isset($entry['date'])) {
|
||||
$awj->date = $esiHelper->DecodeDate($entry['date']);
|
||||
}
|
||||
if(isset($entry['description'])) {
|
||||
$awj->description = $entry['description'];
|
||||
}
|
||||
if(isset($entry['first_party_id'])) {
|
||||
$awj->first_party_id = $entry['first_party_id'];
|
||||
}
|
||||
if(isset($entry['reason'])) {
|
||||
$awj->reason = $entry['reason'];
|
||||
}
|
||||
if(isset($entry['ref_type'])) {
|
||||
$awj->ref_type = $entry['ref_type'];
|
||||
}
|
||||
if(isset($entry['tax'])) {
|
||||
$awj->tax = $entry['tax'];
|
||||
}
|
||||
if(isset($entry['tax_receiver_id'])) {
|
||||
$awj->tax_receiver_id = $entry['tax_receiver_id'];
|
||||
}
|
||||
$awj->save();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Return as completed
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The job failed to process
|
||||
* @param Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function failed($exception) {
|
||||
if(!exception instanceof RequestFailedException) {
|
||||
//If not a failure due to ESI, then log it. Otherwise,
|
||||
//deduce why the exception occurred.
|
||||
Log::critical($exception);
|
||||
}
|
||||
|
||||
if ((is_object($exception->getEsiResponse()) && (stristr($exception->getEsiResponse()->error, 'Too many errors') || stristr($exception->getEsiResponse()->error, 'This software has exceeded the error limit for ESI'))) ||
|
||||
(is_string($exception->getEsiResponse()) && (stristr($exception->getEsiResponse(), 'Too many errors') || stristr($exception->getEsiResponse(), 'This software has exceeded the error limit for ESI')))) {
|
||||
|
||||
//We have hit the error rate limiter, wait 120 seconds before releasing the job back into the queue.
|
||||
Log::info('UpdateAllianceWalletJournalPage has hit the error rate limiter. Releasing the job back into the wild in 2 minutes.');
|
||||
$this->release(120);
|
||||
} else {
|
||||
$errorCode = $exception->getEsiResponse()->getErrorCode();
|
||||
|
||||
switch($errorCode) {
|
||||
case 400: //Bad Request
|
||||
Log::critical("Bad request has occurred in UpdateAllianceWalletJournalPage. Job has been discarded");
|
||||
break;
|
||||
case 401: //Unauthorized Request
|
||||
Log::critical("Unauthorized request has occurred in UpdateAllianceWalletJournalPage at " . Carbon::now()->toDateTimeString() . ".\r\nCancelling the job.");
|
||||
$this->delete();
|
||||
break;
|
||||
case 403: //Forbidden
|
||||
Log::critical("UpdateAllianceWalletJournalPage has incurred a forbidden error. Cancelling the job.");
|
||||
$this->delete();
|
||||
break;
|
||||
case 420: //Error Limited
|
||||
Log::warning("Error rate limit occurred in UpdateAllianceWalletJournalPage. Restarting job in 120 seconds.");
|
||||
$this->release(120);
|
||||
break;
|
||||
case 500: //Internal Server Error
|
||||
Log::critical("Internal Server Error for ESI in UpdateAllianceWalletJournalPage. Attempting a restart in 120 seconds.");
|
||||
$this->release(120);
|
||||
break;
|
||||
case 503: //Service Unavailable
|
||||
Log::critical("Service Unavailabe for ESI in UpdateAllianceWalletJournalPage. Releasing the job back to the queue in 30 seconds.");
|
||||
$this->release(30);
|
||||
break;
|
||||
case 504: //Gateway Timeout
|
||||
Log::critical("Gateway timeout in UpdateAllianceWalletJournalPage. Releasing the job back to the queue in 30 seconds.");
|
||||
$this->release(30);
|
||||
break;
|
||||
case 201:
|
||||
//Good response code
|
||||
$this->delete();
|
||||
break;
|
||||
//If no code is given, then log and break out of switch.
|
||||
default:
|
||||
Log::warning("No response code received from esi call in UpdateAllianceWalletJournalPage.\r\n");
|
||||
$this->delete();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horzion
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['UpdateAllianceWalletJournalPage', 'Finances'];
|
||||
}
|
||||
}
|
||||
66
app/Jobs/Commands/Finances/UpdateItemPrices.php
Normal file
66
app/Jobs/Commands/Finances/UpdateItemPrices.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Finances;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library Functions
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
class UpdateItemPrices implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 1800;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$moonHelper = new MoonCalc;
|
||||
//Fetch new prices from fuzzwork.co.uk for the item pricing schemes
|
||||
$moonHelper->FetchNewPrices();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horzion
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['UpdateItemPrices', 'Finances'];
|
||||
}
|
||||
}
|
||||
200
app/Jobs/Commands/MiningTaxes/FetchMiningTaxesObservers.php
Normal file
200
app/Jobs/Commands/MiningTaxes/FetchMiningTaxesObservers.php
Normal file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Helpers\StructureHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Observer;
|
||||
|
||||
class FetchMiningTaxesObservers implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('miningtaxes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$config = config('esi');
|
||||
$lookup = new LookupHelper;
|
||||
$sHelper = new StructureHelper($config['primary'], $config['corporation']);
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check for the ESI scope needed.
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
||||
Log::critical('Esi scopes were not found for FetchMiningTaxesObserversJob.');
|
||||
print("Esi scopes not found.");
|
||||
return;
|
||||
}
|
||||
//Check for the other ESI scope needed.
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1')) {
|
||||
Log::critical('Esi scope esi-universe.read_structures.v1 was not found for FetchMiningTaxesObserversJob.');
|
||||
print("Esi scopes not found 2");
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the refresh token for the character
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
//Get the esi variable
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Invoke the call to ESI API.
|
||||
$response = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||
'corporation_id' => $config['corporation'],
|
||||
]);
|
||||
|
||||
//Decode the json response, but leave it as objects rather than an array
|
||||
$resp = json_decode($response->raw, false);
|
||||
|
||||
//Run through the mining observers, and add them to the database
|
||||
foreach($resp as $observer) {
|
||||
//See if the observer is found in the database
|
||||
$found = Observer::where([
|
||||
'observer_id' => $observer->observer_id,
|
||||
])->count();
|
||||
|
||||
//Get the observer name from esi
|
||||
$structureInfo = $sHelper->GetStructureInfo($observer->observer_id);
|
||||
|
||||
//If found, then update the structure
|
||||
if($found > 0) {
|
||||
//Update the existing structure in the database
|
||||
Observer::where([
|
||||
'observer_id' => $observer->observer_id,
|
||||
])->update([
|
||||
'observer_id' => $observer->observer_id,
|
||||
'observer_name' => $structureInfo->name,
|
||||
'last_updated' => $observer->last_updated,
|
||||
]);
|
||||
} else {
|
||||
//Add a new observer into the observer table
|
||||
$newObs = new Observer;
|
||||
$newObs->observer_id = $observer->observer_id;
|
||||
$newObs->observer_type = $observer->observer_type;
|
||||
$newObs->observer_name = $structureInfo->name;
|
||||
$newObs->last_updated = $observer->last_updated;
|
||||
$newObs->solar_system_id = $structureInfo->solar_system_id;
|
||||
$newObs->solar_system_name = $lookup->SystemIdToName($structureInfo->solar_system_id);
|
||||
$newObs->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup stale data that hasn't been updated in at least 1 week.
|
||||
*/
|
||||
$date = Carbon::now()->subDays(7);
|
||||
Observer::where('last_updated', '<', $date)->delete();
|
||||
|
||||
//Return 0 saying everything is fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The job failed to process
|
||||
* @param Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function failed($exception) {
|
||||
if(!exception instanceof RequestFailedException) {
|
||||
//If not a failure due to ESI, then log it. Otherwise,
|
||||
//deduce why the exception occurred.
|
||||
Log::critical($exception);
|
||||
}
|
||||
|
||||
if ((is_object($exception->getEsiResponse()) && (stristr($exception->getEsiResponse()->error, 'Too many errors') || stristr($exception->getEsiResponse()->error, 'This software has exceeded the error limit for ESI'))) ||
|
||||
(is_string($exception->getEsiResponse()) && (stristr($exception->getEsiResponse(), 'Too many errors') || stristr($exception->getEsiResponse(), 'This software has exceeded the error limit for ESI')))) {
|
||||
|
||||
//We have hit the error rate limiter, wait 120 seconds before releasing the job back into the queue.
|
||||
Log::info('FetchMiningTaxesObservers has hit the error rate limiter. Releasing the job back into the wild in 2 minutes.');
|
||||
$this->release(120);
|
||||
} else {
|
||||
$errorCode = $exception->getEsiResponse()->getErrorCode();
|
||||
|
||||
switch($errorCode) {
|
||||
case 400: //Bad Request
|
||||
Log::critical("Bad request has occurred in FetchMiningTaxesObservers. Job has been discarded");
|
||||
break;
|
||||
case 401: //Unauthorized Request
|
||||
Log::critical("Unauthorized request has occurred in FetchMiningTaxesObservers at " . Carbon::now()->toDateTimeString() . ".\r\nCancelling the job.");
|
||||
break;
|
||||
case 403: //Forbidden
|
||||
Log::critical("FetchMiningTaxesObservers has incurred a forbidden error. Cancelling the job.");
|
||||
break;
|
||||
case 420: //Error Limited
|
||||
Log::warning("Error rate limit occurred in FetchMiningTaxesObservers. Restarting job in 120 seconds.");
|
||||
$this->release(120);
|
||||
break;
|
||||
case 500: //Internal Server Error
|
||||
Log::critical("Internal Server Error for ESI in FetchMiningTaxesObservers. Attempting a restart in 120 seconds.");
|
||||
$this->release(120);
|
||||
break;
|
||||
case 503: //Service Unavailable
|
||||
Log::critical("Service Unavailabe for ESI in FetchMiningTaxesObservers. Releasing the job back to the queue in 30 seconds.");
|
||||
$this->release(30);
|
||||
break;
|
||||
case 504: //Gateway Timeout
|
||||
Log::critical("Gateway timeout in FetchMiningTaxesObservers. Releasing the job back to the queue in 30 seconds.");
|
||||
$this->release(30);
|
||||
break;
|
||||
case 201: //Good response code
|
||||
$this->delete();
|
||||
break;
|
||||
//If no code is given, then log and break out of switch.
|
||||
default:
|
||||
Log::warning("No response code received from esi call in FetchMiningTaxesObservers.\r\n");
|
||||
$this->delete();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horizon
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['FetchMiningObservers', 'MiningTaxes'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes\Invoices;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\MiningOperation;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
|
||||
class ProcessAllianceMiningOperations implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set job parameters
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('miningtaxes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$count = MiningOperation::where([
|
||||
'processed' => 'No',
|
||||
])->where('operation_date', '<=', Carbon::now())
|
||||
->count();
|
||||
|
||||
if($count > 0) {
|
||||
$operations = MiningOperation::where([
|
||||
'processed' => 'No',
|
||||
])->where('operation_date', '<=', Carbon::now())
|
||||
->get();
|
||||
|
||||
foreach($operations as $operation) {
|
||||
$ledgers = Ledger::where([
|
||||
'observer_id' => $operation->structure_id,
|
||||
'invoiced' => 'No',
|
||||
'last_updated' => $operation->operation_date,
|
||||
])->get();
|
||||
|
||||
foreach($ledgers as $ledger) {
|
||||
Ledger::where([
|
||||
'observer_id' => $operation->structure_id,
|
||||
'invoiced' => 'No',
|
||||
'last_updated' => $operation->operation_date,
|
||||
])->update([
|
||||
'invoiced' => 'Yes',
|
||||
'invoice_id' => 'MiningOp' . $operation->id,
|
||||
]);
|
||||
}
|
||||
|
||||
MiningOperation::where([
|
||||
'id' => $operation->id,
|
||||
])->update([
|
||||
'processed' => 'Yes',
|
||||
'processed_on' => Carbon::now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horzion
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['ProcessAllianceMiningOperations', 'MiningTaxes', 'MiningOperations'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes\Invoices;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
use App\Models\User\UserAlt;
|
||||
use App\Models\User\User;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\SendEveMail;
|
||||
|
||||
class SendMiningTaxesInvoices implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('miningtaxes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$mailDelay = 15;
|
||||
$mains = new Collection;
|
||||
|
||||
/**
|
||||
* This section will determine if users are mains or alts of a main.
|
||||
* If they are mains, we keep the key. If they are alts of a main, then we delete
|
||||
* the key from the collection.
|
||||
*/
|
||||
|
||||
//Pluck all the users from the database of ledgers to determine if they are mains or alts.
|
||||
$tempMains = Ledger::where([
|
||||
'invoiced' => 'No',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->pluck('character_id');
|
||||
|
||||
//Get the unique character ids from the ledgers in the previous statement
|
||||
$tempMains = $tempMains->unique()->values()->all();
|
||||
|
||||
//Cycle through the array of mains, and remove any characters which are in the User Alt table,
|
||||
//as those characters will be grouped with their correct main later.
|
||||
for($i = 0; $i < sizeof($tempMains); $i++) {
|
||||
if(UserAlt::where(['character_id' => $tempMains[$i]])->count() == 0) {
|
||||
$mains->push($tempMains[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For each of the users, let's determine if there are any ledgers,
|
||||
* then determine if there are any alts and ledgers associated with the alts.
|
||||
*/
|
||||
foreach($mains as $main) {
|
||||
//Declare some variables for each run through the for loop
|
||||
$ledgers = new Collection;
|
||||
|
||||
//Count the ledgers for the main
|
||||
$mainLedgerCount = Ledger::where([
|
||||
'character_id' => $main,
|
||||
'invoiced' => 'No',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->count();
|
||||
|
||||
//If there are ledgers for the main, then let's grab them
|
||||
if($mainLedgerCount > 0) {
|
||||
$mainLedgers = Ledger::where([
|
||||
'character_id' => $main,
|
||||
'invoiced' => 'No',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->get();
|
||||
|
||||
//Cycle through the entries, and add them to the ledger to send with the invoice
|
||||
foreach($mainLedgers as $row) {
|
||||
$ledgers->push([
|
||||
'character_id' => $row->character_id,
|
||||
'character_name' => $row->character_name,
|
||||
'observer_id' => $row->observer_id,
|
||||
'type_id' => $row->type_id,
|
||||
'ore_name' => $row->ore_name,
|
||||
'quantity' => (int)$row->quantity,
|
||||
'amount' => (float)$row->amount,
|
||||
'last_updated' => $row->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//Get the alt count for the main character
|
||||
$altCount = UserAlt::where(['main_id' => $main])->count();
|
||||
//If more than 0 alts, grab all the alts.
|
||||
if($altCount > 0) {
|
||||
$alts = UserAlt::where([
|
||||
'main_id' => $main,
|
||||
])->get();
|
||||
|
||||
//Cycle through the alts, and get the ledgers, and push onto the stack
|
||||
foreach($alts as $alt) {
|
||||
$altLedgerCount = Ledger::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'invoiced' => 'No',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->count();
|
||||
|
||||
if($altLedgerCount > 0) {
|
||||
$altLedgers = Ledger::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'invoiced' => 'No',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->get();
|
||||
|
||||
foreach($altLedgers as $row) {
|
||||
$ledgers->push([
|
||||
'character_id' => $row->character_id,
|
||||
'character_name' => $row->character_name,
|
||||
'observer_id' => $row->observer_id,
|
||||
'type_id' => $row->type_id,
|
||||
'ore_name' => $row->ore_name,
|
||||
'quantity' => (int)$row->quantity,
|
||||
'amount' => (float)$row->amount,
|
||||
'last_updated' => $row->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the collected information over to the function to send the actual mail
|
||||
*/
|
||||
if($ledgers->count() > 0) {
|
||||
$this->CreateInvoice($main, $ledgers, $mailDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the invoice to the mail out
|
||||
*
|
||||
* @var charId
|
||||
* @var ledgers
|
||||
* @var mailDelay
|
||||
*/
|
||||
private function CreateInvoice($charId, Collection $ledgers, int &$mailDelay) {
|
||||
$ores = array();
|
||||
$characters = array();
|
||||
$characterIds = array();
|
||||
$totalPrice = 0.00;
|
||||
$body = null;
|
||||
$lookup = new LookupHelper;
|
||||
$config = config('esi');
|
||||
|
||||
//Create an invoice id
|
||||
$invoiceId = "M" . uniqid();
|
||||
|
||||
//Collect the total price of all of the ledgers
|
||||
$totalPrice = round((float)$ledgers->sum('amount'), 2);
|
||||
|
||||
//Get the sum of all the ledgers
|
||||
$invoiceAmount = round(((float)$ledgers->sum('amount') * (float)$config['mining_tax']), 2);
|
||||
|
||||
//Get the character name from the lookup table
|
||||
$charName = $lookup->CharacterIdToName($charId);
|
||||
|
||||
//Create the date due and the invoice date
|
||||
$dateDue = Carbon::now()->addDays(7);
|
||||
$invoiceDate = Carbon::now();
|
||||
|
||||
//Set the mining tax from the config file
|
||||
$numberMiningTax = number_format(((float)$config['mining_tax'] * (float)100.00), 2, ".", ",");
|
||||
|
||||
//Create the list of ores to put in the mail
|
||||
$temp = $ledgers->toArray();
|
||||
foreach($temp as $t) {
|
||||
//If the key isn't set, set it to the default of 0
|
||||
if(!isset($ores[$t['type_id']])) {
|
||||
$ores[$t['type_id']] = (int)0;
|
||||
}
|
||||
|
||||
//Add the quantity into the ores array
|
||||
$ores[$t['type_id']] += (int)$t['quantity'];
|
||||
|
||||
//Create a list of character names
|
||||
if(!isset($characters[$t['character_name']])) {
|
||||
$characters[$t['character_name']] = $t['character_name'];
|
||||
}
|
||||
|
||||
//Create a list of character ids
|
||||
if(!isset($characterIds[$t['character_id']])) {
|
||||
$characterIds[$t['character_id']] = $t['character_id'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the mail body to send to the main character
|
||||
*/
|
||||
$body .= "Dear " . $charName . ",<br><br>";
|
||||
$body .= "Mining Taxes are due for the following ores mined from alliance moons: <br>";
|
||||
foreach($ores as $ore => $quantity) {
|
||||
$oreName = $lookup->ItemIdToName($ore);
|
||||
$body .= $oreName . ": " . number_format($quantity, 0, ".", ",") . "<br>";
|
||||
}
|
||||
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
|
||||
$body .= "<br><br>";
|
||||
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces or contract Spatial Forces the following ores:<br>";
|
||||
foreach($ores as $ore => $quantity) {
|
||||
$oreName = $lookup->ItemIdToName($ore);
|
||||
$body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), 0, ".", ",") . "<br>";
|
||||
}
|
||||
$body .= "<br>";
|
||||
$body .= "The due date is " . $dateDue . "<br>";
|
||||
$body .= "Set the reason for transfer as " . $invoiceId . "<br>";
|
||||
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
|
||||
$body .= "<br>";
|
||||
$body .= "Characters Processed: <br>";
|
||||
foreach($characters as $character) {
|
||||
$body .= $character . "<br>";
|
||||
}
|
||||
$body .= "<br>";
|
||||
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||
|
||||
//Check if the mail body is greater than 2000 characters. If greater than 2,000 characters, then
|
||||
if(strlen($body) > 2000) {
|
||||
$body = "Dear " . $charName . "<br><br>";
|
||||
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
|
||||
$body .= "<br><br>";
|
||||
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces or contract 15% of the ores mined to Spatial Forces.<br>";
|
||||
$body .= "The due date is " . $dateDue . "<br>";
|
||||
$body .= "Set the reason for transfer as: " . $invoiceId . "<br>";
|
||||
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
|
||||
$body .= "<br>";
|
||||
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||
}
|
||||
|
||||
//Mail the invoice to the character if the character is in
|
||||
//Warped Intentions or Legacy
|
||||
$subject = 'Warped Intentions Mining Taxes';
|
||||
$sender = $config['primary'];
|
||||
$recipientType = 'character';
|
||||
$recipient = $charId;
|
||||
|
||||
//Send the Eve Mail Job to the queue to be dispatched
|
||||
SendEveMail::dispatch($body, $recipient, $recipientType, $subject, $sender)->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
|
||||
/**
|
||||
* Create a new invoice model, and save it to the database
|
||||
*/
|
||||
$invoice = new Invoice;
|
||||
$invoice->character_id = $charId;
|
||||
$invoice->character_name = $charName;
|
||||
$invoice->invoice_id = $invoiceId;
|
||||
$invoice->invoice_amount = $invoiceAmount;
|
||||
$invoice->date_issued = $invoiceDate;
|
||||
$invoice->date_due = $dateDue;
|
||||
$invoice->status = 'Pending';
|
||||
$invoice->mail_body = $body;
|
||||
$invoice->save();
|
||||
|
||||
/**
|
||||
* Mark the invoices as paid
|
||||
*/
|
||||
foreach($characterIds as $char) {
|
||||
Ledger::where([
|
||||
'character_id' => $char,
|
||||
'invoiced' => 'No',
|
||||
])->update([
|
||||
'invoice_id' => $invoiceId,
|
||||
'invoiced' => 'Yes',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the mail delay for the next cycle
|
||||
*/
|
||||
$mailDelay += 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horizon
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['MiningTaxes', 'SendMiningTaxesInvoics', 'Invoices'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes\Invoices;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserAlt;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\SendEveMail;
|
||||
|
||||
class UpdateMiningTaxesLateInvoices15th implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('miningtaxes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
$config = config('esi');
|
||||
$mailDelay = 15;
|
||||
$today = Carbon::now();
|
||||
|
||||
//Get all of the invoices that are still pending.
|
||||
$invoices = Invoice::where([
|
||||
'status' => 'Pending',
|
||||
])->get();
|
||||
|
||||
//Cycle through the invoices, and see if they are late or not.
|
||||
foreach($invoices as $invoice) {
|
||||
$dueDate = Carbon::create($invoice->date_due);
|
||||
|
||||
if($dueDate->greaterThan($today->subDays(7))) {
|
||||
//Update the invoice in the database
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Late',
|
||||
]);
|
||||
|
||||
//Build the mail
|
||||
$subject = 'Warped Intentions Mining Taxes - Invoice Late';
|
||||
$sender = $config['primary'];
|
||||
$recipientType = 'character';
|
||||
$recipient = $invoice->character_id;
|
||||
|
||||
$body = "Dear " . $invoice->character_name . ",<br><br>";
|
||||
$body .= "The Mining Invoice: " . $invoice->invoice_id . " is late.<br>";
|
||||
$body .= "Please remite " . number_format($invoice->invoice_amount, 2, ".", ",") . "to Spatial Forces.<br>";
|
||||
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||
|
||||
//Send a reminder to the user through eve mail about the late invoice
|
||||
SendEveMail::dispatch($body, $recipient, $recipientType, $subject, $sender)->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
|
||||
$mailDelay += 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horzion
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['UpdateMiningTaxesLateInvoices', 'MiningTaxes', 'Invoices'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes\Invoices;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserAlt;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\SendEveMail;
|
||||
|
||||
class UpdateMiningTaxesLateInvoices1st implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('miningtaxes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
$config = config('esi');
|
||||
$mailDelay = 15;
|
||||
$today = Carbon::now();
|
||||
|
||||
//Get all of the invoices that are still pending.
|
||||
$invoices = Invoice::where([
|
||||
'status' => 'Pending',
|
||||
])->get();
|
||||
|
||||
//Cycle through the invoices, and see if they are late or not.
|
||||
foreach($invoices as $invoice) {
|
||||
$dueDate = Carbon::create($invoice->date_due);
|
||||
|
||||
if($dueDate->greaterThan($today->subDays(7))) {
|
||||
//Update the invoice in the database
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Late',
|
||||
]);
|
||||
|
||||
//Build the mail
|
||||
$subject = 'Warped Intentions Mining Taxes - Invoice Late';
|
||||
$sender = $config['primary'];
|
||||
$recipientType = 'character';
|
||||
$recipient = $invoice->character_id;
|
||||
|
||||
$body = "Dear " . $invoice->character_name . ",<br><br>";
|
||||
$body .= "The Mining Invoice: " . $invoice->invoice_id . " is late.<br>";
|
||||
$body .= "Please remite " . number_format($invoice->invoice_amount, 2, ".", ",") . "to Spatial Forces.<br>";
|
||||
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||
|
||||
//Send a reminder to the user through eve mail about the late invoice
|
||||
SendEveMail::dispatch($body, $recipient, $recipientType, $subject, $sender)->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
|
||||
$mailDelay += 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horzion
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['UpdateMiningTaxesLateInvoices', 'MiningTaxes', 'Invoices'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes\Ledgers;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\MiningTaxes\Ledgers\ProcessMiningTaxesLedgers;
|
||||
|
||||
//App Models
|
||||
use App\Models\MiningTax\Observer;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
use App\Models\Moon\MineralPrice;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
class FetchMiningTaxesLedgers implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Job Variables
|
||||
*/
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $observerId;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId, $corpId, $observerId)
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('miningtaxes');
|
||||
|
||||
//Import the variables from the calling function
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
$this->observerId = $observerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
$mHelper = new MoonCalc;
|
||||
$esiHelper = new Esi;
|
||||
$pageFailed = false;
|
||||
$config = config('esi');
|
||||
|
||||
//Check for the correct scope
|
||||
if(!$esiHelper->haveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1')) {
|
||||
Log::critical('Character: ' . $this->charId . ' did not have the correct esi scope in FetchMiningTaxesLedgersJob.');
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the esi token in order to pull data from esi
|
||||
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Set the current page
|
||||
$currentPage = 1;
|
||||
$totalPages = 1;
|
||||
|
||||
//Setup a do-while loop to sort through the ledgers by pages
|
||||
do {
|
||||
/**
|
||||
* During the course of the operation, we want to ensure our token stays valid.
|
||||
* If the token, expires, then we want to refresh the token through the esi helper
|
||||
* library functionality.
|
||||
*/
|
||||
if($esiHelper->TokenExpired($refreshToken)) {
|
||||
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get the data from the esi api. If it fails, we skip the page
|
||||
*/
|
||||
try {
|
||||
$response = $esi->page($currentPage)
|
||||
->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||
'corporation_id' => $config['corporation'],
|
||||
'observer_id' => $this->observerId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get the mining ledger in FetchMiningTaxesLedgersCommand for observer id: ' . $this->observerId);
|
||||
$pageFailed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the current page is the first one and the page didn't fail, then update the total pages.
|
||||
* If the first page failed, just return as we aren't going to be able to get the total amount of data needed.
|
||||
*/
|
||||
if($currentPage == 1 && $pageFailed == false) {
|
||||
$totalPages = $response->pages;
|
||||
} else if($currentPage == 1 && $pageFailed == true) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($pageFailed == true) {
|
||||
//If the page failed, then reset the variable, and skip the current iteration
|
||||
//of creating the jobs.
|
||||
$pageFailed = false;
|
||||
} else {
|
||||
//Decode the json response from the ledgers
|
||||
$ledgers = json_decode($response->raw);
|
||||
|
||||
//Dispatch jobs to process each of the mining ledger entries
|
||||
foreach($ledgers as $ledger) {
|
||||
ProcessMiningTaxesLedgers::dispatch($ledger, $this->observerId);
|
||||
}
|
||||
}
|
||||
|
||||
//Increment the current pages
|
||||
$currentPage++;
|
||||
|
||||
} while($currentPage <= $totalPages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horzion
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['FetchMiningTaxesLedgers', 'MiningTaxes', 'MiningTaxesLedgers'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes\Ledgers;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Ledger;
|
||||
use App\Models\Moon\MineralPrice;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
|
||||
class ProcessMiningTaxesLedgers implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Job Variables
|
||||
*/
|
||||
private $ledger;
|
||||
private $observerId;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($ledger, $observerId)
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('miningtaxes');
|
||||
|
||||
//Import variables from the calling function
|
||||
$this->ledger = $ledger;
|
||||
$this->observerId = $observerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$lookup = new LookupHelper;
|
||||
$mHelper = new MoonCalc;
|
||||
$config = config('esi');
|
||||
|
||||
//Create a starting date for the ledger
|
||||
$ledgerDate = Carbon::createFromFormat('Y-m-d', $this->ledger->last_updated);
|
||||
|
||||
//If the ledger is more than one day old, then process it, otherwise, we don't process it
|
||||
//or add it to the database as it may still be updating.
|
||||
if($ledgerDate->lessThan(Carbon::now()->subDay())) {
|
||||
//Get some of the basic information we need to work with
|
||||
$charName = $lookup->CharacterIdToName($this->ledger->character_id);
|
||||
//Get the type name from the ledger ore
|
||||
$typeName = $lookup->ItemIdToName($this->ledger->type_id);
|
||||
//Get the price from the helper function
|
||||
$price = $mHelper->CalculateOrePrice($this->ledger->type_id);
|
||||
//Calculate the total price based on the amount
|
||||
$amount = (($price * $this->ledger->quantity) * $config['refine_rate']);
|
||||
|
||||
$found = Ledger::where([
|
||||
'character_id' => $this->ledger->character_id,
|
||||
'observer_id' => $this->observerId,
|
||||
'type_id' => $this->ledger->type_id,
|
||||
'last_updated' => $this->ledger->last_updated,
|
||||
])->count();
|
||||
|
||||
if($found == 0) {
|
||||
$ledg = new Ledger;
|
||||
$ledg->character_id = $this->ledger->character_id;
|
||||
$ledg->character_name = $charName;
|
||||
$ledg->observer_id = $this->observerId;
|
||||
$ledg->last_updated = $this->ledger->last_updated;
|
||||
$ledg->type_id = $this->ledger->type_id;
|
||||
$ledg->ore_name = $typeName;
|
||||
$ledg->quantity = $this->ledger->quantity;
|
||||
$ledg->amount = $amount;
|
||||
$ledg->save();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horzion
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['ProcessMiningTaxesLedgers', 'MiningTaxes', 'MiningTaxesLedgers'];
|
||||
}
|
||||
}
|
||||
58
app/Jobs/Commands/MiningTaxes/MiningTaxesWeeklyInvoicing.php
Normal file
58
app/Jobs/Commands/MiningTaxes/MiningTaxesWeeklyInvoicing.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
|
||||
use App\Jobs\Commands\MiningTaxes\Invoices\SendMiningTaxesInvoices;
|
||||
use App\Jobs\Commands\MiningTaxes\Invoices\ProcessAllianceMiningOperations;
|
||||
|
||||
class MiningTaxesWeeklyInvoicing implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 1;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set job parameters
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('miningtaxes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Bus::chain([
|
||||
new ProcessAllianceMiningOperations,
|
||||
new SendMiningTaxesInvoices,
|
||||
])->dispatch();
|
||||
}
|
||||
}
|
||||
75
app/Jobs/Commands/MiningTaxes/PreFetchMiningTaxesLedgers.php
Normal file
75
app/Jobs/Commands/MiningTaxes/PreFetchMiningTaxesLedgers.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Observer;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\MiningTaxes\Ledgers\FetchMiningTaxesLedgers;
|
||||
|
||||
class PreFetchMiningTaxesLedgers implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('miningtaxes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Get the site configuration which holds some data we need
|
||||
$config = config('esi');
|
||||
//Get the observers from the database
|
||||
$observers = Observer::all();
|
||||
|
||||
//For each of the observers, send a job to fetch the mining ledger
|
||||
foreach($observers as $obs) {
|
||||
//Dispatch the mining taxes ledger jobs
|
||||
FetchMiningTaxesLedgers::dispatch($config['primary'], $config['corporation'], $obs->observer_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horzion
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['PreFetchMiningTaxesLedgers', 'MiningTaxes', 'MiningTaxesLedgers'];
|
||||
}
|
||||
}
|
||||
143
app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesPayments.php
Normal file
143
app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesPayments.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\MiningTax\Payment;
|
||||
use App\Models\Finances\AllianceWalletJournal;
|
||||
|
||||
class ProcessMiningTaxesPayments implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('miningtaxes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare the variables we will need
|
||||
$looup = new LookupHelper;
|
||||
$currentTime = Carbon::now();
|
||||
|
||||
//Get the outstanding invoices
|
||||
$outstanding = Invoice::where([
|
||||
'status' => 'Pending',
|
||||
])->get();
|
||||
|
||||
//Use the player donation journal from finances to see if the invoice_id is present
|
||||
//as a reason
|
||||
foreach($outstanding as $invoice) {
|
||||
//See if we have a reason with the correct uniqid from the player donation journal
|
||||
$found = AllianceWalletJournal::where([
|
||||
'reason' => $invoice->invoice_id,
|
||||
])->count();
|
||||
|
||||
//If we have received the invoice, then mark the invoice as paid
|
||||
if($found > 0) {
|
||||
//If we have the count, then grab the journal entry in order to do some things with it
|
||||
$journal = AllianceWalletJournal::where([
|
||||
'reason' => $invoice->invoice_id,
|
||||
])->first();
|
||||
|
||||
//If the bill is paid on time, then update the invoice as such
|
||||
if($currentTime->lessThanOrEqualTo($journal->inserted_at)) {
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Paid',
|
||||
]);
|
||||
}
|
||||
|
||||
if($currentTime->greaterThan($journal->inserted_at)) {
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Paid Late',
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$count = AllianceWalletJournal::where([
|
||||
'reason' => $invoice->invoice_id,
|
||||
])->count();
|
||||
|
||||
if($count > 0) {
|
||||
//If we have the count, then grab the journal entry in order to do some things with it
|
||||
$journal = AllianceWalletJournal::where([
|
||||
'reason' => $invoice->invoice_id,
|
||||
])->first();
|
||||
|
||||
//If the bill is paid on time, then update the invoice as such
|
||||
if($currentTime->lessThanOrEqualTo($journal->inserted_at)) {
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Paid',
|
||||
]);
|
||||
}
|
||||
|
||||
if($currentTime->greaterThan($journal->inserted_at)) {
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Paid Late',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Use the contract descriptions from the esi to see if the invoice_id is present.
|
||||
//If the invoice is present, then mark it off as sent in correctly
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horzion
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['ProcessMiningTaxesPayments', 'MiningTaxes', 'Payments'];
|
||||
}
|
||||
}
|
||||
316
app/Jobs/Commands/MiningTaxes/SendMiningTaxesInvoicesOld.php
Normal file
316
app/Jobs/Commands/MiningTaxes/SendMiningTaxesInvoicesOld.php
Normal file
@@ -0,0 +1,316 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
use App\Models\User\UserAlt;
|
||||
use App\Models\User\User;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\SendEveMail;
|
||||
|
||||
class SendMiningTaxesInvoicesOld implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('miningtaxes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$mailDelay = 15;
|
||||
$mains = new Collection;
|
||||
|
||||
/**
|
||||
* This section will determine if users are mains or alts of a main.
|
||||
* If they are mains, we keep the key. If they are alts of a main, then we delete
|
||||
* the key from the collection.
|
||||
*/
|
||||
|
||||
//Pluck all the users from the database of ledgers to determine if they are mains or alts.
|
||||
$tempMains = Ledger::where([
|
||||
'invoiced' => 'No',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->pluck('character_id');
|
||||
|
||||
//Get the unique character ids from the ledgers in the previous statement
|
||||
$tempMains = $tempMains->unique()->values()->all();
|
||||
|
||||
//Cycle through the array of mains, and remove any characters which are in the User Alt table,
|
||||
//as those characters will be grouped with their correct main later.
|
||||
for($i = 0; $i < sizeof($tempMains); $i++) {
|
||||
if(UserAlt::where(['character_id' => $tempMains[$i]])->count() == 0) {
|
||||
$mains->push($tempMains[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For each of the users, let's determine if there are any ledgers,
|
||||
* then determine if there are any alts and ledgers associated with the alts.
|
||||
*/
|
||||
foreach($mains as $main) {
|
||||
//Declare some variables for each run through the for loop
|
||||
$ledgers = new Collection;
|
||||
|
||||
//Count the ledgers for the main
|
||||
$mainLedgerCount = Ledger::where([
|
||||
'character_id' => $main,
|
||||
'invoiced' => 'No',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->count();
|
||||
|
||||
//If there are ledgers for the main, then let's grab them
|
||||
if($mainLedgerCount > 0) {
|
||||
$mainLedgers = Ledger::where([
|
||||
'character_id' => $main,
|
||||
'invoiced' => 'No',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->get();
|
||||
|
||||
//Cycle through the entries, and add them to the ledger to send with the invoice
|
||||
foreach($mainLedgers as $row) {
|
||||
$ledgers->push([
|
||||
'character_id' => $row->character_id,
|
||||
'character_name' => $row->character_name,
|
||||
'observer_id' => $row->observer_id,
|
||||
'type_id' => $row->type_id,
|
||||
'ore_name' => $row->ore_name,
|
||||
'quantity' => (int)$row->quantity,
|
||||
'amount' => (float)$row->amount,
|
||||
'last_updated' => $row->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//Get the alt count for the main character
|
||||
$altCount = UserAlt::where(['main_id' => $main])->count();
|
||||
//If more than 0 alts, grab all the alts.
|
||||
if($altCount > 0) {
|
||||
$alts = UserAlt::where([
|
||||
'main_id' => $main,
|
||||
])->get();
|
||||
|
||||
//Cycle through the alts, and get the ledgers, and push onto the stack
|
||||
foreach($alts as $alt) {
|
||||
$altLedgerCount = Ledger::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'invoiced' => 'No',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->count();
|
||||
|
||||
if($altLedgerCount > 0) {
|
||||
$altLedgers = Ledger::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'invoiced' => 'No',
|
||||
])->where('last_updated', '>', Carbon::now()->subDays(7))->get();
|
||||
|
||||
foreach($altLedgers as $row) {
|
||||
$ledgers->push([
|
||||
'character_id' => $row->character_id,
|
||||
'character_name' => $row->character_name,
|
||||
'observer_id' => $row->observer_id,
|
||||
'type_id' => $row->type_id,
|
||||
'ore_name' => $row->ore_name,
|
||||
'quantity' => (int)$row->quantity,
|
||||
'amount' => (float)$row->amount,
|
||||
'last_updated' => $row->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the collected information over to the function to send the actual mail
|
||||
*/
|
||||
if($ledgers->count() > 0) {
|
||||
$this->CreateInvoice($main, $ledgers, $mailDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the invoice to the mail out
|
||||
*
|
||||
* @var charId
|
||||
* @var ledgers
|
||||
* @var mailDelay
|
||||
*/
|
||||
private function CreateInvoice($charId, Collection $ledgers, int &$mailDelay) {
|
||||
$ores = array();
|
||||
$characters = array();
|
||||
$characterIds = array();
|
||||
$totalPrice = 0.00;
|
||||
$body = null;
|
||||
$lookup = new LookupHelper;
|
||||
$config = config('esi');
|
||||
|
||||
//Create an invoice id
|
||||
$invoiceId = "M" . uniqid();
|
||||
|
||||
//Get the sum of all the ledgers
|
||||
$invoiceAmount = round(((float)$ledgers->sum('amount') * (float)$config['mining_tax']), 2);
|
||||
|
||||
//Get the character name from the lookup table
|
||||
$charName = $lookup->CharacterIdToName($charId);
|
||||
|
||||
//Create the date due and the invoice date
|
||||
$dateDue = Carbon::now()->addDays(7);
|
||||
$invoiceDate = Carbon::now();
|
||||
|
||||
//Set the mining tax from the config file
|
||||
$numberMiningTax = number_format(((float)$config['mining_tax'] * (float)100.00), 2, ".", ",");
|
||||
|
||||
//Create the list of ores to put in the mail
|
||||
$temp = $ledgers->toArray();
|
||||
foreach($temp as $t) {
|
||||
//If the key isn't set, set it to the default of 0
|
||||
if(!isset($ores[$t['type_id']])) {
|
||||
$ores[$t['type_id']] = (int)0;
|
||||
}
|
||||
|
||||
//Add the quantity into the ores array
|
||||
$ores[$t['type_id']] += (int)$t['quantity'];
|
||||
|
||||
//Create a list of character names
|
||||
if(!isset($characters[$t['character_name']])) {
|
||||
$characters[$t['character_name']] = $t['character_name'];
|
||||
}
|
||||
|
||||
//Create a list of character ids
|
||||
if(!isset($characterIds[$t['character_id']])) {
|
||||
$characterIds[$t['character_id']] = $t['character_id'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the mail body to send to the main character
|
||||
*/
|
||||
$body .= "Dear " . $charName . ",<br><br>";
|
||||
$body .= "Mining Taxes are due for the following ores mined from alliance moons: <br>";
|
||||
foreach($ores as $ore => $quantity) {
|
||||
$oreName = $lookup->ItemIdToName($ore);
|
||||
$body .= $oreName . ": " . number_format($quantity, 0, ".", ",") . "<br>";
|
||||
}
|
||||
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
|
||||
$body .= "<br><br>";
|
||||
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces by " . $dateDue . "<br>";
|
||||
$body .= "Set the reason for transfer as " . $invoiceId . "<br>";
|
||||
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
|
||||
$body .= "<br><br>";
|
||||
$body .= "You can also send a contract with the following ores in the contract with the reason set as: " . $invoiceId . "<br>";
|
||||
foreach($ores as $ore => $quantity) {
|
||||
$oreName = $lookup->ItemIdToName($ore);
|
||||
$body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), 0, ".", ",") . "<br>";
|
||||
}
|
||||
$body .= "<br>";
|
||||
$body .= "Characters Processed: <br>";
|
||||
foreach($characters as $character) {
|
||||
$body .= $character . "<br>";
|
||||
}
|
||||
$body .= "<br>";
|
||||
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||
|
||||
//Check if the mail body is greater than 2000 characters. If greater than 2,000 characters, then
|
||||
if(strlen($body) > 2000) {
|
||||
$body = "Dear " . $charName . "<br><br>";
|
||||
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
|
||||
$body .= "<br><br>";
|
||||
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces by " . $dateDue . "<br>";
|
||||
$body .= "Set the reason for transfer as: " . $invoiceId . "<br>";
|
||||
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
|
||||
$body .= "<br>";
|
||||
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||
}
|
||||
|
||||
//Mail the invoice to the character if the character is in
|
||||
//Warped Intentions or Legacy
|
||||
$subject = 'Warped Intentions Mining Taxes';
|
||||
$sender = $config['primary'];
|
||||
$recipientType = 'character';
|
||||
$recipient = $charId;
|
||||
|
||||
//Send the Eve Mail Job to the queue to be dispatched
|
||||
SendEveMail::dispatch($body, $recipient, $recipientType, $subject, $sender)->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
|
||||
/**
|
||||
* Create a new invoice model, and save it to the database
|
||||
*/
|
||||
$invoice = new Invoice;
|
||||
$invoice->character_id = $charId;
|
||||
$invoice->character_name = $charName;
|
||||
$invoice->invoice_id = $invoiceId;
|
||||
$invoice->invoice_amount = $invoiceAmount;
|
||||
$invoice->date_issued = $invoiceDate;
|
||||
$invoice->date_due = $dateDue;
|
||||
$invoice->status = 'Pending';
|
||||
$invoice->mail_body = $body;
|
||||
$invoice->save();
|
||||
|
||||
/**
|
||||
* Mark the invoices as paid
|
||||
*/
|
||||
foreach($characterIds as $char) {
|
||||
Ledger::where([
|
||||
'character_id' => $char,
|
||||
'invoiced' => 'No',
|
||||
])->update([
|
||||
'invoice' => $invoiceId,
|
||||
'invoiced' => 'Yes',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the mail delay for the next cycle
|
||||
*/
|
||||
$mailDelay += 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for Horizon
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['MiningTaxes', 'SendMiningTaxesInvoics', 'Invoices'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MoonRental\Invoices;
|
||||
|
||||
//Application Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Internal Library
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRental\AllianceMoon;
|
||||
use App\Models\MoonRental\AllianceMoonOre;
|
||||
use App\Models\MoonRental\AllianceMoonRental;
|
||||
|
||||
class SendMoonRentalInvoices implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('miningtaxes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
$months = 3;
|
||||
$today = Carbon::now();
|
||||
$future = Carbon::now()->addMonths(3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MoonRental;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Internal Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRental\AllianceMoon;
|
||||
use App\Models\MoonRental\AllianceMoonOre;
|
||||
|
||||
class UpdateAllianceMoonRentalWorth implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
$mHelper = new MoonCalc;
|
||||
$months = 3;
|
||||
$rentalTax = 0.25;
|
||||
|
||||
$moons = AllianceMoon::all();
|
||||
|
||||
foreach($moons as $moon) {
|
||||
//Declare the arrays needed
|
||||
$ores = array();
|
||||
$worth = 0.00;
|
||||
|
||||
$ores = AllianceMoonOre::where([
|
||||
'moon_id' => $moon->moon_id,
|
||||
])->get(['ore_name', 'quantity'])->toArray();
|
||||
|
||||
if(sizeof($ores) == 1) {
|
||||
$ores[1]["ore_name"] = null;
|
||||
$ores[1]["quantity"] = 0.00;
|
||||
$ores[2]["ore_name"] = null;
|
||||
$ores[2]["quantity"] = 0.00;
|
||||
$ores[3]["ore_name"] = null;
|
||||
$ores[3]["quantity"] = 0.00;
|
||||
} else if(sizeof($ores) == 2) {
|
||||
$ores[2]["ore_name"] = null;
|
||||
$ores[2]["quantity"] = 0.00;
|
||||
$ores[3]["ore_name"] = null;
|
||||
$ores[3]["quantity"] = 0.00;
|
||||
} else if(sizeof($ores) == 3) {
|
||||
$ores[3]["ore_name"] = null;
|
||||
$ores[3]["quantity"] = 0.00;
|
||||
}
|
||||
|
||||
//one of these two ways will work
|
||||
$worth = $mHelper->MoonTotalWorth($ores[0]["ore_name"], $ores[0]["quantity"],
|
||||
$ores[1]["ore_name"], $ores[1]["quantity"],
|
||||
$ores[2]["ore_name"], $ores[2]["quantity"],
|
||||
$ores[3]["ore_name"], $ores[3]["quantity"]);
|
||||
|
||||
$rentalAmount = $worth * $rentalTax * $months;
|
||||
|
||||
AllianceMoon::where([
|
||||
'moon_id' => $moon->moon_id,
|
||||
])->update([
|
||||
'worth_amount' => $worth,
|
||||
'rental_amount' => $rentalAmount,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
174
app/Jobs/Commands/Structures/FetchAllianceStructures.php
Normal file
174
app/Jobs/Commands/Structures/FetchAllianceStructures.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Structures;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Exception\RequestFailedException;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Service;
|
||||
|
||||
class FetchAllianceStructures implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('structures');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$config = config('esi');
|
||||
$corpId = 98287666;
|
||||
|
||||
$esiHelper = new Esi;
|
||||
$structureScope = $esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1');
|
||||
$corpStructureScope = $esiHelper->HaveEsiScope($config['primary'], 'esi-corporations.read_structures.v1');
|
||||
|
||||
//Check scopes
|
||||
if($structureScope == false || $corpStructureScope == false) {
|
||||
if($structureScope == false) {
|
||||
Log::critical("Scope check for esi-universe.read_structures.v1 has failed.");
|
||||
}
|
||||
if($corpStructureScope == false) {
|
||||
Log::critical("Scope check for esi-corporations.read_structures.v1 has failed.");
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||
//Create the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Set the current page
|
||||
$currentPage = 1;
|
||||
//Set our default pages
|
||||
$totalPages = 1;
|
||||
|
||||
do {
|
||||
//Attempt to get the entire page worth of structures
|
||||
$structures = $esi->page($currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/structures/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
|
||||
//If on the first page, then update the total number of pages
|
||||
if($currentPage == 1) {
|
||||
$totalPages = $structures->pages;
|
||||
}
|
||||
|
||||
//For each asset retrieved, let's process it.
|
||||
foreach($structures as $s) {
|
||||
ProcessAllianceStructures::dispatch($s)->onQueue('structures');
|
||||
}
|
||||
|
||||
//Increment the current page
|
||||
$currentPage++;
|
||||
} while($currentPage <= $totalPages);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The job failed to process
|
||||
* @param Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function failed($exception) {
|
||||
if(!exception instanceof RequestFailedException) {
|
||||
//If not a failure due to ESI, then log it. Otherwise,
|
||||
//deduce why the exception occurred.
|
||||
Log::critical($exception);
|
||||
}
|
||||
|
||||
if ((is_object($exception->getEsiResponse()) && (stristr($exception->getEsiResponse()->error, 'Too many errors') || stristr($exception->getEsiResponse()->error, 'This software has exceeded the error limit for ESI'))) ||
|
||||
(is_string($exception->getEsiResponse()) && (stristr($exception->getEsiResponse(), 'Too many errors') || stristr($exception->getEsiResponse(), 'This software has exceeded the error limit for ESI')))) {
|
||||
|
||||
//We have hit the error rate limiter, wait 120 seconds before releasing the job back into the queue.
|
||||
Log::info('FetchAllianceStructures has hit the error rate limiter. Releasing the job back into the wild in 2 minutes.');
|
||||
$this->release(120);
|
||||
} else {
|
||||
$errorCode = $exception->getEsiResponse()->getErrorCode();
|
||||
|
||||
switch($errorCode) {
|
||||
case 400: //Bad Request
|
||||
Log::critical("Bad request has occurred in FetchAllianceStructures. Job has been discarded");
|
||||
break;
|
||||
case 401: //Unauthorized Request
|
||||
Log::critical("Unauthorized request has occurred in FetchAllianceStructures at " . Carbon::now()->toDateTimeString() . ".\r\nCancelling the job.");
|
||||
break;
|
||||
case 403: //Forbidden
|
||||
Log::critical("FetchAllianceStructures has incurred a forbidden error. Cancelling the job.");
|
||||
break;
|
||||
case 420: //Error Limited
|
||||
Log::warning("Error rate limit occurred in FetchAllianceStructures. Restarting job in 120 seconds.");
|
||||
$this->release(120);
|
||||
break;
|
||||
case 500: //Internal Server Error
|
||||
Log::critical("Internal Server Error for ESI in FetchAllianceStructures. Attempting a restart in 120 seconds.");
|
||||
$this->release(120);
|
||||
break;
|
||||
case 503: //Service Unavailable
|
||||
Log::critical("Service Unavailabe for ESI in FetchAllianceStructures. Releasing the job back to the queue in 30 seconds.");
|
||||
$this->release(30);
|
||||
break;
|
||||
case 504: //Gateway Timeout
|
||||
Log::critical("Gateway timeout in FetchAllianceStructures. Releasing the job back to the queue in 30 seconds.");
|
||||
$this->release(30);
|
||||
break;
|
||||
case 201: //Good response code
|
||||
$this->delete();
|
||||
break;
|
||||
//If no code is given, then log and break out of switch.
|
||||
default:
|
||||
Log::warning("No response code received from esi call in FetchAllianceStructures.\r\n");
|
||||
$this->delete();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function tags() {
|
||||
return ['FetchAllianceStructures', 'AllianceStructures', 'Structures'];
|
||||
}
|
||||
}
|
||||
216
app/Jobs/Commands/Structures/ProcessAllianceStructures.php
Normal file
216
app/Jobs/Commands/Structures/ProcessAllianceStructures.php
Normal file
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Structures;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Service;
|
||||
|
||||
class ProcessAllianceStructures implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
private $structure;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($s)
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('structures');
|
||||
|
||||
//Set variables
|
||||
$this->structure = $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
/**
|
||||
* Update the structure if it already exists, or add the structure if it doesn't exist in the database
|
||||
*/
|
||||
if(Structure::where(['structure_id' => $this->structure->structure_id])->count() > 0) {
|
||||
$this->UpdateStructure($this->structure);
|
||||
} else {
|
||||
$this->SaveNewStructure($this->structure);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for the job
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['ProcessAllianceStructures', 'AllianceStructures', 'Structures'];
|
||||
}
|
||||
|
||||
private function SaveNewStructure($structure) {
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Get the solar system name
|
||||
$solarName = $lookup->SystemIdToName($structure->system_id);
|
||||
|
||||
$s = new Structure;
|
||||
$s->structure_id = $structure->structure_id;
|
||||
$s->structure_name = $structure->name;
|
||||
$s->solar_system_id = $structure->system_id;
|
||||
$s->solar_system_name = $solarName;
|
||||
$s->type_id = $structure->type_id;
|
||||
$s->type_name = $lookup->StructureTypeIdToName($structure->type_id);
|
||||
$s->corporation_id = $structure->corporation_id;
|
||||
if(isset($structure->services)) {
|
||||
$s->services = true;
|
||||
foreach($structure->services as $service) {
|
||||
$serv = new Service;
|
||||
$serv->structure_id = $structure->structure_id;
|
||||
$serv->name = $service->name;
|
||||
$serv->state = $service->state;
|
||||
}
|
||||
} else {
|
||||
$s->services = false;
|
||||
}
|
||||
$s->state = $structure->state;
|
||||
if(isset($structre->state_timer_start)) {
|
||||
$s->state_timer_start = $esiHelper->DecodeDate($structure->state_timer_start);
|
||||
}
|
||||
if(isset($structure->state_timer_end)) {
|
||||
$s->state_timer_end = $esiHelper->DecodeDate($structure->state_timer_end);
|
||||
}
|
||||
if(isset($structure->fuel_expires)) {
|
||||
$s->fuel_expires = $esiHelper->DecodeDate($structure->fuel_expires);
|
||||
}
|
||||
$s->profile_id = $structure->profile_id;
|
||||
if(isset($structure->next_reinforce_apply)) {
|
||||
$s->next_reinforce_apply = $structure->next_reinforce_apply;
|
||||
}
|
||||
if(isset($structure->next_reinforce_hour)) {
|
||||
$s->next_reinforce_hour = $structure->next_reinforce_hour;
|
||||
}
|
||||
$s->reinforce_hour = $structure->reinforce_hour;
|
||||
if(isset($structure->unanchors_at)) {
|
||||
$s->unanchors_at = $esiHelper->DecodeDate($s->unanchors_at);
|
||||
}
|
||||
$s->save();
|
||||
}
|
||||
|
||||
private function UpdateStructure($structure) {
|
||||
$esiHelper = new Esi;
|
||||
|
||||
if(isset($structure->corporation_id)) {
|
||||
Structure::where([
|
||||
'structure_id' => $structure->structure_id,
|
||||
])->update([
|
||||
'corporation_id' => $structure->corporation_id,
|
||||
]);
|
||||
}
|
||||
if(isset($structure->state)) {
|
||||
Structure::where([
|
||||
'structure_id' => $structure->structure_id,
|
||||
])->update([
|
||||
'state' => $structure->state,
|
||||
]);
|
||||
}
|
||||
if(isset($structure->state_timer_start)) {
|
||||
Structure::where([
|
||||
'structure_id' => $structure->structure_id,
|
||||
])->update([
|
||||
'state_timer_start' => $esiHelper->DecodeDate($structure->state_timer_start),
|
||||
]);
|
||||
}
|
||||
if(isset($structure->state_timer_end)) {
|
||||
Structure::where([
|
||||
'structure_id' => $structure->structure_id,
|
||||
])->update([
|
||||
'state_timer_end' => $esiHelper->DecodeDate($structure->state_timer_end),
|
||||
]);
|
||||
}
|
||||
if(isset($structure->fuel_expires)) {
|
||||
Structure::where([
|
||||
'structure_id' => $structure->structure_id,
|
||||
])->update([
|
||||
'fuel_expires' => $esiHelper->DecodeDate($structure->fuel_expires),
|
||||
]);
|
||||
}
|
||||
if(isset($structure->profile_id)) {
|
||||
Structure::where([
|
||||
'structure_id' => $structure->structure_id,
|
||||
])->update([
|
||||
'profile_id' => $structure->profile_id,
|
||||
]);
|
||||
}
|
||||
if(isset($structure->next_reinforce_apply)) {
|
||||
Structure::where([
|
||||
'structure_id' => $structure->structure_id,
|
||||
])->update([
|
||||
'next_reinforce_apply' => $structure->next_reinforce_apply,
|
||||
]);
|
||||
}
|
||||
if(isset($structure->next_reinforce_hour)) {
|
||||
Structure::where([
|
||||
'structure_id' => $structure->structure_id,
|
||||
])->update([
|
||||
'next_reinforce_hour' => $structure->next_reinforce_hour,
|
||||
]);
|
||||
}
|
||||
if(isset($structure->reinforce_hour)) {
|
||||
Structure::where([
|
||||
'structure_id' => $structure->structure_id,
|
||||
])->update([
|
||||
'reinforce_hour' => $structure->reinforce_hour,
|
||||
]);
|
||||
}
|
||||
if(isset($structure->unanchors_at)) {
|
||||
Structure::where([
|
||||
'structure_id' => $structure->structure_id,
|
||||
])->update([
|
||||
'unanchors_at' => $esiHelper->DecodeDate($structure->unanchors_at),
|
||||
]);
|
||||
}
|
||||
|
||||
if(Service::where(['structure_id' => $structure->structure_id])->count() > 0) {
|
||||
foreach($structure->services as $service) {
|
||||
Service::where([
|
||||
'structure_id' => $structure->structure_id,
|
||||
])->update([
|
||||
'state' => $service->state,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
70
app/Jobs/Commands/Structures/PurgeAllianceStructures.php
Normal file
70
app/Jobs/Commands/Structures/PurgeAllianceStructures.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Structures;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Structures\FetchAllianceStructures;
|
||||
|
||||
//Models
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Service;
|
||||
|
||||
class PurgeAllianceStructures implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
$this->onQueue('structures');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Structure::truncate();
|
||||
Service::truncate();
|
||||
|
||||
FetchAllianceStructures::dispatch()->delay(Carbon::now()->addSeconds(30));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for the job
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['PurgeAllianceStructures', 'AllianceStructures', 'Structures'];
|
||||
}
|
||||
}
|
||||
113
app/Jobs/Commands/SupplyChain/EndSupplyChainContractJob.php
Normal file
113
app/Jobs/Commands/SupplyChain/EndSupplyChainContractJob.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\SupplyChain;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Contracts\SupplyChainBid;
|
||||
use App\Models\Contracts\SupplyChainContract;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\SendEveMail;
|
||||
|
||||
class EndSupplyChainContractJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 1200;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Private Variables
|
||||
*/
|
||||
private $contractId;
|
||||
private $issuerId;
|
||||
private $issuerName;
|
||||
private $title;
|
||||
private $endDate;
|
||||
private $deliveryBy;
|
||||
private $body;
|
||||
private $state;
|
||||
private $finalCost;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(SupplyChainContract $contract)
|
||||
{
|
||||
//Set the queue connection up
|
||||
$this->connection = 'redis';
|
||||
|
||||
//Set the variables
|
||||
$contractId = $contract->contract_id;
|
||||
$issuerId = $contract->issuer_id;
|
||||
$issuerName = $contract->issuer_name;
|
||||
$title = $contract->title;
|
||||
$endDate = $contract->end_date;
|
||||
$deliveryBy = $contract->delivery_by;
|
||||
$body = $contract->body;
|
||||
$state = $contract->state;
|
||||
$finalCost = $contract->final_cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$bidId = null;
|
||||
$bidAmount = null;
|
||||
|
||||
//Get all of the bids from the contract
|
||||
$bids = SupplyChainBids::where([
|
||||
'contract_id' => $contractId,
|
||||
])->get();
|
||||
|
||||
//Loop through the bids and find the lowest bid
|
||||
foreach($bids as $bid) {
|
||||
if($bidId == null) {
|
||||
$bidId = $bid->id;
|
||||
$bidAmount = $bid->bid_amount;
|
||||
} else {
|
||||
if($bid->bid_amount < $bidAmount) {
|
||||
$bidId = $bid->id;
|
||||
$bidAmount = $bid->bid_amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Clean up the bids and update the contract with the winning bid
|
||||
SupplyChainContract::where([
|
||||
'contract_id' => $this->contractId,
|
||||
])->update([
|
||||
'final_cost' => $bidAmount,
|
||||
'winning_bid_id' => $bidId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
169
app/Jobs/Middleware/EveMailLimiter.php
Normal file
169
app/Jobs/Middleware/EveMailLimiter.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
|
||||
class EveMailLimiter {
|
||||
/** @var bool|\Closure */
|
||||
protected $enabled = true;
|
||||
|
||||
/** @var string */
|
||||
protected $connectionName = 'redis';
|
||||
|
||||
/** @var string */
|
||||
protected $key;
|
||||
|
||||
/** @var int */
|
||||
protected $timeSpanInSeconds = 1;
|
||||
|
||||
/** @var int */
|
||||
protected $allowedNumberOfJobsInTimeSpan = 4;
|
||||
|
||||
/** @var int */
|
||||
protected $releaseInSeconds = 60;
|
||||
|
||||
/** @var array */
|
||||
protected $releaseRandomSeconds = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$calledByClass = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['class'];
|
||||
|
||||
$this->key($calledByClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool|\Closure $enabled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function enabled($enabled = true)
|
||||
{
|
||||
$this->enabled = $enabled;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function connectionName(string $connectionName = 'redis')
|
||||
{
|
||||
$this->connectionName = $connectionName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function key(string $key)
|
||||
{
|
||||
$this->key = $key;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function timespanInSeconds(int $timespanInSeconds)
|
||||
{
|
||||
$this->timeSpanInSeconds = $timespanInSeconds;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function allow(int $allowedNumberOfJobsInTimeSpan = 4)
|
||||
{
|
||||
$this->allowedNumberOfJobsInTimeSpan = $allowedNumberOfJobsInTimeSpan;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function everySecond(int $timespanInSeconds = 1)
|
||||
{
|
||||
$this->timeSpanInSeconds = $timespanInSeconds;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function everySeconds(int $timespanInSeconds = 60)
|
||||
{
|
||||
return $this->everySecond($timespanInSeconds);
|
||||
}
|
||||
|
||||
public function everyMinute(int $timespanInMinutes = 1)
|
||||
{
|
||||
return $this->everySecond($timespanInMinutes * 60);
|
||||
}
|
||||
|
||||
public function everyMinutes(int $timespanInMinutes)
|
||||
{
|
||||
return $this->everySecond($timespanInMinutes * 60);
|
||||
}
|
||||
|
||||
public function releaseAfterOneSecond()
|
||||
{
|
||||
return $this->releaseAfterSeconds(1);
|
||||
}
|
||||
|
||||
public function releaseAfterSeconds(int $releaseInSeconds)
|
||||
{
|
||||
$this->releaseInSeconds = $releaseInSeconds;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function releaseAfterOneMinute()
|
||||
{
|
||||
return $this->releaseAfterMinutes(1);
|
||||
}
|
||||
|
||||
public function releaseAfterMinutes(int $releaseInMinutes)
|
||||
{
|
||||
return $this->releaseAfterSeconds($releaseInMinutes * 60);
|
||||
}
|
||||
|
||||
public function releaseAfterRandomSeconds(int $min = 1, int $max = 10)
|
||||
{
|
||||
$this->releaseRandomSeconds = [$min, $max];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function releaseAfterBackoff(int $attemptedCount, int $backoffRate = 2)
|
||||
{
|
||||
$releaseAfterSeconds = 0;
|
||||
$interval = $this->releaseInSeconds;
|
||||
for ($attempt = 0; $attempt <= $attemptedCount; $attempt++) {
|
||||
$releaseAfterSeconds += $interval * pow($backoffRate, $attempt);
|
||||
}
|
||||
|
||||
return $this->releaseAfterSeconds($releaseAfterSeconds);
|
||||
}
|
||||
|
||||
protected function releaseDuration(): int
|
||||
{
|
||||
if (! is_null($this->releaseRandomSeconds)) {
|
||||
return random_int(...$this->releaseRandomSeconds);
|
||||
}
|
||||
|
||||
return $this->releaseInSeconds;
|
||||
}
|
||||
|
||||
public function handle($job, $next)
|
||||
{
|
||||
if ($this->enabled instanceof Closure) {
|
||||
$this->enabled = (bool) $this->enabled();
|
||||
}
|
||||
|
||||
if (! $this->enabled) {
|
||||
return $next($job);
|
||||
}
|
||||
|
||||
Redis::connection($this->connectionName)
|
||||
->throttle($this->key)
|
||||
->block(0)
|
||||
->allow($this->allowedNumberOfJobsInTimeSpan)
|
||||
->every($this->timeSpanInSeconds)
|
||||
->then(function () use ($job, $next) {
|
||||
$next($job);
|
||||
}, function () use ($job) {
|
||||
$job->release($this->releaseDuration());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
|
||||
//App Library
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
use App\Jobs\Library\JobHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessWalletJournal;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class ProcessWalletJournalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 300;
|
||||
|
||||
public $tries = 3;
|
||||
|
||||
private $division;
|
||||
private $charId;
|
||||
private $page;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(JobProcessWalletJournal $pwj) {
|
||||
$this->division = $pwj->division;
|
||||
$this->charId = $pwj->charId;
|
||||
$this->page = $pwj->page;
|
||||
|
||||
$this->delay = 15;
|
||||
$this->connection = 'database';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* Utilized by using ProcessWalletJournalJob::dispatch()
|
||||
* The model is passed into the dispatch function, then added to the queue
|
||||
* for processing.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare the class variable we need
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
$finance->GetWalletJournalPage($this->division, $this->charId, $this->page);
|
||||
|
||||
//After the job is completed, delete the job
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* The job failed to process.
|
||||
*
|
||||
* @param Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function failed($exception)
|
||||
{
|
||||
dd($exception);
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
|
||||
//App Library
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
use App\Jobs\Library\JobHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessWalletTransaction;
|
||||
use App\Models\Jobs\JobError;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class ProcessWalletTransactionJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 300;
|
||||
|
||||
public $tries = 3;
|
||||
|
||||
private $division;
|
||||
private $charId;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(JobProcessWalletTransaction $pwt)
|
||||
{
|
||||
$this->division = $pwt->division;
|
||||
$this->charId = $pwt->charId;
|
||||
|
||||
$this->connection = 'database';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare the class variables
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
$finance->GetWalletTransaction($this->division, $this->charId);
|
||||
|
||||
//After the job is completed, delete the job
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* The job failed to process
|
||||
*
|
||||
* @param Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function failed($exception) {
|
||||
dd($exception);
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
|
||||
//Seat stuff
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Mail\EveMail;
|
||||
use App\Models\Jobs\JobError;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class SendEveMailJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 120;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
private $body;
|
||||
private $recipient;
|
||||
private $recipient_type;
|
||||
private $subject;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(EveMail $mail) {
|
||||
$this->body = $mail->body;
|
||||
$this->recipient = $mail->recipient;
|
||||
$this->recipient_type = $mail->recipient_type;
|
||||
$this->subject = $mail->subject;
|
||||
|
||||
$this->connection = 'database';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* Utilized by using SendEveMailJob::dispatch($mail);
|
||||
* The model is passed into the dispatch function, then added to the queue
|
||||
* for processing.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Retrieve the token for main character to send mails from
|
||||
$token = EsiToken::where(['character_id'=> 93738489])->get();
|
||||
|
||||
//Create the ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
]);
|
||||
|
||||
//Setup the Eseye class
|
||||
$esi = new Eseye($authentication);
|
||||
|
||||
//Attemp to send the mail
|
||||
try {
|
||||
$esi->setBody([
|
||||
'approved_cost' => 0,
|
||||
'body' => $this->body,
|
||||
'recipients' => [[
|
||||
'recipient_id' => (int)$this->recipient,
|
||||
'recipient_type' => $this->recipient_type,
|
||||
]],
|
||||
'subject' => $this->subject,
|
||||
])->invoke('post', '/characters/{character_id}/mail/', [
|
||||
'character_id'=> 93738489,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* The job failed to process.
|
||||
*
|
||||
* @param Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function failed($exception)
|
||||
{
|
||||
dd($exception);
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,17 @@
|
||||
namespace App\Library\Esi;
|
||||
|
||||
//Internal Libraries
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Client;
|
||||
use Log;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\SendEveMailJob;
|
||||
use App\Jobs\Commands\Eve\SendEveMail;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
@@ -33,108 +36,21 @@ class Esi {
|
||||
* @return true,false
|
||||
*/
|
||||
public function HaveEsiScope($charId, $scope) {
|
||||
//Check for an esi scope
|
||||
$checks = DB::table('EsiScopes')->where('character_id', $charId)->get();
|
||||
foreach($checks as $check) {
|
||||
if($check->scope === $scope) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$mail = new EveMail;
|
||||
$mail->sender = 93738489;
|
||||
$mail->subject = 'W4RP Services - Incorrect ESI Scope';
|
||||
$mail->body = "Please register on https://services.w4rp.space with the scope: " . $scope;
|
||||
$mail->recipient = (int)$charId;
|
||||
$mail->recipient_type = 'character';
|
||||
$mail->save();
|
||||
|
||||
SendEveMailJob::dispatch($mail)->delay(Carbon::now()->addSeconds(5));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function GetCharacterData($charId) {
|
||||
$esi = new Eseye();
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $character;
|
||||
}
|
||||
|
||||
public function GetCharacterName($charId) {
|
||||
$esi = new Eseye();
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $character->name;
|
||||
}
|
||||
|
||||
public function FindCharacterId($name) {
|
||||
//Get the esi config
|
||||
$config = config('esi');
|
||||
//Create the esi authentication container
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
]);
|
||||
//Create the esi container
|
||||
$esi = new Eseye($authentication);
|
||||
try {
|
||||
$character = $esi->setQueryString([
|
||||
'categories' => 'character',
|
||||
'language' => 'en-us',
|
||||
'search' => $name,
|
||||
'strict' => 'true',
|
||||
])->invoke('get', '/search/');
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
|
||||
//Check for an esi scope
|
||||
$check = EsiScope::where(['character_id' => $charId, 'scope' => $scope])->count();
|
||||
if($check == 0) {
|
||||
//Compose a mail to send to the user if the scope is not found
|
||||
$subject = 'W4RP Services - Incorrect ESI Scope';
|
||||
$body = "Please register on https://services.w4rp.space with the scope: " . $scope;
|
||||
|
||||
SendEveMail::dispatch($body, (int)$charId, 'character', $subject, $config['primary'])->delay(Carbon::now()->addSeconds(5));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$character = json_decode($character, true);
|
||||
|
||||
return $character['character'];
|
||||
}
|
||||
|
||||
public function FindCorporationId($charId) {
|
||||
$esi = new Eseye();
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $character->corporation_id;
|
||||
}
|
||||
|
||||
public function FindCorporationName($charId) {
|
||||
$esi = new Eseye();
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
|
||||
$corporation = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return $corporation->name;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function DecodeDate($date) {
|
||||
@@ -151,6 +67,125 @@ class Esi {
|
||||
//Return the combined date in the correct format
|
||||
return $realDate;
|
||||
}
|
||||
|
||||
public function TokenExpired($token) {
|
||||
$currentTime = Carbon::now();
|
||||
|
||||
//Create the carbon time for expiration time
|
||||
$expires = $token->inserted_at + $token->expires_in;
|
||||
$tokenExpiration = Carbon::createFromTimeStamp($expires);
|
||||
|
||||
if($currentTime->greaterThan($tokenExpiration->subSeconds(5))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetRefreshToken($charId) {
|
||||
//Declare variables
|
||||
$currentTime = Carbon::now();
|
||||
$scopes = null;
|
||||
$i = 0;
|
||||
$config = config('esi');
|
||||
|
||||
//If the program doesn't find an ESI Token, there is nothing to return
|
||||
if(EsiToken::where(['character_id' => $charId])->count() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the ESI Token from the database
|
||||
$token = EsiToken::where([
|
||||
'character_id' => $charId,
|
||||
])->first();
|
||||
|
||||
//Check the expiration of the token to see if the token has expired and needs to be refreshed using the refresh token
|
||||
$expires = $token->inserted_at + $token->expires_in;
|
||||
$tokenExpiration = Carbon::createFromTimestamp($expires);
|
||||
//If the access token has expired, we need to do a request for a new access token
|
||||
//We give ourselves around 5 seconds leeway in order to deal with an expired token
|
||||
if($currentTime->greaterThan($tokenExpiration->subSeconds(5))) {
|
||||
//Get the current scopes of the token
|
||||
$scopesArr = EsiScope::where([
|
||||
'character_id' => $token->character_id,
|
||||
])->get(['scope'])->toArray();
|
||||
|
||||
//Cycle through the scopes, and create the string for scopes to send with the token
|
||||
foreach($scopesArr as $scp) {
|
||||
$scopes .= $scp['scope'];
|
||||
$i++;
|
||||
if($i < sizeof($scopesArr)) {
|
||||
$scopes .= '%20';
|
||||
}
|
||||
}
|
||||
|
||||
//Setup the guzzle client for the request to get a new token
|
||||
$client = new Client(['base_uri' => 'https://login.eveonline.com']);
|
||||
$response = $client->request('POST', '/v2/oauth/token', [
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/x-www-form-urlencoded',
|
||||
'Host' => 'login.eveonline.com',
|
||||
'Authorization' => "Basic " . base64_encode($config['client_id'] . ":" . $config['secret']),
|
||||
],
|
||||
'form_params' => [
|
||||
'grant_type' => 'refresh_token',
|
||||
'refresh_token' => $token->refresh_token,
|
||||
],
|
||||
]);
|
||||
//Decode the body of the response which has the token information
|
||||
$body = json_decode($response->getBody(), true);
|
||||
//Update the old token, then send the new token back to the calling function
|
||||
EsiToken::where([
|
||||
'character_id' => $charId,
|
||||
])->update([
|
||||
'access_token' => $body['access_token'],
|
||||
'refresh_token' => $body['refresh_token'],
|
||||
'expires_in' => $body['expires_in'],
|
||||
'inserted_at' => time(),
|
||||
]);
|
||||
|
||||
$newToken = new EsiToken;
|
||||
$newToken->character_id = $charId;
|
||||
$newToken->access_token = $body['access_token'];
|
||||
$newToken->refresh_token = $body['refresh_token'];
|
||||
$newToken->inserted_at = time();
|
||||
$newToken->expires_in = $body['expires_in'];
|
||||
|
||||
//Return the new token model
|
||||
return $newToken;
|
||||
}
|
||||
|
||||
//If we had a good token which has not expired yet, return the data
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function SetupEsiAuthentication($token = null) {
|
||||
//Declare some variables
|
||||
$authentication = null;
|
||||
$esi = null;
|
||||
$config = config('esi');
|
||||
|
||||
if($token == null) {
|
||||
$esi = new Eseye();
|
||||
} else {
|
||||
$tokenExpires = $token->inserted_at + $token->expires_in;
|
||||
|
||||
//Setup the esi authentication container
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token->refresh_token,
|
||||
'access_token' => $token->access_token,
|
||||
'token_expires' => $tokenExpires,
|
||||
]);
|
||||
|
||||
//Setup the esi variable
|
||||
$esi = new Eseye($authentication);
|
||||
}
|
||||
|
||||
//Return the created variable
|
||||
return $esi;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Esi;
|
||||
|
||||
use DB;
|
||||
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
class Mail {
|
||||
|
||||
public function SendMail($recipient, $rType, $subject, $body) {
|
||||
//Retrieve the token for main character to send mails from
|
||||
$token = EsiToken::where(['character_id' => 93738489])->first();
|
||||
//Create the ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token->refresh_token,
|
||||
]);
|
||||
$esi = new Eseye($authentication);
|
||||
try {
|
||||
$esi->setBody([
|
||||
'approved_cost' => 0,
|
||||
'body' => $body,
|
||||
'recipients' => [[
|
||||
'recipient_id' => (int)$recipient,
|
||||
'recipient_type' => $rType,
|
||||
]],
|
||||
'subject' => $subject,
|
||||
])->invoke('post', '/characters/{character_id}/mail/', [
|
||||
'character_id'=> 93738489,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,426 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances\Helper;
|
||||
|
||||
//Internal Library
|
||||
use DB;
|
||||
|
||||
//Job
|
||||
use App\Jobs\SendEveMailJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Mail\EveMail;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Finances\MarketTax;
|
||||
use App\Library\Finances\PlayerDonation;
|
||||
use App\Library\Finances\ReprocessingTax;
|
||||
use App\Library\Finances\JumpBridgeTax;
|
||||
use App\Library\Finances\StructureIndustryTax;
|
||||
use App\Library\Finances\OfficeFee;
|
||||
use App\Library\Finances\PlanetProductionTax;
|
||||
use App\Library\Finances\PISale;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
class FinanceHelper {
|
||||
|
||||
public function GetWalletTransaction($division, $charId) {
|
||||
//Declare the lookup class helper
|
||||
$lookups = new LookupHelper;
|
||||
|
||||
//Setup array for PI items
|
||||
$pi_items = $this->GetPIMaterialsArray();
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$tokenData = $this->TokenInfo($charId);
|
||||
$token = $tokenData['token'];
|
||||
$scope = $tokenData['scope'];
|
||||
|
||||
//If the token is not found, send the user an eve mail, and just exit out of the function
|
||||
if($this->TokenNotFound($token, $scope, $charId)) {
|
||||
printr("Token not found\n");
|
||||
return null;
|
||||
}
|
||||
|
||||
//Reference to see if the character is in our look up table for corporations and characters
|
||||
$corpId = $lookups->LookupCharacter($charId);
|
||||
|
||||
//Create an ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
]);
|
||||
|
||||
//Create the esi class varialble
|
||||
$esi = new Eseye($authentication);
|
||||
|
||||
//Get the entries of the journal for transactions
|
||||
try {
|
||||
$journals = $esi->invoke('get', '/corporations/{corporation_id}/wallets/{division}/transactions/', [
|
||||
'corporation_id' => 98251577,
|
||||
'division' => 3,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
}
|
||||
|
||||
//Decode the wallet from json into an array
|
||||
$wallet = json_decode($journals->raw, true);
|
||||
|
||||
//For each transactional entry, attempt to store it in the database.
|
||||
//The PutWalletJournal function checks to see if it's already in the database.
|
||||
foreach($wallet as $entry) {
|
||||
if($division == 3 && $charId == 94415555) {
|
||||
if(in_array($entry['type_id'], $pi_items, false)) {
|
||||
$pi = new PISale();
|
||||
$pi->InsertPISale($entry, 98287666);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function GetWalletJournal($division, $charId) {
|
||||
//Declare new class variables
|
||||
$market = new MarketTax();
|
||||
$reprocessing = new ReprocessingTax();
|
||||
$jb = new JumpBridgeTax();
|
||||
$other = new PlayerDonation();
|
||||
$industry = new StructureIndustryTax();
|
||||
$office = new OfficeFee();
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$tokenData = $this->TokenInfo($charId);
|
||||
$token = $tokenData['token'];
|
||||
$scope = $tokenData['scope'];
|
||||
|
||||
//Declare the lookup class helper
|
||||
$lookups = new LookupHelper;
|
||||
|
||||
//If the token is not found, send the user an eve mail, and just exit out of the function
|
||||
if($this->TokenNotFound($token, $scope, $charId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Reference to see if the character is in our look up table for corporations and characters
|
||||
$corpId = $lookups->LookupCharacter($charId);
|
||||
|
||||
//Create an ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
]);
|
||||
|
||||
//Create the esi class varialble
|
||||
$esi = new Eseye($authentication);
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Set our current page to 1 which is the one we are starting on.
|
||||
$currentPage = 1;
|
||||
//Set our default total pages to 1 in case our try section fails out.
|
||||
$totalPages = 1;
|
||||
|
||||
//If more than one page is found, decode the first set of wallet entries, then call for the next pages
|
||||
do {
|
||||
//Call the first page of the wallet journal, as we are always going to get at least one page.
|
||||
//If we have more pages, then we will continue through the while loop.
|
||||
try {
|
||||
$journals = $esi->page($currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
}
|
||||
|
||||
//Set the total pages we need to cycle through.
|
||||
$totalPages = $journals->pages;
|
||||
//Decode the wallet from json into an array
|
||||
$wallet = json_decode($journals->raw, true);
|
||||
//For each journal entry, attempt to store it in the database.
|
||||
//The PutWalletJournal function checks to see if it's already in the database.
|
||||
foreach($wallet as $entry) {
|
||||
if($entry['amount'] > 0) {
|
||||
if($entry['ref_type'] == 'brokers_fee') {
|
||||
$market->InsertMarketTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'reprocessing_tax') {
|
||||
$reprocessing->InsertReprocessingTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'structure_gate_jump') {
|
||||
$jb->InsertJumpBridgeTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'player_donation' ||
|
||||
($entry['ref_type'] == 'corporation_account_withdrawal' && $entry['second_party_id'] == 98287666)) {
|
||||
$other->InsertPlayerDonation($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'industry_job_tax' && $entry['second_party_id'] == 98287666) {
|
||||
$industry->InsertStructureIndustryTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'office_rental_fee' && $entry['second_party_id'] == 98287666) {
|
||||
$office->InsertOfficeFee($entry, $corpId, $division);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Increment the current page we are on.
|
||||
$currentPage++;
|
||||
//Continue looping through the do while loop until the current page is greater than or equal to the total pages.
|
||||
} while ($currentPage < $totalPages);
|
||||
}
|
||||
|
||||
public function GetJournalPageCount($division, $charId) {
|
||||
//Declare class variables
|
||||
$lookups = new LookupHelper;
|
||||
|
||||
//Get the ESI refresh token for the corporation
|
||||
$tokenData = $this->TokenInfo($charId);
|
||||
$token = $tokenData['token'];
|
||||
$scope = $tokenData['scope'];
|
||||
|
||||
if($this->TokenNotFound($token, $scope, $charId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Refrence to see if the character is in our look up table for corporation and characters
|
||||
$corpId = $lookups->LookupCharacter($charId);
|
||||
|
||||
//Create the ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
]);
|
||||
|
||||
//Create the esi class variable
|
||||
$esi = new Eseye($authentication);
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Call the first page so we can get the header data for the number of pages
|
||||
try {
|
||||
$journals = $esi->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
}
|
||||
|
||||
$pages = $journals->pages;
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public function GetWalletJournalPage($division, $charId, $page = 1) {
|
||||
//Declare new class variables
|
||||
$market = new MarketTax();
|
||||
$reprocessing = new ReprocessingTax();
|
||||
$jb = new JumpBridgeTax();
|
||||
$other = new PlayerDonation();
|
||||
$industry = new StructureIndustryTax();
|
||||
$office = new OfficeFee();
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$tokenData = $this->TokenInfo($charId);
|
||||
$token = $tokenData['token'];
|
||||
$scope = $tokenData['scope'];
|
||||
|
||||
//Declare the lookup class helper
|
||||
$lookups = new LookupHelper;
|
||||
|
||||
//Reference to see if the character is in our look up table for corporations and characters
|
||||
$corpId = $lookups->LookupCorporationId($charId);
|
||||
|
||||
//Create an ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
]);
|
||||
|
||||
//Create the esi class varialble
|
||||
$esi = new Eseye($authentication);
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Call the first page of the wallet journal, as we are always going to get at least one page.
|
||||
//If we have more pages, then we will continue through the while loop.
|
||||
try {
|
||||
$journals = $esi->page($page)
|
||||
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
}
|
||||
|
||||
//Decode the wallet from json into an array
|
||||
$wallet = json_decode($journals->raw, true);
|
||||
//For each journal entry, attempt to store it in the database.
|
||||
//The PutWalletJournal function checks to see if it's already in the database.
|
||||
foreach($wallet as $entry) {
|
||||
if($entry['amount'] > 0) {
|
||||
if($entry['ref_type'] == 'brokers_fee') {
|
||||
$market->InsertMarketTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'reprocessing_tax') {
|
||||
$reprocessing->InsertReprocessingTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'structure_gate_jump') {
|
||||
$jb->InsertJumpBridgeTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'player_donation' ||
|
||||
($entry['ref_type'] == 'corporation_account_withdrawal' && $entry['second_party_id'] == 98287666)) {
|
||||
$other->InsertPlayerDonation($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'industry_job_tax' && $entry['second_party_id'] == 98287666) {
|
||||
$industry->InsertStructureIndustryTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'office_rental_fee' && $entry['second_party_id'] == 98287666) {
|
||||
$office->InsertOfficeFee($entry, $corpId, $division);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function TokenInfo($charId) {
|
||||
//Get the ESI refresh token for the corporation to add a new wallet jouranls into the database
|
||||
//send the token and scope back to the calling function
|
||||
$token = EsiToken::where(['character_id' => $charId])->get(['refresh_token']);
|
||||
$scope = EsiScope::where(['character_id' => $charId, 'scope' => 'esi-wallet.read_corporation_wallets.v1'])->get(['scope']);
|
||||
|
||||
$data = [
|
||||
'token' => $token,
|
||||
'scope' => $scope,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function TokenNotFound($token, $scope, $charId) {
|
||||
if(!isset($token[0]->refresh_token) || !isset($scope[0]->scope)) {
|
||||
//Register a mail to be dispatched as a job
|
||||
$mail = new EveMail;
|
||||
$mail->sender = 93738489;
|
||||
$mail->subject = 'W4RP Services ESI API';
|
||||
$mail->body = 'You need to register an ESI API on the services site for esi-wallet.read_corporation_wallet.v1<br>This is also labeled Corporation Wallets';
|
||||
$mail->recipient = (int)$charId;
|
||||
$mail->recipient_type = 'character';
|
||||
$mail->save();
|
||||
|
||||
SendEveMailJob::dispatch($mail);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function GetPIMaterialsArray() {
|
||||
//Setup array for PI items
|
||||
$pi_items = [
|
||||
//R0 Materials
|
||||
'2073',
|
||||
'2667',
|
||||
'2268',
|
||||
'2270',
|
||||
'2272',
|
||||
'2286',
|
||||
'2287',
|
||||
'2288',
|
||||
'2305',
|
||||
'2306',
|
||||
'2307',
|
||||
'2308',
|
||||
'2309',
|
||||
'2310',
|
||||
'2311',
|
||||
//P1 Materials
|
||||
'2389',
|
||||
'2390',
|
||||
'2392',
|
||||
'2393',
|
||||
'2395',
|
||||
'2396',
|
||||
'2397',
|
||||
'2398',
|
||||
'2399',
|
||||
'2400',
|
||||
'2401',
|
||||
'3645',
|
||||
'3683',
|
||||
'3779',
|
||||
'9828',
|
||||
//P2 Materials
|
||||
'44',
|
||||
'2312',
|
||||
'2317',
|
||||
'2319',
|
||||
'2321',
|
||||
'2327',
|
||||
'2328',
|
||||
'2329',
|
||||
'2463',
|
||||
'3689',
|
||||
'3691',
|
||||
'3693',
|
||||
'3695',
|
||||
'3697',
|
||||
'3725',
|
||||
'3775',
|
||||
'3828',
|
||||
'9830',
|
||||
'9832',
|
||||
'9836',
|
||||
'9838',
|
||||
'9840',
|
||||
'9842',
|
||||
'15317',
|
||||
//P3 Materials
|
||||
'2344',
|
||||
'2345',
|
||||
'2346',
|
||||
'2348',
|
||||
'2349',
|
||||
'2351',
|
||||
'2352',
|
||||
'2354',
|
||||
'2358',
|
||||
'2360',
|
||||
'2361',
|
||||
'2366',
|
||||
'2367',
|
||||
'9834',
|
||||
'9846',
|
||||
'9848',
|
||||
'12836',
|
||||
'17136',
|
||||
'17392',
|
||||
'17898',
|
||||
'28974',
|
||||
//P4 Materials
|
||||
'2867',
|
||||
'2868',
|
||||
'2869',
|
||||
'2870',
|
||||
'2871',
|
||||
'2872',
|
||||
'2875',
|
||||
'2876',
|
||||
];
|
||||
|
||||
return $pi_items;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,155 +0,0 @@
|
||||
<?php
|
||||
|
||||
/** W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
use App\Models\Finances\JumpBridgeJournal;
|
||||
use App\Models\User\UserToCorporation;
|
||||
|
||||
class JumpBridgeTax {
|
||||
private $date;
|
||||
private $days;
|
||||
|
||||
public function __construct($days = null) {
|
||||
if($days === null) {
|
||||
$this->date = Carbon::now();
|
||||
$this->days = 0;
|
||||
} else {
|
||||
$this->date = Carbon::now()->subDays($days);
|
||||
$this->days = $days;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to insert journal entries into the database
|
||||
*/
|
||||
public function InsertJumpBridgeTax($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!JumpBridgeJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new JumpBridgeJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the corporations using the jump bridge over a given time period
|
||||
*/
|
||||
public function CorporationUsage() {
|
||||
//Make an array for corporations, and amounts
|
||||
$amounts = array();
|
||||
$characters = array();
|
||||
$data = array();
|
||||
$esi = new Esi();
|
||||
|
||||
//Get all of the parties which have utilized the jump bridge
|
||||
$parties = DB::table('jump_bridge_journal')
|
||||
->select('first_party_id')
|
||||
->groupBy('first_party_id')
|
||||
->whereTime('date', '>', $this->date)
|
||||
->get();
|
||||
|
||||
//Run through each party and assign them into a corporation, then add the corporation to the corporation array if they don't
|
||||
//exist in the array.
|
||||
foreach($parties as $party) {
|
||||
//If the entry in the database lookup table isn't found, add it.
|
||||
if(!CharacterToCorporation::where(['character_id' => $party->first_party_id])->exists()) {
|
||||
$character = $esi->GetCharacterData($party->first_party_id);
|
||||
$corporation = $esi->GetCorporationData($character->corporation_id);
|
||||
$char = new CharacterToCorporation;
|
||||
$char->character_id = $party->first_party_id;
|
||||
$char->character_name = $character->name;
|
||||
$char->corporation_id = $character->corporation_id;
|
||||
$char->corporation_name = $corporation->name;
|
||||
$char->save();
|
||||
}
|
||||
|
||||
//Perform the lookup and add the user into the corps array, and the ammount to the amount array
|
||||
$char = CharacterToCorporation::where(['character_id' => $party->first_party_id])->get();
|
||||
|
||||
//Find the amount utilized from the jump bridge by the character
|
||||
$isk = JumpBridgeJournal::where(['first_party_id' => $char->character_id])
|
||||
->whereBetween('date', [$this->date, $this->date->addDays(30)])
|
||||
->sum('amount');
|
||||
|
||||
//We have the character and isk amount, so we need to build an array with these two values as key value pairs.
|
||||
$data[$char->corporation_name] = $data[$char->corporation_name] + $isk;
|
||||
}
|
||||
|
||||
//Return the data
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the overall usage for statistics
|
||||
*/
|
||||
public function OverallTax() {
|
||||
|
||||
//Get the total usage
|
||||
$usage = JumpBridgeJournal::select('amount')
|
||||
->whereTime('date', '>', $this->date)
|
||||
->sum('amount');
|
||||
|
||||
//Return the usage
|
||||
return $usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific briddge usage statistics for overall usage
|
||||
*/
|
||||
public function JBOverallUsage($structure) {
|
||||
$usage = DB::table('jump_bridge_journal')
|
||||
->select('amount')
|
||||
->where('context_id', $structure)
|
||||
->sum('amount');
|
||||
|
||||
return $usage;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user