Compare commits
886 Commits
v0.1-beta
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e4c71ccab | ||
| 6a38286d45 | |||
| 6afd6f4f4f | |||
| 0c3e22e17d | |||
| ea4a58095d | |||
| 9ad3a2ea33 | |||
| d59e35ac86 | |||
| e2ba9d29ee | |||
| b037372619 | |||
| 22637f9d34 | |||
| e0128f2e6b | |||
| 1b0c301452 | |||
| 86ad4be8d0 | |||
| 8159810613 | |||
| efc4c4e5bd | |||
| 390208ecd4 | |||
| 054935a95d | |||
| c0c8b6fb32 | |||
| da8834fe96 | |||
| ae93aeb070 | |||
| c369c3487f | |||
| 3531140a13 | |||
| 0dc04a4901 | |||
| 5a7176c493 | |||
| 87a160fb58 | |||
| 4d86c77ced | |||
| 8c972a140b | |||
| a19a756750 | |||
| 5542c6ea11 | |||
| b8b1dad2de | |||
| cfaebed0fe | |||
| 9619fde4ed | |||
| d47b7c9f1c | |||
| 7eee0b66c6 | |||
| 92109f91fd | |||
| c0ba6415e2 | |||
| 32e2a40592 | |||
| 9d40ca26e0 | |||
| 632457ff3a | |||
| 550a6a5d7b | |||
| 9fa08f77bd | |||
| 52705775ce | |||
| ac14c6fa13 | |||
| 1ec7760d12 | |||
| 2dabefa2e1 | |||
| 43fb5573f4 | |||
| c410c05c82 | |||
| 37b99b8146 | |||
| 41228bc857 | |||
| 5566409ffa | |||
| 813cb7de13 | |||
| 490e215971 | |||
| f9e6b84fd9 | |||
| 36b977a53e | |||
| 087fe8e50f | |||
| 2d683bfcd2 | |||
| 113a446cd6 | |||
| 4e2ff481f5 | |||
| 70e2c022bb | |||
| a9105b05eb | |||
| 02b57d226a | |||
| 062901dbe8 | |||
| 4b280e3a91 | |||
| cc5b8576f6 | |||
| a87786d223 | |||
| 562826f0e1 | |||
| 3e1eace056 | |||
| cc4f921fd6 | |||
| e76794172d | |||
| d3f8389cfb | |||
| 31420ed236 | |||
| 17c0ca97ae | |||
| 3257389188 | |||
| 0862183467 | |||
| 4ef0f1ce91 | |||
| 79caad0d54 | |||
| dc2522ab7c | |||
| 324a3ca7da | |||
| a7d3bbb858 | |||
| b153607e32 | |||
| 6ac2db146e | |||
| fddf85e7a6 | |||
| 2ea19ad84d | |||
| 1cfb33ce42 | |||
| 83377eda4a | |||
| ae87e5b01b | |||
| fa4f642498 | |||
| 4220d1c5e3 | |||
| f50e1ddaa2 | |||
| 9f6af14b76 | |||
| 742189907c | |||
| 94041e307d | |||
| 8a8b5cef7a | |||
| c25850ec3a | |||
| 414eca717c | |||
| 3e30c3ae92 | |||
| 80052803cc | |||
| fba2459052 | |||
| 966e8f94d8 | |||
| aeb7bfc2e4 | |||
| 8fed630c0b | |||
| 403c05d061 | |||
| cdd70ee3fa | |||
| 289b6859b6 | |||
| b9f4678d70 | |||
| 960435f874 | |||
| 48d5304f0b | |||
| 918645b05e | |||
| e781554059 | |||
| 9cb42d38cb | |||
| 324311b767 | |||
| 6356de7cf2 | |||
| 76b1fa3775 | |||
| 6980865015 | |||
| d7696e83d6 | |||
| b9984b7236 | |||
| ad43ecbc84 | |||
| fbc6df6f87 | |||
| 87ecbb9407 | |||
| 3712ae9395 | |||
| a6e1b4cccc | |||
| 64d323570c | |||
| 9e98025f24 | |||
| 6c040538f5 | |||
| 0d4ae999d2 | |||
| 4be3f9b33d | |||
| 0c768874ae | |||
| 337ee3ec2c | |||
| b9fa079eb7 | |||
| 85295cb03f | |||
| 3ee138d81d | |||
| 4218731441 | |||
| ba3419d692 | |||
| a6d3e7855b | |||
| e047cfbbf4 | |||
| aaa721447a | |||
| 004eb146bf | |||
| cf300efdaa | |||
| 750333990d | |||
| 036d98a169 | |||
| 02e7f738fc | |||
| 26f5f854be | |||
| 41f9ebf886 | |||
| 53945b0846 | |||
| fd9fda9f47 | |||
| 0328f969dc | |||
| a6cfc6b011 | |||
| 4997560046 | |||
| d770a4866a | |||
| 16e7244065 | |||
| c45766f2d9 | |||
| 4f5c2ef090 | |||
| 7c99a9c67c | |||
| 5b1e580a4f | |||
| 6d312ba589 | |||
| ac22a31427 | |||
| 368906787c | |||
| 7ace3b7d91 | |||
| 6bf3149bea | |||
| a275c608a4 | |||
| 41d433b7c8 | |||
| 7950d7d5ea | |||
| 97801653fe | |||
| 9099997b2c | |||
| 7f02874923 | |||
| 84d02f8ec4 | |||
| a897d095cf | |||
| 2d9a6ab24e | |||
| f671c5a958 | |||
| 8fcf31a349 | |||
| ddb99a311f | |||
| eef6bde7fe | |||
| 8ceea4b491 | |||
| dfc5337b06 | |||
| 396d02e7a3 | |||
| 4701abc691 | |||
| 7d78c0532b | |||
| b65d00c8b4 | |||
| 70f1f5d2a8 | |||
| abe870ece1 | |||
| 7a2701d72d | |||
| b09f48ccdc | |||
| 9192ffa63f | |||
| e6b05806f0 | |||
| 7698a02a31 | |||
| 6e3c51cd97 | |||
| 27ff27a057 | |||
| 00094f8850 | |||
| 6c6321aa03 | |||
| 8cd1f1bcc7 | |||
| c9e1d090ff | |||
| c47917efc4 | |||
| 84824d1ada | |||
| 15e8d7fb6c | |||
| 00424b2384 | |||
| 09ea177d89 | |||
| d58aebf7f6 | |||
| c0506f87f7 | |||
| ec4fc33137 | |||
| 73613d901f | |||
| 1c579bd6e7 | |||
| 937300fad3 | |||
| f9b16e7671 | |||
| d7d865a6c9 | |||
| 489f3603de | |||
| 6f355d2859 | |||
| ad1b690fe1 | |||
| b5920bfc6e | |||
| ca9ae4ca6b | |||
| e5b6ff8301 | |||
| 90db71b2e3 | |||
| 59808c1374 | |||
| ad22fea86d | |||
| d13ab10d4d | |||
| 4b7feb9b5b | |||
| e899dad637 | |||
| 8502a22ffa | |||
| 742735ea39 | |||
| ac56b3e432 | |||
| b7666c1dc8 | |||
| 90020f8152 | |||
| 45615e8f75 | |||
| f61e4d1964 | |||
| a16f225746 | |||
| 7fe19b8c26 | |||
| 5c4aecab55 | |||
| f366bd56b9 | |||
| 171c35d23c | |||
| 53d9453e8b | |||
| 522e75cea6 | |||
| 3164b1a879 | |||
| 2c13fbaca4 | |||
| 9a4abe0da2 | |||
| cc28e24e02 | |||
| 943fd3d174 | |||
| edeb09ffc6 | |||
| 1dc0b4e2af | |||
| f698ba4e38 | |||
| 9401f80108 | |||
| 5dcd19c681 | |||
| 0a41760a24 | |||
| 0069b7639b | |||
| 85191ed0b2 | |||
| f8f8a50418 | |||
| a6a9ddfa02 | |||
| 1558e78b2b | |||
| bcf16ad669 | |||
| 6f13d9c0ae | |||
| 935b7b3ef1 | |||
| 66d6928e4d | |||
| 78cd3abe15 | |||
| cb793fee58 | |||
| d677d52274 | |||
| 551cbf0049 | |||
| ed1355bb4f | |||
| 92d3810a2b | |||
| 49c6c3767f | |||
| e5131bf9f7 | |||
| e6d8a7cb87 | |||
| 772d091425 | |||
| 9d524b07ec | |||
| 37cb24c46e | |||
| c9fc3113a2 | |||
| 7159e3d336 | |||
| b2e9301cc6 | |||
| 460b2c947e | |||
| 92369f9165 | |||
| 119a6eaa17 | |||
| 7f49fbc107 | |||
| 9e198c3102 | |||
| 9ac70f9dfd | |||
| 7ab25c0207 | |||
| 60e0bc52e6 | |||
| 71c3b530cb | |||
| e5771980ba | |||
| d7d30d30f5 | |||
| 6a67df768a | |||
| 9c8cd51b18 | |||
| cb9447ed5b | |||
| be2c8efbf6 | |||
| 79a89c22b9 | |||
| f48171b11a | |||
| 9b8b2fcba7 | |||
| 51c9d85aef | |||
| db45c71636 | |||
| 73034f2f74 | |||
| 0deae9e495 | |||
| 30be401b30 | |||
| 0bb0ae7888 | |||
| d81ca33b0a | |||
| f194d91d90 | |||
| aa86effe5d | |||
| d5b47d1beb | |||
| 16df3e3238 | |||
| 84303b93d2 | |||
| 5521abbf95 | |||
| 77d490c9c3 | |||
| d9de481c39 | |||
| ccd12b57ed | |||
| 2d9a9ab046 | |||
| f5b59a7a22 | |||
| a212b15068 | |||
| 24d578d392 | |||
| 669b599707 | |||
| f0cb91a21f | |||
| 5645ca17e8 | |||
| 12cffcc75d | |||
| 2b5451d3ce | |||
| 1d209c5be9 | |||
| 48d38ff110 | |||
| 06bcaac67d | |||
| 86c8adc3d9 | |||
| 1c67419483 | |||
| 1516e27c5a | |||
| f71a835d1b | |||
| 42b283e956 | |||
| b30a5eeed6 | |||
| 9f9a190cc9 | |||
| b2bd070c9c | |||
| c029cd8cc6 | |||
| 860cea2369 | |||
| d1b132d267 | |||
| a3892b183e | |||
| 94cce31f47 | |||
| 92b79b124f | |||
| b76e0aae32 | |||
| ce18606949 | |||
| e8ec110ecd | |||
| 1594536d01 | |||
| 37d05afd24 | |||
| 746257b831 | |||
| cadef48cb5 | |||
| c26dbba312 | |||
| 3b6eab2b46 | |||
| 0bb0e9d037 | |||
| dc36be558c | |||
| 699af576e3 | |||
| 207b32e600 | |||
| 5b2c692d95 | |||
| 6e9a13b44e | |||
| 22a62ab082 | |||
| 01d3e44d95 | |||
| 3e83a041e9 | |||
| a00332328b | |||
| 4a38bc2fee | |||
| 7eceef4818 | |||
| 88daa2b01a | |||
| dbd92a9df9 | |||
| 366e293e9f | |||
| 5222413c57 | |||
| ead25a3533 | |||
| dac296f8b9 | |||
| 098c1585a1 | |||
| 27c1e0f1c1 | |||
| ec8d5d774f | |||
| e9d0a8a9df | |||
| d19202de9b | |||
| c27a157ebb | |||
| ec7c02db77 | |||
| 0b752a7886 | |||
| 7742b7ba1a | |||
| ff545f4dbc | |||
| 2e7369ee51 | |||
| 2f68ef43da | |||
| fd747d49fb | |||
| 5b80258418 | |||
| 5b1110a3ed | |||
| 9664cb239e | |||
| 24cf162f9b | |||
| af08d5c239 | |||
| dc3d536f0b | |||
| dafebfadc5 | |||
| cb10515c13 | |||
| 156783af7c | |||
| 46c526a515 | |||
| 8724d60d60 | |||
| 2c4e25be59 | |||
| 952d6e83e3 | |||
| 6334865d3f | |||
| d894216c54 | |||
| b9e89e3ffb | |||
| c385228d73 | |||
| 5fcb71dfd1 | |||
| 8322858e20 | |||
| 4e9a289692 | |||
| a097138299 | |||
| 8a53f53d99 | |||
| f0543da790 | |||
| 472c22fcfb | |||
| eb2f2f86f0 | |||
| 72147c7edf | |||
| 2a360d32a6 | |||
| 2eaea8ee26 | |||
| 254562f940 | |||
| fa4367e8d9 | |||
| 0820aa5675 | |||
| 7f13150557 | |||
| a0a4fd136f | |||
| 6c3402fa8d | |||
| eb1ca9d7b1 | |||
| f7d2a5f23b | |||
| abc9364afb | |||
| e027147c99 | |||
| ce2fc54e66 | |||
| a8e39e3125 | |||
| 821e4d7a87 | |||
| 6404c2d99f | |||
| a6be5844e6 | |||
| e40fedb812 | |||
| 09c5091d1c | |||
| 727100f942 | |||
| 574a95fd14 | |||
| 10a00750d7 | |||
| 0b40903ae3 | |||
| 556b62065a | |||
| 51c926c20b | |||
| 96e5c0120e | |||
| 4bebbc204e | |||
| 51912bf3a8 | |||
| 9c4b23905d | |||
| 8d1c597131 | |||
| 8a2bb2e993 | |||
| 0586488d90 | |||
| 176de41288 | |||
| 92f4b78801 | |||
| a9d4c6399f | |||
| d31e1e4bfd | |||
| a39dce4cf8 | |||
| 044d0253ca | |||
| 036de5de95 | |||
| c3c07e2ccb | |||
| 4fe7155f0c | |||
| 83fbe8d881 | |||
| c610352868 | |||
| 217ec34a70 | |||
| 4ddd5dbf03 | |||
| 217f0f47ac | |||
| 8d37376fb1 | |||
| bfebdd2632 | |||
| ee2068eda5 | |||
| 5a6c7da549 | |||
| a29be94d08 | |||
| 20ec956b77 | |||
| 8335e4de96 | |||
| d53e0fbdd7 | |||
| d39be76f0f | |||
| ee1dd570d0 | |||
| 78a51b6817 | |||
| b089ccc39c | |||
| c8a1ccef30 | |||
| 3d93013f75 | |||
| 77c19504be | |||
| 5f7c942354 | |||
| ebb41422f3 | |||
| b4a728213d | |||
| fde47de5ed | |||
| 78d2f447eb | |||
| 702d4f62bb | |||
| a4eb4d58ae | |||
| 80fd882815 | |||
| 3c993c576e | |||
| c3eeadece5 | |||
| 95dad78a7f | |||
| 0498009a42 | |||
| f068a2a9ee | |||
| 3cb2432d14 | |||
| fa3b1d014f | |||
| 8438fa568d | |||
| f1f74019b4 | |||
| c68a5320a3 | |||
| 2581b09ae5 | |||
| 5794c541b0 | |||
| 4ceb989884 | |||
| 7e22e3548e | |||
| 13714677d3 | |||
| f3e730b131 | |||
| 216553f526 | |||
| 2c9ac0c7c2 | |||
| 47dc48555e | |||
| 892f748610 | |||
| 7a221e0cb3 | |||
| 741a707994 | |||
| a9734c90d9 | |||
| 9c36c7be4e | |||
| 72e604bd43 | |||
| 9326f2c4d0 | |||
| 489161437a | |||
| 8fb69b7e9c | |||
| b73149ad67 | |||
| 71f99e68e6 | |||
| eab0548b44 | |||
| 87d27b22f9 | |||
| 928eb4f32c | |||
| 506201f037 | |||
| 6009314efd | |||
| 20ceef0889 | |||
| ebad574330 | |||
| 853e34b12b | |||
| 3a9b16512a | |||
| 25ade94314 | |||
| d5790c5c15 | |||
| d49e9ef89b | |||
| 84e3712e22 | |||
| 3b3a5faad4 | |||
| b55d6a2c24 | |||
| 701c633cc5 | |||
| 3eac154ab6 | |||
| 34bd7e66ec | |||
| f965acaf27 | |||
| 9338532c8c | |||
| 89ebf6e9b5 | |||
| d519f4c04c | |||
| 4cb79807c6 | |||
| e765a5e9c8 | |||
| 100f952a92 | |||
| 6c220b5de5 | |||
| 21d14a0ecd | |||
| 74c69a42c9 | |||
| 677cf8e3d1 | |||
| 7c73bf17b9 | |||
| afa2a653d4 | |||
| 6374b1a81c | |||
| 66e64e3af3 | |||
| b82f20302a | |||
| b4c4ac6c03 | |||
| 19d681b08b | |||
| 475c7d6dc9 | |||
| 4abb6526f3 | |||
| a6a14a3457 | |||
| 1d524a1e5b | |||
| 56c6aaaef0 | |||
| 74102312d0 | |||
| e0db4dac3e | |||
| 05de378cdd | |||
| cd62300547 | |||
| 9302b1c8a5 | |||
| 7de3eb1153 | |||
| 60d2f5da1c | |||
| 0fcf6638c4 | |||
| 005b504422 | |||
| bb7c3bd337 | |||
| d12ac42513 | |||
| d0adc9ea4f | |||
| e09000480c | |||
| 7be6317e5e | |||
| ec2f7f0451 | |||
| 3546c0f1f1 | |||
| fe23b239db | |||
| 46694f67da | |||
| c68ee2d74e | |||
| 4f77a335e8 | |||
| 691a930893 | |||
| b0da66f2e8 | |||
| 74479dc5b9 | |||
| 7369f01d26 | |||
| c675bed506 | |||
| 3e78565e1d | |||
| 04cd7a74fa | |||
| 2d53f3c70f | |||
| 7745643c97 | |||
| 956a4ff911 | |||
| 59693bec9c | |||
| 4e2b937740 | |||
| 4d45778805 | |||
| c3d0a41918 | |||
| c0dd6ef480 | |||
| cd2123e555 | |||
| 76831f65ce | |||
| 0f7e2d5bad | |||
| 079169d8aa | |||
| e9efe70112 | |||
| fc2380d68c | |||
| 6b8a289908 | |||
| 2f8f286788 | |||
| fd10a41ec5 | |||
| 510f1cc570 | |||
| 3558205135 | |||
| 2b148a1982 | |||
| a3f894359e | |||
| 6cb9ccddfa | |||
| 9ff565927e | |||
| cca05eb926 | |||
| 90fbcb18ba | |||
| d5032e4fee | |||
| ec4506ebf4 | |||
| a56db5ea2b | |||
| 520e443712 | |||
| ca4f94ee57 | |||
| a722a18482 | |||
| 56e8c3b4a9 | |||
| 08312733eb | |||
| b55ae5f4c4 | |||
| 6604204b51 | |||
| 74f0305960 | |||
| 1778b61018 | |||
| 78271d7ffa | |||
| 88cc80db16 | |||
| 90d765d224 | |||
| 15db4490ce | |||
| 35357b8dc7 | |||
| dbece52cc3 | |||
| 5d981328db | |||
| 8498cf7b8d | |||
| f360a72e75 | |||
| 7ad40daeb9 | |||
| 676117c053 | |||
| fe837da592 | |||
| 0ce34f4135 | |||
| 2f333dac32 | |||
| c55c333bec | |||
| 2065553f97 | |||
| b6bbd1532c | |||
| a8143e235d | |||
| 9fac05d49e | |||
| e0b1d7c49c | |||
| 0b1ed7343f | |||
| d734872dfa | |||
| 50840eaa90 | |||
| e71ce2b338 | |||
| f8addc663b | |||
| eed78f7639 | |||
| 1cd41d9bec | |||
| 2c8b4cafe6 | |||
| 3a6a8afb41 | |||
| 5ab72d9d7a | |||
| ba289865ac | |||
| b8e6e71da6 | |||
| cff50a10fa | |||
| cb5b8f9a93 | |||
| 606325439f | |||
| e9ed64608f | |||
| 36330f6d46 | |||
| eb40b899e0 | |||
| 23640cd8bd | |||
| 21e8761d48 | |||
| d1249b4e4b | |||
| 34334fd160 | |||
| 82f91861f4 | |||
| 4b4e013212 | |||
| 177942648d | |||
| 57fa3b4912 | |||
| f1ec6785f6 | |||
| 4abcf45ff4 | |||
| 899866e595 | |||
| 722aa7d601 | |||
| 6f84148434 | |||
| 0dca9f0088 | |||
| 25c7ded898 | |||
| 722f034830 | |||
| 87f3e767e4 | |||
| a914dbc469 | |||
| 545480056a | |||
| 3ef3b12197 | |||
| 1a2c0419d8 | |||
| 7e90cfd4fd | |||
| 6e0e906369 | |||
| 492d007314 | |||
| 586f2795e3 | |||
| e5247170aa | |||
| 565c84ba71 | |||
| c07869e928 | |||
| ae18c8ddac | |||
| 1a43114f27 | |||
| 6e2c5a0ec7 | |||
| 4f272fc3a1 | |||
| 57dc1f2c4d | |||
| e225dd622c | |||
| 1efc8519e0 | |||
| 142797926d | |||
| d2520ade06 | |||
| 415ae401fd | |||
| 894fec8ab5 | |||
| d01980515b | |||
| 7fffa955ae | |||
| b3ec73fc75 | |||
| 4b23781a75 | |||
| 7cdce584eb | |||
| 710c894c5d | |||
| 8fd6fa14ca | |||
| 6ec855e93c | |||
| 41457c4c43 | |||
| d4804a5d83 | |||
| 39919f5045 | |||
| 82c9f6d762 | |||
| 2ae0b3f97d | |||
| 857f088da4 | |||
| 1ac9181942 | |||
| 0cdb77f2ad | |||
| d34d5040fb | |||
| 765fc00aa2 | |||
| 3d61ab45ec | |||
| 443d4d1e9b | |||
| 45cfdcdbd6 | |||
| acf591faca | |||
| abcc07c7ba | |||
| 220e473224 | |||
| 3b87ab5bcd | |||
| fce1b4c584 | |||
| 86719ec3d2 | |||
| 3a23e7ecd6 | |||
| ff5f6cd37c | |||
| 378e00147e | |||
| 482c96f0f3 | |||
| 497f0a2233 | |||
| f1c0261cea | |||
| e59d49af03 | |||
| 2d800082b2 | |||
| 352c081f03 | |||
| a786730ca6 | |||
| df21c42353 | |||
| 155f9326b5 | |||
| 5405dbfe39 | |||
| d7fd89c993 | |||
| 6f85366c9c | |||
| 943eee0b9d | |||
| 427769f56c | |||
| 6de678649c | |||
| cb63745b5a | |||
| 1ceb8dacb6 | |||
| 8b2055b352 | |||
| a2e67b71e3 | |||
| 81272c4fe8 | |||
| 6527b66c24 | |||
| 6baa4b94aa | |||
| eca04d4a81 | |||
| 7622801c40 | |||
| 954ddc8f6f | |||
| 94e3fa058f | |||
| 3cc393816e | |||
| acc7da2c07 | |||
| ea1b802f77 | |||
| d354b2ac07 | |||
| e5292a1504 | |||
| d1e7ed388f | |||
| e02cc37a63 | |||
| d285b22161 | |||
| b633518630 | |||
| 1923f3d2e1 | |||
| 5a245f9f36 | |||
| 9d1bb9e670 | |||
| ce0a94dd90 | |||
| 40348ffd22 | |||
| 4d8936f989 | |||
| 82e55421d6 | |||
| e95a89c86a | |||
| f39ef910aa | |||
| 93aa8d5d00 | |||
| 723b18abb9 | |||
| 07a3edf5b4 | |||
| 576ff0b407 | |||
| 73e9341ee7 | |||
| 34aaa563b2 | |||
| ea8ef913b4 | |||
| fd00d9ee6b | |||
| 92d7bc2fa2 | |||
| 765b534ba8 | |||
| ca6829a3ba | |||
| 35555e3d7c | |||
| 38a30553b4 | |||
| f479a7066c | |||
| 1e43122c3d | |||
| 414f35e353 | |||
| c5039c3152 | |||
| b2d60b70f0 | |||
| c6d7c66a8c | |||
| ab4d13fa14 | |||
| 29d5595ec8 | |||
| 852f6610f8 | |||
| 4fddb75f05 | |||
| 4650ca57fb | |||
| 9526c6f9cc | |||
| 8d095ea2f3 | |||
| 47d9efd1ec | |||
| 514f4be140 | |||
| 7eaf2531de | |||
| 293d768f8b | |||
| 8f3e9eefb0 | |||
| 610256f839 | |||
| 8077f8731f | |||
| ec6954733d | |||
| ab9a19d4f1 | |||
| 5e43913915 | |||
| 3ac8912cd5 | |||
| 4994c2a17b | |||
| c708d35b7a | |||
| 41d7b861e0 | |||
| b1fcd54fe0 | |||
| 060d921cbc | |||
| 885f1fe08b | |||
| 1c3c0ea9d4 | |||
| 69d27e1049 | |||
| ee4b64febe | |||
| 65ad6b5085 | |||
| 273d32f2ec | |||
| fdd9aba29a | |||
| 28cd165561 | |||
| 0e7183062e | |||
| 11c11884e7 | |||
| e65c238d37 | |||
| d29069256d | |||
| bc7ae51ce8 | |||
| a0fbc55607 | |||
| 8e359831e9 | |||
| d758950189 | |||
| a76c04b993 | |||
| 5300a3c289 | |||
| 509230445f | |||
| 98241c47c6 | |||
| e4feb4d1e8 | |||
| c93e8e26e4 | |||
| c5a7a9e3ea | |||
| 85d1c30e81 | |||
| 1aff8da252 | |||
| 5aa4a7a513 | |||
| 8f4213678f | |||
| e65fff3ac0 | |||
| 34ee987b03 | |||
| de5c31b605 | |||
| 2e4c98e4bf | |||
| e7bf9ec5e4 | |||
| 3826bcd8c8 | |||
| f166b72b7d | |||
| 2319197b81 | |||
| 7fa63850fc | |||
| c0d16b9d89 | |||
| ec6889d815 | |||
| 249d1d7323 | |||
| fba7c28051 | |||
| 25cd1e9a7f | |||
| 9c26a9dd94 | |||
| 94cb7cd030 | |||
| bc900f87cc | |||
| 2c9ab8fdfc | |||
| 88ad16668d | |||
| 644866f3ef | |||
| dae0f5b159 | |||
| 0323763e83 | |||
| feb1ad2ac0 | |||
| af51db6b7f | |||
| 56d564c1c1 | |||
| 58f163837f | |||
| ab7410a02b | |||
| 96f8fa3375 | |||
| 30d2b3679a | |||
| c304c32b28 | |||
| 54c9ff63f5 | |||
| 4e56114d3c | |||
| c3959d8513 | |||
| bfdbbe8de4 | |||
| 830aa15d24 | |||
| 2d2b28e49a | |||
| fa3a3a4492 | |||
| c6e317f93d | |||
| ebcb93ee7d | |||
| abcca7bf0b | |||
| 85e104adfd | |||
| dab6c21957 | |||
| d56b6c1420 | |||
| e9487fa58a | |||
| 901d16349e | |||
| a67899adb5 | |||
| 978c6040f8 | |||
| fee295810b | |||
| 95151048b9 | |||
| 3b13a6a4ee | |||
| b29d557e5b | |||
| 2d0ba17044 | |||
| c9cb3f10a8 | |||
| 8b0c60cd2d | |||
| 490714f5c0 | |||
| a9e338ba72 | |||
| ef7fc8173b | |||
| 828510a39d | |||
| 5ad0d51001 | |||
| 619315b533 | |||
| 740a9517ab | |||
| bd43e03d1b | |||
| deeb585e40 | |||
| e8399e4590 | |||
| 85a000b8df | |||
| a3bafa610f | |||
| c36e49c7df | |||
| 1e36c38d24 | |||
| 0c4977dc13 | |||
| e264cc0f1f | |||
| 34e42d3846 |
11
.env
11
.env
@@ -4,20 +4,20 @@ APP_KEY=base64:PBOxrGFJAtwj9SDF4F0DZ1J+6MjrJmRiPZJQwRdy3XQ=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_CHANNEL=daily
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=w4rpservices2
|
||||
DB_USERNAME=minerva
|
||||
DB_PASSWORD=strtmage
|
||||
DB_USERNAME=username
|
||||
DB_PASSWORD=password
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
|
||||
QUEUE_CONNECTION=database
|
||||
QUEUE_DRIVER=database
|
||||
QUEUE_DRIVER=redis
|
||||
QUEUE_CONNECTION=sync
|
||||
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
@@ -45,6 +45,7 @@ ESI_CLIENT_ID=e5848fea3618427a8ee0dccb6a04fc62
|
||||
ESI_SECRET_KEY=TdnNGRM8RTNSifZdaIc9yHTTkYPgYEEXHRIbT6oY
|
||||
ESI_USERAGENT='W4RP Services'
|
||||
ESI_CALLBACK_URI='http://services.w4rp.space/callback'
|
||||
ESI_PRIMARY_CHAR=93738489
|
||||
|
||||
EVEONLINE_CLIENT_ID=e5848fea3618427a8ee0dccb6a04fc62
|
||||
EVEONLINE_CLIENT_SECRET=TdnNGRM8RTNSifZdaIc9yHTTkYPgYEEXHRIbT6oY
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,3 +2,5 @@
|
||||
/logs
|
||||
.editorconfig
|
||||
/cache
|
||||
/public/logs
|
||||
worker.log
|
||||
|
||||
21
app/Charts/StructureFuelGauge.php
Normal file
21
app/Charts/StructureFuelGauge.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
120
app/Console/Commands/Assets/GetAssets.php
Normal file
120
app/Console/Commands/Assets/GetAssets.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use DB;
|
||||
use Log;
|
||||
|
||||
//Job
|
||||
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;
|
||||
|
||||
class GetAssetsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:GetAssets';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Gets all of the assets of the holding corporation.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$assets = null;
|
||||
$pages = 0;
|
||||
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('GetAssets');
|
||||
//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 = $config['primary'];
|
||||
$corpId = 98287666;
|
||||
|
||||
//ESI Scope Check
|
||||
$esiHelper = new Esi();
|
||||
$assetScope = $esiHelper->HaveEsiScope($config['primary'], 'esi-assets.read_corporation_assets.v1');
|
||||
|
||||
if($assetScope == false) {
|
||||
Log::critical("Scope check for esi-assets.read_corporation_assets.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 = $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);
|
||||
|
||||
try {
|
||||
$assets = $esi->page(1)
|
||||
->invoke('get', '/corporations/{corporation_id}/assets/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
} catch (RequestFailedException $e) {
|
||||
Log::critical("Failed to get asset list.");
|
||||
return null;
|
||||
}
|
||||
|
||||
$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');
|
||||
}
|
||||
}
|
||||
}
|
||||
44
app/Console/Commands/Data/CleanStaleDataCommand.php
Normal file
44
app/Console/Commands/Data/CleanStaleDataCommand.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
class CleanStaleDataCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:CleanData';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Clean old database data';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$command = new CommandHelper;
|
||||
$command->CleanJobStatusTable();
|
||||
}
|
||||
}
|
||||
81
app/Console/Commands/Finances/CorpFinances.php
Normal file
81
app/Console/Commands/Finances/CorpFinances.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
49
app/Console/Commands/Finances/CorpMarketMail.php
Normal file
49
app/Console/Commands/Finances/CorpMarketMail.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
@@ -55,16 +56,19 @@ class HoldingFinancesCommand extends Command
|
||||
//Setup the Finances container
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Get the total pages for the journal for the holding corporation
|
||||
$pages = $finance->GetJournalPageCount(1, 93738489);
|
||||
$pages = $finance->GetJournalPageCount(1, $config['primary']);
|
||||
|
||||
//Dispatch a single job for each page to process
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
$job = new JobProcessWalletJournal;
|
||||
$job->division = 1;
|
||||
$job->charId = 93738489;
|
||||
$job->charId = $config['primary'];
|
||||
$job->page = $i;
|
||||
ProcessWalletJournalJob::dispatch($job);
|
||||
ProcessWalletJournalJob::dispatch($job)->onQueue('journal');
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
@@ -59,7 +59,7 @@ class PiTransactionsCommand extends Command
|
||||
$job = new JobProcessWalletTransaction;
|
||||
$job->division = 3;
|
||||
$job->charId = 94415555;
|
||||
ProcessWalletTransactionJob::dispatch($job);
|
||||
ProcessWalletTransactionJob::dispatch($job)->onQueue('journal');
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
122
app/Console/Commands/Logistics/GetEveContracts.php
Normal file
122
app/Console/Commands/Logistics/GetEveContracts.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,10 @@ use Carbon\Carbon;
|
||||
use DB;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\SendEveMailJob;
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Moons\MoonMailer;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
//Models
|
||||
@@ -19,6 +18,7 @@ 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
|
||||
{
|
||||
@@ -62,30 +62,31 @@ class MoonMailerCommand extends Command
|
||||
//Add the entry into the jobs table saying the job has started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Declare the moon calc class variable to utilize the library to update the price
|
||||
$mailer = new MoonMailer;
|
||||
|
||||
//Create other variables
|
||||
$body = null;
|
||||
$delay = 5;
|
||||
|
||||
//Get today's date.
|
||||
$today = Carbon::now();
|
||||
$today->second = 1;
|
||||
$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 = $this->GetRentalMoons($contact);
|
||||
|
||||
$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);
|
||||
|
||||
@@ -94,29 +95,33 @@ class MoonMailerCommand extends Command
|
||||
foreach($listItems as $item) {
|
||||
$body .= $item . "<br>";
|
||||
}
|
||||
$body .= "The price for the next month's rent is " . $cost . "<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 JobSendEveMail;
|
||||
$mail->sender = 93738489;
|
||||
$mail->subject = "Warped Intentions Moon Rental Payment Due";
|
||||
$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;
|
||||
$mail->recipient = (int)$contact->Contact;
|
||||
$mail->recipient_type = 'character';
|
||||
SendEveMailJob::dispatch($mail);
|
||||
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) {
|
||||
if($today > $rental->Paid_Until)
|
||||
$this->UpdateNotPaid($rental);
|
||||
$previous = new Carbon($rental->Paid_Until);
|
||||
|
||||
if($today->greaterThan($previous)) {
|
||||
$this->UpdateNotPaid($rental);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
@@ -124,17 +129,13 @@ class MoonMailerCommand extends Command
|
||||
}
|
||||
|
||||
private function UpdateNotPaid(MoonRental $rental) {
|
||||
$today = Carbon::now();
|
||||
|
||||
if($today >= $rental->Paid_Until) {
|
||||
MoonRental::where([
|
||||
'System' => $rental->System,
|
||||
'Planet'=> $rental->Planet,
|
||||
'Moon'=> $rental->Moon,
|
||||
])->update([
|
||||
'Paid' => 'No',
|
||||
]);
|
||||
}
|
||||
MoonRental::where([
|
||||
'System' => $rental->System,
|
||||
'Planet'=> $rental->Planet,
|
||||
'Moon'=> $rental->Moon,
|
||||
])->update([
|
||||
'Paid' => 'No',
|
||||
]);
|
||||
}
|
||||
|
||||
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
|
||||
@@ -147,16 +148,13 @@ class MoonMailerCommand extends Command
|
||||
$sentmail->save();
|
||||
}
|
||||
|
||||
private function GetMoonList(MoonRental $moons) {
|
||||
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 = 'System: ' . $moon->System;
|
||||
$temp .= 'Planet: ' . $moon->Planet;
|
||||
$temp .= 'Moon: ' . $moon->Moon;
|
||||
//Push the new string onto the array list
|
||||
$temp = 'Moon: ' . $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon;
|
||||
array_push($list, $temp);
|
||||
}
|
||||
|
||||
@@ -168,7 +166,7 @@ class MoonMailerCommand extends Command
|
||||
$rentals = MoonRental::where([
|
||||
'Contact' => $contact,
|
||||
])->get();
|
||||
|
||||
dd($rentals);
|
||||
return $rentals;
|
||||
}
|
||||
|
||||
@@ -176,6 +174,7 @@ class MoonMailerCommand extends Command
|
||||
//Delcare variables and classes
|
||||
$moonCalc = new MoonCalc;
|
||||
$totalCost = 0.00;
|
||||
$price = null;
|
||||
|
||||
foreach($rentals as $rental) {
|
||||
$moon = Moon::where([
|
||||
@@ -185,9 +184,9 @@ class MoonMailerCommand extends Command
|
||||
])->first();
|
||||
|
||||
//Get the updated price for the moon
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
$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'];
|
||||
127
app/Console/Commands/Structures/GetStructures.php
Normal file
127
app/Console/Commands/Structures/GetStructures.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
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;
|
||||
|
||||
//Job
|
||||
use App\Jobs\ProcessStructureJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Jobs\JobProcessStructure;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
|
||||
class GetStructuresCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:GetStructures';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get the list of structures ';
|
||||
|
||||
/**
|
||||
* 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('GetStructures');
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Get the esi config
|
||||
$config = config('esi');
|
||||
|
||||
//Declare some variables
|
||||
$charId = $config['primary'];
|
||||
$corpId = 98287666;
|
||||
$sHelper = new StructureHelper($charId, $corpId);
|
||||
$structures = null;
|
||||
|
||||
//ESI Scope Check
|
||||
$esiHelper = new Esi();
|
||||
$structureScope = $esiHelper->HaveEsiScope($charId, 'esi-universe.read_structures.v1');
|
||||
$corpStructureScope = $esiHelper->HaveEsiScope($charId, 'esi-corporations.read_structures.v1');
|
||||
|
||||
//Check scopes
|
||||
if($structureScope == false || $corpStructureScope == false) {
|
||||
if($structureScope == false) {
|
||||
Log::critical("Scope check for esi-universe.read_structures.v1 has failed.");
|
||||
}
|
||||
if($corpStructureScope == false) {
|
||||
Log::critical("Scope check for esi-corporations.read_structures.v1 has failed.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//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);
|
||||
|
||||
//Set the current page
|
||||
$currentPage = 1;
|
||||
//Set our default total pages, and we will refresh this later
|
||||
$totalPages = 1;
|
||||
|
||||
//Try to get the ESI data
|
||||
try {
|
||||
$structures = $esi->page($currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/structures/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
} catch (RequestFailedException $e) {
|
||||
Log::critical("Failed to get structure list.");
|
||||
return null;
|
||||
}
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
184
app/Console/Commands/Users/PurgeUsers.php
Normal file
184
app/Console/Commands/Users/PurgeUsers.php
Normal file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
//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;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserAlt;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
|
||||
|
||||
/**
|
||||
* The PurgeUsers command takes care of updating any user changes in terms of login role, as well as purging any users without at least
|
||||
* the 'User' role. This command heavily relies on ESI being available. If no ESI is available, then the function does nothing, in order to prevent
|
||||
* unwanted changes.
|
||||
*/
|
||||
class PurgeUsers extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:PurgeUsers';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update and purge users from the database.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Setup the esi variable
|
||||
$esi = new Eseye();
|
||||
|
||||
//Get all of the users from the database
|
||||
$users = User::all();
|
||||
|
||||
//Get the allowed logins
|
||||
$legacy = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_id')->toArray();
|
||||
$renter = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_id')->toArray();
|
||||
|
||||
//Cycle through all of the users, and either update their role, or delete them.
|
||||
foreach($users as $user) {
|
||||
//Set the fail bit to false for the next user to check
|
||||
$failed = false;
|
||||
|
||||
//Note a screen entry for when doing cli stuff
|
||||
printf("Processing character with id of " . $user->character_id . "\r\n");
|
||||
|
||||
//Get the character information
|
||||
try {
|
||||
$character_info = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $user->character_id,
|
||||
]);
|
||||
|
||||
$corp_info = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $character_info->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get character information in purge user command for user ' . $user->character_id);
|
||||
$failed = true;
|
||||
}
|
||||
|
||||
//If the fail bit is still false, then continue
|
||||
if($failed === false) {
|
||||
//Get the user's role
|
||||
$role = UserRole::where(['character_id' => $user->character_id])->first();
|
||||
|
||||
//We don't want to modify Admin and SuperUsers. Admins and SuperUsers are removed via a different process.
|
||||
if($role->role != 'Admin') {
|
||||
//Check if the user is allowed to login
|
||||
if(isset($corp_info->alliance_id)) {
|
||||
//Warped Intentions is allowed to login
|
||||
if($corp_info->alliance_id == '99004116') {
|
||||
//If the alliance is Warped Intentions, then modify the role if we need to
|
||||
if($role->role != 'User') {
|
||||
//Upate the role of the user
|
||||
UserRole::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'role' => 'User',
|
||||
]);
|
||||
|
||||
//Update the user type
|
||||
User::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'user_type' => 'W4RP',
|
||||
]);
|
||||
}
|
||||
} else if(in_array($corp_info->alliance_id, $legacy)) { //Legacy Users
|
||||
if($role->role != 'User') {
|
||||
//Update the role of the user
|
||||
UserRole::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'role' => 'User',
|
||||
]);
|
||||
|
||||
//Update the user type
|
||||
User::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'user_type' => 'Legacy',
|
||||
]);
|
||||
}
|
||||
} else if(in_array($corp_info->alliance_id, $renter)) { //Renter Users
|
||||
if($role->role != 'Renter') {
|
||||
//Update the role of the user
|
||||
UserRole::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'role' => 'Renter',
|
||||
]);
|
||||
|
||||
//Update the user type
|
||||
User::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->update([
|
||||
'user_type' => 'Renter',
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
//If the user is part of no valid login group, then delete the user.
|
||||
//Delete all of the permissions first
|
||||
UserPermission::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
|
||||
//Delete the user's role
|
||||
UserRole::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
|
||||
//Delete any alts the user might have registered.
|
||||
$altCount = UserAlt::where(['main_id' => $user->character_id])->count();
|
||||
if($altCount > 0) {
|
||||
UserAlt::where([
|
||||
'main_id' => $user->character_id,
|
||||
])->delete();
|
||||
}
|
||||
|
||||
//Delete the user from the user table
|
||||
User::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\SendEveMailJob;
|
||||
|
||||
//Libraries
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
use App\Library\Structures\StructureTaxHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Market\MonthlyMarketTax;
|
||||
use App\Models\ScheduledTask\ScheduleJob;
|
||||
use App\Models\Corporation\CorpStructure;
|
||||
use App\Models\User\UserToCorporation;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
|
||||
class CalculateMarketTaxCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:CalculateMarketTax';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Calculate the market taxes owed to the holding corporation and store in the database.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('CorpJournal');
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Setup helper classes
|
||||
$hFinances = new FinanceHelper();
|
||||
$sHelper = new StructureTaxHelper();
|
||||
$start = Carbon::now()->startOfMonth()->subMonth();
|
||||
$end = Carbon::now()->endOfMOnth()->subMonth();
|
||||
$end->hour = 23;
|
||||
$end->minute = 59;
|
||||
$end->second = 59;
|
||||
|
||||
//Get the set of corporations from the structure table
|
||||
$corps = CorpStructure::select('corporation_id')->groupBy('corporation_id')->get();
|
||||
$this->line('Got all of the corps with markets.' . sizeof($corps));
|
||||
foreach($corps as $corp) {
|
||||
if($corp->corporation_id != 98287666) {
|
||||
$finalTaxes = $sHelper->GetTaxes($corp->corporation_id, 'Market', $start, $end);
|
||||
if($finalTaxes < 0.00) {
|
||||
$finalTaxes = 0.00;
|
||||
}
|
||||
|
||||
//Get the info about the structures from the database
|
||||
$info = CorpStructure::where(['corporation_id' => $corp->corporation_id])->first();
|
||||
|
||||
$character = UserToCorporation::where(['character_id' => $info->character_id])->first();
|
||||
|
||||
$mail = new JobSendEveMail;
|
||||
$mail->sender = 93738489;
|
||||
$mail->subject = 'Market Taxes Owed';
|
||||
$mail->body = 'Year ' . $start->year . ' ' .
|
||||
'Month: ' .
|
||||
$start->month .
|
||||
'<br>Market Taxes Owed: ' .
|
||||
number_format($finalTaxes, 2, '.', ',') .
|
||||
'<br>Please remit to Spatial Forces';
|
||||
$mail->recipient = (int)$info->character_id;
|
||||
$mail->recipient_type = 'character';
|
||||
SendEveMailJob::dispatch($mail);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessWalletJournalJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Corporation\CorpStructure;
|
||||
use App\Models\Jobs\JobProcessWalletJournal;
|
||||
|
||||
class CorpJournalCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:CorpJournal';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Grabs the corporation journals and deposit in db.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('CorpJournal');
|
||||
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Setup the Finances Container
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
//Setup an array to store corporations which have been logged so we don't keep calling the same ones. We need
|
||||
//this step in order to save time during the cronjob.
|
||||
$finishedCorps = array();
|
||||
$corpCompleted = false;
|
||||
|
||||
//Get the corps with structures logged in the database
|
||||
$corps = CorpStructure::select('corporation_id')->groupBy('corporation_id')->get();
|
||||
|
||||
//For all of the corporations, go through each structure and get wallet data
|
||||
foreach($corps as $corp) {
|
||||
//If the corporation isn't the holding corporation, then process the data.
|
||||
//We process holding corporation data elsewhere.
|
||||
if($corp->corporation_id != 98287666) {
|
||||
$structure = CorpStructure::where(['corporation_id' => $corp->corporation_id])->first();
|
||||
$pages = $finance->GetJournalPageCount(1, $structure->character_id);
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
$job = new JobProcessWalletJournal;
|
||||
$job->division = 1;
|
||||
$job->charId = $structure->character_id;
|
||||
$job->page = $i;
|
||||
ProcessWalletJournalJob::dispatch($job);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,13 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
@@ -13,13 +17,15 @@ class Kernel extends ConsoleKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
Commands\CorpJournalCommand::class,
|
||||
Commands\GetCorpsCommand::class,
|
||||
Commands\UpdateMoonPriceCommand::class,
|
||||
Commands\CalculateMarketTaxCommand::class,
|
||||
Commands\HoldingFinancesCommand::class,
|
||||
Commands\MoonMailerCommand::class,
|
||||
Commands\PiTransactionsCommand::class,
|
||||
Commands\GetStructuresCommand::class,
|
||||
Commands\GetAssetsCommand::class,
|
||||
Commands\GetEveContractsCommand::class,
|
||||
Commands\PurgeUsers::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -30,9 +36,6 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('services:CorpJournal')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:HoldingJournal')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
@@ -42,15 +45,26 @@ class Kernel extends ConsoleKernel
|
||||
$schedule->command('services:GetCorps')
|
||||
->monthlyOn(1, '09:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:CalculateMarketTax')
|
||||
->monthlyOn(1, '08: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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
43
app/Http/Controllers/Ajax/LiveSearch.php
Normal file
43
app/Http/Controllers/Ajax/LiveSearch.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ use DB;
|
||||
use Socialite;
|
||||
use Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Models\User\User;
|
||||
|
||||
class EsiScopeController extends Controller
|
||||
{
|
||||
|
||||
@@ -8,12 +8,13 @@ use Illuminate\Http\Request;
|
||||
use Socialite;
|
||||
use Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Models\User\User;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
use App\Models\User\UserAlt;
|
||||
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
@@ -78,12 +79,68 @@ class LoginController extends Controller
|
||||
* Redirect to the dashboard if logging in successfully.
|
||||
*/
|
||||
public function handleProviderCallback() {
|
||||
//Get the sso user from the socialite driver
|
||||
$ssoUser = Socialite::driver('eveonline')->user();
|
||||
$user = $this->createOrGetUser($ssoUser);
|
||||
|
||||
auth()->login($user, true);
|
||||
if(Auth::check()) {
|
||||
//If a refresh token is present, then we are doing a scope callback
|
||||
//to update scopes for an access token
|
||||
|
||||
return redirect()->to('/dashboard')->with('success', 'Successfully Logged In or Updated ESI.');
|
||||
if(isset($ssoUser->refreshToken)) {
|
||||
//See if an access token is present already
|
||||
$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 the token, we need to update the table for scopes
|
||||
$this->SetScopes($ssoUser->user['Scopes'], $ssoUser->id);
|
||||
|
||||
return redirect()->to('/dashboard')->with('success', 'Successfully updated ESI Scopes.');
|
||||
} else {
|
||||
$created = $this->createAlt($ssoUser);
|
||||
if($created == 1) {
|
||||
return redirect()->to('/profile')->with('success', 'Alt registered.');
|
||||
} else {
|
||||
return redirect()->to('/profile')->with('error', 'Alt was previously registered.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$user = $this->createOrGetUser($ssoUser);
|
||||
|
||||
auth()->login($user, true);
|
||||
|
||||
return redirect()->to('/dashboard')->with('success', 'Successfully Logged In.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an alt exists in the database, else, create and
|
||||
* return the user object.
|
||||
*
|
||||
* @param \Laravel\Socialite\Two\User $user
|
||||
*/
|
||||
private function createAlt($user) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,69 +150,32 @@ class LoginController extends Controller
|
||||
* @param \Laravel\Socialite\Two\User $user
|
||||
*/
|
||||
private function createOrGetUser($eve_user) {
|
||||
//Search for user in the database
|
||||
$authUser = User::where('character_id', $eve_user->id)->first();
|
||||
$authUser = null;
|
||||
|
||||
//Search to see if we have a matching user in the database.
|
||||
//At this point we don't care about the information
|
||||
$userCount = User::where('character_id', $eve_user->id)->count();
|
||||
|
||||
//If the user is found, do more checks to see what type of login we are doing
|
||||
if($authUser) {
|
||||
//if a refresh token is present, then we are doing a scope callback to update scopes for an access token
|
||||
if($eve_user->refreshToken !== null) {
|
||||
//Check if the owner hash has changed to call the user type if it needs to be updated
|
||||
if($this->OwnerHasChanged($authUser->owner_hash, $eve_user->owner_hash)) {
|
||||
//Get the right role for the user
|
||||
$role = $this->GetRole(null, $eve_user->id);
|
||||
//Set the role for the user
|
||||
$this->SetRole($role, $eve_user->id);
|
||||
if($userCount > 0) {
|
||||
//Search for user in the database
|
||||
$authUser = User::where('character_id', $eve_user->id)->first();
|
||||
|
||||
//Update the user information never the less.
|
||||
User::where('character_id', $eve_user->id)->update([
|
||||
'avatar' => $eve_user->avatar,
|
||||
'owner_hash' => $eve_user->owner_hash,
|
||||
'role' => $role,
|
||||
]);
|
||||
//Update the user's roles and permission
|
||||
UserPermission::where(['character_id' => $eve_user->id])->delete();
|
||||
$perm = new UserPermission();
|
||||
$perm->character_id = $eve_user->id;
|
||||
$perm->permission = $role;
|
||||
$perm->save();
|
||||
} else {
|
||||
//Update the user information never the less.
|
||||
User::where('character_id', $eve_user->id)->update([
|
||||
'avatar' => $eve_user->avatar,
|
||||
]);
|
||||
}
|
||||
|
||||
//See if we have an access token for the user.
|
||||
//If we have a token update the token, if not create an entry into the database
|
||||
$token = EsiToken::where('character_id', $eve_user->id)->first();
|
||||
if($token) {
|
||||
//Update the ESI Token
|
||||
EsiToken::where('character_id', $eve_user->id)->update([
|
||||
'character_id' => $eve_user->getId(),
|
||||
'access_token' => $eve_user->token,
|
||||
'refresh_token' => $eve_user->refreshToken,
|
||||
'expires_in' => $eve_user->expiresIn,
|
||||
]);
|
||||
} else { //If a token entry is not found, then we create a new token entry into the database
|
||||
//Save the ESI Token in the database
|
||||
$token = new EsiToken;
|
||||
$token->character_id = $eve_user->id;
|
||||
$token->access_token = $eve_user->token;
|
||||
$token->refresh_token = $eve_user->refreshToken;
|
||||
$token->expires_in = $eve_user->expiresIn;
|
||||
$token->save();
|
||||
}
|
||||
//Check to see if the owner has changed
|
||||
//If the owner has changed, then update their roles and permissions
|
||||
if($this->OwnerHasChanged($authUser->owner_hash, $eve_user->owner_hash)) {
|
||||
//Get the right role for the user
|
||||
$role = $this->GetRole(null, $eve_user->id);
|
||||
//Set the role for the user
|
||||
$this->SetRole($role, $eve_user->id);
|
||||
|
||||
//After creating the token, we need to update the table for scopes
|
||||
//First we look for all the scopes, then if need be add entries or delete entries from the database
|
||||
$this->SetScopes($eve_user->user['Scopes'], $eve_user->id);
|
||||
//Update the user information never the less.
|
||||
$this->UpdateUser($eve_user, $role);
|
||||
|
||||
} else {
|
||||
//If the user is already in the database, but no refresh token was present in the callback, then just update the user
|
||||
User::where('character_id', $eve_user->id)->update([
|
||||
'avatar' => $eve_user->avatar,
|
||||
]);
|
||||
//Update the user's roles and permission
|
||||
$this->UpdatePermission($eve_user, $role);
|
||||
}
|
||||
|
||||
//Return the user to the calling auth function
|
||||
return $authUser;
|
||||
} else {
|
||||
@@ -163,16 +183,7 @@ class LoginController extends Controller
|
||||
$role = $this->GetRole(null, $eve_user->id);
|
||||
|
||||
//Create the user account
|
||||
$user = User::create([
|
||||
'name' => $eve_user->getName(),
|
||||
'email' => null,
|
||||
'avatar' => $eve_user->avatar,
|
||||
'owner_hash' => $eve_user->owner_hash,
|
||||
'character_id'=> $eve_user->getId(),
|
||||
'expires_in' => $eve_user->expiresIn,
|
||||
'access_token' => $eve_user->token,
|
||||
'user_type' => $this->GetAccountType(null, $eve_user->id),
|
||||
]);
|
||||
$user = $this->CreateNewUser($eve_user);
|
||||
|
||||
//Set the role for the user
|
||||
$this->SetRole($role, $eve_user->id);
|
||||
@@ -182,6 +193,81 @@ class LoginController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update avatar
|
||||
*/
|
||||
private function UpdateAvatar($eve_user) {
|
||||
User::where('character_id', $eve_user->id)->update([
|
||||
'avatar' => $eve_user->avatar,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update user permission
|
||||
*/
|
||||
private function UpdatePermission($eve_user, $role) {
|
||||
UserPermission::where(['character_id' => $eve_user->id])->delete();
|
||||
$perm = new UserPermission();
|
||||
$perm->character_id = $eve_user->id;
|
||||
$perm->permission = $role;
|
||||
$perm->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the user
|
||||
*/
|
||||
private function UpdateUser($eve_user, $role) {
|
||||
User::where('character_id', $eve_user->id)->update([
|
||||
'avatar' => $eve_user->avatar,
|
||||
'owner_hash' => $eve_user->owner_hash,
|
||||
'role' => $role,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user account
|
||||
*/
|
||||
private function CreateNewUser($eve_user) {
|
||||
$user = User::create([
|
||||
'name' => $eve_user->getName(),
|
||||
'avatar' => $eve_user->avatar,
|
||||
'owner_hash' => $eve_user->owner_hash,
|
||||
'character_id' => $eve_user->getId(),
|
||||
'inserted_at' => time(),
|
||||
'expires_in' => $eve_user->expiresIn,
|
||||
'access_token' => $eve_user->token,
|
||||
'user_type' => $this->GetAccountType(null, $eve_user->id),
|
||||
]);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user role in the database
|
||||
*
|
||||
|
||||
@@ -10,12 +10,17 @@ use Carbon\Carbon;
|
||||
//Libraries
|
||||
use App\Library\Esi\Mail;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Models
|
||||
use App\User;
|
||||
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
|
||||
{
|
||||
@@ -66,6 +71,9 @@ class ContractAdminController extends Controller
|
||||
$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.');
|
||||
}
|
||||
|
||||
@@ -132,6 +140,9 @@ class ContractAdminController extends Controller
|
||||
$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();
|
||||
|
||||
@@ -143,18 +154,22 @@ class ContractAdminController extends Controller
|
||||
$body .= $contract['body'] . '<br>';
|
||||
$body .= 'Please remit contract when the items are ready to Spatial Forces. Description should be the contract identification number. Request ISK should be the bid amount.';
|
||||
$body .= 'Sincerely,<br>Spatial Forces Contracting Department';
|
||||
while($mail->SendMail($bid['character_id'], 'character', $subject, $body)) {
|
||||
$tries++;
|
||||
if($tries == 5) {
|
||||
TidyContract($contract, $bid);
|
||||
|
||||
return redirect('/contracts/admin/display')->with('error', 'Could not deliver mail. Please manually send the mail to the winner.');
|
||||
}
|
||||
}
|
||||
//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');
|
||||
|
||||
TidyContract($contract, $bid);
|
||||
//Tidy up the contract by doing a few things.
|
||||
$this->TidyContract($contract, $bid);
|
||||
|
||||
return redirect('/contracts/admin/display')->with('success', 'Contract finalized. Mail took ' . $tries . ' attempt to send to the winner.');
|
||||
//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) {
|
||||
@@ -170,4 +185,23 @@ class ContractAdminController extends Controller
|
||||
$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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ use App\Library\Lookups\LookupHelper;
|
||||
//use App\Library\Contracts\ContractHelper;
|
||||
|
||||
//Models
|
||||
use App\User;
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\Contracts\Contract;
|
||||
use App\Models\Contracts\Bid;
|
||||
@@ -80,10 +80,11 @@ class ContractController extends Controller
|
||||
$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();
|
||||
->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++) {
|
||||
@@ -94,10 +95,12 @@ class ContractController extends Controller
|
||||
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'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,7 +116,10 @@ class ContractController extends Controller
|
||||
$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
|
||||
|
||||
122
app/Http/Controllers/Corps/BlacklistController.php
Normal file
122
app/Http/Controllers/Corps/BlacklistController.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ use DB;
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
|
||||
//Models
|
||||
use App\User;
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\AvailableUserPermission;
|
||||
@@ -23,17 +23,110 @@ class AdminController extends Controller
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
public function displayDashboard() {
|
||||
public function displayUsersPaginated() {
|
||||
//Declare array variables
|
||||
$user = array();
|
||||
$permission = array();
|
||||
$userArr = array();
|
||||
$permString = null;
|
||||
|
||||
$usersArr = User::orderBy('name', 'asc')->paginate(50);
|
||||
|
||||
foreach($usersArr as $user) {
|
||||
$user->role = $user->getRole();
|
||||
|
||||
$permCount = UserPermission::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->count();
|
||||
|
||||
if($permCount > 0) {
|
||||
$perms = UserPermission::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->get('permission')->toArray();
|
||||
|
||||
foreach($perms as $perm) {
|
||||
$permString .= $perm['permission'] . ', ';
|
||||
}
|
||||
|
||||
$user->permission = $permString;
|
||||
} else {
|
||||
$user->permission = 'No Permissions';
|
||||
}
|
||||
}
|
||||
|
||||
return view('admin.dashboards.userspaged')->with('usersArr', $usersArr);
|
||||
}
|
||||
|
||||
public function displayUsers($page) {
|
||||
//Declare array variables
|
||||
$user = array();
|
||||
$permission = array();
|
||||
$userArr = array();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
$tempUser['name'] = $user['name'];
|
||||
$tempUser['role'] = $user['user_type'];
|
||||
$tempUser['permissions'] = $perms;
|
||||
|
||||
array_push($userArr, $tempUser);
|
||||
}
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
public function displayAllowedLogins() {
|
||||
//Declare array variables
|
||||
$entities = array();
|
||||
|
||||
/** Entities for allowed logins */
|
||||
$legacys = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_name')->toArray();
|
||||
$renters = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_name')->toArray();
|
||||
//Compile a list of entities by their entity_id
|
||||
foreach($legacys as $legacy) {
|
||||
$entities[] = $legacy;
|
||||
}
|
||||
foreach($renters as $renter) {
|
||||
$entities[] = $renter;
|
||||
}
|
||||
|
||||
return view('admin.dashboards.allowed_logins')->with('entities', $entities);
|
||||
}
|
||||
|
||||
public function displayPurgeWiki() {
|
||||
return view('admin.dashboards.purge_wiki');
|
||||
}
|
||||
|
||||
public function displayTaxes() {
|
||||
//Declare variables needed for displaying items on the page
|
||||
$months = 3;
|
||||
$pi = array();
|
||||
$industry = array();
|
||||
$reprocessing = array();
|
||||
$office = array();
|
||||
$user = array();
|
||||
$permission = array();
|
||||
$entities = array();
|
||||
$corpId = 98287666;
|
||||
$srpActual = array();
|
||||
$srpLoss = array();
|
||||
|
||||
/** Taxes Pane */
|
||||
//Declare classes needed for displaying items on the page
|
||||
@@ -42,6 +135,18 @@ class AdminController extends Controller
|
||||
$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($tHelper->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, ".", ","),
|
||||
];
|
||||
|
||||
//Get the pi taxes for the date range
|
||||
$pis[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
@@ -65,7 +170,7 @@ class AdminController extends Controller
|
||||
//Get the market taxes for the date range
|
||||
$markets[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetMarketGross($date['start'], $date['end']), 2, ".", ","),
|
||||
'gross' => number_format($tHelper->GetAllianceMarketGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the jump gate taxes for the date range
|
||||
$jumpgates[] = [
|
||||
@@ -79,48 +184,44 @@ class AdminController extends Controller
|
||||
];
|
||||
}
|
||||
|
||||
/** Users & Permissions Pane */
|
||||
//Get the users from the database to allow a selection of users for various parts of the webpage
|
||||
$users = User::pluck('name')->all();
|
||||
//Get the available permissions from the database to allow a selection of permissions
|
||||
$permissions = AvailableUserPermission::pluck('permission')->all();
|
||||
//Create the user key value pairs
|
||||
foreach($users as $key => $value) {
|
||||
$user[$value] = $value;
|
||||
}
|
||||
//Create the permission key value pairs
|
||||
foreach($permissions as $key => $value) {
|
||||
$permission[$value] = $value;
|
||||
}
|
||||
//Create the data array
|
||||
$data = [
|
||||
'users' => $user,
|
||||
'permissions' => $permission,
|
||||
];
|
||||
|
||||
/** Entities for allowed logins */
|
||||
$legacys = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_name')->toArray();
|
||||
$renters = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_name')->toArray();
|
||||
//Compile a list of entities by their entity_id
|
||||
foreach($legacys as $legacy) {
|
||||
$entities[] = $legacy;
|
||||
}
|
||||
foreach($renters as $renter) {
|
||||
$entities[] = $renter;
|
||||
}
|
||||
|
||||
return view('admin.dashboard')->with('data', $data)
|
||||
->with('pis', $pis)
|
||||
->with('industrys', $industrys)
|
||||
->with('offices', $offices)
|
||||
->with('markets', $markets)
|
||||
->with('jumpgates', $jumpgates)
|
||||
->with('reprocessings', $reprocessings)
|
||||
->with('entities', $entities)
|
||||
->with('pigross', $pigross);
|
||||
return view('admin.dashboards.taxes')->with('pis', $pis)
|
||||
->with('industrys', $industrys)
|
||||
->with('offices', $offices)
|
||||
->with('markets', $markets)
|
||||
->with('jumpgates', $jumpgates)
|
||||
->with('reprocessings', $reprocessings)
|
||||
->with('pigross', $pigross)
|
||||
->with('srpActual', $srpActual)
|
||||
->with('srpLoss', $srpLoss);
|
||||
}
|
||||
|
||||
public function modifyRole(Request $request) {
|
||||
public function displayModifyUser(Request $request) {
|
||||
$permissions = array();
|
||||
|
||||
$name = $request->user;
|
||||
|
||||
//Get the user information from the name
|
||||
$user = User::where(['name' => $name])->first();
|
||||
|
||||
$perms = AvailableUserPermission::all();
|
||||
foreach($perms as $p) {
|
||||
$permissions[$p->permission] = $p->permission;
|
||||
}
|
||||
|
||||
//Pass the user information to the page for hidden text entries
|
||||
return view('admin.user.modify')->with('user', $user)
|
||||
->with('permissions', $permissions);
|
||||
}
|
||||
|
||||
public function modifyUser(Request $request) {
|
||||
$type = $request->type;
|
||||
if(isset($request->permission)) {
|
||||
$permission = $request->permission;
|
||||
}
|
||||
if(isset($request->user)) {
|
||||
$user = $request->user;
|
||||
}
|
||||
|
||||
return redirect('/admin/dashboard')->with('error', 'Not implemented yet.');
|
||||
}
|
||||
|
||||
@@ -182,8 +283,8 @@ class AdminController extends Controller
|
||||
$found = AllowedLogin::where([
|
||||
'entity_type' => $request->allowedentityType,
|
||||
'entity_name' => $request->allowedEntityName,
|
||||
])->get();
|
||||
if($found != null) {
|
||||
])->count();
|
||||
if($found != 0) {
|
||||
AllowedLogin::where([
|
||||
'entity_type' => $request->allowedEntityType,
|
||||
'entity_name' => $request->allowedEntityName,
|
||||
|
||||
@@ -2,15 +2,20 @@
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
//Internal Libraries
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\SRP\SRPShip;
|
||||
use App\Models\User\UserAlt;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
@@ -32,7 +37,162 @@ class DashboardController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard');
|
||||
//Set some variables to be used in if statements
|
||||
$open = array();
|
||||
$approved = array();
|
||||
$denied = array();
|
||||
$altCount = null;
|
||||
$alts = null;
|
||||
|
||||
//Get the number of the user's alt which are registered so we can process the alt's on the main dashboard page
|
||||
$altCount = UserAlt::where([
|
||||
'main_id' => auth()->user()->character_id,
|
||||
])->count();
|
||||
|
||||
//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([
|
||||
'main_id' => auth()->user()->character_id,
|
||||
])->get();
|
||||
}
|
||||
|
||||
//See if we can get all of the open SRP requests
|
||||
$openCount = SRPShip::where([
|
||||
'character_id' => auth()->user()->character_id,
|
||||
'approved' => 'Under Review',
|
||||
])->count();
|
||||
if($openCount > 0) {
|
||||
$open = SRPShip::where([
|
||||
'character_id' => auth()->user()->character_id,
|
||||
'approved' => 'Under Review'
|
||||
])->get()->toArray();
|
||||
}
|
||||
|
||||
//See if we can get all of the closed and approved SRP requests
|
||||
$approvedCount = SRPShip::where([
|
||||
'character_id' => auth()->user()->character_id,
|
||||
'approved' => 'Approved',
|
||||
])->count();
|
||||
if($approvedCount > 0) {
|
||||
$approved = SRPShip::where([
|
||||
'character_id' => auth()->user()->character_id,
|
||||
'approved' => 'Approved',
|
||||
])->take(10)->get()->toArray();
|
||||
}
|
||||
|
||||
//See if we can get all of the closed and denied SRP requests
|
||||
$deniedCount = SRPShip::where([
|
||||
'character_id' => auth()->user()->character_id,
|
||||
'approved' => 'Denied',
|
||||
])->count();
|
||||
if($deniedCount > 0) {
|
||||
$denied = SRPShip::where([
|
||||
'character_id' => auth()->user()->character_id,
|
||||
'approved' => 'Denied',
|
||||
])->take(10)->get()->toArray();
|
||||
}
|
||||
|
||||
//Process all types of srp requests for the alt of the main and add to the main's page
|
||||
if($altCount > 0) {
|
||||
//For each alt, get the open requests, and increment the open request counter
|
||||
foreach($alts as $alt) {
|
||||
$altOpenCount = SRPShip::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'approved' => 'Under Review',
|
||||
])->count();
|
||||
if($altOpenCount > 0) {
|
||||
//If the number of open requests is greater than zero, add to the open count
|
||||
$openCount += $altOpenCount;
|
||||
|
||||
//Get the alt's open srp requests
|
||||
$altOpen = SRPShip::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'approved' => 'Under Review',
|
||||
])->get()->toArray();
|
||||
|
||||
//Add the alt's open requests to the open requests array
|
||||
foreach($altOpen as $aOpen) {
|
||||
array_push($open, $aOpen);
|
||||
}
|
||||
}
|
||||
|
||||
$altApprovedCount = SRPShip::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'approved' => 'Approved',
|
||||
])->count();
|
||||
if($altApprovedCount > 0) {
|
||||
//If the number of approved requests is greater than zero, add to the approved count
|
||||
$approvedCount += $altApprovedCount;
|
||||
|
||||
//Get the alt's approved srp request
|
||||
$altApproved = SRPShip::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'approved' => 'Approved',
|
||||
])->take(5)->get()->toArray();
|
||||
|
||||
//For each alt add it to the array
|
||||
foreach($altApproved as $aApproved) {
|
||||
array_push($approved, $aApproved);
|
||||
}
|
||||
}
|
||||
|
||||
$altDeniedCount = SRPShip::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'approved' => 'Denied',
|
||||
])->count();
|
||||
if($altDeniedCount > 0) {
|
||||
//If the denied count is greater then zero for the alt, add it to the count
|
||||
$deniedCount += $altDeniedCount;
|
||||
|
||||
//Get the denied alt's srp requests
|
||||
$altDenied = SRPShip::where([
|
||||
'character_id' => $alt->character_id,
|
||||
'approved' => 'Denied',
|
||||
])->take(5)->get()->toArray();
|
||||
|
||||
//For each alt's denied request add it to the array
|
||||
foreach($altDenied as $aDenied) {
|
||||
array_push($denied, $aDenied);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Create a chart of number of approved, denied, and open requests via a fuel gauge chart
|
||||
$lava = new Lavacharts;
|
||||
|
||||
$adur = $lava->DataTable();
|
||||
|
||||
$adur->addStringColumn('Type')
|
||||
->addNumberColumn('Number')
|
||||
->addRow(['SRP', $openCount]);
|
||||
|
||||
$lava->GaugeChart('SRP', $adur, [
|
||||
'width' => 200,
|
||||
'max' => 15,
|
||||
'greenFrom' => 0,
|
||||
'greenTo' => 5,
|
||||
'yellowFrom' => 5,
|
||||
'yellowTo' => 10,
|
||||
'redFrom' => 10,
|
||||
'redTo' => 15,
|
||||
'majorTicks' => [
|
||||
'Safe',
|
||||
'Warning',
|
||||
'Critical',
|
||||
],
|
||||
]);
|
||||
|
||||
return view('dashboard')->with('openCount', $openCount)
|
||||
->with('approvedCount', $approvedCount)
|
||||
->with('deniedCount', $deniedCount)
|
||||
->with('open', $open)
|
||||
->with('approved', $approved)
|
||||
->with('denied', $denied)
|
||||
->with('lava', $lava);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,16 +202,57 @@ class DashboardController extends Controller
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function profile() {
|
||||
$scopes = EsiScope::where('character_id', Auth()->user()->character_id)->get();
|
||||
$permissions = UserPermission::where('character_id', Auth()->user()->characer_id)->get();
|
||||
$roles = UserRole::where('character_id', Auth()->user()->character_id)->get();
|
||||
|
||||
$data = [
|
||||
'scopes' => $scopes,
|
||||
'permissions' => $permissions,
|
||||
'roles' => $roles,
|
||||
];
|
||||
//Declare some variables
|
||||
$alts = null;
|
||||
$scopes = null;
|
||||
$permissions = null;
|
||||
$roles = null;
|
||||
|
||||
return view('dashboard.profile')->with('data', $data);
|
||||
//Get the Esi scopes, user permission set, and roles
|
||||
$scopeCount = EsiScope::where('character_id', Auth()->user()->character_id)->count();
|
||||
if($scopeCount > 0) {
|
||||
$scopes = EsiScope::where('character_id', Auth()->user()->character_id)->get();
|
||||
}
|
||||
|
||||
//Get the permission count and permission of the user
|
||||
$permissionCount = UserPermission::where('character_id', auth()->user()->character_id)->count();
|
||||
if($permissionCount > 0) {
|
||||
$permissions = UserPermission::where('character_id', auth()->user()->character_id)->get();
|
||||
}
|
||||
|
||||
//Get the roles and role count of the user
|
||||
$roleCount = UserRole::where('character_id', Auth()->user()->character_id)->count();
|
||||
if($roleCount > 0) {
|
||||
$roles = UserRole::where('character_id', Auth()->user()->character_id)->get();
|
||||
}
|
||||
|
||||
//Get the alt count and alts of the user
|
||||
$altCount = UserAlt::where('main_id', Auth()->user()->character_id)->count();
|
||||
if($altCount > 0) {
|
||||
$alts = UserAlt::where(['main_id' => Auth()->user()->character_id])->get();
|
||||
}
|
||||
|
||||
//Return the view with that data
|
||||
return view('dashboard.profile')->with('scopeCount', $scopeCount)
|
||||
->with('scopes', $scopes)
|
||||
->with('permissionCount', $permissionCount)
|
||||
->with('permissions', $permissions)
|
||||
->with('roleCount', $roleCount)
|
||||
->with('roles', $roles)
|
||||
->with('altCount', $altCount)
|
||||
->with('alts', $alts);
|
||||
}
|
||||
|
||||
public function removeAlt(Request $request) {
|
||||
$this->validate($request, [
|
||||
'character' => 'required',
|
||||
]);
|
||||
|
||||
UserAlt::where([
|
||||
'main_id' => auth()->user()->character_id,
|
||||
'character_id' => $request->character,
|
||||
])->delete();
|
||||
|
||||
return redirect('/dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
87
app/Http/Controllers/Logistics/FuelController.php
Normal file
87
app/Http/Controllers/Logistics/FuelController.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Fuel;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
use Auth;
|
||||
use Charts;
|
||||
|
||||
//Library Helpers
|
||||
use App\Library\Assets\AssetHelper;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Structure\Structure;
|
||||
|
||||
class FuelController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:logistics.manager');
|
||||
}
|
||||
|
||||
public function displayStructures() {
|
||||
//Declare variables
|
||||
$jumpGates = array();
|
||||
$lava = new Lavacharts;
|
||||
|
||||
//Declare the class helpers
|
||||
$sHelper = new StructureHelper(null, null, null);
|
||||
$aHelper = new AssetHelper(null, null, null);
|
||||
|
||||
//Setup the charts
|
||||
$gauge = $lava->DataTable();
|
||||
$gauge->addStringColumn('Fuel')
|
||||
->addNumberColumn('Units');
|
||||
|
||||
//Get all of the jump gates
|
||||
$gates = $sHelper->GetStructuresByType('Ansiblex Jump Gate');
|
||||
|
||||
foreach($gates as $gate) {
|
||||
$liquidOzone = $aHelper->GetAssetByType(16273, $gate->structure_id);
|
||||
$temp = [
|
||||
'name' => $gate->structure_name,
|
||||
'system' => $gate->solar_system_name,
|
||||
'fuel_expires' => $gate->fuel_expires,
|
||||
'liquid_ozone' => $liquidOzone,
|
||||
'link' => '/logistics/fuel/display/' . $gate->structure_id . '/',
|
||||
];
|
||||
|
||||
array_push($jumpGates, $temp);
|
||||
|
||||
if($liquidOzone > 1000000) {
|
||||
$liquidOzone = 1000000;
|
||||
}
|
||||
|
||||
$gauge->addRow([$gate->solar_system_name, $liquidOzone]);
|
||||
}
|
||||
|
||||
$lava->GaugeChart('Liquid Ozone', $gauge, [
|
||||
'min' => 0,
|
||||
'max' => 1000000,
|
||||
'greenFrom' => 0,
|
||||
'greenTo' => 150000,
|
||||
'greenColor' => '#DC3912',
|
||||
'yellowFrom' => 150000,
|
||||
'yellowTo' => 300000,
|
||||
'yellowColor' => '#FF9900',
|
||||
'redFrom' => 300000,
|
||||
'redTo' => 1000000,
|
||||
'redColor' => '#109618',
|
||||
'majorTicks' => [
|
||||
'Empty',
|
||||
'Full',
|
||||
],
|
||||
]);
|
||||
|
||||
return view('logistics.display.fuel')->with('jumpGates', $jumpGates)
|
||||
->with('lava', $lava);
|
||||
}
|
||||
|
||||
}
|
||||
154
app/Http/Controllers/Logistics/LogisticsController.php
Normal file
154
app/Http/Controllers/Logistics/LogisticsController.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?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,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Logistics;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Log;
|
||||
|
||||
//Library Helpers
|
||||
use App\Library\Lookups\NewLookupHelper;
|
||||
|
||||
|
||||
//Models
|
||||
use App\Models\Logistics\AnchorStructure;
|
||||
|
||||
class StructureRequestController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function displayForm() {
|
||||
return view('structurerequest.requeststructure');
|
||||
}
|
||||
|
||||
public function storeForm() {
|
||||
$this->validate($request, [
|
||||
'corporation_name' => 'required',
|
||||
'system' => 'required',
|
||||
'structure_size' => 'required',
|
||||
'structure_type' => 'required',
|
||||
'requested_drop_time' => 'required',
|
||||
'requester' => 'required',
|
||||
]);
|
||||
|
||||
$lookup = new NewLookupHelper;
|
||||
|
||||
$requesterId = $lookup->CharacterNameToId($request->requester);
|
||||
$corporationId = $lookup->CorporationNameToId($request->corporation_name);
|
||||
|
||||
AnchorStructure::insert([
|
||||
'corporation_id' => $corporationId,
|
||||
'corporation_name' => $request->corporation_name,
|
||||
'system' => $request->system,
|
||||
'structure_size' => $request->structure_size,
|
||||
'structure_type' => $request->structure_type,
|
||||
'requested_drop_time' => $request->requested_drop_time,
|
||||
'requester_id' => $requesterId,
|
||||
'requester' => $request->requester,
|
||||
]);
|
||||
|
||||
return redirect('/structures/display/requests');
|
||||
}
|
||||
|
||||
public function displayRequests() {
|
||||
$reqs = AnchorStructure::all();
|
||||
|
||||
return view('structurerequest.display.structurerequests')->with('reqs', $reqs);
|
||||
}
|
||||
|
||||
public function deleteRequest($request) {
|
||||
$this->validate($request, [
|
||||
'id' => 'required',
|
||||
]);
|
||||
|
||||
AnchorStructure::where([
|
||||
'id' => $request->id,
|
||||
])->delete();
|
||||
|
||||
return redirect('/structures/display/requests');
|
||||
}
|
||||
}
|
||||
85
app/Http/Controllers/Market/MarketController.php
Normal file
85
app/Http/Controllers/Market/MarketController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?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
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
55
app/Http/Controllers/Moons/MoonLedgerController.php
Normal file
55
app/Http/Controllers/Moons/MoonLedgerController.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Moons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Log;
|
||||
use DB;
|
||||
|
||||
//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;
|
||||
|
||||
//App Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Service;
|
||||
|
||||
class MoonLedgerController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:corp.lead');
|
||||
}
|
||||
|
||||
public function displaySelection() {
|
||||
//Declare variables
|
||||
$structures = array();
|
||||
|
||||
|
||||
|
||||
return view('moons.ledger.displayselect')->with('structures', $structures);
|
||||
}
|
||||
|
||||
public function displayLedger(Request $request) {
|
||||
//Validate the request
|
||||
$this->validate($request, [
|
||||
'id' => 'required',
|
||||
]);
|
||||
|
||||
//Declare variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Create the authentication container for ESI, and check for the correct scopes
|
||||
$config = config('esi');
|
||||
}
|
||||
}
|
||||
@@ -21,229 +21,98 @@ use App\Models\MoonRent\MoonRental;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Lookups\NewLookupHelper;
|
||||
|
||||
class MoonsAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
public function showJournalEntries() {
|
||||
$dateInit = Carbon::now();
|
||||
$date = $dateInit->subDays(30);
|
||||
/**
|
||||
* Function to display the moons to logistics personnel
|
||||
*/
|
||||
public function displayMoonsLogistics() {
|
||||
$this->middleware('permissions:logistics.manager');
|
||||
|
||||
$journal = DB::select('SELECT amount,reason,description,date FROM `player_donation_journal` WHERE corporation_id=98287666 AND date >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) ORDER BY date DESC');
|
||||
|
||||
return view('moons.admin.moonjournal')->with('journal', $journal);
|
||||
}
|
||||
|
||||
public function updateMoon() {
|
||||
//Return the view and the form from the blade display
|
||||
return view('moons.admin.updatemoon');
|
||||
}
|
||||
|
||||
public function storeUpdateMoonRental(Request $request) {
|
||||
$moonCalc = new MoonCalc;
|
||||
$lookup = new LookupHelper;
|
||||
$rentalEnd = '';
|
||||
$ticker = '';
|
||||
|
||||
$this->validate($request, [
|
||||
'system' => 'required',
|
||||
'planet' => 'required',
|
||||
'moon' => 'required',
|
||||
'renter' => 'required',
|
||||
'date' => 'required',
|
||||
'contact' => 'required',
|
||||
]);
|
||||
|
||||
//Take the contact name and create a character_id from it
|
||||
if($request->contact == 'None') {
|
||||
$contact = 'None';
|
||||
} else {
|
||||
$contact = $lookup->CharacterNameToId($request->contact);
|
||||
}
|
||||
|
||||
if(isset($request->Paid_Until)) {
|
||||
$paidUntil = $request->Paid_Until;
|
||||
} else {
|
||||
$paidUntil = null;
|
||||
}
|
||||
|
||||
//Let's find the corporation and alliance information to ascertain whethery they are in Warped Intentions or another Legacy Alliance
|
||||
$allianceId = $lookup->LookupCorporation($lookup->LookupCharacter($contact));
|
||||
|
||||
//Create the date
|
||||
$date = new Carbon($request->date . '00:00:01');
|
||||
|
||||
$found = MoonRental::where([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'Contact' => $contact,
|
||||
])->first();
|
||||
|
||||
//If the entry is found, we are most likely just updating an entry to include new paid until data
|
||||
if($found) {
|
||||
if($allianceId = 99004116) {
|
||||
MoonRental::where([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'Contact' => $contact,
|
||||
])->update([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['alliance'],
|
||||
'Type' => 'alliance',
|
||||
'Paid' => $paid,
|
||||
'Paid_Until' => $request->paid_until,
|
||||
]);
|
||||
} else {
|
||||
MoonRental::where([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'Contact' => $contact,
|
||||
])->update([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['outofalliance'],
|
||||
'Type' => 'alliance',
|
||||
'Paid' => $paid,
|
||||
'Paid_Until' => $request->paid_until,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
//If the entry is not found, then attempt to delete whatever existing data is there, then
|
||||
//insert the new data
|
||||
MoonRental::where([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
])->delete();
|
||||
|
||||
if($allianceId = 99004116) {
|
||||
MoonRental::insert([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['alliance'],
|
||||
'Type' => 'alliance',
|
||||
'Paid' => 'No',
|
||||
]);
|
||||
} else {
|
||||
MoonRental::insert([
|
||||
'System' =>$request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['outofalliance'],
|
||||
'Type' => 'outofalliance',
|
||||
'Paid' => 'No',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//Redirect to the update moon page
|
||||
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Updated');
|
||||
}
|
||||
|
||||
public function storeUpdateMoon(Request $request) {
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
$lookup = new LookupHelper();
|
||||
//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();
|
||||
|
||||
$this->validate($request, [
|
||||
'system' => 'required',
|
||||
'planet' => 'required',
|
||||
'moon' => 'required',
|
||||
'renter' => 'required',
|
||||
'date' => 'required',
|
||||
'contact' => 'required',
|
||||
'paid' => 'required',
|
||||
]);
|
||||
foreach($moons as $moon) {
|
||||
//Get the rental data for the moon
|
||||
$count = MoonRental::where([
|
||||
'System' => $moon->System,
|
||||
'Planet' => $moon->Planet,
|
||||
'Moon' => $moon->Moon,
|
||||
])->count();
|
||||
|
||||
//Take the contact name and create a character id from it
|
||||
if($request->contact == 'None') {
|
||||
$contact = 'None';
|
||||
} else {
|
||||
$contact = $lookup->CharacterNameToId($request->contact);
|
||||
}
|
||||
//Let's find the corporation and alliance information to ascertain whether they are in Warped Intentions or another Legacy Alliance
|
||||
$corpId = $lookup->LookupCharacter($contact);
|
||||
$allianceId = $lookup->LookupCorporation($corpId);
|
||||
//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';
|
||||
|
||||
//Create the date
|
||||
$date = new Carbon($request->date . '00:00:01');
|
||||
//Calculate the moon price
|
||||
$moon = Moon::where([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
])->first();
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
$date = new Carbon($request->date . '00:00:01');
|
||||
//Update the database entry
|
||||
Moon::where([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
])->update([
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
]);
|
||||
//If we don't find a rental record, set the rental date as last month
|
||||
$rentalTemp = $lastMonth;
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Going to store moon price in a table for future reference
|
||||
//We need to insert a price based on whether part of Legacy or part of Warped Intentions
|
||||
//Will need an if then else statement to complete this operation
|
||||
if($allianceId = 99004116) {
|
||||
MoonRental::insert([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['alliance'],
|
||||
'Type' => 'alliance',
|
||||
'Paid' => $request->paid,
|
||||
]);
|
||||
} else {
|
||||
MoonRental::insert([
|
||||
'System' =>$request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
'RentalCorp' => $request->renter,
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['outofalliance'],
|
||||
'Type' => 'outofalliance',
|
||||
'Paid' => $request->paid,
|
||||
//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 redirect('/moons/admin/updatemoon')->with('success', 'Moon Updated');
|
||||
|
||||
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 = '';
|
||||
@@ -252,27 +121,29 @@ class MoonsAdminController extends Controller
|
||||
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
//Update the prices for the moon
|
||||
$moonCalc->FetchNewPrices();
|
||||
//get all of the moons from the database
|
||||
//Get all of the moons from the database
|
||||
$moons = Moon::orderBy('System', 'asc')->get();
|
||||
//declare the html variable and set it to null
|
||||
//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
|
||||
$rental = MoonRental::where([
|
||||
$count = MoonRental::where([
|
||||
'System' => $moon->System,
|
||||
'Planet' => $moon->Planet,
|
||||
'Moon' => $moon->Moon,
|
||||
])->first();
|
||||
])->count();
|
||||
|
||||
//Check if their is a current rental for a moon going on
|
||||
if($rental == false) {
|
||||
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 = Carbon::now()->subMonth();
|
||||
$rentalTemp = $lastMonth;
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Set the contact info
|
||||
@@ -281,8 +152,19 @@ class MoonsAdminController extends Controller
|
||||
//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;
|
||||
|
||||
@@ -291,20 +173,19 @@ class MoonsAdminController extends Controller
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Set the contact name
|
||||
$contact = $lookup->CharacterName($rental->Contact);
|
||||
//$contact = $lookup->CharacterName($rental->Contact);
|
||||
$contact = $lookupHelper->CharacterIdToName($rental->Contact);
|
||||
|
||||
//Set up the renter whether it's W4RP or another corporation
|
||||
$corpId = $lookup->LookupCorporationId($rental->Contact);
|
||||
$allianceId = $lookup->LookupCorporation($corpId);
|
||||
$ticker = $lookup->LookupAllianceTicker($allianceId);
|
||||
$ticker = $rental->RentalCorp;
|
||||
$type = $rental->Type;
|
||||
}
|
||||
|
||||
//Set the color for the table
|
||||
$today = Carbon::now();
|
||||
if($rentalTemp->diffInDays($today) < 3 ) {
|
||||
$color = 'table-warning';
|
||||
} else if( $today > $rentalTemp) {
|
||||
$color = 'table-primary';
|
||||
$color = 'table-success';
|
||||
} else {
|
||||
$color = 'table-danger';
|
||||
}
|
||||
@@ -322,6 +203,7 @@ class MoonsAdminController extends Controller
|
||||
'RowColor' => $color,
|
||||
'Paid' => $paid,
|
||||
'Contact' => $contact,
|
||||
'Type' => $type,
|
||||
'Renter' => $ticker,
|
||||
]);
|
||||
}
|
||||
@@ -329,92 +211,243 @@ class MoonsAdminController extends Controller
|
||||
return view('moons.admin.adminmoon')->with('table', $table);
|
||||
}
|
||||
|
||||
public function UpdateMoonPaid(Request $request) {
|
||||
/**
|
||||
* Function to remove a renter from a moon
|
||||
*/
|
||||
public function storeMoonRemoval(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$this->validate($request, [
|
||||
'paid' => 'required',
|
||||
'remove' => 'required',
|
||||
]);
|
||||
|
||||
$str_array = explode(" - ", $request->paid);
|
||||
$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];
|
||||
|
||||
//Update the paid status of the moon
|
||||
MoonRental::where([
|
||||
$found = MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $moon,
|
||||
])->update([
|
||||
'Paid' => 'Yes',
|
||||
]);
|
||||
])->count();
|
||||
|
||||
if($found != 0) {
|
||||
MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $moon,
|
||||
])->delete();
|
||||
|
||||
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');
|
||||
return redirect('/moons/admin/display')->with('error', 'Something went wrong.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display function for adding a new rental moon to the pool
|
||||
*
|
||||
* Function displays the ability for admins to update moons with who is renting, and when it ends.
|
||||
*/
|
||||
public function addMoon() {
|
||||
return view('moons.admin.addmoon');
|
||||
public function updateMoon() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare some variables
|
||||
$system = null;
|
||||
$planet = null;
|
||||
$moon = null;
|
||||
$name = null;
|
||||
$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();
|
||||
|
||||
//Push our default value onto the stack
|
||||
array_push($spmn, 'N/A');
|
||||
|
||||
//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;
|
||||
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
|
||||
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
|
||||
return view('moons.admin.updatemoon')->with('spmn', $spmn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new moon into the database
|
||||
*
|
||||
* @return \Illuminate\Http\Reponse
|
||||
*/
|
||||
public function storeMoon(Request $request) {
|
||||
public function storeUpdateMoon(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare some static variables as needed
|
||||
$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, [
|
||||
'region' => 'required',
|
||||
'system' => 'required',
|
||||
'structure' => 'required',
|
||||
'spmn' => 'required',
|
||||
'renter' => 'required',
|
||||
'date' => 'required',
|
||||
'contact' => 'required',
|
||||
]);
|
||||
|
||||
if($request->input('firstquan') < 1.00) {
|
||||
$firstQuan = $request->input('firstquan') * 100.00;
|
||||
//Decode the System, Planet, Moon, Name combinatio sent from the controller
|
||||
$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 {
|
||||
$firstQuan = $request->input('firstquan');
|
||||
$contact = $lookup->CharacterNameToId($request->contact);
|
||||
}
|
||||
|
||||
if($request->input('secondquan') < 1.00) {
|
||||
$firstQuan = $request->input('secondquan') * 100.00;
|
||||
//Update the paid value for database entry
|
||||
if($request->paid == 'Yes') {
|
||||
$paid = 'Yes';
|
||||
} else {
|
||||
$firstQuan = $request->input('secondquan');
|
||||
$paid = 'No';
|
||||
}
|
||||
|
||||
if($request->input('thirdquan') < 1.00) {
|
||||
$firstQuan = $request->input('thirdquan') * 100.00;
|
||||
//Update the paid unti value for the database entry
|
||||
if(isset($request->Paid_Until)) {
|
||||
$paidUntil = $request->Paid_Until;
|
||||
} else {
|
||||
$firstQuan = $request->input('thirdquan');
|
||||
$paidUntil = null;
|
||||
}
|
||||
|
||||
if($request->input('fourthquan') < 1.00) {
|
||||
$firstQuan = $request->input('fourthquan') * 100.00;
|
||||
//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 {
|
||||
$firstQuan = $request->input('fourthquan');
|
||||
//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();
|
||||
}
|
||||
}
|
||||
|
||||
// Add new moon
|
||||
$moon = new Moon;
|
||||
$moon->Region = $request->input('region');
|
||||
$moon->System = $request->input('system');
|
||||
$moon->Planet = $request->input('planet');
|
||||
$moon->Moon = $request->input('moon');
|
||||
$moon->StructureName = $request->input('structure');
|
||||
$moon->FirstOre = $request->input('firstore');
|
||||
$moon->FirstQuantity = $request->input('firstquan');
|
||||
$moon->SecondOre = $request->input('secondore');
|
||||
$moon->SecondQuantity = $request->input('secondquan');
|
||||
$moon->ThirdOre = $request->input('thirdore');
|
||||
$moon->ThirdQuantity = $request->input('thirdquan');
|
||||
$moon->FourthOre = $request->input('fourthore');
|
||||
$moon->FourthQuantity = $request->input('fourthquan');
|
||||
$moon->save();
|
||||
//Redirect to the update moon page
|
||||
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Updated');
|
||||
}
|
||||
|
||||
return redirect('/dashboard')->with('success', 'Moon Added');
|
||||
public function showJournalEntries() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$dateInit = Carbon::now();
|
||||
$date = $dateInit->subDays(30);
|
||||
|
||||
$journal = DB::select('SELECT amount,reason,description,date FROM `player_donation_journal` WHERE corporation_id=98287666 AND date >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) ORDER BY date DESC');
|
||||
|
||||
return view('moons.admin.moonjournal')->with('journal', $journal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,13 @@ class MoonsController extends Controller
|
||||
$type = Auth::user()->user_type;
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
//Update the prices for the moon
|
||||
$moonCalc->FetchNewPrices();
|
||||
//get all of the moons from the database
|
||||
$moons = DB::table('Moons')->orderBy('System', 'asc')->get();
|
||||
//Set the rental date as last month for moons not rented
|
||||
$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();
|
||||
@@ -55,7 +58,7 @@ class MoonsController extends Controller
|
||||
|
||||
if($rental == false) {
|
||||
//If we don't find a rental record, set the rental date as last month
|
||||
$rentalTemp = Carbon::now()->subMonth();
|
||||
$rentalTemp = $lastMonth;
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
} else {
|
||||
//Set the rental date up
|
||||
@@ -63,9 +66,6 @@ class MoonsController extends Controller
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
}
|
||||
|
||||
//mark today's date in carbon format
|
||||
$today = Carbon::now();
|
||||
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
@@ -124,8 +124,6 @@ class MoonsController extends Controller
|
||||
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
//Update the prices for the moon
|
||||
$moonCalc->FetchNewPrices();
|
||||
|
||||
$totalGoo = $moonCalc->SpatialMoonsOnlyGooTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
||||
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
|
||||
|
||||
481
app/Http/Controllers/SRP/SRPAdminController.php
Normal file
481
app/Http/Controllers/SRP/SRPAdminController.php
Normal file
@@ -0,0 +1,481 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
|
||||
//User Libraries
|
||||
use App\Library\SRP\SRPHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\SRP\SRPShip;
|
||||
use App\Models\User\User;
|
||||
use App\Models\SRP\SrpFleetType;
|
||||
use App\Models\SRP\SrpShipType;
|
||||
use App\Models\SRP\SrpPayout;
|
||||
|
||||
class SRPAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:srp.admin');
|
||||
}
|
||||
|
||||
public function displaySRPRequests() {
|
||||
//Middleware needed for permissions
|
||||
$this->middleware('permission:srp.admin');
|
||||
|
||||
//Create the array
|
||||
$requests = array();
|
||||
|
||||
//Declare variables for use later.
|
||||
$sum_actual = 0.00;
|
||||
$sum_loss = 0.00;
|
||||
|
||||
//Get the ship types from the database
|
||||
$shipTypes = SrpShipType::all();
|
||||
|
||||
//Get the fleet types from the database
|
||||
$fleetTypes = SrpFleetType::all();
|
||||
|
||||
//Get the payouts from the database
|
||||
$payouts = SrpPayout::all();
|
||||
|
||||
//Get the SRP ship count to see how many requests are avaiable "Under Review" in the database
|
||||
$count = SRPShip::where(['approved' => 'Under Review'])->count();
|
||||
//If the count is 0 then there are no requests
|
||||
if($count === 0) {
|
||||
$requests = null;
|
||||
} else { //Process each request
|
||||
$reqs = SRPShip::where(['approved' => 'Under Review'])->get()->toArray();
|
||||
foreach($reqs as $r) {
|
||||
$temp['id'] = $r['id'];
|
||||
$temp['created_at'] = $r['created_at'];
|
||||
$temp['character_name'] = $r['character_name'];
|
||||
$temp['fleet_commander_name'] = $r['fleet_commander_name'];
|
||||
$temp['zkillboard'] = $r['zkillboard'];
|
||||
$temp['loss_value'] = $r['loss_value'];
|
||||
$sum_loss += $temp['loss_value'];
|
||||
//Get the ship type
|
||||
foreach($shipTypes as $s) {
|
||||
if($r['ship_type'] == $s->code) {
|
||||
$temp['ship_type'] = $s->description;
|
||||
}
|
||||
}
|
||||
//Get the fleet type
|
||||
foreach($fleetTypes as $f) {
|
||||
if($r['fleet_type'] == $f->code) {
|
||||
$temp['fleet_type'] = $f->description;
|
||||
}
|
||||
}
|
||||
//Calculate the recommended srp amount
|
||||
foreach($payouts as $p) {
|
||||
if($r['ship_type'] == $p->code) {
|
||||
$temp['actual_srp'] = $r['loss_value'] * ($p->payout / 100.00 );
|
||||
$temp['cost_code'] = $p->payout;
|
||||
$sum_actual += $temp['actual_srp'];
|
||||
}
|
||||
}
|
||||
|
||||
//Push the calculations into the array
|
||||
array_push($requests, $temp);
|
||||
}
|
||||
}
|
||||
|
||||
$sum_actual = number_format($sum_actual, 2, '.', ',');
|
||||
$sum_loss = number_format($sum_loss, 2, '.', ',');
|
||||
|
||||
//Return the view with the variables
|
||||
return view('srp.admin.process')->with('requests', $requests)
|
||||
->with('sum_actual', $sum_actual)
|
||||
->with('sum_loss', $sum_loss);
|
||||
}
|
||||
|
||||
public function processSRPRequest(Request $request) {
|
||||
//Validate the request
|
||||
$this->validate($request, [
|
||||
'id' => 'required',
|
||||
'approved' => 'required',
|
||||
'paid_value' => 'required',
|
||||
]);
|
||||
//Get the paid value from the form
|
||||
$paidValue = str_replace(',', '', $request->paid_value);
|
||||
//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,
|
||||
]);
|
||||
} 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,
|
||||
]);
|
||||
}
|
||||
|
||||
if($request->approved == 'Approved') {
|
||||
return redirect('/srp/admin/display')->with('success', 'SRP Marked as Paid');
|
||||
} else {
|
||||
return redirect('/srp/admin/display')->with('error', 'SRP Request Denied.');
|
||||
}
|
||||
}
|
||||
|
||||
public function displayStatistics() {
|
||||
$months = 3;
|
||||
$barChartData = array();
|
||||
$start = Carbon::now()->toDateTimeString();
|
||||
$end = Carbon::now()->subMonths(1)->toDateTimeString();
|
||||
|
||||
//Declare the Lavacharts variable
|
||||
$lava = new Lavacharts;
|
||||
|
||||
//We need a function from this library rather than recreating a new library
|
||||
$srpHelper = new SRPHelper();
|
||||
|
||||
/**
|
||||
* Pie chart for the number of approved, denied, and under review payouts currently in the system.
|
||||
*/
|
||||
//Get the count of open srp requests
|
||||
$pieOpen = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
['created_at', '>=', $end],
|
||||
])->count();
|
||||
//Get the count of approved srp requests
|
||||
$pieApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
['created_at', '>=', $end],
|
||||
])->count();
|
||||
//Get the count of denied srp requests
|
||||
$pieDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
['created_at', '>=', $end],
|
||||
])->count();
|
||||
|
||||
//Create a new datatable for the lavachart.
|
||||
$srp = $lava->DataTable();
|
||||
//Add string columns, number columns, and data rows for the chart
|
||||
$srp->addStringColumn('ISK Value')
|
||||
->addNumberColumn('ISK')
|
||||
->addRow(['Approved', $pieApproved])
|
||||
->addRow(['Denied', $pieDenied])
|
||||
->addRow(['Under Review', $pieOpen]);
|
||||
//Create the pie chart in memory with any options needed to render the chart
|
||||
$lava->PieChart('SRP Stats', $srp, [
|
||||
'title' => 'SRP Stats',
|
||||
'is3D' => true,
|
||||
]);
|
||||
|
||||
/**
|
||||
* Gauage chart for showing number of open srp requests
|
||||
*/
|
||||
//Create a new datatable in the
|
||||
$adur = $lava->DataTable();
|
||||
//Add string columns, number columns, and data row for the chart
|
||||
$adur->addStringColumn('Type')
|
||||
->addNumberColumn('Value')
|
||||
->addRow(['Under Review', $pieOpen]);
|
||||
//Create the gauge chart with any options needed to render the chart
|
||||
$lava->GaugeChart('SRP', $adur, [
|
||||
'width' => 400,
|
||||
'greenFrom' => 0,
|
||||
'greenTo' => 20,
|
||||
'yellowFrom' => 20,
|
||||
'yellowTo' => 40,
|
||||
'redFrom' => 40,
|
||||
'redTo' => 100,
|
||||
'majorTicks' => [
|
||||
'Safe',
|
||||
'Critical',
|
||||
],
|
||||
]);
|
||||
|
||||
/**
|
||||
* Create a vertical chart of all of the cost codes for the ships being SRP'ed.
|
||||
* The chart will be by cost code of ships being replaced
|
||||
*/
|
||||
//Declare the data table
|
||||
$costCodeChart = $lava->DataTable();
|
||||
|
||||
//Get the approved, under review, and denied cost codes and amounts
|
||||
$t1fdcApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1FDC',
|
||||
])->sum('paid_value');
|
||||
$t1fdcUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1FDC',
|
||||
])->sum('loss_value');
|
||||
$t1fdcDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1FDC',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t1bcApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1BC',
|
||||
])->sum('paid_value');
|
||||
$t1bcUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1BC',
|
||||
])->sum('loss_value');
|
||||
$t1bcDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1BC',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t2fdApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T2FD',
|
||||
])->sum('paid_value');
|
||||
$t2fdUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T2FD',
|
||||
])->sum('loss_value');
|
||||
$t2fdDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T2FD',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t3dApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T3D',
|
||||
])->sum('paid_value');
|
||||
$t3dUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T3D',
|
||||
])->sum('loss_value');
|
||||
$t3dDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T3D',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t1t2logiApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1T2Logi',
|
||||
])->sum('paid_value');
|
||||
$t1t2logiUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1T2Logi',
|
||||
])->sum('loss_value');
|
||||
$t1t2logiDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1T2Logi',
|
||||
])->sum('loss_value');
|
||||
|
||||
$reconsApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'REC',
|
||||
])->sum('paid_value');
|
||||
$reconsUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'REC',
|
||||
])->sum('loss_value');
|
||||
$reconsDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'REC',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t2cApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T2C',
|
||||
])->sum('paid_value');
|
||||
$t2cUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T2C',
|
||||
])->sum('loss_value');
|
||||
$t2cDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T2C',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t3cApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T3C',
|
||||
])->sum('paid_value');
|
||||
$t3cUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T3C',
|
||||
])->sum('loss_value');
|
||||
$t3cDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T3C',
|
||||
])->sum('loss_value');
|
||||
|
||||
$commandApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'COM',
|
||||
])->sum('paid_value');
|
||||
$commandUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'COM',
|
||||
])->sum('loss_value');
|
||||
$commandDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'COM',
|
||||
])->sum('loss_value');
|
||||
|
||||
$interdictorApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'INTD',
|
||||
])->sum('paid_value');
|
||||
$interdictorUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'INTD',
|
||||
])->sum('loss_value');
|
||||
$interdictorDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'INTD',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t1bsApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1BS',
|
||||
])->sum('paid_value');
|
||||
$t1bsUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1BS',
|
||||
])->sum('loss_value');
|
||||
$t1bsDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1BS',
|
||||
])->sum('loss_value');
|
||||
|
||||
$dksApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'DKS',
|
||||
])->sum('paid_value');
|
||||
$dksUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'DKS',
|
||||
])->sum('loss_value');
|
||||
$dksDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'DKS',
|
||||
])->sum('loss_value');
|
||||
|
||||
|
||||
//Add string column, number columns.
|
||||
$costCodeChart->addStringColumn('SRP Costs')
|
||||
->addNumberColumn('Approved')
|
||||
->addNumberColumn('Under Review')
|
||||
->addNumberColumn('Denied')
|
||||
->addRow(['T1FDC', $t1fdcApproved, $t1fdcUnderReview, $t1fdcDenied])
|
||||
->addRow(['T1BC', $t1bcApproved, $t1bcUnderReview, $t1bcDenied])
|
||||
->addRow(['T1BS', $t1bsApproved, $t1bsUnderReview, $t1bsDenied])
|
||||
->addRow(['T2FD', $t2fdApproved, $t2fdUnderReview, $t2fdDenied])
|
||||
->addRow(['T2C', $t2cApproved, $t2cUnderReview, $t2cDenied])
|
||||
->addRow(['T1T2Logi', $t1t2logiApproved, $t1t2logiUnderReview, $t1t2logiDenied])
|
||||
->addRow(['T3D', $t3dApproved, $t3dUnderReview, $t3dDenied])
|
||||
->addRow(['T3C', $t3cApproved, $t3cUnderReview, $t3cDenied])
|
||||
->addRow(['RECON', $reconsApproved, $reconsUnderReview, $reconsDenied])
|
||||
->addRow(['COMMAND', $commandApproved, $commandUnderReview, $commandDenied])
|
||||
->addRow(['DKS', $dksApproved, $dksUnderReview, $dksDenied]);
|
||||
|
||||
$lava->ColumnChart('Cost Codes', $costCodeChart, [
|
||||
'columns' => 4,
|
||||
'title' => 'Cost Code SRP Chart',
|
||||
'titleTextStyle' => [
|
||||
'color' => '#eb6b2c',
|
||||
'fontSize' => 14,
|
||||
],
|
||||
]);
|
||||
|
||||
return view('srp.admin.statistics')->with('lava', $lava);
|
||||
}
|
||||
|
||||
public function displayCostCodes() {
|
||||
//Declare some variables
|
||||
$costcodes = array();
|
||||
$count = 0;
|
||||
$shipType = SrpShipType::all();
|
||||
$srpPayout = SrpPayout::all();
|
||||
|
||||
foreach($shipType as $ship) {
|
||||
//Don't process if the code is None
|
||||
if($ship->code != 'None') {
|
||||
$tempCode = $ship->code;
|
||||
$tempDescription = $ship->description;
|
||||
$temp = SrpPayout::where(['code' => $ship->code])->first();
|
||||
$tempPayout = $temp->payout;
|
||||
//Store the data in a temporary variable
|
||||
$block = [
|
||||
'code' => $tempCode,
|
||||
'description' => $tempDescription,
|
||||
'payout' => $tempPayout,
|
||||
];
|
||||
|
||||
//Push the data into the array
|
||||
array_push($costcodes, $block);
|
||||
}
|
||||
}
|
||||
|
||||
return view('srp.admin.costcodes.display')->with('costcodes', $costcodes);
|
||||
}
|
||||
|
||||
public function displayAddCostCode() {
|
||||
return view('srp.admin.costcodes.add');
|
||||
}
|
||||
|
||||
public function addCostCode(Request $request) {
|
||||
$this->validate($request, [
|
||||
'code' => 'required',
|
||||
'description' => 'required',
|
||||
'payout' => 'required',
|
||||
]);
|
||||
|
||||
$code = $request->code;
|
||||
$description = $request->description;
|
||||
$payout = $request->payout;
|
||||
|
||||
$payoutCount = SrpPayout::where(['code' => $code])->count();
|
||||
$shipTypeCount = SrpShipType::where(['code' => $code])->count();
|
||||
|
||||
//If we don't find the cost code, let's add it. otherwise send an error.
|
||||
if($payoutCount == 0 && $shipTypeCount == 0) {
|
||||
$payoutTable = new SrpPayout;
|
||||
$payoutTable->code = $code;
|
||||
$payoutTable->payout = $payout;
|
||||
$payoutTable->save();
|
||||
|
||||
$shipType = new SrpShipType;
|
||||
$shipType->code = $code;
|
||||
$shipType->description = $description;
|
||||
$shipType->save();
|
||||
|
||||
return redirect('/srp/admin/display')->with('success', 'Cost code added.');
|
||||
} else {
|
||||
return redirect('/srp/admin/display')->with('error', 'Cost code already exists in the database.');
|
||||
}
|
||||
}
|
||||
|
||||
public function modifyCostCodes(Request $request) {
|
||||
$this->validate($request, [
|
||||
'description' => 'required',
|
||||
'payout' => 'required',
|
||||
]);
|
||||
|
||||
//Update the SrpShipType
|
||||
SrpShipType::where(['code' => $request->code])->update([
|
||||
'description' => $request->description,
|
||||
]);
|
||||
|
||||
//Update the payout
|
||||
SrpPayout::where(['code' => $request->code])->update([
|
||||
'payout' => $request->payout,
|
||||
]);
|
||||
|
||||
return redirect('/srp/admin/display')->with('success', 'Payout and Description updated.');
|
||||
}
|
||||
}
|
||||
152
app/Http/Controllers/SRP/SRPController.php
Normal file
152
app/Http/Controllers/SRP/SRPController.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SRP;
|
||||
|
||||
//Laravel Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Auth;
|
||||
|
||||
//User Libraries
|
||||
|
||||
//Models
|
||||
use App\Models\SRP\SRPShip;
|
||||
use App\Models\User\User;
|
||||
use App\Models\SRP\SrpFleetType;
|
||||
use App\Models\SRP\SrpShipType;
|
||||
use App\Models\User\UserAlt;
|
||||
use App\Models\SRP\SrpPayout;
|
||||
|
||||
class SRPController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function displayPayoutAmounts() {
|
||||
$payouts = array();
|
||||
$count = 0;
|
||||
$shipType = SrpShipType::all();
|
||||
$srpPayout = SrpPayout::all();
|
||||
|
||||
foreach($shipType as $ship) {
|
||||
//Don't process if the code is None
|
||||
if($ship->code != 'None') {
|
||||
$tempCode = $ship->code;
|
||||
$tempDescription = $ship->description;
|
||||
$temp = SrpPayout::where(['code' => $ship->code])->first();
|
||||
|
||||
$tempPayout = $temp->payout;
|
||||
|
||||
$block = [
|
||||
'code' => $tempCode,
|
||||
'description' => $tempDescription,
|
||||
'payout' => $tempPayout,
|
||||
];
|
||||
|
||||
array_push($payouts, $block);
|
||||
}
|
||||
}
|
||||
|
||||
return view('srp.payouts')->with('payouts', $payouts);
|
||||
}
|
||||
|
||||
public function displaySrpForm() {
|
||||
$shipTypes = array();
|
||||
$fleetTypes = array();
|
||||
$characters = array();
|
||||
$temp = array();
|
||||
$alts = null;
|
||||
|
||||
//Get all the ship types
|
||||
$shipTypesTemp = SrpShipType::all();
|
||||
|
||||
//Get all of the fleet types
|
||||
$fleetTypesTemp = SrpFleetType::all();
|
||||
|
||||
//Process the ship types and store in the array
|
||||
foreach($shipTypesTemp as $type) {
|
||||
$shipTypes[$type->code] = $type->description;
|
||||
}
|
||||
|
||||
//Process the fleet types and store in the array
|
||||
foreach($fleetTypesTemp as $type) {
|
||||
$fleetTypes[$type->code] = $type->description;
|
||||
}
|
||||
|
||||
//Get the user id and name, and store in the array
|
||||
$characters[auth()->user()->character_id] = auth()->user()->getName();
|
||||
|
||||
//Get the alts and store in the array
|
||||
$altCount = UserAlt::where(['main_id' => auth()->user()->character_id])->count();
|
||||
if($altCount > 0) {
|
||||
$alts = UserAlt::where([
|
||||
'main_id' => auth()->user()->character_id,
|
||||
])->get();
|
||||
|
||||
foreach($alts as $alt) {
|
||||
$characters[$alt->character_id] = $alt->name;
|
||||
}
|
||||
}
|
||||
|
||||
return view('srp.srpform')->with('fleetTypes', $fleetTypes)
|
||||
->with('shipTypes', $shipTypes)
|
||||
->with('characters', $characters);
|
||||
}
|
||||
|
||||
public function storeSRPFile(Request $request) {
|
||||
$name = null;
|
||||
|
||||
$this->validate($request, [
|
||||
'character' => 'required',
|
||||
'FC' => 'required',
|
||||
'FleetType' => 'required',
|
||||
'zKillboard' => 'required',
|
||||
'LossValue' => 'required',
|
||||
'ShipType' => 'required',
|
||||
]);
|
||||
|
||||
//See if the FC Name ties to a user on the services site
|
||||
$fcId = User::where(['name' => $request->FC])->get(['character_id']);
|
||||
|
||||
//Take the loss value and remove ' ISK' from it. Convert the string to a number
|
||||
$lossValue = str_replace(' ISK', '', $request->LossValue);
|
||||
$lossValue = str_replace(',', '', $lossValue);
|
||||
$lossValue = floatval($lossValue);
|
||||
|
||||
//Convert the FC name to a regular case of characters
|
||||
$tempFcName = strtolower($request->FC);
|
||||
$tempFcName = ucwords($tempFcName);
|
||||
|
||||
$userCount = User::where(['character_id' => $request->character])->count();
|
||||
$altCount = UserAlt::where(['character_id' => $request->character])->count();
|
||||
|
||||
if($userCount > 0) {
|
||||
$tempUser = User::where(['character_id' => $request->character])->first();
|
||||
$name = $tempUser->name;
|
||||
} else if($altCount > 0) {
|
||||
$tempAlt = UserAlt::where(['character_id' => $request->character])->first();
|
||||
$name = $tempAlt->name;
|
||||
} else {
|
||||
$name = 'None';
|
||||
}
|
||||
|
||||
$ship = new SRPShip;
|
||||
$ship->character_id = $request->character;
|
||||
$ship->character_name = $name;
|
||||
$ship->fleet_commander_name = $tempFcName;
|
||||
if(isset($fcId[0])) {
|
||||
$ship->fleet_commander_id = $fcId[0]->character_id;
|
||||
}
|
||||
$ship->zkillboard = $request->zKillboard;
|
||||
$ship->fleet_type = $request->FleetType;
|
||||
$ship->ship_type = $request->ShipType;
|
||||
$ship->loss_value = $lossValue;
|
||||
$ship->save();
|
||||
|
||||
return redirect('/dashboard')->with('success', 'SRP Form Submitted.');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Structures;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
use DB;
|
||||
|
||||
use App\Models\Corporation\CorpStructure;
|
||||
use App\Models\Corporation\CorpTaxRatio;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
class RegisterStructureController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:structure.operator');
|
||||
}
|
||||
|
||||
public function displayRegisterStructure() {
|
||||
//Check to see if the user has the read corp journal esi scope before allowing to register a structure
|
||||
if(Auth()->user()->hasEsiScope('esi-wallet.read_corporation_wallets.v1')) {
|
||||
return view('structures.register.register');
|
||||
} else {
|
||||
return view('dashboard')->with('error', 'You need to setup your esi scope for read corporation wallets');
|
||||
}
|
||||
}
|
||||
|
||||
public function storeStructure(Request $request) {
|
||||
$this->validate($request, [
|
||||
'system' => 'required',
|
||||
'structure_name' => 'required',
|
||||
'tax' => 'required',
|
||||
'structure_type' => 'required',
|
||||
]);
|
||||
|
||||
$eHelper = new Esi;
|
||||
|
||||
$tax = floatval($request->tax);
|
||||
|
||||
$structure = new CorpStructure();
|
||||
$structure->character_id = Auth::user()->character_id;
|
||||
$structure->corporation_id = $eHelper->FindCorporationId(Auth::user()->character_id);
|
||||
$structure->corporation_name = $eHelper->FindCorporationName(Auth::user()->character_id);
|
||||
$structure->region = $request->region;
|
||||
$structure->system = $request->system;
|
||||
$structure->structure_name = $request->structure_name;
|
||||
$structure->structure_type = $request->structure_type;
|
||||
$structure->save();
|
||||
|
||||
//Return the view and the message of user updated
|
||||
return redirect('/dashboard')->with('success', 'Structure Added to Database');
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Structures;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class StructureAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
public function displayDashboard() {
|
||||
return view('structures.admin.dashboard');
|
||||
}
|
||||
|
||||
public function storeTaxRatio(Request $request) {
|
||||
$this->validate($request, [
|
||||
'corpId',
|
||||
'corporation',
|
||||
'type',
|
||||
'ratio',
|
||||
]);
|
||||
|
||||
$ratio = new CorpTaxRatio;
|
||||
$ratio->corporation_id = $request->corpId;
|
||||
$ratio->corporation_name = $request->corporation;
|
||||
$ratio->structure_type = $request->type;
|
||||
$ratio->ratio = $request->ratio;
|
||||
$ratio->save();
|
||||
|
||||
return redirect('structure.admin.dashboard');
|
||||
}
|
||||
|
||||
public function updateTaxRatio(Request $request) {
|
||||
$this->validate($request, [
|
||||
'corporation',
|
||||
'type',
|
||||
'ratio',
|
||||
]);
|
||||
|
||||
CorpTaxRatio::where([
|
||||
'corporation_name' => $request->corporation,
|
||||
'structure_type' => $request->type,
|
||||
])->update([
|
||||
'ratio' => $request->ratio,
|
||||
]);
|
||||
|
||||
return redirect('/structure/admin/dashboard')->with('success', 'Tax Ratio updated for structure type: ' . $request->type . ' and corporation: ' . $request->corporation);
|
||||
}
|
||||
|
||||
public function displayTaxRatios() {
|
||||
$taxRatios = CorpTaxRation::all();
|
||||
|
||||
return view('structure.admin.taxratios')->with('structures', $structures);
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Structures;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Auth;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Library\Structures\StructureTaxHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
use App\User;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\Corporation\CorpStructure;
|
||||
use App\Models\Finances\StructureIndustryTaxJournal;
|
||||
use App\Models\Esi\EsiToken;
|
||||
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
class StructureController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:structure.operator');
|
||||
}
|
||||
|
||||
public function chooseCorpTaxes() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$corps = CorpStructure::pluck('corporation_name', 'corporation_id');
|
||||
return view('structures.admin.choosecorporation')->with('corps', $corps);
|
||||
}
|
||||
|
||||
public function displayCorpTaxes(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$corpId = $request->corpId;
|
||||
$months = 3;
|
||||
|
||||
//Declare the structure tax helper class
|
||||
$sHelper = new StructureTaxHelper();
|
||||
|
||||
//Get the dates we are working with
|
||||
$dates = $sHelper->GetTimeFrameInMonths($months);
|
||||
|
||||
foreach($dates as $date) {
|
||||
$totalTaxes[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'tax' => number_format($sHelper->GetTaxes($corpId, 'Market', $date['start'], $date['end']), 2, '.', ','),
|
||||
'revenue' => number_format($sHelper->GetRevenue($corpId, 'Market', $date['start'], $date['end']), 2, '.', ',')
|
||||
];
|
||||
}
|
||||
|
||||
//Return the view with the data passed to it
|
||||
return view('structures.admin.choosecorptaxes')->with('totalTaxes', $totalTaxes);
|
||||
}
|
||||
|
||||
public function displayTaxes() {
|
||||
//Declare new Lookup helper
|
||||
$helper = new LookupHelper();
|
||||
|
||||
//Declare the structure tax helper class
|
||||
$sHelper = new StructureTaxHelper();
|
||||
|
||||
$months = 3;
|
||||
$totalTaxes = array();
|
||||
|
||||
//Get the character's corporation from the lookup table or esi
|
||||
$corpId = $helper->LookupCharacter(Auth::user()->character_id);
|
||||
|
||||
|
||||
//Get the dates we are working with
|
||||
$dates = $sHelper->GetTimeFrameInMonths($months);
|
||||
|
||||
//Get the market taxes for this month from the database
|
||||
foreach($dates as $date) {
|
||||
$totalTaxes[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'tax' => number_format($sHelper->GetTaxes($corpId, 'Market', $date['start'], $date['end']), 2, '.', ','),
|
||||
'revenue' => number_format($sHelper->GetRevenue($corpId, 'Market', $date['start'], $date['end']), 2, '.', ',')
|
||||
];
|
||||
}
|
||||
|
||||
return view('structures.user.taxes')->with('totalTaxes', $totalTaxes);
|
||||
}
|
||||
|
||||
public function displayTaxHistory(Request $request) {
|
||||
//Declare new Lookup helper
|
||||
$helper = new LookupHelper();
|
||||
|
||||
//Get the months from the request
|
||||
$months = $request->months;
|
||||
|
||||
//Get the character's corporation from the lookup table or esi
|
||||
$corpId = $helper->LookupCharacter(Auth::user()->character_id);
|
||||
|
||||
//Declare the structure tax helper class
|
||||
$sHelper = new StructureTaxHelper();
|
||||
|
||||
//Get the dates we are working with
|
||||
$dates = $sHelper->GetTimeFrameInMonths($months);
|
||||
|
||||
//Build the array for displaying the data on the view
|
||||
$totalTaxes = array();
|
||||
|
||||
foreach($dates as $date) {
|
||||
$totalTaxes[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'tax' => number_format($sHelper->GetTaxes($corpId, 'Market', $date['start'], $date['end']), 2, '.', ','),
|
||||
'revenue' => number_format($sHelper->GetRevenue($corpId, 'Market', $date['start'], $date['end']), 2, '.', ',')
|
||||
];
|
||||
}
|
||||
|
||||
return view('structures.user.taxhistory')->with(compact('totalTaxes', 'months'));
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ use App\Models\Doku\DokuGroupNames;
|
||||
use App\Models\Doku\DokuMember;
|
||||
use App\Models\Doku\DokuUser;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
use App\Models\User\User;
|
||||
|
||||
class WikiController extends Controller
|
||||
{
|
||||
@@ -37,17 +38,27 @@ class WikiController extends Controller
|
||||
//Search the names and verify against the lookup table
|
||||
//to find the corporation and / or alliance they belong to.
|
||||
foreach($users as $user) {
|
||||
$charId = $helper->CharacterNameToId($user);
|
||||
$corpId = $helper->LookupCharacter($charId);
|
||||
$allianceId = $helper->LookupCorporation($corpId);
|
||||
if(in_array($allianceId, $legacy) || in_array($allianceId, $renter) || $allianceId == 99004116) {
|
||||
//Do nothing
|
||||
//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 {
|
||||
DokuUser::where(['name' => $user])->delete();
|
||||
$this->DeleteWikiUser($user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return view('admin.dashboard')->with('success', 'Wiki has been purged.');
|
||||
return redirect('/admin/dashboard')->with('success', 'Wiki has been purged.');
|
||||
}
|
||||
|
||||
public function displayRegister() {
|
||||
@@ -167,4 +178,19 @@ class WikiController extends Controller
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
148
app/Http/Controllers/Wormholes/WormholeController.php
Normal file
148
app/Http/Controllers/Wormholes/WormholeController.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use Socialite;
|
||||
use DB;
|
||||
use App\User;
|
||||
use App\Models\User\User;
|
||||
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use Socialite;
|
||||
use DB;
|
||||
use App\User;
|
||||
use App\Models\User\User;
|
||||
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
101
app/Jobs/ProcessAssetsJob.php
Normal file
101
app/Jobs/ProcessAssetsJob.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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\Structures\StructureHelper;
|
||||
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\Assets\AssetHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessAsset;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Stock\Asset;
|
||||
|
||||
class ProcessAssetsJob 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;
|
||||
private $esi;
|
||||
|
||||
protected $location_array = [
|
||||
'StructureFuel',
|
||||
'FighterBay',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(JobProcessAsset $jpa)
|
||||
{
|
||||
$this->charId = $jpa->charId;
|
||||
$this->corpId = $jpa->corpId;
|
||||
$this->page = $jpa->page;
|
||||
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* The job's task is to get all fo the information for all of the assets in
|
||||
* a structure and store them in the database. This task can take a few seconds
|
||||
* therefore we want the Horizon job queue to take care of the request rather
|
||||
* than the cronjob.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare the asset helper
|
||||
$aHelper = new AssetHelper($this->charId, $this->corpId, $this->page);
|
||||
|
||||
//Get a page of assets
|
||||
$assets = $aHelper->GetAssetsByPage();
|
||||
|
||||
//Cycle through the assets, and attmept to store them.
|
||||
foreach($assets as $asset) {
|
||||
//If the asset is in one of the locations we want, then store
|
||||
//or update the asset
|
||||
if(in_array($asset->location_flag, $this->location_array)) {
|
||||
//Attempt to store the asset
|
||||
$aHelper->StoreNewAsset($asset);
|
||||
}
|
||||
}
|
||||
|
||||
//Purge Stale Data
|
||||
$aHelper->PurgeStaleData();
|
||||
}
|
||||
}
|
||||
78
app/Jobs/ProcessCorpJournalJob.php
Normal file
78
app/Jobs/ProcessCorpJournalJob.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
76
app/Jobs/ProcessEveContractsJob.php
Normal file
76
app/Jobs/ProcessEveContractsJob.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//Seat stuff
|
||||
use Seat\Eseye\Configuration;
|
||||
@@ -19,10 +20,9 @@ use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Mail\EveMail;
|
||||
use App\Models\Jobs\JobError;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class SendEveMailJob implements ShouldQueue
|
||||
class ProcessSendEveMailJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -31,7 +31,7 @@ class SendEveMailJob implements ShouldQueue
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 120;
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
@@ -55,13 +55,13 @@ class SendEveMailJob implements ShouldQueue
|
||||
$this->recipient = $mail->recipient;
|
||||
$this->recipient_type = $mail->recipient_type;
|
||||
$this->subject = $mail->subject;
|
||||
|
||||
$this->connection = 'database';
|
||||
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* Utilized by using SendEveMailJob::dispatch($mail);
|
||||
* Utilized by using ProcessSendEveMailJob::dispatch($mail);
|
||||
* The model is passed into the dispatch function, then added to the queue
|
||||
* for processing.
|
||||
*
|
||||
@@ -69,15 +69,18 @@ class SendEveMailJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Retrieve the token for main character to send mails from
|
||||
$token = EsiToken::where(['character_id'=> 93738489])->get();
|
||||
$token = EsiToken::where(['character_id'=> 92626011])->first();
|
||||
|
||||
//Create the ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
'refresh_token' => $token->refresh_token,
|
||||
]);
|
||||
|
||||
//Setup the Eseye class
|
||||
@@ -86,17 +89,18 @@ class SendEveMailJob implements ShouldQueue
|
||||
//Attemp to send the mail
|
||||
try {
|
||||
$esi->setBody([
|
||||
'approved_cost' => 0,
|
||||
'approved_cost' => 100,
|
||||
'body' => $this->body,
|
||||
'recipients' => [[
|
||||
'recipient_id' => (int)$this->recipient,
|
||||
'recipient_id' => $this->recipient,
|
||||
'recipient_type' => $this->recipient_type,
|
||||
]],
|
||||
'subject' => $this->subject,
|
||||
])->invoke('post', '/characters/{character_id}/mail/', [
|
||||
'character_id'=> 93738489,
|
||||
'character_id'=> 92626011,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning($e);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -111,6 +115,6 @@ class SendEveMailJob implements ShouldQueue
|
||||
*/
|
||||
public function failed($exception)
|
||||
{
|
||||
dd($exception);
|
||||
Log::critical($exception);
|
||||
}
|
||||
}
|
||||
79
app/Jobs/ProcessStructureJob.php
Normal file
79
app/Jobs/ProcessStructureJob.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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;
|
||||
|
||||
|
||||
//App Library
|
||||
use App\Library\Structures\StructureHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessStructure;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class ProcessStructureJob 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(JobProcessStructure $jps)
|
||||
{
|
||||
$this->charId = $jps->charId;
|
||||
$this->corpId = $jps->corpId;
|
||||
$this->page = $jps->page;
|
||||
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* The job's task is to get all of the information for a particular structure
|
||||
* and store it in the database. This task can take a few seconds because of the ESI
|
||||
* calls required to store the information. We leave this type of job up to the queue
|
||||
* in order to take the load off of the cron job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$sHelper = new StructureHelper($this->charId, $this->corpId);
|
||||
|
||||
$structures = $sHelper->GetStructuresByPage($this->page);
|
||||
|
||||
foreach($structures as $structure) {
|
||||
$sHelper->ProcessStructure($structure);
|
||||
}
|
||||
|
||||
//After the job is completed, delete the job
|
||||
$this->delete();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ 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;
|
||||
@@ -26,7 +27,7 @@ class ProcessWalletJournalJob implements ShouldQueue
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 300;
|
||||
public $timeout = 3600;
|
||||
|
||||
public $tries = 3;
|
||||
|
||||
@@ -44,8 +45,7 @@ class ProcessWalletJournalJob implements ShouldQueue
|
||||
$this->charId = $pwj->charId;
|
||||
$this->page = $pwj->page;
|
||||
|
||||
$this->delay = 15;
|
||||
$this->connection = 'database';
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,6 +75,6 @@ class ProcessWalletJournalJob implements ShouldQueue
|
||||
*/
|
||||
public function failed($exception)
|
||||
{
|
||||
dd($exception);
|
||||
Log::critical($exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ 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;
|
||||
@@ -15,7 +16,6 @@ use App\Jobs\Library\JobHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessWalletTransaction;
|
||||
use App\Models\Jobs\JobError;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class ProcessWalletTransactionJob implements ShouldQueue
|
||||
@@ -27,7 +27,7 @@ class ProcessWalletTransactionJob implements ShouldQueue
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 300;
|
||||
public $timeout = 3600;
|
||||
|
||||
public $tries = 3;
|
||||
|
||||
@@ -43,8 +43,8 @@ class ProcessWalletTransactionJob implements ShouldQueue
|
||||
{
|
||||
$this->division = $pwt->division;
|
||||
$this->charId = $pwt->charId;
|
||||
|
||||
$this->connection = 'database';
|
||||
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +57,7 @@ class ProcessWalletTransactionJob implements ShouldQueue
|
||||
//Declare the class variables
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
$finance->GetWalletTransaction($this->division, $this->charId);
|
||||
$exception = $finance->GetWalletTransaction($this->division, $this->charId);
|
||||
|
||||
//After the job is completed, delete the job
|
||||
$this->delete();
|
||||
@@ -70,6 +70,6 @@ class ProcessWalletTransactionJob implements ShouldQueue
|
||||
* @return void
|
||||
*/
|
||||
public function failed($exception) {
|
||||
dd($exception);
|
||||
Log::critical($exception);
|
||||
}
|
||||
}
|
||||
|
||||
163
app/Library/Assets/AssetHelper.php
Normal file
163
app/Library/Assets/AssetHelper.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
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 App\Models\Jobs\JobProcessAsset;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Stock\Asset;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
class AssetHelper {
|
||||
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $page;
|
||||
|
||||
public function __construct($char, $corp, $pg = null) {
|
||||
$this->charId = $char;
|
||||
$this->corpId = $corp;
|
||||
$this->page = $pg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Assets By Page in order to store in the database
|
||||
*/
|
||||
public function GetAssetsByPage() {
|
||||
//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');
|
||||
|
||||
//Check for the scope needed
|
||||
$hasScope = $esiHelper->HaveEsiScope($this->charId, 'esi-assets.read_corporation_assets.v1');
|
||||
if($hasScope == false) {
|
||||
Log::critical('ESI Scope check has failed for esi-assets.read_corporation_assets.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 {
|
||||
$assets = $esi->page($this->page)
|
||||
->invoke('get', '/corporations/{corporation_id}/assets', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get page of assets from ESI.");
|
||||
$assets = null;
|
||||
}
|
||||
|
||||
return $assets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a new asset record in the database
|
||||
*/
|
||||
public function StoreNewAsset($asset) {
|
||||
//See if we find any assets which already exist
|
||||
$found = Asset::where([
|
||||
'item_id' => $asset->item_id,
|
||||
])->count();
|
||||
|
||||
//If nothing is found
|
||||
if($found == 0) {
|
||||
$item = new Asset;
|
||||
if(isset($asset->is_blueprint_copy)) {
|
||||
$item->is_blueprint_copy = $asset->is_blueprint_copy;
|
||||
}
|
||||
$item->is_singleton = $asset->is_singleton;
|
||||
$item->item_id = $asset->item_id;
|
||||
$item->location_flag = $asset->location_flag;
|
||||
$item->location_id = $asset->location_id;
|
||||
$item->location_type = $asset->location_type;
|
||||
$item->quantity = $asset->quantity;
|
||||
$item->type_id = $asset->type_id;
|
||||
$item->save();
|
||||
} else {
|
||||
$this->UpdateAsset($asset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge old data, so we don't run into data issues
|
||||
*/
|
||||
public function PurgeStaleData() {
|
||||
$date = Carbon::now()->subDay(1);
|
||||
|
||||
Asset::where('updated_at', '<', $date)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the liquid ozone asset
|
||||
*/
|
||||
public function GetAssetByType($type, $structureId) {
|
||||
//See if the row is in the database table
|
||||
$count = Asset::where([
|
||||
'location_id' => $structureId,
|
||||
'type_id' => $type,
|
||||
'location_flag' => 'StructureFuel',
|
||||
])->count();
|
||||
//Get the row if it is in the table
|
||||
$asset = Asset::where([
|
||||
'location_id' => $structureId,
|
||||
'type_id' => $type,
|
||||
'location_flag' => 'StructureFuel',
|
||||
])->first();
|
||||
|
||||
if($count == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return $asset['quantity'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing asset based off the esi pull
|
||||
*/
|
||||
private function UpdateAsset($asset) {
|
||||
|
||||
Asset::where([
|
||||
'item_id' => $asset->item_id,
|
||||
])->update([
|
||||
'is_singleton' => $asset->is_singleton,
|
||||
'location_flag' => $asset->location_flag,
|
||||
'location_id' => $asset->location_id,
|
||||
'location_type' => $asset->location_type,
|
||||
'quantity' => $asset->quantity,
|
||||
'type_id' => $asset->type_id,
|
||||
'updated_at' => Carbon::now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
281
app/Library/Contracts/EveContractsHelper.php
Normal file
281
app/Library/Contracts/EveContractsHelper.php
Normal file
@@ -0,0 +1,281 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -4,13 +4,16 @@ 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\SendEveMailJob;
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
@@ -33,25 +36,25 @@ class Esi {
|
||||
* @return true,false
|
||||
*/
|
||||
public function HaveEsiScope($charId, $scope) {
|
||||
//Get the esi config
|
||||
$config = config('esi');
|
||||
|
||||
//Check for an esi scope
|
||||
$checks = DB::table('EsiScopes')->where('character_id', $charId)->get();
|
||||
foreach($checks as $check) {
|
||||
if($check->scope === $scope) {
|
||||
return true;
|
||||
}
|
||||
$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';
|
||||
|
||||
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
|
||||
return false;
|
||||
}
|
||||
|
||||
$mail = new EveMail;
|
||||
$mail->sender = 93738489;
|
||||
$mail->subject = 'W4RP Services - Incorrect ESI Scope';
|
||||
$mail->body = "Please register on https://services.w4rp.space with the scope: " . $scope;
|
||||
$mail->recipient = (int)$charId;
|
||||
$mail->recipient_type = 'character';
|
||||
$mail->save();
|
||||
|
||||
SendEveMailJob::dispatch($mail)->delay(Carbon::now()->addSeconds(5));
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function GetCharacterData($charId) {
|
||||
@@ -89,6 +92,21 @@ class Esi {
|
||||
]);
|
||||
//Create the esi container
|
||||
$esi = new Eseye($authentication);
|
||||
|
||||
try {
|
||||
$character = $esi->setBody(array(
|
||||
$name,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(isset($character->characters[0]->id)) {
|
||||
return $character->characters[0]->id;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
try {
|
||||
$character = $esi->setQueryString([
|
||||
'categories' => 'character',
|
||||
@@ -104,6 +122,7 @@ class Esi {
|
||||
$character = json_decode($character, true);
|
||||
|
||||
return $character['character'];
|
||||
*/
|
||||
}
|
||||
|
||||
public function FindCorporationId($charId) {
|
||||
@@ -151,6 +170,51 @@ class Esi {
|
||||
//Return the combined date in the correct format
|
||||
return $realDate;
|
||||
}
|
||||
|
||||
public function GetRefreshToken($charId) {
|
||||
//Get the refresh token from the database
|
||||
$tokenCount = EsiToken::where([
|
||||
'character_id' => $charId,
|
||||
])->count();
|
||||
|
||||
//If the token is not found, then don't return it.
|
||||
if($tokenCount == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$token = EsiToken::where([
|
||||
'character_id' => $charId,
|
||||
])->first();
|
||||
|
||||
return $token->refresh_token;
|
||||
}
|
||||
|
||||
public function SetupEsiAuthentication($token = null) {
|
||||
//Get the platform configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Declare some variables
|
||||
$authentication = null;
|
||||
|
||||
if($token === null) {
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
]);
|
||||
} else {
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
}
|
||||
|
||||
//Setup the esi variable
|
||||
$esi = new Eseye($authentication);
|
||||
|
||||
//Return the created variable
|
||||
return $esi;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -16,8 +16,11 @@ 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' => 93738489])->first();
|
||||
$token = EsiToken::where(['character_id' => $config['primary']])->first();
|
||||
//Create the ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
@@ -36,7 +39,7 @@ class Mail {
|
||||
]],
|
||||
'subject' => $subject,
|
||||
])->invoke('post', '/characters/{character_id}/mail/', [
|
||||
'character_id'=> 93738489,
|
||||
'character_id'=> $config['primary'],
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return 1;
|
||||
|
||||
63
app/Library/Finances/AllianceMarketTax.php
Normal file
63
app/Library/Finances/AllianceMarketTax.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
use DB;
|
||||
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
use App\Models\Finances\AllianceMarketJournal;
|
||||
|
||||
class AllianceMarketTax {
|
||||
public function InsertMarketTax($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(!AllianceMarketJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new AllianceMarketJournal;
|
||||
$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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -13,8 +13,8 @@ use App\Library\Esi\Esi;
|
||||
|
||||
use App\Models\Finances\CorpMarketJournal;
|
||||
|
||||
class MarketTax {
|
||||
public function InsertMarketTax($journal, $corpId, $division) {
|
||||
class CorpMarketTax {
|
||||
public function InsertCorpMarketTax($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
@@ -9,9 +9,10 @@ namespace App\Library\Finances\Helper;
|
||||
|
||||
//Internal Library
|
||||
use DB;
|
||||
use Log;
|
||||
|
||||
//Job
|
||||
use App\Jobs\SendEveMailJob;
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
@@ -20,6 +21,8 @@ use App\Models\Mail\EveMail;
|
||||
|
||||
//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;
|
||||
@@ -35,23 +38,25 @@ use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
|
||||
class FinanceHelper {
|
||||
|
||||
public function GetWalletTransaction($division, $charId) {
|
||||
//Declare the lookup class helper
|
||||
$lookups = new LookupHelper;
|
||||
//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
|
||||
$tokenData = $this->TokenInfo($charId);
|
||||
$token = $tokenData['token'];
|
||||
$scope = $tokenData['scope'];
|
||||
|
||||
//If the token is not found, send the user an eve mail, and just exit out of the function
|
||||
if($this->TokenNotFound($token, $scope, $charId)) {
|
||||
printr("Token not found\n");
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -63,7 +68,7 @@ class FinanceHelper {
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
|
||||
//Create the esi class varialble
|
||||
@@ -72,11 +77,12 @@ class FinanceHelper {
|
||||
//Get the entries of the journal for transactions
|
||||
try {
|
||||
$journals = $esi->invoke('get', '/corporations/{corporation_id}/wallets/{division}/transactions/', [
|
||||
'corporation_id' => 98251577,
|
||||
'division' => 3,
|
||||
'corporation_id' => 98287666,
|
||||
'division' => 5,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
Log::critical($e->getEsiResponse());
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Decode the wallet from json into an array
|
||||
@@ -85,7 +91,7 @@ class FinanceHelper {
|
||||
//For each transactional entry, attempt to store it in the database.
|
||||
//The PutWalletJournal function checks to see if it's already in the database.
|
||||
foreach($wallet as $entry) {
|
||||
if($division == 3 && $charId == 94415555) {
|
||||
if($division == 5 && $charId == 94415555) {
|
||||
if(in_array($entry['type_id'], $pi_items, false)) {
|
||||
$pi = new PISale();
|
||||
$pi->InsertPISale($entry, 98287666);
|
||||
@@ -102,19 +108,19 @@ class FinanceHelper {
|
||||
$other = new PlayerDonation();
|
||||
$industry = new StructureIndustryTax();
|
||||
$office = new OfficeFee();
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$tokenData = $this->TokenInfo($charId);
|
||||
$token = $tokenData['token'];
|
||||
$scope = $tokenData['scope'];
|
||||
|
||||
//Declare the lookup class helper
|
||||
$esiHelper = new Esi();
|
||||
$lookups = new LookupHelper;
|
||||
|
||||
//If the token is not found, send the user an eve mail, and just exit out of the function
|
||||
if($this->TokenNotFound($token, $scope, $charId)) {
|
||||
//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('Scope check failed for esi-wallet.read_corporation_wallets.v1 for character id: ' . $charId);
|
||||
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);
|
||||
@@ -124,7 +130,7 @@ class FinanceHelper {
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
|
||||
//Create the esi class varialble
|
||||
@@ -147,7 +153,8 @@ class FinanceHelper {
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
//Log::warning($e->getEsiResponse());
|
||||
return null;
|
||||
}
|
||||
|
||||
//Set the total pages we need to cycle through.
|
||||
@@ -183,14 +190,17 @@ class FinanceHelper {
|
||||
|
||||
public function GetJournalPageCount($division, $charId) {
|
||||
//Declare class variables
|
||||
$lookups = new LookupHelper;
|
||||
$lookups = new LookupHelper();
|
||||
$esiHelper = new Esi();
|
||||
|
||||
//Get the ESI refresh token for the corporation
|
||||
$tokenData = $this->TokenInfo($charId);
|
||||
$token = $tokenData['token'];
|
||||
$scope = $tokenData['scope'];
|
||||
|
||||
if($this->TokenNotFound($token, $scope, $charId)) {
|
||||
//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 failed for esi-wallet.read_corporation_wallets.v1 for character id: ' . $charId);
|
||||
return null;
|
||||
}
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
if($token == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -202,7 +212,7 @@ class FinanceHelper {
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
|
||||
//Create the esi class variable
|
||||
@@ -216,7 +226,8 @@ class FinanceHelper {
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
//Log::warning($e->getEsiResponse());
|
||||
return null;
|
||||
}
|
||||
|
||||
$pages = $journals->pages;
|
||||
@@ -224,22 +235,74 @@ class FinanceHelper {
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public function GetWalletJournalPage($division, $charId, $page = 1) {
|
||||
public function GetCorpWalletJournalPage($division, $charId, $corpId, $page = 1) {
|
||||
//Declare new class variables
|
||||
$market = new MarketTax();
|
||||
$reprocessing = new ReprocessingTax();
|
||||
$jb = new JumpBridgeTax();
|
||||
$other = new PlayerDonation();
|
||||
$industry = new StructureIndustryTax();
|
||||
$office = new OfficeFee();
|
||||
$corpMarket = new MarketTax();
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$tokenData = $this->TokenInfo($charId);
|
||||
$tokenData = $this->TokenIfno($charId);
|
||||
$token = $tokenData['token'];
|
||||
$scope = $tokenData['scope'];
|
||||
|
||||
//Declare the lookup class helper
|
||||
//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->setVersion('v4');
|
||||
|
||||
//Call the page of the wallet journal
|
||||
try {
|
||||
$journals = $esi->page($page)
|
||||
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning($e->getEsiResponse());
|
||||
return null;
|
||||
}
|
||||
|
||||
//Decode the wallet from json into an array
|
||||
$wallets = json_decode($journals->raw, true);
|
||||
|
||||
//For each journal entry, attempt to store the information into the database
|
||||
foreach($wallets as $wallet) {
|
||||
if($wallet['amount'] > 0) {
|
||||
if($wallet['ref_type'] == 'brokers_fee') {
|
||||
$corpMarket->InsertCorpMarketTax($wallet, $corpId, $division);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function GetWalletJournalPage($division, $charId, $page = 1) {
|
||||
//Declare new class variables
|
||||
$market = new AllianceMarketTax;
|
||||
$reprocessing = new ReprocessingTax;
|
||||
$jb = new JumpBridgeTax;
|
||||
$other = new PlayerDonation;
|
||||
$industry = new StructureIndustryTax;
|
||||
$office = new OfficeFee;
|
||||
$pi = new PlanetProductionTax;
|
||||
$esiHelper = new Esi;
|
||||
$lookups = 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');
|
||||
if($hasScope == false) {
|
||||
Log::critical('Esi Scope check failed for esi-wallet.read_corporation_wallets.v1 for character id: ' . $charId);
|
||||
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->LookupCorporationId($charId);
|
||||
@@ -249,7 +312,7 @@ class FinanceHelper {
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
|
||||
//Create the esi class varialble
|
||||
@@ -265,7 +328,8 @@ class FinanceHelper {
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
//Log::warning($e->getEsiResponse());
|
||||
return null;
|
||||
}
|
||||
|
||||
//Decode the wallet from json into an array
|
||||
@@ -287,44 +351,13 @@ class FinanceHelper {
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function TokenInfo($charId) {
|
||||
//Get the ESI refresh token for the corporation to add a new wallet jouranls into the database
|
||||
//send the token and scope back to the calling function
|
||||
$token = EsiToken::where(['character_id' => $charId])->get(['refresh_token']);
|
||||
$scope = EsiScope::where(['character_id' => $charId, 'scope' => 'esi-wallet.read_corporation_wallets.v1'])->get(['scope']);
|
||||
|
||||
$data = [
|
||||
'token' => $token,
|
||||
'scope' => $scope,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function TokenNotFound($token, $scope, $charId) {
|
||||
if(!isset($token[0]->refresh_token) || !isset($scope[0]->scope)) {
|
||||
//Register a mail to be dispatched as a job
|
||||
$mail = new EveMail;
|
||||
$mail->sender = 93738489;
|
||||
$mail->subject = 'W4RP Services ESI API';
|
||||
$mail->body = 'You need to register an ESI API on the services site for esi-wallet.read_corporation_wallet.v1<br>This is also labeled Corporation Wallets';
|
||||
$mail->recipient = (int)$charId;
|
||||
$mail->recipient_type = 'character';
|
||||
$mail->save();
|
||||
|
||||
SendEveMailJob::dispatch($mail);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function GetPIMaterialsArray() {
|
||||
//Setup array for PI items
|
||||
$pi_items = [
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//dd($journal);
|
||||
|
||||
//Insert the PI Sale into the database
|
||||
if(!PISaleJournal::where(['journal_ref_id' => $journal['journal_ref_id']])->exists()) {
|
||||
$entry = new PISaleJournal;
|
||||
|
||||
@@ -31,27 +31,37 @@ class LookupHelper {
|
||||
|
||||
//Create a character id from a character name
|
||||
public function CharacterNameToId($character) {
|
||||
//Setup Eseye Configuration
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
//Setup class variables
|
||||
$esi = new Eseye();
|
||||
|
||||
//Attempt to find the character name in the LookupCharacter table to see if we can match it to an id
|
||||
$char = CharacterToCorporation::where(['character_name' => $character])->get(['character_id']);
|
||||
if(!isset($char->character_id)) {
|
||||
//Get the character id from the ESI API.
|
||||
$response = $esi->setQueryString([
|
||||
'categories' => 'character',
|
||||
'search' => $character,
|
||||
'strict' => 'true',
|
||||
])->invoke('get', '/search/');
|
||||
$count = CharacterToCorporation::where(['character_name' => $character])->count();
|
||||
if($count === 0) {
|
||||
//Format the name
|
||||
$name = str_replace(' ', '%20', $character);
|
||||
//dd($name);
|
||||
try {
|
||||
//Get the character id from the ESI API.
|
||||
$response = $esi->setBody(array(
|
||||
$character,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
|
||||
$this->LookupCharacter($response->character[0]);
|
||||
}
|
||||
|
||||
//If the data we are looking for is set, then process the data
|
||||
if(isset($response->characters[0]->id)) {
|
||||
$this->LookupCharacter($response->characters[0]->id);
|
||||
|
||||
return $response->characters[0]->id;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return $response->character[0];
|
||||
} else {
|
||||
return $charId[0]->character_id;
|
||||
$char = CharacterToCorporation::where(['character_name' => $character])->get(['character_id'])->first();
|
||||
|
||||
return $char->character_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,11 +69,11 @@ class LookupHelper {
|
||||
//to hit the ESI all the time
|
||||
public function LookupCharacter($charId) {
|
||||
//Check for the character in the user_to_corporation table
|
||||
$found = CharacterToCorporation::where('character_id', $charId)->get(['corporation_id']);
|
||||
$count = CharacterToCorporation::where('character_id', $charId)->count();
|
||||
|
||||
//If we don't find the character in the table, then we retrieve from ESI
|
||||
//and add the character to the table
|
||||
if(!isset($found[0]->corporation_id)) {
|
||||
if($count == 0) {
|
||||
//Get the configuration for ESI from the environmental variables
|
||||
$config = config('esi');
|
||||
|
||||
@@ -92,6 +102,8 @@ class LookupHelper {
|
||||
//Return the corporation_id which is what the calling function is looking for
|
||||
return $character->corporation_id;
|
||||
} else {
|
||||
$found = CharacterToCorporation::where('character_id', $charId)->get(['corporation_id']);
|
||||
|
||||
//Return the corporation_id if it was found in the database as it is what the calling function is looking for
|
||||
return $found[0]->corporation_id;
|
||||
}
|
||||
@@ -99,11 +111,11 @@ class LookupHelper {
|
||||
|
||||
public function LookupCorporationId($charId) {
|
||||
//Check for the character in the user_to_corporation table
|
||||
$found = CharacterToCorporation::where('character_id', $charId)->get(['corporation_id']);
|
||||
$count = CharacterToCorporation::where('character_id', $charId)->count();
|
||||
|
||||
//If we don't find the character in the table, then we retrieve from ESI
|
||||
//and add the character to the table
|
||||
if(!isset($found[0]->corporation_id)) {
|
||||
if($count == 0) {
|
||||
//Get the configuration for ESI from the environmental variables
|
||||
$config = config('esi');
|
||||
|
||||
@@ -132,6 +144,8 @@ class LookupHelper {
|
||||
//Return the corporation_id which is what the calling function is looking for
|
||||
return $character->corporation_id;
|
||||
} else {
|
||||
$found = CharacterToCorporation::where('character_id', $charId)->get(['corporation_id']);
|
||||
|
||||
//Return the corporation_id if it was found in the database as it is what the calling function is looking for
|
||||
return $found[0]->corporation_id;
|
||||
}
|
||||
@@ -144,11 +158,11 @@ class LookupHelper {
|
||||
*/
|
||||
public function LookupCorporationName($corpId) {
|
||||
//check for the character in the user_to_corporation table
|
||||
$found = CorporationToAlliance::where('corporation_id', $corpId)->get(['corporation_name']);
|
||||
$count = CorporationToAlliance::where('corporation_id', $corpId)->count();
|
||||
|
||||
//If we don't find the corporation in the table, then we need to retrieve it from ESI
|
||||
//and add the corporation to the table
|
||||
if(!isset($found[0]->corporation_name)) {
|
||||
if($count == 0) {
|
||||
//Get the configuration for ESI from the environmental variables
|
||||
$config = config('esi');
|
||||
|
||||
@@ -166,6 +180,8 @@ class LookupHelper {
|
||||
//Return the corporation name
|
||||
return $corporation->name;
|
||||
} else {
|
||||
$found = CorporationToAlliance::where('corporation_id', $corpId)->get(['corporation_name']);
|
||||
|
||||
return $found[0]->corporation_name;
|
||||
}
|
||||
}
|
||||
@@ -174,11 +190,11 @@ class LookupHelper {
|
||||
//hit the ESI API all the time
|
||||
public function LookupCorporation($corpId) {
|
||||
//Check for the character in the user_to_corporation table
|
||||
$found = CorporationToAlliance::where('corporation_id', $corpId)->get(['alliance_id']);
|
||||
$count = CorporationToAlliance::where('corporation_id', $corpId)->count();
|
||||
|
||||
//If we don't find the character in the table, then we retrieve from ESI
|
||||
//and add the character to the table
|
||||
if(!isset($found[0]->alliance_id)) {
|
||||
if($count == 0) {
|
||||
//Get the configuration for ESI from the environmental variables
|
||||
$config = config('esi');
|
||||
|
||||
@@ -190,11 +206,16 @@ class LookupHelper {
|
||||
$corporation = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
$alliance = $esi->invoke('get', '/alliances/{alliance_id}/', [
|
||||
'alliance_id' => $corporation->alliance_id,
|
||||
]);
|
||||
if(isset($corporation->alliance_id)) {
|
||||
$alliance = $esi->invoke('get', '/alliances/{alliance_id}/', [
|
||||
'alliance_id' => $corporation->alliance_id,
|
||||
]);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
} catch(\Seat\Eseye\Exceptions\RequestFailedException $e){
|
||||
return $e->getEsiResponse();
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Save all of the data to the database
|
||||
@@ -208,6 +229,8 @@ class LookupHelper {
|
||||
//Return the corporation_id which is what the calling function is looking for
|
||||
return $corporation->alliance_id;
|
||||
} else {
|
||||
$found = CorporationToAlliance::where('corporation_id', $corpId)->get(['alliance_id']);
|
||||
|
||||
//Return the corporation_id if it was found in the database as it is what the calling function is looking for
|
||||
return $found[0]->alliance_id;
|
||||
}
|
||||
|
||||
754
app/Library/Lookups/NewLookupHelper.php
Normal file
754
app/Library/Lookups/NewLookupHelper.php
Normal file
@@ -0,0 +1,754 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Lookups;
|
||||
|
||||
//Internal Libraries
|
||||
use DB;
|
||||
use Log;
|
||||
|
||||
//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;
|
||||
|
||||
//Models
|
||||
use App\Models\Lookups\CharacterToCorporation;
|
||||
use App\Models\Lookups\CorporationToAlliance;
|
||||
use App\Models\Lookups\CharacterLookup;
|
||||
use App\Models\Lookups\CorporationLookup;
|
||||
use App\Models\Lookups\AllianceLookup;
|
||||
|
||||
class NewLookupHelper {
|
||||
|
||||
//Variables
|
||||
private $esi;
|
||||
|
||||
//Construct
|
||||
public function __construct() {
|
||||
$this->esi = new Eseye();
|
||||
}
|
||||
|
||||
public function GetCharacterInfo($charId) {
|
||||
try {
|
||||
$character = $this->esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $character;
|
||||
}
|
||||
|
||||
public function CharacterIdToName($charId) {
|
||||
//Check if the character is stored in our own database first
|
||||
$char = $this->LookupCharacter($charId, null);
|
||||
//If the char is null, then we did not find the character in our own database
|
||||
if($char != null) {
|
||||
return $char->name;
|
||||
} else {
|
||||
//Get the character id from esi
|
||||
try {
|
||||
$character = $this->esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get character name from /characters/{character_id}/ in lookup helper.');
|
||||
return null;
|
||||
}
|
||||
|
||||
if(isset($character->name)) {
|
||||
//Store the character name for the lookup table
|
||||
$this->StoreCharacterLookup(null, $character->name);
|
||||
//Return the character name to the calling function
|
||||
return $character->name;
|
||||
} else {
|
||||
//If we don't find any information return null
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function CharacterNameToId($charName) {
|
||||
//Check if the character is stored in our own database first
|
||||
$char = $this->LookupCharacter(null, $charName);
|
||||
if($char != null) {
|
||||
return $char->character_id;
|
||||
} else {
|
||||
try {
|
||||
$response = $this->esi->setBody(array(
|
||||
$charName,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get character name from /universe/ids/ in lookup helper.');
|
||||
return null;
|
||||
}
|
||||
|
||||
if(isset($response->characters[0]->id)) {
|
||||
$this->StoreCharacterLookup($response->characters[0]->id, null);
|
||||
|
||||
return $response->characters[0]->id;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function CorporationIdToName($corpId) {
|
||||
//Check if the corporation is stored in our own database first
|
||||
$corp = $this->LookupCorporation($corpId, null);
|
||||
if($corp != null) {
|
||||
return $corp->name;
|
||||
} else {
|
||||
//Try to get the corporation details from ESI
|
||||
try {
|
||||
$corporation = $this->esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//Log the issue
|
||||
Log::warning('Failed to get corporation name from /corporations/{corporation_id}/ in lookup helper.');
|
||||
return null;
|
||||
}
|
||||
|
||||
if(isset($corporation->name)) {
|
||||
//Store the corporation name for the lookup table
|
||||
$this->StoreCorporationLookup(null, $corporation->name);
|
||||
//Return the corporation name to the calling function
|
||||
return $corporation->name;
|
||||
} else {
|
||||
//If nothing is found and ESI didn't work, return null to the calling function
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function CorporationNameToId($corpName) {
|
||||
//Check if the corporation is stored in our own database first
|
||||
$corp = $this->LookupCorporation(null, $corpName);
|
||||
if($corp != null) {
|
||||
return $corp->corporation_id;
|
||||
} else {
|
||||
//Try to get the corporation details from ESI
|
||||
try {
|
||||
$corporation = $this->esi->setBody(array(
|
||||
$corpName,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get the corporation id from /universe/ids/ in lookup helper.');
|
||||
return null;
|
||||
}
|
||||
|
||||
if(isset($response->corporations[0]->id)) {
|
||||
$this->StoreCorporationLookup($response->corporations[0]->id, null);
|
||||
|
||||
return $response->corporations[0]->id;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function AllianceIdToName($allianceId) {
|
||||
//Check if the alliance is stored in our own database first
|
||||
$alliance = $this->LookupAlliance($allianceId, null);
|
||||
if($alliance != null) {
|
||||
return $alliance->alliance_id;
|
||||
} else {
|
||||
//Try to get the alliance details from ESI
|
||||
try {
|
||||
$alliance = $this->esi->invoke('get', '/alliances/{alliance_id}/', [
|
||||
'alliance_id' => $allianceId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get the alliance name from /alliances/{alliance_id}/ in lookup helper.');
|
||||
return null;
|
||||
}
|
||||
|
||||
if(isset($alliance->name)) {
|
||||
$this->StoreAllianceLookup(null, $alliance->name);
|
||||
|
||||
return $alliance->name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function AllianceNameToId($allianceName) {
|
||||
//Check if the alliance is stored in our own database first
|
||||
$alliance = $this->LookupAlliance(null, $allianceName);
|
||||
if($alliance != null) {
|
||||
return $alliance->name;
|
||||
} else {
|
||||
//Try to get the alliance details from ESI
|
||||
try {
|
||||
$response = $this->esi->setBody(array(
|
||||
$allianceName,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get the alliance id from /universe/ids/ in lookup helper.');
|
||||
return null;
|
||||
}
|
||||
|
||||
//If the data is pulled from ESI store the data, and send the data back to the calling function
|
||||
if(isset($response->alliances[0]->id)) {
|
||||
$this->StoreAllianceLookup($response->alliances[0]->id, null);
|
||||
|
||||
return $response->alliances[0]->id;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function LookupCharacter($id = null, $name = null) {
|
||||
//If both the id and name are null, then there is nothing to lookup
|
||||
if($id == null & $name == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$character = null;
|
||||
|
||||
//If the id is null attempt to lookup the character
|
||||
if($id != null) {
|
||||
$count = CharacterLookup::where(['character_id' => $id])->count();
|
||||
if($count > 0) {
|
||||
$character = CharacterLookup::where(['character_id' => $id])->first();
|
||||
} else {
|
||||
$character = null;
|
||||
}
|
||||
} else if($name != null) {
|
||||
//If the name is not null then attemp to lookup the character
|
||||
$count = CharacterLookup::where(['name' => $name])->count();
|
||||
if($count > 0) {
|
||||
$character = CharacterLookup::where(['name' => $name])->first();
|
||||
} else {
|
||||
$character = null;
|
||||
}
|
||||
}
|
||||
|
||||
//Return the character details to the calling function
|
||||
return $character;
|
||||
}
|
||||
|
||||
public function LookupCorporation($id = null, $name = null) {
|
||||
if($id == null && $name == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$corporation = null;
|
||||
|
||||
//If the id is not null attempt to lookup the character
|
||||
if($id != null) {
|
||||
$count = CorporationLookup::where(['corporation_id' => $id])->count();
|
||||
if($count > 0) {
|
||||
$corporation = CorporationLookup::where(['corporation_id' => $id])->first();
|
||||
} else {
|
||||
$corporation = null;
|
||||
}
|
||||
} else if($name != null) {
|
||||
$count = CorporationLookup::where(['name' => $name])->count();
|
||||
if($count > 0) {
|
||||
$corporation = CorporationLookup::where(['name' => $name])->count();
|
||||
} else {
|
||||
$corporation = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $corporation;
|
||||
}
|
||||
|
||||
public function LookupAlliance($id = null, $name = null) {
|
||||
if($id == null && $name == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$alliance = null;
|
||||
|
||||
if($id != null) {
|
||||
$count = AllianceLookup::where(['alliance_id' => $id])->count();
|
||||
if($count > 0) {
|
||||
$alliance = AllianceLookup::where(['alliance_id' => $id])->first();
|
||||
} else {
|
||||
$alliance = null;
|
||||
}
|
||||
} else if($name != null) {
|
||||
$count = AllianceLookup::where(['name' => $name])->count();
|
||||
if($count > 0) {
|
||||
$alliance = AllianceLookup::where(['name' => $name])->first();
|
||||
} else {
|
||||
$alliance = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $alliance;
|
||||
}
|
||||
|
||||
private function StoreCharacterLookup($id = null, $name = null) {
|
||||
//Declare the esi helper
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//If the id and name are null, just return
|
||||
if($id == null && $name == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
//If the id isn't null, then get the character information from the esi via the character id
|
||||
if($id != null) {
|
||||
//See if the character already exists in the lookup table
|
||||
$count = CharacterLookup::where(['character_id' => $id])->count();
|
||||
if($count == 0) {
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$corpId = $this->SaveCharacter($response, $id);
|
||||
|
||||
if($corpId != null) {
|
||||
//Do a recursive call for the corporation Lookup
|
||||
$this->StoreCorporationLookup($corpId, null);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
//If the name is not null attempt to add the character to the table
|
||||
if($name != null) {
|
||||
$count = CharacterLookup::where(['name' => $name])->count();
|
||||
if($count == 0) {
|
||||
try {
|
||||
//Get the character id from the ESI API
|
||||
$responseName = $this->esi->setBody(array(
|
||||
$name,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $responseName->characters[0]->id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$corpId = $this->SaveCharacter($response, $responseName->characters[0]->id);
|
||||
if($corpId != null) {
|
||||
//Do a recursive call for the corporation Lookup
|
||||
$this->StoreCorporationLookup($corpId, null);
|
||||
}
|
||||
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private function SaveCharacter($response, $charId) {
|
||||
$char = new CharacterLookup;
|
||||
$char->character_id = $charId;
|
||||
if(isset($response->alliance_id)) {
|
||||
$char->alliance_id = $response->alliance_id;
|
||||
}
|
||||
if(isset($response->ancestry_id)) {
|
||||
$char->ancestry_id = $response->ancestry_id;
|
||||
}
|
||||
$char->birthday = $response->birthday;
|
||||
$char->bloodline_id = $response->bloodline_id;
|
||||
$char->corporation_id = $response->corporation_id;
|
||||
if(isset($response->description)) {
|
||||
$char->description = $response->description;
|
||||
}
|
||||
if(isset($response->faction_id)) {
|
||||
$char->faction_id = $response->faction_id;
|
||||
}
|
||||
$char->gender = $response->gender;
|
||||
$char->name = $response->name;
|
||||
$char->race_id = $response->race_id;
|
||||
if(isset($response->security_status)) {
|
||||
$char->security_status = $response->security_status;
|
||||
}
|
||||
if(isset($response->title)) {
|
||||
$char->title = $response->title;
|
||||
}
|
||||
$char->save();
|
||||
|
||||
return $response->corporation_id;
|
||||
}
|
||||
|
||||
public function UpdateCharacters() {
|
||||
$all = CharacterLookup::all();
|
||||
|
||||
foreach($all as $entry) {
|
||||
//Attempt to get the data from ESI
|
||||
try {
|
||||
$response = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $entry->character_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
|
||||
}
|
||||
|
||||
//Update the data
|
||||
if(isset($response->alliance_id)) {
|
||||
if($response->alliance_id != $entry->alliance_id) {
|
||||
CharacterLookup::where([
|
||||
'character_id' => $entry->character_id,
|
||||
])->update([
|
||||
'alliance_id' => $response->alliance_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->description)) {
|
||||
if($response->description != $entry->description) {
|
||||
CharacterLookup::where([
|
||||
'character_id' => $entry->character_id,
|
||||
])->update([
|
||||
'description' => $response->description,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->security_status)) {
|
||||
if($response->security_status != $entry->security_status) {
|
||||
CharacterLookup::where([
|
||||
'character_id' => $entry->character_id,
|
||||
])->update([
|
||||
'security_status' => $response->security_status,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->title)) {
|
||||
if($response->title != $entry->title) {
|
||||
CharacterLookup::where([
|
||||
'character_id' => $entry->character_id,
|
||||
])->update([
|
||||
'title' => $response->title,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->corporation_id)) {
|
||||
if($response->corporation_id != $entry->corporation_id) {
|
||||
CharacterLookup::where([
|
||||
'character_id' => $entry->character_id,
|
||||
])->update([
|
||||
'corporation_id' => $response->corporation_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function StoreCorporationLookup($id = null, $name = null) {
|
||||
//If the id is null and the name is null, then return
|
||||
if($id == null && $name == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if($id != null) {
|
||||
$count = CorporationLookup::where(['corporation_id' => $id])->count();
|
||||
if($count == 0) {
|
||||
try {
|
||||
$response = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$allianceId = $this->SaveCorporation($response, $id);
|
||||
|
||||
if($allianceId != null) {
|
||||
$this->StoreAllianceLookup($allianceId);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if($name != null) {
|
||||
$count = CorporationLookup::where(['name' => $name])->count();
|
||||
if($count == 0) {
|
||||
try {
|
||||
//Get the corporation id from the ESI API
|
||||
$responseName = $this->esi->setBody(array(
|
||||
$name,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $responseName->corporations[0]->id,
|
||||
]);
|
||||
} catch(ReqeustFailedException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$allianceId = $this->SaveCorporation($response, $responseName->corporations[0]->id);
|
||||
if($allianceId != null) {
|
||||
//Do a recursive call for the alliance lookup
|
||||
$this->StoreAllianceLookup($allianceId, null);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private function SaveCorporation($response, $corpId) {
|
||||
$corp = new CorporationLookup;
|
||||
$corp->corporation_id = $corpId;
|
||||
if(isset($response->alliance_id)) {
|
||||
$corp->alliance_id = $response->alliance_id;
|
||||
}
|
||||
$corp->ceo_id = $response->ceo_id;
|
||||
$corp->creator_id = $response->creator_id;
|
||||
if(isset($response->date_founded)) {
|
||||
$corp->date_founded = $response->date_founded;
|
||||
}
|
||||
if(isset($response->description)) {
|
||||
$corp->description = $response->description;
|
||||
}
|
||||
if(isset($response->faction_id)) {
|
||||
$corp->faction_id = $response->faction_id;
|
||||
}
|
||||
if(isset($response->home_station_id)) {
|
||||
$corp->home_station_id = $response->home_station_id;
|
||||
}
|
||||
$corp->member_count = $response->member_count;
|
||||
$corp->name = $response->name;
|
||||
if(isset($response->shares)) {
|
||||
$corp->shares = $response->shares;
|
||||
}
|
||||
$corp->tax_rate = $response->tax_rate;
|
||||
$corp->ticker = $response->ticker;
|
||||
if(isset($response->url)) {
|
||||
$corp->url = $response->url;
|
||||
}
|
||||
if(isset($response->war_eligible)) {
|
||||
$corp->war_eligible = $response->war_eligible;
|
||||
}
|
||||
$corp->save();
|
||||
|
||||
if(isset($response->alliance_id)) {
|
||||
return $response->alliance_id;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function UpdateCorporations() {
|
||||
$all = CorporationLookup::all();
|
||||
|
||||
foreach($all as $entry) {
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
|
||||
}
|
||||
|
||||
if(isset($response->alliance_id)) {
|
||||
if($response->alliance_id != $entry->alliance_id) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'alliance_id' => $response->alliance_id,
|
||||
]);
|
||||
}
|
||||
|
||||
if(isset($response->description)) {
|
||||
if($response->description != $entry->description) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'description' => $response->description,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($response->faction_id)) {
|
||||
if($response->faction_id != $entry->faction_id) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'faction_id' => $response->faction_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($response->home_station_id)) {
|
||||
if($response->home_station_id != $entry->home_station_id) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'home_station_id' => $response->home_station_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($response->member_count)) {
|
||||
if($response->member_count != $entry->member_count) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'member_count' => $response->member_count,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($response->tax_rate)) {
|
||||
if($response->tax_rate != $entry->tax_rate) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'tax_rate' => $response->tax_rate,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($response->url)) {
|
||||
if($response->url != $entry->url) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'url' => $response->url,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($response->war_eligible)) {
|
||||
if($response->war_eligible != $entry->war_eligible) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'war_eligible' => $response->war_eligible,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function StoreAllianceLookup($id = null, $name = null) {
|
||||
//Check if the passed variables are null
|
||||
if($id == null && $name == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
//If the id isn't null then attempt to populate the table
|
||||
if($id != null) {
|
||||
//See if the alliance already exists in the table
|
||||
$count = AllianceLookup::where(['alliance_id' => $id])->count();
|
||||
if($count == 0) {
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/alliances/{alliance_id}/', [
|
||||
'alliance_id' => $id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->SaveAlliance($response, $id);
|
||||
}
|
||||
}
|
||||
|
||||
//If the name isn't null then attempt to populate the table
|
||||
if($name != null) {
|
||||
$count = AllianceLookup::where(['name' => $name])->count();
|
||||
if($count == 0) {
|
||||
try {
|
||||
$responseName = $this->esi->setBody(array(
|
||||
$name,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/alliances/{alliance_id}/', [
|
||||
'alliance_id' => $responseName->alliances[0]->id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->SaveAlliance($response, $responseName->alliances[0]->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function SaveAlliance($response, $allianceId) {
|
||||
$alliance = new AllianceLookup;
|
||||
$alliance->alliance_id = $allianceId;
|
||||
$alliance->creator_corporation_id = $response->creator_corporation_id;
|
||||
$alliance->creator_id = $response->creator_id;
|
||||
$alliance->date_founded = $response->date_founded;
|
||||
if(isset($response->executor_corporation_id)) {
|
||||
$alliance->executor_corporation_id = $response->executor_corporation_id;
|
||||
}
|
||||
if(isset($response->faction_id)) {
|
||||
$alliance->faction_id = $response->faction_id;
|
||||
}
|
||||
$alliance->name = $response->name;
|
||||
$alliance->ticker = $response->ticker;
|
||||
$alliance->save();
|
||||
}
|
||||
|
||||
public function UpdateAlliances() {
|
||||
$all = AllianceLookup::all();
|
||||
|
||||
foreach($all as $entry) {
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/alliances/{alliance_id}/', [
|
||||
'alliance_id' => $entry->alliance_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
|
||||
}
|
||||
|
||||
if(isset($response->executor_corporation_id)) {
|
||||
if($response->executor_corporation_id != $entry->executor_corporation_id) {
|
||||
AllianceLookup::where([
|
||||
'alliance_id' => $entry->alliance_id,
|
||||
])->update([
|
||||
'executor_corporation_id' => $response->executor_corporation_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($response->faction_id)) {
|
||||
if($response->faction_id != $entry->faction_id) {
|
||||
AllianceLookup::where([
|
||||
'alliance_id' => $entry->alliance_id,
|
||||
])->update([
|
||||
'faction_id' => $response->faction_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
246
app/Library/Moons/MiningLedgerHelper.php
Normal file
246
app/Library/Moons/MiningLedgerHelper.php
Normal file
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Library\Moons;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
use DB;
|
||||
|
||||
//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\Lookups\NewLookupHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Service;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
|
||||
class MiningLedgerHelper {
|
||||
|
||||
private $charId;
|
||||
private $corpId;
|
||||
|
||||
/**
|
||||
* Constructor function
|
||||
*
|
||||
* @var $charId
|
||||
* @var $corpId
|
||||
*/
|
||||
public function __construct($charId, $corpId) {
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corporation's mining structures.
|
||||
* These structures consist of Athanors and Tataras
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetCorpMiningStructures() {
|
||||
//Declare variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check if the character has the correct ESI Scope. If the character doesn't, then return false, but
|
||||
//also send a notice eve mail to the user. The HaveEsiScope sends a mail for us.
|
||||
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the refresh token from the database and setup the esi authenticaiton container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($esiHelper->GetRefreshToken($this->charId));
|
||||
|
||||
//Get a list of the mining observers, which are structures
|
||||
try {
|
||||
$observers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Could not find any mining observers for corporation: ' . $this->corpId);
|
||||
return null;
|
||||
}
|
||||
|
||||
return $observers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mining struture information
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetMiningStructureInfo($observerId) {
|
||||
//Declare variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check for ESI scopes
|
||||
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-universe.read_structures.v1')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the refresh token and setup the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($esiHelper->GetRefreshToken($this->charId));
|
||||
|
||||
//Try to get the structure information
|
||||
try {
|
||||
$info = $esi->invoke('get', '/universe/structures/{struture_id}/', [
|
||||
'structure_id' => $observerId,
|
||||
]);
|
||||
} catch(RequestFailedExcept $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$system = $this->GetSolarSystemName($info->solar_system_id);
|
||||
|
||||
return [
|
||||
'name' => $info->name,
|
||||
'system' => $system,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mining ledger for a particular structure
|
||||
*
|
||||
* @var observerId
|
||||
* @return array
|
||||
*/
|
||||
public function GetMiningLedger($observerId) {
|
||||
//Declare variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check for ESI Scopes
|
||||
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the refresh token and setup the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($esiHelper->GetRefreshToken($charId));
|
||||
|
||||
//Get the mining ledger
|
||||
try {
|
||||
$ledger = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||
'corporation_id' => $corpId,
|
||||
'observer_id' => $observerId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $ledger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the mining ledger into something more readable for humans
|
||||
*
|
||||
* @var array
|
||||
* @return array
|
||||
*/
|
||||
public function ProcessMiningLedger($ledger, $date) {
|
||||
//Declare some variables
|
||||
$items = array();
|
||||
$notSorted = array();
|
||||
$final = array();
|
||||
$lookup = new NewLookupHelper;
|
||||
|
||||
|
||||
//In the first iteration of the array get rid of the extra items we don't want
|
||||
foreach($ledger as $ledg) {
|
||||
if($ledg->last_updated == $date) {
|
||||
array_push($items, $ledg);
|
||||
}
|
||||
}
|
||||
|
||||
//Sort through the array and replace character id with name and item id with name
|
||||
foreach($items as $item) {
|
||||
$charName = $lookup->CharacterIdToName($item->character_id);
|
||||
$typeName = $this->GetItemName($item->type_id);
|
||||
$corpName = $lookup->CorporationIdToName($item->recorded_corporation_id);
|
||||
|
||||
if(isset($final[$charName])) {
|
||||
$final[$charName] = [
|
||||
'ore' => $typeName,
|
||||
'quantity' => $item->quantity,
|
||||
'date' => $item->last_updated,
|
||||
];
|
||||
} else {
|
||||
$temp = [
|
||||
'ore' => $typeName,
|
||||
'quantity' => $item->quantity,
|
||||
'date' => $item->last_updated,
|
||||
];
|
||||
|
||||
array_push($final[$charName], $temp);
|
||||
}
|
||||
}
|
||||
|
||||
return $final;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type id and return the name of the ore
|
||||
*
|
||||
* @var typeId
|
||||
* @return string
|
||||
*/
|
||||
private function GetItemName($typeId) {
|
||||
//Setup the esi helper variable
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup the authentication container for ESI
|
||||
$esi = $esiHelper->SetupEsiAuthentication();
|
||||
|
||||
try {
|
||||
$item = $esi->invoke('get', '/universe/types/{type_id}/', [
|
||||
'type_id' => $typeId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $item->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the solar system name
|
||||
*
|
||||
* @var systemId
|
||||
* @return string
|
||||
*/
|
||||
private function GetSolarSystemName($systemId) {
|
||||
//Setup the esi helper variable
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup the authentication container for ESI
|
||||
$esi = $esiHelper->SetupEsiAuthentication();
|
||||
|
||||
//Attempt to get the solar system name from ESI
|
||||
try {
|
||||
$solar = $esi->invoke('get', '/universe/systems/{system_id}/', [
|
||||
'system_id' => $systemId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
$solar = null;
|
||||
}
|
||||
|
||||
if($solar != null) {
|
||||
return $solar->name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -145,6 +145,78 @@ class MoonCalc {
|
||||
return $totalPriceMined;
|
||||
}
|
||||
|
||||
public function SpatialMoonsOnlyGooMailer($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
||||
//Always assume a 1 month pull which equates to 5.55m3 per second or 2,592,000 seconds
|
||||
//Total pull size is 14,385,600 m3
|
||||
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
||||
//Get the configuration for pricing calculations
|
||||
$config = DB::table('Config')->get();
|
||||
if($firstQuan >= 1.00) {
|
||||
$firstPerc = $this->ConvertToPercentage($firstQuan);
|
||||
} else {
|
||||
$firstPerc = $firstQuan;
|
||||
}
|
||||
if($secondQuan >= 1.00) {
|
||||
$secondPerc = $this->ConvertToPercentage($secondQuan);
|
||||
} else {
|
||||
$secondPerc = $secondQuan;
|
||||
}
|
||||
if($thirdQuan >= 1.00) {
|
||||
$thirdPerc = $this->ConvertToPercentage($thirdQuan);
|
||||
} else {
|
||||
$thirdPerc = $thirdQuan;
|
||||
}
|
||||
if($fourthQuan >= 1.00) {
|
||||
$fourthPerc = $this->ConvertToPercentage($fourthQuan);
|
||||
} else {
|
||||
$fourthPerc = $fourthQuan;
|
||||
}
|
||||
if($firstOre != "None") {
|
||||
if($this->IsRMoon($firstOre)) {
|
||||
$firstTotal = $this->CalcPrice($firstOre, $firstPerc);
|
||||
} else {
|
||||
$firstTotal = 0.00;
|
||||
}
|
||||
} else {
|
||||
$firstTotal = 0.00;
|
||||
}
|
||||
if($secondOre != "None") {
|
||||
if($this->IsRMoon($secondOre)) {
|
||||
$secondTotal = $this->CalcPrice($secondOre, $secondPerc);
|
||||
} else {
|
||||
$secondTotal = 0.00;
|
||||
}
|
||||
} else {
|
||||
$secondTotal = 0.00;
|
||||
}
|
||||
if($thirdOre != "None") {
|
||||
if($this->IsRMoon($thirdOre)) {
|
||||
$thirdTotal = $this->CalcPrice($thirdOre, $thirdPerc);
|
||||
} else {
|
||||
$thirdTotal = 0.00;
|
||||
}
|
||||
} else {
|
||||
$thirdTotal = 0.00;
|
||||
}
|
||||
if($fourthOre != "None") {
|
||||
if($this->IsRMoon($fourthOre)) {
|
||||
$fourthTotal = $this->CalcPrice($fourthOre, $fourthPerc);
|
||||
} else {
|
||||
$fourthTotal = 0.00;
|
||||
}
|
||||
} else {
|
||||
$fourthTotal = 0.00;
|
||||
}
|
||||
//Calculate the total to price to be mined in one month
|
||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||
//Calculate the rental price. Refined rate is already included in the price from rental composition
|
||||
$rentalPrice['alliance'] = $totalPriceMined * ($config[0]->RentalTax / 100.00);
|
||||
$rentalPrice['outofalliance'] = $totalPriceMined * ($config[0]->AllyRentalTax / 100.00);
|
||||
|
||||
//Return the rental price to the caller
|
||||
return $rentalPrice;
|
||||
}
|
||||
|
||||
public function SpatialMoonsOnlyGoo($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
||||
//Always assume a 1 month pull which equates to 5.55m3 per second or 2,592,000 seconds
|
||||
//Total pull size is 14,385,600 m3
|
||||
|
||||
154
app/Library/SRP/SRPHelper.php
Normal file
154
app/Library/SRP/SRPHelper.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\SRP;
|
||||
|
||||
//Internal Libraries
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\SRP\SrpFleetType;
|
||||
use App\Models\SRP\SrpPayout;
|
||||
use App\Models\SRP\SRPShip;
|
||||
use App\Models\SRP\SrpShipType;
|
||||
|
||||
class SRPHelper {
|
||||
|
||||
public function __contruct() {
|
||||
//
|
||||
}
|
||||
|
||||
public function GetLossesByFC($start, $end) {
|
||||
$losses = array();
|
||||
$fcs = null;
|
||||
|
||||
$fcs = SRPShip::whereBetween('created_at', [$start, $end])
|
||||
->pluck('fleet_commander_name')
|
||||
->toArray();
|
||||
|
||||
foreach($fcs as $fc) {
|
||||
$tempLosses = SRPShip::where(['fleet_commander_name' => $fc])
|
||||
->whereBetween('created_at', [$start, $end])
|
||||
->sum('loss_value');
|
||||
|
||||
$losses[$fc] = $tempLosses;
|
||||
}
|
||||
|
||||
return $losses;
|
||||
}
|
||||
|
||||
public function GetUnderReview($start, $end) {
|
||||
$requests = 0.00;
|
||||
|
||||
$requests = SRPShip::where(['approved' => 'Under Review'])
|
||||
->whereBetween('created_at', [$start, $end])
|
||||
->sum('loss_value');
|
||||
|
||||
return $requests;
|
||||
}
|
||||
|
||||
public function GetApprovedValue($start, $end) {
|
||||
$requests = 0.00;
|
||||
|
||||
$requests = SRPShip::where(['approved' => 'Approved'])
|
||||
->whereBetween('created_at', [$start, $end])
|
||||
->sum('paid_value');
|
||||
|
||||
return $requests;
|
||||
}
|
||||
|
||||
public function GetApproved($start, $end, $type) {
|
||||
$requests = 0.00;
|
||||
|
||||
$requests = SRPShip::where(['approved' => 'Approved'])
|
||||
->whereBetween('created_at', [$start, $end])
|
||||
->sum($type);
|
||||
|
||||
return $requests;
|
||||
}
|
||||
|
||||
public function GetDeniedValue($start, $end) {
|
||||
$requests = 0.00;
|
||||
|
||||
$requests = SRPShip::where(['approved' => 'Denied'])
|
||||
->whereBetween('created_at', [$start, $end])
|
||||
->sum('paid_value');
|
||||
|
||||
return $requests;
|
||||
}
|
||||
|
||||
public function GetDenied($start, $end, $type) {
|
||||
$requests = 0.00;
|
||||
|
||||
$requests = SRPShip::where(['approved' => 'Denied'])
|
||||
->whereBetween('created_at', [$start, $end])
|
||||
-sum($type);
|
||||
|
||||
return $requests;
|
||||
}
|
||||
|
||||
public function GetTimeFrame($months) {
|
||||
$start = Carbon::now()->startOfMonth();
|
||||
$start->hour = 23;
|
||||
$start->minute = 59;
|
||||
$start->second = 59;
|
||||
$end = Carbon::now()->subMonths($months);
|
||||
$end->hour = 23;
|
||||
$end->minute = 59;
|
||||
$end->second = 59;
|
||||
|
||||
$date = [
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
];
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of dates from now until the amount of months has passed
|
||||
*
|
||||
* @var integer
|
||||
* @returns array
|
||||
*/
|
||||
public function GetTimeFrameInMonths($months) {
|
||||
//Declare an array of dates
|
||||
$dates = array();
|
||||
//Setup the start of the array as the basis of our start and end dates
|
||||
$start = Carbon::now()->startOfMonth();
|
||||
$end = Carbon::now()->endOfMonth();
|
||||
$end->hour = 23;
|
||||
$end->minute = 59;
|
||||
$end->second = 59;
|
||||
|
||||
if($months == 1) {
|
||||
$dates = [
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
];
|
||||
|
||||
return $dates;
|
||||
}
|
||||
|
||||
//Create an array of dates
|
||||
for($i = 0; $i < $months; $i++) {
|
||||
if($i == 0) {
|
||||
$dates[$i]['start'] = $start;
|
||||
$dates[$i]['end'] = $end;
|
||||
}
|
||||
|
||||
$start = Carbon::now()->startOfMonth()->subMonths($i);
|
||||
$end = Carbon::now()->endOfMonth()->subMonths($i);
|
||||
$end->hour = 23;
|
||||
$end->minute = 59;
|
||||
$end->second = 59;
|
||||
$dates[$i]['start'] = $start;
|
||||
$dates[$i]['end'] = $end;
|
||||
}
|
||||
|
||||
//Return the dates back to the calling function
|
||||
return $dates;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,154 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Structures;
|
||||
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
class JumpBridgeFuel {
|
||||
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $hasScopes;
|
||||
|
||||
public function construct($charId, $corpId) {
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
|
||||
//Set ESI Scopes true or false whether we have the correct ones
|
||||
$esi = new Esi();
|
||||
if($esi->HaveEsiScope($this->charId, 'esi-assets.read_corporation_assets.v1') &&
|
||||
$esi->HaveEsiScope($this->charId, 'esi-corporations.read_structures.v1')) {
|
||||
$this->hasScopes = true;
|
||||
} else {
|
||||
$this->hasScopes = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetCorrrectScopes() {
|
||||
return $this->hasScopes;
|
||||
}
|
||||
|
||||
public function GetStructureFuel() {
|
||||
|
||||
}
|
||||
|
||||
private function GetStructures($charId, $corpId) {
|
||||
//Delcare the data array for returning
|
||||
$data = array();
|
||||
|
||||
//Get a list of structures.
|
||||
$config = config('esi');
|
||||
//Get the token from the database
|
||||
$token = EsiToken::where(['character_id' => $charId])->get(['refresh_token']);
|
||||
//Setup the ESI authentication container
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
|
||||
]);
|
||||
//Setup the ESI authentication container
|
||||
$esi = new Eseye($authentication);
|
||||
|
||||
//set the ESI version we need to work with
|
||||
$esi->setVersion('v3');
|
||||
|
||||
//Set our current page
|
||||
$currentPage = 1;
|
||||
//Set our default total pages, and will refresh this later
|
||||
$totalPages = 1;
|
||||
|
||||
//If more than one page is found, decode the first, then the second
|
||||
do {
|
||||
//Try to gather the structures from ESI
|
||||
try {
|
||||
$structures = $esi->page($currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/structures/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Set the actual total pages after we performed the esi call
|
||||
$totalPages = $structures->pages;
|
||||
|
||||
foreach($structures as $structure) {
|
||||
if($structure->type_id == 35841) {
|
||||
$data = array_push($data, $structure);
|
||||
}
|
||||
}
|
||||
} while ($currentPage < $totalPages);
|
||||
|
||||
//Add structures to a data array for just jump bridge type, and return the data array
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function GetAssets($corpId, $structures) {
|
||||
//Delcare the data array for returning
|
||||
$data = array();
|
||||
|
||||
//Get a list of structures.
|
||||
$config = config('esi');
|
||||
//Get the token from the database
|
||||
$token = EsiToken::where(['character_id' => $charId])->get(['refresh_token']);
|
||||
//Setup the ESI authentication container
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
]);
|
||||
//Setup the ESI authentication container
|
||||
$esi = new Eseye($authentication);
|
||||
|
||||
//set the ESI version we need to work with
|
||||
$esi->setVersion('v3');
|
||||
|
||||
//Set our current page
|
||||
$currentPage = 1;
|
||||
//Set our default total pages, and will refresh this later
|
||||
$totalPages = 1;
|
||||
|
||||
//If more than one page is available we want to get all the pages
|
||||
do {
|
||||
try {
|
||||
//Try to pull the data from ESI
|
||||
$assets = $esi->page($currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/assets/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//If ESI fails, we just return null
|
||||
return null;
|
||||
}
|
||||
|
||||
//Set the total number of pages
|
||||
$totalPages = $assets->pages;
|
||||
|
||||
//For each entry, we only want to save the entries
|
||||
foreach($assets as $asset) {
|
||||
if($asset->type_id == 16273) {
|
||||
//If the type id is correct then push the data onto the array
|
||||
$data = array_push($data, $asset);
|
||||
}
|
||||
}
|
||||
|
||||
} while($currentPage < $totalPages);
|
||||
|
||||
//Return the list of assets, the structure the asset is in, and the division,
|
||||
//to the calling function
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
394
app/Library/Structures/StructureHelper.php
Normal file
394
app/Library/Structures/StructureHelper.php
Normal file
@@ -0,0 +1,394 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*
|
||||
* Finally works in it's current state. Need to move to a job process.
|
||||
*/
|
||||
|
||||
namespace App\Library\Structures;
|
||||
|
||||
//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;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessStructure;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Service;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
|
||||
class StructureHelper {
|
||||
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $page;
|
||||
|
||||
public function __construct($char, $corp) {
|
||||
$this->charId = $char;
|
||||
$this->corpId = $corp;
|
||||
}
|
||||
|
||||
public function GetStructuresByPage($page) {
|
||||
// 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');
|
||||
//Get the refresh token from the database
|
||||
$token = EsiToken::where(['character_id' => $this->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);
|
||||
|
||||
//Try to get the ESI data
|
||||
try {
|
||||
$structures = $esi->page($page)
|
||||
->invoke('get', '/corporations/{corporation_id}/structures/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch (RequestFailedException $e) {
|
||||
Log::critical("Failed to get structure list.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return $structures;
|
||||
}
|
||||
|
||||
public function ProcessStructure($structure) {
|
||||
//Setup the esi authentication container
|
||||
$config = config('esi');
|
||||
//Get the refresh token from the database
|
||||
$token = EsiToken::where(['character_id' => $this->charId])->get(['refresh_token']);
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
]);
|
||||
|
||||
$esi = new Eseye($authentication);
|
||||
|
||||
$info = $this->GetStructureInfo($structure->structure_id);
|
||||
|
||||
//Record the structure information into the database
|
||||
//Find if the structure exists
|
||||
if(Structure::where(['structure_id' => $structure->structure_id])->count() == 0) {
|
||||
$this->SaveNewStructure($structure, $info);
|
||||
} else {
|
||||
$this->UpdateExistingStructure($structure, $info);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function GetSolarSystemName($systemId) {
|
||||
//Setup the esi authentication container
|
||||
$config = config('esi');
|
||||
//Get the refresh token from the database
|
||||
$token = EsiToken::where(['character_id' => $this->charId])->get(['refresh_token']);
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
]);
|
||||
|
||||
$esi = new Eseye($authentication);
|
||||
|
||||
//Attempt to get the solar system name from ESI
|
||||
try {
|
||||
$solar = $esi->invoke('get', '/universe/systems/{system_id}/', [
|
||||
'system_id' => $systemId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
$solar = null;
|
||||
}
|
||||
|
||||
if($solar != null) {
|
||||
return $solar->name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function GetStructureInfo($structureId) {
|
||||
//Setup the esi authentication container
|
||||
$config = config('esi');
|
||||
//Get the refresh token from the database
|
||||
$token = EsiToken::where(['character_id' => $this->charId])->get(['refresh_token']);
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
]);
|
||||
|
||||
$esi = new Eseye($authentication);
|
||||
|
||||
try {
|
||||
$info = $esi->invoke('get', '/universe/structures/{structure_id}/', [
|
||||
'structure_id' => $structureId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning("Failed to get structure information for structure with id " . $structureId);
|
||||
Log::warning($e->getCode());
|
||||
Log::warning($e->getMessage());
|
||||
Log::warning($e->getEsiResponse());
|
||||
$info = null;
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
private function UpdateExistingStructure($structure, $info) {
|
||||
//Update the structure id and name
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'structure_id' => $structure->structure_id,
|
||||
'structure_name' => $info->name,
|
||||
]);
|
||||
|
||||
//Update the services
|
||||
if(isset($structure->services)) {
|
||||
$services = true;
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'services' => $services,
|
||||
]);
|
||||
} else {
|
||||
$services = false;
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'services' => $services,
|
||||
]);
|
||||
}
|
||||
|
||||
//Update the structure state
|
||||
if(isset($structure->state)) {
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'state' => $structure->state,
|
||||
]);
|
||||
} else {
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'state' => 'None',
|
||||
]);
|
||||
}
|
||||
|
||||
//Update the state timer start
|
||||
if(isset($structure->state_timer_start)) {
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'state_timer_start' => $this->DecodeDate($structure->state_timer_start),
|
||||
]);
|
||||
}
|
||||
|
||||
//Update the state timer end
|
||||
if(isset($structure->state_timer_end)) {
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'state_timer_end' => $this->DecodeDate($structure->state_timer_end),
|
||||
]);
|
||||
}
|
||||
|
||||
//Update the fuel expires
|
||||
if(isset($structure->fuel_expires)) {
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'fuel_expires' => $this->DecodeDate($structure->fuel_expires),
|
||||
]);
|
||||
}
|
||||
|
||||
//Update the profile id, and positions
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'profile_id' => $structure->profile_id,
|
||||
'position_x' => $info->position->x,
|
||||
'position_y' => $info->position->y,
|
||||
'position_z' => $info->position->z,
|
||||
]);
|
||||
|
||||
//Update the next reinforce apply
|
||||
if(isset($structure->next_reinforce_apply)) {
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'next_reinforce_apply' => $this->DecodeDate($structure->next_reinforce_apply),
|
||||
]);
|
||||
}
|
||||
|
||||
//update the next reinforce hour
|
||||
if(isset($structure->next_reinforce_hour)) {
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'next_reinforce_hour' => $structure->next_reinforce_hour,
|
||||
]);
|
||||
}
|
||||
|
||||
//Update next reinforce weekday
|
||||
if(isset($structure->next_reinforce_weekday)) {
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'next_reinforce_weekday' => $structure->next_reinforce_weekday,
|
||||
]);
|
||||
}
|
||||
|
||||
//Update reinforce hour
|
||||
if(isset($structure->reinforce_hour)) {
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'reinforce_hour' => $structure->reinforce_hour,
|
||||
]);
|
||||
}
|
||||
|
||||
//Update reinforce weekday
|
||||
if(isset($structure->reinforce_weekday)) {
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'reinforce_weekday' => $structure->reinforce_weekday,
|
||||
]);
|
||||
}
|
||||
|
||||
//Update the unanchors at field
|
||||
if(isset($structure->unanchors_at)) {
|
||||
//Decode the date / time
|
||||
$daTi = $this->DecodeDate($structure->unanchors_at);
|
||||
|
||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||
'unanchors_at' => $daTi,
|
||||
]);
|
||||
}
|
||||
|
||||
//Update the services for the structure as well
|
||||
if($services == true) {
|
||||
//Delete the existing services, then add the new services
|
||||
if(Service::where(['structure_id' => $structure->structure_id])->count() > 0) {
|
||||
Service::where(['structure_id' => $structure->structure_id])->delete();
|
||||
}
|
||||
|
||||
|
||||
foreach($structure->services as $service) {
|
||||
$serv = new Service;
|
||||
$serv->structure_id = $structure->structure_id;
|
||||
$serv->name = $service->name;
|
||||
$serv->state = $service->state;
|
||||
$serv->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function SaveNewStructure($structure, $info) {
|
||||
|
||||
if(isset($info->solar_system_id)) {
|
||||
$solarName = $this->GetSolarSystemName($info->solar_system_id);
|
||||
} else {
|
||||
Log::critical("Couldn't get solar system name for structure " . $structure->structure_id);
|
||||
Log::critical("Check access lists.");
|
||||
$solarName = null;
|
||||
}
|
||||
|
||||
$st = new Structure;
|
||||
$st->structure_id = $structure->structure_id;
|
||||
$st->structure_name = $info->name;
|
||||
$st->corporation_id = $info->owner_id;
|
||||
$st->solar_system_id = $info->solar_system_id;
|
||||
$st->solar_system_name = $solarName;
|
||||
if(isset($info->type_id)) {
|
||||
$st->type_id = $info->type_id;
|
||||
}
|
||||
$st->corporation_id = $structure->corporation_id;
|
||||
if(isset($structure->services)) {
|
||||
$st->services = true;
|
||||
} else {
|
||||
$st->services = false;
|
||||
}
|
||||
if(isset($structure->state)) {
|
||||
$st->state = $structure->state;
|
||||
} else {
|
||||
$st->state = 'None';
|
||||
}
|
||||
if(isset($structure->state_timer_start)) {
|
||||
$st->state_timer_start = $this->DecodeDate($structure->state_timer_start);
|
||||
}
|
||||
if(isset($structure->state_timer_end)) {
|
||||
$st->state_timer_end = $this->DecodeDate($structure->state_timer_end);
|
||||
}
|
||||
if(isset($structure->fuel_expires)) {
|
||||
$st->fuel_expires = $this->DecodeDate($structure->fuel_expires);
|
||||
}
|
||||
$st->profile_id = $structure->profile_id;
|
||||
$st->position_x = $info->position->x;
|
||||
$st->position_y = $info->position->y;
|
||||
$st->position_z = $info->position->z;
|
||||
if(isset($structure->next_reinforce_apply)) {
|
||||
$st->next_reinforce_apply = $this->DecodeDate($structure->next_reinforce_apply);
|
||||
}
|
||||
if(isset($structure->next_reinforce_hour)) {
|
||||
$st->next_reinforce_hour = $structure->next_reinforce_hour;
|
||||
}
|
||||
if(isset($structure->next_reinforce_weekday)) {
|
||||
$st->next_reinforce_weekday = $structure->next_reinforce_weekday;
|
||||
}
|
||||
$st->reinforce_hour = $structure->reinforce_hour;
|
||||
if(isset($structure->reinforce_weekday)) {
|
||||
$st->reinforce_weekday = $structure->reinforce_weekday;
|
||||
}
|
||||
if(isset($structure->unanchors_at)) {
|
||||
$daTi = $this->DecodeDate($structure->unanchors_at);
|
||||
$st->unanchors_at = $daTi;
|
||||
}
|
||||
|
||||
//Save the database record
|
||||
$st->save();
|
||||
|
||||
if($st->services == true) {
|
||||
foreach($structure->services as $service) {
|
||||
$serv = new Service;
|
||||
$serv->structure_id = $structure->structure_id;
|
||||
$serv->name = $service->name;
|
||||
$serv->state = $service->state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function GetStructuresByType($type) {
|
||||
$sType = $this->StructureTypeToId($type);
|
||||
|
||||
$structures = Structure::where([
|
||||
'type_id' => $sType,
|
||||
])->get();
|
||||
|
||||
return $structures;
|
||||
}
|
||||
|
||||
private function StructureTypeToId($name) {
|
||||
$structureTypes = [
|
||||
'Ansiblex Jump Gate' => 35841,
|
||||
'Pharolux Cyno Beacon' => 35840,
|
||||
'Tenebrex Cyno Jammer' => 37534,
|
||||
'Keepstar' => 35834,
|
||||
'Fortizar' => 35833,
|
||||
'Astrahus' => 35832,
|
||||
'Tatara' => 35836,
|
||||
'Athanor' => 35835,
|
||||
'Sotiyo' => 35827,
|
||||
'Azbel' => 35826,
|
||||
'Raitaru' => 35825,
|
||||
];
|
||||
|
||||
return $structureTypes[$name];
|
||||
}
|
||||
|
||||
private function DecodeDate($date) {
|
||||
$esiHelper = new Esi();
|
||||
|
||||
$dateTime = $esiHelper->DecodeDate($date);
|
||||
|
||||
return $dateTime;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,219 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Structures;
|
||||
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\User;
|
||||
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\User\UserPermission;
|
||||
|
||||
use App\Models\Corporation\CorpStructure;
|
||||
use App\Models\Corporation\CorpTaxRatio;
|
||||
|
||||
use App\Models\Finances\CorpMarketJournal;
|
||||
use App\Models\Finances\ReprocessingTaxJournal;
|
||||
use App\Models\Finances\StructureIndustryTaxJournal;
|
||||
|
||||
class StructureTaxHelper {
|
||||
private $corpId;
|
||||
private $refType;
|
||||
private $start;
|
||||
private $end;
|
||||
|
||||
public function __construct($corp = null, $ref = null, $st = null, $en = null) {
|
||||
$this->corpId = $corp;
|
||||
$this->refType = $ref;
|
||||
$this->start = $st;
|
||||
$this->end = $en;
|
||||
}
|
||||
|
||||
public function GetTaxes($corpId, $refType, $start, $end) {
|
||||
$taxOwed = 0.00;
|
||||
//Get the number of structures of a certain type
|
||||
$count = $this->GetStructureCount($corpId, $refType);
|
||||
|
||||
//Calculate the fuel cost for one type of structure
|
||||
$fuelCost = $this->CalculateFuelBlockCost($refType);
|
||||
|
||||
//Get the ratio from the table to be divided against the tax to find the
|
||||
//acutal tax owed to the alliance. Revenue will be a separate function
|
||||
$ratio = CorpTaxRatio::where([
|
||||
'corporation_id' => $corpId,
|
||||
'structure_type' => $refType,
|
||||
])->get(['ratio']);
|
||||
$ratio = $ratio[0]->ratio;
|
||||
|
||||
//Get the total taxes produced by the structure(s) over a given set of dates
|
||||
$revenue = $this->GetRevenue($corpId, $refType, $start, $end);
|
||||
|
||||
//Calculate the total fuel block cost
|
||||
$totalFuelCost = $fuelCost * $count;
|
||||
|
||||
//Calculate the total revenue minus the fuel block cost
|
||||
$totalRevenue = $revenue - $totalFuelCost;
|
||||
|
||||
//Check to see if the revenue is greater than zero to avoid division by zero error.
|
||||
//Then calculate the tax owed which is revenue divided by ratio previously calcualted.
|
||||
if($totalRevenue > 0.00) {
|
||||
$taxOwed = $totalRevenue / $ratio;
|
||||
} else {
|
||||
$taxOwed = 0.00;
|
||||
}
|
||||
|
||||
//Return the amount
|
||||
return $taxOwed;
|
||||
}
|
||||
|
||||
public function GetIndustryRevenue($start, $end) {
|
||||
$revenue = 0.00;
|
||||
|
||||
$revenue = StructureIndustryTaxJournal::where(['ref_type' => 'facility_industry_tax', 'second_party_id' => '98287666'])
|
||||
->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
|
||||
return $revenue;
|
||||
}
|
||||
|
||||
public function GetRevenue($corpId, $refType, $start, $end) {
|
||||
$revenue = 0.00;
|
||||
if($refType == 'Market') {
|
||||
//Get the revenue from the corp_market_journals table and add it up.
|
||||
$revenue = CorpMarketJournal::where(['ref_type' => 'brokers_fee', 'corporation_id' => $corpId, 'second_party_id' => $corpId])
|
||||
->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
} else if($refType == 'Refinery'){
|
||||
//Get the revenue from the reprocessing_tax_journal table and add it up.
|
||||
$revenue = ReprocessingTaxJournal::where(['ref_type' => 'reprocessing_tax', 'corporation_id' => $corpId, 'second_party_id' => $corpId])
|
||||
->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
} else {
|
||||
//If it's not from one of the above tables, then it doesn't mean anything, so return nothing.
|
||||
$revenue = 0.00;
|
||||
}
|
||||
|
||||
return (float)$revenue;
|
||||
}
|
||||
|
||||
private function CalculateTaxRatio($corpId, $overallTax, $type) {
|
||||
//Get the ratio based on what was decided upon for the ratio of taxes.
|
||||
//Default rate is 2.5 ratio.
|
||||
|
||||
|
||||
//The alliance will get a ratio of the tax.
|
||||
//We need to calculate the correct ratio based on structure tax,
|
||||
//Then figure out what is owed to the alliance
|
||||
if($type == 'Market') {
|
||||
$ratioType = 2.5;
|
||||
} else if($type == 'Refinery') {
|
||||
$ratioType = 1.0;
|
||||
} else {
|
||||
$ratioType = 1.0;
|
||||
}
|
||||
//Calculate the ratio since we have the base percentage the alliance takes
|
||||
$taxRatio = $overallTax / $ratioType;
|
||||
|
||||
//Return what is owed to the alliance
|
||||
return $taxRatio;
|
||||
}
|
||||
|
||||
private function CalculateFuelBlockCost($type) {
|
||||
//Calculate how many fuel blocks are used in a month by a structure type
|
||||
if($type === 'Market') {
|
||||
$fuelBlocks = 24*30*32;
|
||||
} else if ($type === 'Refinery') {
|
||||
$fuelBlocks = 24*30*8;
|
||||
} else {
|
||||
$fuelBlocks = 0;
|
||||
}
|
||||
|
||||
//Multiply the amount of fuel blocks used by the structure by 20,000.
|
||||
$cost = $fuelBlocks * 20000;
|
||||
|
||||
//Return to the calling function
|
||||
return $cost;
|
||||
}
|
||||
|
||||
public function GetTimeFrame() {
|
||||
$start = Carbon::now()->startOfMonth();
|
||||
$end = Carbon::now()->endOfMonth();
|
||||
$end->hour = 23;
|
||||
$end->minute = 59;
|
||||
$end->second = 59;
|
||||
$startLast = new Carbon('first day of last month');
|
||||
$endLast = new Carbon('last day of last month');
|
||||
$endLast->hour = 23;
|
||||
$endLast->minute = 59;
|
||||
$endLast->second = 59;
|
||||
|
||||
$dates = [
|
||||
'ThisMonthStart' => $start,
|
||||
'ThisMonthEnd' => $end,
|
||||
'LastMonthStart' => $startLast,
|
||||
'LastMonthEnd' => $endLast,
|
||||
];
|
||||
|
||||
return $dates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of dates from now until the amount of months has passed
|
||||
*
|
||||
* @var integer
|
||||
* @returns array
|
||||
*/
|
||||
public function GetTimeFrameInMonths($months) {
|
||||
//Declare an array of dates
|
||||
$dates = array();
|
||||
//Setup the start of the array as the basis of our start and end dates
|
||||
$start = Carbon::now()->startOfMonth();
|
||||
$end = Carbon::now()->endOfMonth();
|
||||
$end->hour = 23;
|
||||
$end->minute = 59;
|
||||
$end->second = 59;
|
||||
|
||||
if($months == 1) {
|
||||
$dates = [
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
];
|
||||
|
||||
return $dates;
|
||||
}
|
||||
|
||||
//Create an array of dates
|
||||
for($i = 0; $i < $months; $i++) {
|
||||
if($i == 0) {
|
||||
$dates[$i]['start'] = $start;
|
||||
$dates[$i]['end'] = $end;
|
||||
}
|
||||
|
||||
$start = Carbon::now()->startOfMonth()->subMonths($i);
|
||||
$end = Carbon::now()->endOfMonth()->subMonths($i);
|
||||
$end->hour = 23;
|
||||
$end->minute = 59;
|
||||
$end->second = 59;
|
||||
$dates[$i]['start'] = $start;
|
||||
$dates[$i]['end'] = $end;
|
||||
}
|
||||
|
||||
//Return the dates back to the calling function
|
||||
return $dates;
|
||||
}
|
||||
|
||||
private function GetStructureTax($corpId, $structureType) {
|
||||
$tax = CorpStructure::where(['corporation_id' => $corpId, 'structure_type' => $structureType])->avg('tax');
|
||||
|
||||
return (float) $tax;
|
||||
}
|
||||
|
||||
private function GetStructureCount($corpId, $structureType) {
|
||||
$count = CorpStructure::where(['corporation_id' => $corpId, 'structure_type' => $structureType])->count();
|
||||
|
||||
return (int)$count;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -5,8 +5,7 @@ namespace App\Library\Taxes;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\User;
|
||||
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\User\UserPermission;
|
||||
|
||||
@@ -17,6 +16,9 @@ use App\Models\Finances\OfficeFeesJournal;
|
||||
use App\Models\Finances\CorpMarketJournal;
|
||||
use App\Models\Finances\JumpBridgeJournal;
|
||||
use App\Models\Finances\PISaleJournal;
|
||||
use App\Models\Finances\AllianceMarketJournal;
|
||||
use App\Models\Finances\CorpMarketStructure;
|
||||
use App\Models\SRP\SRPShip;
|
||||
|
||||
class TaxesHelper {
|
||||
|
||||
@@ -32,22 +34,59 @@ class TaxesHelper {
|
||||
$this->end = $en;
|
||||
}
|
||||
|
||||
public function GetJumpGateGross($start, $end) {
|
||||
public function GetAllianceSRPActual($start, $end) {
|
||||
$actual = 0.00;
|
||||
|
||||
$actual = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
])->whereBetween('created_at', [$start, $end])
|
||||
->sum('paid_value');
|
||||
|
||||
return $actual;
|
||||
}
|
||||
|
||||
public function GetAllianceSRPLoss($start, $end) {
|
||||
$loss = 0.00;
|
||||
|
||||
$loss = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
])->whereBetween('created_at', [$start, $end])
|
||||
->sum('loss_value');
|
||||
|
||||
return $loss;
|
||||
}
|
||||
|
||||
public function GetAllianceMarketGross($start, $end) {
|
||||
$revenue = 0.00;
|
||||
|
||||
$revenue = JumpBridgeJournal::where(['ref_type' => 'structure_gate_jump', 'second_party_id' => '98287666'])
|
||||
->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
$revenue = AllianceMarketJournal::where([
|
||||
'second_party_id' => '98287666',
|
||||
'ref_type' => 'brokers_fee',
|
||||
])->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
|
||||
return $revenue;
|
||||
}
|
||||
|
||||
public function GetMarketGross($start, $end) {
|
||||
public function GetStructureMarketGross($start, $end, $corpId) {
|
||||
$revenue = 0.00;
|
||||
|
||||
$revenue = CorpMarketJournal::where(['ref_type' => 'brokers_fee', 'second_party_id' => '98287666'])
|
||||
->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
$revenue = CorpMarketJournal::where([
|
||||
'second_party_id' => $corpId,
|
||||
])->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
|
||||
return $revenue;
|
||||
}
|
||||
|
||||
public function GetJumpGateGross($start, $end) {
|
||||
$revenue = 0.00;
|
||||
|
||||
$revenue = JumpBridgeJournal::where([
|
||||
'ref_type' => 'structure_gate_jump',
|
||||
'second_party_id' => '98287666',
|
||||
])->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
|
||||
return $revenue;
|
||||
}
|
||||
@@ -55,9 +94,11 @@ class TaxesHelper {
|
||||
public function GetIndustryGross($start, $end) {
|
||||
$revenue = 0.00;
|
||||
|
||||
$revenue = StructureIndustryTaxJournal::where(['ref_type' => 'industry_job_tax', 'second_party_id' => '98287666'])
|
||||
->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
$revenue = StructureIndustryTaxJournal::where([
|
||||
'ref_type' => 'industry_job_tax',
|
||||
'second_party_id' => '98287666',
|
||||
])->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
|
||||
return $revenue;
|
||||
}
|
||||
@@ -65,9 +106,11 @@ class TaxesHelper {
|
||||
public function GetReprocessingGross($start, $end) {
|
||||
$revenue = 0.00;
|
||||
|
||||
$revenue = ReprocessingTaxJournal::where(['ref_type' => 'reprocessing_tax', 'second_party_id' => '98287666'])
|
||||
->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
$revenue = ReprocessingTaxJournal::where([
|
||||
'ref_type' => 'reprocessing_tax',
|
||||
'second_party_id' => '98287666',
|
||||
])->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
|
||||
return $revenue;
|
||||
}
|
||||
@@ -76,24 +119,35 @@ class TaxesHelper {
|
||||
$revenueImport = 0.00;
|
||||
$revenueExport = 0.00;
|
||||
|
||||
$revenueImport = PlanetProductionTaxJournal::where(['ref_type' => 'planetary_import_tax', 'second_party_id' => '98287666'])
|
||||
->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
$revenueExport = PlanetProductionTaxJournal::where(['ref_type' => 'planetary_export_tax', 'second_party_id' => '98287666'])
|
||||
->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
//Get the import revenue from the database
|
||||
$revenueImport = PlanetProductionTaxJournal::where([
|
||||
'ref_type' => 'planetary_import_tax',
|
||||
'second_party_id' => '98287666',
|
||||
])->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
|
||||
//Get the export revenue from the database
|
||||
$revenueExport = PlanetProductionTaxJournal::where([
|
||||
'ref_type' => 'planetary_export_tax',
|
||||
'second_party_id' => '98287666',
|
||||
])->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
|
||||
//Total up the two values
|
||||
$finalRevenue = $revenueImport + $revenueExport;
|
||||
|
||||
//Return the values
|
||||
return $finalRevenue;
|
||||
}
|
||||
|
||||
public function GetOfficeGross($start, $end) {
|
||||
$revenue = 0.00;
|
||||
|
||||
$revenue = OfficeFeesJournal::where(['ref_type' => 'office_rental_fee', 'second_party_id' => '98287666'])
|
||||
->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
$revenue = OfficeFeesJournal::where([
|
||||
'ref_type' => 'office_rental_fee',
|
||||
'second_party_id' => '98287666',
|
||||
])->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
|
||||
return $revenue;
|
||||
}
|
||||
|
||||
25
app/Models/Charcter/BlacklistUser.php
Normal file
25
app/Models/Charcter/BlacklistUser.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Character;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BlacklistUser extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'blacklisted_characters';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'character_id',
|
||||
'name',
|
||||
'reason',
|
||||
];
|
||||
}
|
||||
43
app/Models/Contracts/EveContract.php
Normal file
43
app/Models/Contracts/EveContract.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Contracts;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EveContract extends Model
|
||||
{
|
||||
//Table name
|
||||
public $table = 'eve_contracts';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'contract_id',
|
||||
'acceptor_id',
|
||||
'assignee_id',
|
||||
'availability',
|
||||
'buyout',
|
||||
'collateral',
|
||||
'date_accepted',
|
||||
'date_completed',
|
||||
'date_expired',
|
||||
'date_issued',
|
||||
'days_to_complete',
|
||||
'end_location_id',
|
||||
'for_corporation',
|
||||
'issuer_corporation_id',
|
||||
'issuer_id',
|
||||
'price',
|
||||
'reward',
|
||||
'start_location_id',
|
||||
'status',
|
||||
'title',
|
||||
'volume',
|
||||
];
|
||||
}
|
||||
@@ -10,4 +10,8 @@ class DokuGroupNames extends Model
|
||||
protected $table = 'wiki_groupnames';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'gname',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -10,4 +10,10 @@ class DokuMember extends Model
|
||||
protected $table = 'wiki_member';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'uid',
|
||||
'gid',
|
||||
'groupname',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -11,4 +11,11 @@ class DokuUser extends Model
|
||||
|
||||
// Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'login',
|
||||
'pass',
|
||||
'name',
|
||||
'mail',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@ class EsiScope extends Model
|
||||
];
|
||||
|
||||
public function user() {
|
||||
return $this->belongsTo('App\User', 'character_id', 'character_id');
|
||||
return $this->belongsTo('App\Models\User\User', 'character_id', 'character_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ class EsiToken extends Model
|
||||
'character_id',
|
||||
'access_token',
|
||||
'refresh_token',
|
||||
'inserted_at',
|
||||
'expires_in',
|
||||
];
|
||||
|
||||
|
||||
41
app/Models/Finances/AllianceMarketJournal.php
Normal file
41
app/Models/Finances/AllianceMarketJournal.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finances;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AllianceMarketJournal extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'alliance_market_journal';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'corporation_id',
|
||||
'division',
|
||||
'amount',
|
||||
'balance',
|
||||
'context_id',
|
||||
'context_id_type',
|
||||
'date',
|
||||
'description',
|
||||
'first_party_id',
|
||||
'reason',
|
||||
'ref_type',
|
||||
'second_party_id',
|
||||
'tax',
|
||||
'tax_receiver_id',
|
||||
];
|
||||
}
|
||||
@@ -1,19 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Corporation;
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CorpTaxRatio extends Model
|
||||
class CorpMarketStructure extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'corp_tax_ratios';
|
||||
//Table Name
|
||||
public $table = 'corp_market_structures';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
@@ -22,9 +18,9 @@ class CorpTaxRatio extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'character_id',
|
||||
'corporation_id',
|
||||
'corporation_name',
|
||||
'structure_type',
|
||||
'tax',
|
||||
'ratio',
|
||||
];
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Fleet;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Fleet extends Model
|
||||
{
|
||||
// Table Name
|
||||
protected $table = 'Fleets';
|
||||
|
||||
// Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
// Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'character_id',
|
||||
'fleet',
|
||||
'description',
|
||||
'creation_time',
|
||||
'time_left',
|
||||
];
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Fleet;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FleetActivity extends Model
|
||||
{
|
||||
// Table Name
|
||||
protected $table = 'fleet_activity_tracking';
|
||||
|
||||
// Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
// Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'fleetId',
|
||||
'character_id',
|
||||
'character_name',
|
||||
'corporation_id',
|
||||
'corporation_name',
|
||||
'region',
|
||||
'system',
|
||||
'ship',
|
||||
'ship_type',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
20
app/Models/Jobs/JobProcessAsset.php
Normal file
20
app/Models/Jobs/JobProcessAsset.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Jobs;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JobProcessAsset extends Model
|
||||
{
|
||||
//no table name is needed
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'charId',
|
||||
'corpId',
|
||||
'page',
|
||||
'esi',
|
||||
];
|
||||
}
|
||||
20
app/Models/Jobs/JobProcessCorpJournal.php
Normal file
20
app/Models/Jobs/JobProcessCorpJournal.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JobProcessCorpJournal extends Model
|
||||
{
|
||||
//No table name is needed
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'division',
|
||||
'charId',
|
||||
'corpId',
|
||||
'page',
|
||||
];
|
||||
}
|
||||
19
app/Models/Jobs/JobProcessEveContracts.php
Normal file
19
app/Models/Jobs/JobProcessEveContracts.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Jobs;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JobProcessContracts extends Model
|
||||
{
|
||||
//No table name is needed
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'charId',
|
||||
'corpId',
|
||||
'page',
|
||||
];
|
||||
}
|
||||
25
app/Models/Jobs/JobProcessStructure.php
Normal file
25
app/Models/Jobs/JobProcessStructure.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Jobs;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JobProcessStructure extends Model
|
||||
{
|
||||
//Table Name - Not Needed for a Job
|
||||
//public $table = null;
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'charId',
|
||||
'corpId',
|
||||
'page',
|
||||
];
|
||||
}
|
||||
@@ -6,9 +6,6 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JobSendEveMail extends Model
|
||||
{
|
||||
//Table Name
|
||||
//protected $table = 'eve_mails';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Corporation;
|
||||
namespace App\Models\Logistics;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CorpStructure extends Model
|
||||
class AnchorStructure extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'CorpStructures';
|
||||
//Table Name
|
||||
public $table = 'alliance_anchor_structure';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
@@ -22,12 +18,13 @@ class CorpStructure extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'character_id',
|
||||
'corporation_id',
|
||||
'corporation_name',
|
||||
'region',
|
||||
'system',
|
||||
'structure_name',
|
||||
'structure_size',
|
||||
'structure_type',
|
||||
'requested_drop_time',
|
||||
'requester_id',
|
||||
'requester',
|
||||
];
|
||||
}
|
||||
27
app/Models/Logistics/LogisticContract.php
Normal file
27
app/Models/Logistics/LogisticContract.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Logistics;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LogisticContract extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'logistics_contracts';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'contract_id',
|
||||
'accepted',
|
||||
'accepted_by_id',
|
||||
'accepted_by_name',
|
||||
'status',
|
||||
];
|
||||
}
|
||||
10
app/Models/Logistics/LogisticsInsuranceDeposit.php
Normal file
10
app/Models/Logistics/LogisticsInsuranceDeposit.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Logistics;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LogisticsInsuranceDeposit extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
10
app/Models/Logistics/LogisticsInsurancePayout.php
Normal file
10
app/Models/Logistics/LogisticsInsurancePayout.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Logistics;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LogisticsInsurancePayout extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
27
app/Models/Logistics/SolarSystemDistance.php
Normal file
27
app/Models/Logistics/SolarSystemDistance.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SolarSystemDistance extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'solar_system_distances';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are fillable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'start_id',
|
||||
'start_name',
|
||||
'end_id',
|
||||
'end_name',
|
||||
'distance',
|
||||
];
|
||||
}
|
||||
30
app/Models/Lookups/AllianceLookup.php
Normal file
30
app/Models/Lookups/AllianceLookup.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Lookups;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AllianceLookup extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'alliance_lookup';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'alliance_id',
|
||||
'creator_corporation_id',
|
||||
'creator_id',
|
||||
'date_founded',
|
||||
'executor_corporation_id',
|
||||
'faction_id',
|
||||
'name',
|
||||
'ticker',
|
||||
];
|
||||
}
|
||||
35
app/Models/Lookups/CharacterLookup.php
Normal file
35
app/Models/Lookups/CharacterLookup.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Lookups;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CharacterLookup extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'character_lookup';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'character_id',
|
||||
'alliance_id',
|
||||
'ancestry_id',
|
||||
'birthday',
|
||||
'bloodline_id',
|
||||
'corporation_id',
|
||||
'description',
|
||||
'faction_id',
|
||||
'gender',
|
||||
'name',
|
||||
'race_id',
|
||||
'security_status',
|
||||
'title',
|
||||
];
|
||||
}
|
||||
37
app/Models/Lookups/CorporationLookup.php
Normal file
37
app/Models/Lookups/CorporationLookup.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Lookups;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CorporationLookup extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'corporation_lookup';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'corporation_id',
|
||||
'alliance_id',
|
||||
'ceo_id',
|
||||
'creator_id',
|
||||
'date_founded',
|
||||
'description',
|
||||
'faction_id',
|
||||
'home_station_id',
|
||||
'member_count',
|
||||
'name',
|
||||
'shares',
|
||||
'tax_rate',
|
||||
'ticker',
|
||||
'url',
|
||||
'war_eligible',
|
||||
];
|
||||
}
|
||||
24
app/Models/Lookups/SolarSystem.php
Normal file
24
app/Models/Lookups/SolarSystem.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Lookups;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SolarSystem extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'solar_systems';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'solar_system_id',
|
||||
];
|
||||
}
|
||||
27
app/Models/Lookups/SolarSystemDistance.php
Normal file
27
app/Models/Lookups/SolarSystemDistance.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SolarSystemDistance extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'solar_system_distances';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'start_id',
|
||||
'start_name',
|
||||
'end_id',
|
||||
'end_name',
|
||||
'distance',
|
||||
];
|
||||
}
|
||||
33
app/Models/SRP/SRPShip.php
Normal file
33
app/Models/SRP/SRPShip.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\SRP;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SRPShip extends Model
|
||||
{
|
||||
//Table Name
|
||||
protected $table = 'srp_ships';
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
//Fillable Items
|
||||
protected $fillable = [
|
||||
'character_id',
|
||||
'character_name',
|
||||
'fleet_commander_name',
|
||||
'fleet_commander_id',
|
||||
'zkillboard',
|
||||
'ship_type',
|
||||
'loss_value',
|
||||
'notes',
|
||||
'approved',
|
||||
'paid_value',
|
||||
'paid_by_id',
|
||||
'paid_by_name',
|
||||
];
|
||||
}
|
||||
17
app/Models/SRP/SrpFleetType.php
Normal file
17
app/Models/SRP/SrpFleetType.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\SRP;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SrpFleetType extends Model
|
||||
{
|
||||
//Table Name
|
||||
protected $table = 'srp_fleet_types';
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
}
|
||||
27
app/Models/SRP/SrpPayout.php
Normal file
27
app/Models/SRP/SrpPayout.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\SRP;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SrpPayout extends Model
|
||||
{
|
||||
//Table Name
|
||||
protected $table = 'srp_payouts';
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
//Fillable
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'payout',
|
||||
];
|
||||
|
||||
public function shipType() {
|
||||
return $this->belongsTo(SrpShipType::class);
|
||||
}
|
||||
}
|
||||
27
app/Models/SRP/SrpShipType.php
Normal file
27
app/Models/SRP/SrpShipType.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\SRP;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SrpShipType extends Model
|
||||
{
|
||||
//Table Name
|
||||
protected $table = 'srp_ship_types';
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
//Fillable
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'description',
|
||||
];
|
||||
|
||||
public function costCode() {
|
||||
return $this->hasOne('App\Models\SRP\SrpPayout', 'code', 'code');
|
||||
}
|
||||
}
|
||||
39
app/Models/Stock/Asset.php
Normal file
39
app/Models/Stock/Asset.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Stock;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Asset extends Model
|
||||
{
|
||||
/**
|
||||
* Required scope:
|
||||
* esi-assets.read_corporation_assets.v1
|
||||
*/
|
||||
|
||||
//Table Name
|
||||
public $table = 'alliance_assets';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'is_blueprint_copy',
|
||||
'is_singleton',
|
||||
'item_id',
|
||||
'location_flag',
|
||||
'location_id',
|
||||
'location_type',
|
||||
'quantity',
|
||||
'type_id',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
28
app/Models/Structure/Service.php
Normal file
28
app/Models/Structure/Service.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Structure;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Service extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'alliance_services';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'structure_id',
|
||||
'name',
|
||||
'state',
|
||||
];
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user