Compare commits
1218 Commits
dependabot
...
v1
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 |
13
.env
13
.env
@@ -10,8 +10,8 @@ DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=w4rpservices2
|
||||
DB_USERNAME=username
|
||||
DB_PASSWORD=password
|
||||
DB_USERNAME=minerva
|
||||
DB_PASSWORD=strtmage
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
@@ -33,19 +33,12 @@ 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_USERAGENT='W4RP Services'
|
||||
ESI_CALLBACK_URI='http://services.w4rp.space/callback'
|
||||
ESI_PRIMARY_CHAR=93738489
|
||||
ESI_ALLIANCE=99004116
|
||||
|
||||
EVEONLINE_CLIENT_ID=e5848fea3618427a8ee0dccb6a04fc62
|
||||
EVEONLINE_CLIENT_SECRET=TdnNGRM8RTNSifZdaIc9yHTTkYPgYEEXHRIbT6oY
|
||||
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,6 +1,9 @@
|
||||
/node_modules
|
||||
/logs
|
||||
.editorconfig
|
||||
/.editorconfig
|
||||
/cache
|
||||
/public/logs
|
||||
/public/logs/*
|
||||
worker.log
|
||||
/public/cache/*
|
||||
/.env
|
||||
.vscode
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Charts;
|
||||
|
||||
//Internal Library
|
||||
use ConsoleTVs\Charts\Classes\ChartJs\Chart;
|
||||
|
||||
class StructureFuelGauge extends Chart
|
||||
{
|
||||
/**
|
||||
* Initializes the chart.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Assets;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use DB;
|
||||
@@ -11,17 +11,9 @@ use App\Jobs\ProcessAssetsJob;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Assets\AssetHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Jobs\JobProcessAsset;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
class GetAssetsCommand extends Command
|
||||
{
|
||||
@@ -80,22 +72,10 @@ class GetAssetsCommand extends Command
|
||||
return null;
|
||||
}
|
||||
|
||||
// Disable all caching by setting the NullCache as the
|
||||
// preferred cache handler. By default, Eseye will use the
|
||||
// FileCache.
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
//Create the authentication container
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
|
||||
$esi = new Eseye($authentication);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
try {
|
||||
$assets = $esi->page(1)
|
||||
@@ -110,11 +90,7 @@ class GetAssetsCommand extends Command
|
||||
$pages = $assets->pages;
|
||||
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
$job = new JobProcessAsset;
|
||||
$job->charId = $charId;
|
||||
$job->corpId = $corpId;
|
||||
$job->page = $i;
|
||||
ProcessAssetsJob::dispatch($job)->onQueue('assets');
|
||||
ProcessAssetsJob::dispatch($charId, $corpId, $i)->onQueue('assets');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Corps;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use DB;
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Models
|
||||
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;
|
||||
//Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
class GetCorpsCommand extends Command
|
||||
{
|
||||
@@ -52,24 +52,29 @@ class GetCorpsCommand extends Command
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Create the ESI container
|
||||
$esi = new Eseye();
|
||||
//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(\Seat\Eseye\Exceptions\RequestFailedException $e){
|
||||
} catch(RequestFailedException $e){
|
||||
dd($e->getEsiResponse());
|
||||
}
|
||||
//Delete all of the entries in the AllianceCorps table
|
||||
DB::table('AllianceCorps')->delete();
|
||||
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(\Seat\Eseye\Exceptions\RequestFailedException $e) {
|
||||
} catch(RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
}
|
||||
$entry = new AllianceCorp;
|
||||
|
||||
@@ -1,10 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Data;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//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
|
||||
{
|
||||
/**
|
||||
@@ -40,5 +59,120 @@ class CleanStaleDataCommand extends Command
|
||||
{
|
||||
$command = new CommandHelper;
|
||||
$command->CleanJobStatusTable();
|
||||
|
||||
//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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
61
app/Console/Commands/Data/EmptyJumpBridges.php
Normal file
61
app/Console/Commands/Data/EmptyJumpBridges.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Data;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Service;
|
||||
use App\Models\Stock\Asset;
|
||||
|
||||
class EmptyJumpBridges extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services: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()
|
||||
{
|
||||
$task = new CommandHelper('EmptyJumpBridges');
|
||||
|
||||
//Add entry into the table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
Structure::truncate();
|
||||
Service::truncate();
|
||||
Asset::truncate();
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
56
app/Console/Commands/Data/PurgeCorpMoonLedgers.php
Normal file
56
app/Console/Commands/Data/PurgeCorpMoonLedgers.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Data;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//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()
|
||||
{
|
||||
$task = new CommandHelper('PurgeCorpLedgers');
|
||||
$task->SetStartStatus();
|
||||
|
||||
PurgeMoonLedgerJob::dispatch();
|
||||
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
58
app/Console/Commands/Eve/ItemPricesUpdateCommand.php
Normal file
58
app/Console/Commands/Eve/ItemPricesUpdateCommand.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Eve;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
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()
|
||||
{
|
||||
$task = new CommandHelper('ItemPriceUpdate');
|
||||
$task->SetStartStatus();
|
||||
|
||||
$moonHelper = new MoonCalc;
|
||||
$moonHelper->FetchNewPrices();
|
||||
|
||||
//ItemPricesUpdateJob::dispatch()->onQueue('default');
|
||||
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
//User Library
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\CorpMarketJournal;
|
||||
use App\Models\Finances\CorpMarketStructure;
|
||||
|
||||
class CorpFinances extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:CorpFinances';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get the corporation finances journal to get the market fees from the master wallet';
|
||||
|
||||
/**
|
||||
* 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('CorpFinances');
|
||||
|
||||
//Add entry into the table saying the jobs is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Setup the Finances container
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Get the corporations who have registered for structure markets
|
||||
$structures = CorpMarketStructure::all();
|
||||
|
||||
foreach($structures as $structure) {
|
||||
$pages = $finance->GetJournalPageCount(1, $structure->character_id);
|
||||
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
$job = new JobProcessCorpJournal;
|
||||
$job->division = 1;
|
||||
$job->charId = $structure->character_id;
|
||||
$job->corpId = $structure->corporation_id;
|
||||
$job->page = $i;
|
||||
ProcessCorpJournalJob::dispatch($job)->onQueue('journal');
|
||||
}
|
||||
}
|
||||
|
||||
//mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CorpMarketMail extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:MarketMail';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Send a mail about a market.';
|
||||
|
||||
/**
|
||||
* 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('CorpMarketMail');
|
||||
|
||||
//Add entry into the table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Finances;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
@@ -11,9 +11,6 @@ use App\Library\Finances\Helper\FinanceHelper;
|
||||
//Jobs
|
||||
use App\Jobs\ProcessWalletJournalJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Jobs\JobProcessWalletJournal;
|
||||
|
||||
class HoldingFinancesCommand extends Command
|
||||
{
|
||||
/**
|
||||
@@ -64,11 +61,15 @@ class HoldingFinancesCommand extends Command
|
||||
|
||||
//Dispatch a single job for each page to process
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
$job = new JobProcessWalletJournal;
|
||||
$job->division = 1;
|
||||
$job->charId = $config['primary'];
|
||||
$job->page = $i;
|
||||
ProcessWalletJournalJob::dispatch($job)->onQueue('journal');
|
||||
ProcessWalletJournalJob::dispatch(1, $config['primary'], $i)->onQueue('journal');
|
||||
}
|
||||
|
||||
//Get the total pages for the journal for the sov bills from the holding corporation
|
||||
$pages = $finance->GetJournalPageCount(6, $config['primary']);
|
||||
|
||||
//Dispatch a job for each page to process
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
ProcessWalletJournalJob::dispatch(6, $config['primary'], $i)->onQueue('journal');
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
|
||||
@@ -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)->onQueue('journal');
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
132
app/Console/Commands/Finances/SovBills.php
Normal file
132
app/Console/Commands/Finances/SovBills.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Finances;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessWalletJournalJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Finances\AllianceMarketTax;
|
||||
use App\Library\Finances\CorpMarketTax;
|
||||
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;
|
||||
use App\Library\Finances\SovBillExpenses;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
class SovBillsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:SovBills';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get the holding corps sov bills from wallet 6.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$sovBill = new SovBillExpenses;
|
||||
$esiHelper = new Esi;
|
||||
$finance = new FinanceHelper();
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('SovBills');
|
||||
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||
if($token == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Create an ESI authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Reference to see if the character is in our look up table for corporations and characters
|
||||
$char = $lookup->GetCharacterInfo($config['primary']);
|
||||
$corpId = $char->corporation_id;
|
||||
|
||||
//Get the total pages for the journal for the sov bills from the holding corporation
|
||||
$pages = $finance->GetJournalPageCount(6, $config['primary']);
|
||||
|
||||
//Try to figure it out from the command itself.
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
printf("Getting page: " . $i . "\n");
|
||||
|
||||
try {
|
||||
$journals = $esi->page($i)
|
||||
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => 6,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Decode the wallet from json into an array
|
||||
$wallet = json_decode($journals->raw, true);
|
||||
dd($wallet);
|
||||
foreach($wallet as $entry) {
|
||||
if($entry['ref_type'] == 'infrastructure_hub_maintenance' && $entry['first_party_id'] == 98287666) {
|
||||
$sovBill->InsertSovBillExpense($entry, $corpId, $division);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
129
app/Console/Commands/Flex/FlexStructureCommand.php
Normal file
129
app/Console/Commands/Flex/FlexStructureCommand.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Flex;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Flex\FlexStructure;
|
||||
use App\Models\Mail\SentMail;
|
||||
|
||||
class FlexStructureCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:FlexStructures';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Mail out reminder for flex structure bills';
|
||||
|
||||
/**
|
||||
* 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('FlexStructureMailer');
|
||||
//Add the entry into the jobs table saying the job has started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Create other variables
|
||||
$body = null;
|
||||
$delay = 5;
|
||||
|
||||
//Get today's date
|
||||
$today = Carbon::now();
|
||||
$today->second = 2;
|
||||
$today->minute = 0;
|
||||
$today->hour = 0;
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Get all of the contacts for the flex structures
|
||||
$contacts = FlexStructure::select('requestor_id')->orderBy('requestor_id')->get();
|
||||
|
||||
//For each of the contacts, send a reminder mail about the total of the structures they are paying for
|
||||
foreach($contacts as $contact) {
|
||||
//Get all of the structures for requestor
|
||||
$structures = FlexStructure::where([
|
||||
'requestor_id' => $contact->requestor_id,
|
||||
])->get();
|
||||
|
||||
//Totalize the total cost of everything
|
||||
$totalCost = $this->TotalizeCost($structures);
|
||||
|
||||
//Build the body of the mail
|
||||
$body = "Flex Structure Overhead Cost is due for the following structures:<br>";
|
||||
foreach($structures as $structure) {
|
||||
|
||||
$body .= "System: " . $structure->system . " - " . $structure->structure_type . ": " . $structure->structure_cost . " ISK<br>";
|
||||
}
|
||||
$body .= "Total Cost: " . number_format($totalCost, 2,".", ",");
|
||||
$body .= "Please remit payment to Spatial Forces by the 3rd of the month.<br>";
|
||||
$body .= "Sincerely,<br>";
|
||||
$body .= "Warped Intentions Leadership<br>";
|
||||
|
||||
//Dispatch the mail job
|
||||
$subject = "Warped Intentions Flex Structures Payment Due for " . $today->englishMonth;
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$structure->requestor_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
|
||||
//Increment the delay for the mail to not hit the rate limits
|
||||
$delay += 60;
|
||||
|
||||
//After the mail is dispatched, save the sent mail record
|
||||
$this->SaveSentRecord($config['primary'], $subject, $body, (int)$structure->requestor_id, 'character');
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
|
||||
private function TotalizeCost($structures) {
|
||||
//Declare the total cost
|
||||
$totalCost = 0.00;
|
||||
|
||||
foreach($structures as $structure) {
|
||||
$totalCost += $structure->structure_cost;
|
||||
}
|
||||
|
||||
return $totalCost;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Commands\Library;
|
||||
|
||||
//Internal Libraries
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
@@ -32,7 +31,7 @@ class CommandHelper {
|
||||
|
||||
public function SetStopStatus() {
|
||||
//Mark the job as finished
|
||||
DB::table('schedule_jobs')->where([
|
||||
ScheduleJob::where([
|
||||
'system_time' => $this->system_time,
|
||||
'job_name' => $this->job_name,
|
||||
])->update([
|
||||
@@ -41,7 +40,8 @@ class CommandHelper {
|
||||
}
|
||||
|
||||
public function CleanJobStatusTable() {
|
||||
DB::table('schedule_jobs')->where('system_time', '<', Carbon::now()->subMonths(3))->delete();
|
||||
//Delete old jobs
|
||||
ScheduleJob::where(['system_time', '<', Carbon::now()->subMonths(3)])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use DB;
|
||||
use Log;
|
||||
|
||||
//Job
|
||||
use App\Jobs\ProcessContractsJob;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Logistics\ContractsHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Jobs\JobProcessContracts;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
|
||||
class GetEveContractsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:GetContracts';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get contracts from a certain corporation';
|
||||
|
||||
/**
|
||||
* 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('GetContracts');
|
||||
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Setup the esi authentication container
|
||||
$config = config('esi');
|
||||
|
||||
//Declare some variables
|
||||
$charId = 2115439862;
|
||||
$corpId = 98606886;
|
||||
|
||||
//Esi Scope Check
|
||||
$esiHelper = new Esi();
|
||||
$contractScope = $esiHelper->HaveEsiScope($charId, 'esi-contracts.read_corporation_contracts.v1');
|
||||
|
||||
if($contractScope == false) {
|
||||
Log::critical('Scope check for esi-contracts.read_corporation_contracts.v1 failed.');
|
||||
return null;
|
||||
}
|
||||
|
||||
// Disable all caching by setting the NullCache as the
|
||||
// preferred cache handler. By default, Eseye will use the
|
||||
// FileCache.
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = EsiToken::where(['character_id' => $charId])->get(['refresh_token']);
|
||||
//Create the authentication container
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
]);
|
||||
|
||||
$esi = new Eseye($authentication);
|
||||
|
||||
try {
|
||||
$contracts = $esi->page(1)
|
||||
->invoke('get', '/corporations/{corporation_id}/contracts/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
} catch (RequestFailedException $e) {
|
||||
Log::critical("Failed to get the contracts list.");
|
||||
return null;
|
||||
}
|
||||
|
||||
$pages = $contracts->pages;
|
||||
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
$job = new JobProcessEveContracts;
|
||||
$job->charId = $charId;
|
||||
$job->corpId = $corpId;
|
||||
$job->page = $i;
|
||||
ProcessEveContractsJob::dispatch($job)->onQueue('default');
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,223 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
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;
|
||||
use App\Models\Mail\EveMail;
|
||||
|
||||
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();
|
||||
|
||||
//Create other variables
|
||||
$body = null;
|
||||
$delay = 5;
|
||||
|
||||
//Get today's date.
|
||||
$today = Carbon::now();
|
||||
$today->second = 2;
|
||||
$today->minute = 0;
|
||||
$today->hour = 0;
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
//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 = MoonRental::where(['Contact' => $contact->Contact])->get();
|
||||
|
||||
//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 " . number_format($cost, 2, ".", ",") . "<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 EveMail;
|
||||
$mail->sender = $config['primary'];
|
||||
$mail->subject = "Warped Intentions Moon Rental Payment Due for " . $today->englishMonth;
|
||||
$mail->body = $body;
|
||||
$mail->recipient = (int)$contact->Contact;
|
||||
$mail->recipient_type = 'character';
|
||||
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay($delay);
|
||||
//Increment the delay for the mail to not hit rate limits
|
||||
$delay += 30;
|
||||
|
||||
//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) {
|
||||
$previous = new Carbon($rental->Paid_Until);
|
||||
|
||||
if($today->greaterThan($previous)) {
|
||||
$this->UpdateNotPaid($rental);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
|
||||
private function UpdateNotPaid(MoonRental $rental) {
|
||||
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($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 = 'Moon: ' . $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon;
|
||||
array_push($list, $temp);
|
||||
}
|
||||
|
||||
//Return the list
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function GetRentalMoons($contact) {
|
||||
$rentals = MoonRental::where([
|
||||
'Contact' => $contact,
|
||||
])->get();
|
||||
dd($rentals);
|
||||
return $rentals;
|
||||
}
|
||||
|
||||
private function TotalizeMoonCost($rentals) {
|
||||
//Delcare variables and classes
|
||||
$moonCalc = new MoonCalc;
|
||||
$totalCost = 0.00;
|
||||
$price = null;
|
||||
|
||||
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->SpatialMoonsOnlyGooMailer($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';
|
||||
}
|
||||
}
|
||||
}
|
||||
90
app/Console/Commands/Moons/MoonsUpdateCommand.php
Normal file
90
app/Console/Commands/Moons/MoonsUpdateCommand.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Moons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Moons\FetchMoonLedgerJob;
|
||||
use App\Jobs\Commands\Moons\FetchMoonObserverJob;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
class MoonsUpdateCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:MoonUpdate';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update all of the moons registered for observers and ledgers.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$delay = 0;
|
||||
$characters = array();
|
||||
|
||||
//Create the new command helper container
|
||||
$task = new CommandHelper('MoonsUpdateCommand');
|
||||
//Set the task start status
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Get all of the characters who have registered structures for moon ledgers
|
||||
$miningChars = EsiScope::where([
|
||||
'scope' => 'esi-industry.read_corporation_mining.v1',
|
||||
])->get();
|
||||
|
||||
foreach($miningChars as $mChars) {
|
||||
$universe = EsiScope::where([
|
||||
'character_id' => $mChars->character_id,
|
||||
'scope' => 'esi-universe.read_structures.v1',
|
||||
])->first();
|
||||
|
||||
if($universe != null) {
|
||||
array_push($characters, $universe->character_id);
|
||||
}
|
||||
}
|
||||
|
||||
//Cycle through each of the character Ids which have the correct scopes,
|
||||
//and dispatch jobs accordingly.
|
||||
foreach($characters as $charId) {
|
||||
//Fetch all of the corp observers with the job dispatch
|
||||
FetchMoonObserverJob::dispatch($charId);
|
||||
//Fetch all of the corp ledgers with the job dispatch
|
||||
FetchMoonLedgerJob::dispatch($charId);
|
||||
}
|
||||
|
||||
//Set task done status
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\RentalMoons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\RentalMoons\SendMoonRentalPaymentReminderJob;
|
||||
use App\Jobs\Commands\RentalMoons\UpdateMoonRentalPaidState;
|
||||
|
||||
class AllianceRentalMoonInvoiceCreationCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:RentalInvoices';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Send out rental invoice reminders';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Set the task as started
|
||||
$task = new CommandHelper('AllianceRentalInvoice');
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Send the job for the invoice creation command
|
||||
SendMoonRentalPaymentReminderJob::dispatch()->delay(Carbon::now()->addSeconds(10));
|
||||
|
||||
//Update the paid state for the moons
|
||||
UpdateMoonRentalPaidState::dispatch()->delay(Carbon::now()->addSeconds(600));
|
||||
|
||||
//Set the task as stopped
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\RentalMoons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Job
|
||||
use App\Jobs\Commands\RentalMoons\UpdateMoonRentalPrice;
|
||||
|
||||
class AllianceRentalMoonUpdatePricingCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:UpdateRentalPrice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update alliance rental moon prices.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Setup the task handler
|
||||
$task = new CommandHelper('AllianceRentalMoonPriceUpdater');
|
||||
$task->SetStartStatus();
|
||||
|
||||
UpdateMoonRentalPrice::dispatch();
|
||||
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Structures;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
@@ -8,17 +8,13 @@ use Log;
|
||||
//Library
|
||||
use App\Library\Structures\StructureHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Commands\Library\CommandHelper;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
//Job
|
||||
use App\Jobs\ProcessStructureJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Jobs\JobProcessStructure;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
|
||||
@@ -70,7 +66,7 @@ class GetStructuresCommand extends Command
|
||||
$structures = null;
|
||||
|
||||
//ESI Scope Check
|
||||
$esiHelper = new Esi();
|
||||
$esiHelper = new Esi;
|
||||
$structureScope = $esiHelper->HaveEsiScope($charId, 'esi-universe.read_structures.v1');
|
||||
$corpStructureScope = $esiHelper->HaveEsiScope($charId, 'esi-corporations.read_structures.v1');
|
||||
|
||||
@@ -86,14 +82,9 @@ class GetStructuresCommand extends Command
|
||||
}
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = EsiToken::where(['character_id' => $charId])->get(['refresh_token']);
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
]);
|
||||
//Setup the ESI variable
|
||||
$esi = new Eseye($authentication);
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
//Create the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Set the current page
|
||||
$currentPage = 1;
|
||||
@@ -114,11 +105,7 @@ class GetStructuresCommand extends Command
|
||||
$totalPages = $structures->pages;
|
||||
|
||||
for($i = 1; $i <= $totalPages; $i++) {
|
||||
$job = new JobProcessStructure;
|
||||
$job->charId = $charId;
|
||||
$job->corpId = $corpId;
|
||||
$job->page = $currentPage;
|
||||
ProcessStructureJob::dispatch($job)->onQueue('structures');
|
||||
ProcessStructureJob::dispatch($charId, $corpId, $currentPage)->onQueue('structures');
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
133
app/Console/Commands/SystemRental/SystemRentalCommand.php
Normal file
133
app/Console/Commands/SystemRental/SystemRentalCommand.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\SystemRental;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Library
|
||||
use Command\Library\CommandHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Rentals\RentalSystem;
|
||||
use App\Models\Mail\SentMail;
|
||||
|
||||
class SystemRentalCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:SystemRentals';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Mail out bill for system rentals.';
|
||||
|
||||
/**
|
||||
* 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('SystemRentalMailer');
|
||||
//Add the entry into the jobs table saying the job has started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Create other variables
|
||||
$body = null;
|
||||
$delay = 30;
|
||||
|
||||
//Get today's date
|
||||
$today = Carbon::now();
|
||||
$today->second = 2;
|
||||
$today->minute = 0;
|
||||
$today->hour = 0;
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Get all of the contacts for the system rentals
|
||||
$contacts = RentalSystem::select('contact_id')->orderBy('contact_id')->get();
|
||||
|
||||
//For each of the contacts send a reminder mail about the total of the systems they are paying for
|
||||
foreach($contacts as $contact) {
|
||||
//Get all of the systems
|
||||
$systems = RentalSystem::where([
|
||||
'contact_id' => $contact->contact_id,
|
||||
])->get();
|
||||
|
||||
//Totalize the total cost of all of the systems
|
||||
$totalCost = $this->TotalizeCost($systems);
|
||||
|
||||
//Build the body of the mail
|
||||
$body = "System Rental Cost is due for the following systems:<br>";
|
||||
foreach($systems as $system) {
|
||||
$body .= $system->system_name . "<br>";
|
||||
}
|
||||
|
||||
//Create the rest of the email body
|
||||
$body .= "Total Cost: " . number_format($totalCost, 2, ".", ",");
|
||||
$body .= "Please remite payment to White Wolves Holding.<br>";
|
||||
$body .= "Sincerely,<br>";
|
||||
$body .= "Warped Intentions Leadership<br>";
|
||||
|
||||
//Fill in the subject
|
||||
$subject = "Warped Intentions System Rental Bill Due";
|
||||
|
||||
//Dispatch the mail job
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$contact->contact_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
|
||||
//Increase the delay for the next mail job
|
||||
$delay += 60;
|
||||
|
||||
//After the mail is dispatched, save the sent mail record
|
||||
$this->SaveSentRecord($config['primary'], $subject, $body, (int)$contact->contact_id, 'character');
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
|
||||
}
|
||||
|
||||
private function TotalizeCost($systems) {
|
||||
//Declare the starting total cost
|
||||
$totalCost = 0.00;
|
||||
|
||||
foreach($systems as $system) {
|
||||
$totalCost += $system->rental_cost;
|
||||
}
|
||||
|
||||
return $totalCost;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Users;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
//Libraries
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Wiki\WikiHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
@@ -20,6 +19,8 @@ use App\Models\Esi\EsiToken;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
use App\Models\Doku\DokuMember;
|
||||
use App\Models\Doku\DokuUser;
|
||||
|
||||
|
||||
/**
|
||||
@@ -60,8 +61,11 @@ class PurgeUsers extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup the esi variable
|
||||
$esi = new Eseye();
|
||||
$esi = $esiHelper->SetupEsiAuthentication();
|
||||
|
||||
//Get all of the users from the database
|
||||
$users = User::all();
|
||||
@@ -175,6 +179,21 @@ class PurgeUsers extends Command
|
||||
User::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
|
||||
EsiScope::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
|
||||
EsiToken::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
|
||||
//Delete the user from the wiki
|
||||
$wikiHelper = new WikiHelper;
|
||||
|
||||
//Get the uid from the wiki tables utilizing the character's name
|
||||
$uid = DokuUser::where(['name' => $user->name])->first();
|
||||
$wikiHelper->DeleteWikiUser($uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,23 @@ class Kernel extends ConsoleKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
Commands\GetCorpsCommand::class,
|
||||
Commands\UpdateMoonPriceCommand::class,
|
||||
Commands\HoldingFinancesCommand::class,
|
||||
Commands\MoonMailerCommand::class,
|
||||
Commands\PiTransactionsCommand::class,
|
||||
Commands\GetStructuresCommand::class,
|
||||
Commands\GetAssetsCommand::class,
|
||||
Commands\GetEveContractsCommand::class,
|
||||
Commands\PurgeUsers::class,
|
||||
Commands\Corps\GetCorpsCommand::class,
|
||||
Commands\Finances\HoldingFinancesCommand::class,
|
||||
Commands\Structures\GetStructuresCommand::class,
|
||||
Commands\Assets\GetAssetsCommand::class,
|
||||
Commands\Users\PurgeUsers::class,
|
||||
Commands\Flex\FlexStructureCommand::class,
|
||||
Commands\Data\EmptyJumpBridges::class,
|
||||
Commands\Finances\SovBillsCommand::class,
|
||||
Commands\Data\CleanStaleDataCommand::class,
|
||||
Commands\Moons\MoonsUpdateCommand::class,
|
||||
Commands\Data\PurgeCorpMoonLedgers::class,
|
||||
Commands\Eve\ItemPricesUpdateCommand::class,
|
||||
/**
|
||||
* Rental Moon Commands
|
||||
*/
|
||||
Commands\RentalMoons\AllianceRentalMoonInvoiceCreationCommand::class,
|
||||
Commands\RentalMoons\AllianceRentalMoonUpdatePricingCommand::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -36,35 +44,51 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('services:HoldingJournal')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:UpdateMoonPrice')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:GetCorps')
|
||||
->monthlyOn(1, '09:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:MoonMailer')
|
||||
->monthlyOn(1, '00:01')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:PiTransactions')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:GetStructures')
|
||||
->dailyAt('09:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:GetAssets')
|
||||
->hourlyAt('22')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:CleanData')
|
||||
->monthlyOn(1, '18:00');
|
||||
$schedule->command('services:PurgeUsers')
|
||||
->dailyAt('23:00')
|
||||
->withoutOverlapping();
|
||||
|
||||
//Horizon Graph Schedule
|
||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||
|
||||
/**
|
||||
* Rentals / Flex Schedule
|
||||
*/
|
||||
$schedule->command('services:UpdateRentalPrice')
|
||||
->dailyAt('11:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:FlexStructures')
|
||||
->monthlyOn(2, '00:01');
|
||||
|
||||
/**
|
||||
* Holding Corp Finance Schedule
|
||||
*/
|
||||
$schedule->command('services:HoldingJournal')
|
||||
->hourlyAt('45')
|
||||
->withoutOverlapping();
|
||||
|
||||
/**
|
||||
* Get Information Schedule
|
||||
*/
|
||||
$schedule->command('services:GetCorps')
|
||||
->monthlyOn(1, '09:00');
|
||||
$schedule->command('services:GetStructures')
|
||||
->dailyAt('09:00');
|
||||
$schedule->command('services:GetAssets')
|
||||
->hourlyAt('22');
|
||||
|
||||
/**
|
||||
* Purge Data Schedule
|
||||
*/
|
||||
$schedule->command('services:CleanData')
|
||||
->weekly(7, '11:00');
|
||||
$schedule->command('data:PurgeCorpLedgers')
|
||||
->monthly();
|
||||
$schedule->command('services:PurgeUsers')
|
||||
->dailyAt('23:00');
|
||||
|
||||
/**
|
||||
* Item Update Schedule
|
||||
*/
|
||||
$schedule->command('services:ItemPriceUpdate')
|
||||
->hourlyAt('30')
|
||||
->withoutOverlapping();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Ajax;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use DB;
|
||||
|
||||
use App\Models\User\User;
|
||||
|
||||
class LiveSearch extends Controller
|
||||
{
|
||||
public function index() {
|
||||
return view('ajax.live_search');
|
||||
}
|
||||
|
||||
public function action(Request $request) {
|
||||
if($request->ajax()) {
|
||||
$output = '';
|
||||
$query = $request->get('query');
|
||||
if($query != null) {
|
||||
$data = User::where('name', 'like', '%'.$query.'%')->get();
|
||||
} else {
|
||||
$data = User::all();
|
||||
}
|
||||
$total_row = $data->count();
|
||||
if($total_row > 0 ) {
|
||||
foreach($data as $row) {
|
||||
$output .= '
|
||||
<tr>
|
||||
<td>'.$row->name.'</td>
|
||||
<td>'.$row->character_id.'</td>
|
||||
</tr>';
|
||||
}
|
||||
} else {
|
||||
$output = '<tr><td align="center" colspan="5">No Data Found</td></tr>';
|
||||
}
|
||||
$data = array('table_data' => $output, 'total_data' => $total_row);
|
||||
|
||||
echo json_encode($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
//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,12 +2,19 @@
|
||||
|
||||
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;
|
||||
|
||||
//Library
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
@@ -16,10 +23,6 @@ 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
|
||||
{
|
||||
@@ -345,22 +348,25 @@ class LoginController extends Controller
|
||||
* @return text
|
||||
*/
|
||||
private function GetAccountType($refreshToken, $charId) {
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//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 = $esiHelper->GetCharacterData($charId);
|
||||
|
||||
//Get the corporation information
|
||||
$corp_info = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $character_info->corporation_id,
|
||||
]);
|
||||
$corp_info = $esiHelper->GetCorporationData($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\Lookups\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,207 +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;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\Contracts\Contract;
|
||||
use App\Models\Contracts\Bid;
|
||||
use App\Models\Contracts\AcceptedBid;
|
||||
use App\Models\Mail\EveMail;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
|
||||
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();
|
||||
|
||||
//Send a mail out to all of the people who can bid on a contract
|
||||
$this->NewContractMail();
|
||||
|
||||
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;
|
||||
|
||||
//Get the esi config
|
||||
$config = config('esi');
|
||||
|
||||
$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';
|
||||
|
||||
//Setup the mail job
|
||||
$mail = new EveMail;
|
||||
$mail->subject = $subject;
|
||||
$mail->recipient_type = 'character';
|
||||
$mail->recipient = $bid['character_id'];
|
||||
$mail->body = $body;
|
||||
$mail->sender = $config['primary'];
|
||||
//Dispatch the mail job
|
||||
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail');
|
||||
|
||||
//Tidy up the contract by doing a few things.
|
||||
$this->TidyContract($contract, $bid);
|
||||
|
||||
//Redirect back to the contract admin dashboard.
|
||||
return redirect('/contracts/admin/display')->with('success', 'Contract finalized. Mail has been sent to the queue for processing.');
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
private function NewContractMail() {
|
||||
//Get all the users with a specific permission set
|
||||
$users = UserPermission::where(['permission' => 'contract.canbid'])->get()->toArray();
|
||||
|
||||
//Get the esi config
|
||||
$config = config('esi');
|
||||
|
||||
//Cycle through the users with the correct permission and send a mail to go out with the queue system.
|
||||
foreach($users as $user) {
|
||||
$mail = new EveMail;
|
||||
$mail->sender = $config['primary'];
|
||||
$mail->subject = 'New Alliance Contract Available';
|
||||
$mail->recipient = $user['character_id'];
|
||||
$mail->recipient_type = 'character';
|
||||
$mail->body = "A new contract is available for the alliance contracting system. Please check out <a href='https://services.w4rp.space'>Services Site</a>.";
|
||||
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,322 +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\Models\User\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;
|
||||
$lowestChar = 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'];
|
||||
$lowestChar = $bid['character_name'];
|
||||
} else {
|
||||
if($bid['bid_amount'] < $lowestBid) {
|
||||
$lowestBid = $bid['bid_amount'];
|
||||
$lowestCorp = $bid['corporation_name'];
|
||||
$lowestChar = $bid['character_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;
|
||||
$contracts[$i]['lowestchar'] = $lowestChar;
|
||||
|
||||
//Reset the lowestBid back to null
|
||||
$lowestBid = null;
|
||||
}
|
||||
|
||||
//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\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\Contracts\SupplyChainBid;
|
||||
use App\Models\Contracts\SupplyChainContract;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
class SupplyChainController extends Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Renter');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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>";
|
||||
ProcessSendEveMailJob::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->onQueue('mail')->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;
|
||||
ProcessSendEveMailJob::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->onQueue('mail')->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,122 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Corps;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\NewLookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Character\BlacklistUser;
|
||||
|
||||
class BlacklistController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function AddToBlacklist(Request $request) {
|
||||
//Middleware needed for the function
|
||||
$this->middleware('permission:alliance.recruiter');
|
||||
|
||||
//Validate the user input
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'reason' => 'required',
|
||||
]);
|
||||
|
||||
//Create the library variable
|
||||
$lookup = new NewLookupHelper;
|
||||
|
||||
//See if the character is already on the list
|
||||
$count = BlacklistUser::where([
|
||||
'name' => $request->name,
|
||||
])->count();
|
||||
|
||||
//If the count is 0, then add the character to the blacklist
|
||||
if($count === 0) {
|
||||
//Get the character id from the universe end point
|
||||
$charId = $lookup->CharacterNameToId($request->name);
|
||||
|
||||
//Insert the character into the blacklist table
|
||||
BlacklistUser::insert([
|
||||
'character_id' => $charId,
|
||||
'name' => $request->name,
|
||||
'reason' => $request->reason,
|
||||
]);
|
||||
} else {
|
||||
//Return the view
|
||||
return view('blacklist.add')->with('error', 'Character is already on the black list.');
|
||||
}
|
||||
|
||||
//Return the view
|
||||
return view('blacklist.list')->with('success', 'Character added to the blacklist');
|
||||
}
|
||||
|
||||
public function RemoveFromBlacklist(Request $request) {
|
||||
//Middleware needed
|
||||
$this->middleware('permission:alliance.recruiter');
|
||||
|
||||
//Validate the input request
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
]);
|
||||
|
||||
//Delete the blacklist character
|
||||
BlacklistUser::where([
|
||||
'name' => $request->name,
|
||||
])->delete();
|
||||
|
||||
//Return the view
|
||||
return view('blacklist.list')->with('success', 'Character removed from the blacklist.');
|
||||
}
|
||||
|
||||
public function DisplayBlacklist() {
|
||||
//Middleware needed
|
||||
$this->middleware('permission:corp.recruiter');
|
||||
|
||||
//Get the entire blacklist
|
||||
$blacklist = BlacklistUser::all();
|
||||
|
||||
//Return the view with the data
|
||||
return view('blacklist.list')->with('blacklist', $blacklist);
|
||||
}
|
||||
|
||||
public function SearchInBlacklist(Request $request) {
|
||||
//Middleware needed
|
||||
$this->middleware('permission:corp.recruiter');
|
||||
|
||||
//Validate the input from the form
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
]);
|
||||
|
||||
//Get the data being requested
|
||||
$blacklistCount = BlacklistUser::where([
|
||||
'name' => $request->name,
|
||||
])->count();
|
||||
|
||||
//If the count for the blacklist is greater than 0, then get the details, and send it to the view
|
||||
if($blacklistCount > 0) {
|
||||
//Try to find the user in the blacklist
|
||||
$blacklist = BlacklistUser::where([
|
||||
'name' => $request->name,
|
||||
])->first();
|
||||
|
||||
//Send the data to the view
|
||||
return view('blacklist.list')->with('blacklist', $blacklist)
|
||||
->with('success', 'Name was 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', 'Name was not found on the blacklist.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,24 @@ namespace App\Http\Controllers\Dashboard;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
use App\Library\Wiki\WikiHelper;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\SRP\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\Doku\DokuGroupNames;
|
||||
use App\Models\Doku\DokuMember;
|
||||
use App\Models\Doku\DokuUser;
|
||||
|
||||
class AdminController extends Controller
|
||||
{
|
||||
@@ -23,6 +31,19 @@ class AdminController extends Controller
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
public function displayTestAdminDashboard() {
|
||||
return view('admin.dashboards.testdashboard');
|
||||
}
|
||||
|
||||
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 2 MONTH) ORDER BY date DESC');
|
||||
|
||||
return view('admin.dashboards.walletjournal')->with('journal', $journal);
|
||||
}
|
||||
|
||||
public function displayUsersPaginated() {
|
||||
//Declare array variables
|
||||
$user = array();
|
||||
@@ -57,42 +78,43 @@ class AdminController extends Controller
|
||||
return view('admin.dashboards.userspaged')->with('usersArr', $usersArr);
|
||||
}
|
||||
|
||||
public function displayUsers($page) {
|
||||
public function searchUsers(Request $request) {
|
||||
//Declare array variables
|
||||
$user = array();
|
||||
$permission = array();
|
||||
$userArr = array();
|
||||
$permString = null;
|
||||
|
||||
/**
|
||||
* For each user we want to build their name and permission set into one array
|
||||
* Having all of the data in one array will allow us to build the table for the admin page more fluently.
|
||||
* Example: userArr[0]['name'] = Minerva Arbosa
|
||||
* userArr[0]['role'] = W4RP
|
||||
* userArr[0]['permissions'] = ['admin', 'contract.admin', superuser]
|
||||
*/
|
||||
$usersTable = User::orderBy('name', 'asc')->get()->toArray();
|
||||
foreach($usersTable as $user) {
|
||||
$perms = UserPermission::where([
|
||||
'character_id' => $user['character_id'],
|
||||
])->get('permission')->toArray();
|
||||
//Validate the input from the form
|
||||
$this->validate($request, [
|
||||
'parameter' => 'required',
|
||||
]);
|
||||
|
||||
$tempUser['name'] = $user['name'];
|
||||
$tempUser['role'] = $user['user_type'];
|
||||
$tempUser['permissions'] = $perms;
|
||||
$usersArr = User::where('name', 'like', $request->parameter . "%")->paginate(50);
|
||||
|
||||
array_push($userArr, $tempUser);
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
//Get a user count for the view so we can do pagination
|
||||
$userCount = User::orderBy('name', 'asc')->count();
|
||||
//Set the amount of pages for the data
|
||||
$userPages = ceil($userCount / 50);
|
||||
$users = User::pluck('name')->all();
|
||||
|
||||
return view('admin.dashboards.users')->with('users', $users)
|
||||
->with('userArr', $userArr)
|
||||
->with('userCount', $userCount)
|
||||
->with('userPages', $userPages);
|
||||
return view('admin.dashboards.users.searched')->with('usersArr', $usersArr);
|
||||
}
|
||||
|
||||
public function displayAllowedLogins() {
|
||||
@@ -113,10 +135,6 @@ class AdminController extends Controller
|
||||
return view('admin.dashboards.allowed_logins')->with('entities', $entities);
|
||||
}
|
||||
|
||||
public function displayPurgeWiki() {
|
||||
return view('admin.dashboards.purge_wiki');
|
||||
}
|
||||
|
||||
public function displayTaxes() {
|
||||
//Declare variables needed for displaying items on the page
|
||||
$months = 3;
|
||||
@@ -131,6 +149,7 @@ class AdminController extends Controller
|
||||
/** 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
|
||||
@@ -138,13 +157,13 @@ class AdminController extends Controller
|
||||
//Get the srp actual pay out for the date range
|
||||
$srpActual[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetAllianceSRPActual($date['start'], $date['end']), 2, ".", ","),
|
||||
'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($tHelper->GetAllianceSRPLoss($date['start'], $date['end']), 2, ".", ","),
|
||||
'gross' => number_format($srpHelper->GetAllianceSRPLoss($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
//Get the pi taxes for the date range
|
||||
@@ -177,11 +196,6 @@ class AdminController extends Controller
|
||||
'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, ".", ","),
|
||||
];
|
||||
}
|
||||
|
||||
return view('admin.dashboards.taxes')->with('pis', $pis)
|
||||
@@ -190,7 +204,6 @@ class AdminController extends Controller
|
||||
->with('markets', $markets)
|
||||
->with('jumpgates', $jumpgates)
|
||||
->with('reprocessings', $reprocessings)
|
||||
->with('pigross', $pigross)
|
||||
->with('srpActual', $srpActual)
|
||||
->with('srpLoss', $srpLoss);
|
||||
}
|
||||
@@ -208,43 +221,47 @@ class AdminController extends Controller
|
||||
$permissions[$p->permission] = $p->permission;
|
||||
}
|
||||
|
||||
$roles = AvailableUserRole::all();
|
||||
|
||||
$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('permissions', $permissions)
|
||||
->with('role', $role)
|
||||
->with('roles', $roles);
|
||||
}
|
||||
|
||||
public function modifyUser(Request $request) {
|
||||
$type = $request->type;
|
||||
if(isset($request->permission)) {
|
||||
$permission = $request->permission;
|
||||
}
|
||||
if(isset($request->user)) {
|
||||
$user = $request->user;
|
||||
}
|
||||
public function modifyRole(Request $request) {
|
||||
$this->validate($request, [
|
||||
'user' => 'required',
|
||||
'role' => 'required|role!=None',
|
||||
]);
|
||||
|
||||
return redirect('/admin/dashboard')->with('error', 'Not implemented yet.');
|
||||
UserRole::where(['character_id' => $user])->update([
|
||||
'role' => $request->role,
|
||||
]);
|
||||
|
||||
return redirect('/admin/dashboard/users')->with('success', "User: " . $user . " has been modified to a new role: " . $request->role . ".");
|
||||
}
|
||||
|
||||
public function addPermission(Request $request) {
|
||||
//Get the user and permission from the form
|
||||
$user = $request->user;
|
||||
$character = $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']);
|
||||
$check = UserPermission::where(['character_id' => $character, 'permission' => $permission])->get(['permission']);
|
||||
|
||||
if(!isset($check[0]->permission)) {
|
||||
$perm = new UserPermission;
|
||||
$perm->character_id = $character[0]->character_id;
|
||||
$perm->character_id = $character;
|
||||
$perm->permission = $permission;
|
||||
$perm->save();
|
||||
|
||||
return redirect('/admin/dashboard')->with('success', 'User udpated!');
|
||||
return redirect('/admin/dashboard/users')->with('success', 'User udpated!');
|
||||
} else {
|
||||
return redirect('/admin/dashboard')->with('error', 'User not updated or already has the permission.');
|
||||
return redirect('/admin/dashboard/users')->with('error', 'User not updated or already has the permission.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +284,7 @@ class AdminController extends Controller
|
||||
//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.');
|
||||
return redirect('/admin/dashboard/users')->with('success', 'User deleted from the site.');
|
||||
}
|
||||
|
||||
public function addAllowedLogin(Request $request) {
|
||||
@@ -300,6 +317,7 @@ class AdminController extends Controller
|
||||
$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.');
|
||||
@@ -317,4 +335,188 @@ class AdminController extends Controller
|
||||
|
||||
return redirect('/admin/dashboard')->with('success', 'Entity removed from allowed login list.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the wiki dashboard for wiki functions
|
||||
*/
|
||||
public function displayWikiDashboard() {
|
||||
//Declare some variables
|
||||
$wikiUsers = array();
|
||||
$wikiGroups = array();
|
||||
|
||||
$tempUsers = DokuUser::all();
|
||||
$tempGroups = DokuGroupNames::all();
|
||||
$wikiMembership = DokuMember::all();
|
||||
|
||||
//Create a list of users based on id and name for the select form
|
||||
foreach($tempUsers as $temp) {
|
||||
$wikiUsers[$temp->id] = $temp->name;
|
||||
}
|
||||
|
||||
asort($wikiUsers);
|
||||
|
||||
foreach($tempGroups as $temp) {
|
||||
$wikiGroups[$temp->id] = $temp->gname;
|
||||
}
|
||||
|
||||
asort($wikiGroups);
|
||||
|
||||
return view('admin.dashboards.wiki')->with('wikiUsers', $wikiUsers)
|
||||
->with('wikiGroups', $wikiGroups)
|
||||
->with('wikiMembership', $wikiMembership);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a wiki user
|
||||
*/
|
||||
public function deleteWikiUser(Request $request) {
|
||||
$this->validate($request, [
|
||||
'user' => 'required',
|
||||
]);
|
||||
|
||||
//Declare helper variable
|
||||
$wikiHelper = new WikiHelper;
|
||||
|
||||
$wikiHelper->DeleteWikiUser($request->user);
|
||||
|
||||
redirect('/admin/dashboard/wiki')->with('success', 'User: ' . $request->user . ' has been deleted.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a group to a wiki user
|
||||
*/
|
||||
public function addWikiUserGroup(Request $request) {
|
||||
$this->validate($request, [
|
||||
'user' => 'required', //User Id number
|
||||
'groupname' => 'required', //Group Id number
|
||||
]);
|
||||
|
||||
//Declare some helper variables
|
||||
$wikiHelper = new WikiHelper;
|
||||
|
||||
//Check to see if the user has the group we are going to add first
|
||||
if($wikiHelper->UserHasGroup($request->user, $request->groupname)) {
|
||||
return redirect('/admin/dashboard/wiki')->with('error', 'User already has the group.');
|
||||
}
|
||||
|
||||
//Add the user to the wiki group
|
||||
$results = $wikiHelper->AddUserToGroup($request->user, $request->groupname);
|
||||
|
||||
//Redirect based on the results of the add user to group function
|
||||
if($results) {
|
||||
return redirect('/admin/dashboard/wiki')->with('success', 'User added to group for the wiki.');
|
||||
} else {
|
||||
return redirect('/admin/dashboard/wiki')->with('error', 'Failed at add user to group, or user was already part of the group.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a group from a wiki user
|
||||
*/
|
||||
public function removeWikiUserGroup(Request $request) {
|
||||
$this->validate($request, [
|
||||
'user' => 'required',
|
||||
'groupname' => 'required',
|
||||
]);
|
||||
|
||||
//Declare some helper variables
|
||||
$wikiHelper = new WikiHelper;
|
||||
|
||||
//Check to see if the user has the group we are going to remove them from
|
||||
if(!$wikiHelper->UserHasGroup($request->user, $request->groupname)) {
|
||||
return redirect('/admin/dashboard/wiki')->with('error', 'User does not have the group to remove.');
|
||||
}
|
||||
|
||||
//Remove the user from the wiki group
|
||||
$wikiHelper->RemoveUserFromGroup($request->user, $request->groupname);
|
||||
|
||||
return redirect('/admin/dashboard/wiki')->with('success', 'Removed user from group ' . $request->grouopname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a user from all wiki groups
|
||||
*/
|
||||
public function removeWikiUserAllGroups(Request $request) {
|
||||
$this->validate($request, [
|
||||
'user' => 'required',
|
||||
]);
|
||||
|
||||
//Declare variable
|
||||
$wikiHelper = new WikiHelper;
|
||||
|
||||
$wikiHelper->RemoveUserFromAllGroups($request->user);
|
||||
|
||||
return redirect('/admin/dashboard/wiki')->with('success', 'User successfully removed from all groups.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a new group for wiki user's to be added to
|
||||
*/
|
||||
public function insertNewWikiUserGroup(Request $request) {
|
||||
$this->validate($request, [
|
||||
'group' => 'required',
|
||||
'description' => 'required',
|
||||
]);
|
||||
|
||||
//Declare variable
|
||||
$wikiHelper = new WikiHelper;
|
||||
|
||||
$wikiHelper->AddNewUserGroup($request->group, $request->description);
|
||||
|
||||
return redirect('/admin/dashboard/wiki')->with('success', 'Added new user group.');
|
||||
}
|
||||
|
||||
public function purgeWikiUsers(Request $request) {
|
||||
$this->validate($request, [
|
||||
'admin' => 'required',
|
||||
]);
|
||||
|
||||
//Declare helper classes
|
||||
$lookup = new LookupHelper;
|
||||
$wikiHelper = new WikiHelper;
|
||||
|
||||
//Get all of the users from the database
|
||||
$users = User::all();
|
||||
|
||||
//Search the names and verify against the lookup table
|
||||
//to find the corporation and / or alliance they belong to.
|
||||
foreach($users as $user) {
|
||||
//Let's look up the character in the user table by their name.
|
||||
//If no name is found, then delete the user and have them start over with the wiki permissions
|
||||
$count = DokuUser::where(['name' => $user->name])->count();
|
||||
|
||||
//If the user is found, then check if they are allowed on the wiki.
|
||||
//If the the count == 0, then the user wasn't found on the wiki, so do nothing.
|
||||
if($count > 0) {
|
||||
//If the user is not allowed, then delete the user, otherwise, leave the user untouched
|
||||
if(!$wikiHelper->AllowedUser($user->name)) {
|
||||
$uid = $wikiHelper->GetUID($user->name);
|
||||
$wikiHelper->DeleteWikiUser($uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Get all of the DokuUsers and verify against the Users on the services page
|
||||
$users = DokuUser::all();
|
||||
|
||||
//Search the names and verify against the lookup table to find the corporation / alliance the user belongs to.
|
||||
foreach($users as $user) {
|
||||
//Lookup the character in the user table on the services page
|
||||
$count = User::where(['name' => $user->name])->count();
|
||||
|
||||
//If the user is found, then check if they are allowed on the wiki.
|
||||
//If the count == 0, then delete the user anyways
|
||||
if($count > 0 ) {
|
||||
//If the user is not allowed, then delete the user, otherwise, leave them alone.
|
||||
if(!$wikiHelper->AllowedUser($user->name)) {
|
||||
$uid = $wikiHelper->GetUID($user->name);
|
||||
$wikiHelper->DeleteWikiUser($uid);
|
||||
} else {
|
||||
$wikiHelper->DeleteWikiUser($user->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return redirect('/admin/dashboard/wiki')->with('success', 'Wiki has been purged.');
|
||||
}
|
||||
}
|
||||
|
||||
96
app/Http/Controllers/Dashboard/AdminDashboardController.php
Normal file
96
app/Http/Controllers/Dashboard/AdminDashboardController.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?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\Taxes\TaxesHelper;
|
||||
use App\Library\Wiki\WikiHelper;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\SRP\SRPHelper;
|
||||
|
||||
//Models
|
||||
|
||||
|
||||
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('moon.admin') || auth()->user()->hasPermission('srp.admin') || auth()->user()->hasPermission('contract.admin')) {
|
||||
//Do nothing and continue on
|
||||
} else {
|
||||
redirect('/dashboard');
|
||||
}
|
||||
|
||||
//Declare variables we will need
|
||||
$tHelper = new TaxesHelper();
|
||||
$srpHelper = new SRPHelper();
|
||||
$days = 30;
|
||||
$months = 1;
|
||||
$lava = new Lavacharts;
|
||||
|
||||
//Get the dates for the information being requested
|
||||
$dates = $tHelper->GetTimeFrameInMonths($months);
|
||||
|
||||
//Get the data for the sov expenses for a graph
|
||||
|
||||
//Setup the charts
|
||||
//Setup the chart to be able the show the categories for income
|
||||
/*
|
||||
$iChart = $lava->DataTable();
|
||||
$iChart->addStringColumn('Categories')
|
||||
->addNumberColumn('ISK')
|
||||
->addRow(['pi', $pi])
|
||||
->addRow(['industry', $industry])
|
||||
->addRow(['reprocessing', $reprocessing])
|
||||
->addRow(['offices', $office])
|
||||
->addRow(['industry', $industry])
|
||||
->addRow(['market', $market])
|
||||
->addRow(['gate', $gate])
|
||||
->addRow(['iBuyback', $iBuyback])
|
||||
->addRow(['renters', $renters])
|
||||
->addRow(['ops', $ops]);
|
||||
*/
|
||||
|
||||
//Setup the chart to be able to show the categories for expenses
|
||||
/*
|
||||
$eChart = $lava->DataTable();
|
||||
$eCjart->addStringColumn('Categories')
|
||||
->addNumberColumn('ISK')
|
||||
->addRow(['sov', $sovBills])
|
||||
->addRow(['srp', $srpActual])
|
||||
->addRow(['maintenance', $maintenance])
|
||||
->addRow(['wardecs', $wardecs])
|
||||
->addRow(['fcs', $fcs])
|
||||
->addRow(['keepstar_fuel', $keepstarFuel])
|
||||
->addRow(['fortizar_fuel', $fortizarFuel])
|
||||
->addRow(['astrahus_fuel', $astrahusFuel])
|
||||
->addRow(['sotiyo_fuel', $sotiyoFuel])
|
||||
->addRow(['azbel_fuel', $azbelFuel])
|
||||
->addRow(['raitaru_fuel', $raitaruFuel])
|
||||
->addRow(['beacon_fuel', $beaconFuel])
|
||||
->addRow(['bridge_fuel', $bridgeFuel])
|
||||
->addRow(['jammer_fuel', $jammerFuel]);
|
||||
*/
|
||||
return view('admin.dashboards.dashboard');
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiScope;
|
||||
@@ -49,9 +50,6 @@ class DashboardController extends Controller
|
||||
'main_id' => auth()->user()->character_id,
|
||||
])->count();
|
||||
|
||||
//Temporary Measure to keep the page working properly
|
||||
//$altCount = 0;
|
||||
|
||||
//If the alt count is greater than 0 get all of the alt accounts
|
||||
if($altCount > 0) {
|
||||
$alts = UserAlt::where([
|
||||
|
||||
400
app/Http/Controllers/Dashboard/StatisticsController.php
Normal file
400
app/Http/Controllers/Dashboard/StatisticsController.php
Normal file
@@ -0,0 +1,400 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\SRP\SRPHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\Doku\DokuGroupNames;
|
||||
use App\Models\Doku\DokuMember;
|
||||
use App\Models\Doku\DokuUser;
|
||||
use App\Models\SRP\SrpFleetType;
|
||||
use App\Models\SRP\SRPShip;
|
||||
use App\Models\SRP\SrpShipType;
|
||||
use App\Models\SRP\SrpPayout;
|
||||
|
||||
|
||||
class StatisticsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Jump Bridge Statistics
|
||||
*/
|
||||
public function displayJumpBridgeStatistics() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$lava = new Lavacharts;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Taxes Statistics
|
||||
*/
|
||||
public function displayTaxes() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare variables needed for displaying items on the page
|
||||
$months = 3;
|
||||
$pi = array();
|
||||
$industry = array();
|
||||
$reprocessing = array();
|
||||
$office = array();
|
||||
$corpId = 98287666;
|
||||
$srpActual = array();
|
||||
$srpLoss = 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, ".", ","),
|
||||
];
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display wiki statistics
|
||||
*/
|
||||
public function displayWikiStatistics() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display SRP Statistics
|
||||
*/
|
||||
public function displaySRPStatistics() {
|
||||
$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);
|
||||
}
|
||||
}
|
||||
148
app/Http/Controllers/Flex/FlexAdminController.php
Normal file
148
app/Http/Controllers/Flex/FlexAdminController.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Flex;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Flex\FlexStructure;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
class FlexAdminController extends Controller
|
||||
{
|
||||
//Constructor
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display all active flex structures and
|
||||
* the information regarding the flex structure
|
||||
*/
|
||||
public function displayFlexStructures() {
|
||||
//Get the structures from the database
|
||||
$structures = FlexStructure::all();
|
||||
|
||||
//Return the view with the data
|
||||
return view('flex.list')->with('structures', $structures);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display form for adding new flex structure
|
||||
*/
|
||||
public function displayAddFlexStructure() {
|
||||
return view('flex.add');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to add new flex structure to the database
|
||||
*/
|
||||
public function addFlexStructure(Request $request) {
|
||||
$this->validate($request, [
|
||||
'requestor_name' => 'required',
|
||||
'requestor_corp_name' => 'required',
|
||||
'system' => 'required',
|
||||
'structure_type' => 'required',
|
||||
'structure_cost' => 'required',
|
||||
]);
|
||||
|
||||
//Delcare variables and classes
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//From the character name find the character id
|
||||
$charId = $lookup->CharacterNameToId($request->requestor_name);
|
||||
|
||||
//From the corporation name find the corporation id
|
||||
$corpId = $lookup->CorporationNameToId($request->requestor_corp_name);
|
||||
|
||||
//From the system name find the system id
|
||||
$systemId = $lookup->SystemNameToId($request->system);
|
||||
|
||||
//Create the database model
|
||||
$flex = new FlexStructure;
|
||||
$flex->requestor_id = $charId;
|
||||
$flex->requestor_name = $request->requestor_name;
|
||||
$flex->requestor_corp_id = $corpId;
|
||||
$flex->requestor_corp_name = $request->requestor_corp_name;
|
||||
$flex->system_id = $systemId;
|
||||
$flex->system = $request->system;
|
||||
$flex->structure_type = $request->structure_type;
|
||||
$flex->structure_cost = $request->structure_cost;
|
||||
if(isset($request->paid_until)) {
|
||||
$flex->paid_until = $request->paid_until;
|
||||
}
|
||||
$flex->save();
|
||||
|
||||
return redirect('/flex/display')->with('success', 'Flex Structure Added.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to update paid until section of the flex structure in the database
|
||||
*/
|
||||
public function updateFlexStructure(Request $request) {
|
||||
$this->validate($request, [
|
||||
'paid_until' => 'required',
|
||||
'requestor_id' => 'required',
|
||||
'requestor_corp_id' => 'required',
|
||||
'system_id' => 'required',
|
||||
'structure_type' => 'required',
|
||||
]);
|
||||
|
||||
FlexStructure::where([
|
||||
'requestor_id' => $request->requestor_id,
|
||||
'requestor_corp_id' => $request->requestor_corp_id,
|
||||
'system_id' => $request->system_id,
|
||||
'structure_type' => $request->structure_type,
|
||||
])->update([
|
||||
'paid_until' => $request->paid_until,
|
||||
]);
|
||||
|
||||
return redirect('/flex/display')->with('success', 'Flex Structure Updated.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Funciton to remove flex structure from the database
|
||||
*/
|
||||
public function removeFlexStructure(Request $request) {
|
||||
$this->validate($request, [
|
||||
'requestor_id' => 'required',
|
||||
'requestor_corp_id' => 'required',
|
||||
'system_id' => 'required',
|
||||
'structure_type' => 'required',
|
||||
]);
|
||||
|
||||
$count = FlexStructure::where([
|
||||
'requestor_id' => $request->requestor_id,
|
||||
'requestor_corp_id' => $request->requestor_corp_id,
|
||||
'system_id' => $request->system_id,
|
||||
'structure_type' => $request->structure_type,
|
||||
])->count();
|
||||
|
||||
if($count > 0) {
|
||||
FlexStructure::where([
|
||||
'requestor_id' => $request->requestor_id,
|
||||
'requestor_corp_id' => $request->requestor_corp_id,
|
||||
'system_id' => $request->system_id,
|
||||
'structure_type' => $request->structure_type,
|
||||
])->delete();
|
||||
|
||||
return redirect('/flex/display')->with('success', 'Flex Structure Entry Removed.');
|
||||
} else {
|
||||
return redirect('/flex/display')->with('error', 'Could not find flex structure to delete.');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Fuel;
|
||||
namespace App\Http\Controllers\Logistics;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
@@ -23,7 +23,7 @@ class FuelController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:logistics.manager');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function displayStructures() {
|
||||
@@ -80,8 +80,7 @@ class FuelController extends Controller
|
||||
],
|
||||
]);
|
||||
|
||||
return view('logistics.display.fuel')->with('jumpGates', $jumpGates)
|
||||
return view('logistics.fuel')->with('jumpGates', $jumpGates)
|
||||
->with('lava', $lava);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,154 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Logistics;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
|
||||
//Models
|
||||
use App\Models\Contracts\EveContract;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
class LogisticsController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display available contracts
|
||||
*/
|
||||
public function displayLogisticsContracts() {
|
||||
$this->middelware('permissions:logistics.courier');
|
||||
|
||||
//Get the non-accepted contracts
|
||||
$openCount == EveContract::where(['status' => 'outstanding'])->count();
|
||||
$open = EveContract::where([
|
||||
'status' => 'outstanding',
|
||||
])->get();
|
||||
|
||||
$inProgressCount = EveContract::where(['status' => 'in_progress'])->count();
|
||||
$inProgress = EveContract::where([
|
||||
'status' => 'in_progress',
|
||||
])->get();
|
||||
|
||||
$finishedCount = EveContract::where(['status' => 'finished'])->count();
|
||||
$finished = EveContract::where([
|
||||
'status' => 'finished',
|
||||
])->get();
|
||||
|
||||
$totalCount = $openCount + $inProgressCount + $finishedCount;
|
||||
|
||||
//Fuel Gauge Chart Declarations
|
||||
$lava = new Lavacharts;
|
||||
|
||||
$openChart = $lava->DataTable();
|
||||
$openChart->addStringColumn('Contracts')
|
||||
->addNumberColumn('Number')
|
||||
->addRow(['Open Contracts', $openCount]);
|
||||
|
||||
$lava->GaugeChart('Open Contracts', $openChart, [
|
||||
'width' => 300,
|
||||
'greenFrom' => 0,
|
||||
'greenTo' => 10,
|
||||
'yellowFrom' => 10,
|
||||
'yellowTo', 30,
|
||||
'redFrom' => 30,
|
||||
'redTo' => 100,
|
||||
'majorTicks' => [
|
||||
'Normal',
|
||||
'Delayed',
|
||||
'Backed Up',
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
return view('logistics.display.contracts')->with('open', $open)
|
||||
->with('inProgress', $inProgress)
|
||||
->with('finished', $finished)
|
||||
->with('openCount', $openCount)
|
||||
->with('inProgressCount', $inProgressCount)
|
||||
->with('finishedCount', $finishedCount)
|
||||
->with('totalCount', $totalCount)
|
||||
->with('lava', $lava);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to calculate details needing to be set for contracts
|
||||
*/
|
||||
public function displayContractForm() {
|
||||
//Declare some variables
|
||||
$route = LogisticsRoute::pluck('name');
|
||||
|
||||
return view('logistics.display.courierform')->with('route', $route);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to calculate details needing to be set for contracts
|
||||
*/
|
||||
public function displayContractDetails(Request $request) {
|
||||
$startSystem = null;
|
||||
$endSystem = null;
|
||||
$reward = null;
|
||||
$okVolume = null;
|
||||
$corporation = null;
|
||||
|
||||
$this->validate($request, [
|
||||
'route' => 'required',
|
||||
'volume' => 'required',
|
||||
'collateral' => 'required',
|
||||
]);
|
||||
|
||||
//Sanitize the collateral string as we want
|
||||
$collateral = str_replace(' ISK', '', $request->collateral);
|
||||
$collateral = str_replace(',', '', $collateral);
|
||||
$collateral = floatval($collateral);
|
||||
|
||||
$volume = $request->volume;
|
||||
|
||||
$route = LogisticsRoute::where([
|
||||
'name'=> $request->route,
|
||||
])->get();
|
||||
|
||||
if($routeCount == 0) {
|
||||
$startSystem = 'N/A';
|
||||
$endSystem = 'N/A';
|
||||
} else {
|
||||
//Check the volume of the contract
|
||||
if($volume > $route->max_size) {
|
||||
$okVolume = false;
|
||||
} else {
|
||||
$okVolume = true;
|
||||
}
|
||||
|
||||
//Compose the route to be displayed
|
||||
$tempSystem = explode(' -> ', $request->route);
|
||||
$startSystem = $tempSystem[0];
|
||||
$endSystem = $tempSystem[1];
|
||||
|
||||
if($startSystem == 'Jita' || $endSystem == 'Jita') {
|
||||
$corporation = 'Infernal Armada';
|
||||
} else {
|
||||
$corporation = 'Inmate Logistics';
|
||||
}
|
||||
|
||||
//Calculate the route parameters
|
||||
$reward = ($route->price_per_m3 * $volume) + ( $collateral * 1.02);
|
||||
}
|
||||
|
||||
return view('logistics.display.courier')->with('okVolume', $okVolume)
|
||||
->with('collateral', $collateral)
|
||||
->with('reward', $reward)
|
||||
->with('startSystem', $startSystem)
|
||||
->with('endSystem', $endSystem)
|
||||
->with('corporation', $corporation);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Logistics;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Log;
|
||||
|
||||
//Models
|
||||
use App\Models\Logistics\AnchorStructure;
|
||||
|
||||
class StructureRequestAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:fc.team');
|
||||
}
|
||||
|
||||
public function displayRequests() {
|
||||
$reqs = AnchorStructure::all();
|
||||
|
||||
return view('structurerequest.display.structurerequests')->with('reqs', $reqs);
|
||||
}
|
||||
|
||||
public function deleteRequest(Request $request) {
|
||||
$this->validate($request, [
|
||||
'id' => 'required',
|
||||
]);
|
||||
|
||||
AnchorStructure::where([
|
||||
'id' => $request->id,
|
||||
])->delete();
|
||||
|
||||
return redirect('/structures/display/requests');
|
||||
}
|
||||
}
|
||||
@@ -5,27 +5,31 @@ namespace App\Http\Controllers\Logistics;
|
||||
//Internal Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Library Helpers
|
||||
use App\Library\Lookups\NewLookupHelper;
|
||||
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Logistics\AnchorStructure;
|
||||
use App\Models\User\UserPermission;
|
||||
|
||||
class StructureRequestController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function displayForm() {
|
||||
return view('structurerequest.requeststructure');
|
||||
}
|
||||
|
||||
public function storeForm() {
|
||||
public function storeForm(Request $request) {
|
||||
$this->validate($request, [
|
||||
'corporation_name' => 'required',
|
||||
'system' => 'required',
|
||||
@@ -35,7 +39,9 @@ class StructureRequestController extends Controller
|
||||
'requester' => 'required',
|
||||
]);
|
||||
|
||||
$lookup = new NewLookupHelper;
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
$config = config('esi');
|
||||
|
||||
$requesterId = $lookup->CharacterNameToId($request->requester);
|
||||
$corporationId = $lookup->CorporationNameToId($request->corporation_name);
|
||||
@@ -51,24 +57,27 @@ class StructureRequestController extends Controller
|
||||
'requester' => $request->requester,
|
||||
]);
|
||||
|
||||
return redirect('/structures/display/requests');
|
||||
}
|
||||
//Send a mail out to the FC Team
|
||||
$fcTeam = UserPermission::where([
|
||||
'permission' => 'fc.team',
|
||||
])->get();
|
||||
|
||||
public function displayRequests() {
|
||||
$reqs = AnchorStructure::all();
|
||||
//Set the mail delay
|
||||
$delay = 30;
|
||||
|
||||
return view('structurerequest.display.structurerequests')->with('reqs', $reqs);
|
||||
}
|
||||
foreach($fcTeam as $fc) {
|
||||
$body = "Structure Anchor Request has been entered.<br>";
|
||||
$body .= "Please check the W4RP Services Site for the structure information.<br>";
|
||||
$body .= "<br>Sincerely,<br>";
|
||||
$body .= "Warped Intentions Leadership<br>";
|
||||
|
||||
public function deleteRequest($request) {
|
||||
$this->validate($request, [
|
||||
'id' => 'required',
|
||||
]);
|
||||
//Dispatch the mail job
|
||||
$subject = "New Structure Anchor Request";
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$fc->character_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
|
||||
AnchorStructure::where([
|
||||
'id' => $request->id,
|
||||
])->delete();
|
||||
$delay += 30;
|
||||
}
|
||||
|
||||
return redirect('/structures/display/requests');
|
||||
return redirect('/dashboard')->with('success', 'Structure request successfully submitted.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Market;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Finances\CorpMarketJournal;
|
||||
use App\Models\Finances\CorpMarketStructure;
|
||||
|
||||
class MarketController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:structure.market');
|
||||
}
|
||||
|
||||
public function displayAddMarketTax() {
|
||||
return view('market.add.display');
|
||||
}
|
||||
|
||||
public function storeAddMarketTax(Request $request) {
|
||||
$this->validate($request, [
|
||||
'tax' => 'required',
|
||||
]);
|
||||
|
||||
$charId = auth()->user()->getId();
|
||||
|
||||
//Declare the esi helper
|
||||
$esiHelper = new Esi;
|
||||
//Create the esi container to get the character's public information
|
||||
$esi = new Eseye();
|
||||
try {
|
||||
$charInfo = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestExceptionFailed $e) {
|
||||
return redirect('/market/add')->with('erorr', 'Failed to get character info.');
|
||||
}
|
||||
|
||||
$ratio = $request->tax / 2.5;
|
||||
|
||||
$corpMarket = new CorpMarketStructure;
|
||||
$corpMarket->character_id = $charId;
|
||||
$corpMarket->corporation_id = $charInfo->corporation_id;
|
||||
$corpMarket->tax = $request->tax;
|
||||
$corpMarket->ratio = $ratio;
|
||||
$corpMarket->save();
|
||||
|
||||
return redirect('/dahsboard')->with('success', 'Market structure recorded.');
|
||||
}
|
||||
|
||||
public function displayTaxes() {
|
||||
$charId = auth()->user()->getId();
|
||||
|
||||
$esi = new Eseye();
|
||||
try {
|
||||
$charInfo = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestExceptionFailed $e) {
|
||||
return redirect('/market/add')->with('erorr', 'Failed to get character info.');
|
||||
}
|
||||
|
||||
//Get the total taxes from the database for each of the 3 months in the past
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,50 +6,234 @@ namespace App\Http\Controllers\Moons;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Log;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Service;
|
||||
use App\Models\Lookups\ItemLookup;
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Moon\RentalMoon;
|
||||
use App\Models\Moon\CorpObserversRegistered;
|
||||
use App\Models\Moon\CorpMoonObserver;
|
||||
|
||||
class MoonLedgerController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:corp.lead');
|
||||
}
|
||||
|
||||
public function displaySelection() {
|
||||
public function displayMoonLedgerNew() {
|
||||
|
||||
}
|
||||
|
||||
public function displayMoonLedger() {
|
||||
//Declare variables
|
||||
$structures = array();
|
||||
$miningLedgers = array();
|
||||
$tempMiningLedger = array();
|
||||
$tempMining = array();
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
$response = null;
|
||||
$structureInfo = null;
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope(auth()->user()->getId(), 'esi-industry.read_corporation_mining.v1')) {
|
||||
return redirect('/dashboard')->with('error', 'Need to add scopes for esi-industry.read_corporation_mining.v1');
|
||||
} else {
|
||||
if(!$esiHelper->HaveEsiScope(auth()->user()->getId(), 'esi-universe.read_structures.v1')) {
|
||||
return redirect('/dashboard')->with('error', 'Need to add scope for esi-universe.read_structures.v1');
|
||||
}
|
||||
}
|
||||
|
||||
//Get the refresh token if scope checks have passed
|
||||
$refreshToken = $esiHelper->GetRefreshToken(auth()->user()->getId());
|
||||
|
||||
return view('moons.ledger.displayselect')->with('structures', $structures);
|
||||
//Setup the esi container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Get the character data from the lookup table if possible or esi
|
||||
$character = $lookup->GetCharacterInfo(auth()->user()->getId());
|
||||
|
||||
//Try to get the mining observers for the corporation from esi
|
||||
try {
|
||||
$responses = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//If an exception has occurred for some reason redirect back to the dashboard with an error message
|
||||
return redirect('/dashboard')->with('error', 'Failed to get mining structures.');
|
||||
}
|
||||
|
||||
//For each mining observer, let's build the array of data to show on the page
|
||||
foreach($responses as $response) {
|
||||
//Try to get the structure information from esi
|
||||
try {
|
||||
$structureInfo = $esi->invoke('get', '/universe/structures/{structure_id}/', [
|
||||
'structure_id' => $response->observer_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//If an exception has occurred, then do nothing
|
||||
}
|
||||
|
||||
//We don't really care about the key, but it is better than just 0 through whatever number
|
||||
$structures[$response->observer_id] = $structureInfo->name;
|
||||
}
|
||||
|
||||
//For each of the structures we want to address it by it's key value pair.
|
||||
//This will allow us to do some interesting things in the display.
|
||||
foreach($structures as $key => $value) {
|
||||
try {
|
||||
$ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
'observer_id' => $key,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
$ledgers = null;
|
||||
}
|
||||
|
||||
if($ledgers != null) {
|
||||
foreach($ledgers as $ledger) {
|
||||
//Declare a variable that will need to be cleared each time the foreach processes
|
||||
$tempArray = array();
|
||||
|
||||
//Get the character information from the character id
|
||||
$charInfo = $lookup->GetCharacterInfo($ledger->character_id);
|
||||
//Get the corp ticker
|
||||
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||
//Get the ore name from the type id
|
||||
$ore = $lookup->ItemIdToName($ledger->type_id);
|
||||
|
||||
//We only want to push the mining ledger entry into the array if it matches
|
||||
//the date within 30 days
|
||||
$sortTime = Carbon::now()->subDays(30);
|
||||
$current = Carbon::createFromFormat('Y-m-d', $ledger->last_updated);
|
||||
if($current->greaterThanOrEqualTo($sortTime)) {
|
||||
array_push($miningLedgers, [
|
||||
'structure' => $value,
|
||||
'character' => $charInfo->name,
|
||||
'corpTicker' => $corpInfo->ticker,
|
||||
'ore' => $ore,
|
||||
'quantity' => $ledger->quantity,
|
||||
'updated' => $ledger->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return view('moons.ledger.displayledger')->with('miningLedgers', $miningLedgers)
|
||||
->with('structures', $structures);
|
||||
}
|
||||
|
||||
public function displayLedger(Request $request) {
|
||||
//Validate the request
|
||||
$this->validate($request, [
|
||||
'id' => 'required',
|
||||
]);
|
||||
|
||||
public function displayRentalMoonLedger() {
|
||||
//Declare variables
|
||||
$structures = array();
|
||||
$miningLedgers = array();
|
||||
$tempMiningLedger = array();
|
||||
$tempMining = array();
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
$response = null;
|
||||
$structureInfo = null;
|
||||
|
||||
//Create the authentication container for ESI, and check for the correct scopes
|
||||
//Get the configuration for the main site
|
||||
$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.');
|
||||
} 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.');
|
||||
}
|
||||
}
|
||||
|
||||
//Get the refresh token if scope checks have passed
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
|
||||
//Setup the esi container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Get the character data from the lookup table if possible or esi
|
||||
$character = $lookup->GetCharacterInfo($config['primary']);
|
||||
|
||||
//Try to get the mining observers for the corporation from esi
|
||||
try {
|
||||
$responses = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//If an exception has occurred for some reason redirect back to the dashboard with an error message
|
||||
return redirect('/dashboard')->with('error', 'Failed to get mining structures.');
|
||||
}
|
||||
|
||||
//For each mining observer, let's build the array of data to show on the page
|
||||
foreach($responses as $response) {
|
||||
//Try to get the structure information from esi
|
||||
try {
|
||||
$structureInfo = $esi->invoke('get', '/universe/structures/{structure_id}/', [
|
||||
'structure_id' => $response->observer_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//If an exception has occurred, then do nothing
|
||||
}
|
||||
|
||||
//We don't really care about the key, but it is better than just 0 through whatever number
|
||||
$structures[$response->observer_id] = $structureInfo->name;
|
||||
}
|
||||
|
||||
//For each of the structures we want to address it by it's key value pair.
|
||||
//This will allow us to do some interesting things in the display.
|
||||
foreach($structures as $key => $value) {
|
||||
try {
|
||||
$ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
'observer_id' => $key,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
$ledgers = null;
|
||||
}
|
||||
|
||||
if($ledgers != null) {
|
||||
foreach($ledgers as $ledger) {
|
||||
//Declare a variable that will need to be cleared each time the foreach processes
|
||||
$tempArray = array();
|
||||
|
||||
//Get the character information from the character id
|
||||
$charInfo = $lookup->GetCharacterInfo($ledger->character_id);
|
||||
//Get the corp ticker
|
||||
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||
//Get the ore name from the type id
|
||||
$ore = $lookup->ItemIdToName($ledger->type_id);
|
||||
|
||||
//We only want to push the mining ledger entry into the array if it matches
|
||||
//the date within 30 days
|
||||
$sortTime = Carbon::now()->subDays(30);
|
||||
$current = Carbon::createFromFormat('Y-m-d', $ledger->last_updated);
|
||||
if($current->greaterThanOrEqualTo($sortTime)) {
|
||||
array_push($miningLedgers, [
|
||||
'structure' => $value,
|
||||
'character' => $charInfo->name,
|
||||
'corpTicker' => $corpInfo->ticker,
|
||||
'ore' => $ore,
|
||||
'quantity' => $ledger->quantity,
|
||||
'updated' => $ledger->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return view('moons.ledger.rentalledger')->with('miningLedgers', $miningLedgers)
|
||||
->with('structures', $structures);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,255 +6,162 @@ namespace App\Http\Controllers\Moons;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\Config;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Moon\Moon;
|
||||
use App\Models\Moon\RentalMoon;
|
||||
use App\Models\Moon\OrePrice;
|
||||
use App\Models\Moon\Price;
|
||||
use App\Models\MoonRent\MoonRental;
|
||||
use App\Models\Moon\AllianceMoon;
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Moon\AllianceMoonRequest;
|
||||
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Lookups\NewLookupHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
class MoonsAdminController extends Controller
|
||||
{
|
||||
/**
|
||||
* Variable for the class
|
||||
*/
|
||||
private $romans = [
|
||||
'M' => 1000,
|
||||
'CM' => 900,
|
||||
'D' => 500,
|
||||
'CD' => 400,
|
||||
'C' => 100,
|
||||
'XC' => 90,
|
||||
'L' => 50,
|
||||
'XL' => 40,
|
||||
'X' => 10,
|
||||
'IX' => 9,
|
||||
'V' => 5,
|
||||
'IV' => 4,
|
||||
'I' => 1,
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor for the class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the moons to logistics personnel
|
||||
*/
|
||||
public function displayMoonsLogistics() {
|
||||
$this->middleware('permissions:logistics.manager');
|
||||
|
||||
$lookup = new LookupHelper;
|
||||
$rentalEnd = '';
|
||||
$ticker = '';
|
||||
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
//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();
|
||||
//Set carbon dates as needed
|
||||
$lastMonth = Carbon::now()->subMonth();
|
||||
$today = Carbon::now();
|
||||
|
||||
foreach($moons as $moon) {
|
||||
//Get the rental data for the moon
|
||||
$count = MoonRental::where([
|
||||
'System' => $moon->System,
|
||||
'Planet' => $moon->Planet,
|
||||
'Moon' => $moon->Moon,
|
||||
])->count();
|
||||
|
||||
//Check if their is a current rental for a moon going on
|
||||
if($count == 0) {
|
||||
//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 = $lastMonth;
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Set the ticker info
|
||||
$ticker = 'N/A';
|
||||
} else {
|
||||
//Get the rental data for the moon
|
||||
$rental = MoonRental::where([
|
||||
'System' => $moon->System,
|
||||
'Planet' => $moon->Planet,
|
||||
'Moon' => $moon->Moon,
|
||||
])->first();
|
||||
|
||||
//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 color for the table
|
||||
if($rentalTemp->diffInDays($today) < 3 ) {
|
||||
$color = 'table-warning';
|
||||
} else if( $today > $rentalTemp) {
|
||||
$color = 'table-success';
|
||||
} 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,
|
||||
'RentalEnd' => $rentalEnd,
|
||||
'RowColor' => $color,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('moons.logistics.adminmoon')->with('table', $table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the moons to admins
|
||||
*/
|
||||
public function displayMoonsAdmin() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$lookup = new LookupHelper;
|
||||
$lookupHelper = new NewLookupHelper;
|
||||
$contact = '';
|
||||
$paid = '';
|
||||
$rentalEnd = '';
|
||||
$renter = '';
|
||||
$ticker = '';
|
||||
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
//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();
|
||||
//Set carbon dates as needed
|
||||
$lastMonth = Carbon::now()->subMonth();
|
||||
$today = Carbon::now();
|
||||
|
||||
foreach($moons as $moon) {
|
||||
//Get the rental data for the moon
|
||||
$count = MoonRental::where([
|
||||
'System' => $moon->System,
|
||||
'Planet' => $moon->Planet,
|
||||
'Moon' => $moon->Moon,
|
||||
])->count();
|
||||
|
||||
//Check if their is a current rental for a moon going on
|
||||
if($count == 0) {
|
||||
//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 = $lastMonth;
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Set the contact info
|
||||
$contact = 'None';
|
||||
|
||||
//Set the renter info
|
||||
$renter = 'None';
|
||||
|
||||
//Set the ticker info
|
||||
$ticker = 'N/A';
|
||||
|
||||
//Set the type info as it's needed
|
||||
$type = 'N/A';
|
||||
} else {
|
||||
//Get the rental data for the moon
|
||||
$rental = MoonRental::where([
|
||||
'System' => $moon->System,
|
||||
'Planet' => $moon->Planet,
|
||||
'Moon' => $moon->Moon,
|
||||
])->first();
|
||||
|
||||
//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);
|
||||
$contact = $lookupHelper->CharacterIdToName($rental->Contact);
|
||||
|
||||
//Set up the renter whether it's W4RP or another corporation
|
||||
$ticker = $rental->RentalCorp;
|
||||
$type = $rental->Type;
|
||||
}
|
||||
|
||||
//Set the color for the table
|
||||
if($rentalTemp->diffInDays($today) < 3 ) {
|
||||
$color = 'table-warning';
|
||||
} else if( $today > $rentalTemp) {
|
||||
$color = 'table-success';
|
||||
} 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,
|
||||
'Type' => $type,
|
||||
'Renter' => $ticker,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('moons.admin.adminmoon')->with('table', $table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to remove a renter from a moon
|
||||
* Function to display moon requests
|
||||
*/
|
||||
public function storeMoonRemoval(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
public function displayMoonRequests() {
|
||||
$requests = AllianceMoonRequest::where([
|
||||
'status' => 'Pending',
|
||||
])->get();
|
||||
|
||||
return view('moons.admin.moonrequest')->with('requests', $requests);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to approve a moon request
|
||||
*/
|
||||
public function storeApprovedMoonRequest(Request $request) {
|
||||
//Validate the input request
|
||||
$this->validate($request, [
|
||||
'remove' => 'required',
|
||||
'id' => 'required',
|
||||
'status' => 'required',
|
||||
'system' => 'required',
|
||||
'planet' => 'required',
|
||||
'moon' => 'required',
|
||||
]);
|
||||
|
||||
$str_array = explode(" - ", $request->remove);
|
||||
|
||||
//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];
|
||||
//Get the request data which holds all of the information for the request user
|
||||
$moon = AllianceMoonRequest::where([
|
||||
'id' => $request->id,
|
||||
])->first();
|
||||
|
||||
$found = MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $moon,
|
||||
])->count();
|
||||
//Get the configuration data to use later in the function
|
||||
$config = config('esi');
|
||||
|
||||
if($found != 0) {
|
||||
MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $moon,
|
||||
])->delete();
|
||||
//If the request is approved, then update everything.
|
||||
if($request->status == 'Approved') {
|
||||
//Update the alliance moon request to either approved or denied
|
||||
AllianceMoonRequest::where([
|
||||
'id' => $request->id,
|
||||
])->update([
|
||||
'status' => $request->status,
|
||||
'approver_name' => auth()->user()->getName(),
|
||||
'approver_id' => auth()->user()->getId(),
|
||||
]);
|
||||
|
||||
//Update the alliance moon in the table to the correct status
|
||||
AllianceMoon::where([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
])->update([
|
||||
'Corporation' => $moon->corporation_ticker,
|
||||
'Availability' => 'Deployed',
|
||||
]);
|
||||
|
||||
//Send an eve mail to the requestor stating they can set a moon up.
|
||||
//Setup the mail body
|
||||
$body = 'The moon request for ' . $request->system . ' - ' . $request->planet . ' - ' . $request->moon . ' has changed status.<br>';
|
||||
$body .= 'The request has been ' . $request->status . '.<br>';
|
||||
$body .= 'Please contact the FC Team should it be necessary to arrange a fleet to cover the structure drop.<br>';
|
||||
$body .= 'Sincerely,<br>';
|
||||
$body .= 'Warped Intentions Leadership<br>';
|
||||
|
||||
|
||||
} else {
|
||||
//If the status was Denied, then update the request, and mark the moon available again.
|
||||
AllianceMoonRequest::where([
|
||||
'id' => $request->id,
|
||||
])->update([
|
||||
'status' => $request->status,
|
||||
'approver_name' => auth()->user()->getName(),
|
||||
'approver_id' => auth()->user()->getId(),
|
||||
]);
|
||||
|
||||
//Update the alliance moon in the table to the correct status
|
||||
AllianceMoon::where([
|
||||
'System' => (string)$request->system,
|
||||
'Planet' => (string)$request->planet,
|
||||
'Moon' => (string)$request->moon,
|
||||
])->update([
|
||||
'Availability' => 'Available',
|
||||
]);
|
||||
|
||||
//Send an eve mail to the requestor stating they can set a moon up.
|
||||
//Setup the mail body
|
||||
$body = 'The moon request for ' . $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon . ' has changed status.<br>';
|
||||
$body .= 'The request has been ' . $request->status . '.<br>';
|
||||
$body .= 'Should you have questions please contact alliance leadership for further clarification.<br>';
|
||||
$body .= 'Sincerely,<br>';
|
||||
$body .= 'Warped Intentions Leadership<br>';
|
||||
|
||||
return redirect('/moons/admin/display')->with('success', 'Renter removed.');
|
||||
}
|
||||
|
||||
//Redirect back to the moon page, which should call the page to be displayed correctly
|
||||
return redirect('/moons/admin/display')->with('error', 'Something went wrong.');
|
||||
//Setup the mail model
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$moon->requestor_id, 'character', 'Warped Intentions Moon Request', $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
|
||||
|
||||
return redirect('/moons/admin/display/request')->with('success', 'Moon has been processed, and mail has been sent out.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function displays the ability for admins to update moons with who is renting, and when it ends.
|
||||
* Function to display the ability for the admins to update moons with who is renting,
|
||||
* and when it ends
|
||||
*/
|
||||
public function updateMoon() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare some variables
|
||||
//Declare the variables we need
|
||||
$system = null;
|
||||
$planet = null;
|
||||
$moon = null;
|
||||
@@ -262,192 +169,427 @@ class MoonsAdminController extends Controller
|
||||
$spmnTemp = array();
|
||||
$spmn = array();
|
||||
|
||||
//Get the moons and put in order by System, Planet, then Moon number
|
||||
$moons = Moon::orderBy('System', 'ASC')
|
||||
->orderBy('Planet', 'ASC')
|
||||
->orderBy('Moon', 'ASC')
|
||||
->get();
|
||||
//Get the moons and put in order by System, Planet, Moon number
|
||||
$moons = AllianceRentalMoon::orderBy('System', 'ASC')
|
||||
->orderBy('Planet', 'ASC')
|
||||
->orderBy('Moon', 'ASC')
|
||||
->get();
|
||||
|
||||
//Push our default value onto the stack
|
||||
array_push($spmn, 'N/A');
|
||||
|
||||
//Form our array of strings for each system, planet, and moon combination.
|
||||
//Form our array of strings for each system, planet, and moon combination
|
||||
foreach($moons as $m) {
|
||||
$temp = $m->System . " - " . $m->Planet . " - " . $m->Moon . " - " . $m->StructureName;
|
||||
$temp = $m->system . " - " . $m->planet . " - " . $m->moon . " - " . $m->structure_name;
|
||||
array_push($spmnTemp, $temp);
|
||||
}
|
||||
|
||||
//From our temporary array with all the values in a numbered key, create the real array with the value being the key
|
||||
//From the temporary array, build the final array
|
||||
foreach($spmnTemp as $key => $value) {
|
||||
$spmn[$value] = $value;
|
||||
}
|
||||
|
||||
//Return the view and the form from the blade display
|
||||
//Pass the data to the view as well
|
||||
//Pass the data to the blade display
|
||||
return view('moons.admin.updatemoon')->with('spmn', $spmn);
|
||||
}
|
||||
|
||||
public function storeUpdateMoon(Request $request) {
|
||||
/**
|
||||
* Function to remove a renter from a moon
|
||||
* New function based on new table. Will
|
||||
* update description in a future update.
|
||||
*/
|
||||
public function storeMoonRemoval(Request $request) {
|
||||
//Check for the correct role for the user to utilize this function
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare some static variables as needed
|
||||
//Validate the request
|
||||
$this->validate($request, [
|
||||
'remove' => 'required',
|
||||
]);
|
||||
|
||||
//Explode the remove request to an array of strings
|
||||
$str_array = explode(" - ", $request->remove);
|
||||
|
||||
//Decode the value for the SPM into a system, planet, and moon
|
||||
$system = $str_array[0];
|
||||
$planet = $str_array[1];
|
||||
$moon = $str_array[2];
|
||||
|
||||
//Update the moon rental
|
||||
AllianceRentalMoon::where([
|
||||
'system' => $system,
|
||||
'planet' => $planet,
|
||||
'moon' => $moon,
|
||||
])->update([
|
||||
'rental_type' => 'Not Rented',
|
||||
'rental_until' => null,
|
||||
'rental_contact_id' => 0,
|
||||
'rental_contact_type' => 'Not Rented',
|
||||
'paid' => 'Not Rented',
|
||||
'paid_until' => null,
|
||||
'alliance_use_until' => null,
|
||||
]);
|
||||
|
||||
//Once the action is completed, redirect to the original page
|
||||
return redirect('/moons/admin/display/rentals')->with('success', 'Renter removed from the moon.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the moons to admins
|
||||
* New function based on new table. Will
|
||||
* update description in a future update.
|
||||
*/
|
||||
public function displayRentalMoonsAdmin() {
|
||||
//Declare variables for the function
|
||||
$lookupHelper = new LookupHelper;
|
||||
$moonCalc = new MoonCalc;
|
||||
$contactId = null;
|
||||
$contactType = null;
|
||||
$paid = null;
|
||||
$paidUntil = null;
|
||||
$corpTicker = null;
|
||||
$table = array();
|
||||
//Setup the carbon date using Carbon\Carbon
|
||||
$lastMonth = Carbon::now()->subMonth();
|
||||
$today = Carbon::now();
|
||||
|
||||
//Get the moon rentals from the database
|
||||
$rentalMoons = AllianceRentalMoon::orderBy('system', 'asc')->get();
|
||||
|
||||
//For each of the moons compile different data for the view for formatting
|
||||
foreach($rentalMoons as $moon) {
|
||||
|
||||
//Check if a current rental for the moon is on going
|
||||
if(($moon->rental_type == 'In Alliance' || $moon->rental_type == 'Out of Alliance')) {
|
||||
$paid = $moon->paid;
|
||||
$paidUntil = new Carbon($moon->paid_until);
|
||||
$paidUntil = $paidUntil->format('m-d');
|
||||
|
||||
//Set the rental date up
|
||||
$rentalTemp = new Carbon($moon->rental_until);
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Set the correct color for the table
|
||||
if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
|
||||
$color = 'table-warning';
|
||||
} else if($today->lessThan($rentalTemp)) {
|
||||
$color = 'table-danger';
|
||||
} else {
|
||||
$color = 'table-primary';
|
||||
}
|
||||
|
||||
//Set the contact name based on the contact type
|
||||
if($moon->rental_contact_type == 'Alliance') {
|
||||
$allianceInfo = $lookupHelper->GetAllianceInfo($moon->rental_contact_id);
|
||||
//Set the contact name and ticker
|
||||
$contact = $allianceInfo->name;
|
||||
$ticker = $allianceInfo->ticker;
|
||||
|
||||
} else if($moon->rental_contact_type == 'Corporation') {
|
||||
$corporationInfo = $lookupHelper->GetCorporationInfo($moon->rental_contact_id);
|
||||
//Set the contact name and ticker
|
||||
$contact = $corporationInfo->name;
|
||||
$ticker = $corporationInfo->ticker;
|
||||
|
||||
} else if($moon->rental_contact_type == 'Character') {
|
||||
$characterInfo = $lookupHelper->GetCharacterInfo($moon->rental_contact_id);
|
||||
//Set the contact name
|
||||
$contact = $characterInfo->name;
|
||||
//Get the ticker for the character from the corporation he belongs to
|
||||
$corpInfo = $lookupHelper->GetCorporationInfo($characterInfo->corporation_id);
|
||||
$ticker = $corpInfo->ticker;
|
||||
|
||||
} else {
|
||||
$contact = 'N/A';
|
||||
$ticker = 'N/A';
|
||||
$type = 'N/A';
|
||||
$color = 'table-primary';
|
||||
}
|
||||
|
||||
//Check if the moon is currently being utilized by the alliance
|
||||
} else if($moon->rental_type == 'Alliance') {
|
||||
//If the moon is in use by the alliance then the moon isn't paid for
|
||||
$paid = 'No';
|
||||
|
||||
//Setup the rental end time as the end of the month
|
||||
$rentalTemp = Carbon::now()->endOfMonth();
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
//Set the color of the table
|
||||
$color = 'table-info';
|
||||
|
||||
//Setup the paid time as the same as the rental end
|
||||
$paidUntiltemp = $rentalTemp;
|
||||
$paidUntil = $rentalEnd;
|
||||
|
||||
//Set the other information for the spreadsheet
|
||||
$contact = 'Spatial Forces';
|
||||
$renter = 'SP3C';
|
||||
$ticker = 'SP3C';
|
||||
$type = 'Alliance';
|
||||
|
||||
//The last case is the moon is not utilized by the Alliance or is not being rented
|
||||
} else {
|
||||
//If the moon is not being rented, or being utilized by the alliance then set paid to No
|
||||
$paid = 'No';
|
||||
|
||||
//Setup the rental time to end as last month to show it's free
|
||||
$rentalTemp = $lastMonth;
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Setup the paid until as last month to show it's free
|
||||
$paidUntilTemp = $lastMonth;
|
||||
$paidUntil = $lastMonth->format('m-d');
|
||||
|
||||
//Setup the other variables with the correct information
|
||||
$contact = 'None';
|
||||
$renter = 'None';
|
||||
$ticker = 'N/A';
|
||||
$type = 'N/A';
|
||||
|
||||
//Set the color of the table
|
||||
$color = 'table-primary';
|
||||
}
|
||||
|
||||
//Set up the moon rental type
|
||||
if($moon->rental_type == 'In Alliance') {
|
||||
$type = 'IA';
|
||||
//Setup the row color
|
||||
if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
|
||||
$color = 'table-warning';
|
||||
} else if($today->lessThan($rentalTemp)) {
|
||||
$color = 'table-danger';
|
||||
} else {
|
||||
$color = 'table-primary';
|
||||
}
|
||||
} else if($moon->rental_type == 'Out of Alliance') {
|
||||
$type = 'OOA';
|
||||
//Setup the row color
|
||||
if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
|
||||
$color = 'table-warning';
|
||||
} else if($today->lessThan($rentalTemp)) {
|
||||
$color = 'table-danger';
|
||||
} else {
|
||||
$color = 'table-primary';
|
||||
}
|
||||
} else if($moon->rental_type == 'Alliance') {
|
||||
$type = 'W4RP';
|
||||
//Set the row color
|
||||
$color = 'table-info';
|
||||
} else {
|
||||
$type = 'N/A';
|
||||
//Set the row color
|
||||
$color = 'table-primary';
|
||||
}
|
||||
|
||||
//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->structure_name,
|
||||
'AlliancePrice' => $moon->alliance_rental_price,
|
||||
'OutOfAlliancePrice' => $moon->out_of_alliance_rental_price,
|
||||
'RentalEnd' => $rentalEnd,
|
||||
'RowColor' => $color,
|
||||
'Paid' => $moon->paid,
|
||||
'PaidUntil' => $paidUntil,
|
||||
'Contact' => $contact,
|
||||
'Type' => $moon->rental_type,
|
||||
'Renter' => $type,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('moons.admin.adminmoon')->with('table', $table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to store the updates from the moons.
|
||||
* New function based on new table. Will update
|
||||
* the description in a future update
|
||||
*/
|
||||
public function storeUpdateMoon(Request $request) {
|
||||
//Require the site administration role
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare some variables we will need
|
||||
$moonCalc = new MoonCalc;
|
||||
$lookup = new LookupHelper;
|
||||
$paid = false;
|
||||
$system = null;
|
||||
$planet = null;
|
||||
$mn = null;
|
||||
$name = null;
|
||||
|
||||
//Validate our request from the html form
|
||||
$this->validate($request, [
|
||||
'spmn' => 'required',
|
||||
'renter' => 'required',
|
||||
'date' => 'required',
|
||||
'contact' => 'required',
|
||||
'contact_type' => 'required',
|
||||
'paid_until' => 'required',
|
||||
'rental_end' => 'required',
|
||||
]);
|
||||
|
||||
//Decode the System, Planet, Moon, Name combinatio sent from the controller
|
||||
//Decode the spmn
|
||||
$str_array = explode(" - ", $request->spmn);
|
||||
$system = $str_array[0];
|
||||
$planet = $str_array[1];
|
||||
$mn = $str_array[2];
|
||||
$name = $str_array[3];
|
||||
|
||||
//Take the contact name and create a character_id from it
|
||||
if($request->contact == 'None') {
|
||||
$contact = 'None';
|
||||
} else {
|
||||
$contact = $lookup->CharacterNameToId($request->contact);
|
||||
}
|
||||
|
||||
//Update the paid value for database entry
|
||||
//Update the paid value from the request value
|
||||
if($request->paid == 'Yes') {
|
||||
$paid = 'Yes';
|
||||
} else {
|
||||
$paid = 'No';
|
||||
}
|
||||
|
||||
//Update the paid unti value for the database entry
|
||||
if(isset($request->Paid_Until)) {
|
||||
$paidUntil = $request->Paid_Until;
|
||||
} else {
|
||||
$paidUntil = null;
|
||||
//Setup the rental end and paid until variables
|
||||
$rentalEnd = $request->rental_end . " 23:59:59";
|
||||
$paidUntil = $request->paid_until . " 23:59:59";
|
||||
|
||||
//Check if the alliance is renting the moon for itself
|
||||
if($request->contact_type == 'Corporation' && $request->contact == 'Spatial Forces') {
|
||||
AllianceRentalMoon::where([
|
||||
'system' => $str_array[0],
|
||||
'planet' => $str_array[1],
|
||||
'moon' => $str_array[2],
|
||||
])->update([
|
||||
'rental_type' => 'Alliance',
|
||||
'rental_until' => $request->rental_end . " 23:59:59",
|
||||
'rental_contact_id' => 98287666,
|
||||
'rental_contact_type' => 'Alliance',
|
||||
'paid' => 'No',
|
||||
'paid_until' => null,
|
||||
'alliance_use_until' => $request->rental_end . " 23:59:59",
|
||||
]);
|
||||
} else if($request->contact_type == 'Character') {
|
||||
//Get the character id from the lookup helper
|
||||
$charId = $lookup->CharacterNameToId($request->contact);
|
||||
//Get the character information including the corporation from the lookup tables
|
||||
$char = $lookup->GetCharacterInfo($charId);
|
||||
//Get the corporation id from the lookup helper, followed by the alliance id
|
||||
//so we can determine if it's in alliance or out of alliance
|
||||
$corp = $lookup->GetCorporationInfo($char->corporation_id);
|
||||
|
||||
if($corp->alliance_id == 99004116) {
|
||||
$type = 'In Alliance';
|
||||
} else {
|
||||
$type = 'Out of Alliance';
|
||||
}
|
||||
|
||||
AllianceRentalMoon::where([
|
||||
'system' => $str_array[0],
|
||||
'planet' => $str_array[1],
|
||||
'moon' => $str_array[2],
|
||||
])->update([
|
||||
'rental_type' => $type,
|
||||
'rental_until' => $request->rental_end . " 23:59:59",
|
||||
'rental_contact_id' => $charId,
|
||||
'rental_contact_type' => 'Character',
|
||||
'paid' => $paid,
|
||||
'paid_until' => $request->paid_until . " 23:59:59",
|
||||
'alliance_use_until' => null,
|
||||
]);
|
||||
|
||||
} else if($request->contact_type == 'Corporation') {
|
||||
//Get the corporation id from the lookup helper
|
||||
$corpId = $lookup->CorporationNameToId($request->contact);
|
||||
//Get the corporation information to determine if they are in Warped Intentions or not.
|
||||
$corporation = $lookup->GetCorporationInfo($request->contact);
|
||||
|
||||
if($corp->alliance_id == 99004116) {
|
||||
$type = 'In Alliance';
|
||||
} else {
|
||||
$type = 'Out of Alliance';
|
||||
}
|
||||
|
||||
AllianceMoonRental::where([
|
||||
'system' => $str_array[0],
|
||||
'planet' => $str_array[1],
|
||||
'moon' => $str_array[2],
|
||||
])->update([
|
||||
'rental_type' => $type,
|
||||
'rental_until' => $request->rental_end . " 23:59:59",
|
||||
'rental_contact_id' => $corpId,
|
||||
'rental_contact_type' => 'Corporation',
|
||||
'paid' => $paid,
|
||||
'paid_until' => $request->paid_until . " 23:59:59",
|
||||
'alliance_use_until' => 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');
|
||||
|
||||
//Count how many rentals we find for later database processing
|
||||
$count = MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $mn,
|
||||
'Contact' => $contact,
|
||||
])->count();
|
||||
|
||||
//Calculate the price of the moon for when it's updated
|
||||
$moon = Moon::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $mn,
|
||||
])->first();
|
||||
|
||||
//Calculate the price of the rental and store it in the database
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
//If the database entry isn't found, then insert it into the database,
|
||||
//otherwise, account for it being in the system already.
|
||||
if($count != 0) {
|
||||
if($allianceId = 99004116) {
|
||||
MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $mn,
|
||||
'Contact' => $contact,
|
||||
])->update([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $mn,
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['alliance'],
|
||||
'Type' => 'alliance',
|
||||
'Paid' => $paid,
|
||||
'Paid_Until' => $request->paid_until,
|
||||
]);
|
||||
} else {
|
||||
MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $mn,
|
||||
'Contact' => $contact,
|
||||
])->update([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $mn,
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['outofalliance'],
|
||||
'Type' => 'outofalliance',
|
||||
'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' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $moon,
|
||||
])->delete();
|
||||
|
||||
if($allianceId == 99004116) {
|
||||
$store = new MoonRental;
|
||||
$store->System = $system;
|
||||
$store->Planet = $planet;
|
||||
$store->Moon = $mn;
|
||||
$store->RentalCorp = $request->renter;
|
||||
$store->RentalEnd = $date;
|
||||
$store->Contact = $contact;
|
||||
$store->Price = $price['alliance'];
|
||||
$store->Type = 'alliance';
|
||||
$store->Paid = $paid;
|
||||
$store->save();
|
||||
} else {
|
||||
$store = new MoonRental;
|
||||
$store->System = $system;
|
||||
$store->Planet = $planet;
|
||||
$store->Moon = $mn;
|
||||
$store->RentalCorp = $request->renter;
|
||||
$store->RentalEnd = $date;
|
||||
$store->Contact = $contact;
|
||||
$store->Price = $price['outofalliance'];
|
||||
$store->Type = 'outofalliance';
|
||||
$store->Paid = $paid;
|
||||
$store->save();
|
||||
}
|
||||
}
|
||||
|
||||
//Redirect to the update moon page
|
||||
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Updated');
|
||||
//Redirect to the previous screen.
|
||||
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Rental updated.');
|
||||
}
|
||||
|
||||
public function showJournalEntries() {
|
||||
$this->middleware('role:Admin');
|
||||
public function ImportMoonSurveyData(Request $request) {
|
||||
//Declare variables
|
||||
$added = 0;
|
||||
$updated = 0;
|
||||
$moon = null;
|
||||
$newMoon = false;
|
||||
$num = 0;
|
||||
$planet = null;
|
||||
$moonNumber = null;
|
||||
|
||||
$dateInit = Carbon::now();
|
||||
$date = $dateInit->subDays(30);
|
||||
foreach(explode("\n", $request->input('data')) as $row) {
|
||||
$cols = explode("\t", $row);
|
||||
dd($cols);
|
||||
}
|
||||
|
||||
$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 redirect('/admin/dashboard')->with('success', 'Import done: ' . $added . ' moons added ' . $updated . ' moons updated.');
|
||||
}
|
||||
|
||||
return view('moons.admin.moonjournal')->with('journal', $journal);
|
||||
private function romanNumberToInteger($roman) {
|
||||
$result = 0;
|
||||
|
||||
foreach($this->romans as $key => $value) {
|
||||
while(strpos($roman, $key) === 0) {
|
||||
$result += $value;
|
||||
$roman = substr($roman, strlen($key));
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function integerToRomanNumber($number) {
|
||||
$returnValue = '';
|
||||
while($number > 0) {
|
||||
foreach($this->romans as $roman => $int) {
|
||||
if($number >= $int) {
|
||||
$number -= $int;
|
||||
$returnValue .= $roman;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
private function arrayToCsv(array $rows) {
|
||||
//Declare needed variable as text null
|
||||
$result = '';
|
||||
|
||||
//Open the temp file
|
||||
$fp = fopen('php://temp', 'w');
|
||||
|
||||
//Process the file
|
||||
foreach($rows as $fields) {
|
||||
fputcsv($fp, $fields, ';', '"');
|
||||
|
||||
}
|
||||
|
||||
//Go back to the beginning of the file
|
||||
rewind($fp);
|
||||
|
||||
//Continue through the buffer until the end
|
||||
while(($buffer = fgets($fp, 4096)) !== false) {
|
||||
$result .= $buffer;
|
||||
}
|
||||
|
||||
//Close the temp file
|
||||
fclose($fp);
|
||||
|
||||
//Return the result
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,18 @@ 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;
|
||||
use App\Models\Moon\AllianceMoon;
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Moon\AllianceMoonRequest;
|
||||
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
class MoonsController extends Controller
|
||||
{
|
||||
@@ -27,84 +32,283 @@ class MoonsController extends Controller
|
||||
$this->middleware('role:Renter');
|
||||
}
|
||||
|
||||
public function displayRentalMoonPage() {
|
||||
return view('moons.user.requestrental');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the moons and pass data to the blade template
|
||||
* Function to display all alliance moons and pass data to the blade template
|
||||
*/
|
||||
public function displayMoons() {
|
||||
$rentalEnd = '';
|
||||
//Setup variables for moons
|
||||
$moons = array();
|
||||
$systems = array();
|
||||
|
||||
//Get the user type from the user Auth class
|
||||
$type = Auth::user()->user_type;
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
//get all of the moons from the database
|
||||
$moons = DB::table('Moons')->orderBy('System', 'asc')->get();
|
||||
//Set the rental date as last month for moons not rented
|
||||
//Get all of the alliance moon systems from the database
|
||||
$systems = AllianceMoon::groupBy('System')->pluck('System');
|
||||
|
||||
//Get all of the alliance moons from the database
|
||||
$moons = AllianceMoon::all();
|
||||
|
||||
$gasGoo = [
|
||||
'Zeolites',
|
||||
'Sylvite',
|
||||
'Bitumens',
|
||||
'Coesite',
|
||||
];
|
||||
|
||||
$r8Goo = [
|
||||
'Cobaltite',
|
||||
'Euxenite',
|
||||
'Titanite',
|
||||
'Scheelite',
|
||||
];
|
||||
|
||||
$r16Goo = [
|
||||
'Otavite',
|
||||
'Sperrylite',
|
||||
'Vanadinite',
|
||||
'Chromite',
|
||||
];
|
||||
|
||||
$r32Goo = [
|
||||
'Carnotite',
|
||||
'Zircon',
|
||||
'Pollucite',
|
||||
'Cinnabar',
|
||||
];
|
||||
|
||||
$r64Goo = [
|
||||
'Xenotime',
|
||||
'Monazite',
|
||||
'Loparite',
|
||||
'Ytterbite',
|
||||
];
|
||||
|
||||
return view('moons.user.allmoons')->with('systems', $systems)
|
||||
->with('moons', $moons)
|
||||
->with('gasGoo', $gasGoo)
|
||||
->with('r8Goo', $r8Goo)
|
||||
->with('r16Goo', $r16Goo)
|
||||
->with('r32Goo', $r32Goo)
|
||||
->with('r64Goo', $r64Goo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display moon request form
|
||||
*/
|
||||
public function displayRequestAllianceMoon() {
|
||||
return view('moons.user.requestmoon');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to store the moon request
|
||||
*/
|
||||
public function storeRequestAllianceMoon(Request $request) {
|
||||
$this->validate($request, [
|
||||
'system' => 'required',
|
||||
'planet' => 'required',
|
||||
'moon' => 'required',
|
||||
]);
|
||||
|
||||
//Declare some necessary arrays for figuring out what region a moon resides in
|
||||
$catch = [
|
||||
'6X7-JO',
|
||||
'A803-L',
|
||||
'I8-D0G',
|
||||
'WQH-4K',
|
||||
'GJ0-JO',
|
||||
'Q-S7ZD',
|
||||
'JWZ2-V',
|
||||
'J-ODE7',
|
||||
'OGL8-Q',
|
||||
'R-K4QY',
|
||||
];
|
||||
|
||||
$immensea = [
|
||||
'ZBP-TP',
|
||||
'XVV-21',
|
||||
'B9E-H6',
|
||||
'JDAS-0',
|
||||
'Y19P-1',
|
||||
'LN-56V',
|
||||
'O7-7UX',
|
||||
'Y2-QUV',
|
||||
'SPBS-6',
|
||||
'A4B-V5',
|
||||
'GXK-7F',
|
||||
'78TS-Q',
|
||||
'CJNF-J',
|
||||
'EA-HSA',
|
||||
'FYI-49',
|
||||
'WYF8-8',
|
||||
'NS2L-4',
|
||||
'B-S347',
|
||||
'AF0-V5',
|
||||
'QI-S9W',
|
||||
'B-A587',
|
||||
'PPFB-U',
|
||||
'L-5JCJ',
|
||||
'4-GB14',
|
||||
'REB-KR',
|
||||
'QE-E1D',
|
||||
'LK1K-5',
|
||||
'Z-H2MA',
|
||||
'B-KDOZ',
|
||||
'E8-YS9',
|
||||
'DY-P7Q',
|
||||
];
|
||||
|
||||
//Declare lookup variables
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//Get all of the information needed to create the database entry
|
||||
$charId = auth()->user()->getId();
|
||||
$charInfo = $lookup->GetCharacterInfo($charId);
|
||||
$charName = $charInfo->name;
|
||||
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||
$corpId = $corpInfo->corporation_id;
|
||||
$corpName = $corpInfo->name;
|
||||
$corpTicker = $corpInfo->ticker;
|
||||
//Declare the region variable as null for the lookup if statement
|
||||
$region = null;
|
||||
|
||||
//Get the region the moon resides in from the system
|
||||
if(in_array($request->system, $catch, true)) {
|
||||
$region = 'Catch';
|
||||
} else if(in_array($request->system, $immensea, true)) {
|
||||
$region = 'Immensea';
|
||||
} else {
|
||||
//False value. Redirect back to page
|
||||
return redirct('/moons/display/request')->with('error', 'Region was not found.');
|
||||
}
|
||||
|
||||
//Check to see if the moon has been previously inputted for
|
||||
$allMoons = AllianceMoon::all();
|
||||
foreach($allMoons as $moon) {
|
||||
if($moon->Region == $region && $moon->System == $request->system && $moon->Planet == $request->planet && $moon->Moon == $request->moon) {
|
||||
if($moon->Availability != 'Available') {
|
||||
return redirect('moons/display/request')->with('error', 'The moon has already been reserved by another party.');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Create the new object to save into the database
|
||||
$moonRequest = new AllianceMoonRequest;
|
||||
$moonRequest->region = $region;
|
||||
$moonRequest->system = $request->system;
|
||||
$moonRequest->planet = $request->planet;
|
||||
$moonRequest->moon = $request->moon;
|
||||
$moonRequest->corporation_id = $corpId;
|
||||
$moonRequest->corporation_name = $corpName;
|
||||
$moonRequest->corporation_ticker = $corpTicker;
|
||||
$moonRequest->requestor_name = $charName;
|
||||
$moonRequest->requestor_id = $charId;
|
||||
$moonRequest->status = 'Pending';
|
||||
$moonRequest->save();
|
||||
|
||||
//Update the current moon's status in the model AllianceMoon
|
||||
AllianceMoon::where([
|
||||
'Region' => $region,
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
])->update([
|
||||
'Availability' => 'Request Pending',
|
||||
]);
|
||||
|
||||
//Send a mail over to the site admins to approve the moon request
|
||||
$config = config('esi');
|
||||
$body = 'A new moon request has been entered into the services site. Please approve or deny the request within 3 business days.<br><br>';
|
||||
$body .= 'Sincerely,<br>';
|
||||
$body .= 'W4RP Services Site';
|
||||
$subject = 'New Moon Request Available';
|
||||
|
||||
ProcessSendEveMailJob::dispatch($body, 92947432, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
|
||||
ProcessSendEveMailJob::dispatch($body, 92626011, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(60));
|
||||
|
||||
return redirect('/moons/display/request')->with('success', 'Moon request submitted.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the moons and pass to the blade template
|
||||
* Function description will be updated in a future release.
|
||||
*/
|
||||
public function displayRentalMoons() {
|
||||
//Declare variables
|
||||
$lastMonth = Carbon::now()->subMonth();
|
||||
//Set a variable for today's date
|
||||
$today = Carbon::now();
|
||||
|
||||
//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
|
||||
//Get the user type from the user Auth class
|
||||
$type = auth()->user()->getUserType();
|
||||
//Get all of the rental moons from the database
|
||||
$moons = AllianceRentalMoon::orderBy('system', 'ASC')
|
||||
->orderBy('planet', 'ASC')
|
||||
->orderBy('moon', 'ASC')
|
||||
->get();
|
||||
|
||||
//For each of the moons let's format the data for the display table
|
||||
foreach($moons as $moon) {
|
||||
$color = null;
|
||||
$rentalTemp = null;
|
||||
$rentalEnd = null;
|
||||
|
||||
//Check if someone is currently renting the moon
|
||||
if($moon->rental_type == 'In Alliance' || $moon->rental_type == 'Out of Alliance') {
|
||||
$rentalTemp = new Carbon($moon->rental_until);
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Setup the correct color for the table
|
||||
if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
|
||||
$color = 'table-warning';
|
||||
} else if($today->lessThan($rentalTemp)) {
|
||||
$color = 'table-danger';
|
||||
} else {
|
||||
$color = 'table-primary';
|
||||
}
|
||||
} else if($moon->rental_type == 'Alliance') {
|
||||
$rentalTemp = Carbon::now()->endOfMonth();
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
$color = 'table-info';
|
||||
} else {
|
||||
//Set the rental date for if someone is not renting the moon
|
||||
$rentalTemp = $lastMonth;
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
} else {
|
||||
//Set the rental date up
|
||||
$rentalTemp = new Carbon($rental->RentalEnd);
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
}
|
||||
|
||||
$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
|
||||
//Get the price of the moon from the database based on if the person is in Warped Intentions
|
||||
$userType = auth()->user()->getUserType();
|
||||
if($userType == 'W4RP') {
|
||||
$moonprice = $moon->alliance_rental_price;
|
||||
} else {
|
||||
$moonprice = $moon->out_of_alliance_rental_price;
|
||||
}
|
||||
|
||||
//Add the data to the html array 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", ".", ","),
|
||||
'SPM' => $moon->system . " - " . $moon->planet . " - " . $moon->moon,
|
||||
'StructureName' => $moon->structure_name,
|
||||
'FirstOre' => $moon->first_ore,
|
||||
'FirstQuantity' => number_format($moon->first_quantity, 0, ".", ","),
|
||||
'SecondOre' => $moon->second_ore,
|
||||
'SecondQuantity' => number_format($moon->second_quantity, 0, ".", ","),
|
||||
'ThirdOre' => $moon->third_ore,
|
||||
'ThirdQuantity' => number_format($moon->third_quantity, 0, ".", ","),
|
||||
'FourthOre' => $moon->fourth_ore,
|
||||
'FourthQuantity' => number_format($moon->fourth_quantity, 0, ".", ","),
|
||||
'Price' => number_format($moonprice, 0, ".", ","),
|
||||
'Worth' => number_format($moon->moon_worth, 0, ".", ","),
|
||||
'RentalEnd' => $rentalEnd,
|
||||
'RowColor' => $color,
|
||||
]);
|
||||
}
|
||||
|
||||
//Pass the data to the view
|
||||
return view('moons.user.moon')->with('table', $table);
|
||||
}
|
||||
|
||||
@@ -113,26 +317,252 @@ class MoonsController extends Controller
|
||||
}
|
||||
|
||||
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();
|
||||
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
||||
$composition = [
|
||||
'Tritanium' => 0,
|
||||
'Pyerite' => 0,
|
||||
'Mexallon' => 0,
|
||||
'Isogen' => 0,
|
||||
'Nocxium' => 0,
|
||||
'Zydrine' => 0,
|
||||
'Megacyte' => 0,
|
||||
'Atmospheric_Gases' => 0,
|
||||
'Evaporite_Deposits' => 0,
|
||||
'Hydrocarbons' => 0,
|
||||
'Silicates' => 0,
|
||||
'Cobalt' => 0,
|
||||
'Scandium' => 0,
|
||||
'Titanium' => 0,
|
||||
'Tungsten' => 0,
|
||||
'Cadmium' => 0,
|
||||
'Platinum' => 0,
|
||||
'Vanadium'=> 0,
|
||||
'Chromium' => 0,
|
||||
'Technetium' => 0,
|
||||
'Hafnium' => 0,
|
||||
'Caesium' => 0,
|
||||
'Mercury' => 0,
|
||||
'Dysprosium' => 0,
|
||||
'Neodymium' => 0,
|
||||
'Promethium' => 0,
|
||||
'Thulium' => 0,
|
||||
];
|
||||
|
||||
$totalGoo = $moonCalc->SpatialMoonsOnlyGooTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
||||
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
|
||||
$totalGoo = number_format($totalGoo, 2, ".", ",");
|
||||
$firstOre = $request->firstOre;
|
||||
if($request->firstQuantity >= 1.00) {
|
||||
$firstQuantity = $request->firstQuantity / 100.00;
|
||||
} else {
|
||||
$firstQuantity = $request->firstQuantity;
|
||||
}
|
||||
|
||||
$secondOre = $request->secondOre;
|
||||
if($request->secondQuantity >= 1.00) {
|
||||
$secondQuantity = $request->secondQuantity / 100.00;
|
||||
} else {
|
||||
$secondQuantity = $request->secondQuantity;
|
||||
}
|
||||
|
||||
$thirdOre = $request->thirdOre;
|
||||
if($request->thirdQuantity >= 1.00) {
|
||||
$thirdQuantity = $request->thirdQuantity / 100.00;
|
||||
} else {
|
||||
$thirdQuantity = $request->thirdQuantity;
|
||||
}
|
||||
|
||||
$fourthOre = $request->fourthOre;
|
||||
if($request->fourthQuantity >= 1.00) {
|
||||
$fourthQuantity = $request->fourthQuantity / 100.00;
|
||||
} else {
|
||||
$fourthQuantity = $request->fourthQuantity;
|
||||
}
|
||||
|
||||
if($request->reprocessing >= 1.00) {
|
||||
$reprocessing = $request->reprocessing / 100.00;
|
||||
} else {
|
||||
$reprocessing = $request->reprocessing;
|
||||
}
|
||||
|
||||
//Set the reprocessing level for 84% if the value is null
|
||||
if($request->reprocessing == null) {
|
||||
$reprocessing = 0.84;
|
||||
}
|
||||
|
||||
//Get the total percentage of the ores, and normalize it to 1.00.
|
||||
$totalPercent = $firstQuantity + $secondQuantity + $thirdQuantity + $fourthQuantity;
|
||||
if($totalPercent < 1.00) {
|
||||
$firstQuantity = $firstQuantity / $totalPercent;
|
||||
$secondQuantity = $secondQuantity / $totalPercent;
|
||||
$thirdQuantity = $thirdQuantity / $totalPercent;
|
||||
$fourthQuantity = $fourthQuantity / $totalPercent;
|
||||
}
|
||||
|
||||
//Calculate the total worth of the moon
|
||||
$totalWorth = $moonCalc->SpatialMoonsTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
||||
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
|
||||
//Format the number to send to the blade.
|
||||
$totalWorth = number_format($totalWorth, 2, ".", ",");
|
||||
|
||||
return view('moons.user.displayTotalWorth')->with(['totalWorth' => $totalWorth, 'totalGoo' => $totalGoo]);
|
||||
//Get the composition for the first ore if it is not None.
|
||||
//Add the first ore composition to the final composition
|
||||
if($firstOre != 'None') {
|
||||
//Get the ore's composition
|
||||
$firstComp = $moonCalc->GetOreComposition($firstOre);
|
||||
//Get the amount of units mine-able from the moon
|
||||
$mUnits = $moonCalc->CalcOreUnits($firstOre, $firstQuantity);
|
||||
//Calculate the number of reprocessing units to happen from moon units
|
||||
$rUnits = floor($mUnits / 100.0);
|
||||
|
||||
//Compile the composition of the ore
|
||||
$composition['Tritanium'] += floor(($firstComp->Tritanium * $rUnits) * $reprocessing);
|
||||
$composition['Pyerite'] += floor(($firstComp->Pyerite * $rUnits) * $reprocessing);
|
||||
$composition['Mexallon'] += floor(($firstComp->Mexallon * $rUnits) * $reprocessing);
|
||||
$composition['Isogen'] += floor(($firstComp->Isogen * $rUnits) * $reprocessing);
|
||||
$composition['Nocxium'] += floor(($firstComp->Nocxium * $rUnits) * $reprocessing);
|
||||
$composition['Zydrine'] += floor(($firstComp->Zydrine * $rUnits) * $reprocessing);
|
||||
$composition['Megacyte'] += floor(($firstComp->Megacyte * $rUnits) * $reprocessing);
|
||||
$composition['Atmospheric_Gases'] += floor(($firstComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||
$composition['Evaporite_Deposits'] += floor(($firstComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||
$composition['Hydrocarbons'] += floor(($firstComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||
$composition['Silicates'] += floor(($firstComp->Silicates * $rUnits) * $reprocessing);
|
||||
$composition['Cobalt'] += floor(($firstComp->Cobalt * $rUnits) * $reprocessing);
|
||||
$composition['Scandium'] += floor(($firstComp->Scandium * $rUnits) * $reprocessing);
|
||||
$composition['Titanium'] += floor(($firstComp->Titanium * $rUnits) * $reprocessing);
|
||||
$composition['Tungsten'] += floor(($firstComp->Tungsten * $rUnits) * $reprocessing);
|
||||
$composition['Cadmium'] += floor(($firstComp->Cadmium * $rUnits) * $reprocessing);
|
||||
$composition['Platinum'] += floor(($firstComp->Platinium * $rUnits) * $reprocessing);
|
||||
$composition['Vanadium'] += floor(($firstComp->Vanadium * $rUnits) * $reprocessing);
|
||||
$composition['Chromium'] += floor(($firstComp->Chromium * $rUnits) * $reprocessing);
|
||||
$composition['Technetium'] += floor(($firstComp->Technetium * $rUnits) * $reprocessing);
|
||||
$composition['Hafnium'] += floor(($firstComp->Hafnium * $rUnits) * $reprocessing);
|
||||
$composition['Caesium'] += floor(($firstComp->Caesium * $rUnits) * $reprocessing);
|
||||
$composition['Mercury'] += floor(($firstComp->Mercury * $rUnits) * $reprocessing);
|
||||
$composition['Dysprosium'] += floor(($firstComp->Dysprosium * $rUnits) * $reprocessing);
|
||||
$composition['Neodymium'] += floor(($firstComp->Neodymium * $rUnits) * $reprocessing);
|
||||
$composition['Promethium'] += floor(($firstComp->Promethium * $rUnits) * $reprocessing);
|
||||
$composition['Thulium'] += floor(($firstComp->Thulium * $rUnits) * $reprocessing);
|
||||
}
|
||||
|
||||
//Get the composition for the second ore if it is not None.
|
||||
//Add the second ore composition to the final composition
|
||||
if($secondOre != 'None') {
|
||||
//Get the ore's composition
|
||||
$secondComp = $moonCalc->GetOreComposition($secondOre);
|
||||
//Get the amount of units mine-able from the moon
|
||||
$mUnits = $moonCalc->CalcOreUnits($secondOre, $secondQuantity);
|
||||
//Calculate the number of reprocessing units to happen from moon units
|
||||
$rUnits = floor($mUnits / 100.0);
|
||||
|
||||
$composition['Tritanium'] += floor(($secondComp->Tritanium * $rUnits) * $reprocessing);
|
||||
$composition['Pyerite'] += floor(($secondComp->Pyerite * $rUnits) * $reprocessing);
|
||||
$composition['Mexallon'] += floor(($secondComp->Mexallon * $rUnits) * $reprocessing);
|
||||
$composition['Isogen'] += floor(($secondComp->Isogen * $rUnits) * $reprocessing);
|
||||
$composition['Nocxium'] += floor(($secondComp->Nocxium * $rUnits) * $reprocessing);
|
||||
$composition['Zydrine'] += floor(($secondComp->Zydrine * $rUnits) * $reprocessing);
|
||||
$composition['Megacyte'] += floor(($secondComp->Megacyte * $rUnits) * $reprocessing);
|
||||
$composition['Atmospheric_Gases'] += floor(($secondComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||
$composition['Evaporite_Deposits'] += floor(($secondComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||
$composition['Hydrocarbons'] += floor(($secondComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||
$composition['Silicates'] += floor(($secondComp->Silicates * $rUnits) * $reprocessing);
|
||||
$composition['Cobalt'] += floor(($secondComp->Cobalt * $rUnits) * $reprocessing);
|
||||
$composition['Scandium'] += floor(($secondComp->Scandium * $rUnits) * $reprocessing);
|
||||
$composition['Titanium'] += floor(($secondComp->Titanium * $rUnits) * $reprocessing);
|
||||
$composition['Tungsten'] += floor(($secondComp->Tungsten * $rUnits) * $reprocessing);
|
||||
$composition['Cadmium'] += floor(($secondComp->Cadmium * $rUnits) * $reprocessing);
|
||||
$composition['Platinum'] += floor(($secondComp->Platinium * $rUnits) * $reprocessing);
|
||||
$composition['Vanadium'] += floor(($secondComp->Vanadium * $rUnits) * $reprocessing);
|
||||
$composition['Chromium'] += floor(($secondComp->Chromium * $rUnits) * $reprocessing);
|
||||
$composition['Technetium'] += floor(($secondComp->Technetium * $rUnits) * $reprocessing);
|
||||
$composition['Hafnium'] += floor(($secondComp->Hafnium * $rUnits) * $reprocessing);
|
||||
$composition['Caesium'] += floor(($secondComp->Caesium * $rUnits) * $reprocessing);
|
||||
$composition['Mercury'] += floor(($secondComp->Mercury * $rUnits) * $reprocessing);
|
||||
$composition['Dysprosium'] += floor(($secondComp->Dysprosium * $rUnits) * $reprocessing);
|
||||
$composition['Neodymium'] += floor(($secondComp->Neodymium * $rUnits) * $reprocessing);
|
||||
$composition['Promethium'] += floor(($secondComp->Promethium * $rUnits) * $reprocessing);
|
||||
$composition['Thulium'] += floor(($secondComp->Thulium * $rUnits) * $reprocessing);
|
||||
}
|
||||
|
||||
//Get the composition for the third ore if it is not None.
|
||||
//Add the third ore composition to the final composition
|
||||
if($thirdOre != 'None') {
|
||||
//Get the ore's composition
|
||||
$thirdComp = $moonCalc->GetOreComposition($thirdOre);
|
||||
//Get the amount of units mine-able from the moon
|
||||
$mUnits = $moonCalc->CalcOreUnits($thirdOre, $thirdQuantity);
|
||||
//Calculate the number of reprocessing units to happen from moon units
|
||||
$rUnits = floor($mUnits / 100.0);
|
||||
|
||||
$composition['Tritanium'] += floor(($thirdComp->Tritanium * $rUnits) * $reprocessing);
|
||||
$composition['Pyerite'] += floor(($thirdComp->Pyerite * $rUnits) * $reprocessing);
|
||||
$composition['Mexallon'] += floor(($thirdComp->Mexallon * $rUnits) * $reprocessing);
|
||||
$composition['Isogen'] += floor(($thirdComp->Isogen * $rUnits) * $reprocessing);
|
||||
$composition['Nocxium'] += floor(($thirdComp->Nocxium * $rUnits) * $reprocessing);
|
||||
$composition['Zydrine'] += floor(($thirdComp->Zydrine * $rUnits) * $reprocessing);
|
||||
$composition['Megacyte'] += floor(($thirdComp->Megacyte * $rUnits) * $reprocessing);
|
||||
$composition['Atmospheric_Gases'] += floor(($thirdComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||
$composition['Evaporite_Deposits'] += floor(($thirdComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||
$composition['Hydrocarbons'] += floor(($thirdComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||
$composition['Silicates'] += floor(($thirdComp->Silicates * $rUnits) * $reprocessing);
|
||||
$composition['Cobalt'] += floor(($thirdComp->Cobalt * $rUnits) * $reprocessing);
|
||||
$composition['Scandium'] += floor(($thirdComp->Scandium * $rUnits) * $reprocessing);
|
||||
$composition['Titanium'] += floor(($thirdComp->Titanium * $rUnits) * $reprocessing);
|
||||
$composition['Tungsten'] += floor(($thirdComp->Tungsten * $rUnits) * $reprocessing);
|
||||
$composition['Cadmium'] += floor(($thirdComp->Cadmium * $rUnits) * $reprocessing);
|
||||
$composition['Platinum'] += floor(($thirdComp->Platinium * $rUnits) * $reprocessing);
|
||||
$composition['Vanadium'] += floor(($thirdComp->Vanadium * $rUnits) * $reprocessing);
|
||||
$composition['Chromium'] += floor(($thirdComp->Chromium * $rUnits) * $reprocessing);
|
||||
$composition['Technetium'] += floor(($thirdComp->Technetium * $rUnits) * $reprocessing);
|
||||
$composition['Hafnium'] += floor(($thirdComp->Hafnium * $rUnits) * $reprocessing);
|
||||
$composition['Caesium'] += floor(($thirdComp->Caesium * $rUnits) * $reprocessing);
|
||||
$composition['Mercury'] += floor(($thirdComp->Mercury * $rUnits) * $reprocessing);
|
||||
$composition['Dysprosium'] += floor(($thirdComp->Dysprosium * $rUnits) * $reprocessing);
|
||||
$composition['Neodymium'] += floor(($thirdComp->Neodymium * $rUnits) * $reprocessing);
|
||||
$composition['Promethium'] += floor(($thirdComp->Promethium * $rUnits) * $reprocessing);
|
||||
$composition['Thulium'] += floor(($thirdComp->Thulium * $rUnits) * $reprocessing);
|
||||
}
|
||||
|
||||
//Get the composition for the fourth ore if it is not None.
|
||||
//Add the fourth ore composition to the final composition
|
||||
if($fourthOre != 'None') {
|
||||
//Get the ore's composition
|
||||
$fourthComp = $moonCalc->GetOreComposition($fourthOre);
|
||||
//Get the amount of units mine-able from the moon
|
||||
$mUnits = $moonCalc->CalcOreUnits($fourthOre, $fourthQuantity);
|
||||
//Calculate the number of reprocessing units to happen from moon units
|
||||
$rUnits = floor($mUnits / 100.0);
|
||||
|
||||
$composition['Tritanium'] += floor(($fourthComp->Tritanium * $rUnits) * $reprocessing);
|
||||
$composition['Pyerite'] += floor(($fourthComp->Pyerite * $rUnits) * $reprocessing);
|
||||
$composition['Mexallon'] += floor(($fourthComp->Mexallon * $rUnits) * $reprocessing);
|
||||
$composition['Isogen'] += floor(($fourthComp->Isogen * $rUnits) * $reprocessing);
|
||||
$composition['Nocxium'] += floor(($fourthComp->Nocxium * $rUnits) * $reprocessing);
|
||||
$composition['Zydrine'] += floor(($fourthComp->Zydrine * $rUnits) * $reprocessing);
|
||||
$composition['Megacyte'] += floor(($fourthComp->Megacyte * $rUnits) * $reprocessing);
|
||||
$composition['Atmospheric_Gases'] += floor(($fourthComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||
$composition['Evaporite_Deposits'] += floor(($fourthComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||
$composition['Hydrocarbons'] += floor(($fourthComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||
$composition['Silicates'] += floor(($fourthComp->Silicates * $rUnits) * $reprocessing);
|
||||
$composition['Cobalt'] += floor(($fourthComp->Cobalt * $rUnits) * $reprocessing);
|
||||
$composition['Scandium'] += floor(($fourthComp->Scandium * $rUnits) * $reprocessing);
|
||||
$composition['Titanium'] += floor(($fourthComp->Titanium * $rUnits) * $reprocessing);
|
||||
$composition['Tungsten'] += floor(($fourthComp->Tungsten * $rUnits) * $reprocessing);
|
||||
$composition['Cadmium'] += floor(($fourthComp->Cadmium * $rUnits) * $reprocessing);
|
||||
$composition['Platinum'] += floor(($fourthComp->Platinium * $rUnits) * $reprocessing);
|
||||
$composition['Vanadium'] += floor(($fourthComp->Vanadium * $rUnits) * $reprocessing);
|
||||
$composition['Chromium'] += floor(($fourthComp->Chromium * $rUnits) * $reprocessing);
|
||||
$composition['Technetium'] += floor(($fourthComp->Technetium * $rUnits) * $reprocessing);
|
||||
$composition['Hafnium'] += floor(($fourthComp->Hafnium * $rUnits) * $reprocessing);
|
||||
$composition['Caesium'] += floor(($fourthComp->Caesium * $rUnits) * $reprocessing);
|
||||
$composition['Mercury'] += floor(($fourthComp->Mercury * $rUnits) * $reprocessing);
|
||||
$composition['Dysprosium'] += floor(($fourthComp->Dysprosium * $rUnits) * $reprocessing);
|
||||
$composition['Neodymium'] += floor(($fourthComp->Neodymium * $rUnits) * $reprocessing);
|
||||
$composition['Promethium'] += floor(($fourthComp->Promethium * $rUnits) * $reprocessing);
|
||||
$composition['Thulium'] += floor(($fourthComp->Thulium * $rUnits) * $reprocessing);
|
||||
}
|
||||
|
||||
return view('moons.user.displayTotalWorth')->with('totalWorth', $totalWorth)
|
||||
->with('composition', $composition)
|
||||
->with('reprocessing', $reprocessing);
|
||||
}
|
||||
}
|
||||
|
||||
62
app/Http/Controllers/Moons/RentalMoonsAdminController.php
Normal file
62
app/Http/Controllers/Moons/RentalMoonsAdminController.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Moons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\AllianceRentalMoon;
|
||||
|
||||
class RentalMoonsAdminController extends Controller
|
||||
{
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middelware('role:user');
|
||||
$this->middleware('permission:mining.director');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display rental moons being used for the alliance
|
||||
*/
|
||||
public function displayAllianceUsageRentalMoons() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display the form for requesting new rental moon for the alliance
|
||||
*/
|
||||
public function displayRentalMoonForAllianceForm() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to store when a new rental moon is requested
|
||||
*/
|
||||
public function storeRentalMoonForAlliance(Request $request) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the form for figuring out item composition
|
||||
*/
|
||||
public function displayItemCompositionForm() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the results of the form for figuring out item composition
|
||||
*/
|
||||
public function displayItemCompositionResults(Request $request) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ namespace App\Http\Controllers\SRP;
|
||||
//Laravel Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Auth;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
use Carbon\Carbon;
|
||||
@@ -34,6 +33,7 @@ class SRPAdminController extends Controller
|
||||
|
||||
//Create the array
|
||||
$requests = array();
|
||||
$viewShipTypes = array();
|
||||
|
||||
//Declare variables for use later.
|
||||
$sum_actual = 0.00;
|
||||
@@ -42,6 +42,12 @@ class SRPAdminController extends Controller
|
||||
//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();
|
||||
|
||||
@@ -67,6 +73,7 @@ class SRPAdminController extends Controller
|
||||
foreach($shipTypes as $s) {
|
||||
if($r['ship_type'] == $s->code) {
|
||||
$temp['ship_type'] = $s->description;
|
||||
$temp['cost_code'] = $s->code;
|
||||
}
|
||||
}
|
||||
//Get the fleet type
|
||||
@@ -78,8 +85,13 @@ class SRPAdminController extends Controller
|
||||
//Calculate the recommended srp amount
|
||||
foreach($payouts as $p) {
|
||||
if($r['ship_type'] == $p->code) {
|
||||
$temp['actual_srp'] = $r['loss_value'] * ($p->payout / 100.00 );
|
||||
$temp['cost_code'] = $p->payout;
|
||||
$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'];
|
||||
}
|
||||
}
|
||||
@@ -95,7 +107,28 @@ class SRPAdminController extends Controller
|
||||
//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('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) {
|
||||
@@ -105,23 +138,26 @@ class SRPAdminController extends Controller
|
||||
'approved' => 'required',
|
||||
'paid_value' => 'required',
|
||||
]);
|
||||
//Get the paid value from the form
|
||||
$paidValue = str_replace(',', '', $request->paid_value);
|
||||
|
||||
//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_value' => $paidValue,
|
||||
'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_value' => $paidValue,
|
||||
'paid_by_id' => auth()->user()->character_id,
|
||||
'paid_by_name' => auth()->user()->name,
|
||||
'paid_value' => $paidLoss,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -132,6 +168,20 @@ class SRPAdminController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Http\Controllers\SRP;
|
||||
//Laravel Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Auth;
|
||||
|
||||
//User Libraries
|
||||
@@ -25,6 +24,10 @@ class SRPController extends Controller
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function displaySrpHistory() {
|
||||
|
||||
}
|
||||
|
||||
public function displayPayoutAmounts() {
|
||||
$payouts = array();
|
||||
$count = 0;
|
||||
@@ -112,6 +115,7 @@ class SRPController extends Controller
|
||||
$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);
|
||||
|
||||
156
app/Http/Controllers/SystemRentals/RentalAdminController.php
Normal file
156
app/Http/Controllers/SystemRentals/RentalAdminController.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SystemRentals;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\SystemRentals\RentalSystem;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
class RentalAdminController extends Controller
|
||||
{
|
||||
//Constructor
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display all active rental systems and
|
||||
* the information regarding the rental systems
|
||||
*/
|
||||
public function displayRentalSystems() {
|
||||
//Get the rental systems from the database
|
||||
$rentals = RentalSystem::all();
|
||||
|
||||
foreach($rentals as $rental) {
|
||||
//Format the rental cost
|
||||
if($rental->rental_cost > 1000000000.00) {
|
||||
$rental->rental_cost = $rental->rental_cost / 1000000000.00;
|
||||
$rental->rental_cost = $rental->rental_cost . "B";
|
||||
} else if($rental->rental_cost > 1000000.00 && $rental->rental_cost < 999999999.99) {
|
||||
$rental->rental_cost = $rental->rental_cost / 1000000.00;
|
||||
$rental->rental_cost = $rental->rental_cost . "M";
|
||||
}
|
||||
|
||||
//Format the date
|
||||
$rental->paid_until = Carbon::parse($rental->paid_until)->format('Y-m-d');
|
||||
}
|
||||
|
||||
//Return the view with the data
|
||||
return view('rental.list')->with('rentals', $rentals);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display form for adding new rental system
|
||||
*/
|
||||
public function displayAddRentalSystem() {
|
||||
return view('rental.add');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to add new rental system to the database
|
||||
*/
|
||||
public function addRentalSystem(Request $request) {
|
||||
$this->validate($request, [
|
||||
'contact_name' => 'required',
|
||||
'contact_corp_name' => 'required',
|
||||
'system' => 'required',
|
||||
'rental_cost' => 'required',
|
||||
'paid_until' => 'required',
|
||||
]);
|
||||
|
||||
//Declare the variables and classes needed
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//From the character name find the character id
|
||||
$charId = $lookup->CharacterNameToId($request->contact_name);
|
||||
|
||||
//From the corporation name find the corporation id
|
||||
$corpId = $lookup->CorporationNameToId($request->contact_corp_name);
|
||||
|
||||
//From the system name find the system id
|
||||
$systemId = $lookup->SystemNameToId($request->system);
|
||||
|
||||
//Sanitize the bid amount
|
||||
if(preg_match('(m|M|b|B)', $request->rental_cost) === 1) {
|
||||
if(preg_match('(m|M)', $request->rental_cost) === 1) {
|
||||
$cStringSize = strlen($request->rental_cost);
|
||||
$tempCol = str_split($request->rental_cost, $cStringSize - 1);
|
||||
$rentalCost = $tempCol[0];
|
||||
$rentalCost = $rentalCost * 1000000.00;
|
||||
} else if(preg_match('(b|B)', $request->rental_cost) === 1) {
|
||||
$cStringSize = strlen($request->rental_cost);
|
||||
$tempCol = str_split($request->rental_cost, $cStringSize - 1);
|
||||
$rentalCost = $tempCol[0];
|
||||
$rentalCost = $rentalCost * 1000000000.00;
|
||||
}
|
||||
} else {
|
||||
$rentalCost = $request->rental_cost;
|
||||
}
|
||||
|
||||
//Create the database model
|
||||
$rental = new RentalSystem;
|
||||
$rental->contact_id = $charId;
|
||||
$rental->contact_name = $request->contact_name;
|
||||
$rental->corporation_id = $corpId;
|
||||
$rental->corporation_name = $request->contact_corp_name;
|
||||
$rental->system_id = $systemId;
|
||||
$rental->system_name = $request->system;
|
||||
$rental->rental_cost = $rentalCost;
|
||||
$rental->paid_until = $request->paid_until;
|
||||
$rental->save();
|
||||
|
||||
return redirect('/system/rental/dashboard')->with('success', 'Rental System Added.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to update paid until section of the rental system in the database
|
||||
*/
|
||||
public function updateRentalSystem(Request $request) {
|
||||
$this->validate($request, [
|
||||
'paid_until' => 'required',
|
||||
'contact_id' => 'required',
|
||||
'corporation_id' => 'required',
|
||||
'system_id' => 'required',
|
||||
]);
|
||||
|
||||
RentalSystem::where([
|
||||
'contact_id' => $request->contact_id,
|
||||
'corporation_id' => $request->corporation_id,
|
||||
'system_id' => $request->system_id,
|
||||
])->update([
|
||||
'paid_until' => $request->paid_until,
|
||||
]);
|
||||
|
||||
return redirect('/system/rental/dashboard')->with('success', 'Rental System updated.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to remove rental system from the database
|
||||
*/
|
||||
public function removeRentalSystem(Request $request) {
|
||||
$this->validate($request, [
|
||||
'contact_id' => 'required',
|
||||
'corporation_id' => 'required',
|
||||
'system_id' => 'required',
|
||||
]);
|
||||
|
||||
RentalSystem::where([
|
||||
'contact_id' => $request->contact_id,
|
||||
'corporation_id' => $request->corporation_id,
|
||||
'system_id' => $request->system_id,
|
||||
])->delete();
|
||||
|
||||
return redirect('/system/rental/dashboard')->with('success', 'Removed renter from database.');
|
||||
}
|
||||
}
|
||||
25
app/Http/Controllers/Test/TestController.php
Normal file
25
app/Http/Controllers/Test/TestController.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Test;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
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 CharacterLookupTest(Request $request) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,11 @@ 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;
|
||||
use App\Library\Wiki\WikiHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Doku\DokuGroupNames;
|
||||
@@ -25,42 +25,6 @@ class WikiController extends Controller
|
||||
$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) {
|
||||
//Let's look up the character in the user table by their name.
|
||||
//If no name is found, then delete the user and have them start over with the wiki permissions
|
||||
$count = User::where(['name' => $user])->count();
|
||||
if($count > 0) {
|
||||
$charIdTemp = User::where(['name' => $user])->get(['character_id']);
|
||||
$charId = $charIdTemp[0]->character_id;
|
||||
$corpId = $helper->LookupCharacter($charId);
|
||||
$allianceId = $helper->LookupCorporation($corpId);
|
||||
|
||||
if(in_array($allianceId, $legacy) || in_array($allianceId, $renter) || $allianceId == 99004116) {
|
||||
//Do nothing
|
||||
} else {
|
||||
$this->DeleteWikiUser($user);
|
||||
}
|
||||
} else {
|
||||
$this->DeleteWikiUser($user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return redirect('/admin/dashboard')->with('success', 'Wiki has been purged.');
|
||||
}
|
||||
|
||||
public function displayRegister() {
|
||||
//make user name syntax like we want it.
|
||||
$name = Auth::user()->name;
|
||||
@@ -68,9 +32,19 @@ class WikiController extends Controller
|
||||
$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!');
|
||||
$count = DokuUser::where([
|
||||
'login' => $name,
|
||||
])->count();
|
||||
|
||||
//If the count is greater than zero, also check the login name as a reference
|
||||
if($count > 0) {
|
||||
$check = DokuUser::where([
|
||||
'login' => $name,
|
||||
])->first();
|
||||
|
||||
if($check->login === $name) {
|
||||
return redirect('/dashboard')->with('error', 'Already registered for the wiki!');
|
||||
}
|
||||
}
|
||||
|
||||
return view('wiki.user.register')->with('name', $name);
|
||||
@@ -93,8 +67,10 @@ class WikiController extends Controller
|
||||
|
||||
if(Auth::user()->hasRole('User')) {
|
||||
$role = 1; //User role id from wiki_groupname table
|
||||
$roleDescription = 'user';
|
||||
} else if(Auth::user()->hasRole('Renter')) {
|
||||
$role = 8; //Renter role id from wiki_groupname table
|
||||
$roleDescription = 'renter';
|
||||
}
|
||||
|
||||
//Load the model
|
||||
@@ -113,10 +89,16 @@ class WikiController extends Controller
|
||||
$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;
|
||||
$uid = DokuUser::where([
|
||||
'login' => $name,
|
||||
])->first();
|
||||
|
||||
//Save information in the model
|
||||
$member->uid = $uid->id;
|
||||
$member->gid = $role;
|
||||
$member->groupname = $roleDescription;
|
||||
$member->save();
|
||||
|
||||
//Return to the dashboard view
|
||||
return redirect('/dashboard')->with('success', 'Registration successful. Your username is: ' . $name);
|
||||
}
|
||||
@@ -125,9 +107,14 @@ class WikiController extends Controller
|
||||
$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!');
|
||||
|
||||
//Get the password
|
||||
$check = DokuUser::where([
|
||||
'login' => $name
|
||||
])->count();
|
||||
|
||||
if($check == 0) {
|
||||
return redirect('/dashboard')->with('error', 'Login Not Found');
|
||||
}
|
||||
|
||||
return view('wiki.user.changepassword')->with('name', $name);
|
||||
@@ -152,45 +139,14 @@ class WikiController extends Controller
|
||||
$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]);
|
||||
DokuUser::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);
|
||||
}
|
||||
|
||||
private function DeleteWikiUser($user) {
|
||||
//Get the uid of the user as we will need to purge them from the member table as well.
|
||||
//the member table holds their permissions.
|
||||
$uid = DokuUser::where([
|
||||
'name' => $user,
|
||||
])->value('id');
|
||||
//Delete the permissions of the user first.
|
||||
DokuMember::where([
|
||||
'uid' => $uid,
|
||||
])->delete();
|
||||
|
||||
//Delete the user from the user table
|
||||
DokuUser::where(['name' => $user])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wormholes;
|
||||
|
||||
//Laravel Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
|
||||
//User Libraries
|
||||
|
||||
//Models
|
||||
use App\Models\Wormholes\AllianceWormhole;
|
||||
use App\Models\Wormholes\WormholeType;
|
||||
|
||||
class WormholeController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function displayWormholeForm() {
|
||||
//Declare a few array variables
|
||||
$duration = array();
|
||||
$class = array();
|
||||
$stability = array();
|
||||
$size = array();
|
||||
|
||||
//Get the duration from the table
|
||||
$duration = [
|
||||
'This wormhole has not yet begun its natural cycle of decay and should last at least another day.',
|
||||
'This wormhole is beginning to decay, but will not last another day.',
|
||||
'This wormhole is reaching the end of its natural lifetime',
|
||||
];
|
||||
|
||||
//Get the wh classes from the table
|
||||
$class = [
|
||||
'C1',
|
||||
'C2',
|
||||
'C3',
|
||||
'C4',
|
||||
'C5',
|
||||
'C6',
|
||||
'C7',
|
||||
'C8',
|
||||
'C9',
|
||||
'C13',
|
||||
'Drifter',
|
||||
'Thera',
|
||||
'Exit WH',
|
||||
];
|
||||
|
||||
//Get the wh types from the table
|
||||
$type = WormholeType::pluck('type');
|
||||
|
||||
//Get the wh sizes from the table
|
||||
$size = [
|
||||
'XS',
|
||||
'S',
|
||||
'M',
|
||||
'L',
|
||||
'XL',
|
||||
];
|
||||
|
||||
//Get the wh stabilities from the table
|
||||
$stability = [
|
||||
'Stable',
|
||||
'Non-Critical',
|
||||
'Critical',
|
||||
];
|
||||
|
||||
//Return all the variables to the view
|
||||
return view('wormholes.form')->with('class', $class)
|
||||
->with('type', $type)
|
||||
->with('size', $size)
|
||||
->with('stability', $stability)
|
||||
->with('duration', $duration);
|
||||
}
|
||||
|
||||
public function storeWormhole() {
|
||||
$this->validate($request, [
|
||||
'sig' => 'required',
|
||||
'duration' => 'required',
|
||||
'dateTiume' => 'required',
|
||||
'class' => 'required',
|
||||
'size' => 'required',
|
||||
'stability' => 'required',
|
||||
'type' => 'required',
|
||||
'system' => 'required',
|
||||
]);
|
||||
|
||||
//Declare some variables
|
||||
$duration = null;
|
||||
|
||||
//Create the stable time for the database
|
||||
if($request->duraiton == 'This wormhole has not yet begun its natural cycle of decay and should last at least another day.') {
|
||||
$duration = '>24 hours';
|
||||
} else if ($request->duration == 'This wormhole is beginning to decay, but will not last another day.') {
|
||||
$duration = '>4 hours <24 hours';
|
||||
} else if($request->duration == 'This wormhole is reaching the end of its natural lifetime') {
|
||||
'<4 hours';
|
||||
}
|
||||
|
||||
//Get the wormhole type from the database so we can enter other details
|
||||
$wormholeType = WormholeType::where([
|
||||
'type' => $request->type,
|
||||
])->first();
|
||||
|
||||
$found = AllianceWormhole::where([
|
||||
'system' => $request->system,
|
||||
'sig_ig' => $request->sig,
|
||||
])->count();
|
||||
|
||||
if($found == 0) {
|
||||
AllianceWormhole::insert([
|
||||
'system' => $request->system,
|
||||
'sig_id' => $request->sig_id,
|
||||
'duration_left' => $duration,
|
||||
'dateTime' => $request->dateTime,
|
||||
'class' => $request->class,
|
||||
'type' => $request->type,
|
||||
'hole_size' => $request->size,
|
||||
'stability' => $request->stability,
|
||||
'details' => $request->details,
|
||||
'link' => $request->link,
|
||||
'mass_allowed' => $wormholeType->mass_allowed,
|
||||
'individual_mass' => $wormholeType->individual_mass,
|
||||
'regeneration' => $wormholeType->regeneration,
|
||||
'max_stable_time' => $wormholeType->max_stable_time,
|
||||
]);
|
||||
|
||||
return redirect('/wormholes/display')->with('success', 'Wormhole Info Added.');
|
||||
} else {
|
||||
return redirect('/wormholes/display')->with('error', 'Wormhole already in database.');
|
||||
}
|
||||
}
|
||||
|
||||
public function displayWormholes() {
|
||||
//Create the date and time
|
||||
$dateTime = Carbon::now()->subDays(2);
|
||||
|
||||
//Get all of the wormholes from the last 48 hours from the database to display
|
||||
$wormholes = AllianceWormholes::where('created_at', '>=', $dateTime)->get();
|
||||
|
||||
return view('wormholes.display')->with('wormholes', $wormholes);
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ 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,
|
||||
//'callback' => \App\Http\Middleware\Callback::class,
|
||||
'role' => \App\Http\Middleware\RequireRole::class,
|
||||
'permission' => \App\Http\Middleware\RequirePermission::class,
|
||||
];
|
||||
|
||||
@@ -2,29 +2,120 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
//Internal Library
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use Socialite;
|
||||
use DB;
|
||||
use App\Models\User\User;
|
||||
|
||||
//Libraries
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
class Callback
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
* Handle an incoming request for callback. Set to handle the request after the
|
||||
* login controller does what it needs to do.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
public function handle($request, Closure $next, $ssoUser)
|
||||
{
|
||||
return $next($request);
|
||||
$response = $next($request);
|
||||
|
||||
if(isset($ssoUser->refreshToken)) {
|
||||
//See if an access token is present for the user
|
||||
$tokenCount = EsiToken::where(['character_id' => $ssoUser->id])->count();
|
||||
if($tokenCount > 0) {
|
||||
//Update the esi token
|
||||
$this->UpdateEsiToken($ssoUser);
|
||||
} else {
|
||||
//Save the esi token
|
||||
$this->SaveEsiToken($ssoUser);
|
||||
}
|
||||
|
||||
//After creating or updating the token, update the table for the scopes.
|
||||
$this->SetScopes($ssoUser->user['Scopes'], $ssoUser->id);
|
||||
} else {
|
||||
$created = $this->createAlt($ssoUser);
|
||||
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ESI Token
|
||||
*/
|
||||
private function UpdateEsiToken($eve_user) {
|
||||
EsiToken::where('character_id', $eve_user->id)->update([
|
||||
'character_id' => $eve_user->getId(),
|
||||
'access_token' => $eve_user->token,
|
||||
'refresh_token' => $eve_user->refreshToken,
|
||||
'inserted_at' => time(),
|
||||
'expires_in' => $eve_user->expiresIn,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ESI Token in the database
|
||||
*/
|
||||
private function SaveEsiToken($eve_user) {
|
||||
$token = new EsiToken;
|
||||
$token->character_id = $eve_user->id;
|
||||
$token->access_token = $eve_user->token;
|
||||
$token->refresh_token = $eve_user->refreshToken;
|
||||
$token->inserted_at = time();
|
||||
$token->expires_in = $eve_user->expiresIn;
|
||||
$token->save();
|
||||
}
|
||||
|
||||
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;
|
||||
$data->scope = $scope;
|
||||
$data->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
$altCount = UserAlt::where('character_id', $user->id)->count();
|
||||
if($altCount == 0) {
|
||||
$newAlt = new UserAlt;
|
||||
$newAlt->name = $user->getName();
|
||||
$newAlt->main_id = auth()->user()->getId();
|
||||
$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();
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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',
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
40
app/Jobs/Commands/Eve/ItemPricesUpdateJob.php
Normal file
40
app/Jobs/Commands/Eve/ItemPricesUpdateJob.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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 ItemPricesUpdateJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$moonHelper = new MoonCalc;
|
||||
|
||||
$moonHelper->FetchNewPrices();
|
||||
}
|
||||
}
|
||||
152
app/Jobs/Commands/Moons/FetchMoonLedgerJob.php
Normal file
152
app/Jobs/Commands/Moons/FetchMoonLedgerJob.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Moons;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Moon\CorpMoonLedger;
|
||||
use App\Models\Moon\CorpMoonObserver;
|
||||
|
||||
|
||||
class FetchMoonLedgerJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Private Variables
|
||||
*/
|
||||
private $charId;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId)
|
||||
{
|
||||
//Set the character id
|
||||
$this->charId = $charId;
|
||||
|
||||
//Set the connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare Variables
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
$response = null;
|
||||
$structureInfo = null;
|
||||
|
||||
//Get the configuration for the main site
|
||||
$config = config('esi');
|
||||
|
||||
//Check for esi scope for the character
|
||||
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($this->charId, 'esi-universe.read_structures.v1')) {
|
||||
Log::critical('The primary character does not have the necessary scopes for FetchRentalMoonLedgerCommand.');
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the refresh token if the scope checks have passed
|
||||
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
|
||||
|
||||
//Setup the esi information
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Get the character data from the lookup table
|
||||
$character = $lookup->GetCharacterInfo($this->charId);
|
||||
|
||||
//Get the corporation data from the lookup table
|
||||
$corporation = $lookup->GetCorporationInfo($character->corporation_id);
|
||||
|
||||
//Setup the structure helper
|
||||
$structure = new StructureHelper($this->charId, $character->corporation_id, $esi);
|
||||
|
||||
//Get the moon observers from the database
|
||||
$observers = CorpMoonObserver::where([
|
||||
'corporation_id' => $character->corporation_id,
|
||||
])->get();
|
||||
|
||||
foreach($observers as $observer) {
|
||||
//Try to get the ledger data from the esi
|
||||
try {
|
||||
$ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
'observer_id' => $observer->observer_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//Log the exception
|
||||
Log::critical('FetchMoonLedger job failed to get the mining ledgers.');
|
||||
}
|
||||
|
||||
if($ledgers != null) {
|
||||
foreach($ledgers as $ledger) {
|
||||
//Get the ore name from the lookup table
|
||||
$ore = $lookup->ItemIdToName($ledger->type_id);
|
||||
|
||||
//Get the character name from the lookup helper
|
||||
$charInfo = $lookup->GetCharacterInfo($ledger->character_id);
|
||||
//Get the corporation info from the lookup helper
|
||||
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||
//Get the recorded corporation information
|
||||
$recordedCorpInfo = $lookup->GetCorporationInfo($ledger->recorded_corporation_id);
|
||||
|
||||
$entries[] = [
|
||||
'corporation_id' => $corpInfo->corporation_id,
|
||||
'corporation_name' => $corpInfo->name,
|
||||
'character_id' => $ledger->character_id,
|
||||
'character_name' => $charInfo->name,
|
||||
'observer_id' => $observer->observer_id,
|
||||
'observer_name' => $observer->observer_name,
|
||||
'type_id' => $ledger->type_id,
|
||||
'ore' => $ore,
|
||||
'quantity' => $ledger->quantity,
|
||||
'recorded_corporation_id' => $ledger->recorded_corporation_id,
|
||||
'recorded_corporation_name' => $recordedCorpInfo->name,
|
||||
'last_updated' => $ledger->last_updated,
|
||||
'created_at' => $ledger->last_updated . ' 23:59:59',
|
||||
'updated_at' => $ledger->last_updated . ' 23:59:59',
|
||||
];
|
||||
}
|
||||
|
||||
//Insert or ignore each entry into the database
|
||||
CorpMoonLedger::insertOrIgnore($entries);
|
||||
|
||||
Log::info('FetchMoonLedgerJob inserted up to ' . count($entries) . 'into the database.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
130
app/Jobs/Commands/Moons/FetchMoonObserverJob.php
Normal file
130
app/Jobs/Commands/Moons/FetchMoonObserverJob.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Moons;
|
||||
|
||||
//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 Log;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Moon\CorpMoonObserver;
|
||||
|
||||
class FetchMoonObserverJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Private variables
|
||||
*/
|
||||
private $charId;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId)
|
||||
{
|
||||
//Set the character id
|
||||
$this->charId = $charId;
|
||||
|
||||
//Set the connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare some variables
|
||||
$lookup = new LookupHelper;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Get the configuration from the main site
|
||||
$config = config('esi');
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($this->charId, 'esi-universe.read_structures.v1')) {
|
||||
Log::warning('Esi scopes were not found for Fetch Moon Observers job.');
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the refresh token for the character
|
||||
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Get the esi variable
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//With the lookup helper, get the character information
|
||||
$character = $lookup->GetCharacterInfo($this->charId);
|
||||
//With the lookup helper, get the corporation information
|
||||
$corporation = $lookup->GetCorporationInfo($character->corporation_id);
|
||||
|
||||
//Delcare the structure helper since we have the necessary data
|
||||
$structureHelper = new StructureHelper($this->charId, $character->corporation_id, $esi);
|
||||
|
||||
//Get the mining observers for the corporation's from esi
|
||||
try {
|
||||
$response = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical('FetchMoonObservers failed to get the moon observers for the corporation');
|
||||
return null;
|
||||
}
|
||||
|
||||
//Run through the mining observers, and add them to the database as needed
|
||||
foreach($response as $observer) {
|
||||
$count = CorpMoonObserver::where(['observer_id' => $observer->observer_id])->count();
|
||||
//If the observer is not found, then add it to the database
|
||||
if($count == 0) {
|
||||
//Get the structure information from the universe structure esi endpoint
|
||||
$structureInfo = $structureHelper->GetStructureInfo($observer->observer_id);
|
||||
//Create a new corp moon observer in the database
|
||||
$obs = new CorpMoonObserver;
|
||||
$obs->corporation_id = $character->corporation_id;
|
||||
$obs->corporation_name = $corporation->name;
|
||||
$obs->observer_id = $observer->observer_id;
|
||||
$obs->observer_name = $structureInfo->name;
|
||||
$obs->observer_owner_id = $structureInfo->owner_id;
|
||||
$obs->solar_system_id = $structureInfo->solar_system_id;
|
||||
$obs->observer_type = $observer->observer_type;
|
||||
$obs->observer_type_id = $structureInfo->type_id;
|
||||
$obs->last_updated = $observer->last_updated;
|
||||
$obs->save();
|
||||
} else {
|
||||
CorpMoonObserver::where([
|
||||
'observer_id' => $observer->observer_id,
|
||||
])->update([
|
||||
'last_updated' => $observer->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
58
app/Jobs/Commands/Moons/PurgeMoonLedgerJob.php
Normal file
58
app/Jobs/Commands/Moons/PurgeMoonLedgerJob.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Moons;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//App Models
|
||||
use App\Models\Moon\CorpMoonLedger;
|
||||
|
||||
class PurgeMoonLedgerJob 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()
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$previous = Carbon::now()->subDays(60);
|
||||
|
||||
//Remove old ledger entries
|
||||
CorpMoonLedger::where('created_at', '<', $previous)->delete();
|
||||
}
|
||||
}
|
||||
143
app/Jobs/Commands/Not Used/FetchRentalMoonLedgerJob.php
Normal file
143
app/Jobs/Commands/Not Used/FetchRentalMoonLedgerJob.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\RentalMoonLedger;
|
||||
use App\Models\RentalMoonObserver;
|
||||
|
||||
class FetchRentalMoonLedgerJob 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()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
$response = null;
|
||||
$structureInfo = null;
|
||||
$entries = array();
|
||||
|
||||
//Get the configuration for the main site
|
||||
$config = config('esi');
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1')) {
|
||||
Log::critical('The primary character does not have the necessary scopes for FetchRentalMoonLedgerCommand.');
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the refresh token if scope checks have passed
|
||||
$refreshToken = $esiHelper->GetRefreshtoken($config['primary']);
|
||||
|
||||
//Get the character data from the lookup table if possible or esi
|
||||
$character = $lookup->GetCharacterInfo($config['primary']);
|
||||
|
||||
//Get all of the rental moon observers from the database
|
||||
$observers = RentalMoonObserver::all();
|
||||
|
||||
//Dump the mining ledger table for rental moons
|
||||
RentalMoonLedger::truncate();
|
||||
|
||||
//Foreach observer get the ledger
|
||||
foreach($observers as $observer) {
|
||||
//Get the observer name.
|
||||
$observerInfo = Structure::where([
|
||||
'structure_id' => $observer->observer_id,
|
||||
])->first();
|
||||
|
||||
try {
|
||||
$ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
'observer_id' => $observer->observer_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//If an exception has occurred, then log it
|
||||
Log::critical('FetchRentalMoonLedger command failed to get the mining ledger for observer id: ' . $observer->observer_id);
|
||||
}
|
||||
|
||||
if($ledgers != null) {
|
||||
foreach($ledgers as $ledger) {
|
||||
//Get the ore name from the lookup table
|
||||
$ore = $lookup->ItemIdToName($ledger->type_id);
|
||||
|
||||
//Get the character name from the lookup helper using the characterId
|
||||
$charInfo = $lookup->GetCharacterInfo($ledger->character_id);
|
||||
//Get the corporation information
|
||||
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||
|
||||
//Get the recorded corporation information
|
||||
$recordedCorpInfo = $lookup->GetCorporationInfo($ledger->recorded_corporation_id);
|
||||
|
||||
$entries[] = [
|
||||
'corporation_id' => $corpInfo->corporation_id,
|
||||
'corporation_name' => $corpInfo->name,
|
||||
'character_id' => $ledger->character_id,
|
||||
'character_name' => $charInfo->name,
|
||||
'observer_id' => $observer->observer_id,
|
||||
'observer_name' => $observerInfo->name,
|
||||
'type_id' => $ledger->type_id,
|
||||
'ore' => $ore,
|
||||
'quantity' => $ledger->quantity,
|
||||
'recorded_corporation_id' => $ledger->recorded_corporation_id,
|
||||
'recorded_corporation_name' => $recordedCorpInfo->name,
|
||||
'last_updated' => $ledger->last_updated,
|
||||
'created_at' => $ledger->last_updated . ' 23:59:59',
|
||||
'updated_at' => $ledger->last_updated . ' 23:59:59',
|
||||
];
|
||||
}
|
||||
|
||||
//Insert or ignore each of the records saved into the array through the foreach loop
|
||||
RentalMoonLedger::insertOrIgnore($entries);
|
||||
|
||||
Log::info(
|
||||
'FetchRentalMoonLedgerJob inserted up to ' .count($entires) . ' new ledger entries.'
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
97
app/Jobs/Commands/Not Used/FetchRentalMoonObserversJob.php
Normal file
97
app/Jobs/Commands/Not Used/FetchRentalMoonObserversJob.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
|
||||
//App Models
|
||||
use App\Models\Moon\RentalMoonObserver;
|
||||
|
||||
class FetchRentalMoonObserversJob 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()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare some variables
|
||||
$lookup = new LookupHelper;
|
||||
$esi = new Esi;
|
||||
$obss = array();
|
||||
|
||||
//Get the configuration for the main site
|
||||
$config = config('esi');
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1')) {
|
||||
Log::critical('The primary character does not have the necessary scopes for FetchRentalMoonObservers.');
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the refresh token for spatial forces
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
|
||||
//Get the character data from the lookup table if possible or esi
|
||||
$character = $lookup->GetCharacterInfo($config['primary']);
|
||||
|
||||
//Get the mining observers for spatial forces from esi
|
||||
try {
|
||||
$responses = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical('RentalMoonObservers failed to get the moon observers for Spatial Forces.');
|
||||
}
|
||||
|
||||
//Run through the mining observers, and add them to the database as needed
|
||||
foreach($responses as $observer) {
|
||||
//Populate the array with the data, so we can do an insert or ignore after the foreach loop is completed.
|
||||
$obss[] = [
|
||||
'observer_id' => $observer->observer_id,
|
||||
'observer_type' => $observer->observer_type,
|
||||
'last_updated' => $esi->DecodeDate($observer->last_updated)
|
||||
];
|
||||
}
|
||||
|
||||
RentalMoonObserver::insertOrIgnore($obss);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\PublicContracts;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\PublicContracts\GetPublicContractItemsJob;
|
||||
|
||||
//Models
|
||||
use App\Models\PublicContracts\PublicContract;
|
||||
use App\Models\PublicContracts\PUblicContractItem;
|
||||
|
||||
class GetPublicContractItemsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Private Variables
|
||||
*/
|
||||
private $esi;
|
||||
private $contractId;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($esi, $contract)
|
||||
{
|
||||
//Setup the variables
|
||||
$this->esi = $esi;
|
||||
$this->contractId = $contract;
|
||||
|
||||
//Set the connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Get the items from esi
|
||||
$responses = $this->esi->invoke('get', '/contracts/public/items/{contract_id}/', [
|
||||
'contract_id' => $this->contract,
|
||||
]);
|
||||
|
||||
foreach($response as $resp) {
|
||||
//See if the item exists
|
||||
$count = PublicContractItems::where([
|
||||
'record_id' => $resp->record_id,
|
||||
])->count();
|
||||
|
||||
//If the item doesn't exist in the database, save it to the database
|
||||
if($count == 0) {
|
||||
$contractItem = new PublicContractItems;
|
||||
if(isset($resp->is_blueprint_copy)) {
|
||||
$contractItem->is_blueprint_copy = $resp->is_blueprint_copy;
|
||||
}
|
||||
$contractItem->is_included = $resp->is_included;
|
||||
if(isset($resp->item_id)) {
|
||||
$contractItem->item_id = $resp->item_id;
|
||||
}
|
||||
if(isset($resp->material_efficiency)) {
|
||||
$contractItem->material_efficiency = $resp->material_efficiency;
|
||||
}
|
||||
$contractItem->quantity = $resp->quantity;
|
||||
$contractItem->recorded_id = $resp->recorded_id;
|
||||
if(isset($resp->runs)) {
|
||||
$contractItem->runs = $resp->runs;
|
||||
}
|
||||
if(isset($resp->time_efficiency)) {
|
||||
$contractItem->time_efficiency = $resp->time_efficiency;
|
||||
}
|
||||
$contractItem->type_id = $resp->type_id;
|
||||
$contractItem->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
115
app/Jobs/Commands/PublicContracts/GetPublicContractsJob.php
Normal file
115
app/Jobs/Commands/PublicContracts/GetPublicContractsJob.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\PublicContracts;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHellper;
|
||||
|
||||
//Models
|
||||
use App\Models\PublicContracts\PublicContract;
|
||||
|
||||
class GetPublicContractsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Job Variables
|
||||
*/
|
||||
private $esi;
|
||||
private $region;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($regionId, $esi = null)
|
||||
{
|
||||
//Setup the esi authentication container
|
||||
if($esi == null) {
|
||||
$this->esi = new Esi();
|
||||
} else {
|
||||
$this->esi = $esi;
|
||||
}
|
||||
//Set the region code
|
||||
$this->region = $regionId;
|
||||
|
||||
//Set the connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* The job gets all of the contracts in a region
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$responses = $this->esi->invoke('get', '/contracts/public/{region_id}/', [
|
||||
'region_id' => $this->region,
|
||||
]);
|
||||
|
||||
foreach($response as $resp) {
|
||||
$count = PublicContract::where([
|
||||
'contract_id' => $resp->contract_id,
|
||||
])->count();
|
||||
if($count == 0) {
|
||||
$pub = new PublicContract;
|
||||
$pub->region_id = $this->region;
|
||||
if(isset($resp->buyout)) {
|
||||
$pub->buyout = $resp->buyout;
|
||||
}
|
||||
if(isset($resp->collateral)) {
|
||||
$pub->collateral = $resp->collateral;
|
||||
}
|
||||
$pub->contract_id = $resp->contract_id;
|
||||
$pub->date_expired = $resp->date_expired;
|
||||
$pub->date_issed = $resp->date_issed;
|
||||
if(isset($resp->days_to_complete)) {
|
||||
$pub->days_to_complete = $resp->days_to_complete;
|
||||
}
|
||||
if(isset($resp->end_location_id)) {
|
||||
$pub->end_location_id = $resp->end_location_id;
|
||||
}
|
||||
if(isset($resp->for_corporation)) {
|
||||
$pub->for_corporation = $resp->for_corporation;
|
||||
}
|
||||
$pub->issuer_corporation_id = $resp->issuer_corporation_id;
|
||||
$pub->issuer_id = $resp->issuer_id;
|
||||
if(isset($resp->price)) {
|
||||
$pub->price = $resp->price;
|
||||
}
|
||||
if(isset($resp->reward)) {
|
||||
$pub->reward = $resp->reward;
|
||||
}
|
||||
if(isset($resp->start_location_id)) {
|
||||
$pub->start_location_id = $resp->start_location_id;
|
||||
}
|
||||
if(isset($resp->title)) {
|
||||
$pub->title = $resp->title;
|
||||
}
|
||||
$pub->type = $resp->type;
|
||||
if(isset($resp->volume)) {
|
||||
$pub->volume = $resp->volume;
|
||||
}
|
||||
//Save the new contract
|
||||
$pub->save();
|
||||
|
||||
//Dispatch a job to collect the contract items
|
||||
GetPublicContractItemsJob::dispatch($this->esi, $resp->contract_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
68
app/Jobs/Commands/PublicContracts/PurgePublicContracts.php
Normal file
68
app/Jobs/Commands/PublicContracts/PurgePublicContracts.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\PublicContracts;
|
||||
|
||||
//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 Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
|
||||
//Models
|
||||
use App\Models\PublicContracts\PublicContract;
|
||||
use App\Models\PublicContracts\PublicContractItem;
|
||||
|
||||
|
||||
/**
|
||||
* Job to purge some old data from the public contracts
|
||||
*/
|
||||
class PurgePublicContracts implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Get today's date
|
||||
$today = Carbon::now();
|
||||
|
||||
//If the date for a contract has expired, then purge it from the system
|
||||
$contracts = PublicContract::all();
|
||||
|
||||
//Check each contract to see if it has expired
|
||||
foreach($contracts as $contract) {
|
||||
//If the contract has expired, then delete the contract and all of it's items
|
||||
if($today->greaterThan($contract->date_expired)) {
|
||||
//Delete the contract
|
||||
PublicContract::where([
|
||||
'id' => $contract->id,
|
||||
])->delete();
|
||||
|
||||
//Delete the items from the contract from the other table
|
||||
PublicContract::where([
|
||||
'contract_id' => $contract->id,
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\RentalMoons;
|
||||
|
||||
//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 Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEvveMailJob;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Mail\SentMail;
|
||||
|
||||
|
||||
/**
|
||||
* This job will send out a reminder about the moon rental payment being due
|
||||
* when it's due based on the rental paid date versus rental date. If the paid
|
||||
* date is in the future from today, then we don't need to send out a reminder.
|
||||
* If the paid date is today or less, then we need to send out a reminder about
|
||||
* paying for the moon rental.
|
||||
*/
|
||||
class SendMoonRentalPaymentReminderJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 1600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the queue connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Get today's date
|
||||
$today = Carbon::now();
|
||||
$today->second = 1;
|
||||
$today->minute = 0;
|
||||
$today->hour = 0;
|
||||
//Declare some other variables
|
||||
$totalCost = 0.00;
|
||||
$moonList = array();
|
||||
$delay = 30;
|
||||
$lookup = new LookupHelper;
|
||||
$config = config('esi');
|
||||
|
||||
//Get all of the contacts from the rentals group
|
||||
$contacts = AllianceMoonRental::select('rental_contact_id')->groupBy('rental_contact_id')->get();
|
||||
|
||||
//For each of the contacts, totalize the moon rentals, and create a reminder mail
|
||||
foreach($contacts as $contact) {
|
||||
//Get the moons the renter is renting, but only get the ones whose paid date is not after today.
|
||||
$dues = $this->GetMoonDueList($contact->rental_contact_id);
|
||||
|
||||
//Get the list of moons for the mail body.
|
||||
$alls = $this->GetMoonRentalList($contact->rental_contact_id);
|
||||
|
||||
//Totalize the cost for the moons whose rent is due
|
||||
$cost = $this->TotalizeMoonCost($contact->rental_contact_id);
|
||||
|
||||
//For each of the rentals, build the mail body, and totalize the cost of the moon
|
||||
$body = "Moon Rent is due for the following moons:<br>";
|
||||
foreach($rentalsDue as $due) {
|
||||
$body .= $due . "<br>";
|
||||
}
|
||||
//Put the price for the moons
|
||||
$body .= "The price for next month's rent is " . number_format($cost, 0, ".", ",") . "<br>";
|
||||
$body .= "Rental Payment is due on the 1st of the month. If the rental payment is not remitted to Spatial Forces by the 3rd of the month, the rental claim shall be forfeited.<br>";
|
||||
$body .= "Rental Payment should be transferred to Spatial Forces.<br>";
|
||||
$body .= "In the description of the payment please put the following transaction identification: " . $transId . "<br>";
|
||||
$body .= "<br>";
|
||||
$body .= $contact->contact_name . " is responsible for payment of the moons.<br>";
|
||||
$body .= "The following moons are being rented:<br>";
|
||||
foreach($alls as $all) {
|
||||
$body .= $all . "<br>";
|
||||
}
|
||||
$body .= "<br>";
|
||||
$body .= "Sincerely,<br>";
|
||||
$body .= "Warped Intentions Leadership<br>";
|
||||
|
||||
//Create the subject line
|
||||
$subject = "Warped Intentions Moon Rental Payment Due for " . $today->englishMonth;
|
||||
//Dispatch the mail job if the contact type is a character, otherwise
|
||||
//dispatch the job to the ceo of the corporation instead. If the contact is an alliance
|
||||
//dispatch the job to the ceo of the holding corporation.
|
||||
if($contact->contact_type == 'Character') {
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$contact->rental_contact_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
//Increment the delay to get ready for the next mail job
|
||||
$delay += 30;
|
||||
} else if($contact->contact_type == 'Corporation') {
|
||||
//Get the CEO of the corporation from the lookup helper
|
||||
$corporation = $lookup->GetCorporationInfo($contact->rental_contact_id);
|
||||
$charId = $corporation->ceo_id;
|
||||
//Send out the mail
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$charId, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
//Increment the delay to get ready for the next mail job
|
||||
$delay += 30;
|
||||
} else if($contact->contact_type == 'Alliance') {
|
||||
//Get the holding corporation from the lookup helper
|
||||
$alliance = $lookup->GetAllianceInfo($contact->rental_contact_id);
|
||||
//Get the CEO of the corporation of the holding corp from the lookup helper
|
||||
$corporation = $lookup->GetCorporationInfo($alliance->executor_corporation_id);
|
||||
$charId = $corporation->ceo_id;
|
||||
//Send out the mail
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$charId, 'character', $subject, $config['primaryh'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
//Increment the detaly to get ready for the next mail job
|
||||
$delay += 30;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function GetMoonRentalsList($contact) {
|
||||
//Declare the variables
|
||||
$list = array();
|
||||
|
||||
$moons = AllianceMoonRental::where([
|
||||
'rental_contact_id' => $contact,
|
||||
])->get();
|
||||
|
||||
foreach($moons as $moon) {
|
||||
$temp = 'Rental: ' . $moon->region . ' - ' . $moon->system . ' - ' . $moon->planet . ' - ' . $moon->moon;
|
||||
array_push($list, $temp);
|
||||
}
|
||||
|
||||
//Return the list
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function GetMoonDueList($contact) {
|
||||
//Declare the variables
|
||||
$list = array();
|
||||
|
||||
$moons = AllianceMoonRental::where([
|
||||
'rental_contact_id' => $contact,
|
||||
])->where('paid_until', '<=', $today)->get();
|
||||
|
||||
//Create the list
|
||||
foreach($moons as $moon) {
|
||||
$temp = 'Rental: ' . $moon->region . ' - ' . $moon->system . ' - ' . $moon->planet . ' - ' . $moon->moon;
|
||||
array_push($list, $temp);
|
||||
}
|
||||
|
||||
//Return the list
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function TotalizeCost($rentals, $rentalType) {
|
||||
//Declare the stuff we need
|
||||
$totalCost = 0.00;
|
||||
|
||||
//Totalize the cost
|
||||
foreach($rentals as $rental) {
|
||||
if($rentalType = 'In Alliance') {
|
||||
$totalCost += $rental->alliance_rental_price;
|
||||
} else {
|
||||
$totalCost += $rental->out_of_alliance_rental_price;
|
||||
}
|
||||
}
|
||||
|
||||
return $totalCost;
|
||||
}
|
||||
}
|
||||
153
app/Jobs/Commands/RentalMoons/UpdateMoonRentalPaidState.php
Normal file
153
app/Jobs/Commands/RentalMoons/UpdateMoonRentalPaidState.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\RentalMoons;
|
||||
|
||||
//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 Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
class UpdateMoonRentalPaidState implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 1600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the queue connection up
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$mailDelay = 5;
|
||||
|
||||
//Get all of the moons from the rental database
|
||||
$moons = AllianceRentalMoons::all();
|
||||
|
||||
//Set today's date
|
||||
$today = Carbon::now();
|
||||
|
||||
//Get the esi configuration
|
||||
$esiConfig = config('esi');
|
||||
|
||||
/**
|
||||
* For each of the moons check the rental until date, the paid until date,
|
||||
* and compare them to today's current date.
|
||||
*
|
||||
* If the paid date is later than the rental until date, then update the rental until
|
||||
* date to match the paid date. If the paid until date is today or less, then update the
|
||||
* paid column of the moon to not paid. If the moon hasn't been paid 2 weeks after the first
|
||||
* of the month, then remove the renter, and send an eve mail to alliance leadership, and the renter
|
||||
* denoting failure of payment has resulted in the moon rental for the current month being
|
||||
* revoked.
|
||||
*/
|
||||
foreach($moon as $rental) {
|
||||
//Setup the rental date, paid until date, and today's date as functions of Carbon library
|
||||
$rentedUntil = new Carbon($rental->rental_until);
|
||||
$paidUntil = new Carbon($rental->paid_until);
|
||||
|
||||
//If the paid date is larger than the rental date, then update the rental date
|
||||
if($paidUntil->greaterThan($rentedUntil)) {
|
||||
AllianceMoonRental::where([
|
||||
'region' => $rental->region,
|
||||
'system' => $rental->system,
|
||||
'planet' => $rental->planet,
|
||||
'moon' => $rental->moon,
|
||||
])->update([
|
||||
'rental_until' => $rental->paid_until,
|
||||
]);
|
||||
}
|
||||
|
||||
//If the paid date is today or less, then update the paid column of the moon as not paid
|
||||
if($paidUntil->greaterThanOrEqualTo($today)) {
|
||||
AllianceMoonRental::where([
|
||||
'region' => $rental->region,
|
||||
'system' => $rental->system,
|
||||
'planet' => $rental->planet,
|
||||
'moon' => $rental->moon,
|
||||
])->update([
|
||||
'paid' => 'No',
|
||||
]);
|
||||
}
|
||||
|
||||
//If the moon hasn't been paid for in two weeks, then remove the renter,
|
||||
//then send the renter and w4rp leadership a mail.
|
||||
if($paidUntil->greaterThanOrEqualTo($today->subWeeks(2))) {
|
||||
//Declare the lookup helper as it will be needed
|
||||
$lookupHelper = new LookupHelper;
|
||||
|
||||
//Get the character id for Minerva Arbosa and Rock Onzo
|
||||
$minerva = $lookupHelper->CharacterNameToId('Minerva Arbosa');
|
||||
$rock = $lookupHelper->CharacterNameToId('Rock Onzo');
|
||||
|
||||
//Remove the renter
|
||||
AllianceMoonRental::where([
|
||||
'region' => $rental->region,
|
||||
'system' => $rental->system,
|
||||
'planet' => $rental->planet,
|
||||
'moon' => $rental->moon,
|
||||
])->update([
|
||||
'rental_type' => 'Not Rented',
|
||||
'rental_until' => null,
|
||||
'rental_contact_id' => 0,
|
||||
'rental_contact_type' => null,
|
||||
'paid' => 'Not Rented',
|
||||
'paid_until' => null,
|
||||
]);
|
||||
|
||||
//Send a mail over to the alliance leadership, and the former renter with
|
||||
//why the moon was removed.
|
||||
$subject = "W4RP Moon Rental Cancelled";
|
||||
|
||||
//Dispatch the mail job
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$rental->rental_contact_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
$mailDelay += 30;
|
||||
if($minerva != null) {
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$minerva, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
$mailDelay += 30;
|
||||
}
|
||||
if($rock != null) {
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$rock, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
104
app/Jobs/Commands/RentalMoons/UpdateMoonRentalPrice.php
Normal file
104
app/Jobs/Commands/RentalMoons/UpdateMoonRentalPrice.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\RentalMoons;
|
||||
|
||||
//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 Log;
|
||||
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
|
||||
/**
|
||||
* This job performs the action of updating the moon rental price once per day.
|
||||
*/
|
||||
class UpdateMoonRentalPrice implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3200;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 1;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare the helper for moon calculations
|
||||
$moonHelper = new MoonCalc;
|
||||
//Get all the moons from the rental database
|
||||
$moons = AllianceRentalMoon::all();
|
||||
|
||||
/**
|
||||
* Calculate the worth of each moon along with the rental prices.
|
||||
* For all of the moon calculations, the price of the mineral is averaged,
|
||||
* thereby, the price of the moon worth is also averaged based on the averaging
|
||||
* of the mineral price.
|
||||
*/
|
||||
foreach($moons as $rental) {
|
||||
//Calculate the total worth of the moon
|
||||
$totalWorth = $moonHelper->SpatialMoonsTotalWorth(
|
||||
$rental->first_ore, $rental->first_quantity,
|
||||
$rental->second_ore, $rental->second_quantity,
|
||||
$rental->third_ore, $rental->third_quantity,
|
||||
$rental->fourth_ore, $rental->fourth_quantity,
|
||||
);
|
||||
|
||||
//Calculate the rental prices of the moon
|
||||
$rentalPrice = $moonHelper->SpatialMoons(
|
||||
$rental->first_ore, $rental->first_quantity,
|
||||
$rental->second_ore, $rental->second_quantity,
|
||||
$rental->third_ore, $rental->third_quantity,
|
||||
$rental->fourth_ore, $rental->fourth_quantity,
|
||||
);
|
||||
|
||||
//Update the moon in the database
|
||||
AllianceRentalMoon::where([
|
||||
'region' => $rental->region,
|
||||
'system' => $rental->system,
|
||||
'planet' => $rental->planet,
|
||||
'moon' => $rental->moon,
|
||||
])->update([
|
||||
'moon_worth' => $totalWorth,
|
||||
'alliance_rental_price' => $rentalPrice['alliance'],
|
||||
'out_of_alliance_rental_price' => $rentalPrice['outofalliance'],
|
||||
]);
|
||||
|
||||
Log::info('Alliance Rental Moon: ' . $rental->region . ' : ' . $rental->system . ' : ' . $rental->planet . ' : ' . $rental->moon . ' : ' . $rental->structure_name);
|
||||
Log::info('Total Worth: ' . $totalWorth);
|
||||
Log::info('Alliance Rental Price: ' . $rentalPrice['alliance']);
|
||||
Log::info('Out of Alliance Rental Price: ' . $rentalPrice['outofalliance']);
|
||||
}
|
||||
}
|
||||
}
|
||||
103
app/Jobs/Commands/RentalMoons/UpdateRentalMoonPullJob.php
Normal file
103
app/Jobs/Commands/RentalMoons/UpdateRentalMoonPullJob.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\RentalMoons;
|
||||
|
||||
//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 Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
|
||||
class UpdateRentalMoonPullJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the queue connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Setup the configuration variable for ESI
|
||||
$config = config('esi');
|
||||
//Setup the esi helper variable
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
||||
//Send a mail to the holding toon to update the esi scopes
|
||||
return null;
|
||||
}
|
||||
|
||||
//Is this valid?
|
||||
AllianceRentalMoon::update([
|
||||
'next_moon_pull' => null,
|
||||
]);
|
||||
|
||||
//Reset all table entries to clear out the next moon pull entry
|
||||
$allMoons = AllianceRentalMoon::all();
|
||||
//Cycle through all of the moons, and make the next moon pull null
|
||||
foreach($allMoons as $moon) {
|
||||
AllianceRentalMoon::where([
|
||||
'system' => $moon->system,
|
||||
'planet' => $moon->planet,
|
||||
'moon' => $moon->moon,
|
||||
])->update([
|
||||
'next_moon_pull' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
//Get the refresh token
|
||||
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||
//Setup the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
try {
|
||||
$responses = $esi->invoke('get', '/corporation/{corporation_id}/mining/extractions/', [
|
||||
'corporation_id' => 98287666,
|
||||
]);
|
||||
} catch(RequestExceptionFailed $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach($response as $response) {
|
||||
//Get whether the structure is being used by the alliance or not.
|
||||
$usage = AllianceRentalMoon::where([
|
||||
'structure_id' => $response->structure_id,
|
||||
'rental_type' => 'Alliance',
|
||||
])->count();
|
||||
|
||||
if($usage > 0) {
|
||||
AllianceRentalMoon::where([
|
||||
'structure_id' => $response->structure_id,
|
||||
])->update([
|
||||
'next_moon_pull' => $response->chunk_arrival_time,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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\ProcessSendEveMailJob;
|
||||
|
||||
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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Assets\AssetHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessAsset;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Stock\Asset;
|
||||
|
||||
@@ -58,11 +57,11 @@ class ProcessAssetsJob implements ShouldQueue
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(JobProcessAsset $jpa)
|
||||
public function __construct($charId, $corpId, $page)
|
||||
{
|
||||
$this->charId = $jpa->charId;
|
||||
$this->corpId = $jpa->corpId;
|
||||
$this->page = $jpa->page;
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
$this->page = $page;
|
||||
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
use App\Jobs\Library\JobHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessCorpJournal;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class ProcessCorpJournalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
public $tries = 3;
|
||||
|
||||
private $division;
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $page;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(JobProcessCorpJournal $pcj)
|
||||
{
|
||||
$this->division = $pcj->division;
|
||||
$this->charId = $pcj->charId;
|
||||
$this->corpId = $pcj->corpId;
|
||||
$this->page = $pcj->page;
|
||||
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Delcare the class variable we need
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
$finance->GetCorpWalletJournalPage($this->division, $this->charId, $this->corpId, $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) {
|
||||
Log::critical($exception);
|
||||
}
|
||||
}
|
||||
@@ -1,76 +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;
|
||||
|
||||
//App Library
|
||||
use App\Library\Logistics\ContractsHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessContracts;
|
||||
use App\Models\Job\JobStatus;
|
||||
|
||||
class ProcessEveContractsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Job Variables
|
||||
*/
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $page;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(JobProcessContracts $jpc)
|
||||
{
|
||||
$this->charId = $jpc->charId;
|
||||
$this->corpId = $jpc->corpId;
|
||||
$this->page = $jpc->page;
|
||||
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare the contracts helper
|
||||
$cHelper = new EveContractsHelper($this->charId, $this->corpId, $this->page);
|
||||
|
||||
$contracts = $cHelper->GetContractsByPage();
|
||||
|
||||
foreach($contracts as $contract) {
|
||||
$cHelper->ProcessContract($contract);
|
||||
}
|
||||
|
||||
//After the job is completed, delete the job
|
||||
$this->delete();
|
||||
}
|
||||
}
|
||||
@@ -9,18 +9,19 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Seat stuff
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
//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\Mail\EveMail;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Mail\SentMail;
|
||||
|
||||
class ProcessSendEveMailJob implements ShouldQueue
|
||||
{
|
||||
@@ -40,6 +41,7 @@ class ProcessSendEveMailJob implements ShouldQueue
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
private $sender;
|
||||
private $body;
|
||||
private $recipient;
|
||||
private $recipient_type;
|
||||
@@ -50,11 +52,12 @@ class ProcessSendEveMailJob implements ShouldQueue
|
||||
*
|
||||
* @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;
|
||||
public function __construct($body, $recipient, $recipient_type, $subject, $sender) {
|
||||
$this->body = $body;
|
||||
$this->recipient = $recipient;
|
||||
$this->recipient_type = $recipient_type;
|
||||
$this->subject = $subject;
|
||||
$this->sender = $sender;
|
||||
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
@@ -69,22 +72,17 @@ class ProcessSendEveMailJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Retrieve the token for main character to send mails from
|
||||
$token = EsiToken::where(['character_id'=> 92626011])->first();
|
||||
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||
|
||||
//Create the ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token->refresh_token,
|
||||
]);
|
||||
|
||||
//Setup the Eseye class
|
||||
$esi = new Eseye($authentication);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Attemp to send the mail
|
||||
try {
|
||||
@@ -97,13 +95,15 @@ class ProcessSendEveMailJob implements ShouldQueue
|
||||
]],
|
||||
'subject' => $this->subject,
|
||||
])->invoke('post', '/characters/{character_id}/mail/', [
|
||||
'character_id'=> 92626011,
|
||||
'character_id'=> $this->sender,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning($e);
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->SaveSentRecord($this->sender, $this->subject, $this->body, $this->recipient, $this->recipient_type);
|
||||
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
@@ -117,4 +117,14 @@ class ProcessSendEveMailJob implements ShouldQueue
|
||||
{
|
||||
Log::critical($exception);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessStructure;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class ProcessStructureJob implements ShouldQueue
|
||||
@@ -44,11 +43,11 @@ class ProcessStructureJob implements ShouldQueue
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(JobProcessStructure $jps)
|
||||
public function __construct($charId, $corpId, $page)
|
||||
{
|
||||
$this->charId = $jps->charId;
|
||||
$this->corpId = $jps->corpId;
|
||||
$this->page = $jps->page;
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
$this->page = $page;
|
||||
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
|
||||
@@ -40,10 +40,10 @@ class ProcessWalletJournalJob implements ShouldQueue
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(JobProcessWalletJournal $pwj) {
|
||||
$this->division = $pwj->division;
|
||||
$this->charId = $pwj->charId;
|
||||
$this->page = $pwj->page;
|
||||
public function __construct($division, $charId, $page) {
|
||||
$this->division = $division;
|
||||
$this->charId = $charId;
|
||||
$this->page = $page;
|
||||
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
use App\Jobs\Library\JobHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessWalletTransaction;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class ProcessWalletTransactionJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
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 = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare the class variables
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
$exception = $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) {
|
||||
Log::critical($exception);
|
||||
}
|
||||
}
|
||||
@@ -4,23 +4,16 @@ namespace App\Library\Assets;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//App Library
|
||||
use App\Jobs\Library\JobHelper;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
use App\Models\Jobs\JobProcessAsset;
|
||||
//Models
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Stock\Asset;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
class AssetHelper {
|
||||
|
||||
@@ -41,12 +34,6 @@ class AssetHelper {
|
||||
//Declare the variable for the esi helper
|
||||
$esiHelper = new Esi;
|
||||
|
||||
// Disable all caching by setting the NullCache as the
|
||||
// preferred cache handler. By default, Eseye will use the
|
||||
// FileCache.
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//Setup the esi authentication container
|
||||
$config = config('esi');
|
||||
|
||||
@@ -59,17 +46,12 @@ class AssetHelper {
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
//Setup the ESI variable
|
||||
$esi = new Eseye($authentication);
|
||||
//Setup the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
try {
|
||||
$assets = $esi->page($this->page)
|
||||
->invoke('get', '/corporations/{corporation_id}/assets', [
|
||||
->invoke('get', '/corporations/{corporation_id}/assets/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
|
||||
@@ -1,281 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Contracts;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
use DB;
|
||||
|
||||
//App Library
|
||||
use App\Jobs\Library\JobHelper;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Jobs\JobProcessContracts;
|
||||
use App\Models\Job\JobStatus;
|
||||
use App\Models\Logistics\Contract;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
class EveContractsHelper {
|
||||
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $page;
|
||||
|
||||
public function __construct($char, $corp, $pg = null) {
|
||||
$this->charId = $char;
|
||||
$this->corpId = $corp;
|
||||
$this->page = $pg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a page of Contracts to store in the database
|
||||
*/
|
||||
public function GetContractsByPage() {
|
||||
// Disable all caching by setting the NullCache as the
|
||||
// preferred cache handler. By default, Eseye will use the
|
||||
// FileCache.
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//Setup the esi authentication container
|
||||
$config = config('esi');
|
||||
|
||||
//Check for the scope for the esi token needed
|
||||
$hasScope = $esiHelper->HaveEsiScope($this->charId, 'esi-contracts.read_corporation_contracts.v1');
|
||||
if($hasScope == false) {
|
||||
Log::critical('Esi Scope check failed for esi-contracts.read_corporation_contracts.v1 for character id: ' . $this->charId);
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
//Setup the ESI variable
|
||||
$esi = new Eseye($authentication);
|
||||
|
||||
try {
|
||||
$contracts = $esi->page($this->page)
|
||||
->invoke('get', '/corporations/{corporation_id}/contracts/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get a page of contracts from ESI.");
|
||||
$contracts = null;
|
||||
}
|
||||
|
||||
return $contracts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a new contract record in the database
|
||||
*/
|
||||
public function StoreNewContract($contract) {
|
||||
//Declare esi helper for decoding the date
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup the esi authentication container
|
||||
$config = config('esi');
|
||||
|
||||
//Check if the scope is present for ESI
|
||||
$hasScope = $esiHelper->HaveEsiScope($this->charId, 'esi-contracts.read_corporation_contracts.v1');
|
||||
if($hasScope == false) {
|
||||
Log::critical('Esi Scope check failed for esi-contracts.read_corporation_contracts.v1 for character id: ' . $this->charId);
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
//Setup the ESI variable
|
||||
$esi = new Eseye($authentication);
|
||||
|
||||
//See if we find the contract in the database
|
||||
$found = LogisticsContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->count();
|
||||
//If nothing is found we need to store the contract
|
||||
if($found == 0) {
|
||||
$logi = new LogisticsContract;
|
||||
$logi->acceptor_id = $contract->acceptor_id;
|
||||
$logi->assignee_id = $contract->assignee_id;
|
||||
$logi->availability = $contract->availability;
|
||||
if(isset($contract->buyout)) {
|
||||
$logi->buyout = $contract->buyout;
|
||||
}
|
||||
if(isset($contract->collateral)) {
|
||||
$logi->collateral = $contract->collateral;
|
||||
}
|
||||
$logi->contract_id = $contract->contract_id;
|
||||
if(isset($contract->date_accepted)) {
|
||||
$logi->date_accepted = $esiHelper->DecodeDate($contract->date_accepted);
|
||||
}
|
||||
if(isset($contract->date_completed)) {
|
||||
$logi->date_completed = $esiHelper->DecodeDate($contract->date_completed);
|
||||
}
|
||||
$logi->date_expired = $contract->date_expired;
|
||||
$logi->date_issued = $contract->date_issued;
|
||||
if(isset($contract->days_to_complete)) {
|
||||
$logi->days_to_complete = $contract->days_to_complete;
|
||||
}
|
||||
if(isset($contract->end_location_id)) {
|
||||
$logi->end_location_id = $contract->end_location_id;
|
||||
}
|
||||
$logi->for_corporation = $contract->for_corporation;
|
||||
$logi->issuer_corporation_id = $contract->issuer_corporation_id;
|
||||
$logi->issuer_id = $contract->issuer_id;
|
||||
if(isset($contract->price)) {
|
||||
$logi->price = $contract->price;
|
||||
}
|
||||
if(isset($contract->reward)) {
|
||||
$logi->reward = $contract->reward;
|
||||
}
|
||||
if(isset($contract->start_location_id)) {
|
||||
$logi->start_location_id = $contract->start_location_id;
|
||||
}
|
||||
$logi->status = $contract->status;
|
||||
if(isset($contract->title)) {
|
||||
$logi->title = $contract->title;
|
||||
}
|
||||
$logi->type = $contract->type;
|
||||
$logi->status = $contract->status;
|
||||
if(isset($contract->volume)) {
|
||||
$logi->volume = $contract->volume;
|
||||
}
|
||||
$logi->save();
|
||||
} else { //If the contract is found, then call the function to update the contract
|
||||
$this->UpdateLogisticsContract($contract);
|
||||
}
|
||||
}
|
||||
|
||||
public function UpdateLogisticsContract($contract) {
|
||||
//Declare Esi Helper function
|
||||
$esiHelper = new Esi;
|
||||
|
||||
LogisticsContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'acceptor_id' => $contract->acceptor_id,
|
||||
'assignee_id' => $contract->assignee_id,
|
||||
'availability' => $contract->availability,
|
||||
'date_expired' => $esiHelper->DecodeDate($contract->date_expired),
|
||||
'date_issued' => $esiHelper->DecodeDate($contract->date_issued),
|
||||
'for_corporation' => $contract->for_corporation,
|
||||
'issuer_corporation_id' => $contract->issuer_corporation_id,
|
||||
'issuer_id' => $contract->issuer_id,
|
||||
'status' => $contract->status,
|
||||
'type' => $contract->type,
|
||||
]);
|
||||
|
||||
if(isset($contract->buyout)) {
|
||||
LogisticsContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'buyout' => $contract->buyout,
|
||||
]);
|
||||
}
|
||||
|
||||
if(isset($contract->collateral)) {
|
||||
LogisticsContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'collateral' => $contract->collateral,
|
||||
]);
|
||||
}
|
||||
|
||||
if(isset($contract->date_accepted)) {
|
||||
LogisticsContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'date_accepted' => $esiHelper->DecodeDate($contract->date_accepted),
|
||||
]);
|
||||
}
|
||||
|
||||
if(isset($contract->date_completed)) {
|
||||
LogisticsContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'date_completed' => $esiHelper->DecodeDate($contract->date_completed),
|
||||
]);
|
||||
}
|
||||
|
||||
if(isset($contract->days_to_complete)) {
|
||||
LogisticsContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'days_to_complete' => $contract->days_to_complete,
|
||||
]);
|
||||
}
|
||||
|
||||
if(isset($contract->end_location_id)) {
|
||||
LogisticsContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'end_location_id' => $contract->end_location_id,
|
||||
]);
|
||||
}
|
||||
|
||||
if(isset($contract->price)) {
|
||||
LogisticsContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'price' => $contract->price,
|
||||
]);
|
||||
}
|
||||
|
||||
if(isset($contract->reward)) {
|
||||
LogisticsContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'reward' => $contract->reward,
|
||||
]);
|
||||
}
|
||||
|
||||
if(isset($contract->start_location_id)) {
|
||||
LogisticsContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'start_location_id' => $contract->start_location_id,
|
||||
]);
|
||||
}
|
||||
|
||||
if(isset($contract->title)) {
|
||||
LogisticsContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'title' => $contract->title,
|
||||
]);
|
||||
}
|
||||
|
||||
if(isset($contract->volume)) {
|
||||
LogisticsContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'volume' => $contract->voluem,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function PurgeOldContracts() {
|
||||
$date = Carbon::now();
|
||||
|
||||
LogisticsContract::where('date_expired', '<', $date)->delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -3,14 +3,11 @@
|
||||
namespace App\Library\Esi;
|
||||
|
||||
//Internal Libraries
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
use App\Models\Mail\EveMail;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
@@ -43,14 +40,10 @@ class Esi {
|
||||
$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
|
||||
$mail = new EveMail;
|
||||
$mail->sender = $config['primary'];
|
||||
$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';
|
||||
$subject = 'W4RP Services - Incorrect ESI Scope';
|
||||
$body = "Please register on https://services.w4rp.space with the scope: " . $scope;
|
||||
|
||||
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$charId, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -58,7 +51,8 @@ class Esi {
|
||||
}
|
||||
|
||||
public function GetCharacterData($charId) {
|
||||
$esi = new Eseye();
|
||||
$esi = $this->SetupEsiAuthentication();
|
||||
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
@@ -70,8 +64,23 @@ class Esi {
|
||||
return $character;
|
||||
}
|
||||
|
||||
public function GetCorporationData($corpId) {
|
||||
$esi = $this->SetupEsiAuthentication();
|
||||
|
||||
try {
|
||||
$corporation = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $corporation;
|
||||
}
|
||||
|
||||
public function GetCharacterName($charId) {
|
||||
$esi = new Eseye();
|
||||
$esi = $this->SetupEsiAuthentication;
|
||||
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
@@ -85,13 +94,8 @@ class Esi {
|
||||
|
||||
public function FindCharacterId($name) {
|
||||
$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);
|
||||
|
||||
$esi = $this->SetupEsiAuthentication();
|
||||
|
||||
try {
|
||||
$character = $esi->setBody(array(
|
||||
@@ -106,27 +110,11 @@ class Esi {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
try {
|
||||
$character = $esi->setQueryString([
|
||||
'categories' => 'character',
|
||||
'language' => 'en-us',
|
||||
'search' => $name,
|
||||
'strict' => 'true',
|
||||
])->invoke('get', '/search/');
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
$character = json_decode($character, true);
|
||||
|
||||
return $character['character'];
|
||||
*/
|
||||
}
|
||||
|
||||
public function FindCorporationId($charId) {
|
||||
$esi = new Eseye();
|
||||
$esi = $this->SetupEsiAuthentication();
|
||||
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
@@ -139,7 +127,8 @@ class Esi {
|
||||
}
|
||||
|
||||
public function FindCorporationName($charId) {
|
||||
$esi = new Eseye();
|
||||
$esi = $this->SetupEsiAuthentication();
|
||||
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
@@ -195,22 +184,20 @@ class Esi {
|
||||
|
||||
//Declare some variables
|
||||
$authentication = null;
|
||||
$esi = null;
|
||||
|
||||
if($token === null) {
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
]);
|
||||
if($token == null) {
|
||||
$esi = new Eseye();
|
||||
} else {
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
}
|
||||
|
||||
//Setup the esi variable
|
||||
$esi = new Eseye($authentication);
|
||||
//Setup the esi variable
|
||||
$esi = new Eseye($authentication);
|
||||
}
|
||||
|
||||
//Return the created variable
|
||||
return $esi;
|
||||
|
||||
@@ -1,52 +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) {
|
||||
//Get the esi config
|
||||
$config = config('esi');
|
||||
|
||||
//Retrieve the token for main character to send mails from
|
||||
$token = EsiToken::where(['character_id' => $config['primary']])->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'=> $config['primary'],
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -7,13 +7,21 @@
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
use DB;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\AllianceMarketJournal;
|
||||
|
||||
class AllianceMarketTax {
|
||||
public function EntryExists($journal) {
|
||||
if(AllianceMarketJournal::where(['id' => $journal['id']])->exists()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function InsertMarketTax($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
use DB;
|
||||
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
use App\Models\Finances\CorpMarketJournal;
|
||||
|
||||
class CorpMarketTax {
|
||||
public function InsertCorpMarketTax($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(!CorpMarketJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new CorpMarketJournal;
|
||||
$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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -8,16 +8,12 @@
|
||||
namespace App\Library\Finances\Helper;
|
||||
|
||||
//Internal Library
|
||||
use DB;
|
||||
use Log;
|
||||
|
||||
//Job
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Mail\EveMail;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
@@ -32,74 +28,15 @@ use App\Library\Finances\OfficeFee;
|
||||
use App\Library\Finances\PlanetProductionTax;
|
||||
use App\Library\Finances\PISale;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Finances\SovBillExpenses;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
class FinanceHelper {
|
||||
|
||||
public function GetWalletTransaction($division, $charId) {
|
||||
//Declare the class helpers
|
||||
$lookups = new LookupHelper();
|
||||
$esiHelper = new Esi();
|
||||
|
||||
//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
|
||||
$hasScope = $esiHelper->HaveEsiScope($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||
if($hasScope == false) {
|
||||
Log::critical('Esi scope check for esi-wallet.read_corporation_wallets.v1 has failed for character id: ' . $hcarId);
|
||||
return null;
|
||||
}
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
if($token == null) {
|
||||
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,
|
||||
]);
|
||||
|
||||
//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' => 98287666,
|
||||
'division' => 5,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical($e->getEsiResponse());
|
||||
return -1;
|
||||
}
|
||||
|
||||
//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 == 5 && $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();
|
||||
@@ -109,7 +46,8 @@ class FinanceHelper {
|
||||
$industry = new StructureIndustryTax();
|
||||
$office = new OfficeFee();
|
||||
$esiHelper = new Esi();
|
||||
$lookups = new LookupHelper;
|
||||
$sovBillHelper = new SovBillExpenses();
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$hasScope = $esiHelper->HaveEsiScope($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||
@@ -123,20 +61,18 @@ class FinanceHelper {
|
||||
}
|
||||
|
||||
//Reference to see if the character is in our look up table for corporations and characters
|
||||
$corpId = $lookups->LookupCharacter($charId);
|
||||
$char = $lookup->GetCharacterInfo($charId);
|
||||
$corpId = $char->corporation_id;
|
||||
|
||||
//Create an ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
|
||||
//Create the esi class varialble
|
||||
$esi = new Eseye($authentication);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
//Set the version
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//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.
|
||||
@@ -153,32 +89,34 @@ class FinanceHelper {
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//Log::warning($e->getEsiResponse());
|
||||
return null;
|
||||
}
|
||||
|
||||
//Set the total pages we need to cycle through.
|
||||
$totalPages = $journals->pages;
|
||||
if($currentPage == 1) {
|
||||
//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);
|
||||
}
|
||||
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);
|
||||
} else if($entry['ref_type'] == 'infrastructure_hub_maintenance' && $entry['first_party_id'] == 98287666) {
|
||||
$sovBillHelper->InsertSovBillExpense($entry, $corpId, $division);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,8 +128,8 @@ class FinanceHelper {
|
||||
|
||||
public function GetJournalPageCount($division, $charId) {
|
||||
//Declare class variables
|
||||
$lookups = new LookupHelper();
|
||||
$esiHelper = new Esi();
|
||||
$lookup = new LookupHelper;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$hasScope = $esiHelper->HaveEsiScope($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||
@@ -205,20 +143,19 @@ class FinanceHelper {
|
||||
}
|
||||
|
||||
//Refrence to see if the character is in our look up table for corporation and characters
|
||||
$corpId = $lookups->LookupCharacter($charId);
|
||||
$char = $lookup->GetCharacterInfo($charId);
|
||||
$corpId = $char->corporation_id;
|
||||
|
||||
//Create the ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Create the esi class variable
|
||||
$esi = new Eseye($authentication);
|
||||
//Set the esi version to v4
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//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/', [
|
||||
@@ -226,7 +163,7 @@ class FinanceHelper {
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//Log::warning($e->getEsiResponse());
|
||||
Log::warning($e->getEsiResponse());
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -238,24 +175,19 @@ class FinanceHelper {
|
||||
public function GetCorpWalletJournalPage($division, $charId, $corpId, $page = 1) {
|
||||
//Declare new class variables
|
||||
$corpMarket = new MarketTax();
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$tokenData = $this->TokenIfno($charId);
|
||||
$token = $tokenData['token'];
|
||||
$scope = $tokenData['scope'];
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
|
||||
//Create an ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
|
||||
//Create the esi class varialble
|
||||
$esi = new Eseye($authentication);
|
||||
//Setup the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//Call the page of the wallet journal
|
||||
try {
|
||||
$journals = $esi->page($page)
|
||||
@@ -291,7 +223,8 @@ class FinanceHelper {
|
||||
$office = new OfficeFee;
|
||||
$pi = new PlanetProductionTax;
|
||||
$esiHelper = new Esi;
|
||||
$lookups = new LookupHelper;
|
||||
$lookup = new LookupHelper;
|
||||
$sovBill = new SovBillExpenses;
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$hasScope = $esiHelper->HaveEsiScope($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||
@@ -305,20 +238,17 @@ class FinanceHelper {
|
||||
}
|
||||
|
||||
//Reference to see if the character is in our look up table for corporations and characters
|
||||
$corpId = $lookups->LookupCorporationId($charId);
|
||||
$char = $lookup->GetCharacterInfo($charId);
|
||||
$corpId = $char->corporation_id;
|
||||
|
||||
//Create an ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
|
||||
//Create the esi class varialble
|
||||
$esi = new Eseye($authentication);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//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 {
|
||||
@@ -328,7 +258,6 @@ class FinanceHelper {
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//Log::warning($e->getEsiResponse());
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -337,23 +266,23 @@ class FinanceHelper {
|
||||
//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);
|
||||
} else if($entry['ref_type'] == 'planetary_export_tax' || $entry['ref_type'] == 'planetary_import_tax') {
|
||||
$pi->InsertPlanetProductionTax($entry, $corpId, $division);
|
||||
}
|
||||
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);
|
||||
} else if($entry['ref_type'] == 'planetary_export_tax' || $entry['ref_type'] == 'planetary_import_tax') {
|
||||
$pi->InsertPlanetProductionTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'infrastructure_hub_maintenance' && $entry['first_party_id'] == 98287666) {
|
||||
$sovBill->InsertSovBillExpense($entry, $corpId, $division);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,15 @@
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Internal Library
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\JumpBridgeJournal;
|
||||
use App\Models\User\UserToCorporation;
|
||||
|
||||
class JumpBridgeTax {
|
||||
private $date;
|
||||
@@ -76,55 +78,6 @@ class JumpBridgeTax {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@@ -143,6 +96,7 @@ class JumpBridgeTax {
|
||||
* 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)
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
use DB;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\OfficeFeesJournal;
|
||||
|
||||
class OfficeFee {
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
namespace App\Library\Finances;
|
||||
|
||||
use DB;
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
use App\Library\Esi\Esi;
|
||||
//Models
|
||||
use App\Models\Finances\PISaleJournal;
|
||||
|
||||
use App\Models\Finances\PISaleJournal;
|
||||
|
||||
class PISale {
|
||||
class PISale {
|
||||
|
||||
public function InsertPISale($journal, $corpId) {
|
||||
//Create the ESI Helper class
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
use DB;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\PlanetProductionTaxJournal;
|
||||
|
||||
class PlanetProductionTax {
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
use DB;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\PlayerDonationJournal;
|
||||
|
||||
class PlayerDonation {
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
use DB;
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\ReprocessingTaxJournal;
|
||||
|
||||
class ReprocessingTax {
|
||||
|
||||
63
app/Library/Finances/SovBillExpenses.php
Normal file
63
app/Library/Finances/SovBillExpenses.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\SovBillJournal;
|
||||
|
||||
class SovBillExpenses {
|
||||
public function InsertSovBillExpense($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(!SovBillJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new SovBillJournal;
|
||||
$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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -7,9 +7,10 @@
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
use DB;
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\StructureIndustryTaxJournal;
|
||||
|
||||
class StructureIndustryTax {
|
||||
|
||||
67
app/Library/Fleets/FleetHelper.php
Normal file
67
app/Library/Fleets/FleetHelper.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Fleets;
|
||||
|
||||
//Internal Libraries
|
||||
use Log;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
//Libraries
|
||||
use App\library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Fleets\AllianceFleet;
|
||||
use App\Models\Fleets\AllianceFleetMember;
|
||||
|
||||
class FleetHelper {
|
||||
//Variables
|
||||
private $esi;
|
||||
|
||||
//Constructi
|
||||
public function __construct($charId) {
|
||||
//Declare a variable for use by the constructor
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check for the ESI scope
|
||||
$check = $esiHelper->HaveEsiScope($charId, 'esi-fleets.read_fleet.v1');
|
||||
if($check) {
|
||||
//Setup the ESI authentication container
|
||||
$this->esi = $esiHelper->SetupEsiAuthentication();
|
||||
} else {
|
||||
$this->esi = null;
|
||||
}
|
||||
}
|
||||
|
||||
//Get fleet information
|
||||
public function GetFleetInfo($fleetId) {
|
||||
|
||||
}
|
||||
|
||||
//Get fleet members
|
||||
public function GetFleetMembers($fleetId) {
|
||||
|
||||
}
|
||||
|
||||
//Get fleet wings
|
||||
public function GetFleetWings($fleetId) {
|
||||
|
||||
}
|
||||
|
||||
//Update fleet time
|
||||
public function UpdateFleetTime($fleetId) {
|
||||
|
||||
}
|
||||
|
||||
//Update fleet character names
|
||||
public function UpdateFleetCharacters($fleetId) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
23
app/Library/JumpBridges/JumpBridgeHelper.php
Normal file
23
app/Library/JumpBridges/JumpBridgeHelper.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\JumpBridges;
|
||||
|
||||
//Internal Libraries
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\JumpBridgeJournal;
|
||||
|
||||
class JumpBridgeHelper {
|
||||
|
||||
public function __construct() {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user