Compare commits
1699 Commits
v0.1-beta
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7660b2aa67 | ||
| ec694c23b5 | |||
| e92a1a5647 | |||
| aaefdb2a59 | |||
| 398b2f5c4f | |||
| c26a23b36c | |||
| 45c2297de7 | |||
| 6fdfc4467e | |||
| 36368fa260 | |||
| 4b875454d8 | |||
| 346fcd746f | |||
| 754fbb9aad | |||
| 66896ab73e | |||
| 5cc9914c38 | |||
| 468cfd8810 | |||
| b2de6fa5cd | |||
| 8cf41c5c36 | |||
| 59c0de75c4 | |||
| 6a26f4bc6e | |||
| d08eaa2da8 | |||
| 9140edb031 | |||
| b71e44bd01 | |||
| 5a2de99035 | |||
| cfbccbf443 | |||
| a5a894e6d6 | |||
| 4fa31759c3 | |||
| 5b92fba23a | |||
| 932c8e1c58 | |||
| 1845ee9d81 | |||
| 762af28ae0 | |||
| cea3c47caf | |||
| e568347ea4 | |||
| 766e6f64f1 | |||
| 472b2b0bc2 | |||
| 2507c5c60e | |||
| d42d0c9d73 | |||
| f2771e2bed | |||
| c56bc9fb9d | |||
| 921632789b | |||
| 7b0da0f96e | |||
| de09e811c6 | |||
| 48042df9d5 | |||
| 3ae603a789 | |||
| 519cca30b5 | |||
| 96e0710d8a | |||
| f88232fdd3 | |||
| 861f3654d2 | |||
| 2d6989ed1c | |||
| dd0fb8eff0 | |||
| 649e9cff13 | |||
| f2b11b038e | |||
| dbf5115c0c | |||
| f349094e10 | |||
| e597ec1b69 | |||
| 8511a6cb41 | |||
| 3f61ad8f99 | |||
| d2fbac3a70 | |||
| f13326f7d3 | |||
| 4bd2d2c3ee | |||
| 5a45af6d40 | |||
| b53610f6fa | |||
| ee4b67c03c | |||
| 445f8a7660 | |||
| 750652c068 | |||
| 67115a2dd8 | |||
| f6034240d8 | |||
| 5a590f7530 | |||
| e005ab6211 | |||
| 6e5a63b3a1 | |||
| 01dd27c088 | |||
| 2883d2a35b | |||
| be6b13a7ae | |||
| 80364a3cbf | |||
| 548d37a14d | |||
| 1f96c3a175 | |||
| 7bdbc95a19 | |||
| 6a4bd749a8 | |||
| 60a0dcc5a2 | |||
| 1b88380e38 | |||
| 81b0634e1b | |||
| b8be6a1bc0 | |||
| 807a567db4 | |||
| 5105246f07 | |||
| 51727bc05b | |||
| 9ba5d665f1 | |||
| b9f814de1e | |||
| f3912bab13 | |||
| 0847be02de | |||
| bb86f32e3a | |||
| 12b97490e3 | |||
| 59d7072ab4 | |||
| 896687f735 | |||
| 8ef67e3087 | |||
| 652d141608 | |||
| 8161b11b38 | |||
| 6890e2580a | |||
| 216f7ad6de | |||
| ae9fbd89c1 | |||
| 51d34b4208 | |||
| abb7e43033 | |||
| 48c5dc4db7 | |||
| a259764743 | |||
| d7dafdaeab | |||
| 7320fe363d | |||
| 603e39ca54 | |||
| 0e616fc86f | |||
| 7b96be5be8 | |||
| 034df21bf4 | |||
| 06dd0669fe | |||
| a2673187d3 | |||
| 943735a7c7 | |||
| 73d27ba44f | |||
| c1d2d897a1 | |||
| 1944f651e5 | |||
| 4b56fb9025 | |||
| e8a077c0df | |||
| a16f72e9ae | |||
| 2b5f89b239 | |||
| fa8775e440 | |||
| 9ff3c46a07 | |||
| 76b4fc559c | |||
| d4032ce27c | |||
| e4171ad06e | |||
| 597e2e80e2 | |||
| 9050d7b612 | |||
| ea1ed80816 | |||
| 2adaf192da | |||
| 01715d5791 | |||
| 37e2a82e92 | |||
| cc1b82c76f | |||
| ee0ba02610 | |||
| e1ce9227c0 | |||
| c6cb7e3b2c | |||
| fc0f2686e6 | |||
| 37b5e6ace4 | |||
| dd6ebb366b | |||
| fd4dcf88a9 | |||
| dab3aa3ca6 | |||
| 233c2f46b8 | |||
| 583ceb1427 | |||
| 22a4d26b87 | |||
| 68a4caa163 | |||
| 5d2e9755ec | |||
| 7788f468f2 | |||
| 18517dcb6d | |||
| 20427231eb | |||
| 1da477236c | |||
| 2b1f35a36f | |||
| 089944622e | |||
| 09a73adb6a | |||
| ff7d88bccf | |||
| b292f3c86c | |||
| a6bda7887f | |||
| f970aa0c5b | |||
| 955662f139 | |||
| 7d6e77a879 | |||
| 3bfbde740b | |||
| 5fb231207f | |||
| fb6c0deff7 | |||
| 98a88d8bf5 | |||
| 06fe3b1cdc | |||
| e630c22843 | |||
| 5a5c10bbee | |||
| b919c9a086 | |||
| a41a025a1a | |||
| b84d6ab58d | |||
| 63f1f93ddd | |||
| 18a1a8cdc6 | |||
| 1c265427a7 | |||
| 4aa9154920 | |||
| 161ee30130 | |||
| a87404a224 | |||
| ac4aea0844 | |||
| 1e47a3cbaf | |||
| c825089886 | |||
| 83490cc7be | |||
| c95b8787c0 | |||
| 62c16e356b | |||
| a5be5a31e6 | |||
| 5d2f7686cc | |||
| cffb3c24f1 | |||
| e80374e618 | |||
| 0ea25686e4 | |||
| 73687d7353 | |||
| f6c689dd6c | |||
| 2960346805 | |||
| 6fdabd7269 | |||
| 4ada4e7f6e | |||
| f464080639 | |||
| c2e8b07de0 | |||
| 6f1e2c7ad9 | |||
| 05691f0d2d | |||
| e5bf5692c1 | |||
| e07956a276 | |||
| 9313112b5e | |||
| 6bbbd388d7 | |||
| 700d3ab5f1 | |||
| b4e20bdc8d | |||
| 0ff2ddbbea | |||
| bec56e4219 | |||
| d57e40a3db | |||
| 27e99bd091 | |||
| 1034822f35 | |||
| 61c7aa77eb | |||
| 12c4640c53 | |||
| 24a4bbecff | |||
| f262e02beb | |||
| 44c1225b21 | |||
| 69b3941776 | |||
| ba4b303554 | |||
| dcbcef9f05 | |||
| 57d229148d | |||
| 1c6b596ba8 | |||
| 6644982444 | |||
| a521fe613c | |||
| e83163ff7c | |||
| a1e356beaf | |||
| 9c3b4ccaf6 | |||
| 2b2d8f98cd | |||
| 822469803d | |||
| 4b169395fb | |||
| b54e718378 | |||
| f0a581eadb | |||
| aabf0ae6c1 | |||
| d61245daf3 | |||
| b5e1c7d100 | |||
| 4ba7812b9b | |||
| 98a6574596 | |||
| 61e051800b | |||
| 77ed3d8f83 | |||
| 8df497b356 | |||
| 2169e0bd1a | |||
| 825cd9a9f0 | |||
| ef280382a8 | |||
| 8e090379cc | |||
| ca06012678 | |||
| 11c5414f44 | |||
| f1dc70b963 | |||
| be59d7100b | |||
| b1786652ae | |||
| f819b0318a | |||
| 70c037d33d | |||
| 7615cb8cf1 | |||
| 6d10755f27 | |||
| ee2160fa8a | |||
| c5c4b7af5d | |||
| 8b4408e6fd | |||
| 0085f7deaf | |||
| 9eae8bfff9 | |||
| f6c1454ed5 | |||
| 7725c32567 | |||
| 3e854da56d | |||
| 5ad0f3448f | |||
| 288ca42ee1 | |||
| 0f2e41a222 | |||
| 0a26a7f3c5 | |||
| 07ad2d5be7 | |||
| a714d2bf21 | |||
| 0c00eb9b2f | |||
| c5b3fb5c86 | |||
| feab4dd020 | |||
| a461e62bf8 | |||
| 7368c137cc | |||
| 5b131567f7 | |||
| f437a4128b | |||
| 8962883e69 | |||
| 9b465eb45f | |||
| 96211eef3a | |||
| ea875b05a7 | |||
| a55a99e5bb | |||
| 0df2cea80c | |||
| 9588b0ee34 | |||
| 4299ec13da | |||
| fb44225163 | |||
| f34da4ff5d | |||
| 30595d6c08 | |||
| ae3147cec8 | |||
| 3f99f327f6 | |||
| 188ef7bff5 | |||
| ff8b19c75b | |||
| 88697d30c5 | |||
| 34448d56d2 | |||
| 3de3e992f7 | |||
| 7f1da17750 | |||
| 18500aa23f | |||
| 282bffa140 | |||
| 517d7aa868 | |||
| e1c63db7a3 | |||
| b571781578 | |||
| 4ae8a747b4 | |||
| 91d46fe0a7 | |||
| bc3a3e2f03 | |||
| 38e636c779 | |||
| 543b5be1c7 | |||
| 3292b369de | |||
| b9044b077f | |||
| cfe58f07a9 | |||
| 10254bfd6b | |||
| 842ae29199 | |||
| 358a99a8fb | |||
| 6ffcb83e1e | |||
| a2c8c14ef9 | |||
| c2ab369601 | |||
| 39caf1417e | |||
| 1723fc7258 | |||
| 5a03fc639b | |||
| 9641df10a7 | |||
| 92e8a12f81 | |||
| b91d477c26 | |||
| 39f215bea9 | |||
| 7c5ebac3d6 | |||
| a2e8ea4ffd | |||
| efb53579a8 | |||
| fc57039c00 | |||
| 17eced109d | |||
| 34ca85a72e | |||
| f0060c8442 | |||
| 6589486eca | |||
| 5a936d8364 | |||
| 602b85fcfd | |||
| 4a0f0d7c99 | |||
| 0a6f1d8f73 | |||
| 8c2008891f | |||
| 98bda601c5 | |||
| 22eadc832c | |||
| 577bb0e299 | |||
| 01f2049399 | |||
| 2981262277 | |||
| 94adec97b2 | |||
| 4652e293b1 | |||
| 9c4d0bc46f | |||
| c9dc812ff6 | |||
| 6b33141962 | |||
| b4c5db6b79 | |||
| 33dec64955 | |||
| 84627eb0a6 | |||
| ef61dae0f1 | |||
| dd5a26b959 | |||
| 49f513f025 | |||
| f183738a62 | |||
| 7bf659c2f5 | |||
| 0c18935f20 | |||
| 66438d574e | |||
| 5217bb52ad | |||
| bea1b222ae | |||
| 0013a92f6f | |||
| 4557632b97 | |||
| e7029952c0 | |||
| ca04aa5e12 | |||
| 96dbf70e59 | |||
| 87a0d82980 | |||
| 35f911b6d6 | |||
| d911bc32d0 | |||
| cb39026564 | |||
| e19157a60c | |||
| c2a5858967 | |||
| af6b1d198d | |||
| 75dfaa21da | |||
| b8d46e1b26 | |||
| f0df3d577a | |||
| dc1220f443 | |||
| 384a875945 | |||
| 0f7c290cb6 | |||
| 940892b3ab | |||
| a70e5b7e62 | |||
| 018d1d73ec | |||
| ba1b9e8b01 | |||
| c41e6f54b8 | |||
| d78661cf02 | |||
| f2f427cce6 | |||
| c5283cfecd | |||
| a3e940fd79 | |||
| 203b2085ef | |||
| 12b6f0120b | |||
| e2a3794016 | |||
| 34d0e062f3 | |||
| c8bca6d0de | |||
| 1db723de19 | |||
| ab7e91e06d | |||
| 50748ebdc9 | |||
| b3d708de0d | |||
| 09cf7b46dd | |||
| 52ebcf0041 | |||
| f1c3544fd2 | |||
| bc93af2cae | |||
| d14c097e30 | |||
| 2fcbfb3cd3 | |||
| 456d05fdcb | |||
| 8072046773 | |||
| cb58fb6af5 | |||
| f8d16ddaaa | |||
| b78ce01f57 | |||
| 6e7e4cd8f5 | |||
| 8c199d8ee8 | |||
| 9f3f4030dc | |||
| 40b4cc0f63 | |||
| 4cdff38675 | |||
| 76f54226de | |||
| 2c62f3018e | |||
| afe989f0e5 | |||
| cf357d9a5b | |||
| 0f3b8652ef | |||
| 42edfa8aa8 | |||
| 013fa36513 | |||
| 154d97c441 | |||
| a345b0a37e | |||
| 67c864a357 | |||
| e36348b039 | |||
| 62eda6a8e5 | |||
| a22f5a1349 | |||
| 149e6472f3 | |||
| 0da53b41c3 | |||
| 1a91302ac8 | |||
| 96bbb1afc3 | |||
| b329e3a089 | |||
| e2e15a6877 | |||
| 088812a7eb | |||
| 4ebb9a7a3f | |||
| 6db126e1f5 | |||
| 8ced378e34 | |||
| adb52cd062 | |||
| 942adcc721 | |||
| d8fce0c18f | |||
| 727bd30f84 | |||
| aac90b4be8 | |||
| f9e69bfd24 | |||
| c96991739f | |||
| 5c17e25e47 | |||
| 8944219804 | |||
| 4ec22e1917 | |||
| a3762a90ed | |||
| e827571eeb | |||
| d4f2834b75 | |||
| a2c47b87b9 | |||
| f199d633b1 | |||
| cd53f8515a | |||
| 86a519eeaa | |||
| 37f9b2a6e7 | |||
| d7fdfab9f1 | |||
| caaaa85354 | |||
| 52c93c9616 | |||
| ed81bc72ef | |||
| e72b06249e | |||
| 5e397c06c6 | |||
| 4f4cb8ee39 | |||
| 5ae722b6a4 | |||
| 84991d26a5 | |||
| 6f1bd0538a | |||
| 14880a54bb | |||
| fac1da9a06 | |||
| 24f3751ab0 | |||
| d76b8c965a | |||
| 1f2686ed28 | |||
| 4215dea758 | |||
| ccf89919f1 | |||
| 0184eebcd2 | |||
| fa839e6046 | |||
| bcafa912f0 | |||
| cfc18d8ee2 | |||
| 7bf0c61066 | |||
| ed4daeda4f | |||
| 7a503e642a | |||
| acbe6b6868 | |||
| 413388e7b4 | |||
| 50c9e85b01 | |||
| 06256f223c | |||
| ad421a809a | |||
| 7dbaa41389 | |||
| c1e0eb1b36 | |||
| 8ea488209c | |||
| 026f9b6a1d | |||
| 606348f5db | |||
| a52d0453bb | |||
| 2e396f4ec7 | |||
| 3418cc6c90 | |||
| 9b76f90725 | |||
| 393a3c5842 | |||
| 9d75415ebd | |||
| 60c0cf82d9 | |||
| d9dc35b543 | |||
| b9255b90ba | |||
| 875b3ca090 | |||
| 6474d7b9c2 | |||
| 7a9f7c4c44 | |||
| 19d000d3d0 | |||
| 9fc4751e8b | |||
| 61be896b08 | |||
| 3f782dfc36 | |||
| d6e0b6715c | |||
| d09edd0e49 | |||
| 464a32bf2a | |||
| a6df57f087 | |||
| f9960cc15e | |||
| a31a7383a4 | |||
| c90a352dee | |||
| 6a270146b7 | |||
| d8a7ae1748 | |||
| 4d54225434 | |||
| 3c59ac6708 | |||
| c166eac472 | |||
| f70e8ded6f | |||
| bee4b637b9 | |||
| 7e7c3dc217 | |||
| 74d1c96ca6 | |||
| a2d7747ed8 | |||
| 2d6108d7a8 | |||
| cf3b444a87 | |||
| 7f54d992ea | |||
| 85da1351d1 | |||
| 16f94aac77 | |||
| 5fbea70f92 | |||
| efe499456a | |||
| 0721850bd7 | |||
| 466febeb13 | |||
| 1f2d68600b | |||
| e54a2c1c5f | |||
| d38bd692af | |||
| eaa7281374 | |||
| 38947493a1 | |||
| f27e24e746 | |||
| dc042d982c | |||
| c0b1db3ea1 | |||
| ee631b5e5e | |||
| 8fecd0ab7c | |||
| e332d4e55d | |||
| 2367438d2e | |||
| 1fd0103a43 | |||
| 55cba30f17 | |||
| 3af4db41ac | |||
| dee4e0d751 | |||
| 0b587aaec6 | |||
| 5261645c40 | |||
| e6a15c04c8 | |||
| 3b04fff2c8 | |||
| fcfff0be06 | |||
| add7f637ee | |||
| d4b64055d0 | |||
| dbfdc41029 | |||
| 22d5d4692d | |||
| 896b3bb13a | |||
| 120e9b6304 | |||
| 7d31230870 | |||
| 332c093820 | |||
| eabf2373fb | |||
| 35de697cde | |||
| 24fc7cf3e2 | |||
| cdd9bd53ae | |||
| 4dd667bcb2 | |||
| 7056d40449 | |||
| 6bf2a1d733 | |||
| de8da1ab15 | |||
| 685e38818b | |||
| 9fb6ce40ba | |||
| b2fb22a890 | |||
| 4be9e32e8a | |||
| 567e303394 | |||
| db5b4085ca | |||
| 25c77a8ee0 | |||
| 30333873ca | |||
| 523bbf013f | |||
| 0cedb506c9 | |||
| 9aeaa0231a | |||
| d4b2d3f05b | |||
| 2de8d78094 | |||
| af3da4d5a0 | |||
| 5686665255 | |||
| a257bd79b5 | |||
| fff53c312b | |||
| 770994cf22 | |||
| 88964a36dc | |||
| dbb6d57d7c | |||
| 7ac12d3278 | |||
| 65ef5695d5 | |||
| 00513e1eef | |||
| 472fd7f49f | |||
| 0162ee44ef | |||
| 0721e41d5a | |||
| 499a0dfbd8 | |||
| cb39cda33e | |||
| e0f1aefa73 | |||
| 6a6100f11f | |||
| 1a40c9038b | |||
| 18ca40fac7 | |||
| c630cd0e59 | |||
| 297f041a0e | |||
| 308164f7f4 | |||
| 29c1986204 | |||
| 95e58ab6d1 | |||
| 42c70759d0 | |||
| 8055e5ee60 | |||
| 4462e13533 | |||
| a210eb5e81 | |||
| dd8f85a356 | |||
| b3db5ab69f | |||
| e7a7bd32ef | |||
| 9c36a10864 | |||
| 766236a78c | |||
| 98669eae02 | |||
| de9c20ac58 | |||
| 1ae5a6fcec | |||
| f852eb5631 | |||
| 1956a1db11 | |||
| 4ceff1c046 | |||
| 91f9b318ad | |||
| 5205184d6e | |||
| 15139add20 | |||
| d20f59313d | |||
| 5307758ebe | |||
| 5ded4dc3a3 | |||
| 87f405d57e | |||
| 3bb922955e | |||
| 04b58ece21 | |||
| afb145aac1 | |||
| ed419ada89 | |||
| fff6bdd624 | |||
| c56264b130 | |||
| 92f1de9155 | |||
| 826294b438 | |||
| 198c338892 | |||
| 36cbac5070 | |||
| 733841cfc1 | |||
| 3484ebf04e | |||
| b50a9b5406 | |||
| 21a85add82 | |||
| e6173a7f17 | |||
| 89f614fe77 | |||
| ac65d8423b | |||
| c8fe6053cf | |||
| 86993f455c | |||
| 502aa59192 | |||
| e209a2bdc5 | |||
| a3d3a2649d | |||
| 336077d24d | |||
| 487187cbb5 | |||
| 8c1061f34d | |||
| 2fecc22822 | |||
| b45b11f927 | |||
| 32cfb6b93c | |||
| 4848ef379a | |||
| a52b17985e | |||
| 8c87e1433c | |||
| 1a6577539f | |||
| 7a5da1e4c2 | |||
| 9b71df8ee4 | |||
| c201578191 | |||
| a1ced2ace6 | |||
| 9e47568e67 | |||
| 55225fdea3 | |||
| 8447319514 | |||
| a2b54aee0f | |||
| 99c736660d | |||
| 4e97b0964f | |||
| 2f404bee72 | |||
| 581fb45795 | |||
| afa2a45fe9 | |||
| dae302f6e3 | |||
| 583769ff5f | |||
| 2d1c6e5ed4 | |||
| 90ae3117ab | |||
| e7d98028a3 | |||
| 2e785222e9 | |||
| 4c9bc24ac7 | |||
| 7498657419 | |||
| b24b0e553d | |||
| 3ccee32232 | |||
| cdabb5772d | |||
| 5ca78942d1 | |||
| 485d2b01e3 | |||
| 1748dad9ea | |||
| 6d38990fd3 | |||
| f0255af222 | |||
| 0a2e94d3d7 | |||
| 241a73c2d0 | |||
| 738b916ab5 | |||
| 7189773694 | |||
| 7e626a2ad1 | |||
| 93a1f568c8 | |||
| 34da40dc59 | |||
| f0395fa6a9 | |||
| 3ca9dcbb88 | |||
| 0204f19541 | |||
| eea884e11a | |||
| cf55c4809c | |||
| ea9a2776b7 | |||
| ec95c84d87 | |||
| 677469e112 | |||
| c0237ab13c | |||
| 90c6c629d3 | |||
| 525b34d28c | |||
| b137c41d7a | |||
| 8e72fbdc0e | |||
| b14301711b | |||
| 3d4dd88c07 | |||
| 2b2db423a0 | |||
| 8087102482 | |||
| 5ccd44de5d | |||
| 389c0bcd9a | |||
| c9a99eecc1 | |||
| 8c4851b831 | |||
| ce75c5ee47 | |||
| f4be75e116 | |||
| a3dc388abb | |||
| d700910cfd | |||
| e9adf4fa4b | |||
| 0f4cd267f2 | |||
| 4fc5b437ae | |||
| 5635fbf57b | |||
| a2b6a9198f | |||
| b064f73b12 | |||
| 82580edb8c | |||
| 3cbb3bd26f | |||
| 31104d7f62 | |||
| bea6cac46b | |||
| 479492726a | |||
| 957c947929 | |||
| b042286edb | |||
| 8459660d90 | |||
| 45763a4223 | |||
| 8b1093d552 | |||
| b341801e16 | |||
| 153e17ee4a | |||
| b642ab0379 | |||
| 69121d25f3 | |||
| b317fce919 | |||
| a538c3cf9b | |||
| d95b3ba9f7 | |||
| fde6190226 | |||
| bb1d986113 | |||
| ebb3789d51 | |||
| 43b5f579c3 | |||
| 9ef5ff1dac | |||
| d41d678df3 | |||
| 3c43289e98 | |||
| b78675718d | |||
| 5038eed34e | |||
| fbfb79c328 | |||
| de14043c5c | |||
| eb0d1364b8 | |||
| ddcd082fee | |||
| eef64b414e | |||
| 410f28a4c3 | |||
| 4918e49b3f | |||
| f2212f5e9d | |||
| 52937d4d51 | |||
| 67b9f10156 | |||
| 11c9bd6a32 | |||
| 0ab18c9ebe | |||
| 6e12870182 | |||
| aaab8310b8 | |||
| 829eb8428d | |||
| 9c927e025d | |||
| 43e5ca50a6 | |||
| b5da5dbde6 | |||
| 75c3f2a522 | |||
| 4932d4d8e7 | |||
| c5d7c2b05a | |||
| 54cd34d0b9 | |||
| cd5d844d25 | |||
| 790fc6a042 | |||
| d16e028276 | |||
| 6b3df0e5bd | |||
| 321991b4b8 | |||
| f33d1b5407 | |||
| eab7ac809d | |||
| 61bd162177 | |||
| 2677bc6eb7 | |||
| 4b3f4e84a7 | |||
| 18239d4b79 | |||
| 5f6c8f4085 | |||
| 0f59440ce4 | |||
| c11b774c63 | |||
| cd86a66b0e | |||
| c400f78398 | |||
| d3d06806a3 | |||
| 8c8ff49513 | |||
| b7bdd265c6 | |||
| a5fdc49548 | |||
| 9c8e38e469 | |||
| 3115ab75a5 | |||
| fa199eef05 | |||
| c65653ef1e | |||
| 0fb0cca948 | |||
| 10acc10a16 | |||
| 3a40a92573 | |||
| 17e4ee9603 | |||
| 2c8bc106fb | |||
| 0cb3698fe6 | |||
| 9928727bd7 | |||
| 2455899373 | |||
| 8d0736e54c | |||
| 096378bdd3 | |||
| 863c7080d3 | |||
| 09ea2a5511 | |||
| 77dd47c435 | |||
| a7dd4f3c20 | |||
| 6ea342d983 | |||
| d59b35df11 | |||
| 5bb4068dbc | |||
| 4dba3fa998 | |||
| ca69b278c2 | |||
| 245a73b5b0 | |||
| 66e52c52bd | |||
| b18b68d124 | |||
| 04faa42987 | |||
| 93db789a0f | |||
| f48f75ab79 | |||
| 088488bb3a | |||
| 8cacabf1c9 | |||
| e3e9d39858 | |||
| c980326a4e | |||
| e203f6e0d5 | |||
| 1922c88306 | |||
| dc8179a23a | |||
| 28b9f0734a | |||
| 6a38286d45 | |||
| 6afd6f4f4f | |||
| 0c3e22e17d | |||
| ea4a58095d | |||
| 9ad3a2ea33 | |||
| d59e35ac86 | |||
| e2ba9d29ee | |||
| b037372619 | |||
| 22637f9d34 | |||
| e0128f2e6b | |||
| 1b0c301452 | |||
| 86ad4be8d0 | |||
| 8159810613 | |||
| efc4c4e5bd | |||
| 390208ecd4 | |||
| 054935a95d | |||
| c0c8b6fb32 | |||
| da8834fe96 | |||
| ae93aeb070 | |||
| c369c3487f | |||
| 3531140a13 | |||
| 0dc04a4901 | |||
| 5a7176c493 | |||
| 87a160fb58 | |||
| 4d86c77ced | |||
| 8c972a140b | |||
| a19a756750 | |||
| 5542c6ea11 | |||
| b8b1dad2de | |||
| cfaebed0fe | |||
| 9619fde4ed | |||
| d47b7c9f1c | |||
| 7eee0b66c6 | |||
| 92109f91fd | |||
| c0ba6415e2 | |||
| 32e2a40592 | |||
| 9d40ca26e0 | |||
| 632457ff3a | |||
| 550a6a5d7b | |||
| 9fa08f77bd | |||
| 52705775ce | |||
| ac14c6fa13 | |||
| 1ec7760d12 | |||
| 2dabefa2e1 | |||
| 43fb5573f4 | |||
| c410c05c82 | |||
| 37b99b8146 | |||
| 41228bc857 | |||
| 5566409ffa | |||
| 813cb7de13 | |||
| 490e215971 | |||
| f9e6b84fd9 | |||
| 36b977a53e | |||
| 087fe8e50f | |||
| 2d683bfcd2 | |||
| 113a446cd6 | |||
| 4e2ff481f5 | |||
| 70e2c022bb | |||
| a9105b05eb | |||
| 02b57d226a | |||
| 062901dbe8 | |||
| 4b280e3a91 | |||
| cc5b8576f6 | |||
| a87786d223 | |||
| 562826f0e1 | |||
| 3e1eace056 | |||
| cc4f921fd6 | |||
| e76794172d | |||
| d3f8389cfb | |||
| 31420ed236 | |||
| 17c0ca97ae | |||
| 3257389188 | |||
| 0862183467 | |||
| 4ef0f1ce91 | |||
| 79caad0d54 | |||
| dc2522ab7c | |||
| 324a3ca7da | |||
| a7d3bbb858 | |||
| b153607e32 | |||
| 6ac2db146e | |||
| fddf85e7a6 | |||
| 2ea19ad84d | |||
| 1cfb33ce42 | |||
| 83377eda4a | |||
| ae87e5b01b | |||
| fa4f642498 | |||
| 4220d1c5e3 | |||
| f50e1ddaa2 | |||
| 9f6af14b76 | |||
| 742189907c | |||
| 94041e307d | |||
| 8a8b5cef7a | |||
| c25850ec3a | |||
| 414eca717c | |||
| 3e30c3ae92 | |||
| 80052803cc | |||
| fba2459052 | |||
| 966e8f94d8 | |||
| aeb7bfc2e4 | |||
| 8fed630c0b | |||
| 403c05d061 | |||
| cdd70ee3fa | |||
| 289b6859b6 | |||
| b9f4678d70 | |||
| 960435f874 | |||
| 48d5304f0b | |||
| 918645b05e | |||
| e781554059 | |||
| 9cb42d38cb | |||
| 324311b767 | |||
| 6356de7cf2 | |||
| 76b1fa3775 | |||
| 6980865015 | |||
| d7696e83d6 | |||
| b9984b7236 | |||
| ad43ecbc84 | |||
| fbc6df6f87 | |||
| 87ecbb9407 | |||
| 3712ae9395 | |||
| a6e1b4cccc | |||
| 64d323570c | |||
| 9e98025f24 | |||
| 6c040538f5 | |||
| 0d4ae999d2 | |||
| 4be3f9b33d | |||
| 0c768874ae | |||
| 337ee3ec2c | |||
| b9fa079eb7 | |||
| 85295cb03f | |||
| 3ee138d81d | |||
| 4218731441 | |||
| ba3419d692 | |||
| a6d3e7855b | |||
| e047cfbbf4 | |||
| aaa721447a | |||
| 004eb146bf | |||
| cf300efdaa | |||
| 750333990d | |||
| 036d98a169 | |||
| 02e7f738fc | |||
| 26f5f854be | |||
| 41f9ebf886 | |||
| 53945b0846 | |||
| fd9fda9f47 | |||
| 0328f969dc | |||
| a6cfc6b011 | |||
| 4997560046 | |||
| d770a4866a | |||
| 16e7244065 | |||
| c45766f2d9 | |||
| 4f5c2ef090 | |||
| 7c99a9c67c | |||
| 5b1e580a4f | |||
| 6d312ba589 | |||
| ac22a31427 | |||
| 368906787c | |||
| 7ace3b7d91 | |||
| 6bf3149bea | |||
| a275c608a4 | |||
| 41d433b7c8 | |||
| 7950d7d5ea | |||
| 97801653fe | |||
| 9099997b2c | |||
| 7f02874923 | |||
| 84d02f8ec4 | |||
| a897d095cf | |||
| 2d9a6ab24e | |||
| f671c5a958 | |||
| 8fcf31a349 | |||
| ddb99a311f | |||
| eef6bde7fe | |||
| 8ceea4b491 | |||
| dfc5337b06 | |||
| 396d02e7a3 | |||
| 4701abc691 | |||
| 7d78c0532b | |||
| b65d00c8b4 | |||
| 70f1f5d2a8 | |||
| abe870ece1 | |||
| 7a2701d72d | |||
| b09f48ccdc | |||
| 9192ffa63f | |||
| e6b05806f0 | |||
| 7698a02a31 | |||
| 6e3c51cd97 | |||
| 27ff27a057 | |||
| 00094f8850 | |||
| 6c6321aa03 | |||
| 8cd1f1bcc7 | |||
| c9e1d090ff | |||
| c47917efc4 | |||
| 84824d1ada | |||
| 15e8d7fb6c | |||
| 00424b2384 | |||
| 09ea177d89 | |||
| d58aebf7f6 | |||
| c0506f87f7 | |||
| ec4fc33137 | |||
| 73613d901f | |||
| 1c579bd6e7 | |||
| 937300fad3 | |||
| f9b16e7671 | |||
| d7d865a6c9 | |||
| 489f3603de | |||
| 6f355d2859 | |||
| ad1b690fe1 | |||
| b5920bfc6e | |||
| ca9ae4ca6b | |||
| e5b6ff8301 | |||
| 90db71b2e3 | |||
| 59808c1374 | |||
| ad22fea86d | |||
| d13ab10d4d | |||
| 4b7feb9b5b | |||
| e899dad637 | |||
| 8502a22ffa | |||
| 742735ea39 | |||
| ac56b3e432 | |||
| b7666c1dc8 | |||
| 90020f8152 | |||
| 45615e8f75 | |||
| f61e4d1964 | |||
| a16f225746 | |||
| 7fe19b8c26 | |||
| 5c4aecab55 | |||
| f366bd56b9 | |||
| 171c35d23c | |||
| 53d9453e8b | |||
| 522e75cea6 | |||
| 3164b1a879 | |||
| 2c13fbaca4 | |||
| 9a4abe0da2 | |||
| cc28e24e02 | |||
| 943fd3d174 | |||
| edeb09ffc6 | |||
| 1dc0b4e2af | |||
| f698ba4e38 | |||
| 9401f80108 | |||
| 5dcd19c681 | |||
| 0a41760a24 | |||
| 0069b7639b | |||
| 85191ed0b2 | |||
| f8f8a50418 | |||
| a6a9ddfa02 | |||
| 1558e78b2b | |||
| bcf16ad669 | |||
| 6f13d9c0ae | |||
| 935b7b3ef1 | |||
| 66d6928e4d | |||
| 78cd3abe15 | |||
| cb793fee58 | |||
| d677d52274 | |||
| 551cbf0049 | |||
| ed1355bb4f | |||
| 92d3810a2b | |||
| 49c6c3767f | |||
| e5131bf9f7 | |||
| e6d8a7cb87 | |||
| 772d091425 | |||
| 9d524b07ec | |||
| 37cb24c46e | |||
| c9fc3113a2 | |||
| 7159e3d336 | |||
| b2e9301cc6 | |||
| 460b2c947e | |||
| 92369f9165 | |||
| 119a6eaa17 | |||
| 7f49fbc107 | |||
| 9e198c3102 | |||
| 9ac70f9dfd | |||
| 7ab25c0207 | |||
| 60e0bc52e6 | |||
| 71c3b530cb | |||
| e5771980ba | |||
| d7d30d30f5 | |||
| 6a67df768a | |||
| 9c8cd51b18 | |||
| cb9447ed5b | |||
| be2c8efbf6 | |||
| 79a89c22b9 | |||
| f48171b11a | |||
| 9b8b2fcba7 | |||
| 51c9d85aef | |||
| db45c71636 | |||
| 73034f2f74 | |||
| 0deae9e495 | |||
| 30be401b30 | |||
| 0bb0ae7888 | |||
| d81ca33b0a | |||
| f194d91d90 | |||
| aa86effe5d | |||
| d5b47d1beb | |||
| 16df3e3238 | |||
| 84303b93d2 | |||
| 5521abbf95 | |||
| 77d490c9c3 | |||
| d9de481c39 | |||
| ccd12b57ed | |||
| 2d9a9ab046 | |||
| f5b59a7a22 | |||
| a212b15068 | |||
| 24d578d392 | |||
| 669b599707 | |||
| f0cb91a21f | |||
| 5645ca17e8 | |||
| 12cffcc75d | |||
| 2b5451d3ce | |||
| 1d209c5be9 | |||
| 48d38ff110 | |||
| 06bcaac67d | |||
| 86c8adc3d9 | |||
| 1c67419483 | |||
| 1516e27c5a | |||
| f71a835d1b | |||
| 42b283e956 | |||
| b30a5eeed6 | |||
| 9f9a190cc9 | |||
| b2bd070c9c | |||
| c029cd8cc6 | |||
| 860cea2369 | |||
| d1b132d267 | |||
| a3892b183e | |||
| 94cce31f47 | |||
| 92b79b124f | |||
| b76e0aae32 | |||
| ce18606949 | |||
| e8ec110ecd | |||
| 1594536d01 | |||
| 37d05afd24 | |||
| 746257b831 | |||
| cadef48cb5 | |||
| c26dbba312 | |||
| 3b6eab2b46 | |||
| 0bb0e9d037 | |||
| dc36be558c | |||
| 699af576e3 | |||
| 207b32e600 | |||
| 5b2c692d95 | |||
| 6e9a13b44e | |||
| 22a62ab082 | |||
| 01d3e44d95 | |||
| 3e83a041e9 | |||
| a00332328b | |||
| 4a38bc2fee | |||
| 7eceef4818 | |||
| 88daa2b01a | |||
| dbd92a9df9 | |||
| 366e293e9f | |||
| 5222413c57 | |||
| ead25a3533 | |||
| dac296f8b9 | |||
| 098c1585a1 | |||
| 27c1e0f1c1 | |||
| ec8d5d774f | |||
| e9d0a8a9df | |||
| d19202de9b | |||
| c27a157ebb | |||
| ec7c02db77 | |||
| 0b752a7886 | |||
| 7742b7ba1a | |||
| ff545f4dbc | |||
| 2e7369ee51 | |||
| 2f68ef43da | |||
| fd747d49fb | |||
| 5b80258418 | |||
| 5b1110a3ed | |||
| 9664cb239e | |||
| 24cf162f9b | |||
| af08d5c239 | |||
| dc3d536f0b | |||
| dafebfadc5 | |||
| cb10515c13 | |||
| 156783af7c | |||
| 46c526a515 | |||
| 8724d60d60 | |||
| 2c4e25be59 | |||
| 952d6e83e3 | |||
| 6334865d3f | |||
| d894216c54 | |||
| b9e89e3ffb | |||
| c385228d73 | |||
| 5fcb71dfd1 | |||
| 8322858e20 | |||
| 4e9a289692 | |||
| a097138299 | |||
| 8a53f53d99 | |||
| f0543da790 | |||
| 472c22fcfb | |||
| eb2f2f86f0 | |||
| 72147c7edf | |||
| 2a360d32a6 | |||
| 2eaea8ee26 | |||
| 254562f940 | |||
| fa4367e8d9 | |||
| 0820aa5675 | |||
| 7f13150557 | |||
| a0a4fd136f | |||
| 6c3402fa8d | |||
| eb1ca9d7b1 | |||
| f7d2a5f23b | |||
| abc9364afb | |||
| e027147c99 | |||
| ce2fc54e66 | |||
| a8e39e3125 | |||
| 821e4d7a87 | |||
| 6404c2d99f | |||
| a6be5844e6 | |||
| e40fedb812 | |||
| 09c5091d1c | |||
| 727100f942 | |||
| 574a95fd14 | |||
| 10a00750d7 | |||
| 0b40903ae3 | |||
| 556b62065a | |||
| 51c926c20b | |||
| 96e5c0120e | |||
| 4bebbc204e | |||
| 51912bf3a8 | |||
| 9c4b23905d | |||
| 8d1c597131 | |||
| 8a2bb2e993 | |||
| 0586488d90 | |||
| 176de41288 | |||
| 92f4b78801 | |||
| a9d4c6399f | |||
| d31e1e4bfd | |||
| a39dce4cf8 | |||
| 044d0253ca | |||
| 036de5de95 | |||
| c3c07e2ccb | |||
| 4fe7155f0c | |||
| 83fbe8d881 | |||
| c610352868 | |||
| 217ec34a70 | |||
| 4ddd5dbf03 | |||
| 217f0f47ac | |||
| 8d37376fb1 | |||
| bfebdd2632 | |||
| ee2068eda5 | |||
| 5a6c7da549 | |||
| a29be94d08 | |||
| 20ec956b77 | |||
| 8335e4de96 | |||
| d53e0fbdd7 | |||
| d39be76f0f | |||
| ee1dd570d0 | |||
| 78a51b6817 | |||
| b089ccc39c | |||
| c8a1ccef30 | |||
| 3d93013f75 | |||
| 77c19504be | |||
| 5f7c942354 | |||
| ebb41422f3 | |||
| b4a728213d | |||
| fde47de5ed | |||
| 78d2f447eb | |||
| 702d4f62bb | |||
| a4eb4d58ae | |||
| 80fd882815 | |||
| 3c993c576e | |||
| c3eeadece5 | |||
| 95dad78a7f | |||
| 0498009a42 | |||
| f068a2a9ee | |||
| 3cb2432d14 | |||
| fa3b1d014f | |||
| 8438fa568d | |||
| f1f74019b4 | |||
| c68a5320a3 | |||
| 2581b09ae5 | |||
| 5794c541b0 | |||
| 4ceb989884 | |||
| 7e22e3548e | |||
| 13714677d3 | |||
| f3e730b131 | |||
| 216553f526 | |||
| 2c9ac0c7c2 | |||
| 47dc48555e | |||
| 892f748610 | |||
| 7a221e0cb3 | |||
| 741a707994 | |||
| a9734c90d9 | |||
| 9c36c7be4e | |||
| 72e604bd43 | |||
| 9326f2c4d0 | |||
| 489161437a | |||
| 8fb69b7e9c | |||
| b73149ad67 | |||
| 71f99e68e6 | |||
| eab0548b44 | |||
| 87d27b22f9 | |||
| 928eb4f32c | |||
| 506201f037 | |||
| 6009314efd | |||
| 20ceef0889 | |||
| ebad574330 | |||
| 853e34b12b | |||
| 3a9b16512a | |||
| 25ade94314 | |||
| d5790c5c15 | |||
| d49e9ef89b | |||
| 84e3712e22 | |||
| 3b3a5faad4 | |||
| b55d6a2c24 | |||
| 701c633cc5 | |||
| 3eac154ab6 | |||
| 34bd7e66ec | |||
| f965acaf27 | |||
| 9338532c8c | |||
| 89ebf6e9b5 | |||
| d519f4c04c | |||
| 4cb79807c6 | |||
| e765a5e9c8 | |||
| 100f952a92 | |||
| 6c220b5de5 | |||
| 21d14a0ecd | |||
| 74c69a42c9 | |||
| 677cf8e3d1 | |||
| 7c73bf17b9 | |||
| afa2a653d4 | |||
| 6374b1a81c | |||
| 66e64e3af3 | |||
| b82f20302a | |||
| b4c4ac6c03 | |||
| 19d681b08b | |||
| 475c7d6dc9 | |||
| 4abb6526f3 | |||
| a6a14a3457 | |||
| 1d524a1e5b | |||
| 56c6aaaef0 | |||
| 74102312d0 | |||
| e0db4dac3e | |||
| 05de378cdd | |||
| cd62300547 | |||
| 9302b1c8a5 | |||
| 7de3eb1153 | |||
| 60d2f5da1c | |||
| 0fcf6638c4 | |||
| 005b504422 | |||
| bb7c3bd337 | |||
| d12ac42513 | |||
| d0adc9ea4f | |||
| e09000480c | |||
| 7be6317e5e | |||
| ec2f7f0451 | |||
| 3546c0f1f1 | |||
| fe23b239db | |||
| 46694f67da | |||
| c68ee2d74e | |||
| 4f77a335e8 | |||
| 691a930893 | |||
| b0da66f2e8 | |||
| 74479dc5b9 | |||
| 7369f01d26 | |||
| c675bed506 | |||
| 3e78565e1d | |||
| 04cd7a74fa | |||
| 2d53f3c70f | |||
| 7745643c97 | |||
| 956a4ff911 | |||
| 59693bec9c | |||
| 4e2b937740 | |||
| 4d45778805 | |||
| c3d0a41918 | |||
| c0dd6ef480 | |||
| cd2123e555 | |||
| 76831f65ce | |||
| 0f7e2d5bad | |||
| 079169d8aa | |||
| e9efe70112 | |||
| fc2380d68c | |||
| 6b8a289908 | |||
| 2f8f286788 | |||
| fd10a41ec5 | |||
| 510f1cc570 | |||
| 3558205135 | |||
| 2b148a1982 | |||
| a3f894359e | |||
| 6cb9ccddfa | |||
| 9ff565927e | |||
| cca05eb926 | |||
| 90fbcb18ba | |||
| d5032e4fee | |||
| ec4506ebf4 | |||
| a56db5ea2b | |||
| 520e443712 | |||
| ca4f94ee57 | |||
| a722a18482 | |||
| 56e8c3b4a9 | |||
| 08312733eb | |||
| b55ae5f4c4 | |||
| 6604204b51 | |||
| 74f0305960 | |||
| 1778b61018 | |||
| 78271d7ffa | |||
| 88cc80db16 | |||
| 90d765d224 | |||
| 15db4490ce | |||
| 35357b8dc7 | |||
| dbece52cc3 | |||
| 5d981328db | |||
| 8498cf7b8d | |||
| f360a72e75 | |||
| 7ad40daeb9 | |||
| 676117c053 | |||
| fe837da592 | |||
| 0ce34f4135 | |||
| 2f333dac32 | |||
| c55c333bec | |||
| 2065553f97 | |||
| b6bbd1532c | |||
| a8143e235d | |||
| 9fac05d49e | |||
| e0b1d7c49c | |||
| 0b1ed7343f | |||
| d734872dfa | |||
| 50840eaa90 | |||
| e71ce2b338 | |||
| f8addc663b | |||
| eed78f7639 | |||
| 1cd41d9bec | |||
| 2c8b4cafe6 | |||
| 3a6a8afb41 | |||
| 5ab72d9d7a | |||
| ba289865ac | |||
| b8e6e71da6 | |||
| cff50a10fa | |||
| cb5b8f9a93 | |||
| 606325439f | |||
| e9ed64608f | |||
| 36330f6d46 | |||
| eb40b899e0 | |||
| 23640cd8bd | |||
| 21e8761d48 | |||
| d1249b4e4b | |||
| 34334fd160 | |||
| 82f91861f4 | |||
| 4b4e013212 | |||
| 177942648d | |||
| 57fa3b4912 | |||
| f1ec6785f6 | |||
| 4abcf45ff4 | |||
| 899866e595 | |||
| 722aa7d601 | |||
| 6f84148434 | |||
| 0dca9f0088 | |||
| 25c7ded898 | |||
| 722f034830 | |||
| 87f3e767e4 | |||
| a914dbc469 | |||
| 545480056a | |||
| 3ef3b12197 | |||
| 1a2c0419d8 | |||
| 7e90cfd4fd | |||
| 6e0e906369 | |||
| 492d007314 | |||
| 586f2795e3 | |||
| e5247170aa | |||
| 565c84ba71 | |||
| c07869e928 | |||
| ae18c8ddac | |||
| 1a43114f27 | |||
| 6e2c5a0ec7 | |||
| 4f272fc3a1 | |||
| 57dc1f2c4d | |||
| e225dd622c | |||
| 1efc8519e0 | |||
| 142797926d | |||
| d2520ade06 | |||
| 415ae401fd | |||
| 894fec8ab5 | |||
| d01980515b | |||
| 7fffa955ae | |||
| b3ec73fc75 | |||
| 4b23781a75 | |||
| 7cdce584eb | |||
| 710c894c5d | |||
| 8fd6fa14ca | |||
| 6ec855e93c | |||
| 41457c4c43 | |||
| d4804a5d83 | |||
| 39919f5045 | |||
| 82c9f6d762 | |||
| 2ae0b3f97d | |||
| 857f088da4 | |||
| 1ac9181942 | |||
| 0cdb77f2ad | |||
| d34d5040fb | |||
| 765fc00aa2 | |||
| 3d61ab45ec | |||
| 443d4d1e9b | |||
| 45cfdcdbd6 | |||
| acf591faca | |||
| abcc07c7ba | |||
| 220e473224 | |||
| 3b87ab5bcd | |||
| fce1b4c584 | |||
| 86719ec3d2 | |||
| 3a23e7ecd6 | |||
| ff5f6cd37c | |||
| 378e00147e | |||
| 482c96f0f3 | |||
| 497f0a2233 | |||
| f1c0261cea | |||
| e59d49af03 | |||
| 2d800082b2 | |||
| 352c081f03 | |||
| a786730ca6 | |||
| df21c42353 | |||
| 155f9326b5 | |||
| 5405dbfe39 | |||
| d7fd89c993 | |||
| 6f85366c9c | |||
| 943eee0b9d | |||
| 427769f56c | |||
| 6de678649c | |||
| cb63745b5a | |||
| 1ceb8dacb6 | |||
| 8b2055b352 | |||
| a2e67b71e3 | |||
| 81272c4fe8 | |||
| 6527b66c24 | |||
| 6baa4b94aa | |||
| eca04d4a81 | |||
| 7622801c40 | |||
| 954ddc8f6f | |||
| 94e3fa058f | |||
| 3cc393816e | |||
| acc7da2c07 | |||
| ea1b802f77 | |||
| d354b2ac07 | |||
| e5292a1504 | |||
| d1e7ed388f | |||
| e02cc37a63 | |||
| d285b22161 | |||
| b633518630 | |||
| 1923f3d2e1 | |||
| 5a245f9f36 | |||
| 9d1bb9e670 | |||
| ce0a94dd90 | |||
| 40348ffd22 | |||
| 4d8936f989 | |||
| 82e55421d6 | |||
| e95a89c86a | |||
| f39ef910aa | |||
| 93aa8d5d00 | |||
| 723b18abb9 | |||
| 07a3edf5b4 | |||
| 576ff0b407 | |||
| 73e9341ee7 | |||
| 34aaa563b2 | |||
| ea8ef913b4 | |||
| fd00d9ee6b | |||
| 92d7bc2fa2 | |||
| 765b534ba8 | |||
| ca6829a3ba | |||
| 35555e3d7c | |||
| 38a30553b4 | |||
| f479a7066c | |||
| 1e43122c3d | |||
| 414f35e353 | |||
| c5039c3152 | |||
| b2d60b70f0 | |||
| c6d7c66a8c | |||
| ab4d13fa14 | |||
| 29d5595ec8 | |||
| 852f6610f8 | |||
| 4fddb75f05 | |||
| 4650ca57fb | |||
| 9526c6f9cc | |||
| 8d095ea2f3 | |||
| 47d9efd1ec | |||
| 514f4be140 | |||
| 7eaf2531de | |||
| 293d768f8b | |||
| 8f3e9eefb0 | |||
| 610256f839 | |||
| 8077f8731f | |||
| ec6954733d | |||
| ab9a19d4f1 | |||
| 5e43913915 | |||
| 3ac8912cd5 | |||
| 4994c2a17b | |||
| c708d35b7a | |||
| 41d7b861e0 | |||
| b1fcd54fe0 | |||
| 060d921cbc | |||
| 885f1fe08b | |||
| 1c3c0ea9d4 | |||
| 69d27e1049 | |||
| ee4b64febe | |||
| 65ad6b5085 | |||
| 273d32f2ec | |||
| fdd9aba29a | |||
| 28cd165561 | |||
| 0e7183062e | |||
| 11c11884e7 | |||
| e65c238d37 | |||
| d29069256d | |||
| bc7ae51ce8 | |||
| a0fbc55607 | |||
| 8e359831e9 | |||
| d758950189 | |||
| a76c04b993 | |||
| 5300a3c289 | |||
| 509230445f | |||
| 98241c47c6 | |||
| e4feb4d1e8 | |||
| c93e8e26e4 | |||
| c5a7a9e3ea | |||
| 85d1c30e81 | |||
| 1aff8da252 | |||
| 5aa4a7a513 | |||
| 8f4213678f | |||
| e65fff3ac0 | |||
| 34ee987b03 | |||
| de5c31b605 | |||
| 2e4c98e4bf | |||
| e7bf9ec5e4 | |||
| 3826bcd8c8 | |||
| f166b72b7d | |||
| 2319197b81 | |||
| 7fa63850fc | |||
| c0d16b9d89 | |||
| ec6889d815 | |||
| 249d1d7323 | |||
| fba7c28051 | |||
| 25cd1e9a7f | |||
| 9c26a9dd94 | |||
| 94cb7cd030 | |||
| bc900f87cc | |||
| 2c9ab8fdfc | |||
| 88ad16668d | |||
| 644866f3ef | |||
| dae0f5b159 | |||
| 0323763e83 | |||
| feb1ad2ac0 | |||
| af51db6b7f | |||
| 56d564c1c1 | |||
| 58f163837f | |||
| ab7410a02b | |||
| 96f8fa3375 | |||
| 30d2b3679a | |||
| c304c32b28 | |||
| 54c9ff63f5 | |||
| 4e56114d3c | |||
| c3959d8513 | |||
| bfdbbe8de4 | |||
| 830aa15d24 | |||
| 2d2b28e49a | |||
| fa3a3a4492 | |||
| c6e317f93d | |||
| ebcb93ee7d | |||
| abcca7bf0b | |||
| 85e104adfd | |||
| dab6c21957 | |||
| d56b6c1420 | |||
| e9487fa58a | |||
| 901d16349e | |||
| a67899adb5 | |||
| 978c6040f8 | |||
| fee295810b | |||
| 95151048b9 | |||
| 3b13a6a4ee | |||
| b29d557e5b | |||
| 2d0ba17044 | |||
| c9cb3f10a8 | |||
| 8b0c60cd2d | |||
| 490714f5c0 | |||
| a9e338ba72 | |||
| ef7fc8173b | |||
| 828510a39d | |||
| 5ad0d51001 | |||
| 619315b533 | |||
| 740a9517ab | |||
| bd43e03d1b | |||
| deeb585e40 | |||
| e8399e4590 | |||
| 85a000b8df | |||
| a3bafa610f | |||
| c36e49c7df | |||
| 1e36c38d24 | |||
| 0c4977dc13 | |||
| e264cc0f1f | |||
| 34e42d3846 |
16
.env
16
.env
@@ -4,7 +4,7 @@ APP_KEY=base64:PBOxrGFJAtwj9SDF4F0DZ1J+6MjrJmRiPZJQwRdy3XQ=
|
|||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
APP_URL=http://localhost
|
APP_URL=http://localhost
|
||||||
|
|
||||||
LOG_CHANNEL=stack
|
LOG_CHANNEL=daily
|
||||||
|
|
||||||
DB_CONNECTION=mysql
|
DB_CONNECTION=mysql
|
||||||
DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
@@ -16,8 +16,8 @@ DB_PASSWORD=strtmage
|
|||||||
BROADCAST_DRIVER=log
|
BROADCAST_DRIVER=log
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
|
|
||||||
QUEUE_CONNECTION=database
|
QUEUE_DRIVER=redis
|
||||||
QUEUE_DRIVER=database
|
QUEUE_CONNECTION=sync
|
||||||
|
|
||||||
SESSION_DRIVER=file
|
SESSION_DRIVER=file
|
||||||
SESSION_LIFETIME=120
|
SESSION_LIFETIME=120
|
||||||
@@ -33,18 +33,12 @@ MAIL_USERNAME=null
|
|||||||
MAIL_PASSWORD=null
|
MAIL_PASSWORD=null
|
||||||
MAIL_ENCRYPTION=null
|
MAIL_ENCRYPTION=null
|
||||||
|
|
||||||
PUSHER_APP_ID=
|
|
||||||
PUSHER_APP_KEY=
|
|
||||||
PUSHER_APP_SECRET=
|
|
||||||
PUSHER_APP_CLUSTER=mt1
|
|
||||||
|
|
||||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
|
||||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
|
||||||
|
|
||||||
ESI_CLIENT_ID=e5848fea3618427a8ee0dccb6a04fc62
|
ESI_CLIENT_ID=e5848fea3618427a8ee0dccb6a04fc62
|
||||||
ESI_SECRET_KEY=TdnNGRM8RTNSifZdaIc9yHTTkYPgYEEXHRIbT6oY
|
ESI_SECRET_KEY=TdnNGRM8RTNSifZdaIc9yHTTkYPgYEEXHRIbT6oY
|
||||||
ESI_USERAGENT='W4RP Services'
|
ESI_USERAGENT='W4RP Services'
|
||||||
ESI_CALLBACK_URI='http://services.w4rp.space/callback'
|
ESI_CALLBACK_URI='http://services.w4rp.space/callback'
|
||||||
|
ESI_PRIMARY_CHAR=93738489
|
||||||
|
ESI_ALLIANCE=99004116
|
||||||
|
|
||||||
EVEONLINE_CLIENT_ID=e5848fea3618427a8ee0dccb6a04fc62
|
EVEONLINE_CLIENT_ID=e5848fea3618427a8ee0dccb6a04fc62
|
||||||
EVEONLINE_CLIENT_SECRET=TdnNGRM8RTNSifZdaIc9yHTTkYPgYEEXHRIbT6oY
|
EVEONLINE_CLIENT_SECRET=TdnNGRM8RTNSifZdaIc9yHTTkYPgYEEXHRIbT6oY
|
||||||
|
|||||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,4 +1,9 @@
|
|||||||
/node_modules
|
/node_modules
|
||||||
/logs
|
/logs
|
||||||
.editorconfig
|
/.editorconfig
|
||||||
/cache
|
/cache
|
||||||
|
/public/logs/*
|
||||||
|
worker.log
|
||||||
|
/public/cache/*
|
||||||
|
/.env
|
||||||
|
.vscode
|
||||||
103
app/Console/Commands/Assets/GetAssets.php
Normal file
103
app/Console/Commands/Assets/GetAssets.php
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
<?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 Commands\Library\CommandHelper;
|
||||||
|
use App\Library\Assets\AssetHelper;
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Jobs\JobProcessAsset;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the refresh token from the database
|
||||||
|
$token = $esiHelper->GetRefreshToken($charId);
|
||||||
|
//Create the authentication container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
89
app/Console/Commands/Corps/GetCorps.php
Normal file
89
app/Console/Commands/Corps/GetCorps.php
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Commands\Library\CommandHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Corporation\AllianceCorp;
|
||||||
|
use App\Models\ScheduledTask\ScheduleJob;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
|
class GetCorpsCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'services:GetCorps';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Get corporations in alliance and store in db.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Create the command helper container
|
||||||
|
$task = new CommandHelper('CorpJournal');
|
||||||
|
//Add the entry into the jobs table saying the job is starting
|
||||||
|
$task->SetStartStatus();
|
||||||
|
|
||||||
|
//Declare some variables
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication();
|
||||||
|
|
||||||
|
//try the esi call to get all of the corporations in the alliance
|
||||||
|
try {
|
||||||
|
$corporations = $esi->invoke('get', '/alliances/{alliance_id}/corporations/', [
|
||||||
|
'alliance_id' => 99004116,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e){
|
||||||
|
dd($e->getEsiResponse());
|
||||||
|
}
|
||||||
|
//Delete all of the entries in the AllianceCorps table
|
||||||
|
AllianceCorp::truncate();
|
||||||
|
|
||||||
|
//Foreach corporation, make entries into the database.
|
||||||
|
foreach($corporations as $corp) {
|
||||||
|
try {
|
||||||
|
$corpInfo = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||||
|
'corporation_id' => $corp,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
return $e->getEsiResponse();
|
||||||
|
}
|
||||||
|
$entry = new AllianceCorp;
|
||||||
|
$entry->corporation_id = $corp;
|
||||||
|
$entry->name = $corpInfo->name;
|
||||||
|
$entry->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Mark the job as finished
|
||||||
|
$task->SetStopStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
177
app/Console/Commands/Data/CleanStaleDataCommand.php
Normal file
177
app/Console/Commands/Data/CleanStaleDataCommand.php
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use Commands\Library\CommandHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Lookups\AllianceLookup;
|
||||||
|
use App\Models\Lookups\CharacterLookup;
|
||||||
|
use App\Models\Lookups\CorporationLookup;
|
||||||
|
use App\Models\Lookups\ItemLookup;
|
||||||
|
use App\Models\Finances\AllianceMarketJournal;
|
||||||
|
use App\Models\Finances\JumpBridgeJournal;
|
||||||
|
use App\Models\Finances\OfficeFeesJournal;
|
||||||
|
use App\Models\Finances\PISaleJournal;
|
||||||
|
use App\Models\Finances\PlanetProductionTaxJournal;
|
||||||
|
use App\Models\Finances\ReprocessingTaxJournal;
|
||||||
|
use App\Models\Finances\SovBillJournal;
|
||||||
|
use App\Models\Finances\StructureIndustryTaxJournal;
|
||||||
|
|
||||||
|
class CleanStaleDataCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
|
||||||
|
//Empty the item lookup table
|
||||||
|
ItemLookup::truncate();
|
||||||
|
|
||||||
|
//Empty the character lookup table
|
||||||
|
CharacterLookup::truncate();
|
||||||
|
|
||||||
|
//Empty the corporation lookup table
|
||||||
|
CorporationLookup::truncate();
|
||||||
|
|
||||||
|
//Empty the alliance lookup table
|
||||||
|
AllianceLookup::truncate();
|
||||||
|
|
||||||
|
//Setup today's carbon date
|
||||||
|
$today = Carbon::now();
|
||||||
|
$ago = $today->subMonths(6);
|
||||||
|
|
||||||
|
//Clean old data from the Alliance Market Tax Journal
|
||||||
|
$markets = AllianceMarketJournal::all();
|
||||||
|
foreach($markets as $market) {
|
||||||
|
$date = new Carbon($market->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
AllianceMarketJournal::where([
|
||||||
|
'id' => $market->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old data from Jump Bridge Journal
|
||||||
|
$jumps = JumpBridgeJournal::all();
|
||||||
|
foreach($jumps as $jump) {
|
||||||
|
$date = new Carbon($jump->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
JumpBridgeJournal::where([
|
||||||
|
'id' => $jump->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old data from office fees journal
|
||||||
|
$offices = OfficeFeesJournal::all();
|
||||||
|
foreach($offices as $office) {
|
||||||
|
$date = new Carbon($office->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
OfficeFeesJournal::where([
|
||||||
|
'id' => $office->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old data from pi sale journal
|
||||||
|
$pisales = PISaleJournal::all();
|
||||||
|
foreach($pisales as $sale) {
|
||||||
|
$date = new Carbon($sale->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
PISaleJournal::where([
|
||||||
|
'id' => $sale->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old data from planet production tax journal
|
||||||
|
$pis = PlanetProductionTaxJournal::all();
|
||||||
|
foreach($pis as $pi) {
|
||||||
|
$date = new Carbon($pi->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
PlanetProductionTaxJournal::where([
|
||||||
|
'id' => $pi->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old data from player donation journal
|
||||||
|
$donations = PlayerDonationJournal::all();
|
||||||
|
foreach($donations as $donation) {
|
||||||
|
$date = new Carbon($donation->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
PlayerDonationJournal::where([
|
||||||
|
'id' => $donation->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old data from Reprocessing Tax Journal
|
||||||
|
$reps = ReprocessingTaxJournal::all();
|
||||||
|
foreach($reps as $rep) {
|
||||||
|
$date = new Carbon($rep->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
ReprocessingTaxJournal::where([
|
||||||
|
'id' => $rep->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old sov bill journal data
|
||||||
|
$sovs = SovBillJournal::all();
|
||||||
|
foreach($sovs as $sov) {
|
||||||
|
$date = new Carbon($sov->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
SovBillJournal::where([
|
||||||
|
'id' => $sov->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old structure industry tax journal data
|
||||||
|
$industrys = StructureIndustryTaxJournal::all();
|
||||||
|
foreach($industrys as $indy) {
|
||||||
|
$date = new Carbon($indy->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
StructureIndustryTaxJournal::where([
|
||||||
|
'id' => $indy->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
61
app/Console/Commands/Data/EmptyJumpBridges.php
Normal file
61
app/Console/Commands/Data/EmptyJumpBridges.php
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use Commands\Library\CommandHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Structure\Structure;
|
||||||
|
use App\Models\Structure\Service;
|
||||||
|
use App\Models\Stock\Asset;
|
||||||
|
|
||||||
|
class EmptyJumpBridges extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'services:EmptyJumpBridges';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Reset the jump bridge fuel related tables.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$task = new CommandHelper('EmptyJumpBridges');
|
||||||
|
|
||||||
|
//Add entry into the table saying the job is starting
|
||||||
|
$task->SetStartStatus();
|
||||||
|
|
||||||
|
Structure::truncate();
|
||||||
|
Service::truncate();
|
||||||
|
Asset::truncate();
|
||||||
|
|
||||||
|
//Mark the job as finished
|
||||||
|
$task->SetStopStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
81
app/Console/Commands/Files/MoonFormatter.php
Normal file
81
app/Console/Commands/Files/MoonFormatter.php
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Http\File;
|
||||||
|
|
||||||
|
class MoonFormatter extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'file:moons';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Create a text file to put into sql to update the moons';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$lines = array();
|
||||||
|
|
||||||
|
//Create the file handler
|
||||||
|
$data = Storage::get('public/moon_data.txt');
|
||||||
|
//Split the string into separate arrays based on the line
|
||||||
|
$data = preg_split("/\n/", $data);
|
||||||
|
|
||||||
|
//For each array of data, let's separate the data into more arrays built in arrays
|
||||||
|
for($i = 0; $i < sizeof($data); $i++) {
|
||||||
|
//Strip the beginning [ from the line
|
||||||
|
$temp = str_replace('[', '', $data[$i]);
|
||||||
|
//Strip the ending ] from the line
|
||||||
|
$temp = str_replace(']', '', $temp);
|
||||||
|
//Remove the spacees from the line
|
||||||
|
$temp = str_replace(' ', '', $temp);
|
||||||
|
//Remove the quotes from the line
|
||||||
|
$temp = str_replace("'", '', $temp);
|
||||||
|
//Split up the line into separate arrays after each comma
|
||||||
|
$lines[$i] = preg_split("/,/", $temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The output within the lines array
|
||||||
|
* 0 => System
|
||||||
|
* 1 => Planet
|
||||||
|
* 2 => Moon
|
||||||
|
* 3 => FirstOre
|
||||||
|
* 4 => FirstQuan
|
||||||
|
* 5 => SecondOre
|
||||||
|
* 6 => SecondQuan
|
||||||
|
* 7 => ThirdOre
|
||||||
|
* 8 => ThirdQuan
|
||||||
|
* 9 => FourthOre
|
||||||
|
* 10 => FourthQuan
|
||||||
|
*/
|
||||||
|
|
||||||
|
var_dump($lines);
|
||||||
|
dd();
|
||||||
|
}
|
||||||
|
}
|
||||||
89
app/Console/Commands/Finances/HoldingFinances.php
Normal file
89
app/Console/Commands/Finances/HoldingFinances.php
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
use Commands\Library\CommandHelper;
|
||||||
|
use App\Library\Finances\Helper\FinanceHelper;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\ProcessWalletJournalJob;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Jobs\JobProcessWalletJournal;
|
||||||
|
|
||||||
|
class HoldingFinancesCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'services:HoldingJournal';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Get the holding corps finances.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Create the command helper container
|
||||||
|
$task = new CommandHelper('HoldingFinances');
|
||||||
|
|
||||||
|
//Add the entry into the jobs table saying the job is starting
|
||||||
|
$task->SetStartStatus();
|
||||||
|
|
||||||
|
//Setup the Finances container
|
||||||
|
$finance = new FinanceHelper();
|
||||||
|
|
||||||
|
//Get the esi configuration
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
//Get the total pages for the journal for the holding corporation
|
||||||
|
$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 = $config['primary'];
|
||||||
|
$job->page = $i;
|
||||||
|
ProcessWalletJournalJob::dispatch($job)->onQueue('journal');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the total pages for the journal for the sov bills from the holding corporation
|
||||||
|
$pages = $finance->GetJournalPageCount(6, $config['primary']);
|
||||||
|
|
||||||
|
//Dispatch a job for each page to process
|
||||||
|
for($i = 1; $i <= $pages; $i++) {
|
||||||
|
$job = new JobProcessWalletJournal;
|
||||||
|
$job->division = 6;
|
||||||
|
$job->charId = $config['primary'];
|
||||||
|
$job->page = $i;
|
||||||
|
ProcessWalletJournalJob::dispatch($job)->onQueue('journal');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Mark the job as finished
|
||||||
|
$task->SetStopStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
142
app/Console/Commands/Finances/SovBills.php
Normal file
142
app/Console/Commands/Finances/SovBills.php
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
use Commands\Library\CommandHelper;
|
||||||
|
use App\Library\Finances\Helper\FinanceHelper;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\ProcessWalletJournalJob;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Jobs\JobProcessWalletJournal;
|
||||||
|
use App\Models\Esi\EsiToken;
|
||||||
|
use App\Models\Esi\EsiScope;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use App\Library\Finances\AllianceMarketTax;
|
||||||
|
use App\Library\Finances\CorpMarketTax;
|
||||||
|
use App\Library\Finances\MarketTax;
|
||||||
|
use App\Library\Finances\PlayerDonation;
|
||||||
|
use App\Library\Finances\ReprocessingTax;
|
||||||
|
use App\Library\Finances\JumpBridgeTax;
|
||||||
|
use App\Library\Finances\StructureIndustryTax;
|
||||||
|
use App\Library\Finances\OfficeFee;
|
||||||
|
use App\Library\Finances\PlanetProductionTax;
|
||||||
|
use App\Library\Finances\PISale;
|
||||||
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
use App\Library\Finances\SovBillExpenses;
|
||||||
|
|
||||||
|
//Seat Stuff
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
use Seat\Eseye\Cache\NullCache;
|
||||||
|
use Seat\Eseye\Configuration;
|
||||||
|
|
||||||
|
class SovBillsCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'services:SovBills';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Get the holding corps sov bills from wallet 6.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$sovBill = new SovBillExpenses;
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
$finance = new FinanceHelper();
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
|
||||||
|
//Create the command helper container
|
||||||
|
$task = new CommandHelper('SovBills');
|
||||||
|
|
||||||
|
//Add the entry into the jobs table saying the job is starting
|
||||||
|
$task->SetStartStatus();
|
||||||
|
|
||||||
|
|
||||||
|
//Get the esi configuration
|
||||||
|
$config = config('esi');
|
||||||
|
//Set caching to null
|
||||||
|
$configuration = Configuration::getInstance();
|
||||||
|
$configuration->cache = NullCache::class;
|
||||||
|
|
||||||
|
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||||
|
if($token == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create an ESI authentication container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
$esi->setVersion('v4');
|
||||||
|
|
||||||
|
//Reference to see if the character is in our look up table for corporations and characters
|
||||||
|
$char = $lookup->GetCharacterInfo($config['primary']);
|
||||||
|
$corpId = $char->corporation_id;
|
||||||
|
|
||||||
|
//Get the total pages for the journal for the sov bills from the holding corporation
|
||||||
|
$pages = $finance->GetJournalPageCount(6, $config['primary']);
|
||||||
|
|
||||||
|
//Dispatch a job for each page to process
|
||||||
|
//for($i = 1; $i <= $pages; $i++) {
|
||||||
|
// $job = new JobProcessWalletJournal;
|
||||||
|
// $job->division = 6;
|
||||||
|
// $job->charId = $config['primary'];
|
||||||
|
// $job->page = $i;
|
||||||
|
// ProcessWalletJournalJob::dispatch($job)->onQueue('journal');
|
||||||
|
//}
|
||||||
|
|
||||||
|
//Try to figure it out from the command itself.
|
||||||
|
for($i = 1; $i <= $pages; $i++) {
|
||||||
|
printf("Getting page: " . $i . "\n");
|
||||||
|
|
||||||
|
try {
|
||||||
|
$journals = $esi->page($i)
|
||||||
|
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||||
|
'corporation_id' => $corpId,
|
||||||
|
'division' => 6,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Decode the wallet from json into an array
|
||||||
|
$wallet = json_decode($journals->raw, true);
|
||||||
|
dd($wallet);
|
||||||
|
foreach($wallet as $entry) {
|
||||||
|
if($entry['ref_type'] == 'infrastructure_hub_maintenance' && $entry['first_party_id'] == 98287666) {
|
||||||
|
$sovBill->InsertSovBillExpense($entry, $corpId, $division);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Mark the job as finished
|
||||||
|
$task->SetStopStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
134
app/Console/Commands/Flex/FlexStructureCommand.php
Normal file
134
app/Console/Commands/Flex/FlexStructureCommand.php
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\ProcessSendEveMailJob;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use Commands\Library\CommandHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Flex\FlexStructure;
|
||||||
|
use App\Models\Mail\SentMail;
|
||||||
|
use App\Models\Jobs\JobSendEveMail;
|
||||||
|
|
||||||
|
class FlexStructureCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'services:FlexStructures';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Mail out reminder for flex structure bills';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Create the new command helper container
|
||||||
|
$task = new CommandHelper('FlexStructureMailer');
|
||||||
|
//Add the entry into the jobs table saying the job has started
|
||||||
|
$task->SetStartStatus();
|
||||||
|
|
||||||
|
//Create other variables
|
||||||
|
$body = null;
|
||||||
|
$delay = 5;
|
||||||
|
|
||||||
|
//Get today's date
|
||||||
|
$today = Carbon::now();
|
||||||
|
$today->second = 2;
|
||||||
|
$today->minute = 0;
|
||||||
|
$today->hour = 0;
|
||||||
|
|
||||||
|
//Get the esi configuration
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
//Get all of the contacts for the flex structures
|
||||||
|
$contacts = FlexStructure::select('requestor_id')->orderBy('requestor_id')->get();
|
||||||
|
|
||||||
|
//For each of the contacts, send a reminder mail about the total of the structures they are paying for
|
||||||
|
foreach($contacts as $contact) {
|
||||||
|
//Get all of the structures for requestor
|
||||||
|
$structures = FlexStructure::where([
|
||||||
|
'requestor_id' => $contact->requestor_id,
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
//Totalize the total cost of everything
|
||||||
|
$totalCost = $this->TotalizeCost($structures);
|
||||||
|
|
||||||
|
//Build the body of the mail
|
||||||
|
$body = "Flex Structure Overhead Cost is due for the following structures:<br>";
|
||||||
|
foreach($structures as $structure) {
|
||||||
|
$body += "System: " . $structure->system . " - " . $structure->structure_type . ": " . $structure->structure_cost . " ISK<br>";
|
||||||
|
}
|
||||||
|
$body += "Total Cost: " . number_format($totalCost, 2,".", ",");
|
||||||
|
$body += "Please remit payment to Spatial Forces by the 3rd of the month.<br>";
|
||||||
|
$body += "Sincerely,<br>";
|
||||||
|
$body += "Warped Intentions Leadership<br>";
|
||||||
|
|
||||||
|
//Dispatch the mail job
|
||||||
|
$mail = new JobSendEveMail;
|
||||||
|
$mail->sender = $config['primary'];
|
||||||
|
$mail->subject = "Warped Intentions Flex Structures Payment Due for " . $today->englishMonth;
|
||||||
|
$mail->body = $body;
|
||||||
|
$mail->recipient = (int)$structure->requestor_id;
|
||||||
|
$mail->recipient_type = 'character';
|
||||||
|
ProcessSendEveMailJob::dispatch($mail)->onQueueu('mail')->delay($delay);
|
||||||
|
|
||||||
|
//Increment the delay for the mail to not hit the rate limits
|
||||||
|
$delay += 60;
|
||||||
|
|
||||||
|
//After the mail is dispatched, save the sent mail record
|
||||||
|
$this->SaveSentRecord($mail->sender, $mail->subject, $mail->body, $mail->recipient, $mail->recipient_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Mark the job as finished
|
||||||
|
$task->SetStopStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function TotalizeCost($structures) {
|
||||||
|
//Declare the total cost
|
||||||
|
$totalCost = 0.00;
|
||||||
|
|
||||||
|
foreach($structures as $structure) {
|
||||||
|
$totalCost += $structure->structure_cost;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $totalCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
|
||||||
|
$sentmail = new SentMail;
|
||||||
|
$sentmail->sender = $sender;
|
||||||
|
$sentmail->subject = $subject;
|
||||||
|
$sentmail->body = $body;
|
||||||
|
$sentmail->recipient = $recipient;
|
||||||
|
$sentmail->recipient_type = $recipientType;
|
||||||
|
$sentmail->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
48
app/Console/Commands/Library/CommandHelper.php
Normal file
48
app/Console/Commands/Library/CommandHelper.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Commands\Library;
|
||||||
|
|
||||||
|
//Internal Libraries
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\ScheduledTask\ScheduleJob;
|
||||||
|
|
||||||
|
class CommandHelper {
|
||||||
|
|
||||||
|
private $job_name;
|
||||||
|
private $job_state;
|
||||||
|
private $system_time;
|
||||||
|
|
||||||
|
public function __construct($name) {
|
||||||
|
$this->job_name = $name;
|
||||||
|
$this->job_state = 'Starting';
|
||||||
|
$this->system_time = Carbon::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function SetStartStatus() {
|
||||||
|
//Add an entry into the jobs table
|
||||||
|
$job = new ScheduleJob;
|
||||||
|
$job->job_name = $this->job_name;
|
||||||
|
$job->job_state = $this->job_state;
|
||||||
|
$job->system_time = $this->system_time;
|
||||||
|
$job->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function SetStopStatus() {
|
||||||
|
//Mark the job as finished
|
||||||
|
ScheduleJob::where([
|
||||||
|
'system_time' => $this->system_time,
|
||||||
|
'job_name' => $this->job_name,
|
||||||
|
])->update([
|
||||||
|
'job_state' => 'Finished',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function CleanJobStatusTable() {
|
||||||
|
//Delete old jobs
|
||||||
|
ScheduleJob::where(['system_time', '<', Carbon::now()->subMonths(3)])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Commands\Library;
|
|
||||||
|
|
||||||
//Internal Libraries
|
|
||||||
use DB;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
//Models
|
|
||||||
use App\Models\ScheduledTask\ScheduleJob;
|
|
||||||
|
|
||||||
class CommandHelper {
|
|
||||||
|
|
||||||
private $job_name;
|
|
||||||
private $job_state;
|
|
||||||
private $system_time;
|
|
||||||
|
|
||||||
public function __construct($name) {
|
|
||||||
$this->job_name = $name;
|
|
||||||
$this->job_state = 'Starting';
|
|
||||||
$this->system_time = Carbon::now();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function SetStartStatus() {
|
|
||||||
//Add an entry into the jobs table
|
|
||||||
$job = new ScheduleJob;
|
|
||||||
$job->job_name = $this->job_name;
|
|
||||||
$job->job_state = $this->job_state;
|
|
||||||
$job->system_time = $this->system_time;
|
|
||||||
$job->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function SetStopStatus() {
|
|
||||||
//Mark the job as finished
|
|
||||||
DB::table('schedule_jobs')->where([
|
|
||||||
'system_time' => $this->system_time,
|
|
||||||
'job_name' => $this->job_name,
|
|
||||||
])->update([
|
|
||||||
'job_state' => 'Finished',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function CleanJobStatusTable() {
|
|
||||||
DB::table('schedule_jobs')->where('system_time', '<', Carbon::now()->subMonths(3))->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
226
app/Console/Commands/Moons/MoonMailer.php
Normal file
226
app/Console/Commands/Moons/MoonMailer.php
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\ProcessSendEveMailJob;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use Commands\Library\CommandHelper;
|
||||||
|
use App\Library\Moons\MoonCalc;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Moon\RentalMoon;
|
||||||
|
use App\Models\MoonRent\MoonRental;
|
||||||
|
use App\Models\Jobs\JobSendEveMail;
|
||||||
|
use App\Models\Mail\SentMail;
|
||||||
|
|
||||||
|
class MoonMailerCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Next update will include checking for if the moon has been paid in advance.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'services:MoonMailer';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Mail out the moon rental bills automatically';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Create the new command helper container
|
||||||
|
$task = new CommandHelper('MoonMailer');
|
||||||
|
//Add the entry into the jobs table saying the job has started
|
||||||
|
$task->SetStartStatus();
|
||||||
|
|
||||||
|
//Create other variables
|
||||||
|
$body = null;
|
||||||
|
$delay = 5;
|
||||||
|
|
||||||
|
//Get today's date.
|
||||||
|
$today = Carbon::now();
|
||||||
|
$today->second = 1;
|
||||||
|
$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. Also only get the moons which are not paid as of today
|
||||||
|
$rentals = MoonRental::where(['Contact' => $contact->Contact])->get();
|
||||||
|
|
||||||
|
//Totalize the cost of the moons
|
||||||
|
$cost = $this->TotalizeMoonCost($rentals);
|
||||||
|
|
||||||
|
//Get the list of moons in a list format
|
||||||
|
$listItems = $this->GetMoonList($rentals);
|
||||||
|
|
||||||
|
//Build the mail body
|
||||||
|
$body = "Moon Rent is due for the following moons:<br>";
|
||||||
|
foreach($listItems as $item) {
|
||||||
|
$body .= $item . "<br>";
|
||||||
|
}
|
||||||
|
$body .= "The price for the next month's rent is " . number_format($cost, 2, ".", ",") . "<br>";
|
||||||
|
$body .= "Please remit payment to Spatial Forces on the 1st should you continue to wish to rent the moon.<br>";
|
||||||
|
$body .= "Sincerely,<br>";
|
||||||
|
$body .= "Warped Intentions Leadership<br>";
|
||||||
|
|
||||||
|
//Dispatch the mail job
|
||||||
|
$mail = new JobSendEveMail;
|
||||||
|
$mail->sender = $config['primary'];
|
||||||
|
$mail->subject = "Warped Intentions Moon Rental Payment Due for " . $today->englishMonth;
|
||||||
|
$mail->body = $body;
|
||||||
|
$mail->recipient = (int)$contact->Contact;
|
||||||
|
$mail->recipient_type = 'character';
|
||||||
|
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay($delay);
|
||||||
|
//Increment the delay for the mail to not hit rate limits
|
||||||
|
$delay += 30;
|
||||||
|
|
||||||
|
//Update the moon as not being paid for the next month?
|
||||||
|
foreach($rentals as $rental) {
|
||||||
|
$previous = new Carbon($rental->Paid_Until);
|
||||||
|
|
||||||
|
if($today->greaterThanOrEqualTo($previous)) {
|
||||||
|
$this->UpdateNotPaid($rental);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Mark the job as finished
|
||||||
|
$task->SetStopStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function SendMail() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function UpdateNotPaid(MoonRental $rental) {
|
||||||
|
MoonRental::where([
|
||||||
|
'System' => $rental->System,
|
||||||
|
'Planet'=> $rental->Planet,
|
||||||
|
'Moon'=> $rental->Moon,
|
||||||
|
])->update([
|
||||||
|
'Paid' => 'No',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function GetMoonList($moons) {
|
||||||
|
//Declare the variable to be used as a global part of the function
|
||||||
|
$list = array();
|
||||||
|
|
||||||
|
//For each of the moons, build the System Planet and Moon.
|
||||||
|
foreach($moons as $moon) {
|
||||||
|
$temp = 'Moon: ' . $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon;
|
||||||
|
array_push($list, $temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return the list
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function GetRentalMoons($contact) {
|
||||||
|
$rentals = MoonRental::where([
|
||||||
|
'Contact' => $contact,
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
return $rentals;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function TotalizeMoonCost($rentals) {
|
||||||
|
//Delcare variables and classes
|
||||||
|
$moonCalc = new MoonCalc;
|
||||||
|
$totalCost = 0.00;
|
||||||
|
$price = null;
|
||||||
|
|
||||||
|
//Create the date for today
|
||||||
|
$today = Carbon::now();
|
||||||
|
$today->second = 1;
|
||||||
|
$today->minute = 0;
|
||||||
|
$today->hour = 0;
|
||||||
|
|
||||||
|
foreach($rentals as $rental) {
|
||||||
|
$moon = RentalMoon::where([
|
||||||
|
'System' => $rental->System,
|
||||||
|
'Planet' => $rental->Planet,
|
||||||
|
'Moon' => $rental->Moon,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
//Create the date time object for the rental end
|
||||||
|
$end = new Carbon($rental->Paid_Until);
|
||||||
|
|
||||||
|
//If today is greater than the rental end, then calculate the moon cost
|
||||||
|
if($today->greaterThanOrEqualTo($end)) {
|
||||||
|
//Get the updated price for the moon
|
||||||
|
$price = $moonCalc->SpatialMoonsOnlyGooMailer($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||||
|
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||||
|
|
||||||
|
//Check the type and figure out which price to add in
|
||||||
|
if($rental->Type == 'alliance') {
|
||||||
|
$totalCost += $price['alliance'];
|
||||||
|
} else{
|
||||||
|
$totalCost += $price['outofalliance'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return the total cost back to the calling function
|
||||||
|
return $totalCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function GetRentalType($rentals) {
|
||||||
|
$alliance = 0;
|
||||||
|
$outofalliance = 0;
|
||||||
|
|
||||||
|
//Go through the data and log whether the renter is in the alliance,
|
||||||
|
//or the renter is out of the alliance
|
||||||
|
foreach($rentals as $rental) {
|
||||||
|
if($rental->Type == 'alliance') {
|
||||||
|
$alliance++;
|
||||||
|
} else {
|
||||||
|
$outofalliance++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return the rental type
|
||||||
|
if($alliance > $outofalliance) {
|
||||||
|
return 'alliance';
|
||||||
|
} else {
|
||||||
|
return 'outofalliance';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use DB;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Commands\Library\CommandHelper;
|
use Commands\Library\CommandHelper;
|
||||||
|
|
||||||
119
app/Console/Commands/Structures/GetStructures.php
Normal file
119
app/Console/Commands/Structures/GetStructures.php
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use App\Library\Structures\StructureHelper;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use Commands\Library\CommandHelper;
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
|
||||||
|
//Job
|
||||||
|
use App\Jobs\ProcessStructureJob;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Jobs\JobProcessStructure;
|
||||||
|
use App\Models\Esi\EsiScope;
|
||||||
|
use App\Models\Esi\EsiToken;
|
||||||
|
|
||||||
|
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 = $esiHelper->GetRefreshToken($charId);
|
||||||
|
//Create the esi authentication container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
|
||||||
|
//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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
|
|
||||||
class UpdateMoonRental extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'services:UpdateMoonRental';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Command description';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
193
app/Console/Commands/Users/PurgeUsers.php
Normal file
193
app/Console/Commands/Users/PurgeUsers.php
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//Libraries
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\User\User;
|
||||||
|
use App\Models\User\UserAlt;
|
||||||
|
use App\Models\Esi\EsiScope;
|
||||||
|
use App\Models\Esi\EsiToken;
|
||||||
|
use App\Models\User\UserPermission;
|
||||||
|
use App\Models\User\UserRole;
|
||||||
|
use App\Models\Admin\AllowedLogin;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The PurgeUsers command takes care of updating any user changes in terms of login role, as well as purging any users without at least
|
||||||
|
* the 'User' role. This command heavily relies on ESI being available. If no ESI is available, then the function does nothing, in order to prevent
|
||||||
|
* unwanted changes.
|
||||||
|
*/
|
||||||
|
class PurgeUsers extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = '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()
|
||||||
|
{
|
||||||
|
//Declare some variables
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Setup the esi variable
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication();
|
||||||
|
|
||||||
|
//Get all of the users from the database
|
||||||
|
$users = User::all();
|
||||||
|
|
||||||
|
//Get the allowed logins
|
||||||
|
$legacy = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_id')->toArray();
|
||||||
|
$renter = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_id')->toArray();
|
||||||
|
|
||||||
|
//Cycle through all of the users, and either update their role, or delete them.
|
||||||
|
foreach($users as $user) {
|
||||||
|
//Set the fail bit to false for the next user to check
|
||||||
|
$failed = false;
|
||||||
|
|
||||||
|
//Note a screen entry for when doing cli stuff
|
||||||
|
printf("Processing character with id of " . $user->character_id . "\r\n");
|
||||||
|
|
||||||
|
//Get the character information
|
||||||
|
try {
|
||||||
|
$character_info = $esi->invoke('get', '/characters/{character_id}/', [
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$corp_info = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||||
|
'corporation_id' => $character_info->corporation_id,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
Log::warning('Failed to get character information in purge user command for user ' . $user->character_id);
|
||||||
|
$failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//If the fail bit is still false, then continue
|
||||||
|
if($failed === false) {
|
||||||
|
//Get the user's role
|
||||||
|
$role = UserRole::where(['character_id' => $user->character_id])->first();
|
||||||
|
|
||||||
|
//We don't want to modify Admin and SuperUsers. Admins and SuperUsers are removed via a different process.
|
||||||
|
if($role->role != 'Admin') {
|
||||||
|
//Check if the user is allowed to login
|
||||||
|
if(isset($corp_info->alliance_id)) {
|
||||||
|
//Warped Intentions is allowed to login
|
||||||
|
if($corp_info->alliance_id == '99004116') {
|
||||||
|
//If the alliance is Warped Intentions, then modify the role if we need to
|
||||||
|
if($role->role != 'User') {
|
||||||
|
//Upate the role of the user
|
||||||
|
UserRole::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->update([
|
||||||
|
'role' => 'User',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Update the user type
|
||||||
|
User::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->update([
|
||||||
|
'user_type' => 'W4RP',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} else if(in_array($corp_info->alliance_id, $legacy)) { //Legacy Users
|
||||||
|
if($role->role != 'User') {
|
||||||
|
//Update the role of the user
|
||||||
|
UserRole::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->update([
|
||||||
|
'role' => 'User',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Update the user type
|
||||||
|
User::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->update([
|
||||||
|
'user_type' => 'Legacy',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} else if(in_array($corp_info->alliance_id, $renter)) { //Renter Users
|
||||||
|
if($role->role != 'Renter') {
|
||||||
|
//Update the role of the user
|
||||||
|
UserRole::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->update([
|
||||||
|
'role' => 'Renter',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Update the user type
|
||||||
|
User::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->update([
|
||||||
|
'user_type' => 'Renter',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//If the user is part of no valid login group, then delete the user.
|
||||||
|
//Delete all of the permissions first
|
||||||
|
UserPermission::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
//Delete the user's role
|
||||||
|
UserRole::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
//Delete any alts the user might have registered.
|
||||||
|
$altCount = UserAlt::where(['main_id' => $user->character_id])->count();
|
||||||
|
if($altCount > 0) {
|
||||||
|
UserAlt::where([
|
||||||
|
'main_id' => $user->character_id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Delete the user from the user table
|
||||||
|
User::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
EsiScope::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
EsiToken::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
50
app/Console/Commands/Wormholes/PurgeWormholes.php
Normal file
50
app/Console/Commands/Wormholes/PurgeWormholes.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Wormholes\AllianceWormhole;
|
||||||
|
|
||||||
|
class PurgeWormholes extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'services:PurgeWormholeData';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Purge stale wormhole data automatically';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Time of now
|
||||||
|
$currentTime = Carbon::now();
|
||||||
|
|
||||||
|
AllianceWormhole::where('created_at', '<', $currentTime->subHours(48))->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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use DB;
|
|
||||||
use Commands\Library\CommandHelper;
|
|
||||||
|
|
||||||
use App\Models\Corporation\AllianceCorp;
|
|
||||||
use App\Models\ScheduledTask\ScheduleJob;
|
|
||||||
|
|
||||||
use Seat\Eseye\Cache\NullCache;
|
|
||||||
use Seat\Eseye\Configuration;
|
|
||||||
use Seat\Eseye\Containers\EsiAuthentication;
|
|
||||||
use Seat\Eseye\Eseye;
|
|
||||||
|
|
||||||
class GetCorpsCommand extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'services:GetCorps';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Get corporations in alliance and store in db.';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//Create the command helper container
|
|
||||||
$task = new CommandHelper('CorpJournal');
|
|
||||||
//Add the entry into the jobs table saying the job is starting
|
|
||||||
$task->SetStartStatus();
|
|
||||||
|
|
||||||
//Create the ESI container
|
|
||||||
$esi = new Eseye();
|
|
||||||
//try the esi call to get all of the corporations in the alliance
|
|
||||||
try {
|
|
||||||
$corporations = $esi->invoke('get', '/alliances/{alliance_id}/corporations/', [
|
|
||||||
'alliance_id' => 99004116,
|
|
||||||
]);
|
|
||||||
} catch(\Seat\Eseye\Exceptions\RequestFailedException $e){
|
|
||||||
dd($e->getEsiResponse());
|
|
||||||
}
|
|
||||||
//Delete all of the entries in the AllianceCorps table
|
|
||||||
DB::table('AllianceCorps')->delete();
|
|
||||||
foreach($corporations as $corp) {
|
|
||||||
try {
|
|
||||||
$corpInfo = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
|
||||||
'corporation_id' => $corp,
|
|
||||||
]);
|
|
||||||
} catch(\Seat\Eseye\Exceptions\RequestFailedException $e) {
|
|
||||||
return $e->getEsiResponse();
|
|
||||||
}
|
|
||||||
$entry = new AllianceCorp;
|
|
||||||
$entry->corporation_id = $corp;
|
|
||||||
$entry->name = $corpInfo->name;
|
|
||||||
$entry->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Mark the job as finished
|
|
||||||
$task->SetStopStatus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
|
|
||||||
use Commands\Library\CommandHelper;
|
|
||||||
use App\Library\Finances\Helper\FinanceHelper;
|
|
||||||
|
|
||||||
//Jobs
|
|
||||||
use App\Jobs\ProcessWalletJournalJob;
|
|
||||||
|
|
||||||
//Models
|
|
||||||
use App\Models\Jobs\JobProcessWalletJournal;
|
|
||||||
|
|
||||||
class HoldingFinancesCommand extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'services:HoldingJournal';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Get the holding corps finances.';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//Create the command helper container
|
|
||||||
$task = new CommandHelper('HoldingFinances');
|
|
||||||
|
|
||||||
//Add the entry into the jobs table saying the job is starting
|
|
||||||
$task->SetStartStatus();
|
|
||||||
|
|
||||||
//Setup the Finances container
|
|
||||||
$finance = new FinanceHelper();
|
|
||||||
|
|
||||||
//Get the total pages for the journal for the holding corporation
|
|
||||||
$pages = $finance->GetJournalPageCount(1, 93738489);
|
|
||||||
|
|
||||||
//Dispatch a single job for each page to process
|
|
||||||
for($i = 1; $i <= $pages; $i++) {
|
|
||||||
$job = new JobProcessWalletJournal;
|
|
||||||
$job->division = 1;
|
|
||||||
$job->charId = 93738489;
|
|
||||||
$job->page = $i;
|
|
||||||
ProcessWalletJournalJob::dispatch($job);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Mark the job as finished
|
|
||||||
$task->SetStopStatus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,224 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use DB;
|
|
||||||
|
|
||||||
//Jobs
|
|
||||||
use App\Jobs\SendEveMailJob;
|
|
||||||
|
|
||||||
//Library
|
|
||||||
use Commands\Library\CommandHelper;
|
|
||||||
use App\Library\Moons\MoonMailer;
|
|
||||||
use App\Library\Moons\MoonCalc;
|
|
||||||
|
|
||||||
//Models
|
|
||||||
use App\Models\Moon\Moon;
|
|
||||||
use App\Models\MoonRent\MoonRental;
|
|
||||||
use App\Models\Jobs\JobSendEveMail;
|
|
||||||
use App\Models\Mail\SentMail;
|
|
||||||
|
|
||||||
class MoonMailerCommand extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Next update will include checking for if the moon has been paid in advance.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'services:MoonMailer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Mail out the moon rental bills automatically';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//Create the new command helper container
|
|
||||||
$task = new CommandHelper('MoonMailer');
|
|
||||||
//Add the entry into the jobs table saying the job has started
|
|
||||||
$task->SetStartStatus();
|
|
||||||
|
|
||||||
//Declare the moon calc class variable to utilize the library to update the price
|
|
||||||
$mailer = new MoonMailer;
|
|
||||||
|
|
||||||
//Create other variables
|
|
||||||
$body = null;
|
|
||||||
|
|
||||||
//Get today's date.
|
|
||||||
$today = Carbon::now();
|
|
||||||
$today->second = 1;
|
|
||||||
$today->minute = 0;
|
|
||||||
$today->hour = 0;
|
|
||||||
|
|
||||||
//Get all contacts from the rentals group
|
|
||||||
$contacts = MoonRental::select('Contact')->groupBy('Contact')->get();
|
|
||||||
|
|
||||||
//For each of the contacts totalize the moon rental, and create the mail to send to them,
|
|
||||||
//then update parameters of the moon
|
|
||||||
foreach($contacts as $contact) {
|
|
||||||
//Get the moons the renter is renting
|
|
||||||
$rentals = $this->GetRentalMoons($contact);
|
|
||||||
|
|
||||||
//Totalize the cost of the moons
|
|
||||||
$cost = $this->TotalizeMoonCost($rentals);
|
|
||||||
|
|
||||||
//Get the list of moons in a list format
|
|
||||||
$listItems = $this->GetMoonList($rentals);
|
|
||||||
|
|
||||||
//Build the mail body
|
|
||||||
$body = "Moon Rent is due for the following moons:<br>";
|
|
||||||
foreach($listItems as $item) {
|
|
||||||
$body .= $item . "<br>";
|
|
||||||
}
|
|
||||||
$body .= "The price for the next month's rent is " . $cost . "<br>";
|
|
||||||
$body .= "Please remit payment to Spatial Forces on the 1st should you continue to wish to rent the moon.<br>";
|
|
||||||
$body .= "Sincerely,<br>";
|
|
||||||
$body .= "Warped Intentions Leadership<br>";
|
|
||||||
|
|
||||||
//Dispatch the mail job
|
|
||||||
$mail = new JobSendEveMail;
|
|
||||||
$mail->sender = 93738489;
|
|
||||||
$mail->subject = "Warped Intentions Moon Rental Payment Due";
|
|
||||||
$mail->body = $body;
|
|
||||||
$mail->recipient = (int)$contact;
|
|
||||||
$mail->recipient_type = 'character';
|
|
||||||
SendEveMailJob::dispatch($mail);
|
|
||||||
|
|
||||||
//After the mail is dispatched, saved the sent mail record
|
|
||||||
$this->SaveSentRecord($mail->sender, $mail->subject, $mail->body, $mail->recipient, $mail->recipient_type);
|
|
||||||
|
|
||||||
//Update the moon as not being paid for the next month?
|
|
||||||
foreach($rentals as $rental) {
|
|
||||||
if($today > $rental->Paid_Until)
|
|
||||||
$this->UpdateNotPaid($rental);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Mark the job as finished
|
|
||||||
$task->SetStopStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function UpdateNotPaid(MoonRental $rental) {
|
|
||||||
$today = Carbon::now();
|
|
||||||
|
|
||||||
if($today >= $rental->Paid_Until) {
|
|
||||||
MoonRental::where([
|
|
||||||
'System' => $rental->System,
|
|
||||||
'Planet'=> $rental->Planet,
|
|
||||||
'Moon'=> $rental->Moon,
|
|
||||||
])->update([
|
|
||||||
'Paid' => 'No',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
|
|
||||||
$sentmail = new SentMail;
|
|
||||||
$sentmail->sender = $sender;
|
|
||||||
$sentmail->subject = $subject;
|
|
||||||
$sentmail->body = $body;
|
|
||||||
$sentmail->recipient = $recipient;
|
|
||||||
$sentmail->recipient_type = $recipientType;
|
|
||||||
$sentmail->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function GetMoonList(MoonRental $moons) {
|
|
||||||
//Declare the variable to be used as a global part of the function
|
|
||||||
$list = array();
|
|
||||||
|
|
||||||
//For each of the moons, build the System Planet and Moon.
|
|
||||||
foreach($moons as $moon) {
|
|
||||||
$temp = 'System: ' . $moon->System;
|
|
||||||
$temp .= 'Planet: ' . $moon->Planet;
|
|
||||||
$temp .= 'Moon: ' . $moon->Moon;
|
|
||||||
//Push the new string onto the array list
|
|
||||||
array_push($list, $temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Return the list
|
|
||||||
return $list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function GetRentalMoons($contact) {
|
|
||||||
$rentals = MoonRental::where([
|
|
||||||
'Contact' => $contact,
|
|
||||||
])->get();
|
|
||||||
|
|
||||||
return $rentals;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function TotalizeMoonCost($rentals) {
|
|
||||||
//Delcare variables and classes
|
|
||||||
$moonCalc = new MoonCalc;
|
|
||||||
$totalCost = 0.00;
|
|
||||||
|
|
||||||
foreach($rentals as $rental) {
|
|
||||||
$moon = Moon::where([
|
|
||||||
'System' => $rental->System,
|
|
||||||
'Planet' => $rental->Planet,
|
|
||||||
'Moon' => $rental->Moon,
|
|
||||||
])->first();
|
|
||||||
|
|
||||||
//Get the updated price for the moon
|
|
||||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
|
||||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
|
||||||
|
|
||||||
//Check the type and figure out which price to add in
|
|
||||||
if($rental->Type == 'alliance') {
|
|
||||||
$totalCost += $price['alliance'];
|
|
||||||
} else{
|
|
||||||
$totalCost += $price['outofalliance'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Return the total cost back to the calling function
|
|
||||||
return $totalCost;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function GetRentalType($rentals) {
|
|
||||||
$alliance = 0;
|
|
||||||
$outofalliance = 0;
|
|
||||||
|
|
||||||
//Go through the data and log whether the renter is in the alliance,
|
|
||||||
//or the renter is out of the alliance
|
|
||||||
foreach($rentals as $rental) {
|
|
||||||
if($rental->Type == 'alliance') {
|
|
||||||
$alliance++;
|
|
||||||
} else {
|
|
||||||
$outofalliance++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Return the rental type
|
|
||||||
if($alliance > $outofalliance) {
|
|
||||||
return 'alliance';
|
|
||||||
} else {
|
|
||||||
return 'outofalliance';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
|
|
||||||
//Library
|
|
||||||
use Commands\Library\CommandHelper;
|
|
||||||
use App\Library\Finances\Helper\FinanceHelper;
|
|
||||||
|
|
||||||
//Jobs
|
|
||||||
use App\Jobs\ProcessWalletTransactionJob;
|
|
||||||
|
|
||||||
//Models
|
|
||||||
use App\Models\Jobs\JobProcessWalletTransaction;
|
|
||||||
|
|
||||||
class PiTransactionsCommand extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'services:PiTransactions';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Get the transactions from the market alt for the alliance';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//Create the command helper container
|
|
||||||
$task = new CommandHelper('PiTransactions');
|
|
||||||
|
|
||||||
//Add the entry into the jobs table saying the job is starting
|
|
||||||
$task->SetStartStatus();
|
|
||||||
|
|
||||||
//Setup the Finances container
|
|
||||||
$finance = new FinanceHelper();
|
|
||||||
|
|
||||||
$job = new JobProcessWalletTransaction;
|
|
||||||
$job->division = 3;
|
|
||||||
$job->charId = 94415555;
|
|
||||||
ProcessWalletTransactionJob::dispatch($job);
|
|
||||||
|
|
||||||
//Mark the job as finished
|
|
||||||
$task->SetStopStatus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,9 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Console;
|
namespace App\Console;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use Commands\Library\CommandHelper;
|
||||||
|
|
||||||
class Kernel extends ConsoleKernel
|
class Kernel extends ConsoleKernel
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -13,13 +17,18 @@ class Kernel extends ConsoleKernel
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $commands = [
|
protected $commands = [
|
||||||
Commands\CorpJournalCommand::class,
|
|
||||||
Commands\GetCorpsCommand::class,
|
Commands\GetCorpsCommand::class,
|
||||||
Commands\UpdateMoonPriceCommand::class,
|
Commands\UpdateMoonPriceCommand::class,
|
||||||
Commands\CalculateMarketTaxCommand::class,
|
|
||||||
Commands\HoldingFinancesCommand::class,
|
Commands\HoldingFinancesCommand::class,
|
||||||
Commands\MoonMailerCommand::class,
|
Commands\MoonMailerCommand::class,
|
||||||
Commands\PiTransactionsCommand::class,
|
Commands\GetStructuresCommand::class,
|
||||||
|
Commands\GetAssetsCommand::class,
|
||||||
|
Commands\PurgeUsers::class,
|
||||||
|
Commands\FlexStructureCommand::class,
|
||||||
|
Commands\EmptyJumpBridges::class,
|
||||||
|
Commands\PurgeWormholes::class,
|
||||||
|
Commands\SovBillsCommand::class,
|
||||||
|
Commands\CleanStaleDataCommand::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,27 +39,51 @@ class Kernel extends ConsoleKernel
|
|||||||
*/
|
*/
|
||||||
protected function schedule(Schedule $schedule)
|
protected function schedule(Schedule $schedule)
|
||||||
{
|
{
|
||||||
$schedule->command('services:CorpJournal')
|
//Command to get the holding journal finances
|
||||||
->hourly()
|
|
||||||
->withoutOverlapping();
|
|
||||||
$schedule->command('services:HoldingJournal')
|
$schedule->command('services:HoldingJournal')
|
||||||
->hourly()
|
->hourly()
|
||||||
->withoutOverlapping();
|
->withoutOverlapping();
|
||||||
|
//Command to update moon rental pricing
|
||||||
$schedule->command('services:UpdateMoonPrice')
|
$schedule->command('services:UpdateMoonPrice')
|
||||||
->hourly()
|
->hourly()
|
||||||
->withoutOverlapping();
|
->withoutOverlapping();
|
||||||
|
//Get the corps within the alliance
|
||||||
$schedule->command('services:GetCorps')
|
$schedule->command('services:GetCorps')
|
||||||
->monthlyOn(1, '09:00')
|
->monthlyOn(1, '09:00')
|
||||||
->withoutOverlapping();
|
->withoutOverlapping();
|
||||||
$schedule->command('services:CalculateMarketTax')
|
//Update the moons, and send out mails for current moon rentals
|
||||||
->monthlyOn(1, '08:00')
|
|
||||||
->withoutOverlapping();
|
|
||||||
$schedule->command('services:MoonMailer')
|
$schedule->command('services:MoonMailer')
|
||||||
->monthlyOn(1, '00:01')
|
->monthlyOn(1, '00:01')
|
||||||
->withoutOverlapping();
|
->withoutOverlapping();
|
||||||
$schedule->command('services:PiTransactions')
|
//Get the structures within the alliance and their information
|
||||||
->hourly()
|
$schedule->command('services:GetStructures')
|
||||||
|
->dailyAt('09:00')
|
||||||
->withoutOverlapping();
|
->withoutOverlapping();
|
||||||
|
//Get the assets for the alliance. Only saves the Liquid Ozone for jump bridges
|
||||||
|
$schedule->command('services:GetAssets')
|
||||||
|
->hourlyAt('22')
|
||||||
|
->withoutOverlapping();
|
||||||
|
//Clean old data from the database
|
||||||
|
$schedule->command('services:CleanData')
|
||||||
|
->monthlyOn(15, '18:00');
|
||||||
|
//Purge users from the database which don't belong and reset the user roles as necessary
|
||||||
|
$schedule->command('services:PurgeUsers')
|
||||||
|
->dailyAt('23:00')
|
||||||
|
->withoutOverlapping();
|
||||||
|
//Mail about payments for flex structures
|
||||||
|
$schedule->command('services:FlexStructures')
|
||||||
|
->monthlyOn(2, '00:01')
|
||||||
|
->withoutOverlapping();
|
||||||
|
//Wormhole data purge
|
||||||
|
$schedule->command('services:PurgeWormholeData')
|
||||||
|
->hourlyAt(20);
|
||||||
|
//Purge old data from the database
|
||||||
|
$schedule->command('services:CleanData')
|
||||||
|
->weekly(7, '11:00')
|
||||||
|
->withoutOverlapping();
|
||||||
|
|
||||||
|
//Horizon Graph Schedule
|
||||||
|
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Auth;
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use Socialite;
|
use Socialite;
|
||||||
use Auth;
|
use Auth;
|
||||||
|
|
||||||
use App\User;
|
//Models
|
||||||
|
use App\Models\User\User;
|
||||||
|
use App\Models\Esi\EsiScope;
|
||||||
|
|
||||||
class EsiScopeController extends Controller
|
class EsiScopeController extends Controller
|
||||||
{
|
{
|
||||||
@@ -20,7 +21,10 @@ class EsiScopeController extends Controller
|
|||||||
|
|
||||||
public function displayScopes() {
|
public function displayScopes() {
|
||||||
//Get the ESI Scopes for the user
|
//Get the ESI Scopes for the user
|
||||||
$scopes = DB::table('EsiScopes')->where('character_id', Auth::user()->character_id)->get();
|
$scopes = EsiScope::where([
|
||||||
|
'character_id' => Auth::user()->character_id,
|
||||||
|
])->get();
|
||||||
|
|
||||||
return view('scopes.select')->with('scopes', $scopes);
|
return view('scopes.select')->with('scopes', $scopes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,23 +2,27 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Auth;
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Socialite;
|
use Socialite;
|
||||||
use Auth;
|
use Auth;
|
||||||
|
|
||||||
use App\User;
|
//Library
|
||||||
|
use Seat\Eseye\Cache\NullCache;
|
||||||
|
use Seat\Eseye\Configuration;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\User\User;
|
||||||
use App\Models\Esi\EsiScope;
|
use App\Models\Esi\EsiScope;
|
||||||
use App\Models\Esi\EsiToken;
|
use App\Models\Esi\EsiToken;
|
||||||
use App\Models\User\UserPermission;
|
use App\Models\User\UserPermission;
|
||||||
use App\Models\User\UserRole;
|
use App\Models\User\UserRole;
|
||||||
use App\Models\Admin\AllowedLogin;
|
use App\Models\Admin\AllowedLogin;
|
||||||
|
use App\Models\User\UserAlt;
|
||||||
|
|
||||||
use Seat\Eseye\Cache\NullCache;
|
|
||||||
use Seat\Eseye\Configuration;
|
|
||||||
use Seat\Eseye\Containers\EsiAuthentication;
|
|
||||||
use Seat\Eseye\Eseye;
|
|
||||||
|
|
||||||
class LoginController extends Controller
|
class LoginController extends Controller
|
||||||
{
|
{
|
||||||
@@ -78,12 +82,68 @@ class LoginController extends Controller
|
|||||||
* Redirect to the dashboard if logging in successfully.
|
* Redirect to the dashboard if logging in successfully.
|
||||||
*/
|
*/
|
||||||
public function handleProviderCallback() {
|
public function handleProviderCallback() {
|
||||||
|
//Get the sso user from the socialite driver
|
||||||
$ssoUser = Socialite::driver('eveonline')->user();
|
$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 +153,32 @@ class LoginController extends Controller
|
|||||||
* @param \Laravel\Socialite\Two\User $user
|
* @param \Laravel\Socialite\Two\User $user
|
||||||
*/
|
*/
|
||||||
private function createOrGetUser($eve_user) {
|
private function createOrGetUser($eve_user) {
|
||||||
//Search for user in the database
|
$authUser = null;
|
||||||
$authUser = User::where('character_id', $eve_user->id)->first();
|
|
||||||
|
//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 the user is found, do more checks to see what type of login we are doing
|
||||||
if($authUser) {
|
if($userCount > 0) {
|
||||||
//if a refresh token is present, then we are doing a scope callback to update scopes for an access token
|
//Search for user in the database
|
||||||
if($eve_user->refreshToken !== null) {
|
$authUser = User::where('character_id', $eve_user->id)->first();
|
||||||
//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);
|
|
||||||
|
|
||||||
//Update the user information never the less.
|
//Check to see if the owner has changed
|
||||||
User::where('character_id', $eve_user->id)->update([
|
//If the owner has changed, then update their roles and permissions
|
||||||
'avatar' => $eve_user->avatar,
|
if($this->OwnerHasChanged($authUser->owner_hash, $eve_user->owner_hash)) {
|
||||||
'owner_hash' => $eve_user->owner_hash,
|
//Get the right role for the user
|
||||||
'role' => $role,
|
$role = $this->GetRole(null, $eve_user->id);
|
||||||
]);
|
//Set the role for the user
|
||||||
//Update the user's roles and permission
|
$this->SetRole($role, $eve_user->id);
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
//After creating the token, we need to update the table for scopes
|
//Update the user information never the less.
|
||||||
//First we look for all the scopes, then if need be add entries or delete entries from the database
|
$this->UpdateUser($eve_user, $role);
|
||||||
$this->SetScopes($eve_user->user['Scopes'], $eve_user->id);
|
|
||||||
|
|
||||||
} else {
|
//Update the user's roles and permission
|
||||||
//If the user is already in the database, but no refresh token was present in the callback, then just update the user
|
$this->UpdatePermission($eve_user, $role);
|
||||||
User::where('character_id', $eve_user->id)->update([
|
|
||||||
'avatar' => $eve_user->avatar,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return the user to the calling auth function
|
//Return the user to the calling auth function
|
||||||
return $authUser;
|
return $authUser;
|
||||||
} else {
|
} else {
|
||||||
@@ -163,16 +186,7 @@ class LoginController extends Controller
|
|||||||
$role = $this->GetRole(null, $eve_user->id);
|
$role = $this->GetRole(null, $eve_user->id);
|
||||||
|
|
||||||
//Create the user account
|
//Create the user account
|
||||||
$user = User::create([
|
$user = $this->CreateNewUser($eve_user);
|
||||||
'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),
|
|
||||||
]);
|
|
||||||
|
|
||||||
//Set the role for the user
|
//Set the role for the user
|
||||||
$this->SetRole($role, $eve_user->id);
|
$this->SetRole($role, $eve_user->id);
|
||||||
@@ -182,6 +196,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
|
* Set the user role in the database
|
||||||
*
|
*
|
||||||
@@ -259,22 +348,25 @@ class LoginController extends Controller
|
|||||||
* @return text
|
* @return text
|
||||||
*/
|
*/
|
||||||
private function GetAccountType($refreshToken, $charId) {
|
private function GetAccountType($refreshToken, $charId) {
|
||||||
|
//Declare some variables
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Instantiate a new ESI isntance
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication();
|
||||||
|
|
||||||
//Set caching to null
|
//Set caching to null
|
||||||
$configuration = Configuration::getInstance();
|
$configuration = Configuration::getInstance();
|
||||||
$configuration->cache = NullCache::class;
|
$configuration->cache = NullCache::class;
|
||||||
|
|
||||||
// Instantiate a new ESI instance
|
|
||||||
$esi = new Eseye();
|
|
||||||
|
|
||||||
//Get the character information
|
//Get the character information
|
||||||
$character_info = $esi->invoke('get', '/characters/{character_id}/', [
|
$character_info = $esiHelper->GetCharacterData($charId);
|
||||||
'character_id' => $charId,
|
|
||||||
]);
|
|
||||||
|
|
||||||
//Get the corporation information
|
//Get the corporation information
|
||||||
$corp_info = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
$corp_info = $esiHelper->GetCorporationData($character_info->corporation_id);
|
||||||
'corporation_id' => $character_info->corporation_id,
|
|
||||||
]);
|
if($character_info == null || $corp_info == null) {
|
||||||
|
return redirect('/')->with('error', 'Could not create user at this time.');
|
||||||
|
}
|
||||||
|
|
||||||
$legacy = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_id')->toArray();
|
$legacy = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_id')->toArray();
|
||||||
$renter = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_id')->toArray();
|
$renter = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_id')->toArray();
|
||||||
|
|||||||
166
app/Http/Controllers/Blacklist/BlacklistController.php
Normal file
166
app/Http/Controllers/Blacklist/BlacklistController.php
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Blacklist;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Log;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Blacklist\BlacklistEntity;
|
||||||
|
use App\Models\User\User;
|
||||||
|
use App\Models\User\UserRole;
|
||||||
|
use App\Models\User\UserPermission;
|
||||||
|
|
||||||
|
class BlacklistController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct() {
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->middleware('role:User');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function DisplayAddToBlacklist() {
|
||||||
|
return view('blacklist.add');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function DisplayRemoveFromBlacklist() {
|
||||||
|
return view('blacklist.remove');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function DisplaySearch() {
|
||||||
|
return view('blacklist.search');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function AddToBlacklist(Request $request) {
|
||||||
|
//Middleware needed for the function
|
||||||
|
$this->middleware('permission:alliance.recruiter');
|
||||||
|
|
||||||
|
//Validate the user input
|
||||||
|
$this->validate($request, [
|
||||||
|
'name' => 'required',
|
||||||
|
'type' => 'required',
|
||||||
|
'reason' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Create the library variable
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
//Declare other necessary variables
|
||||||
|
$charId = null;
|
||||||
|
$corporationId = null;
|
||||||
|
$allianceId = null;
|
||||||
|
$entityId = null;
|
||||||
|
$entityType = null;
|
||||||
|
|
||||||
|
//See if the entity is already on the list
|
||||||
|
$count = BlacklistEntity::where([
|
||||||
|
'entity_name' => $request->name,
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
//If the count is 0, then add the character to the blacklist
|
||||||
|
if($count === 0) {
|
||||||
|
if($request->type == 'Character') {
|
||||||
|
//Get the character id from the universe end point
|
||||||
|
$entityId = $lookup->CharacterNameToId($request->name);
|
||||||
|
} else if($request->type == 'Corporation') {
|
||||||
|
//Get the corporation id from the universe end point
|
||||||
|
$entityId = $lookup->CorporationNameToId($request->name);
|
||||||
|
} else if($request->type == 'Alliance') {
|
||||||
|
//Get the alliance id from the universe end point
|
||||||
|
$entityId = $lookup->AllianceNameToId($request->name);
|
||||||
|
} else {
|
||||||
|
//Redirect back to the view
|
||||||
|
return redirect('/blacklist/display/add')->with('error', 'Entity Type not allowed.');
|
||||||
|
}
|
||||||
|
|
||||||
|
//If all id's are null, then we couldn't find the entity
|
||||||
|
if($entityId == null) {
|
||||||
|
//Redirect back to the view
|
||||||
|
return redirect('/blacklist/display/add')->with('error', 'Entity Id was not found.');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Store the entity in the table
|
||||||
|
BlacklistEntity::insert([
|
||||||
|
'entity_id' => $entityId,
|
||||||
|
'entity_name' => $request->name,
|
||||||
|
'entity_type' => $request->type,
|
||||||
|
'reason' => $request->reason,
|
||||||
|
'alts' => $request->alts,
|
||||||
|
'lister_id' => auth()->user()->getId(),
|
||||||
|
'lister_name' => auth()->user()->getName(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Return to the view
|
||||||
|
return redirect('/blacklist/display/add')->with('success', $request->name . ' added to the blacklist.');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//Return the view
|
||||||
|
return view('blacklist.add')->with('error', 'Entity of type '. $request->entity_type . ' is already on the black list.');
|
||||||
|
}
|
||||||
|
|
||||||
|
//If we get back to this point redirect to the blacklist with a general error.
|
||||||
|
return redirect('/blacklist/display/add')->with('error', 'General Error. Contact Support.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function RemoveFromBlacklist(Request $request) {
|
||||||
|
//Middleware needed
|
||||||
|
$this->middleware('permission:alliance.recruiter');
|
||||||
|
|
||||||
|
//Validate the input request
|
||||||
|
$this->validate($request, [
|
||||||
|
'name' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Delete the blacklist character
|
||||||
|
BlacklistEntity::where([
|
||||||
|
'entity_name' => $request->name,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
//Return the view
|
||||||
|
return redirect('/blacklist/display')->with('success', 'Character removed from the blacklist.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function DisplayBlacklist() {
|
||||||
|
|
||||||
|
//Get the entire blacklist
|
||||||
|
$blacklist = BlacklistEntity::orderBy('entity_name', 'asc')->paginate(50);
|
||||||
|
|
||||||
|
//Return the view with the data
|
||||||
|
return view('blacklist.list')->with('blacklist', $blacklist);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function SearchInBlacklist(Request $request) {
|
||||||
|
|
||||||
|
//Validate the input from the form
|
||||||
|
$this->validate($request, [
|
||||||
|
'parameter' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$blacklist = DB::table('alliance_blacklist')->where('entity_name', 'like', $request->parameter . "%")
|
||||||
|
->orWhere('entity_type', 'like', $request->parameter . "%")
|
||||||
|
->orWhere('alts', 'like', $request->parameter . "%")
|
||||||
|
->orWhere('reason', 'like', $request->parameter . "%")
|
||||||
|
->orderBy('entity_name', 'asc')
|
||||||
|
->paginate(50);
|
||||||
|
|
||||||
|
$blacklistCount = sizeof($blacklist);
|
||||||
|
|
||||||
|
//If the count for the blacklist is greater than 0, then get the details, and send it to the view
|
||||||
|
if($blacklistCount > 0) {
|
||||||
|
|
||||||
|
//Send the data to the view
|
||||||
|
return view('blacklist.list')->with('blacklist', $blacklist)
|
||||||
|
->with('success', 'Results were found on the blacklist');
|
||||||
|
} else {
|
||||||
|
//If they aren't found, then null out the blacklist variable, and send to the view
|
||||||
|
$blacklist = null;
|
||||||
|
|
||||||
|
return view('blacklist.list')->with('blacklist', $blacklist)
|
||||||
|
->with('error', 'Results were not found on the blacklist.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,18 +4,21 @@ namespace App\Http\Controllers\Contracts;
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use DB;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
//Libraries
|
//Libraries
|
||||||
use App\Library\Esi\Mail;
|
use App\Library\Esi\Mail;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\ProcessSendEveMailJob;
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
use App\User;
|
use App\Models\User\User;
|
||||||
use App\Models\User\UserPermission;
|
use App\Models\User\UserPermission;
|
||||||
use App\Models\Contracts\Contract;
|
use App\Models\Contracts\Contract;
|
||||||
use App\Models\Contracts\Bid;
|
use App\Models\Contracts\Bid;
|
||||||
use App\Models\Contracts\AcceptedBid;
|
use App\Models\Contracts\AcceptedBid;
|
||||||
|
use App\Models\Jobs\JobSendEveMail;
|
||||||
|
|
||||||
class ContractAdminController extends Controller
|
class ContractAdminController extends Controller
|
||||||
{
|
{
|
||||||
@@ -66,6 +69,9 @@ class ContractAdminController extends Controller
|
|||||||
$contract->type = $request->type;
|
$contract->type = $request->type;
|
||||||
$contract->save();
|
$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.');
|
return redirect('/contracts/admin/display')->with('success', 'Contract written.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,9 +135,11 @@ class ContractAdminController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
//Declare class variables
|
//Declare class variables
|
||||||
$mail = new Mail;
|
|
||||||
$tries = 1;
|
$tries = 1;
|
||||||
|
|
||||||
|
//Get the esi config
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
$contract = Contract::where(['contract_id' => $request->contract_id])->first()->toArray();
|
$contract = Contract::where(['contract_id' => $request->contract_id])->first()->toArray();
|
||||||
$bid = Bid::where(['id' => $request->accept, 'contract_id' => $request->contract_id])->first()->toArray();
|
$bid = Bid::where(['id' => $request->accept, 'contract_id' => $request->contract_id])->first()->toArray();
|
||||||
|
|
||||||
@@ -143,18 +151,22 @@ class ContractAdminController extends Controller
|
|||||||
$body .= $contract['body'] . '<br>';
|
$body .= $contract['body'] . '<br>';
|
||||||
$body .= 'Please remit contract when the items are ready to Spatial Forces. Description should be the contract identification number. Request ISK should be the bid amount.';
|
$body .= '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';
|
$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 JobSendEveMail;
|
||||||
}
|
$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) {
|
private function TidyContract($contract, $bid) {
|
||||||
@@ -170,4 +182,17 @@ class ContractAdminController extends Controller
|
|||||||
$accepted->notes = $bid['notes'];
|
$accepted->notes = $bid['notes'];
|
||||||
$accepted->save();
|
$accepted->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function NewContractMail() {
|
||||||
|
//Get the esi config
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
$mail = new JobSendEveMail;
|
||||||
|
$mail->sender = $config['primary'];
|
||||||
|
$mail->subject = 'New Alliance Production Contract Available';
|
||||||
|
$mail->recipient = $config['alliance'];
|
||||||
|
$mail->recipient_type = 'alliance';
|
||||||
|
$mail->body = "A new contract is available for the alliance contracting system. Please check out <a href='https://services.w4rp.space'>Services Site</a> if you want to bid on the production contract.<br><br>Sincerely,<br>Warped Intentions Leadership";
|
||||||
|
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,13 @@ namespace App\Http\Controllers\Contracts;
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use DB;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
//Libraries
|
//Libraries
|
||||||
use App\Library\Lookups\LookupHelper;
|
use App\Library\Lookups\LookupHelper;
|
||||||
//use App\Library\Contracts\ContractHelper;
|
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
use App\User;
|
use App\Models\User\User;
|
||||||
use App\Models\User\UserPermission;
|
use App\Models\User\UserPermission;
|
||||||
use App\Models\Contracts\Contract;
|
use App\Models\Contracts\Contract;
|
||||||
use App\Models\Contracts\Bid;
|
use App\Models\Contracts\Bid;
|
||||||
@@ -22,7 +20,6 @@ class ContractController extends Controller
|
|||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->middleware('auth');
|
$this->middleware('auth');
|
||||||
$this->middleware('role:User');
|
$this->middleware('role:User');
|
||||||
$this->middleware('permission:contract.canbid');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,10 +77,11 @@ class ContractController extends Controller
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
$lowestBid = null;
|
$lowestBid = null;
|
||||||
$lowestCorp = null;
|
$lowestCorp = null;
|
||||||
|
$lowestChar = null;
|
||||||
|
|
||||||
//Fetch all of the current contracts from the database
|
//Fetch all of the current contracts from the database
|
||||||
$contractsTemp = Contract::where('end_date', '>=', $today)
|
$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
|
//Count the number of bids, and add them to the arrays
|
||||||
for($i = 0; $i < sizeof($contractsTemp); $i++) {
|
for($i = 0; $i < sizeof($contractsTemp); $i++) {
|
||||||
@@ -94,10 +92,12 @@ class ContractController extends Controller
|
|||||||
if($lowestBid == null) {
|
if($lowestBid == null) {
|
||||||
$lowestBid = $bid['bid_amount'];
|
$lowestBid = $bid['bid_amount'];
|
||||||
$lowestCorp = $bid['corporation_name'];
|
$lowestCorp = $bid['corporation_name'];
|
||||||
|
$lowestChar = $bid['character_name'];
|
||||||
} else {
|
} else {
|
||||||
if($bid['bid_amount'] < $lowestBid) {
|
if($bid['bid_amount'] < $lowestBid) {
|
||||||
$lowestBid = $bid['bid_amount'];
|
$lowestBid = $bid['bid_amount'];
|
||||||
$lowestCorp = $bid['corporation_name'];
|
$lowestCorp = $bid['corporation_name'];
|
||||||
|
$lowestChar = $bid['character_name'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,10 @@ class ContractController extends Controller
|
|||||||
$contracts[$i]['bids'] = $bids;
|
$contracts[$i]['bids'] = $bids;
|
||||||
$contracts[$i]['lowestbid'] = $lowestBid;
|
$contracts[$i]['lowestbid'] = $lowestBid;
|
||||||
$contracts[$i]['lowestcorp'] = $lowestCorp;
|
$contracts[$i]['lowestcorp'] = $lowestCorp;
|
||||||
|
$contracts[$i]['lowestchar'] = $lowestChar;
|
||||||
|
|
||||||
|
//Reset the lowestBid back to null
|
||||||
|
$lowestBid = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Call for the view to be displayed
|
//Call for the view to be displayed
|
||||||
@@ -225,8 +228,11 @@ class ContractController extends Controller
|
|||||||
$characterId = auth()->user()->getId();
|
$characterId = auth()->user()->getId();
|
||||||
$characterName = auth()->user()->getName();
|
$characterName = auth()->user()->getName();
|
||||||
//Use the lookup helper in order to find the user's corporation id and name
|
//Use the lookup helper in order to find the user's corporation id and name
|
||||||
$corporationId = $lookup->LookupCharacter($characterId);
|
$char = $lookup->GetCharacterInfo($characterId);
|
||||||
$corporationName = $lookup->LookupCorporationName($corporationId);
|
$corporationId = $char->corporation_id;
|
||||||
|
//use the lookup helper in order to find the corporation's name from it's id.
|
||||||
|
$corp = $lookup->GetCorporationInfo($corporationId);
|
||||||
|
$corporationName = $corp->name;
|
||||||
|
|
||||||
//Before saving a bid let's check to see if the user already placed a bid on the contract
|
//Before saving a bid let's check to see if the user already placed a bid on the contract
|
||||||
$found = Bid::where([
|
$found = Bid::where([
|
||||||
|
|||||||
@@ -5,16 +5,23 @@ namespace App\Http\Controllers\Dashboard;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use DB;
|
use DB;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
//Libraries
|
//Libraries
|
||||||
use App\Library\Taxes\TaxesHelper;
|
use App\Library\Taxes\TaxesHelper;
|
||||||
|
use App\Library\Wiki\WikiHelper;
|
||||||
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
use App\Library\SRP\SRPHelper;
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
use App\User;
|
use App\Models\User\User;
|
||||||
use App\Models\User\UserRole;
|
use App\Models\User\UserRole;
|
||||||
use App\Models\User\UserPermission;
|
use App\Models\User\UserPermission;
|
||||||
use App\Models\User\AvailableUserPermission;
|
use App\Models\User\AvailableUserPermission;
|
||||||
use App\Models\Admin\AllowedLogin;
|
use App\Models\Admin\AllowedLogin;
|
||||||
|
use App\Models\Doku\DokuGroupNames;
|
||||||
|
use App\Models\Doku\DokuMember;
|
||||||
|
use App\Models\Doku\DokuUser;
|
||||||
|
|
||||||
class AdminController extends Controller
|
class AdminController extends Controller
|
||||||
{
|
{
|
||||||
@@ -23,25 +30,141 @@ class AdminController extends Controller
|
|||||||
$this->middleware('role:Admin');
|
$this->middleware('role:Admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function displayDashboard() {
|
public function displayTestAdminDashboard() {
|
||||||
|
return view('admin.dashboards.testdashboard');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showJournalEntries() {
|
||||||
|
$dateInit = Carbon::now();
|
||||||
|
$date = $dateInit->subDays(30);
|
||||||
|
|
||||||
|
$journal = DB::select('SELECT amount,reason,description,date FROM `player_donation_journal` WHERE corporation_id=98287666 AND date >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) ORDER BY date DESC');
|
||||||
|
|
||||||
|
return view('admin.dashboards.walletjournal')->with('journal', $journal);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 searchUsers(Request $request) {
|
||||||
|
//Declare array variables
|
||||||
|
$user = array();
|
||||||
|
$permission = array();
|
||||||
|
$userArr = array();
|
||||||
|
$permString = null;
|
||||||
|
|
||||||
|
//Validate the input from the form
|
||||||
|
$this->validate($request, [
|
||||||
|
'parameter' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$usersArr = User::where('name', 'like', $request->parameter . "%")->paginate(50);
|
||||||
|
|
||||||
|
foreach($usersArr as $user) {
|
||||||
|
$user->role = $user->getRole();
|
||||||
|
|
||||||
|
$permCount = UserPermission::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
if($permCount > 0) {
|
||||||
|
$perms = UserPermission::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->get('permission')->toArray();
|
||||||
|
|
||||||
|
foreach($perms as $perm) {
|
||||||
|
$permString .= $perm['permission'] . ', ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->permission = $permString;
|
||||||
|
} else {
|
||||||
|
$user->permission = 'No Permissions';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.dashboards.users.searched')->with('usersArr', $usersArr);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 displayTaxes() {
|
||||||
//Declare variables needed for displaying items on the page
|
//Declare variables needed for displaying items on the page
|
||||||
$months = 3;
|
$months = 3;
|
||||||
$pi = array();
|
$pi = array();
|
||||||
$industry = array();
|
$industry = array();
|
||||||
$reprocessing = array();
|
$reprocessing = array();
|
||||||
$office = array();
|
$office = array();
|
||||||
$user = array();
|
|
||||||
$permission = array();
|
|
||||||
$entities = array();
|
|
||||||
$corpId = 98287666;
|
$corpId = 98287666;
|
||||||
|
$srpActual = array();
|
||||||
|
$srpLoss = array();
|
||||||
|
|
||||||
/** Taxes Pane */
|
/** Taxes Pane */
|
||||||
//Declare classes needed for displaying items on the page
|
//Declare classes needed for displaying items on the page
|
||||||
$tHelper = new TaxesHelper();
|
$tHelper = new TaxesHelper();
|
||||||
|
$srpHelper = new SRPHelper();
|
||||||
//Get the dates for the tab panes
|
//Get the dates for the tab panes
|
||||||
$dates = $tHelper->GetTimeFrameInMonths($months);
|
$dates = $tHelper->GetTimeFrameInMonths($months);
|
||||||
//Get the data for the Taxes Pane
|
//Get the data for the Taxes Pane
|
||||||
foreach($dates as $date) {
|
foreach($dates as $date) {
|
||||||
|
//Get the srp actual pay out for the date range
|
||||||
|
$srpActual[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($srpHelper->GetAllianceSRPActual($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
|
//Get the srp loss value for the date range
|
||||||
|
$srpLoss[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($srpHelper->GetAllianceSRPLoss($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
//Get the pi taxes for the date range
|
//Get the pi taxes for the date range
|
||||||
$pis[] = [
|
$pis[] = [
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
@@ -65,63 +188,53 @@ class AdminController extends Controller
|
|||||||
//Get the market taxes for the date range
|
//Get the market taxes for the date range
|
||||||
$markets[] = [
|
$markets[] = [
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
'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
|
//Get the jump gate taxes for the date range
|
||||||
$jumpgates[] = [
|
$jumpgates[] = [
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
'gross' => number_format($tHelper->GetJumpGateGross($date['start'], $date['end']), 2, ".", ","),
|
'gross' => number_format($tHelper->GetJumpGateGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
];
|
];
|
||||||
|
|
||||||
$pigross[] = [
|
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
|
||||||
'gross' => number_format($tHelper->GetPiSalesGross($date['start'], $date['end']), 2, ".", ","),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Users & Permissions Pane */
|
return view('admin.dashboards.taxes')->with('pis', $pis)
|
||||||
//Get the users from the database to allow a selection of users for various parts of the webpage
|
->with('industrys', $industrys)
|
||||||
$users = User::pluck('name')->all();
|
->with('offices', $offices)
|
||||||
//Get the available permissions from the database to allow a selection of permissions
|
->with('markets', $markets)
|
||||||
$permissions = AvailableUserPermission::pluck('permission')->all();
|
->with('jumpgates', $jumpgates)
|
||||||
//Create the user key value pairs
|
->with('reprocessings', $reprocessings)
|
||||||
foreach($users as $key => $value) {
|
->with('srpActual', $srpActual)
|
||||||
$user[$value] = $value;
|
->with('srpLoss', $srpLoss);
|
||||||
}
|
|
||||||
//Create the permission key value pairs
|
|
||||||
foreach($permissions as $key => $value) {
|
|
||||||
$permission[$value] = $value;
|
|
||||||
}
|
|
||||||
//Create the data array
|
|
||||||
$data = [
|
|
||||||
'users' => $user,
|
|
||||||
'permissions' => $permission,
|
|
||||||
];
|
|
||||||
|
|
||||||
/** Entities for allowed logins */
|
|
||||||
$legacys = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_name')->toArray();
|
|
||||||
$renters = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_name')->toArray();
|
|
||||||
//Compile a list of entities by their entity_id
|
|
||||||
foreach($legacys as $legacy) {
|
|
||||||
$entities[] = $legacy;
|
|
||||||
}
|
|
||||||
foreach($renters as $renter) {
|
|
||||||
$entities[] = $renter;
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('admin.dashboard')->with('data', $data)
|
|
||||||
->with('pis', $pis)
|
|
||||||
->with('industrys', $industrys)
|
|
||||||
->with('offices', $offices)
|
|
||||||
->with('markets', $markets)
|
|
||||||
->with('jumpgates', $jumpgates)
|
|
||||||
->with('reprocessings', $reprocessings)
|
|
||||||
->with('entities', $entities)
|
|
||||||
->with('pigross', $pigross);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function modifyRole(Request $request) {
|
public function displayModifyUser(Request $request) {
|
||||||
return redirect('/admin/dashboard')->with('error', 'Not implemented yet.');
|
$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/users')->with('error', 'Not Implemented Yet.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addPermission(Request $request) {
|
public function addPermission(Request $request) {
|
||||||
@@ -141,9 +254,9 @@ class AdminController extends Controller
|
|||||||
$perm->permission = $permission;
|
$perm->permission = $permission;
|
||||||
$perm->save();
|
$perm->save();
|
||||||
|
|
||||||
return redirect('/admin/dashboard')->with('success', 'User udpated!');
|
return redirect('/admin/dashboard/users')->with('success', 'User udpated!');
|
||||||
} else {
|
} else {
|
||||||
return redirect('/admin/dashboard')->with('error', 'User not updated or already has the permission.');
|
return redirect('/admin/dashboard/users')->with('error', 'User not updated or already has the permission.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +279,7 @@ class AdminController extends Controller
|
|||||||
//Delete the user from the user table
|
//Delete the user from the user table
|
||||||
DB::table('users')->where(['character_id' => $data[0]->character_id])->delete();
|
DB::table('users')->where(['character_id' => $data[0]->character_id])->delete();
|
||||||
|
|
||||||
return redirect('/admin/dashboard')->with('success', 'User deleted from the site.');
|
return redirect('/admin/dashboard/users')->with('success', 'User deleted from the site.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addAllowedLogin(Request $request) {
|
public function addAllowedLogin(Request $request) {
|
||||||
@@ -182,8 +295,8 @@ class AdminController extends Controller
|
|||||||
$found = AllowedLogin::where([
|
$found = AllowedLogin::where([
|
||||||
'entity_type' => $request->allowedentityType,
|
'entity_type' => $request->allowedentityType,
|
||||||
'entity_name' => $request->allowedEntityName,
|
'entity_name' => $request->allowedEntityName,
|
||||||
])->get();
|
])->count();
|
||||||
if($found != null) {
|
if($found != 0) {
|
||||||
AllowedLogin::where([
|
AllowedLogin::where([
|
||||||
'entity_type' => $request->allowedEntityType,
|
'entity_type' => $request->allowedEntityType,
|
||||||
'entity_name' => $request->allowedEntityName,
|
'entity_name' => $request->allowedEntityName,
|
||||||
@@ -199,6 +312,7 @@ class AdminController extends Controller
|
|||||||
$login->entity_name = $request->allowedEntityName;
|
$login->entity_name = $request->allowedEntityName;
|
||||||
$login->entity_type = $request->allowedEntityType;
|
$login->entity_type = $request->allowedEntityType;
|
||||||
$login->login_type = $request->allowedLoginType;
|
$login->login_type = $request->allowedLoginType;
|
||||||
|
$login->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect('/admin/dashboard')->with('success', 'Entity added to allowed login list.');
|
return redirect('/admin/dashboard')->with('success', 'Entity added to allowed login list.');
|
||||||
@@ -216,4 +330,157 @@ class AdminController extends Controller
|
|||||||
|
|
||||||
return redirect('/admin/dashboard')->with('success', 'Entity removed from allowed login list.');
|
return redirect('/admin/dashboard')->with('success', 'Entity removed from allowed login list.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the wiki dashboard for wiki functions
|
||||||
|
*/
|
||||||
|
public function displayWikiDashboard() {
|
||||||
|
//Declare some variables
|
||||||
|
$wikiUsers = array();
|
||||||
|
$wikiGroups = array();
|
||||||
|
|
||||||
|
$tempUsers = DokuUser::all();
|
||||||
|
$tempGroups = DokuGroupNames::all();
|
||||||
|
$wikiMembership = DokuMember::all();
|
||||||
|
|
||||||
|
//Create a list of users based on id and name for the select form
|
||||||
|
foreach($tempUsers as $temp) {
|
||||||
|
$wikiUsers[$temp->id] = $temp->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
asort($wikiUsers);
|
||||||
|
|
||||||
|
foreach($tempGroups as $temp) {
|
||||||
|
$wikiGroups[$temp->id] = $temp->gname;
|
||||||
|
}
|
||||||
|
|
||||||
|
asort($wikiGroups);
|
||||||
|
|
||||||
|
return view('admin.dashboards.wiki')->with('wikiUsers', $wikiUsers)
|
||||||
|
->with('wikiGroups', $wikiGroups)
|
||||||
|
->with('wikiMembership', $wikiMembership);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a wiki user
|
||||||
|
*/
|
||||||
|
public function deleteWikiUser(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'user' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Declare helper variable
|
||||||
|
$wikiHelper = new WikiHelper;
|
||||||
|
|
||||||
|
$wikiHelper->DeleteWikiUser($request->user);
|
||||||
|
|
||||||
|
redirect('/admin/dashboard/wiki')->with('success', 'User: ' . $request->user . ' has been deleted.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a group to a wiki user
|
||||||
|
*/
|
||||||
|
public function addWikiUserGroup(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'user' => 'required', //User Id number
|
||||||
|
'groupname' => 'required', //Group Id number
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Declare some helper variables
|
||||||
|
$wikiHelper = new WikiHelper;
|
||||||
|
|
||||||
|
//Check to see if the user has the group we are going to add first
|
||||||
|
if($wikiHelper->UserHasGroup($request->user, $request->groupname)) {
|
||||||
|
return redirect('/admin/dashboard/wiki')->with('error', 'User already has the group.');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add the user to the wiki group
|
||||||
|
$wikiHelper->AddUserToGroup($request->user, $request->groupname);
|
||||||
|
|
||||||
|
return redirect('/admin/dashboard/wiki')->with('success', 'User added to group for the wiki.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a group from a wiki user
|
||||||
|
*/
|
||||||
|
public function removeWikiUserGroup(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'user' => 'required',
|
||||||
|
'groupname' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Declare some helper variables
|
||||||
|
$wikiHelper = new WikiHelper;
|
||||||
|
|
||||||
|
//Check to see if the user has the group we are going to remove them from
|
||||||
|
if(!$wikiHelper->UserHasGroup($request->user, $request->groupname)) {
|
||||||
|
return redirect('/admin/dashboard/wiki')->with('error', 'User does not have the group to remove.');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Remove the user from the wiki group
|
||||||
|
$wikiHelper->RemoveUserFromGroup($request->user, $request->groupname);
|
||||||
|
|
||||||
|
return redirect('/admin/dashboard/wiki')->with('success', 'Removed user from group ' . $request->grouopname);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a user from all wiki groups
|
||||||
|
*/
|
||||||
|
public function removeWikiUserAllGroups(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'user' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Declare variable
|
||||||
|
$wikiHelper = new WikiHelper;
|
||||||
|
|
||||||
|
$wikiHelper->RemoveUserFromAllGroups($request->user);
|
||||||
|
|
||||||
|
return redirect('/admin/dashboard/wiki')->with('success', 'User successfully removed from all groups.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a new group for wiki user's to be added to
|
||||||
|
*/
|
||||||
|
public function insertNewWikiUserGroup(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'group' => 'required',
|
||||||
|
'description' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Declare variable
|
||||||
|
$wikiHelper = new WikiHelper;
|
||||||
|
|
||||||
|
$wikiHelper->AddNewUserGroup($request->group, $request->description);
|
||||||
|
|
||||||
|
return redirect('/admin/dashboard/wiki')->with('success', 'Added new user group.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function purgeWikiUsers(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'admin' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Declare helper classes
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$wikiHelper = new WikiHelper;
|
||||||
|
|
||||||
|
//Search the names and verify against the lookup table
|
||||||
|
//to find the corporation and / or alliance they belong to.
|
||||||
|
foreach($users as $user) {
|
||||||
|
//Let's look up the character in the user table by their name.
|
||||||
|
//If no name is found, then delete the user and have them start over with the wiki permissions
|
||||||
|
$count = User::where(['name' => $user])->count();
|
||||||
|
if($count > 0) {
|
||||||
|
//If the user is not allowed, then delete the user, otherwise, leave the user untouched
|
||||||
|
if(!$wikiHelper->AllowedUser($user)) {
|
||||||
|
$wikiHelper->DeleteWikiUser($user);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$wikiHelper->DeleteWikiUser($user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect('/admin/dashboard/wiki')->with('success', 'Wiki has been purged.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
59
app/Http/Controllers/Dashboard/AdminDashboardController.php
Normal file
59
app/Http/Controllers/Dashboard/AdminDashboardController.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Dashboard;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Khill\Lavacharts\Lavacharts;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
//Libraries
|
||||||
|
use App\Library\Taxes\TaxesHelper;
|
||||||
|
use App\Library\Wiki\WikiHelper;
|
||||||
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
use App\Library\SRP\SRPHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
|
||||||
|
|
||||||
|
class AdminDashboardController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->middleware('role:User');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the administration dashboard.
|
||||||
|
*/
|
||||||
|
public function displayAdminDashboard() {
|
||||||
|
if(auth()->user()->hasRole('Admin') || auth()->user()->hasPermission('moon.admin') || auth()->user()->hasPermission('srp.admin') || auth()->user()->hasPermission('contract.admin')) {
|
||||||
|
//Do nothing and continue on
|
||||||
|
} else {
|
||||||
|
redirect('/dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Declare variables we will need
|
||||||
|
$days = 30;
|
||||||
|
$sovBills = array();
|
||||||
|
$pi = array();
|
||||||
|
$industry = array();
|
||||||
|
$reprocessing = array();
|
||||||
|
$office = array();
|
||||||
|
$sprActual = array();
|
||||||
|
$srpLoss = array();
|
||||||
|
|
||||||
|
//Get the data for the sov expenses for a graph
|
||||||
|
|
||||||
|
|
||||||
|
return view('admin.dashboards.dashboard');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,15 +2,21 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Dashboard;
|
namespace App\Http\Controllers\Dashboard;
|
||||||
|
|
||||||
|
//Internal Libraries
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Khill\Lavacharts\Lavacharts;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Models
|
||||||
use App\Models\Esi\EsiScope;
|
use App\Models\Esi\EsiScope;
|
||||||
use App\Models\Esi\EsiToken;
|
use App\Models\Esi\EsiToken;
|
||||||
use App\Models\User\UserPermission;
|
use App\Models\User\UserPermission;
|
||||||
use App\Models\User\UserRole;
|
use App\Models\User\UserRole;
|
||||||
|
use App\Models\SRP\SRPShip;
|
||||||
|
use App\Models\User\UserAlt;
|
||||||
|
|
||||||
class DashboardController extends Controller
|
class DashboardController extends Controller
|
||||||
{
|
{
|
||||||
@@ -32,7 +38,159 @@ class DashboardController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
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();
|
||||||
|
|
||||||
|
//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 +200,57 @@ class DashboardController extends Controller
|
|||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function profile() {
|
public function profile() {
|
||||||
$scopes = EsiScope::where('character_id', Auth()->user()->character_id)->get();
|
//Declare some variables
|
||||||
$permissions = UserPermission::where('character_id', Auth()->user()->characer_id)->get();
|
$alts = null;
|
||||||
$roles = UserRole::where('character_id', Auth()->user()->character_id)->get();
|
$scopes = null;
|
||||||
|
$permissions = null;
|
||||||
$data = [
|
$roles = null;
|
||||||
'scopes' => $scopes,
|
|
||||||
'permissions' => $permissions,
|
|
||||||
'roles' => $roles,
|
|
||||||
];
|
|
||||||
|
|
||||||
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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
400
app/Http/Controllers/Dashboard/StatisticsController.php
Normal file
400
app/Http/Controllers/Dashboard/StatisticsController.php
Normal file
@@ -0,0 +1,400 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Dashboard;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Khill\Lavacharts\Lavacharts;
|
||||||
|
|
||||||
|
//Libraries
|
||||||
|
use App\Library\Taxes\TaxesHelper;
|
||||||
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
use App\Library\SRP\SRPHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\User\User;
|
||||||
|
use App\Models\Doku\DokuGroupNames;
|
||||||
|
use App\Models\Doku\DokuMember;
|
||||||
|
use App\Models\Doku\DokuUser;
|
||||||
|
use App\Models\SRP\SrpFleetType;
|
||||||
|
use App\Models\SRP\SRPShip;
|
||||||
|
use App\Models\SRP\SrpShipType;
|
||||||
|
use App\Models\SRP\SrpPayout;
|
||||||
|
|
||||||
|
|
||||||
|
class StatisticsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
$this->middleware('auth');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display Jump Bridge Statistics
|
||||||
|
*/
|
||||||
|
public function displayJumpBridgeStatistics() {
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
$lava = new Lavacharts;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display Taxes Statistics
|
||||||
|
*/
|
||||||
|
public function displayTaxes() {
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
//Declare variables needed for displaying items on the page
|
||||||
|
$months = 3;
|
||||||
|
$pi = array();
|
||||||
|
$industry = array();
|
||||||
|
$reprocessing = array();
|
||||||
|
$office = array();
|
||||||
|
$corpId = 98287666;
|
||||||
|
$srpActual = array();
|
||||||
|
$srpLoss = array();
|
||||||
|
|
||||||
|
/** Taxes Pane */
|
||||||
|
//Declare classes needed for displaying items on the page
|
||||||
|
$tHelper = new TaxesHelper;
|
||||||
|
$srpHelper = new SRPHelper;
|
||||||
|
//Get the dates for the tab panes
|
||||||
|
$dates = $tHelper->GetTimeFrameInMonths($months);
|
||||||
|
//Get the data for the Taxes Pane
|
||||||
|
foreach($dates as $date) {
|
||||||
|
//Get the srp actual pay out for the date range
|
||||||
|
$srpActual[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($srpHelper->GetAllianceSRPActual($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
|
//Get the srp loss value for the date range
|
||||||
|
$srpLoss[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($srpHelper->GetAllianceSRPLoss($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
|
//Get the pi taxes for the date range
|
||||||
|
$pis[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetPIGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the industry taxes for the date range
|
||||||
|
$industrys[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetIndustryGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the reprocessing taxes for the date range
|
||||||
|
$reprocessings[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetReprocessingGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the office taxes for the date range
|
||||||
|
$offices[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetOfficeGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the market taxes for the date range
|
||||||
|
$markets[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetAllianceMarketGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the jump gate taxes for the date range
|
||||||
|
$jumpgates[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetJumpGateGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.dashboards.taxes')->with('pis', $pis)
|
||||||
|
->with('industrys', $industrys)
|
||||||
|
->with('offices', $offices)
|
||||||
|
->with('markets', $markets)
|
||||||
|
->with('jumpgates', $jumpgates)
|
||||||
|
->with('reprocessings', $reprocessings)
|
||||||
|
->with('srpActual', $srpActual)
|
||||||
|
->with('srpLoss', $srpLoss);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display wiki statistics
|
||||||
|
*/
|
||||||
|
public function displayWikiStatistics() {
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display SRP Statistics
|
||||||
|
*/
|
||||||
|
public function displaySRPStatistics() {
|
||||||
|
$months = 3;
|
||||||
|
$barChartData = array();
|
||||||
|
$start = Carbon::now()->toDateTimeString();
|
||||||
|
$end = Carbon::now()->subMonths(1)->toDateTimeString();
|
||||||
|
|
||||||
|
//Declare the Lavacharts variable
|
||||||
|
$lava = new Lavacharts;
|
||||||
|
|
||||||
|
//We need a function from this library rather than recreating a new library
|
||||||
|
$srpHelper = new SRPHelper();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pie chart for the number of approved, denied, and under review payouts currently in the system.
|
||||||
|
*/
|
||||||
|
//Get the count of open srp requests
|
||||||
|
$pieOpen = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
['created_at', '>=', $end],
|
||||||
|
])->count();
|
||||||
|
//Get the count of approved srp requests
|
||||||
|
$pieApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
['created_at', '>=', $end],
|
||||||
|
])->count();
|
||||||
|
//Get the count of denied srp requests
|
||||||
|
$pieDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
['created_at', '>=', $end],
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
//Create a new datatable for the lavachart.
|
||||||
|
$srp = $lava->DataTable();
|
||||||
|
//Add string columns, number columns, and data rows for the chart
|
||||||
|
$srp->addStringColumn('ISK Value')
|
||||||
|
->addNumberColumn('ISK')
|
||||||
|
->addRow(['Approved', $pieApproved])
|
||||||
|
->addRow(['Denied', $pieDenied])
|
||||||
|
->addRow(['Under Review', $pieOpen]);
|
||||||
|
//Create the pie chart in memory with any options needed to render the chart
|
||||||
|
$lava->PieChart('SRP Stats', $srp, [
|
||||||
|
'title' => 'SRP Stats',
|
||||||
|
'is3D' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gauage chart for showing number of open srp requests
|
||||||
|
*/
|
||||||
|
//Create a new datatable in the
|
||||||
|
$adur = $lava->DataTable();
|
||||||
|
//Add string columns, number columns, and data row for the chart
|
||||||
|
$adur->addStringColumn('Type')
|
||||||
|
->addNumberColumn('Value')
|
||||||
|
->addRow(['Under Review', $pieOpen]);
|
||||||
|
//Create the gauge chart with any options needed to render the chart
|
||||||
|
$lava->GaugeChart('SRP', $adur, [
|
||||||
|
'width' => 400,
|
||||||
|
'greenFrom' => 0,
|
||||||
|
'greenTo' => 20,
|
||||||
|
'yellowFrom' => 20,
|
||||||
|
'yellowTo' => 40,
|
||||||
|
'redFrom' => 40,
|
||||||
|
'redTo' => 100,
|
||||||
|
'majorTicks' => [
|
||||||
|
'Safe',
|
||||||
|
'Critical',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a vertical chart of all of the cost codes for the ships being SRP'ed.
|
||||||
|
* The chart will be by cost code of ships being replaced
|
||||||
|
*/
|
||||||
|
//Declare the data table
|
||||||
|
$costCodeChart = $lava->DataTable();
|
||||||
|
|
||||||
|
//Get the approved, under review, and denied cost codes and amounts
|
||||||
|
$t1fdcApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T1FDC',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t1fdcUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T1FDC',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t1fdcDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T1FDC',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$t1bcApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T1BC',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t1bcUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T1BC',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t1bcDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T1BC',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$t2fdApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T2FD',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t2fdUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T2FD',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t2fdDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T2FD',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$t3dApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T3D',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t3dUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T3D',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t3dDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T3D',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$t1t2logiApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T1T2Logi',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t1t2logiUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T1T2Logi',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t1t2logiDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T1T2Logi',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$reconsApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'REC',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$reconsUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'REC',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$reconsDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'REC',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$t2cApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T2C',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t2cUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T2C',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t2cDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T2C',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$t3cApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T3C',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t3cUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T3C',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t3cDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T3C',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$commandApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'COM',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$commandUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'COM',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$commandDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'COM',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$interdictorApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'INTD',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$interdictorUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'INTD',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$interdictorDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'INTD',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$t1bsApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T1BS',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t1bsUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T1BS',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t1bsDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T1BS',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$dksApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'DKS',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$dksUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'DKS',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$dksDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'DKS',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
|
||||||
|
//Add string column, number columns.
|
||||||
|
$costCodeChart->addStringColumn('SRP Costs')
|
||||||
|
->addNumberColumn('Approved')
|
||||||
|
->addNumberColumn('Under Review')
|
||||||
|
->addNumberColumn('Denied')
|
||||||
|
->addRow(['T1FDC', $t1fdcApproved, $t1fdcUnderReview, $t1fdcDenied])
|
||||||
|
->addRow(['T1BC', $t1bcApproved, $t1bcUnderReview, $t1bcDenied])
|
||||||
|
->addRow(['T1BS', $t1bsApproved, $t1bsUnderReview, $t1bsDenied])
|
||||||
|
->addRow(['T2FD', $t2fdApproved, $t2fdUnderReview, $t2fdDenied])
|
||||||
|
->addRow(['T2C', $t2cApproved, $t2cUnderReview, $t2cDenied])
|
||||||
|
->addRow(['T1T2Logi', $t1t2logiApproved, $t1t2logiUnderReview, $t1t2logiDenied])
|
||||||
|
->addRow(['T3D', $t3dApproved, $t3dUnderReview, $t3dDenied])
|
||||||
|
->addRow(['T3C', $t3cApproved, $t3cUnderReview, $t3cDenied])
|
||||||
|
->addRow(['RECON', $reconsApproved, $reconsUnderReview, $reconsDenied])
|
||||||
|
->addRow(['COMMAND', $commandApproved, $commandUnderReview, $commandDenied])
|
||||||
|
->addRow(['DKS', $dksApproved, $dksUnderReview, $dksDenied]);
|
||||||
|
|
||||||
|
$lava->ColumnChart('Cost Codes', $costCodeChart, [
|
||||||
|
'columns' => 4,
|
||||||
|
'title' => 'Cost Code SRP Chart',
|
||||||
|
'titleTextStyle' => [
|
||||||
|
'color' => '#eb6b2c',
|
||||||
|
'fontSize' => 14,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return view('srp.admin.statistics')->with('lava', $lava);
|
||||||
|
}
|
||||||
|
}
|
||||||
133
app/Http/Controllers/Flex/FlexAdminController.php
Normal file
133
app/Http/Controllers/Flex/FlexAdminController.php
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Flex;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Auth;
|
||||||
|
use DB;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Flex\FlexStructure;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
|
class FlexAdminController extends Controller
|
||||||
|
{
|
||||||
|
//Constructor
|
||||||
|
public function __construct() {
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to display all active flex structures and
|
||||||
|
* the information regarding the flex structure
|
||||||
|
*/
|
||||||
|
public function displayFlexStructures() {
|
||||||
|
//Get the structures from the database
|
||||||
|
$structures = FlexStructure::all();
|
||||||
|
|
||||||
|
//Return the view with the data
|
||||||
|
return view('flex.list')->with('structures', $structures);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to display form for adding new flex structure
|
||||||
|
*/
|
||||||
|
public function displayAddFlexStructure() {
|
||||||
|
return view('flex.add');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to add new flex structure to the database
|
||||||
|
*/
|
||||||
|
public function addFlexStructure(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'requestor_name' => 'required',
|
||||||
|
'requestor_corp_name' => 'required',
|
||||||
|
'system' => 'required',
|
||||||
|
'structure_type' => 'required',
|
||||||
|
'structure_cost' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Delcare variables and classes
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
|
||||||
|
//From the character name find the character id
|
||||||
|
$charId = $lookup->CharacterNameToId($request->requestor_name);
|
||||||
|
|
||||||
|
//From the corporation name find the corporation id
|
||||||
|
$corpId = $lookup->CorporationNameToId($request->requestor_corp_name);
|
||||||
|
|
||||||
|
//From the system name find the system id
|
||||||
|
$systemId = $lookup->SystemNameToId($request->system);
|
||||||
|
|
||||||
|
//Create the database model
|
||||||
|
$flex = new FlexStructure;
|
||||||
|
$flex->requestor_id = $charId;
|
||||||
|
$flex->requestor_name = $request->requestor_name;
|
||||||
|
$flex->requestor_corp_id = $corpId;
|
||||||
|
$flex->requestor_corp_name = $request->requestor_corp_name;
|
||||||
|
$flex->system_id = $systemId;
|
||||||
|
$flex->system = $request->system;
|
||||||
|
$flex->structure_type = $request->structure_type;
|
||||||
|
$flex->structure_cost = $request->structure_cost;
|
||||||
|
if(isset($request->paid_until)) {
|
||||||
|
$flex->paid_until = $request->paid_until;
|
||||||
|
}
|
||||||
|
$flex->save();
|
||||||
|
|
||||||
|
return redirect('/flex/display')->with('success', 'Flex Structure Added.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to update paid until section of the flex structure in the database
|
||||||
|
*/
|
||||||
|
public function updateFlexStructure(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'paid_until' => 'required',
|
||||||
|
'requestor_id' => 'required',
|
||||||
|
'requestor_corp_id' => 'required',
|
||||||
|
'system_id' => 'required',
|
||||||
|
'structure_type' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
FlexStructure::where([
|
||||||
|
'requestor_id' => $request->requestor_id,
|
||||||
|
'requestor_corp_id' => $request->requestor_corp_id,
|
||||||
|
'system_id' => $request->system_id,
|
||||||
|
'structure_type' => $request->structure_type,
|
||||||
|
])->update([
|
||||||
|
'paid_until' => $request->paid_until,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect('/flex/display')->with('success', 'Flex Structure Updated.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Funciton to remove flex structure from the database
|
||||||
|
*/
|
||||||
|
public function removeFlexStructure(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'requestor_id' => 'required',
|
||||||
|
'requestor_corp_id' => 'required',
|
||||||
|
'system_id' => 'required',
|
||||||
|
'structure_type' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
FlexStructure::where([
|
||||||
|
'requestor_id' => $request->requestor_id,
|
||||||
|
'requestor_corp_id' => $request->requestor_corp_id,
|
||||||
|
'system' => $request->system_id,
|
||||||
|
'structure_type' => $request->structure_type,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
return redirect('/flex/display')->with('success', 'Flex Structure Entry Removed.');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
86
app/Http/Controllers/Logistics/FuelController.php
Normal file
86
app/Http/Controllers/Logistics/FuelController.php
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Logistics;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use DB;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Khill\Lavacharts\Lavacharts;
|
||||||
|
use Auth;
|
||||||
|
use Charts;
|
||||||
|
|
||||||
|
//Library Helpers
|
||||||
|
use App\Library\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('role:User');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayStructures() {
|
||||||
|
//Declare variables
|
||||||
|
$jumpGates = array();
|
||||||
|
$lava = new Lavacharts;
|
||||||
|
|
||||||
|
//Declare the class helpers
|
||||||
|
$sHelper = new StructureHelper(null, null, null);
|
||||||
|
$aHelper = new AssetHelper(null, null, null);
|
||||||
|
|
||||||
|
//Setup the charts
|
||||||
|
$gauge = $lava->DataTable();
|
||||||
|
$gauge->addStringColumn('Fuel')
|
||||||
|
->addNumberColumn('Units');
|
||||||
|
|
||||||
|
//Get all of the jump gates
|
||||||
|
$gates = $sHelper->GetStructuresByType('Ansiblex Jump Gate');
|
||||||
|
|
||||||
|
foreach($gates as $gate) {
|
||||||
|
$liquidOzone = $aHelper->GetAssetByType(16273, $gate->structure_id);
|
||||||
|
$temp = [
|
||||||
|
'name' => $gate->structure_name,
|
||||||
|
'system' => $gate->solar_system_name,
|
||||||
|
'fuel_expires' => $gate->fuel_expires,
|
||||||
|
'liquid_ozone' => $liquidOzone,
|
||||||
|
'link' => '/logistics/fuel/display/' . $gate->structure_id . '/',
|
||||||
|
];
|
||||||
|
|
||||||
|
array_push($jumpGates, $temp);
|
||||||
|
|
||||||
|
if($liquidOzone > 1000000) {
|
||||||
|
$liquidOzone = 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
$gauge->addRow([$gate->solar_system_name, $liquidOzone]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$lava->GaugeChart('Liquid Ozone', $gauge, [
|
||||||
|
'min' => 0,
|
||||||
|
'max' => 1000000,
|
||||||
|
'greenFrom' => 0,
|
||||||
|
'greenTo' => 150000,
|
||||||
|
'greenColor' => '#DC3912',
|
||||||
|
'yellowFrom' => 150000,
|
||||||
|
'yellowTo' => 300000,
|
||||||
|
'yellowColor' => '#FF9900',
|
||||||
|
'redFrom' => 300000,
|
||||||
|
'redTo' => 1000000,
|
||||||
|
'redColor' => '#109618',
|
||||||
|
'majorTicks' => [
|
||||||
|
'Empty',
|
||||||
|
'Full',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return view('logistics.fuel')->with('jumpGates', $jumpGates)
|
||||||
|
->with('lava', $lava);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Logistics;
|
||||||
|
|
||||||
|
//Internal Libraries
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\ProcessSendEveMailJob;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Logistics\AnchorStructure;
|
||||||
|
use App\Models\Jobs\JobSendEveMail;
|
||||||
|
|
||||||
|
class StructureRequestAdminController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct() {
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->middleware('permission:fc.team');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayRequests() {
|
||||||
|
$reqs = AnchorStructure::all();
|
||||||
|
|
||||||
|
return view('structurerequest.display.structurerequests')->with('reqs', $reqs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteRequest(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'id' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
AnchorStructure::where([
|
||||||
|
'id' => $request->id,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
return redirect('/structures/display/requests');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Logistics;
|
||||||
|
|
||||||
|
//Internal Libraries
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\ProcessSendEveMailJob;
|
||||||
|
|
||||||
|
//Library Helpers
|
||||||
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Logistics\AnchorStructure;
|
||||||
|
use App\Models\Jobs\JobSendEveMail;
|
||||||
|
use App\Models\User\UserPermission;
|
||||||
|
|
||||||
|
class StructureRequestController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct() {
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->middleware('role:User');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayForm() {
|
||||||
|
return view('structurerequest.requeststructure');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeForm(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'corporation_name' => 'required',
|
||||||
|
'system' => 'required',
|
||||||
|
'structure_size' => 'required',
|
||||||
|
'structure_type' => 'required',
|
||||||
|
'requested_drop_time' => 'required',
|
||||||
|
'requester' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
$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,
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Send a mail out to the FC Team
|
||||||
|
$fcTeam = UserPermission::where([
|
||||||
|
'permission' => 'fc.team',
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
//Set the mail delay
|
||||||
|
$delay = 5;
|
||||||
|
|
||||||
|
foreach($fcTeam as $fc) {
|
||||||
|
$body = "Structure Anchor Request has been entered.<br>";
|
||||||
|
$body .= "Please check the W4RP Services Site for the structure information.<br>";
|
||||||
|
$body .= "<br>Sincerely,<br>";
|
||||||
|
$body .= "Warped Intentions Leadership<br>";
|
||||||
|
|
||||||
|
//Dispatch the mail job
|
||||||
|
$mail = new JobSendEveMail;
|
||||||
|
$mail->sender = $config['primary'];
|
||||||
|
$mail->subject = "New Structure Anchor Request";
|
||||||
|
$mail->body = $body;
|
||||||
|
$mail->recipient = (int)$fc->character_id;
|
||||||
|
$mail->recipient_type = 'character';
|
||||||
|
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay($delay);
|
||||||
|
|
||||||
|
$delay += 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect('/structures/display/requests');
|
||||||
|
}
|
||||||
|
}
|
||||||
234
app/Http/Controllers/Moons/MoonLedgerController.php
Normal file
234
app/Http/Controllers/Moons/MoonLedgerController.php
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Moons;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//App Library
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use App\Library\Structures\StructureHelper;
|
||||||
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
|
||||||
|
//App Models
|
||||||
|
use App\Models\Esi\EsiToken;
|
||||||
|
use App\Models\Esi\EsiScope;
|
||||||
|
use App\Models\Lookups\ItemLookup;
|
||||||
|
use App\Models\MoonRent\MoonRental;
|
||||||
|
use App\Models\Moon\RentalMoon;
|
||||||
|
|
||||||
|
class MoonLedgerController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct() {
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->middleware('role:User');
|
||||||
|
$this->middleware('permission:corp.lead');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayMoonLedger() {
|
||||||
|
//Declare variables
|
||||||
|
$structures = array();
|
||||||
|
$miningLedgers = array();
|
||||||
|
$tempMiningLedger = array();
|
||||||
|
$tempMining = array();
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$response = null;
|
||||||
|
$structureInfo = null;
|
||||||
|
|
||||||
|
//Check for the esi scope
|
||||||
|
if(!$esiHelper->HaveEsiScope(auth()->user()->getId(), 'esi-industry.read_corporation_mining.v1')) {
|
||||||
|
return redirect('/dashboard')->with('error', 'Need to add scopes for esi-industry.read_corporation_mining.v1');
|
||||||
|
} else {
|
||||||
|
if(!$esiHelper->HaveEsiScope(auth()->user()->getId(), 'esi-universe.read_structures.v1')) {
|
||||||
|
return redirect('/dashboard')->with('error', 'Need to add scope for esi-universe.read_structures.v1');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the refresh token if scope checks have passed
|
||||||
|
$refreshToken = $esiHelper->GetRefreshToken(auth()->user()->getId());
|
||||||
|
|
||||||
|
//Setup the esi container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||||
|
|
||||||
|
//Get the character data from the lookup table if possible or esi
|
||||||
|
$character = $lookup->GetCharacterInfo(auth()->user()->getId());
|
||||||
|
|
||||||
|
//Try to get the mining observers for the corporation from esi
|
||||||
|
try {
|
||||||
|
$responses = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||||
|
'corporation_id' => $character->corporation_id,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
//If an exception has occurred for some reason redirect back to the dashboard with an error message
|
||||||
|
return redirect('/dashboard')->with('error', 'Failed to get mining structures.');
|
||||||
|
}
|
||||||
|
|
||||||
|
//For each mining observer, let's build the array of data to show on the page
|
||||||
|
foreach($responses as $response) {
|
||||||
|
//Try to get the structure information from esi
|
||||||
|
try {
|
||||||
|
$structureInfo = $esi->invoke('get', '/universe/structures/{structure_id}/', [
|
||||||
|
'structure_id' => $response->observer_id,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
//If an exception has occurred, then do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
//We don't really care about the key, but it is better than just 0 through whatever number
|
||||||
|
$structures[$response->observer_id] = $structureInfo->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
//For each of the structures we want to address it by it's key value pair.
|
||||||
|
//This will allow us to do some interesting things in the display.
|
||||||
|
foreach($structures as $key => $value) {
|
||||||
|
try {
|
||||||
|
$ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||||
|
'corporation_id' => $character->corporation_id,
|
||||||
|
'observer_id' => $key,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
$ledgers = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($ledgers != null) {
|
||||||
|
foreach($ledgers as $ledger) {
|
||||||
|
//Declare a variable that will need to be cleared each time the foreach processes
|
||||||
|
$tempArray = array();
|
||||||
|
|
||||||
|
//Get the character information from the character id
|
||||||
|
$charInfo = $lookup->GetCharacterInfo($ledger->character_id);
|
||||||
|
//Get the corp ticker
|
||||||
|
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||||
|
//Get the ore name from the type id
|
||||||
|
$ore = $lookup->ItemIdToName($ledger->type_id);
|
||||||
|
|
||||||
|
//We only want to push the mining ledger entry into the array if it matches
|
||||||
|
//the date within 30 days
|
||||||
|
$sortTime = Carbon::now()->subDays(30);
|
||||||
|
$current = Carbon::createFromFormat('Y-m-d', $ledger->last_updated);
|
||||||
|
if($current->greaterThanOrEqualTo($sortTime)) {
|
||||||
|
array_push($miningLedgers, [
|
||||||
|
'structure' => $value,
|
||||||
|
'character' => $charInfo->name,
|
||||||
|
'corpTicker' => $corpInfo->ticker,
|
||||||
|
'ore' => $ore,
|
||||||
|
'quantity' => $ledger->quantity,
|
||||||
|
'updated' => $ledger->last_updated,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('moons.ledger.corpmoons')->with('miningLedgers', $miningLedgers)
|
||||||
|
->with('structures', $structures);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayRentalMoonLedger() {
|
||||||
|
//Declare variables
|
||||||
|
$structures = array();
|
||||||
|
$miningLedgers = array();
|
||||||
|
$tempMiningLedger = array();
|
||||||
|
$tempMining = array();
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$response = null;
|
||||||
|
$structureInfo = null;
|
||||||
|
|
||||||
|
//Get the configuration for the main site
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
//Check for the esi scope
|
||||||
|
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
||||||
|
return redirect('/dashboard')->with('error', 'Tell the nub Minerva to register the ESI for the holding corp.');
|
||||||
|
} else {
|
||||||
|
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1')) {
|
||||||
|
return redirect('/dashboard')->with('error', 'Tell the nub Minerva to register the ESI for the holding corp.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the refresh token if scope checks have passed
|
||||||
|
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||||
|
|
||||||
|
//Setup the esi container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||||
|
|
||||||
|
//Get the character data from the lookup table if possible or esi
|
||||||
|
$character = $lookup->GetCharacterInfo($config['primary']);
|
||||||
|
|
||||||
|
//Try to get the mining observers for the corporation from esi
|
||||||
|
try {
|
||||||
|
$responses = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||||
|
'corporation_id' => $character->corporation_id,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
//If an exception has occurred for some reason redirect back to the dashboard with an error message
|
||||||
|
return redirect('/dashboard')->with('error', 'Failed to get mining structures.');
|
||||||
|
}
|
||||||
|
|
||||||
|
//For each mining observer, let's build the array of data to show on the page
|
||||||
|
foreach($responses as $response) {
|
||||||
|
//Try to get the structure information from esi
|
||||||
|
try {
|
||||||
|
$structureInfo = $esi->invoke('get', '/universe/structures/{structure_id}/', [
|
||||||
|
'structure_id' => $response->observer_id,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
//If an exception has occurred, then do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
//We don't really care about the key, but it is better than just 0 through whatever number
|
||||||
|
$structures[$response->observer_id] = $structureInfo->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
//For each of the structures we want to address it by it's key value pair.
|
||||||
|
//This will allow us to do some interesting things in the display.
|
||||||
|
foreach($structures as $key => $value) {
|
||||||
|
try {
|
||||||
|
$ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||||
|
'corporation_id' => $character->corporation_id,
|
||||||
|
'observer_id' => $key,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
$ledgers = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($ledgers != null) {
|
||||||
|
foreach($ledgers as $ledger) {
|
||||||
|
//Declare a variable that will need to be cleared each time the foreach processes
|
||||||
|
$tempArray = array();
|
||||||
|
|
||||||
|
//Get the character information from the character id
|
||||||
|
$charInfo = $lookup->GetCharacterInfo($ledger->character_id);
|
||||||
|
//Get the corp ticker
|
||||||
|
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||||
|
//Get the ore name from the type id
|
||||||
|
$ore = $lookup->ItemIdToName($ledger->type_id);
|
||||||
|
|
||||||
|
//We only want to push the mining ledger entry into the array if it matches
|
||||||
|
//the date within 30 days
|
||||||
|
$sortTime = Carbon::now()->subDays(30);
|
||||||
|
$current = Carbon::createFromFormat('Y-m-d', $ledger->last_updated);
|
||||||
|
if($current->greaterThanOrEqualTo($sortTime)) {
|
||||||
|
array_push($miningLedgers, [
|
||||||
|
'structure' => $value,
|
||||||
|
'character' => $charInfo->name,
|
||||||
|
'corpTicker' => $corpInfo->ticker,
|
||||||
|
'ore' => $ore,
|
||||||
|
'quantity' => $ledger->quantity,
|
||||||
|
'updated' => $ledger->last_updated,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('moons.ledger.corpmoons')->with('miningLedgers', $miningLedgers)
|
||||||
|
->with('structures', $structures);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,244 +6,148 @@ namespace App\Http\Controllers\Moons;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Auth;
|
use Auth;
|
||||||
use DB;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
use App\Models\Moon\Config;
|
use App\Models\Moon\Config;
|
||||||
use App\Models\Moon\ItemComposition;
|
use App\Models\Moon\ItemComposition;
|
||||||
use App\Models\Moon\Moon;
|
use App\Models\Moon\RentalMoon;
|
||||||
use App\Models\Moon\OrePrice;
|
use App\Models\Moon\OrePrice;
|
||||||
use App\Models\Moon\Price;
|
use App\Models\Moon\Price;
|
||||||
use App\Models\MoonRent\MoonRental;
|
use App\Models\MoonRent\MoonRental;
|
||||||
|
use App\Models\Moon\AllianceMoon;
|
||||||
|
use App\Models\Moon\AllianceMoonRequest;
|
||||||
|
use App\Models\Jobs\JobSendEveMail;
|
||||||
|
|
||||||
//Library
|
//Library
|
||||||
use App\Library\Moons\MoonCalc;
|
use App\Library\Moons\MoonCalc;
|
||||||
use App\Library\Esi\Esi;
|
use App\Library\Esi\Esi;
|
||||||
use App\Library\Lookups\LookupHelper;
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\ProcessSendEveMailJob;
|
||||||
|
|
||||||
class MoonsAdminController extends Controller
|
class MoonsAdminController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Constructor for the class
|
||||||
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->middleware('auth');
|
$this->middleware('auth');
|
||||||
$this->middleware('role:Admin');
|
$this->middleware('role:Admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showJournalEntries() {
|
/**
|
||||||
$dateInit = Carbon::now();
|
* Function to display moon requests
|
||||||
$date = $dateInit->subDays(30);
|
*/
|
||||||
|
public function displayMoonRequests() {
|
||||||
|
$requests = AllianceMoonRequest::where([
|
||||||
|
'status' => 'Pending',
|
||||||
|
])->get();
|
||||||
|
|
||||||
$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.moonrequest')->with('requests', $requests);
|
||||||
|
|
||||||
return view('moons.admin.moonjournal')->with('journal', $journal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateMoon() {
|
/**
|
||||||
//Return the view and the form from the blade display
|
* Function to approve a moon request
|
||||||
return view('moons.admin.updatemoon');
|
*/
|
||||||
}
|
public function storeApprovedMoonRequest(Request $request) {
|
||||||
|
//Validate the input request
|
||||||
public function storeUpdateMoonRental(Request $request) {
|
|
||||||
$moonCalc = new MoonCalc;
|
|
||||||
$lookup = new LookupHelper;
|
|
||||||
|
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
|
'id' => 'required',
|
||||||
|
'status' => 'required',
|
||||||
'system' => 'required',
|
'system' => 'required',
|
||||||
'planet' => 'required',
|
'planet' => 'required',
|
||||||
'moon' => 'required',
|
'moon' => 'required',
|
||||||
'renter' => 'required',
|
|
||||||
'date' => 'required',
|
|
||||||
'contact' => 'required',
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//Take the contact name and create a character_id from it
|
|
||||||
if($request->contact == 'None') {
|
//Get the request data which holds all of the information for the request user
|
||||||
$contact = 'None';
|
$moon = AllianceMoonRequest::where([
|
||||||
} else {
|
'id' => $request->id,
|
||||||
$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();
|
])->first();
|
||||||
|
|
||||||
//If the entry is found, we are most likely just updating an entry to include new paid until data
|
//Get the configuration data to use later in the function
|
||||||
if($found) {
|
$config = config('esi');
|
||||||
if($allianceId = 99004116) {
|
|
||||||
MoonRental::where([
|
//If the request is approved, then update everything.
|
||||||
'System' => $request->system,
|
if($request->status == 'Approved') {
|
||||||
'Planet' => $request->planet,
|
//Update the alliance moon request to either approved or denied
|
||||||
'Moon' => $request->moon,
|
AllianceMoonRequest::where([
|
||||||
'Contact' => $contact,
|
'id' => $request->id,
|
||||||
])->update([
|
])->update([
|
||||||
'System' => $request->system,
|
'status' => $request->status,
|
||||||
'Planet' => $request->planet,
|
'approver_name' => auth()->user()->getName(),
|
||||||
'Moon' => $request->moon,
|
'approver_id' => auth()->user()->getId(),
|
||||||
'RentalCorp' => $request->renter,
|
]);
|
||||||
'RentalEnd' => $date,
|
|
||||||
'Contact' => $contact,
|
//Update the alliance moon in the table to the correct status
|
||||||
'Price' => $price['alliance'],
|
AllianceMoon::where([
|
||||||
'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,
|
'System' => $request->system,
|
||||||
'Planet' => $request->planet,
|
'Planet' => $request->planet,
|
||||||
'Moon' => $request->moon,
|
'Moon' => $request->moon,
|
||||||
])->delete();
|
])->update([
|
||||||
|
'Corporation' => $moon->corporation_ticker,
|
||||||
|
'Availability' => 'Deployed',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Send an eve mail to the requestor stating they can set a moon up.
|
||||||
|
//Setup the mail body
|
||||||
|
$body = 'The moon request for ' . $request->system . ' - ' . $request->planet . ' - ' . $request->moon . ' has changed status.<br>';
|
||||||
|
$body .= 'The request has been ' . $request->status . '.<br>';
|
||||||
|
$body .= 'Please contact the FC Team should it be necessary to arrange a fleet to cover the structure drop.<br>';
|
||||||
|
$body .= 'Sincerely,<br>';
|
||||||
|
$body .= 'Warped Intentions Leadership<br>';
|
||||||
|
|
||||||
|
|
||||||
if($allianceId = 99004116) {
|
|
||||||
MoonRental::insert([
|
|
||||||
'System' => $request->system,
|
|
||||||
'Planet' => $request->planet,
|
|
||||||
'Moon' => $request->moon,
|
|
||||||
'RentalCorp' => $request->renter,
|
|
||||||
'RentalEnd' => $date,
|
|
||||||
'Contact' => $contact,
|
|
||||||
'Price' => $price['alliance'],
|
|
||||||
'Type' => 'alliance',
|
|
||||||
'Paid' => 'No',
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
MoonRental::insert([
|
|
||||||
'System' =>$request->system,
|
|
||||||
'Planet' => $request->planet,
|
|
||||||
'Moon' => $request->moon,
|
|
||||||
'RentalCorp' => $request->renter,
|
|
||||||
'RentalEnd' => $date,
|
|
||||||
'Contact' => $contact,
|
|
||||||
'Price' => $price['outofalliance'],
|
|
||||||
'Type' => 'outofalliance',
|
|
||||||
'Paid' => 'No',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Redirect to the update moon page
|
|
||||||
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Updated');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function storeUpdateMoon(Request $request) {
|
|
||||||
$moonCalc = new MoonCalc();
|
|
||||||
$lookup = new LookupHelper();
|
|
||||||
|
|
||||||
$this->validate($request, [
|
|
||||||
'system' => 'required',
|
|
||||||
'planet' => 'required',
|
|
||||||
'moon' => 'required',
|
|
||||||
'renter' => 'required',
|
|
||||||
'date' => 'required',
|
|
||||||
'contact' => 'required',
|
|
||||||
'paid' => 'required',
|
|
||||||
]);
|
|
||||||
|
|
||||||
//Take the contact name and create a character id from it
|
|
||||||
if($request->contact == 'None') {
|
|
||||||
$contact = 'None';
|
|
||||||
} else {
|
} else {
|
||||||
$contact = $lookup->CharacterNameToId($request->contact);
|
//If the status was Denied, then update the request, and mark the moon available again.
|
||||||
}
|
AllianceMoonRequest::where([
|
||||||
//Let's find the corporation and alliance information to ascertain whether they are in Warped Intentions or another Legacy Alliance
|
'id' => $request->id,
|
||||||
$corpId = $lookup->LookupCharacter($contact);
|
])->update([
|
||||||
$allianceId = $lookup->LookupCorporation($corpId);
|
'status' => $request->status,
|
||||||
|
'approver_name' => auth()->user()->getName(),
|
||||||
//Create the date
|
'approver_id' => auth()->user()->getId(),
|
||||||
$date = new Carbon($request->date . '00:00:01');
|
|
||||||
//Calculate the moon price
|
|
||||||
$moon = Moon::where([
|
|
||||||
'System' => $request->system,
|
|
||||||
'Planet' => $request->planet,
|
|
||||||
'Moon' => $request->moon,
|
|
||||||
])->first();
|
|
||||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
|
||||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
|
||||||
|
|
||||||
$date = new Carbon($request->date . '00:00:01');
|
|
||||||
//Update the database entry
|
|
||||||
Moon::where([
|
|
||||||
'System' => $request->system,
|
|
||||||
'Planet' => $request->planet,
|
|
||||||
'Moon' => $request->moon,
|
|
||||||
])->update([
|
|
||||||
'RentalCorp' => $request->renter,
|
|
||||||
'RentalEnd' => $date,
|
|
||||||
]);
|
|
||||||
|
|
||||||
//Going to store moon price in a table for future reference
|
|
||||||
//We need to insert a price based on whether part of Legacy or part of Warped Intentions
|
|
||||||
//Will need an if then else statement to complete this operation
|
|
||||||
if($allianceId = 99004116) {
|
|
||||||
MoonRental::insert([
|
|
||||||
'System' => $request->system,
|
|
||||||
'Planet' => $request->planet,
|
|
||||||
'Moon' => $request->moon,
|
|
||||||
'RentalCorp' => $request->renter,
|
|
||||||
'RentalEnd' => $date,
|
|
||||||
'Contact' => $contact,
|
|
||||||
'Price' => $price['alliance'],
|
|
||||||
'Type' => 'alliance',
|
|
||||||
'Paid' => $request->paid,
|
|
||||||
]);
|
]);
|
||||||
} else {
|
|
||||||
MoonRental::insert([
|
//Update the alliance moon in the table to the correct status
|
||||||
'System' =>$request->system,
|
AllianceMoon::where([
|
||||||
'Planet' => $request->planet,
|
'System' => (string)$request->system,
|
||||||
'Moon' => $request->moon,
|
'Planet' => (string)$request->planet,
|
||||||
'RentalCorp' => $request->renter,
|
'Moon' => (string)$request->moon,
|
||||||
'RentalEnd' => $date,
|
])->update([
|
||||||
'Contact' => $contact,
|
'Availability' => 'Available',
|
||||||
'Price' => $price['outofalliance'],
|
|
||||||
'Type' => 'outofalliance',
|
|
||||||
'Paid' => $request->paid,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
//Send an eve mail to the requestor stating they can set a moon up.
|
||||||
|
//Setup the mail body
|
||||||
|
$body = 'The moon request for ' . $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon . ' has changed status.<br>';
|
||||||
|
$body .= 'The request has been ' . $request->status . '.<br>';
|
||||||
|
$body .= 'Should you have questions please contact alliance leadership for further clarification.<br>';
|
||||||
|
$body .= 'Sincerely,<br>';
|
||||||
|
$body .= 'Warped Intentions Leadership<br>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Updated');
|
//Setup the mail model
|
||||||
|
$mail = new JobSendEveMail;
|
||||||
|
$mail->sender = $config['primary'];
|
||||||
|
$mail->subject = 'Warped Intentions Moon Request';
|
||||||
|
$mail->body = $body;
|
||||||
|
$mail->recipient = (int)$moon->requestor_id;
|
||||||
|
$mail->recipient_type = 'character';
|
||||||
|
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail');
|
||||||
|
|
||||||
|
return redirect('/moons/admin/display/request')->with('success', 'Moon has been processed, and mail has been sent out.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to display the moons to admins
|
* Function to display the moons to admins
|
||||||
*/
|
*/
|
||||||
public function displayMoonsAdmin() {
|
public function displayRentalMoonsAdmin() {
|
||||||
$lookup = new LookupHelper;
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
$lookupHelper = new LookupHelper;
|
||||||
$contact = '';
|
$contact = '';
|
||||||
$paid = '';
|
$paid = '';
|
||||||
$rentalEnd = '';
|
$rentalEnd = '';
|
||||||
@@ -252,59 +156,76 @@ class MoonsAdminController extends Controller
|
|||||||
|
|
||||||
//Setup calls to the MoonCalc class
|
//Setup calls to the MoonCalc class
|
||||||
$moonCalc = new MoonCalc();
|
$moonCalc = new MoonCalc();
|
||||||
//Update the prices for the moon
|
//Get all of the moons from the database
|
||||||
$moonCalc->FetchNewPrices();
|
$moons = RentalMoon::orderBy('System', 'asc')->get();
|
||||||
//get all of the moons from the database
|
//Declare the html variable and set it to null
|
||||||
$moons = Moon::orderBy('System', 'asc')->get();
|
|
||||||
//declare the html variable and set it to null
|
|
||||||
$table = array();
|
$table = array();
|
||||||
|
//Set carbon dates as needed
|
||||||
|
$lastMonth = Carbon::now()->subMonth();
|
||||||
|
$today = Carbon::now();
|
||||||
|
|
||||||
foreach($moons as $moon) {
|
foreach($moons as $moon) {
|
||||||
//Get the rental data for the moon
|
//Get the rental data for the moon
|
||||||
$rental = MoonRental::where([
|
$count = MoonRental::where([
|
||||||
'System' => $moon->System,
|
'System' => $moon->System,
|
||||||
'Planet' => $moon->Planet,
|
'Planet' => $moon->Planet,
|
||||||
'Moon' => $moon->Moon,
|
'Moon' => $moon->Moon,
|
||||||
])->first();
|
])->count();
|
||||||
|
|
||||||
//Check if their is a current rental for a moon going on
|
//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
|
//If we don't find a rental record, mark the moon as not paid
|
||||||
$paid = 'No';
|
$paid = 'No';
|
||||||
|
|
||||||
//If we don't find a rental record, set the rental date as last month
|
//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');
|
$rentalEnd = $rentalTemp->format('m-d');
|
||||||
|
|
||||||
|
//If we don't find a rental record, set the paid until date as last month
|
||||||
|
$paidUntilTemp = $lastMonth;
|
||||||
|
$paidUntil = $paidUntilTemp->format('m-d');
|
||||||
|
|
||||||
//Set the contact info
|
//Set the contact info
|
||||||
$contact = 'None';
|
$contact = 'None';
|
||||||
|
|
||||||
//Set the renter info
|
//Set the renter info
|
||||||
$renter = 'None';
|
$renter = 'None';
|
||||||
|
|
||||||
|
//Set the ticker info
|
||||||
$ticker = 'N/A';
|
$ticker = 'N/A';
|
||||||
|
|
||||||
|
//Set the type info as it's needed
|
||||||
|
$type = 'N/A';
|
||||||
} else {
|
} 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
|
//If we find a rental record, mark the moon as whether it's paid or not
|
||||||
$paid = $rental->Paid;
|
$paid = $rental->Paid;
|
||||||
|
$paidUntil = new Carbon($rental->Paid_Until);
|
||||||
|
$paidUntil = $paidUntil->format('m-d');
|
||||||
|
|
||||||
//Set the rental date up
|
//Set the rental date up
|
||||||
$rentalTemp = new Carbon($rental->RentalEnd);
|
$rentalTemp = new Carbon($rental->RentalEnd);
|
||||||
$rentalEnd = $rentalTemp->format('m-d');
|
$rentalEnd = $rentalTemp->format('m-d');
|
||||||
|
|
||||||
//Set the contact name
|
//Set the contact name
|
||||||
$contact = $lookup->CharacterName($rental->Contact);
|
$contact = $lookupHelper->CharacterIdToName($rental->Contact);
|
||||||
|
|
||||||
//Set up the renter whether it's W4RP or another corporation
|
//Set up the renter whether it's a corporation in W4RP or another alliance
|
||||||
$corpId = $lookup->LookupCorporationId($rental->Contact);
|
$ticker = $rental->RentalCorp;
|
||||||
$allianceId = $lookup->LookupCorporation($corpId);
|
$type = $rental->Type;
|
||||||
$ticker = $lookup->LookupAllianceTicker($allianceId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set the color for the table
|
//Set the color for the table
|
||||||
$today = Carbon::now();
|
|
||||||
if($rentalTemp->diffInDays($today) < 3 ) {
|
if($rentalTemp->diffInDays($today) < 3 ) {
|
||||||
$color = 'table-warning';
|
$color = 'table-warning';
|
||||||
} else if( $today > $rentalTemp) {
|
} else if( $today > $rentalTemp) {
|
||||||
$color = 'table-primary';
|
$color = 'table-success';
|
||||||
} else {
|
} else {
|
||||||
$color = 'table-danger';
|
$color = 'table-danger';
|
||||||
}
|
}
|
||||||
@@ -321,7 +242,9 @@ class MoonsAdminController extends Controller
|
|||||||
'RentalEnd' => $rentalEnd,
|
'RentalEnd' => $rentalEnd,
|
||||||
'RowColor' => $color,
|
'RowColor' => $color,
|
||||||
'Paid' => $paid,
|
'Paid' => $paid,
|
||||||
|
'PaidUntil' => $paidUntil,
|
||||||
'Contact' => $contact,
|
'Contact' => $contact,
|
||||||
|
'Type' => $type,
|
||||||
'Renter' => $ticker,
|
'Renter' => $ticker,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -329,92 +252,290 @@ class MoonsAdminController extends Controller
|
|||||||
return view('moons.admin.adminmoon')->with('table', $table);
|
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, [
|
$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
|
//Decode the value for the SPM into a system, planet, and moon for the database to update
|
||||||
$system = $str_array[0];
|
$system = $str_array[0];
|
||||||
$planet = $str_array[1];
|
$planet = $str_array[1];
|
||||||
$moon = $str_array[2];
|
$moon = $str_array[2];
|
||||||
|
|
||||||
//Update the paid status of the moon
|
$found = MoonRental::where([
|
||||||
MoonRental::where([
|
|
||||||
'System' => $system,
|
'System' => $system,
|
||||||
'Planet' => $planet,
|
'Planet' => $planet,
|
||||||
'Moon' => $moon,
|
'Moon' => $moon,
|
||||||
])->update([
|
])->count();
|
||||||
'Paid' => 'Yes',
|
|
||||||
]);
|
if($found != 0) {
|
||||||
|
MoonRental::where([
|
||||||
|
'System' => $system,
|
||||||
|
'Planet' => $planet,
|
||||||
|
'Moon' => $moon,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
return redirect('/moons/admin/display/rentals')->with('success', 'Renter removed.');
|
||||||
|
}
|
||||||
|
|
||||||
//Redirect back to the moon page, which should call the page to be displayed correctly
|
//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/rentals')->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() {
|
public function updateMoon() {
|
||||||
return view('moons.admin.addmoon');
|
$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 = RentalMoon::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
|
* Store the updated moon
|
||||||
*
|
|
||||||
* @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, [
|
$this->validate($request, [
|
||||||
'region' => 'required',
|
'spmn' => 'required',
|
||||||
'system' => 'required',
|
'contact' => 'required',
|
||||||
'structure' => 'required',
|
'paid_until' => 'required',
|
||||||
|
'rental_end' => 'required',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if($request->input('firstquan') < 1.00) {
|
//Decode the System, Planet, Moon, Name combinatio sent from the controller
|
||||||
$firstQuan = $request->input('firstquan') * 100.00;
|
$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 = -1;
|
||||||
} else {
|
} else {
|
||||||
$firstQuan = $request->input('firstquan');
|
$contact = $lookup->CharacterNameToId($request->contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($request->input('secondquan') < 1.00) {
|
//After we get the contact, from his name to the character Id, let's do some other functions before continuing.
|
||||||
$firstQuan = $request->input('secondquan') * 100.00;
|
//Let's find the corporation and alliance information to ascertain whethery they are in Warped Intentions or another Legacy Alliance
|
||||||
|
$char = $lookup->GetCharacterInfo($contact);
|
||||||
|
//Takes the corp id and looks up the corporation info
|
||||||
|
$corp = $lookup->GetCorporationInfo($char->corporation_id);
|
||||||
|
$alliance = $lookup->GetAllianceInfo($corp->alliance_id);
|
||||||
|
$allianceId = $corp->alliance_id;
|
||||||
|
|
||||||
|
//Update the paid value for database entry
|
||||||
|
if($request->paid == 'Yes') {
|
||||||
|
$paid = 'Yes';
|
||||||
} else {
|
} else {
|
||||||
$firstQuan = $request->input('secondquan');
|
$paid = 'No';
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create the rnetal ticker if the corp is in Warped Intentions, otherwise just display the alliance ticker
|
||||||
|
if($allianceId == 99004116) {
|
||||||
|
$renter = $corp->ticker;
|
||||||
|
} else {
|
||||||
|
$renter = $alliance->ticker;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($request->input('thirdquan') < 1.00) {
|
//Create the paid until date
|
||||||
$firstQuan = $request->input('thirdquan') * 100.00;
|
if(isset($request->paid_until)) {
|
||||||
|
$paidUntil = new Carbon($request->paid_until . '00:00:01');
|
||||||
} else {
|
} else {
|
||||||
$firstQuan = $request->input('thirdquan');
|
$paidUntil = Carbon::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($request->input('fourthquan') < 1.00) {
|
//Create the rental end date
|
||||||
$firstQuan = $request->input('fourthquan') * 100.00;
|
if(isset($request->rental_end)) {
|
||||||
|
$rentalEnd = new Carbon($request->rental_end . '23:59:59');
|
||||||
} else {
|
} else {
|
||||||
$firstQuan = $request->input('fourthquan');
|
$rentalEnd = Carbon::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new moon
|
//Calculate the price of the moon for when it's updated
|
||||||
$moon = new Moon;
|
$moon = RentalMoon::where([
|
||||||
$moon->Region = $request->input('region');
|
'System' => $system,
|
||||||
$moon->System = $request->input('system');
|
'Planet' => $planet,
|
||||||
$moon->Planet = $request->input('planet');
|
'Moon' => $mn,
|
||||||
$moon->Moon = $request->input('moon');
|
])->first();
|
||||||
$moon->StructureName = $request->input('structure');
|
|
||||||
$moon->FirstOre = $request->input('firstore');
|
|
||||||
$moon->FirstQuantity = $request->input('firstquan');
|
|
||||||
$moon->SecondOre = $request->input('secondore');
|
|
||||||
$moon->SecondQuantity = $request->input('secondquan');
|
|
||||||
$moon->ThirdOre = $request->input('thirdore');
|
|
||||||
$moon->ThirdQuantity = $request->input('thirdquan');
|
|
||||||
$moon->FourthOre = $request->input('fourthore');
|
|
||||||
$moon->FourthQuantity = $request->input('fourthquan');
|
|
||||||
$moon->save();
|
|
||||||
|
|
||||||
return redirect('/dashboard')->with('success', 'Moon Added');
|
//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);
|
||||||
|
|
||||||
|
//Count how many rentals we find for later database processing
|
||||||
|
$count = MoonRental::where([
|
||||||
|
'System' => $system,
|
||||||
|
'Planet' => $planet,
|
||||||
|
'Moon' => $mn,
|
||||||
|
'Contact' => $contact,
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
//If the database entry isn't found, then insert it into the database,
|
||||||
|
//otherwise, account for it being in the system already.
|
||||||
|
//Also check for the weird condition of more than one moon entry existing
|
||||||
|
if($count > 1) {
|
||||||
|
//If more than one entry is found for a particular system, planet, moon combo, then delete all the entries, and put in
|
||||||
|
// a single new entry
|
||||||
|
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 = $renter;
|
||||||
|
$store->RentalEnd = $rentalEnd;
|
||||||
|
$store->Contact = $contact;
|
||||||
|
$store->Price = $price['alliance'];
|
||||||
|
$store->Type = 'alliance';
|
||||||
|
$store->Paid = $paid;
|
||||||
|
$store->Paid_Until = $paidUntil;
|
||||||
|
$store->save();
|
||||||
|
} else {
|
||||||
|
$store = new MoonRental;
|
||||||
|
$store->System = $system;
|
||||||
|
$store->Planet = $planet;
|
||||||
|
$store->Moon = $mn;
|
||||||
|
$store->RentalCorp = $renter;
|
||||||
|
$store->RentalEnd = $rentalEnd;
|
||||||
|
$store->Contact = $contact;
|
||||||
|
$store->Price = $price['outofalliance'];
|
||||||
|
$store->Type = 'outofalliance';
|
||||||
|
$store->Paid = $paid;
|
||||||
|
$store->Paid_Until = $paidUntil;
|
||||||
|
$store->save();
|
||||||
|
}
|
||||||
|
} else if($count == 1) {
|
||||||
|
if($allianceId = 99004116) {
|
||||||
|
MoonRental::where([
|
||||||
|
'System' => $system,
|
||||||
|
'Planet' => $planet,
|
||||||
|
'Moon' => $mn,
|
||||||
|
'Contact' => $contact,
|
||||||
|
])->update([
|
||||||
|
'System' => $system,
|
||||||
|
'Planet' => $planet,
|
||||||
|
'Moon' => $mn,
|
||||||
|
'RentalCorp' => $renter,
|
||||||
|
'RentalEnd' => $rentalEnd,
|
||||||
|
'Contact' => $contact,
|
||||||
|
'Price' => $price['alliance'],
|
||||||
|
'Type' => 'alliance',
|
||||||
|
'Paid' => $paid,
|
||||||
|
'Paid_Until' => $paidUntil,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
MoonRental::where([
|
||||||
|
'System' => $system,
|
||||||
|
'Planet' => $planet,
|
||||||
|
'Moon' => $mn,
|
||||||
|
'Contact' => $contact,
|
||||||
|
])->update([
|
||||||
|
'System' => $system,
|
||||||
|
'Planet' => $planet,
|
||||||
|
'Moon' => $mn,
|
||||||
|
'RentalCorp' => $renter,
|
||||||
|
'RentalEnd' => $rentalEnd,
|
||||||
|
'Contact' => $contact,
|
||||||
|
'Price' => $price['outofalliance'],
|
||||||
|
'Type' => 'outofalliance',
|
||||||
|
'Paid' => $paid,
|
||||||
|
'Paid_Until' => $paidUntil,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//If the entry is not found, then attempt to delete whatever existing data is there, then
|
||||||
|
//insert the new data
|
||||||
|
MoonRental::where([
|
||||||
|
'System' => $system,
|
||||||
|
'Planet' => $planet,
|
||||||
|
'Moon' => $moon,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
if($allianceId == 99004116) {
|
||||||
|
$store = new MoonRental;
|
||||||
|
$store->System = $system;
|
||||||
|
$store->Planet = $planet;
|
||||||
|
$store->Moon = $mn;
|
||||||
|
$store->RentalCorp = $renter;
|
||||||
|
$store->RentalEnd = $rentalEnd;
|
||||||
|
$store->Contact = $contact;
|
||||||
|
$store->Price = $price['alliance'];
|
||||||
|
$store->Type = 'alliance';
|
||||||
|
$store->Paid = $paid;
|
||||||
|
$store->Paid_Until = $paidUntil;
|
||||||
|
$store->save();
|
||||||
|
} else {
|
||||||
|
$store = new MoonRental;
|
||||||
|
$store->System = $system;
|
||||||
|
$store->Planet = $planet;
|
||||||
|
$store->Moon = $mn;
|
||||||
|
$store->RentalCorp = $renter;
|
||||||
|
$store->RentalEnd = $rentalEnd;
|
||||||
|
$store->Contact = $contact;
|
||||||
|
$store->Price = $price['outofalliance'];
|
||||||
|
$store->Type = 'outofalliance';
|
||||||
|
$store->Paid = $paid;
|
||||||
|
$store->Paid_Until = $paidUntil;
|
||||||
|
$store->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Redirect to the update moon page
|
||||||
|
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Updated');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,13 +12,16 @@ use Carbon\Carbon;
|
|||||||
//Models
|
//Models
|
||||||
use App\Models\Moon\Config;
|
use App\Models\Moon\Config;
|
||||||
use App\Models\Moon\ItemComposition;
|
use App\Models\Moon\ItemComposition;
|
||||||
use App\Models\Moon\Moon;
|
use App\Models\Moon\RentalMoon;
|
||||||
use App\Models\Moon\OrePrice;
|
use App\Models\Moon\OrePrice;
|
||||||
use App\Models\Moon\Price;
|
use App\Models\Moon\Price;
|
||||||
use App\Models\MoonRent\MoonRental;
|
use App\Models\MoonRent\MoonRental;
|
||||||
|
use App\Models\Moon\AllianceMoon;
|
||||||
|
use App\Models\Moon\AllianceMoonRequest;
|
||||||
|
|
||||||
//Library
|
//Library
|
||||||
use App\Library\Moons\MoonCalc;
|
use App\Library\Moons\MoonCalc;
|
||||||
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
|
||||||
class MoonsController extends Controller
|
class MoonsController extends Controller
|
||||||
{
|
{
|
||||||
@@ -28,19 +31,221 @@ class MoonsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to display the moons and pass data to the blade template
|
* Function to display all alliance moons and pass data to the blade template
|
||||||
*/
|
*/
|
||||||
public function displayMoons() {
|
public function displayMoons() {
|
||||||
|
//Setup variables for moons
|
||||||
|
$moons = array();
|
||||||
|
$systems = array();
|
||||||
|
|
||||||
|
//Get all of the alliance moon systems from the database
|
||||||
|
$systems = AllianceMoon::groupBy('System')->pluck('System');
|
||||||
|
|
||||||
|
//Get all of the alliance moons from the database
|
||||||
|
$moons = AllianceMoon::all();
|
||||||
|
|
||||||
|
$gasGoo = [
|
||||||
|
'Zeolites',
|
||||||
|
'Sylvite',
|
||||||
|
'Bitumens',
|
||||||
|
'Coesite',
|
||||||
|
];
|
||||||
|
|
||||||
|
$r8Goo = [
|
||||||
|
'Cobaltite',
|
||||||
|
'Euxenite',
|
||||||
|
'Titanite',
|
||||||
|
'Scheelite',
|
||||||
|
];
|
||||||
|
|
||||||
|
$r16Goo = [
|
||||||
|
'Otavite',
|
||||||
|
'Sperrylite',
|
||||||
|
'Vanadinite',
|
||||||
|
'Chromite',
|
||||||
|
];
|
||||||
|
|
||||||
|
$r32Goo = [
|
||||||
|
'Carnotite',
|
||||||
|
'Zircon',
|
||||||
|
'Pollucite',
|
||||||
|
'Cinnabar',
|
||||||
|
];
|
||||||
|
|
||||||
|
$r64Goo = [
|
||||||
|
'Xenotime',
|
||||||
|
'Monazite',
|
||||||
|
'Loparite',
|
||||||
|
'Ytterbite',
|
||||||
|
];
|
||||||
|
|
||||||
|
return view('moons.user.allmoons')->with('systems', $systems)
|
||||||
|
->with('moons', $moons)
|
||||||
|
->with('gasGoo', $gasGoo)
|
||||||
|
->with('r8Goo', $r8Goo)
|
||||||
|
->with('r16Goo', $r16Goo)
|
||||||
|
->with('r32Goo', $r32Goo)
|
||||||
|
->with('r64Goo', $r64Goo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to display moon request form
|
||||||
|
*/
|
||||||
|
public function displayRequestAllianceMoon() {
|
||||||
|
return view('moons.user.requestmoon');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to store the moon request
|
||||||
|
*/
|
||||||
|
public function storeRequestAllianceMoon(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'system' => 'required',
|
||||||
|
'planet' => 'required',
|
||||||
|
'moon' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Declare some necessary arrays for figuring out what region a moon resides in
|
||||||
|
$catch = [
|
||||||
|
'6X7-JO',
|
||||||
|
'A803-L',
|
||||||
|
'I8-D0G',
|
||||||
|
'WQH-4K',
|
||||||
|
'GJ0-JO',
|
||||||
|
'Q-S7ZD',
|
||||||
|
'JWZ2-V',
|
||||||
|
'J-ODE7',
|
||||||
|
'OGL8-Q',
|
||||||
|
'R-K4QY',
|
||||||
|
];
|
||||||
|
|
||||||
|
$immensea = [
|
||||||
|
'ZBP-TP',
|
||||||
|
'XVV-21',
|
||||||
|
'B9E-H6',
|
||||||
|
'JDAS-0',
|
||||||
|
'Y19P-1',
|
||||||
|
'LN-56V',
|
||||||
|
'O7-7UX',
|
||||||
|
'Y2-QUV',
|
||||||
|
'SPBS-6',
|
||||||
|
'A4B-V5',
|
||||||
|
'GXK-7F',
|
||||||
|
'78TS-Q',
|
||||||
|
'CJNF-J',
|
||||||
|
'EA-HSA',
|
||||||
|
'FYI-49',
|
||||||
|
'WYF8-8',
|
||||||
|
'NS2L-4',
|
||||||
|
'B-S347',
|
||||||
|
'AF0-V5',
|
||||||
|
'QI-S9W',
|
||||||
|
'B-A587',
|
||||||
|
'PPFB-U',
|
||||||
|
'L-5JCJ',
|
||||||
|
'4-GB14',
|
||||||
|
'REB-KR',
|
||||||
|
'QE-E1D',
|
||||||
|
'LK1K-5',
|
||||||
|
'Z-H2MA',
|
||||||
|
'B-KDOZ',
|
||||||
|
'E8-YS9',
|
||||||
|
];
|
||||||
|
|
||||||
|
//Declare lookup variables
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
|
||||||
|
//Get all of the information needed to create the database entry
|
||||||
|
$charId = auth()->user()->getId();
|
||||||
|
$charInfo = $lookup->GetCharacterInfo($charId);
|
||||||
|
$charName = $charInfo->name;
|
||||||
|
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||||
|
$corpId = $corpInfo->corporation_id;
|
||||||
|
$corpName = $corpInfo->name;
|
||||||
|
$corpTicker = $corpInfo->ticker;
|
||||||
|
//Declare the region variable as null for the lookup if statement
|
||||||
|
$region = null;
|
||||||
|
|
||||||
|
//Get the region the moon resides in from the system
|
||||||
|
if(in_array($request->system, $catch, true)) {
|
||||||
|
$region = 'Catch';
|
||||||
|
} else if(in_array($request->system, $immensea, true)) {
|
||||||
|
$region = 'Immensea';
|
||||||
|
} else {
|
||||||
|
//False value. Redirect back to page
|
||||||
|
return redirct('/moons/display/request')->with('error', 'Region was not found.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Not working correctly with certain systems
|
||||||
|
//Check to see if the moon is not available
|
||||||
|
$future = AllianceMoon::where([
|
||||||
|
'Region' => (string)$region,
|
||||||
|
'System' => (string)$request->system,
|
||||||
|
'Planet' => (string)$request->planet,
|
||||||
|
'Moon' => (string)$request->moon,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
if($future->Availability != 'Available') {
|
||||||
|
return redirect('/moons/display/request')->with('error', 'The moon has already been reserved by another party.');
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Check to see if the moon has been previously inputted for
|
||||||
|
$allMoons = AllianceMoon::all();
|
||||||
|
foreach($allMoons as $moon) {
|
||||||
|
if($moon->Region == $region && $moon->System == $request->system && $moon->Planet == $request->planet && $moon->Moon == $request->moon) {
|
||||||
|
if($moon->Availability != 'Available') {
|
||||||
|
return redirect('moons/display/request')->with('error', 'The moon has already been reserved by another party.');
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create the new object to save into the database
|
||||||
|
$moonRequest = new AllianceMoonRequest;
|
||||||
|
$moonRequest->region = $region;
|
||||||
|
$moonRequest->system = $request->system;
|
||||||
|
$moonRequest->planet = $request->planet;
|
||||||
|
$moonRequest->moon = $request->moon;
|
||||||
|
$moonRequest->corporation_id = $corpId;
|
||||||
|
$moonRequest->corporation_name = $corpName;
|
||||||
|
$moonRequest->corporation_ticker = $corpTicker;
|
||||||
|
$moonRequest->requestor_name = $charName;
|
||||||
|
$moonRequest->requestor_id = $charId;
|
||||||
|
$moonRequest->status = 'Pending';
|
||||||
|
$moonRequest->save();
|
||||||
|
|
||||||
|
//Update the current moon's status in the model AllianceMoon
|
||||||
|
AllianceMoon::where([
|
||||||
|
'Region' => $region,
|
||||||
|
'System' => $request->system,
|
||||||
|
'Planet' => $request->planet,
|
||||||
|
'Moon' => $request->moon,
|
||||||
|
])->update([
|
||||||
|
'Availability' => 'Request Pending',
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect('/moons/display/request')->with('success', 'Moon request submitted.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to display the moons and pass data to the blade template
|
||||||
|
*/
|
||||||
|
public function displayRentalMoons() {
|
||||||
$rentalEnd = '';
|
$rentalEnd = '';
|
||||||
|
|
||||||
//Get the user type from the user Auth class
|
//Get the user type from the user Auth class
|
||||||
$type = Auth::user()->user_type;
|
$type = Auth::user()->getUserType();
|
||||||
//Setup calls to the MoonCalc class
|
//Setup calls to the MoonCalc class
|
||||||
$moonCalc = new MoonCalc();
|
$moonCalc = new MoonCalc();
|
||||||
//Update the prices for the moon
|
//get all of the rental moons from the database
|
||||||
$moonCalc->FetchNewPrices();
|
$moons = DB::table('RentalMoons')->orderBy('System', 'asc')->get();
|
||||||
//get all of the moons from the database
|
//Set the rental date as last month for moons not rented
|
||||||
$moons = DB::table('Moons')->orderBy('System', 'asc')->get();
|
$lastMonth = Carbon::now()->subMonth();
|
||||||
|
//Set a variable for today's date
|
||||||
|
$today = Carbon::now();
|
||||||
|
|
||||||
//declare the html variable and set it to null
|
//declare the html variable and set it to null
|
||||||
|
|
||||||
$table = array();
|
$table = array();
|
||||||
@@ -55,7 +260,7 @@ class MoonsController extends Controller
|
|||||||
|
|
||||||
if($rental == false) {
|
if($rental == false) {
|
||||||
//If we don't find a rental record, set the rental date as last month
|
//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');
|
$rentalEnd = $rentalTemp->format('m-d');
|
||||||
} else {
|
} else {
|
||||||
//Set the rental date up
|
//Set the rental date up
|
||||||
@@ -63,9 +268,6 @@ class MoonsController extends Controller
|
|||||||
$rentalEnd = $rentalTemp->format('m-d');
|
$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,
|
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||||
|
|
||||||
@@ -113,28 +315,230 @@ class MoonsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function displayTotalWorth(Request $request) {
|
public function displayTotalWorth(Request $request) {
|
||||||
$firstOre = $request->firstOre;
|
|
||||||
$firstQuantity = $request->firstQuantity;
|
|
||||||
$secondOre = $request->secondOre;
|
|
||||||
$secondQuantity = $request->secondQuantity;
|
|
||||||
$thirdOre = $request->thirdOre;
|
|
||||||
$thirdQuantity = $request->thirdQuantity;
|
|
||||||
$fourthOre = $request->fourthOre;
|
|
||||||
$fourthQuantity = $request->fourthQuantity;
|
|
||||||
|
|
||||||
//Setup calls to the MoonCalc class
|
//Setup calls to the MoonCalc class
|
||||||
$moonCalc = new MoonCalc();
|
$moonCalc = new MoonCalc();
|
||||||
//Update the prices for the moon
|
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
||||||
$moonCalc->FetchNewPrices();
|
$composition = [
|
||||||
|
'Tritanium' => 0,
|
||||||
|
'Pyerite' => 0,
|
||||||
|
'Mexallon' => 0,
|
||||||
|
'Isogen' => 0,
|
||||||
|
'Nocxium' => 0,
|
||||||
|
'Zydrine' => 0,
|
||||||
|
'Megacyte' => 0,
|
||||||
|
'Atmospheric_Gases' => 0,
|
||||||
|
'Evaporite_Deposits' => 0,
|
||||||
|
'Hydrocarbons' => 0,
|
||||||
|
'Silicates' => 0,
|
||||||
|
'Cobalt' => 0,
|
||||||
|
'Platinum' => 0,
|
||||||
|
'Vanadium'=> 0,
|
||||||
|
'Chromium' => 0,
|
||||||
|
'Technetium' => 0,
|
||||||
|
'Hafnium' => 0,
|
||||||
|
'Caesium' => 0,
|
||||||
|
'Mercury' => 0,
|
||||||
|
'Dysprosium' => 0,
|
||||||
|
'Neodymium' => 0,
|
||||||
|
'Promethium' => 0,
|
||||||
|
'Thulium' => 0,
|
||||||
|
];
|
||||||
|
|
||||||
|
$firstOre = $request->firstOre;
|
||||||
|
if($request->firstQuantity >= 1.00) {
|
||||||
|
$firstQuantity = $request->firstQuantity / 100.00;
|
||||||
|
} else {
|
||||||
|
$firstQuantity = $request->firstQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
$secondOre = $request->secondOre;
|
||||||
|
if($request->secondQuantity >= 1.00) {
|
||||||
|
$secondQuantity = $request->secondQuantity / 100.00;
|
||||||
|
} else {
|
||||||
|
$secondQuantity = $request->secondQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
$thirdOre = $request->thirdOre;
|
||||||
|
if($request->thirdQuantity >= 1.00) {
|
||||||
|
$thirdQuantity = $request->thirdQuantity / 100.00;
|
||||||
|
} else {
|
||||||
|
$thirdQuantity = $request->thirdQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fourthOre = $request->fourthOre;
|
||||||
|
if($request->fourthQuantity >= 1.00) {
|
||||||
|
$fourthQuantity = $request->fourthQuantity / 100.00;
|
||||||
|
} else {
|
||||||
|
$fourthQuantity = $request->fourthQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($request->reprocessing >= 1.00) {
|
||||||
|
$reprocessing = $request->reprocessing / 100.00;
|
||||||
|
} else {
|
||||||
|
$reprocessing = $request->reprocessing;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Set the reprocessing level for 84% if the value is null
|
||||||
|
if($request->reprocessing == null) {
|
||||||
|
$reprocessing = 0.84;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Calculate the total moon goo value
|
||||||
$totalGoo = $moonCalc->SpatialMoonsOnlyGooTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
$totalGoo = $moonCalc->SpatialMoonsOnlyGooTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
||||||
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
|
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
|
||||||
|
//Format the number to send to the blade
|
||||||
$totalGoo = number_format($totalGoo, 2, ".", ",");
|
$totalGoo = number_format($totalGoo, 2, ".", ",");
|
||||||
|
|
||||||
|
//Calculate the total worth of the moon
|
||||||
$totalWorth = $moonCalc->SpatialMoonsTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
$totalWorth = $moonCalc->SpatialMoonsTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
||||||
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
|
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
|
||||||
|
//Format the number to send to the blade.
|
||||||
$totalWorth = number_format($totalWorth, 2, ".", ",");
|
$totalWorth = number_format($totalWorth, 2, ".", ",");
|
||||||
|
|
||||||
return view('moons.user.displayTotalWorth')->with(['totalWorth' => $totalWorth, 'totalGoo' => $totalGoo]);
|
//Get the composition for the first ore if it is not None.
|
||||||
|
//Add the first ore composition to the final composition
|
||||||
|
if($firstOre != 'None') {
|
||||||
|
//Get the ore's composition
|
||||||
|
$firstComp = $moonCalc->GetOreComposition($firstOre);
|
||||||
|
//Get the amount of units mine-able from the moon
|
||||||
|
$mUnits = $moonCalc->CalcOreUnits($firstOre, $firstQuantity);
|
||||||
|
//Calculate the number of reprocessing units to happen from moon units
|
||||||
|
$rUnits = floor($mUnits / 100.0);
|
||||||
|
|
||||||
|
//Compile the composition of the ore
|
||||||
|
$composition['Tritanium'] += floor(($firstComp->Tritanium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Pyerite'] += floor(($firstComp->Pyerite * $rUnits) * $reprocessing);
|
||||||
|
$composition['Mexallon'] += floor(($firstComp->Mexallon * $rUnits) * $reprocessing);
|
||||||
|
$composition['Isogen'] += floor(($firstComp->Isogen * $rUnits) * $reprocessing);
|
||||||
|
$composition['Nocxium'] += floor(($firstComp->Nocxium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Zydrine'] += floor(($firstComp->Zydrine * $rUnits) * $reprocessing);
|
||||||
|
$composition['Megacyte'] += floor(($firstComp->Megacyte * $rUnits) * $reprocessing);
|
||||||
|
$composition['Atmospheric_Gases'] += floor(($firstComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||||
|
$composition['Evaporite_Deposits'] += floor(($firstComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||||
|
$composition['Hydrocarbons'] += floor(($firstComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||||
|
$composition['Silicates'] += floor(($firstComp->Silicates * $rUnits) * $reprocessing);
|
||||||
|
$composition['Cobalt'] += floor(($firstComp->Cobalt * $rUnits) * $reprocessing);
|
||||||
|
$composition['Platinum'] += floor(($firstComp->Platinium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Vanadium'] += floor(($firstComp->Vanadium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Chromium'] += floor(($firstComp->Chromium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Technetium'] += floor(($firstComp->Technetium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Hafnium'] += floor(($firstComp->Hafnium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Caesium'] += floor(($firstComp->Caesium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Mercury'] += floor(($firstComp->Mercury * $rUnits) * $reprocessing);
|
||||||
|
$composition['Dysprosium'] += floor(($firstComp->Dysprosium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Neodymium'] += floor(($firstComp->Neodymium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Promethium'] += floor(($firstComp->Promethium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Thulium'] += floor(($firstComp->Thulium * $rUnits) * $reprocessing);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the composition for the second ore if it is not None.
|
||||||
|
//Add the second ore composition to the final composition
|
||||||
|
if($secondOre != 'None') {
|
||||||
|
//Get the ore's composition
|
||||||
|
$secondComp = $moonCalc->GetOreComposition($secondOre);
|
||||||
|
//Get the amount of units mine-able from the moon
|
||||||
|
$mUnits = $moonCalc->CalcOreUnits($secondOre, $secondQuantity);
|
||||||
|
//Calculate the number of reprocessing units to happen from moon units
|
||||||
|
$rUnits = floor($mUnits / 100.0);
|
||||||
|
|
||||||
|
$composition['Tritanium'] += floor(($secondComp->Tritanium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Pyerite'] += floor(($secondComp->Pyerite * $rUnits) * $reprocessing);
|
||||||
|
$composition['Mexallon'] += floor(($secondComp->Mexallon * $rUnits) * $reprocessing);
|
||||||
|
$composition['Isogen'] += floor(($secondComp->Isogen * $rUnits) * $reprocessing);
|
||||||
|
$composition['Nocxium'] += floor(($secondComp->Nocxium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Zydrine'] += floor(($secondComp->Zydrine * $rUnits) * $reprocessing);
|
||||||
|
$composition['Megacyte'] += floor(($secondComp->Megacyte * $rUnits) * $reprocessing);
|
||||||
|
$composition['Atmospheric_Gases'] += floor(($secondComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||||
|
$composition['Evaporite_Deposits'] += floor(($secondComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||||
|
$composition['Hydrocarbons'] += floor(($secondComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||||
|
$composition['Silicates'] += floor(($secondComp->Silicates * $rUnits) * $reprocessing);
|
||||||
|
$composition['Cobalt'] += floor(($secondComp->Cobalt * $rUnits) * $reprocessing);
|
||||||
|
$composition['Platinum'] += floor(($secondComp->Platinium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Vanadium'] += floor(($secondComp->Vanadium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Chromium'] += floor(($secondComp->Chromium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Technetium'] += floor(($secondComp->Technetium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Hafnium'] += floor(($secondComp->Hafnium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Caesium'] += floor(($secondComp->Caesium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Mercury'] += floor(($secondComp->Mercury * $rUnits) * $reprocessing);
|
||||||
|
$composition['Dysprosium'] += floor(($secondComp->Dysprosium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Neodymium'] += floor(($secondComp->Neodymium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Promethium'] += floor(($secondComp->Promethium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Thulium'] += floor(($secondComp->Thulium * $rUnits) * $reprocessing);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the composition for the third ore if it is not None.
|
||||||
|
//Add the third ore composition to the final composition
|
||||||
|
if($thirdOre != 'None') {
|
||||||
|
//Get the ore's composition
|
||||||
|
$thirdComp = $moonCalc->GetOreComposition($thirdOre);
|
||||||
|
//Get the amount of units mine-able from the moon
|
||||||
|
$mUnits = $moonCalc->CalcOreUnits($thirdOre, $thirdQuantity);
|
||||||
|
//Calculate the number of reprocessing units to happen from moon units
|
||||||
|
$rUnits = floor($mUnits / 100.0);
|
||||||
|
|
||||||
|
$composition['Tritanium'] += floor(($thirdComp->Tritanium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Pyerite'] += floor(($thirdComp->Pyerite * $rUnits) * $reprocessing);
|
||||||
|
$composition['Mexallon'] += floor(($thirdComp->Mexallon * $rUnits) * $reprocessing);
|
||||||
|
$composition['Isogen'] += floor(($thirdComp->Isogen * $rUnits) * $reprocessing);
|
||||||
|
$composition['Nocxium'] += floor(($thirdComp->Nocxium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Zydrine'] += floor(($thirdComp->Zydrine * $rUnits) * $reprocessing);
|
||||||
|
$composition['Megacyte'] += floor(($thirdComp->Megacyte * $rUnits) * $reprocessing);
|
||||||
|
$composition['Atmospheric_Gases'] += floor(($thirdComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||||
|
$composition['Evaporite_Deposits'] += floor(($thirdComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||||
|
$composition['Hydrocarbons'] += floor(($thirdComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||||
|
$composition['Silicates'] += floor(($thirdComp->Silicates * $rUnits) * $reprocessing);
|
||||||
|
$composition['Cobalt'] += floor(($thirdComp->Cobalt * $rUnits) * $reprocessing);
|
||||||
|
$composition['Platinum'] += floor(($thirdComp->Platinium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Vanadium'] += floor(($thirdComp->Vanadium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Chromium'] += floor(($thirdComp->Chromium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Technetium'] += floor(($thirdComp->Technetium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Hafnium'] += floor(($thirdComp->Hafnium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Caesium'] += floor(($thirdComp->Caesium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Mercury'] += floor(($thirdComp->Mercury * $rUnits) * $reprocessing);
|
||||||
|
$composition['Dysprosium'] += floor(($thirdComp->Dysprosium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Neodymium'] += floor(($thirdComp->Neodymium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Promethium'] += floor(($thirdComp->Promethium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Thulium'] += floor(($thirdComp->Thulium * $rUnits) * $reprocessing);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the composition for the fourth ore if it is not None.
|
||||||
|
//Add the fourth ore composition to the final composition
|
||||||
|
if($fourthOre != 'None') {
|
||||||
|
//Get the ore's composition
|
||||||
|
$fourthComp = $moonCalc->GetOreComposition($fourthOre);
|
||||||
|
//Get the amount of units mine-able from the moon
|
||||||
|
$mUnits = $moonCalc->CalcOreUnits($fourthOre, $fourthQuantity);
|
||||||
|
//Calculate the number of reprocessing units to happen from moon units
|
||||||
|
$rUnits = floor($mUnits / 100.0);
|
||||||
|
|
||||||
|
$composition['Tritanium'] += floor(($fourthComp->Tritanium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Pyerite'] += floor(($fourthComp->Pyerite * $rUnits) * $reprocessing);
|
||||||
|
$composition['Mexallon'] += floor(($fourthComp->Mexallon * $rUnits) * $reprocessing);
|
||||||
|
$composition['Isogen'] += floor(($fourthComp->Isogen * $rUnits) * $reprocessing);
|
||||||
|
$composition['Nocxium'] += floor(($fourthComp->Nocxium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Zydrine'] += floor(($fourthComp->Zydrine * $rUnits) * $reprocessing);
|
||||||
|
$composition['Megacyte'] += floor(($fourthComp->Megacyte * $rUnits) * $reprocessing);
|
||||||
|
$composition['Atmospheric_Gases'] += floor(($fourthComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||||
|
$composition['Evaporite_Deposits'] += floor(($fourthComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||||
|
$composition['Hydrocarbons'] += floor(($fourthComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||||
|
$composition['Silicates'] += floor(($fourthComp->Silicates * $rUnits) * $reprocessing);
|
||||||
|
$composition['Cobalt'] += floor(($fourthComp->Cobalt * $rUnits) * $reprocessing);
|
||||||
|
$composition['Platinum'] += floor(($fourthComp->Platinium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Vanadium'] += floor(($fourthComp->Vanadium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Chromium'] += floor(($fourthComp->Chromium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Technetium'] += floor(($fourthComp->Technetium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Hafnium'] += floor(($fourthComp->Hafnium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Caesium'] += floor(($fourthComp->Caesium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Mercury'] += floor(($fourthComp->Mercury * $rUnits) * $reprocessing);
|
||||||
|
$composition['Dysprosium'] += floor(($fourthComp->Dysprosium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Neodymium'] += floor(($fourthComp->Neodymium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Promethium'] += floor(($fourthComp->Promethium * $rUnits) * $reprocessing);
|
||||||
|
$composition['Thulium'] += floor(($fourthComp->Thulium * $rUnits) * $reprocessing);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('moons.user.displayTotalWorth')->with('totalWorth', $totalWorth)
|
||||||
|
->with('totalGoo', $totalGoo)
|
||||||
|
->with('composition', $composition)
|
||||||
|
->with('reprocessing', $reprocessing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
526
app/Http/Controllers/SRP/SRPAdminController.php
Normal file
526
app/Http/Controllers/SRP/SRPAdminController.php
Normal file
@@ -0,0 +1,526 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\SRP;
|
||||||
|
|
||||||
|
//Laravel Libraries
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Auth;
|
||||||
|
use Khill\Lavacharts\Lavacharts;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//User Libraries
|
||||||
|
use App\Library\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();
|
||||||
|
$viewShipTypes = array();
|
||||||
|
|
||||||
|
//Declare variables for use later.
|
||||||
|
$sum_actual = 0.00;
|
||||||
|
$sum_loss = 0.00;
|
||||||
|
|
||||||
|
//Get the ship types from the database
|
||||||
|
$shipTypes = SrpShipType::all();
|
||||||
|
|
||||||
|
//Setup the viewShipTypes variable
|
||||||
|
$tempShipTypes = SrpShipType::groupBy('code')->pluck('code');
|
||||||
|
foreach($tempShipTypes as $key => $value) {
|
||||||
|
$viewShipTypes[$value] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the fleet types from the database
|
||||||
|
$fleetTypes = SrpFleetType::all();
|
||||||
|
|
||||||
|
//Get the payouts from the database
|
||||||
|
$payouts = SrpPayout::all();
|
||||||
|
|
||||||
|
//Get the SRP ship count to see how many requests are avaiable "Under Review" in the database
|
||||||
|
$count = SRPShip::where(['approved' => 'Under Review'])->count();
|
||||||
|
//If the count is 0 then there are no requests
|
||||||
|
if($count === 0) {
|
||||||
|
$requests = null;
|
||||||
|
} else { //Process each request
|
||||||
|
$reqs = SRPShip::where(['approved' => 'Under Review'])->get()->toArray();
|
||||||
|
foreach($reqs as $r) {
|
||||||
|
$temp['id'] = $r['id'];
|
||||||
|
$temp['created_at'] = $r['created_at'];
|
||||||
|
$temp['character_name'] = $r['character_name'];
|
||||||
|
$temp['fleet_commander_name'] = $r['fleet_commander_name'];
|
||||||
|
$temp['zkillboard'] = $r['zkillboard'];
|
||||||
|
$temp['loss_value'] = $r['loss_value'];
|
||||||
|
$sum_loss += $temp['loss_value'];
|
||||||
|
//Get the ship type
|
||||||
|
foreach($shipTypes as $s) {
|
||||||
|
if($r['ship_type'] == $s->code) {
|
||||||
|
$temp['ship_type'] = $s->description;
|
||||||
|
$temp['cost_code'] = $s->code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Get the fleet type
|
||||||
|
foreach($fleetTypes as $f) {
|
||||||
|
if($r['fleet_type'] == $f->code) {
|
||||||
|
$temp['fleet_type'] = $f->description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Calculate the recommended srp amount
|
||||||
|
foreach($payouts as $p) {
|
||||||
|
if($r['ship_type'] == $p->code) {
|
||||||
|
$temp['actual_srp'] = $r['loss_value'] * ($p->payout / 100.00 );
|
||||||
|
$temp['payout_percentage'] = $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)
|
||||||
|
->with('viewShipTypes', $viewShipTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateLossValue($id, $value) {
|
||||||
|
//Convert the string into a decimal style number to be stored correctly
|
||||||
|
$lossValue = str_replace(',', '', $value);
|
||||||
|
$lossValue = floatval($lossValue);
|
||||||
|
|
||||||
|
SRPShip::where(['id' => $id])->update([
|
||||||
|
'loss_value' => $lossValue,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect('/srp/admin/display');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateShipType($id, $value) {
|
||||||
|
SRPShip::where(['id' => $id])->update([
|
||||||
|
'ship_type' => $value,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect('/srp/admin/display');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processSRPRequest(Request $request) {
|
||||||
|
//Validate the request
|
||||||
|
$this->validate($request, [
|
||||||
|
'id' => 'required',
|
||||||
|
'approved' => 'required',
|
||||||
|
'paid_value' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Get the total loss value from the form and convert it to the right format
|
||||||
|
$paidLoss = str_replace(',', '', $request->paid_value);
|
||||||
|
$paidLoss = floatval($paidLoss);
|
||||||
|
|
||||||
|
//If the notes are not null update like this.
|
||||||
|
if($request->notes != null) {
|
||||||
|
$srp = SRPShip::where(['id' => $request->id])->update([
|
||||||
|
'approved' => $request->approved,
|
||||||
|
'paid_by_id' => auth()->user()->character_id,
|
||||||
|
'paid_by_name' => auth()->user()->name,
|
||||||
|
'notes' => $request->notes,
|
||||||
|
'paid_value' => $paidLoss,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$srp = SRPShip::where(['id' => $request->id])->update([
|
||||||
|
'approved' => $request->approved,
|
||||||
|
'paid_by_id' => auth()->user()->character_id,
|
||||||
|
'paid_by_name' => auth()->user()->name,
|
||||||
|
'paid_value' => $paidLoss,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($request->approved == 'Approved') {
|
||||||
|
return redirect('/srp/admin/display')->with('success', 'SRP Marked as Paid');
|
||||||
|
} else {
|
||||||
|
return redirect('/srp/admin/display')->with('error', 'SRP Request Denied.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayHistory() {
|
||||||
|
|
||||||
|
$srpApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
])->orderBy('created_at', 'desc')->paginate(25);
|
||||||
|
|
||||||
|
$srpDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
])->orderBy('created_at', 'desc')->paginate(25);
|
||||||
|
|
||||||
|
return view('srp.admin.history')->with('srpApproved', $srpApproved)
|
||||||
|
->with('srpDenied', $srpDenied);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayStatistics() {
|
||||||
|
$months = 3;
|
||||||
|
$barChartData = array();
|
||||||
|
$start = Carbon::now()->toDateTimeString();
|
||||||
|
$end = Carbon::now()->subMonths(1)->toDateTimeString();
|
||||||
|
|
||||||
|
//Declare the Lavacharts variable
|
||||||
|
$lava = new Lavacharts;
|
||||||
|
|
||||||
|
//We need a function from this library rather than recreating a new library
|
||||||
|
$srpHelper = new SRPHelper();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pie chart for the number of approved, denied, and under review payouts currently in the system.
|
||||||
|
*/
|
||||||
|
//Get the count of open srp requests
|
||||||
|
$pieOpen = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
['created_at', '>=', $end],
|
||||||
|
])->count();
|
||||||
|
//Get the count of approved srp requests
|
||||||
|
$pieApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
['created_at', '>=', $end],
|
||||||
|
])->count();
|
||||||
|
//Get the count of denied srp requests
|
||||||
|
$pieDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
['created_at', '>=', $end],
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
//Create a new datatable for the lavachart.
|
||||||
|
$srp = $lava->DataTable();
|
||||||
|
//Add string columns, number columns, and data rows for the chart
|
||||||
|
$srp->addStringColumn('ISK Value')
|
||||||
|
->addNumberColumn('ISK')
|
||||||
|
->addRow(['Approved', $pieApproved])
|
||||||
|
->addRow(['Denied', $pieDenied])
|
||||||
|
->addRow(['Under Review', $pieOpen]);
|
||||||
|
//Create the pie chart in memory with any options needed to render the chart
|
||||||
|
$lava->PieChart('SRP Stats', $srp, [
|
||||||
|
'title' => 'SRP Stats',
|
||||||
|
'is3D' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gauage chart for showing number of open srp requests
|
||||||
|
*/
|
||||||
|
//Create a new datatable in the
|
||||||
|
$adur = $lava->DataTable();
|
||||||
|
//Add string columns, number columns, and data row for the chart
|
||||||
|
$adur->addStringColumn('Type')
|
||||||
|
->addNumberColumn('Value')
|
||||||
|
->addRow(['Under Review', $pieOpen]);
|
||||||
|
//Create the gauge chart with any options needed to render the chart
|
||||||
|
$lava->GaugeChart('SRP', $adur, [
|
||||||
|
'width' => 400,
|
||||||
|
'greenFrom' => 0,
|
||||||
|
'greenTo' => 20,
|
||||||
|
'yellowFrom' => 20,
|
||||||
|
'yellowTo' => 40,
|
||||||
|
'redFrom' => 40,
|
||||||
|
'redTo' => 100,
|
||||||
|
'majorTicks' => [
|
||||||
|
'Safe',
|
||||||
|
'Critical',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a vertical chart of all of the cost codes for the ships being SRP'ed.
|
||||||
|
* The chart will be by cost code of ships being replaced
|
||||||
|
*/
|
||||||
|
//Declare the data table
|
||||||
|
$costCodeChart = $lava->DataTable();
|
||||||
|
|
||||||
|
//Get the approved, under review, and denied cost codes and amounts
|
||||||
|
$t1fdcApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T1FDC',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t1fdcUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T1FDC',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t1fdcDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T1FDC',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$t1bcApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T1BC',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t1bcUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T1BC',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t1bcDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T1BC',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$t2fdApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T2FD',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t2fdUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T2FD',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t2fdDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T2FD',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$t3dApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T3D',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t3dUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T3D',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t3dDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T3D',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$t1t2logiApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T1T2Logi',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t1t2logiUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T1T2Logi',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t1t2logiDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T1T2Logi',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$reconsApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'REC',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$reconsUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'REC',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$reconsDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'REC',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$t2cApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T2C',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t2cUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T2C',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t2cDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T2C',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$t3cApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T3C',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t3cUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T3C',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t3cDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T3C',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$commandApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'COM',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$commandUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'COM',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$commandDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'COM',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$interdictorApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'INTD',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$interdictorUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'INTD',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$interdictorDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'INTD',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$t1bsApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'T1BS',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$t1bsUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'T1BS',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$t1bsDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'T1BS',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
$dksApproved = SRPShip::where([
|
||||||
|
'approved' => 'Approved',
|
||||||
|
'ship_type' => 'DKS',
|
||||||
|
])->sum('paid_value');
|
||||||
|
$dksUnderReview = SRPShip::where([
|
||||||
|
'approved' => 'Under Review',
|
||||||
|
'ship_type' => 'DKS',
|
||||||
|
])->sum('loss_value');
|
||||||
|
$dksDenied = SRPShip::where([
|
||||||
|
'approved' => 'Denied',
|
||||||
|
'ship_type' => 'DKS',
|
||||||
|
])->sum('loss_value');
|
||||||
|
|
||||||
|
|
||||||
|
//Add string column, number columns.
|
||||||
|
$costCodeChart->addStringColumn('SRP Costs')
|
||||||
|
->addNumberColumn('Approved')
|
||||||
|
->addNumberColumn('Under Review')
|
||||||
|
->addNumberColumn('Denied')
|
||||||
|
->addRow(['T1FDC', $t1fdcApproved, $t1fdcUnderReview, $t1fdcDenied])
|
||||||
|
->addRow(['T1BC', $t1bcApproved, $t1bcUnderReview, $t1bcDenied])
|
||||||
|
->addRow(['T1BS', $t1bsApproved, $t1bsUnderReview, $t1bsDenied])
|
||||||
|
->addRow(['T2FD', $t2fdApproved, $t2fdUnderReview, $t2fdDenied])
|
||||||
|
->addRow(['T2C', $t2cApproved, $t2cUnderReview, $t2cDenied])
|
||||||
|
->addRow(['T1T2Logi', $t1t2logiApproved, $t1t2logiUnderReview, $t1t2logiDenied])
|
||||||
|
->addRow(['T3D', $t3dApproved, $t3dUnderReview, $t3dDenied])
|
||||||
|
->addRow(['T3C', $t3cApproved, $t3cUnderReview, $t3cDenied])
|
||||||
|
->addRow(['RECON', $reconsApproved, $reconsUnderReview, $reconsDenied])
|
||||||
|
->addRow(['COMMAND', $commandApproved, $commandUnderReview, $commandDenied])
|
||||||
|
->addRow(['DKS', $dksApproved, $dksUnderReview, $dksDenied]);
|
||||||
|
|
||||||
|
$lava->ColumnChart('Cost Codes', $costCodeChart, [
|
||||||
|
'columns' => 4,
|
||||||
|
'title' => 'Cost Code SRP Chart',
|
||||||
|
'titleTextStyle' => [
|
||||||
|
'color' => '#eb6b2c',
|
||||||
|
'fontSize' => 14,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return view('srp.admin.statistics')->with('lava', $lava);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayCostCodes() {
|
||||||
|
//Declare some variables
|
||||||
|
$costcodes = array();
|
||||||
|
$count = 0;
|
||||||
|
$shipType = SrpShipType::all();
|
||||||
|
$srpPayout = SrpPayout::all();
|
||||||
|
|
||||||
|
foreach($shipType as $ship) {
|
||||||
|
//Don't process if the code is None
|
||||||
|
if($ship->code != 'None') {
|
||||||
|
$tempCode = $ship->code;
|
||||||
|
$tempDescription = $ship->description;
|
||||||
|
$temp = SrpPayout::where(['code' => $ship->code])->first();
|
||||||
|
$tempPayout = $temp->payout;
|
||||||
|
//Store the data in a temporary variable
|
||||||
|
$block = [
|
||||||
|
'code' => $tempCode,
|
||||||
|
'description' => $tempDescription,
|
||||||
|
'payout' => $tempPayout,
|
||||||
|
];
|
||||||
|
|
||||||
|
//Push the data into the array
|
||||||
|
array_push($costcodes, $block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('srp.admin.costcodes.display')->with('costcodes', $costcodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayAddCostCode() {
|
||||||
|
return view('srp.admin.costcodes.add');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addCostCode(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'code' => 'required',
|
||||||
|
'description' => 'required',
|
||||||
|
'payout' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$code = $request->code;
|
||||||
|
$description = $request->description;
|
||||||
|
$payout = $request->payout;
|
||||||
|
|
||||||
|
$payoutCount = SrpPayout::where(['code' => $code])->count();
|
||||||
|
$shipTypeCount = SrpShipType::where(['code' => $code])->count();
|
||||||
|
|
||||||
|
//If we don't find the cost code, let's add it. otherwise send an error.
|
||||||
|
if($payoutCount == 0 && $shipTypeCount == 0) {
|
||||||
|
$payoutTable = new SrpPayout;
|
||||||
|
$payoutTable->code = $code;
|
||||||
|
$payoutTable->payout = $payout;
|
||||||
|
$payoutTable->save();
|
||||||
|
|
||||||
|
$shipType = new SrpShipType;
|
||||||
|
$shipType->code = $code;
|
||||||
|
$shipType->description = $description;
|
||||||
|
$shipType->save();
|
||||||
|
|
||||||
|
return redirect('/srp/admin/display')->with('success', 'Cost code added.');
|
||||||
|
} else {
|
||||||
|
return redirect('/srp/admin/display')->with('error', 'Cost code already exists in the database.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function modifyCostCodes(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'description' => 'required',
|
||||||
|
'payout' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Update the SrpShipType
|
||||||
|
SrpShipType::where(['code' => $request->code])->update([
|
||||||
|
'description' => $request->description,
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Update the payout
|
||||||
|
SrpPayout::where(['code' => $request->code])->update([
|
||||||
|
'payout' => $request->payout,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect('/srp/admin/display')->with('success', 'Payout and Description updated.');
|
||||||
|
}
|
||||||
|
}
|
||||||
156
app/Http/Controllers/SRP/SRPController.php
Normal file
156
app/Http/Controllers/SRP/SRPController.php
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\SRP;
|
||||||
|
|
||||||
|
//Laravel Libraries
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
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 displaySrpHistory() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayPayoutAmounts() {
|
||||||
|
$payouts = array();
|
||||||
|
$count = 0;
|
||||||
|
$shipType = SrpShipType::all();
|
||||||
|
$srpPayout = SrpPayout::all();
|
||||||
|
|
||||||
|
foreach($shipType as $ship) {
|
||||||
|
//Don't process if the code is None
|
||||||
|
if($ship->code != 'None') {
|
||||||
|
$tempCode = $ship->code;
|
||||||
|
$tempDescription = $ship->description;
|
||||||
|
$temp = SrpPayout::where(['code' => $ship->code])->first();
|
||||||
|
|
||||||
|
$tempPayout = $temp->payout;
|
||||||
|
|
||||||
|
$block = [
|
||||||
|
'code' => $tempCode,
|
||||||
|
'description' => $tempDescription,
|
||||||
|
'payout' => $tempPayout,
|
||||||
|
];
|
||||||
|
|
||||||
|
array_push($payouts, $block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('srp.payouts')->with('payouts', $payouts);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displaySrpForm() {
|
||||||
|
$shipTypes = array();
|
||||||
|
$fleetTypes = array();
|
||||||
|
$characters = array();
|
||||||
|
$temp = array();
|
||||||
|
$alts = null;
|
||||||
|
|
||||||
|
//Get all the ship types
|
||||||
|
$shipTypesTemp = SrpShipType::all();
|
||||||
|
|
||||||
|
//Get all of the fleet types
|
||||||
|
$fleetTypesTemp = SrpFleetType::all();
|
||||||
|
|
||||||
|
//Process the ship types and store in the array
|
||||||
|
foreach($shipTypesTemp as $type) {
|
||||||
|
$shipTypes[$type->code] = $type->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Process the fleet types and store in the array
|
||||||
|
foreach($fleetTypesTemp as $type) {
|
||||||
|
$fleetTypes[$type->code] = $type->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the user id and name, and store in the array
|
||||||
|
$characters[auth()->user()->character_id] = auth()->user()->getName();
|
||||||
|
|
||||||
|
//Get the alts and store in the array
|
||||||
|
$altCount = UserAlt::where(['main_id' => auth()->user()->character_id])->count();
|
||||||
|
if($altCount > 0) {
|
||||||
|
$alts = UserAlt::where([
|
||||||
|
'main_id' => auth()->user()->character_id,
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
foreach($alts as $alt) {
|
||||||
|
$characters[$alt->character_id] = $alt->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('srp.srpform')->with('fleetTypes', $fleetTypes)
|
||||||
|
->with('shipTypes', $shipTypes)
|
||||||
|
->with('characters', $characters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeSRPFile(Request $request) {
|
||||||
|
$name = null;
|
||||||
|
|
||||||
|
$this->validate($request, [
|
||||||
|
'character' => 'required',
|
||||||
|
'FC' => 'required',
|
||||||
|
'FleetType' => 'required',
|
||||||
|
'zKillboard' => 'required',
|
||||||
|
'LossValue' => 'required',
|
||||||
|
'ShipType' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//See if the FC Name ties to a user on the services site
|
||||||
|
$fcId = User::where(['name' => $request->FC])->get(['character_id']);
|
||||||
|
|
||||||
|
//Take the loss value and remove ' ISK' from it. Convert the string to a number
|
||||||
|
//May need to work on some locale stuff here but will think about it first.
|
||||||
|
$lossValue = str_replace(' ISK', '', $request->LossValue);
|
||||||
|
$lossValue = str_replace(',', '', $lossValue);
|
||||||
|
$lossValue = floatval($lossValue);
|
||||||
|
|
||||||
|
//Convert the FC name to a regular case of characters
|
||||||
|
$tempFcName = strtolower($request->FC);
|
||||||
|
$tempFcName = ucwords($tempFcName);
|
||||||
|
|
||||||
|
$userCount = User::where(['character_id' => $request->character])->count();
|
||||||
|
$altCount = UserAlt::where(['character_id' => $request->character])->count();
|
||||||
|
|
||||||
|
if($userCount > 0) {
|
||||||
|
$tempUser = User::where(['character_id' => $request->character])->first();
|
||||||
|
$name = $tempUser->name;
|
||||||
|
} else if($altCount > 0) {
|
||||||
|
$tempAlt = UserAlt::where(['character_id' => $request->character])->first();
|
||||||
|
$name = $tempAlt->name;
|
||||||
|
} else {
|
||||||
|
$name = 'None';
|
||||||
|
}
|
||||||
|
|
||||||
|
$ship = new SRPShip;
|
||||||
|
$ship->character_id = $request->character;
|
||||||
|
$ship->character_name = $name;
|
||||||
|
$ship->fleet_commander_name = $tempFcName;
|
||||||
|
if(isset($fcId[0])) {
|
||||||
|
$ship->fleet_commander_id = $fcId[0]->character_id;
|
||||||
|
}
|
||||||
|
$ship->zkillboard = $request->zKillboard;
|
||||||
|
$ship->fleet_type = $request->FleetType;
|
||||||
|
$ship->ship_type = $request->ShipType;
|
||||||
|
$ship->loss_value = $lossValue;
|
||||||
|
$ship->save();
|
||||||
|
|
||||||
|
return redirect('/dashboard')->with('success', 'SRP Form Submitted.');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Structures;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Auth;
|
|
||||||
use DB;
|
|
||||||
|
|
||||||
use App\Models\Corporation\CorpStructure;
|
|
||||||
use App\Models\Corporation\CorpTaxRatio;
|
|
||||||
use App\Library\Esi\Esi;
|
|
||||||
|
|
||||||
class RegisterStructureController extends Controller
|
|
||||||
{
|
|
||||||
public function __construct() {
|
|
||||||
$this->middleware('auth');
|
|
||||||
$this->middleware('role:User');
|
|
||||||
$this->middleware('permission:structure.operator');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayRegisterStructure() {
|
|
||||||
//Check to see if the user has the read corp journal esi scope before allowing to register a structure
|
|
||||||
if(Auth()->user()->hasEsiScope('esi-wallet.read_corporation_wallets.v1')) {
|
|
||||||
return view('structures.register.register');
|
|
||||||
} else {
|
|
||||||
return view('dashboard')->with('error', 'You need to setup your esi scope for read corporation wallets');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function storeStructure(Request $request) {
|
|
||||||
$this->validate($request, [
|
|
||||||
'system' => 'required',
|
|
||||||
'structure_name' => 'required',
|
|
||||||
'tax' => 'required',
|
|
||||||
'structure_type' => 'required',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$eHelper = new Esi;
|
|
||||||
|
|
||||||
$tax = floatval($request->tax);
|
|
||||||
|
|
||||||
$structure = new CorpStructure();
|
|
||||||
$structure->character_id = Auth::user()->character_id;
|
|
||||||
$structure->corporation_id = $eHelper->FindCorporationId(Auth::user()->character_id);
|
|
||||||
$structure->corporation_name = $eHelper->FindCorporationName(Auth::user()->character_id);
|
|
||||||
$structure->region = $request->region;
|
|
||||||
$structure->system = $request->system;
|
|
||||||
$structure->structure_name = $request->structure_name;
|
|
||||||
$structure->structure_type = $request->structure_type;
|
|
||||||
$structure->save();
|
|
||||||
|
|
||||||
//Return the view and the message of user updated
|
|
||||||
return redirect('/dashboard')->with('success', 'Structure Added to Database');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Structures;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class StructureAdminController extends Controller
|
|
||||||
{
|
|
||||||
public function __construct() {
|
|
||||||
$this->middleware('role:Admin');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayDashboard() {
|
|
||||||
return view('structures.admin.dashboard');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function storeTaxRatio(Request $request) {
|
|
||||||
$this->validate($request, [
|
|
||||||
'corpId',
|
|
||||||
'corporation',
|
|
||||||
'type',
|
|
||||||
'ratio',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$ratio = new CorpTaxRatio;
|
|
||||||
$ratio->corporation_id = $request->corpId;
|
|
||||||
$ratio->corporation_name = $request->corporation;
|
|
||||||
$ratio->structure_type = $request->type;
|
|
||||||
$ratio->ratio = $request->ratio;
|
|
||||||
$ratio->save();
|
|
||||||
|
|
||||||
return redirect('structure.admin.dashboard');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateTaxRatio(Request $request) {
|
|
||||||
$this->validate($request, [
|
|
||||||
'corporation',
|
|
||||||
'type',
|
|
||||||
'ratio',
|
|
||||||
]);
|
|
||||||
|
|
||||||
CorpTaxRatio::where([
|
|
||||||
'corporation_name' => $request->corporation,
|
|
||||||
'structure_type' => $request->type,
|
|
||||||
])->update([
|
|
||||||
'ratio' => $request->ratio,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return redirect('/structure/admin/dashboard')->with('success', 'Tax Ratio updated for structure type: ' . $request->type . ' and corporation: ' . $request->corporation);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayTaxRatios() {
|
|
||||||
$taxRatios = CorpTaxRation::all();
|
|
||||||
|
|
||||||
return view('structure.admin.taxratios')->with('structures', $structures);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Structures;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use DB;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
use App\Library\Structures\StructureTaxHelper;
|
|
||||||
use App\Library\Esi\Esi;
|
|
||||||
use App\Library\Lookups\LookupHelper;
|
|
||||||
|
|
||||||
use App\User;
|
|
||||||
use App\Models\User\UserRole;
|
|
||||||
use App\Models\User\UserPermission;
|
|
||||||
use App\Models\Corporation\CorpStructure;
|
|
||||||
use App\Models\Finances\StructureIndustryTaxJournal;
|
|
||||||
use App\Models\Esi\EsiToken;
|
|
||||||
|
|
||||||
use Seat\Eseye\Containers\EsiAuthentication;
|
|
||||||
use Seat\Eseye\Eseye;
|
|
||||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
|
||||||
|
|
||||||
class StructureController extends Controller
|
|
||||||
{
|
|
||||||
public function __construct() {
|
|
||||||
$this->middleware('auth');
|
|
||||||
$this->middleware('role:User');
|
|
||||||
$this->middleware('permission:structure.operator');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function chooseCorpTaxes() {
|
|
||||||
$this->middleware('role:Admin');
|
|
||||||
|
|
||||||
$corps = CorpStructure::pluck('corporation_name', 'corporation_id');
|
|
||||||
return view('structures.admin.choosecorporation')->with('corps', $corps);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayCorpTaxes(Request $request) {
|
|
||||||
$this->middleware('role:Admin');
|
|
||||||
|
|
||||||
$corpId = $request->corpId;
|
|
||||||
$months = 3;
|
|
||||||
|
|
||||||
//Declare the structure tax helper class
|
|
||||||
$sHelper = new StructureTaxHelper();
|
|
||||||
|
|
||||||
//Get the dates we are working with
|
|
||||||
$dates = $sHelper->GetTimeFrameInMonths($months);
|
|
||||||
|
|
||||||
foreach($dates as $date) {
|
|
||||||
$totalTaxes[] = [
|
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
|
||||||
'tax' => number_format($sHelper->GetTaxes($corpId, 'Market', $date['start'], $date['end']), 2, '.', ','),
|
|
||||||
'revenue' => number_format($sHelper->GetRevenue($corpId, 'Market', $date['start'], $date['end']), 2, '.', ',')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
//Return the view with the data passed to it
|
|
||||||
return view('structures.admin.choosecorptaxes')->with('totalTaxes', $totalTaxes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayTaxes() {
|
|
||||||
//Declare new Lookup helper
|
|
||||||
$helper = new LookupHelper();
|
|
||||||
|
|
||||||
//Declare the structure tax helper class
|
|
||||||
$sHelper = new StructureTaxHelper();
|
|
||||||
|
|
||||||
$months = 3;
|
|
||||||
$totalTaxes = array();
|
|
||||||
|
|
||||||
//Get the character's corporation from the lookup table or esi
|
|
||||||
$corpId = $helper->LookupCharacter(Auth::user()->character_id);
|
|
||||||
|
|
||||||
|
|
||||||
//Get the dates we are working with
|
|
||||||
$dates = $sHelper->GetTimeFrameInMonths($months);
|
|
||||||
|
|
||||||
//Get the market taxes for this month from the database
|
|
||||||
foreach($dates as $date) {
|
|
||||||
$totalTaxes[] = [
|
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
|
||||||
'tax' => number_format($sHelper->GetTaxes($corpId, 'Market', $date['start'], $date['end']), 2, '.', ','),
|
|
||||||
'revenue' => number_format($sHelper->GetRevenue($corpId, 'Market', $date['start'], $date['end']), 2, '.', ',')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('structures.user.taxes')->with('totalTaxes', $totalTaxes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayTaxHistory(Request $request) {
|
|
||||||
//Declare new Lookup helper
|
|
||||||
$helper = new LookupHelper();
|
|
||||||
|
|
||||||
//Get the months from the request
|
|
||||||
$months = $request->months;
|
|
||||||
|
|
||||||
//Get the character's corporation from the lookup table or esi
|
|
||||||
$corpId = $helper->LookupCharacter(Auth::user()->character_id);
|
|
||||||
|
|
||||||
//Declare the structure tax helper class
|
|
||||||
$sHelper = new StructureTaxHelper();
|
|
||||||
|
|
||||||
//Get the dates we are working with
|
|
||||||
$dates = $sHelper->GetTimeFrameInMonths($months);
|
|
||||||
|
|
||||||
//Build the array for displaying the data on the view
|
|
||||||
$totalTaxes = array();
|
|
||||||
|
|
||||||
foreach($dates as $date) {
|
|
||||||
$totalTaxes[] = [
|
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
|
||||||
'tax' => number_format($sHelper->GetTaxes($corpId, 'Market', $date['start'], $date['end']), 2, '.', ','),
|
|
||||||
'revenue' => number_format($sHelper->GetRevenue($corpId, 'Market', $date['start'], $date['end']), 2, '.', ',')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('structures.user.taxhistory')->with(compact('totalTaxes', 'months'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
25
app/Http/Controllers/Test/TestController.php
Normal file
25
app/Http/Controllers/Test/TestController.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Test;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
|
||||||
|
class TestController extends Controller
|
||||||
|
{
|
||||||
|
public function displayCharTest() {
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
$char = $lookup->GetCharacterInfo($config['primary']);
|
||||||
|
|
||||||
|
return view('test.char.display')->with('char', $char);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function CharacterLookupTest(Request $request) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,17 +5,18 @@ namespace App\Http\Controllers\Wiki;
|
|||||||
//Laravel libraries
|
//Laravel libraries
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use DB;
|
|
||||||
use Auth;
|
use Auth;
|
||||||
|
|
||||||
//User Libraries
|
//User Libraries
|
||||||
use App\Library\Lookups\LookupHelper;
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
use App\Library\Wiki\WikiHelper;
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
use App\Models\Doku\DokuGroupNames;
|
use App\Models\Doku\DokuGroupNames;
|
||||||
use App\Models\Doku\DokuMember;
|
use App\Models\Doku\DokuMember;
|
||||||
use App\Models\Doku\DokuUser;
|
use App\Models\Doku\DokuUser;
|
||||||
use App\Models\Admin\AllowedLogin;
|
use App\Models\Admin\AllowedLogin;
|
||||||
|
use App\Models\User\User;
|
||||||
|
|
||||||
class WikiController extends Controller
|
class WikiController extends Controller
|
||||||
{
|
{
|
||||||
@@ -23,32 +24,6 @@ class WikiController extends Controller
|
|||||||
$this->middleware('auth');
|
$this->middleware('auth');
|
||||||
$this->middleware('role:Renter');
|
$this->middleware('role:Renter');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function purgeUsers() {
|
|
||||||
//Declare helper classes
|
|
||||||
$helper = new LookupHelper;
|
|
||||||
|
|
||||||
//Get all the users from the database
|
|
||||||
$users = DokuUser::pluck('name')->all();
|
|
||||||
|
|
||||||
$legacy = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_id')->toArray();
|
|
||||||
$renter = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_id')->toArray();
|
|
||||||
|
|
||||||
//Search the names and verify against the lookup table
|
|
||||||
//to find the corporation and / or alliance they belong to.
|
|
||||||
foreach($users as $user) {
|
|
||||||
$charId = $helper->CharacterNameToId($user);
|
|
||||||
$corpId = $helper->LookupCharacter($charId);
|
|
||||||
$allianceId = $helper->LookupCorporation($corpId);
|
|
||||||
if(in_array($allianceId, $legacy) || in_array($allianceId, $renter) || $allianceId == 99004116) {
|
|
||||||
//Do nothing
|
|
||||||
} else {
|
|
||||||
DokuUser::where(['name' => $user])->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('admin.dashboard')->with('success', 'Wiki has been purged.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayRegister() {
|
public function displayRegister() {
|
||||||
//make user name syntax like we want it.
|
//make user name syntax like we want it.
|
||||||
@@ -57,9 +32,19 @@ class WikiController extends Controller
|
|||||||
$name = str_replace(' ', '_', $name);
|
$name = str_replace(' ', '_', $name);
|
||||||
|
|
||||||
//Check to see if the user is already registered in the database
|
//Check to see if the user is already registered in the database
|
||||||
$check = DB::select('SELECT login FROM wiki_user WHERE login = ?', [$name]);
|
$count = DokuUser::where([
|
||||||
if(isset($check[0]) && ($check[0]->login === $name)) {
|
'login' => $name,
|
||||||
return redirect('/dashboard')->with('error', 'Already registered for the wiki!');
|
])->count();
|
||||||
|
|
||||||
|
//If the count is greater than zero, also check the login name as a reference
|
||||||
|
if($count > 0) {
|
||||||
|
$check = DokuUser::where([
|
||||||
|
'login' => $name,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
if($check->login === $name) {
|
||||||
|
return redirect('/dashboard')->with('error', 'Already registered for the wiki!');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('wiki.user.register')->with('name', $name);
|
return view('wiki.user.register')->with('name', $name);
|
||||||
@@ -82,8 +67,10 @@ class WikiController extends Controller
|
|||||||
|
|
||||||
if(Auth::user()->hasRole('User')) {
|
if(Auth::user()->hasRole('User')) {
|
||||||
$role = 1; //User role id from wiki_groupname table
|
$role = 1; //User role id from wiki_groupname table
|
||||||
|
$roleDescription = 'user';
|
||||||
} else if(Auth::user()->hasRole('Renter')) {
|
} else if(Auth::user()->hasRole('Renter')) {
|
||||||
$role = 8; //Renter role id from wiki_groupname table
|
$role = 8; //Renter role id from wiki_groupname table
|
||||||
|
$roleDescription = 'renter';
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load the model
|
//Load the model
|
||||||
@@ -102,10 +89,16 @@ class WikiController extends Controller
|
|||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
//Get the user from the table to get the uid
|
//Get the user from the table to get the uid
|
||||||
$uid = DB::select('SELECT id FROM wiki_user WHERE login = ?', [$name]);
|
$uid = DokuUser::where([
|
||||||
$member->uid = $uid[0]->id;
|
'login' => $name,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
//Save information in the model
|
||||||
|
$member->uid = $uid->id;
|
||||||
$member->gid = $role;
|
$member->gid = $role;
|
||||||
|
$member->groupname = $roleDescription;
|
||||||
$member->save();
|
$member->save();
|
||||||
|
|
||||||
//Return to the dashboard view
|
//Return to the dashboard view
|
||||||
return redirect('/dashboard')->with('success', 'Registration successful. Your username is: ' . $name);
|
return redirect('/dashboard')->with('success', 'Registration successful. Your username is: ' . $name);
|
||||||
}
|
}
|
||||||
@@ -114,10 +107,15 @@ class WikiController extends Controller
|
|||||||
$name = Auth::user()->name;
|
$name = Auth::user()->name;
|
||||||
$name = strtolower($name);
|
$name = strtolower($name);
|
||||||
$name = str_replace(' ', '_', $name);
|
$name = str_replace(' ', '_', $name);
|
||||||
$check = DB::select('SELECT login FROM wiki_user WHERE login = ?', [$name]);
|
|
||||||
if(!isset($check[0])) {
|
//Get the password
|
||||||
return redirect('/dashboard')->with('error', 'Login Not Found!');
|
$check = DokuUser::where([
|
||||||
}
|
'login' => $name
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
if($check == 0) {
|
||||||
|
return redirect('/dashboard')->with('error', 'Login Not Found');
|
||||||
|
}
|
||||||
|
|
||||||
return view('wiki.user.changepassword')->with('name', $name);
|
return view('wiki.user.changepassword')->with('name', $name);
|
||||||
}
|
}
|
||||||
@@ -141,30 +139,14 @@ class WikiController extends Controller
|
|||||||
$name = Auth::user()->name;
|
$name = Auth::user()->name;
|
||||||
$name = strtolower($name);
|
$name = strtolower($name);
|
||||||
$name = str_replace(' ', '_', $name);
|
$name = str_replace(' ', '_', $name);
|
||||||
|
|
||||||
//Update the password for the login name
|
//Update the password for the login name
|
||||||
DB::table('wiki_user')
|
DokuUser::where([
|
||||||
->where('login', $name)
|
'login' => $name,
|
||||||
->update(['pass' => $password]);
|
])->update([
|
||||||
|
'pass' => $password,
|
||||||
|
]);
|
||||||
|
|
||||||
return redirect('/dashboard')->with('success', 'Password changed successfully. Your username is: ' . $name);
|
return redirect('/dashboard')->with('success', 'Password changed successfully. Your username is: ' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays the page to add a user to a certain group
|
|
||||||
*/
|
|
||||||
public function displayAddUserToGroup() {
|
|
||||||
return view('wiki.displayaddug');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores the modifications to the user to add to a group to give permissions
|
|
||||||
*
|
|
||||||
* @param uid
|
|
||||||
* @param gid
|
|
||||||
* @param gname
|
|
||||||
*/
|
|
||||||
public function storeAddUserToGroup($uid, $gid, $gname) {
|
|
||||||
|
|
||||||
return redirect('/dashboard')->with('success', 'User added to the group: ' . $gid . ' with name of ' . $gname);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
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;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//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::groupBy('type')->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',
|
||||||
|
'system' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Declare some variables
|
||||||
|
$duration = null;
|
||||||
|
|
||||||
|
//Create the stable time for the database
|
||||||
|
if($request->duration == '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->class,
|
||||||
|
'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 = AllianceWormhole::where('created_at', '>=', $dateTime)->get();
|
||||||
|
|
||||||
|
return view('wormholes.display')->with('wormholes', $wormholes);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
|
|
||||||
use Socialite;
|
use Socialite;
|
||||||
use DB;
|
use DB;
|
||||||
use App\User;
|
use App\Models\User\User;
|
||||||
|
|
||||||
use Seat\Eseye\Cache\NullCache;
|
use Seat\Eseye\Cache\NullCache;
|
||||||
use Seat\Eseye\Configuration;
|
use Seat\Eseye\Configuration;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
|
|
||||||
use Socialite;
|
use Socialite;
|
||||||
use DB;
|
use DB;
|
||||||
use App\User;
|
use App\Models\User\User;
|
||||||
|
|
||||||
use Seat\Eseye\Cache\NullCache;
|
use Seat\Eseye\Cache\NullCache;
|
||||||
use Seat\Eseye\Configuration;
|
use Seat\Eseye\Configuration;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Http\Middleware;
|
|||||||
use Closure;
|
use Closure;
|
||||||
|
|
||||||
use App\Models\User\UserRole;
|
use App\Models\User\UserRole;
|
||||||
|
use App\Models\User\AvailableUserRole;
|
||||||
|
|
||||||
class RequireRole
|
class RequireRole
|
||||||
{
|
{
|
||||||
@@ -17,21 +18,17 @@ class RequireRole
|
|||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next, $role)
|
public function handle($request, Closure $next, $role)
|
||||||
{
|
{
|
||||||
$confirmed = false;
|
$ranking = array();
|
||||||
|
$roles = AvailableUserRole::all();
|
||||||
|
|
||||||
$ranking = [
|
foreach($roles as $r) {
|
||||||
'None' => 0,
|
$ranking[$r->role] = $r->rank;
|
||||||
'Guest' => 1,
|
}
|
||||||
'Renter' => 2,
|
|
||||||
'User' => 3,
|
|
||||||
'Admin' => 4,
|
|
||||||
'SuperUser' => 5,
|
|
||||||
];
|
|
||||||
|
|
||||||
$check = UserRole::where('character_id', auth()->user()->character_id)->get(['role']);
|
$check = UserRole::where('character_id', auth()->user()->character_id)->get(['role']);
|
||||||
|
|
||||||
if(!isset($check[0]->role)) {
|
if(!isset($check[0]->role)) {
|
||||||
abort(403, "You don't any roles. You don't belong here.");
|
abort(403, "You don't have any roles. You don't belong here.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($ranking[$check[0]->role] < $ranking[$role]) {
|
if($ranking[$check[0]->role] < $ranking[$role]) {
|
||||||
|
|||||||
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
134
app/Jobs/ProcessSendEveMailJob.php
Normal file
134
app/Jobs/ProcessSendEveMailJob.php
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
<?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;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
use Seat\Eseye\Cache\NullCache;
|
||||||
|
use Seat\Eseye\Configuration;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Esi\EsiScope;
|
||||||
|
use App\Models\Esi\EsiToken;
|
||||||
|
use App\Models\Jobs\JobStatus;
|
||||||
|
use App\Models\Mail\SentMail;
|
||||||
|
use App\Models\Jobs\JobSendEveMail;
|
||||||
|
|
||||||
|
class ProcessSendEveMailJob implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $retries = 3;
|
||||||
|
|
||||||
|
private $sender;
|
||||||
|
private $body;
|
||||||
|
private $recipient;
|
||||||
|
private $recipient_type;
|
||||||
|
private $subject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(JobSendEveMail $mail) {
|
||||||
|
$this->body = $mail->body;
|
||||||
|
$this->recipient = $mail->recipient;
|
||||||
|
$this->recipient_type = $mail->recipient_type;
|
||||||
|
$this->subject = $mail->subject;
|
||||||
|
$this->sender = $mail->sender;
|
||||||
|
|
||||||
|
$this->connection = 'redis';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
* Utilized by using ProcessSendEveMailJob::dispatch($mail);
|
||||||
|
* The model is passed into the dispatch function, then added to the queue
|
||||||
|
* for processing.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare some variables
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Get the esi configuration
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
//Retrieve the token for main character to send mails from
|
||||||
|
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||||
|
|
||||||
|
//Create the ESI authentication container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
|
||||||
|
//Set caching to null
|
||||||
|
$configuration = Configuration::getInstance();
|
||||||
|
$configuration->cache = NullCache::class;
|
||||||
|
|
||||||
|
//Attemp to send the mail
|
||||||
|
try {
|
||||||
|
$esi->setBody([
|
||||||
|
'approved_cost' => 100,
|
||||||
|
'body' => $this->body,
|
||||||
|
'recipients' => [[
|
||||||
|
'recipient_id' => $this->recipient,
|
||||||
|
'recipient_type' => $this->recipient_type,
|
||||||
|
]],
|
||||||
|
'subject' => $this->subject,
|
||||||
|
])->invoke('post', '/characters/{character_id}/mail/', [
|
||||||
|
'character_id'=> $this->sender,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
Log::warning($e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->SaveSentRecord($this->sender, $this->subject, $this->body, $this->recipient, $this->recipient_type);
|
||||||
|
|
||||||
|
$this->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The job failed to process.
|
||||||
|
*
|
||||||
|
* @param Exception $exception
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function failed($exception)
|
||||||
|
{
|
||||||
|
Log::critical($exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
|
||||||
|
$sentmail = new SentMail;
|
||||||
|
$sentmail->sender = $sender;
|
||||||
|
$sentmail->subject = $subject;
|
||||||
|
$sentmail->body = $body;
|
||||||
|
$sentmail->recipient = $recipient;
|
||||||
|
$sentmail->recipient_type = $recipientType;
|
||||||
|
$sentmail->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
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\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Log;
|
||||||
|
|
||||||
//App Library
|
//App Library
|
||||||
use App\Library\Finances\Helper\FinanceHelper;
|
use App\Library\Finances\Helper\FinanceHelper;
|
||||||
@@ -26,7 +27,7 @@ class ProcessWalletJournalJob implements ShouldQueue
|
|||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $timeout = 300;
|
public $timeout = 3600;
|
||||||
|
|
||||||
public $tries = 3;
|
public $tries = 3;
|
||||||
|
|
||||||
@@ -44,8 +45,7 @@ class ProcessWalletJournalJob implements ShouldQueue
|
|||||||
$this->charId = $pwj->charId;
|
$this->charId = $pwj->charId;
|
||||||
$this->page = $pwj->page;
|
$this->page = $pwj->page;
|
||||||
|
|
||||||
$this->delay = 15;
|
$this->connection = 'redis';
|
||||||
$this->connection = 'database';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,6 +75,6 @@ class ProcessWalletJournalJob implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function failed($exception)
|
public function failed($exception)
|
||||||
{
|
{
|
||||||
dd($exception);
|
Log::critical($exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,75 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Jobs;
|
|
||||||
|
|
||||||
//Internal Libraries
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
|
|
||||||
//App Library
|
|
||||||
use App\Library\Finances\Helper\FinanceHelper;
|
|
||||||
use App\Jobs\Library\JobHelper;
|
|
||||||
|
|
||||||
//App Models
|
|
||||||
use App\Models\Jobs\JobProcessWalletTransaction;
|
|
||||||
use App\Models\Jobs\JobError;
|
|
||||||
use App\Models\Jobs\JobStatus;
|
|
||||||
|
|
||||||
class ProcessWalletTransactionJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Timeout in seconds
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $timeout = 300;
|
|
||||||
|
|
||||||
public $tries = 3;
|
|
||||||
|
|
||||||
private $division;
|
|
||||||
private $charId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new job instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct(JobProcessWalletTransaction $pwt)
|
|
||||||
{
|
|
||||||
$this->division = $pwt->division;
|
|
||||||
$this->charId = $pwt->charId;
|
|
||||||
|
|
||||||
$this->connection = 'database';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the job.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//Declare the class variables
|
|
||||||
$finance = new FinanceHelper();
|
|
||||||
|
|
||||||
$finance->GetWalletTransaction($this->division, $this->charId);
|
|
||||||
|
|
||||||
//After the job is completed, delete the job
|
|
||||||
$this->delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The job failed to process
|
|
||||||
*
|
|
||||||
* @param Exception $exception
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function failed($exception) {
|
|
||||||
dd($exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Jobs;
|
|
||||||
|
|
||||||
//Internal Library
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
|
|
||||||
//Seat stuff
|
|
||||||
use Seat\Eseye\Configuration;
|
|
||||||
use Seat\Eseye\Containers\EsiAuthentication;
|
|
||||||
use Seat\Eseye\Eseye;
|
|
||||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
|
||||||
|
|
||||||
//Models
|
|
||||||
use App\Models\Esi\EsiScope;
|
|
||||||
use App\Models\Esi\EsiToken;
|
|
||||||
use App\Models\Mail\EveMail;
|
|
||||||
use App\Models\Jobs\JobError;
|
|
||||||
use App\Models\Jobs\JobStatus;
|
|
||||||
|
|
||||||
class SendEveMailJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Timeout in seconds
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $timeout = 120;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retries
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $retries = 3;
|
|
||||||
|
|
||||||
private $body;
|
|
||||||
private $recipient;
|
|
||||||
private $recipient_type;
|
|
||||||
private $subject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new job instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct(EveMail $mail) {
|
|
||||||
$this->body = $mail->body;
|
|
||||||
$this->recipient = $mail->recipient;
|
|
||||||
$this->recipient_type = $mail->recipient_type;
|
|
||||||
$this->subject = $mail->subject;
|
|
||||||
|
|
||||||
$this->connection = 'database';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the job.
|
|
||||||
* Utilized by using SendEveMailJob::dispatch($mail);
|
|
||||||
* The model is passed into the dispatch function, then added to the queue
|
|
||||||
* for processing.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//Retrieve the token for main character to send mails from
|
|
||||||
$token = EsiToken::where(['character_id'=> 93738489])->get();
|
|
||||||
|
|
||||||
//Create the ESI authentication container
|
|
||||||
$config = config('esi');
|
|
||||||
$authentication = new EsiAuthentication([
|
|
||||||
'client_id' => $config['client_id'],
|
|
||||||
'secret' => $config['secret'],
|
|
||||||
'refresh_token' => $token[0]->refresh_token,
|
|
||||||
]);
|
|
||||||
|
|
||||||
//Setup the Eseye class
|
|
||||||
$esi = new Eseye($authentication);
|
|
||||||
|
|
||||||
//Attemp to send the mail
|
|
||||||
try {
|
|
||||||
$esi->setBody([
|
|
||||||
'approved_cost' => 0,
|
|
||||||
'body' => $this->body,
|
|
||||||
'recipients' => [[
|
|
||||||
'recipient_id' => (int)$this->recipient,
|
|
||||||
'recipient_type' => $this->recipient_type,
|
|
||||||
]],
|
|
||||||
'subject' => $this->subject,
|
|
||||||
])->invoke('post', '/characters/{character_id}/mail/', [
|
|
||||||
'character_id'=> 93738489,
|
|
||||||
]);
|
|
||||||
} catch(RequestFailedException $e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The job failed to process.
|
|
||||||
*
|
|
||||||
* @param Exception $exception
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function failed($exception)
|
|
||||||
{
|
|
||||||
dd($exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
145
app/Library/Assets/AssetHelper.php
Normal file
145
app/Library/Assets/AssetHelper.php
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Library\Assets;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//App Library
|
||||||
|
use App\Jobs\Library\JobHelper;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
|
||||||
|
use App\Models\Jobs\JobProcessAsset;
|
||||||
|
use App\Models\Jobs\JobStatus;
|
||||||
|
use App\Models\Stock\Asset;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
//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);
|
||||||
|
//Setup the esi authentication container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
|
||||||
|
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(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -3,14 +3,15 @@
|
|||||||
namespace App\Library\Esi;
|
namespace App\Library\Esi;
|
||||||
|
|
||||||
//Internal Libraries
|
//Internal Libraries
|
||||||
use DB;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
|
use App\Models\Esi\EsiToken;
|
||||||
use App\Models\Esi\EsiScope;
|
use App\Models\Esi\EsiScope;
|
||||||
use App\Models\Jobs\JobSendEveMail;
|
use App\Models\Jobs\JobSendEveMail;
|
||||||
|
|
||||||
//Jobs
|
//Jobs
|
||||||
use App\Jobs\SendEveMailJob;
|
use App\Jobs\ProcessSendEveMailJob;
|
||||||
|
|
||||||
//Seat Stuff
|
//Seat Stuff
|
||||||
use Seat\Eseye\Cache\NullCache;
|
use Seat\Eseye\Cache\NullCache;
|
||||||
@@ -33,29 +34,30 @@ class Esi {
|
|||||||
* @return true,false
|
* @return true,false
|
||||||
*/
|
*/
|
||||||
public function HaveEsiScope($charId, $scope) {
|
public function HaveEsiScope($charId, $scope) {
|
||||||
|
//Get the esi config
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
//Check for an esi scope
|
//Check for an esi scope
|
||||||
$checks = DB::table('EsiScopes')->where('character_id', $charId)->get();
|
$check = EsiScope::where(['character_id' => $charId, 'scope' => $scope])->count();
|
||||||
foreach($checks as $check) {
|
if($check == 0) {
|
||||||
if($check->scope === $scope) {
|
//Compose a mail to send to the user if the scope is not found
|
||||||
return true;
|
$mail = new JobSendEveMail;
|
||||||
}
|
$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(5);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mail = new EveMail;
|
return true;
|
||||||
$mail->sender = 93738489;
|
|
||||||
$mail->subject = 'W4RP Services - Incorrect ESI Scope';
|
|
||||||
$mail->body = "Please register on https://services.w4rp.space with the scope: " . $scope;
|
|
||||||
$mail->recipient = (int)$charId;
|
|
||||||
$mail->recipient_type = 'character';
|
|
||||||
$mail->save();
|
|
||||||
|
|
||||||
SendEveMailJob::dispatch($mail)->delay(Carbon::now()->addSeconds(5));
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetCharacterData($charId) {
|
public function GetCharacterData($charId) {
|
||||||
$esi = new Eseye();
|
$esi = $this->SetupEsiAuthentication();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||||
'character_id' => $charId,
|
'character_id' => $charId,
|
||||||
@@ -67,8 +69,23 @@ class Esi {
|
|||||||
return $character;
|
return $character;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function GetCorporationData($corpId) {
|
||||||
|
$esi = $this->SetupEsiAuthentication();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$corporation = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||||
|
'corporation_id' => $corpId,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $corporation;
|
||||||
|
}
|
||||||
|
|
||||||
public function GetCharacterName($charId) {
|
public function GetCharacterName($charId) {
|
||||||
$esi = new Eseye();
|
$esi = $this->SetupEsiAuthentication;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||||
'character_id' => $charId,
|
'character_id' => $charId,
|
||||||
@@ -82,32 +99,27 @@ class Esi {
|
|||||||
|
|
||||||
public function FindCharacterId($name) {
|
public function FindCharacterId($name) {
|
||||||
$config = config('esi');
|
$config = config('esi');
|
||||||
//Create the esi authentication container
|
|
||||||
$authentication = new EsiAuthentication([
|
$esi = $this->SetupEsiAuthentication();
|
||||||
'client_id' => $config['client_id'],
|
|
||||||
'secret' => $config['secret'],
|
|
||||||
]);
|
|
||||||
//Create the esi container
|
|
||||||
$esi = new Eseye($authentication);
|
|
||||||
try {
|
try {
|
||||||
$character = $esi->setQueryString([
|
$character = $esi->setBody(array(
|
||||||
'categories' => 'character',
|
$name,
|
||||||
'language' => 'en-us',
|
))->invoke('post', '/universe/ids/');
|
||||||
'search' => $name,
|
|
||||||
'strict' => 'true',
|
|
||||||
])->invoke('get', '/search/');
|
|
||||||
} catch(RequestFailedException $e) {
|
} catch(RequestFailedException $e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$character = json_decode($character, true);
|
if(isset($character->characters[0]->id)) {
|
||||||
|
return $character->characters[0]->id;
|
||||||
return $character['character'];
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function FindCorporationId($charId) {
|
public function FindCorporationId($charId) {
|
||||||
$esi = new Eseye();
|
$esi = $this->SetupEsiAuthentication();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||||
'character_id' => $charId,
|
'character_id' => $charId,
|
||||||
@@ -120,7 +132,8 @@ class Esi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function FindCorporationName($charId) {
|
public function FindCorporationName($charId) {
|
||||||
$esi = new Eseye();
|
$esi = $this->SetupEsiAuthentication();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||||
'character_id' => $charId,
|
'character_id' => $charId,
|
||||||
@@ -151,6 +164,49 @@ class Esi {
|
|||||||
//Return the combined date in the correct format
|
//Return the combined date in the correct format
|
||||||
return $realDate;
|
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;
|
||||||
|
$esi = null;
|
||||||
|
|
||||||
|
if($token == null) {
|
||||||
|
$esi = new Eseye();
|
||||||
|
} else {
|
||||||
|
$authentication = new EsiAuthentication([
|
||||||
|
'client_id' => $config['client_id'],
|
||||||
|
'secret' => $config['secret'],
|
||||||
|
'refresh_token' => $token,
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Setup the esi variable
|
||||||
|
$esi = new Eseye($authentication);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return the created variable
|
||||||
|
return $esi;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Library\Esi;
|
|
||||||
|
|
||||||
use DB;
|
|
||||||
|
|
||||||
use App\Models\Esi\EsiScope;
|
|
||||||
use App\Models\Esi\EsiToken;
|
|
||||||
|
|
||||||
use Seat\Eseye\Cache\NullCache;
|
|
||||||
use Seat\Eseye\Configuration;
|
|
||||||
use Seat\Eseye\Containers\EsiAuthentication;
|
|
||||||
use Seat\Eseye\Eseye;
|
|
||||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
|
||||||
|
|
||||||
class Mail {
|
|
||||||
|
|
||||||
public function SendMail($recipient, $rType, $subject, $body) {
|
|
||||||
//Retrieve the token for main character to send mails from
|
|
||||||
$token = EsiToken::where(['character_id' => 93738489])->first();
|
|
||||||
//Create the ESI authentication container
|
|
||||||
$config = config('esi');
|
|
||||||
$authentication = new EsiAuthentication([
|
|
||||||
'client_id' => $config['client_id'],
|
|
||||||
'secret' => $config['secret'],
|
|
||||||
'refresh_token' => $token->refresh_token,
|
|
||||||
]);
|
|
||||||
$esi = new Eseye($authentication);
|
|
||||||
try {
|
|
||||||
$esi->setBody([
|
|
||||||
'approved_cost' => 0,
|
|
||||||
'body' => $body,
|
|
||||||
'recipients' => [[
|
|
||||||
'recipient_id' => (int)$recipient,
|
|
||||||
'recipient_type' => $rType,
|
|
||||||
]],
|
|
||||||
'subject' => $subject,
|
|
||||||
])->invoke('post', '/characters/{character_id}/mail/', [
|
|
||||||
'character_id'=> 93738489,
|
|
||||||
]);
|
|
||||||
} catch(RequestFailedException $e) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
71
app/Library/Finances/AllianceMarketTax.php
Normal file
71
app/Library/Finances/AllianceMarketTax.php
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* W4RP Services
|
||||||
|
* GNU Public License
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Library\Finances;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Finances\AllianceMarketJournal;
|
||||||
|
|
||||||
|
class AllianceMarketTax {
|
||||||
|
public function EntryExists($journal) {
|
||||||
|
if(AllianceMarketJournal::where(['id' => $journal['id']])->exists()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function InsertMarketTax($journal, $corpId, $division) {
|
||||||
|
//Create the ESI Helper class
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -8,18 +8,19 @@
|
|||||||
namespace App\Library\Finances\Helper;
|
namespace App\Library\Finances\Helper;
|
||||||
|
|
||||||
//Internal Library
|
//Internal Library
|
||||||
use DB;
|
use Log;
|
||||||
|
|
||||||
//Job
|
//Job
|
||||||
use App\Jobs\SendEveMailJob;
|
use App\Jobs\ProcessSendEveMailJob;
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
use App\Models\Esi\EsiToken;
|
use App\Models\Esi\EsiToken;
|
||||||
use App\Models\Esi\EsiScope;
|
use App\Models\Esi\EsiScope;
|
||||||
use App\Models\Mail\EveMail;
|
|
||||||
|
|
||||||
//Library
|
//Library
|
||||||
use App\Library\Esi\Esi;
|
use App\Library\Esi\Esi;
|
||||||
|
use App\Library\Finances\AllianceMarketTax;
|
||||||
|
use App\Library\Finances\CorpMarketTax;
|
||||||
use App\Library\Finances\MarketTax;
|
use App\Library\Finances\MarketTax;
|
||||||
use App\Library\Finances\PlayerDonation;
|
use App\Library\Finances\PlayerDonation;
|
||||||
use App\Library\Finances\ReprocessingTax;
|
use App\Library\Finances\ReprocessingTax;
|
||||||
@@ -29,71 +30,15 @@ use App\Library\Finances\OfficeFee;
|
|||||||
use App\Library\Finances\PlanetProductionTax;
|
use App\Library\Finances\PlanetProductionTax;
|
||||||
use App\Library\Finances\PISale;
|
use App\Library\Finances\PISale;
|
||||||
use App\Library\Lookups\LookupHelper;
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
use App\Library\Finances\SovBillExpenses;
|
||||||
|
|
||||||
//Seat Stuff
|
//Seat Stuff
|
||||||
use Seat\Eseye\Containers\EsiAuthentication;
|
|
||||||
use Seat\Eseye\Eseye;
|
|
||||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
use Seat\Eseye\Cache\NullCache;
|
||||||
|
use Seat\Eseye\Configuration;
|
||||||
|
|
||||||
class FinanceHelper {
|
class FinanceHelper {
|
||||||
|
|
||||||
public function GetWalletTransaction($division, $charId) {
|
|
||||||
//Declare the lookup class helper
|
|
||||||
$lookups = new LookupHelper;
|
|
||||||
|
|
||||||
//Setup array for PI items
|
|
||||||
$pi_items = $this->GetPIMaterialsArray();
|
|
||||||
|
|
||||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
|
||||||
$tokenData = $this->TokenInfo($charId);
|
|
||||||
$token = $tokenData['token'];
|
|
||||||
$scope = $tokenData['scope'];
|
|
||||||
|
|
||||||
//If the token is not found, send the user an eve mail, and just exit out of the function
|
|
||||||
if($this->TokenNotFound($token, $scope, $charId)) {
|
|
||||||
printr("Token not found\n");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Reference to see if the character is in our look up table for corporations and characters
|
|
||||||
$corpId = $lookups->LookupCharacter($charId);
|
|
||||||
|
|
||||||
//Create an ESI authentication container
|
|
||||||
$config = config('esi');
|
|
||||||
$authentication = new EsiAuthentication([
|
|
||||||
'client_id' => $config['client_id'],
|
|
||||||
'secret' => $config['secret'],
|
|
||||||
'refresh_token' => $token[0]->refresh_token,
|
|
||||||
]);
|
|
||||||
|
|
||||||
//Create the esi class varialble
|
|
||||||
$esi = new Eseye($authentication);
|
|
||||||
|
|
||||||
//Get the entries of the journal for transactions
|
|
||||||
try {
|
|
||||||
$journals = $esi->invoke('get', '/corporations/{corporation_id}/wallets/{division}/transactions/', [
|
|
||||||
'corporation_id' => 98251577,
|
|
||||||
'division' => 3,
|
|
||||||
]);
|
|
||||||
} catch(RequestFailedException $e) {
|
|
||||||
return $e->getEsiResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Decode the wallet from json into an array
|
|
||||||
$wallet = json_decode($journals->raw, true);
|
|
||||||
|
|
||||||
//For each transactional entry, attempt to store it in the database.
|
|
||||||
//The PutWalletJournal function checks to see if it's already in the database.
|
|
||||||
foreach($wallet as $entry) {
|
|
||||||
if($division == 3 && $charId == 94415555) {
|
|
||||||
if(in_array($entry['type_id'], $pi_items, false)) {
|
|
||||||
$pi = new PISale();
|
|
||||||
$pi->InsertPISale($entry, 98287666);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetWalletJournal($division, $charId) {
|
public function GetWalletJournal($division, $charId) {
|
||||||
//Declare new class variables
|
//Declare new class variables
|
||||||
$market = new MarketTax();
|
$market = new MarketTax();
|
||||||
@@ -102,34 +47,33 @@ class FinanceHelper {
|
|||||||
$other = new PlayerDonation();
|
$other = new PlayerDonation();
|
||||||
$industry = new StructureIndustryTax();
|
$industry = new StructureIndustryTax();
|
||||||
$office = new OfficeFee();
|
$office = new OfficeFee();
|
||||||
|
$esiHelper = new Esi();
|
||||||
|
$sovBillHelper = new SovBillExpenses();
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
|
||||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||||
$tokenData = $this->TokenInfo($charId);
|
$hasScope = $esiHelper->HaveEsiScope($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||||
$token = $tokenData['token'];
|
if($hasScope == false) {
|
||||||
$scope = $tokenData['scope'];
|
Log::critical('Scope check failed for esi-wallet.read_corporation_wallets.v1 for character id: ' . $charId);
|
||||||
|
|
||||||
//Declare the lookup class helper
|
|
||||||
$lookups = new LookupHelper;
|
|
||||||
|
|
||||||
//If the token is not found, send the user an eve mail, and just exit out of the function
|
|
||||||
if($this->TokenNotFound($token, $scope, $charId)) {
|
|
||||||
return null;
|
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
|
//Reference to see if the character is in our look up table for corporations and characters
|
||||||
$corpId = $lookups->LookupCharacter($charId);
|
$char = $lookup->GetCharacterInfo($charId);
|
||||||
|
$corpId = $char->corporation_id;
|
||||||
|
|
||||||
//Create an ESI authentication container
|
//Create an ESI authentication container
|
||||||
$config = config('esi');
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
$authentication = new EsiAuthentication([
|
//Set the version
|
||||||
'client_id' => $config['client_id'],
|
|
||||||
'secret' => $config['secret'],
|
|
||||||
'refresh_token' => $token[0]->refresh_token,
|
|
||||||
]);
|
|
||||||
|
|
||||||
//Create the esi class varialble
|
|
||||||
$esi = new Eseye($authentication);
|
|
||||||
$esi->setVersion('v4');
|
$esi->setVersion('v4');
|
||||||
|
|
||||||
|
//Set caching to null
|
||||||
|
$configuration = Configuration::getInstance();
|
||||||
|
$configuration->cache = NullCache::class;
|
||||||
|
|
||||||
//Set our current page to 1 which is the one we are starting on.
|
//Set our current page to 1 which is the one we are starting on.
|
||||||
$currentPage = 1;
|
$currentPage = 1;
|
||||||
@@ -147,31 +91,34 @@ class FinanceHelper {
|
|||||||
'division' => $division,
|
'division' => $division,
|
||||||
]);
|
]);
|
||||||
} catch(RequestFailedException $e) {
|
} catch(RequestFailedException $e) {
|
||||||
return $e->getEsiResponse();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set the total pages we need to cycle through.
|
if($currentPage == 1) {
|
||||||
$totalPages = $journals->pages;
|
//Set the total pages we need to cycle through.
|
||||||
|
$totalPages = $journals->pages;
|
||||||
|
}
|
||||||
|
|
||||||
//Decode the wallet from json into an array
|
//Decode the wallet from json into an array
|
||||||
$wallet = json_decode($journals->raw, true);
|
$wallet = json_decode($journals->raw, true);
|
||||||
//For each journal entry, attempt to store it in the database.
|
//For each journal entry, attempt to store it in the database.
|
||||||
//The PutWalletJournal function checks to see if it's already in the database.
|
//The PutWalletJournal function checks to see if it's already in the database.
|
||||||
foreach($wallet as $entry) {
|
foreach($wallet as $entry) {
|
||||||
if($entry['amount'] > 0) {
|
if($entry['ref_type'] == 'brokers_fee') {
|
||||||
if($entry['ref_type'] == 'brokers_fee') {
|
$market->InsertMarketTax($entry, $corpId, $division);
|
||||||
$market->InsertMarketTax($entry, $corpId, $division);
|
} else if($entry['ref_type'] == 'reprocessing_tax') {
|
||||||
} else if($entry['ref_type'] == 'reprocessing_tax') {
|
$reprocessing->InsertReprocessingTax($entry, $corpId, $division);
|
||||||
$reprocessing->InsertReprocessingTax($entry, $corpId, $division);
|
} else if($entry['ref_type'] == 'structure_gate_jump') {
|
||||||
} else if($entry['ref_type'] == 'structure_gate_jump') {
|
$jb->InsertJumpBridgeTax($entry, $corpId, $division);
|
||||||
$jb->InsertJumpBridgeTax($entry, $corpId, $division);
|
} else if($entry['ref_type'] == 'player_donation' ||
|
||||||
} else if($entry['ref_type'] == 'player_donation' ||
|
($entry['ref_type'] == 'corporation_account_withdrawal' && $entry['second_party_id'] == 98287666)) {
|
||||||
($entry['ref_type'] == 'corporation_account_withdrawal' && $entry['second_party_id'] == 98287666)) {
|
$other->InsertPlayerDonation($entry, $corpId, $division);
|
||||||
$other->InsertPlayerDonation($entry, $corpId, $division);
|
} else if($entry['ref_type'] == 'industry_job_tax' && $entry['second_party_id'] == 98287666) {
|
||||||
} else if($entry['ref_type'] == 'industry_job_tax' && $entry['second_party_id'] == 98287666) {
|
$industry->InsertStructureIndustryTax($entry, $corpId, $division);
|
||||||
$industry->InsertStructureIndustryTax($entry, $corpId, $division);
|
} else if($entry['ref_type'] == 'office_rental_fee' && $entry['second_party_id'] == 98287666) {
|
||||||
} else if($entry['ref_type'] == 'office_rental_fee' && $entry['second_party_id'] == 98287666) {
|
$office->InsertOfficeFee($entry, $corpId, $division);
|
||||||
$office->InsertOfficeFee($entry, $corpId, $division);
|
} else if($entry['ref_type'] == 'infrastructure_hub_maintenance' && $entry['first_party_id'] == 98287666) {
|
||||||
}
|
$sovBillHelper->InsertSovBillExpense($entry, $corpId, $division);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,32 +130,34 @@ class FinanceHelper {
|
|||||||
|
|
||||||
public function GetJournalPageCount($division, $charId) {
|
public function GetJournalPageCount($division, $charId) {
|
||||||
//Declare class variables
|
//Declare class variables
|
||||||
$lookups = new LookupHelper;
|
$lookup = new LookupHelper;
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
//Get the ESI refresh token for the corporation
|
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||||
$tokenData = $this->TokenInfo($charId);
|
$hasScope = $esiHelper->HaveEsiScope($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||||
$token = $tokenData['token'];
|
if($hasScope == false) {
|
||||||
$scope = $tokenData['scope'];
|
Log::critical('Esi Scope check failed for esi-wallet.read_corporation_wallets.v1 for character id: ' . $charId);
|
||||||
|
return null;
|
||||||
if($this->TokenNotFound($token, $scope, $charId)) {
|
}
|
||||||
|
$token = $esiHelper->GetRefreshToken($charId);
|
||||||
|
if($token == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Refrence to see if the character is in our look up table for corporation and characters
|
//Refrence to see if the character is in our look up table for corporation and characters
|
||||||
$corpId = $lookups->LookupCharacter($charId);
|
$char = $lookup->GetCharacterInfo($charId);
|
||||||
|
$corpId = $char->corporation_id;
|
||||||
|
|
||||||
//Create the ESI authentication container
|
//Create the ESI authentication container
|
||||||
$config = config('esi');
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
$authentication = new EsiAuthentication([
|
|
||||||
'client_id' => $config['client_id'],
|
|
||||||
'secret' => $config['secret'],
|
|
||||||
'refresh_token' => $token[0]->refresh_token,
|
|
||||||
]);
|
|
||||||
|
|
||||||
//Create the esi class variable
|
//Set the esi version to v4
|
||||||
$esi = new Eseye($authentication);
|
|
||||||
$esi->setVersion('v4');
|
$esi->setVersion('v4');
|
||||||
|
|
||||||
|
//Set caching to null
|
||||||
|
$configuration = Configuration::getInstance();
|
||||||
|
$configuration->cache = NullCache::class;
|
||||||
|
|
||||||
//Call the first page so we can get the header data for the number of pages
|
//Call the first page so we can get the header data for the number of pages
|
||||||
try {
|
try {
|
||||||
$journals = $esi->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
$journals = $esi->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||||
@@ -216,7 +165,8 @@ class FinanceHelper {
|
|||||||
'division' => $division,
|
'division' => $division,
|
||||||
]);
|
]);
|
||||||
} catch(RequestFailedException $e) {
|
} catch(RequestFailedException $e) {
|
||||||
return $e->getEsiResponse();
|
Log::warning($e->getEsiResponse());
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pages = $journals->pages;
|
$pages = $journals->pages;
|
||||||
@@ -224,38 +174,83 @@ class FinanceHelper {
|
|||||||
return $pages;
|
return $pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetWalletJournalPage($division, $charId, $page = 1) {
|
public function GetCorpWalletJournalPage($division, $charId, $corpId, $page = 1) {
|
||||||
//Declare new class variables
|
//Declare new class variables
|
||||||
$market = new MarketTax();
|
$corpMarket = new MarketTax();
|
||||||
$reprocessing = new ReprocessingTax();
|
$esiHelper = new Esi;
|
||||||
$jb = new JumpBridgeTax();
|
|
||||||
$other = new PlayerDonation();
|
|
||||||
$industry = new StructureIndustryTax();
|
|
||||||
$office = new OfficeFee();
|
|
||||||
|
|
||||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||||
$tokenData = $this->TokenInfo($charId);
|
$token = $esiHelper->GetRefreshToken($charId);
|
||||||
$token = $tokenData['token'];
|
|
||||||
$scope = $tokenData['scope'];
|
|
||||||
|
|
||||||
//Declare the lookup class helper
|
//Setup the esi authentication container
|
||||||
$lookups = new LookupHelper;
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
$esi->setVersion('v4');
|
||||||
|
|
||||||
|
//Set caching to null
|
||||||
|
$configuration = Configuration::getInstance();
|
||||||
|
$configuration->cache = NullCache::class;
|
||||||
|
|
||||||
|
//Call the page of the wallet journal
|
||||||
|
try {
|
||||||
|
$journals = $esi->page($page)
|
||||||
|
->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;
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$sovBill = new SovBillExpenses;
|
||||||
|
|
||||||
|
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||||
|
$hasScope = $esiHelper->HaveEsiScope($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||||
|
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
|
//Reference to see if the character is in our look up table for corporations and characters
|
||||||
$corpId = $lookups->LookupCorporationId($charId);
|
$char = $lookup->GetCharacterInfo($charId);
|
||||||
|
$corpId = $char->corporation_id;
|
||||||
|
|
||||||
//Create an ESI authentication container
|
//Create an ESI authentication container
|
||||||
$config = config('esi');
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
$authentication = new EsiAuthentication([
|
|
||||||
'client_id' => $config['client_id'],
|
|
||||||
'secret' => $config['secret'],
|
|
||||||
'refresh_token' => $token[0]->refresh_token,
|
|
||||||
]);
|
|
||||||
|
|
||||||
//Create the esi class varialble
|
|
||||||
$esi = new Eseye($authentication);
|
|
||||||
$esi->setVersion('v4');
|
$esi->setVersion('v4');
|
||||||
|
|
||||||
|
//Set caching to null
|
||||||
|
$configuration = Configuration::getInstance();
|
||||||
|
$configuration->cache = NullCache::class;
|
||||||
|
|
||||||
//Call the first page of the wallet journal, as we are always going to get at least one page.
|
//Call the first page of the wallet journal, as we are always going to get at least one page.
|
||||||
//If we have more pages, then we will continue through the while loop.
|
//If we have more pages, then we will continue through the while loop.
|
||||||
try {
|
try {
|
||||||
@@ -265,7 +260,7 @@ class FinanceHelper {
|
|||||||
'division' => $division,
|
'division' => $division,
|
||||||
]);
|
]);
|
||||||
} catch(RequestFailedException $e) {
|
} catch(RequestFailedException $e) {
|
||||||
return $e->getEsiResponse();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Decode the wallet from json into an array
|
//Decode the wallet from json into an array
|
||||||
@@ -273,58 +268,27 @@ class FinanceHelper {
|
|||||||
//For each journal entry, attempt to store it in the database.
|
//For each journal entry, attempt to store it in the database.
|
||||||
//The PutWalletJournal function checks to see if it's already in the database.
|
//The PutWalletJournal function checks to see if it's already in the database.
|
||||||
foreach($wallet as $entry) {
|
foreach($wallet as $entry) {
|
||||||
if($entry['amount'] > 0) {
|
if($entry['ref_type'] == 'brokers_fee') {
|
||||||
if($entry['ref_type'] == 'brokers_fee') {
|
$market->InsertMarketTax($entry, $corpId, $division);
|
||||||
$market->InsertMarketTax($entry, $corpId, $division);
|
} else if($entry['ref_type'] == 'reprocessing_tax') {
|
||||||
} else if($entry['ref_type'] == 'reprocessing_tax') {
|
$reprocessing->InsertReprocessingTax($entry, $corpId, $division);
|
||||||
$reprocessing->InsertReprocessingTax($entry, $corpId, $division);
|
} else if($entry['ref_type'] == 'structure_gate_jump') {
|
||||||
} else if($entry['ref_type'] == 'structure_gate_jump') {
|
$jb->InsertJumpBridgeTax($entry, $corpId, $division);
|
||||||
$jb->InsertJumpBridgeTax($entry, $corpId, $division);
|
} else if($entry['ref_type'] == 'player_donation' ||
|
||||||
} else if($entry['ref_type'] == 'player_donation' ||
|
($entry['ref_type'] == 'corporation_account_withdrawal' && $entry['second_party_id'] == 98287666)) {
|
||||||
($entry['ref_type'] == 'corporation_account_withdrawal' && $entry['second_party_id'] == 98287666)) {
|
$other->InsertPlayerDonation($entry, $corpId, $division);
|
||||||
$other->InsertPlayerDonation($entry, $corpId, $division);
|
} else if($entry['ref_type'] == 'industry_job_tax' && $entry['second_party_id'] == 98287666) {
|
||||||
} else if($entry['ref_type'] == 'industry_job_tax' && $entry['second_party_id'] == 98287666) {
|
$industry->InsertStructureIndustryTax($entry, $corpId, $division);
|
||||||
$industry->InsertStructureIndustryTax($entry, $corpId, $division);
|
} else if($entry['ref_type'] == 'office_rental_fee' && $entry['second_party_id'] == 98287666) {
|
||||||
} else if($entry['ref_type'] == 'office_rental_fee' && $entry['second_party_id'] == 98287666) {
|
$office->InsertOfficeFee($entry, $corpId, $division);
|
||||||
$office->InsertOfficeFee($entry, $corpId, $division);
|
} else if($entry['ref_type'] == 'planetary_export_tax' || $entry['ref_type'] == 'planetary_import_tax') {
|
||||||
}
|
$pi->InsertPlanetProductionTax($entry, $corpId, $division);
|
||||||
|
} else if($entry['ref_type'] == 'infrastructure_hub_maintenance' && $entry['first_party_id'] == 98287666) {
|
||||||
|
$sovBill->InsertSovBillExpense($entry, $corpId, $division);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
private function GetPIMaterialsArray() {
|
||||||
//Setup array for PI items
|
//Setup array for PI items
|
||||||
$pi_items = [
|
$pi_items = [
|
||||||
|
|||||||
@@ -6,13 +6,15 @@
|
|||||||
|
|
||||||
namespace App\Library\Finances;
|
namespace App\Library\Finances;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
use DB;
|
use DB;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Library
|
||||||
use App\Library\Esi\Esi;
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
|
//Models
|
||||||
use App\Models\Finances\JumpBridgeJournal;
|
use App\Models\Finances\JumpBridgeJournal;
|
||||||
use App\Models\User\UserToCorporation;
|
|
||||||
|
|
||||||
class JumpBridgeTax {
|
class JumpBridgeTax {
|
||||||
private $date;
|
private $date;
|
||||||
@@ -76,55 +78,6 @@ class JumpBridgeTax {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to get the corporations using the jump bridge over a given time period
|
|
||||||
*/
|
|
||||||
public function CorporationUsage() {
|
|
||||||
//Make an array for corporations, and amounts
|
|
||||||
$amounts = array();
|
|
||||||
$characters = array();
|
|
||||||
$data = array();
|
|
||||||
$esi = new Esi();
|
|
||||||
|
|
||||||
//Get all of the parties which have utilized the jump bridge
|
|
||||||
$parties = DB::table('jump_bridge_journal')
|
|
||||||
->select('first_party_id')
|
|
||||||
->groupBy('first_party_id')
|
|
||||||
->whereTime('date', '>', $this->date)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
//Run through each party and assign them into a corporation, then add the corporation to the corporation array if they don't
|
|
||||||
//exist in the array.
|
|
||||||
foreach($parties as $party) {
|
|
||||||
//If the entry in the database lookup table isn't found, add it.
|
|
||||||
if(!CharacterToCorporation::where(['character_id' => $party->first_party_id])->exists()) {
|
|
||||||
$character = $esi->GetCharacterData($party->first_party_id);
|
|
||||||
$corporation = $esi->GetCorporationData($character->corporation_id);
|
|
||||||
$char = new CharacterToCorporation;
|
|
||||||
$char->character_id = $party->first_party_id;
|
|
||||||
$char->character_name = $character->name;
|
|
||||||
$char->corporation_id = $character->corporation_id;
|
|
||||||
$char->corporation_name = $corporation->name;
|
|
||||||
$char->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Perform the lookup and add the user into the corps array, and the ammount to the amount array
|
|
||||||
$char = CharacterToCorporation::where(['character_id' => $party->first_party_id])->get();
|
|
||||||
|
|
||||||
//Find the amount utilized from the jump bridge by the character
|
|
||||||
$isk = JumpBridgeJournal::where(['first_party_id' => $char->character_id])
|
|
||||||
->whereBetween('date', [$this->date, $this->date->addDays(30)])
|
|
||||||
->sum('amount');
|
|
||||||
|
|
||||||
//We have the character and isk amount, so we need to build an array with these two values as key value pairs.
|
|
||||||
$data[$char->corporation_name] = $data[$char->corporation_name] + $isk;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Return the data
|
|
||||||
return $data;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the overall usage for statistics
|
* Returns the overall usage for statistics
|
||||||
*/
|
*/
|
||||||
@@ -143,6 +96,7 @@ class JumpBridgeTax {
|
|||||||
* Returns a specific briddge usage statistics for overall usage
|
* Returns a specific briddge usage statistics for overall usage
|
||||||
*/
|
*/
|
||||||
public function JBOverallUsage($structure) {
|
public function JBOverallUsage($structure) {
|
||||||
|
|
||||||
$usage = DB::table('jump_bridge_journal')
|
$usage = DB::table('jump_bridge_journal')
|
||||||
->select('amount')
|
->select('amount')
|
||||||
->where('context_id', $structure)
|
->where('context_id', $structure)
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* W4RP Services
|
|
||||||
* GNU Public License
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Library\Finances;
|
|
||||||
|
|
||||||
use DB;
|
|
||||||
|
|
||||||
use App\Library\Esi\Esi;
|
|
||||||
|
|
||||||
use App\Models\Finances\CorpMarketJournal;
|
|
||||||
|
|
||||||
class MarketTax {
|
|
||||||
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(!CorpMarketJournal::where(['id' => $journal['id']])->exists()) {
|
|
||||||
$entry = new CorpMarketJournal;
|
|
||||||
$entry->id = $journal['id'];
|
|
||||||
$entry->corporation_id = $corpId;
|
|
||||||
$entry->division = $division;
|
|
||||||
if(isset($journal['amount'])) {
|
|
||||||
$entry->amount = $journal['amount'];
|
|
||||||
}
|
|
||||||
if(isset($journal['balance'])) {
|
|
||||||
$entry->balance = $journal['balance'];
|
|
||||||
}
|
|
||||||
if(isset($journal['context_id'])) {
|
|
||||||
$entry->context_id = $journal['context_id'];
|
|
||||||
}
|
|
||||||
if(isset($journal['context_id_type'])) {
|
|
||||||
$entry->context_id_type = $journal['context_id_type'];
|
|
||||||
}
|
|
||||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
|
||||||
$entry->description = $journal['description'];
|
|
||||||
if(isset($journal['first_party_id'])) {
|
|
||||||
$entry->first_party_id = $journal['first_party_id'];
|
|
||||||
}
|
|
||||||
if(isset($journal['reason'])) {
|
|
||||||
$entry->reason = $journal['reason'];
|
|
||||||
}
|
|
||||||
$entry->ref_type = $journal['ref_type'];
|
|
||||||
if(isset($journal['second_party_id'])) {
|
|
||||||
$entry->second_party_id = $journal['second_party_id'];
|
|
||||||
}
|
|
||||||
if(isset($journal['tax'])) {
|
|
||||||
$entry->tax = $journal['tax'];
|
|
||||||
}
|
|
||||||
if(isset($journal['tax_receiver_id'])) {
|
|
||||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
|
||||||
}
|
|
||||||
$entry->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -7,10 +7,10 @@
|
|||||||
|
|
||||||
namespace App\Library\Finances;
|
namespace App\Library\Finances;
|
||||||
|
|
||||||
use DB;
|
//Library
|
||||||
|
|
||||||
use App\Library\Esi\Esi;
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
|
//Models
|
||||||
use App\Models\Finances\OfficeFeesJournal;
|
use App\Models\Finances\OfficeFeesJournal;
|
||||||
|
|
||||||
class OfficeFee {
|
class OfficeFee {
|
||||||
|
|||||||
@@ -5,22 +5,20 @@
|
|||||||
* GNU Public License
|
* GNU Public License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace App\Library\Finances;
|
namespace App\Library\Finances;
|
||||||
|
|
||||||
use DB;
|
//Library
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
use App\Library\Esi\Esi;
|
//Models
|
||||||
|
use App\Models\Finances\PISaleJournal;
|
||||||
|
|
||||||
use App\Models\Finances\PISaleJournal;
|
class PISale {
|
||||||
|
|
||||||
class PISale {
|
|
||||||
|
|
||||||
public function InsertPISale($journal, $corpId) {
|
public function InsertPISale($journal, $corpId) {
|
||||||
//Create the ESI Helper class
|
//Create the ESI Helper class
|
||||||
$esiHelper = new Esi;
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
//dd($journal);
|
|
||||||
|
|
||||||
//Insert the PI Sale into the database
|
//Insert the PI Sale into the database
|
||||||
if(!PISaleJournal::where(['journal_ref_id' => $journal['journal_ref_id']])->exists()) {
|
if(!PISaleJournal::where(['journal_ref_id' => $journal['journal_ref_id']])->exists()) {
|
||||||
$entry = new PISaleJournal;
|
$entry = new PISaleJournal;
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
|
|
||||||
namespace App\Library\Finances;
|
namespace App\Library\Finances;
|
||||||
|
|
||||||
use DB;
|
//Library
|
||||||
|
|
||||||
use App\Library\Esi\Esi;
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
|
//Models
|
||||||
use App\Models\Finances\PlanetProductionTaxJournal;
|
use App\Models\Finances\PlanetProductionTaxJournal;
|
||||||
|
|
||||||
class PlanetProductionTax {
|
class PlanetProductionTax {
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
|
|
||||||
namespace App\Library\Finances;
|
namespace App\Library\Finances;
|
||||||
|
|
||||||
use DB;
|
//Library
|
||||||
|
|
||||||
use App\Library\Esi\Esi;
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
|
//Models
|
||||||
use App\Models\Finances\PlayerDonationJournal;
|
use App\Models\Finances\PlayerDonationJournal;
|
||||||
|
|
||||||
class PlayerDonation {
|
class PlayerDonation {
|
||||||
|
|||||||
@@ -7,9 +7,10 @@
|
|||||||
|
|
||||||
namespace App\Library\Finances;
|
namespace App\Library\Finances;
|
||||||
|
|
||||||
use DB;
|
//Library
|
||||||
use App\Library\Esi\Esi;
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
|
//Models
|
||||||
use App\Models\Finances\ReprocessingTaxJournal;
|
use App\Models\Finances\ReprocessingTaxJournal;
|
||||||
|
|
||||||
class ReprocessingTax {
|
class ReprocessingTax {
|
||||||
|
|||||||
63
app/Library/Finances/SovBillExpenses.php
Normal file
63
app/Library/Finances/SovBillExpenses.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* W4RP Services
|
||||||
|
* GNU Public License
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Library\Finances;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Finances\SovBillJournal;
|
||||||
|
|
||||||
|
class SovBillExpenses {
|
||||||
|
public function InsertSovBillExpense($journal, $corpId, $division) {
|
||||||
|
//Create the ESI Helper class
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Check to see if we can find the entry in the database already.
|
||||||
|
//If we don't then add it to the database
|
||||||
|
if(!SovBillJournal::where(['id' => $journal['id']])->exists()) {
|
||||||
|
$entry = new SovBillJournal;
|
||||||
|
$entry->id = $journal['id'];
|
||||||
|
$entry->corporation_id = $corpId;
|
||||||
|
$entry->division = $division;
|
||||||
|
if(isset($journal['amount'])) {
|
||||||
|
$entry->amount = $journal['amount'];
|
||||||
|
}
|
||||||
|
if(isset($journal['balance'])) {
|
||||||
|
$entry->balance = $journal['balance'];
|
||||||
|
}
|
||||||
|
if(isset($journal['context_id'])) {
|
||||||
|
$entry->context_id = $journal['context_id'];
|
||||||
|
}
|
||||||
|
if(isset($journal['context_id_type'])) {
|
||||||
|
$entry->context_id_type = $journal['context_id_type'];
|
||||||
|
}
|
||||||
|
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||||
|
$entry->description = $journal['description'];
|
||||||
|
if(isset($journal['first_party_id'])) {
|
||||||
|
$entry->first_party_id = $journal['first_party_id'];
|
||||||
|
}
|
||||||
|
if(isset($journal['reason'])) {
|
||||||
|
$entry->reason = $journal['reason'];
|
||||||
|
}
|
||||||
|
$entry->ref_type = $journal['ref_type'];
|
||||||
|
if(isset($journal['second_party_id'])) {
|
||||||
|
$entry->second_party_id = $journal['second_party_id'];
|
||||||
|
}
|
||||||
|
if(isset($journal['tax'])) {
|
||||||
|
$entry->tax = $journal['tax'];
|
||||||
|
}
|
||||||
|
if(isset($journal['tax_receiver_id'])) {
|
||||||
|
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||||
|
}
|
||||||
|
$entry->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -7,9 +7,10 @@
|
|||||||
|
|
||||||
namespace App\Library\Finances;
|
namespace App\Library\Finances;
|
||||||
|
|
||||||
use DB;
|
//Library
|
||||||
use App\Library\Esi\Esi;
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
|
//Models
|
||||||
use App\Models\Finances\StructureIndustryTaxJournal;
|
use App\Models\Finances\StructureIndustryTaxJournal;
|
||||||
|
|
||||||
class StructureIndustryTax {
|
class StructureIndustryTax {
|
||||||
|
|||||||
67
app/Library/Fleets/FleetHelper.php
Normal file
67
app/Library/Fleets/FleetHelper.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Library\Fleets;
|
||||||
|
|
||||||
|
//Internal Libraries
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//Seat Stuff
|
||||||
|
use Seat\Eseye\Cache\NullCache;
|
||||||
|
use Seat\Eseye\Configuration;
|
||||||
|
use Seat\Eseye\Containers\EsiAuthentication;
|
||||||
|
use Seat\Eseye\Eseye;
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
|
||||||
|
//Libraries
|
||||||
|
use App\library\Esi\Esi;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Fleets\AllianceFleet;
|
||||||
|
use App\Models\Fleets\AllianceFleetMember;
|
||||||
|
|
||||||
|
class FleetHelper {
|
||||||
|
//Variables
|
||||||
|
private $esi;
|
||||||
|
|
||||||
|
//Constructi
|
||||||
|
public function __construct($charId) {
|
||||||
|
//Declare a variable for use by the constructor
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Check for the ESI scope
|
||||||
|
$check = $esiHelper->HaveEsiScope($charId, 'esi-fleets.read_fleet.v1');
|
||||||
|
if($check) {
|
||||||
|
//Setup the ESI authentication container
|
||||||
|
$this->esi = $esiHelper->SetupEsiAuthentication();
|
||||||
|
} else {
|
||||||
|
$this->esi = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get fleet information
|
||||||
|
public function GetFleetInfo($fleetId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get fleet members
|
||||||
|
public function GetFleetMembers($fleetId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get fleet wings
|
||||||
|
public function GetFleetWings($fleetId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Update fleet time
|
||||||
|
public function UpdateFleetTime($fleetId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Update fleet character names
|
||||||
|
public function UpdateFleetCharacters($fleetId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
23
app/Library/JumpBridges/JumpBridgeHelper.php
Normal file
23
app/Library/JumpBridges/JumpBridgeHelper.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Library\JumpBridges;
|
||||||
|
|
||||||
|
//Internal Libraries
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use App\Library\Taxes\TaxesHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\JumpBridgeJournal;
|
||||||
|
|
||||||
|
class JumpBridgeHelper {
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
File diff suppressed because it is too large
Load Diff
73
app/Library/Mail/Helper/EveMailHelper.php
Normal file
73
app/Library/Mail/Helper/EveMailHelper.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* W4RP Services
|
||||||
|
* GNU Public License
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Library\Mail\Helper;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//Job
|
||||||
|
use App\Jobs\ProcessSendEveMailJob;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Esi\EsiToken;
|
||||||
|
use App\Models\Esi\EsiScope;
|
||||||
|
use App\Models\Jobs\JobSendEveMail;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
|
||||||
|
//Seat Stuff
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
use Seat\Eseye\Cache\NullCache;
|
||||||
|
use Seat\Eseye\Configuration;
|
||||||
|
|
||||||
|
class EveMailHelper {
|
||||||
|
|
||||||
|
public function SendEveMail($sender, $subject, $body, $recipient, $rType) {
|
||||||
|
//Get the esi config from the environment file
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
//Declare the ESI Helper
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Check for the correct scope
|
||||||
|
if(!$esiHelper->HaveEsiScope($sender, 'esi-mail.send_mail.v1')) {
|
||||||
|
Log::critical('Could not find correct scope for the token for the mailer.');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Retrieve token from from the database for the sender
|
||||||
|
$token = $esiHelper->GetRefreshToken($sender);
|
||||||
|
|
||||||
|
//Create the ESI authentication container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
|
||||||
|
//Set caching to null
|
||||||
|
$configuration = Configuration::getInstance();
|
||||||
|
$configuration->cache = NullCache::class;
|
||||||
|
|
||||||
|
//Attempt to send the mail
|
||||||
|
try {
|
||||||
|
$esi->setBody([
|
||||||
|
'approved_cost' => 100,
|
||||||
|
'body' => $this->body,
|
||||||
|
'recipients' => [[
|
||||||
|
'recipient_id' => $this->recipient,
|
||||||
|
'recipient_type' => $this->recipient_type,
|
||||||
|
]],
|
||||||
|
'subject' => $this->subject,
|
||||||
|
])->invoke('post', '/characters/{character_id}/mail/', [
|
||||||
|
'character_id'=> $this->sender,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
Log::warning($e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
241
app/Library/Moons/MiningLedgerHelper.php
Normal file
241
app/Library/Moons/MiningLedgerHelper.php
Normal file
@@ -0,0 +1,241 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* W4RP Services
|
||||||
|
* GNU Public License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Library\Moons;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//App Library
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
|
||||||
|
//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 LookupHelper;
|
||||||
|
|
||||||
|
|
||||||
|
//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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -6,69 +6,44 @@
|
|||||||
|
|
||||||
namespace App\Library\Moons;
|
namespace App\Library\Moons;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
//Internal Library
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
|
|
||||||
use Session;
|
use Session;
|
||||||
use DB;
|
use DB;
|
||||||
|
use Carbon\Carbon;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
|
|
||||||
|
//Models
|
||||||
use App\Models\Moon\Config;
|
use App\Models\Moon\Config;
|
||||||
use App\Models\Moon\ItemComposition;
|
use App\Models\Moon\ItemComposition;
|
||||||
use App\Models\Moon\Moon;
|
use App\Models\Moon\RentalMoon;
|
||||||
use App\Models\Moon\OrePrice;
|
use App\Models\Moon\OrePrice;
|
||||||
use App\Models\Moon\Price;
|
use App\Models\Moon\MineralPrice;
|
||||||
|
|
||||||
class MoonCalc {
|
class MoonCalc {
|
||||||
|
|
||||||
|
public function GetOreComposition($ore) {
|
||||||
|
$composition = ItemComposition::where([
|
||||||
|
'Name' => $ore,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
return $composition;
|
||||||
|
}
|
||||||
|
|
||||||
public function SpatialMoonsTotalWorth($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
public function SpatialMoonsTotalWorth($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
|
//Get the total moon pull in m3
|
||||||
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
$totalPull = $this->CalculateTotalMoonPull();
|
||||||
|
|
||||||
//Get the configuration for pricing calculations
|
//Get the configuration for pricing calculations
|
||||||
$config = DB::table('Config')->get();
|
$config = DB::table('Config')->get();
|
||||||
if($firstQuan >= 1.00) {
|
|
||||||
$firstPerc = $this->ConvertToPercentage($firstQuan);
|
//Convert the quantities into numbers we want to utilize
|
||||||
} else {
|
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||||
$firstPerc = $firstQuan;
|
|
||||||
}
|
//Calculate the prices from the ores
|
||||||
if($secondQuan >= 1.00) {
|
$this->CalculateTotalPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||||
$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") {
|
|
||||||
$firstTotal = $this->CalcPrice($firstOre, $firstPerc);
|
|
||||||
} else {
|
|
||||||
$firstTotal = 0.00;
|
|
||||||
}
|
|
||||||
if($secondOre != "None") {
|
|
||||||
$secondTotal = $this->CalcPrice($secondOre, $secondPerc);
|
|
||||||
} else {
|
|
||||||
$secondTotal = 0.00;
|
|
||||||
}
|
|
||||||
if($thirdOre != "None") {
|
|
||||||
$thirdTotal = $this->CalcPrice($thirdOre, $thirdPerc);
|
|
||||||
} else {
|
|
||||||
$thirdTotal = 0.00;
|
|
||||||
}
|
|
||||||
if($fourthOre != "None") {
|
|
||||||
$fourthTotal = $this->CalcPrice($fourthOre, $fourthPerc);
|
|
||||||
} else {
|
|
||||||
$fourthTotal = 0.00;
|
|
||||||
}
|
|
||||||
//Calculate the total to price to be mined in one month
|
//Calculate the total to price to be mined in one month
|
||||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||||
|
|
||||||
@@ -77,67 +52,18 @@ class MoonCalc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function SpatialMoonsOnlyGooTotalWorth($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
public function SpatialMoonsOnlyGooTotalWorth($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
|
//Get the total moon pull in m3
|
||||||
//Total pull size is 14,385,600 m3
|
$totalPull = $this->CalculateTotalMoonPull();
|
||||||
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
|
||||||
//Get the configuration for pricing calculations
|
//Get the configuration for pricing calculations
|
||||||
$config = DB::table('Config')->get();
|
$config = DB::table('Config')->get();
|
||||||
if($firstQuan >= 1.00) {
|
|
||||||
$firstPerc = $this->ConvertToPercentage($firstQuan);
|
//Convert the quantities into numbers we want to utilize
|
||||||
} else {
|
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||||
$firstPerc = $firstQuan;
|
|
||||||
}
|
//Calculate the price of each ore
|
||||||
if($secondQuan >= 1.00) {
|
$this->CalculateOnlyGooPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||||
$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->IsRMoonGoo($firstOre)) {
|
|
||||||
$firstTotal = $this->CalcPrice($firstOre, $firstPerc);
|
|
||||||
} else {
|
|
||||||
$firstTotal = 0.00;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$firstTotal = 0.00;
|
|
||||||
}
|
|
||||||
if($secondOre != "None") {
|
|
||||||
if($this->IsRMoonGoo($secondOre)) {
|
|
||||||
$secondTotal = $this->CalcPrice($secondOre, $secondPerc);
|
|
||||||
} else {
|
|
||||||
$secondTotal = 0.00;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$secondTotal = 0.00;
|
|
||||||
}
|
|
||||||
if($thirdOre != "None") {
|
|
||||||
if($this->IsRMoonGoo($thirdOre)) {
|
|
||||||
$thirdTotal = $this->CalcPrice($thirdOre, $thirdPerc);
|
|
||||||
} else {
|
|
||||||
$thirdTotal = 0.00;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$thirdTotal = 0.00;
|
|
||||||
}
|
|
||||||
if($fourthOre != "None") {
|
|
||||||
if($this->IsRMoonGoo($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
|
//Calculate the total to price to be mined in one month
|
||||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||||
|
|
||||||
@@ -145,73 +71,50 @@ class MoonCalc {
|
|||||||
return $totalPriceMined;
|
return $totalPriceMined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SpatialMoonsOnlyGoo($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
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
|
//Get the total moon pull in m3
|
||||||
//Total pull size is 14,385,600 m3
|
$totalPull = $this->CalculateTotalMoonPull();
|
||||||
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
|
||||||
//Get the configuration for pricing calculations
|
//Get the configuration for pricing calculations
|
||||||
$config = DB::table('Config')->get();
|
$config = DB::table('Config')->get();
|
||||||
if($firstQuan >= 1.00) {
|
|
||||||
$firstPerc = $this->ConvertToPercentage($firstQuan);
|
//Convert the quantities into numbers we want to utilize
|
||||||
} else {
|
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||||
$firstPerc = $firstQuan;
|
|
||||||
}
|
//Calculate the price of each ore
|
||||||
if($secondQuan >= 1.00) {
|
$this->CalculateOnlyGooPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||||
$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
|
//Calculate the total to price to be mined in one month
|
||||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||||
|
|
||||||
//Calculate the rental price. Refined rate is already included in the price from rental composition
|
//Calculate the rental price. Refined rate is already included in the price from rental composition
|
||||||
$rentalPrice['alliance'] = $totalPriceMined * ($config[0]->RentalTax / 100.00);
|
$rentalPrice['alliance'] = $totalPriceMined * ($config[0]->RentalTax / 100.00);
|
||||||
$rentalPrice['outofalliance'] = $totalPriceMined * ($config[0]->AllyRentalTax / 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) {
|
||||||
|
//Get the total moon pull in m3
|
||||||
|
$totalPull = $this->CalculateTotalMoonPull();
|
||||||
|
|
||||||
|
//Get the configuration for pricing calculations
|
||||||
|
$config = DB::table('Config')->get();
|
||||||
|
|
||||||
|
//Convert the quantities into numbers we want to utilize
|
||||||
|
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||||
|
|
||||||
|
//Calculate the price of each ore
|
||||||
|
$this->CalculateOnlyGooPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||||
|
|
||||||
|
//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);
|
||||||
|
|
||||||
//Format the rental price to the appropriate number
|
//Format the rental price to the appropriate number
|
||||||
$rentalPrice['alliance'] = number_format($rentalPrice['alliance'], 0, ".", ",");
|
$rentalPrice['alliance'] = number_format($rentalPrice['alliance'], 0, ".", ",");
|
||||||
$rentalPrice['outofalliance'] = number_format($rentalPrice['outofalliance'], 0, ".", ",");
|
$rentalPrice['outofalliance'] = number_format($rentalPrice['outofalliance'], 0, ".", ",");
|
||||||
@@ -221,56 +124,25 @@ class MoonCalc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function SpatialMoons($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
public function SpatialMoons($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
|
//Get the total moon pull in m3
|
||||||
//Total pull size is 14,385,600 m3
|
$totalPull = $this->CalculateTotalMoonPull();
|
||||||
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
|
||||||
//Get the configuration for pricing calculations
|
//Get the configuration for pricing calculations
|
||||||
$config = DB::table('Config')->get();
|
$config = DB::table('Config')->get();
|
||||||
if($firstQuan >= 1.00) {
|
|
||||||
$firstPerc = $this->ConvertToPercentage($firstQuan);
|
//Convert the quantities into numbers we want to utilize
|
||||||
} else {
|
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||||
$firstPerc = $firstQuan;
|
|
||||||
}
|
//Calculate the prices from the ores
|
||||||
if($secondQuan >= 1.00) {
|
$this->CalculateTotalPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||||
$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") {
|
|
||||||
$firstTotal = $this->CalcPrice($firstOre, $firstPerc);
|
|
||||||
} else {
|
|
||||||
$firstTotal = 0.00;
|
|
||||||
}
|
|
||||||
if($secondOre != "None") {
|
|
||||||
$secondTotal = $this->CalcPrice($secondOre, $secondPerc);
|
|
||||||
} else {
|
|
||||||
$secondTotal = 0.00;
|
|
||||||
}
|
|
||||||
if($thirdOre != "None") {
|
|
||||||
$thirdTotal = $this->CalcPrice($thirdOre, $thirdPerc);
|
|
||||||
} else {
|
|
||||||
$thirdTotal = 0.00;
|
|
||||||
}
|
|
||||||
if($fourthOre != "None") {
|
|
||||||
$fourthTotal = $this->CalcPrice($fourthOre, $fourthPerc);
|
|
||||||
} else {
|
|
||||||
$fourthTotal = 0.00;
|
|
||||||
}
|
|
||||||
//Calculate the total to price to be mined in one month
|
//Calculate the total to price to be mined in one month
|
||||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||||
|
|
||||||
//Calculate the rental price. Refined rate is already included in the price from rental composition
|
//Calculate the rental price. Refined rate is already included in the price from rental composition
|
||||||
$rentalPrice['alliance'] = $totalPriceMined * ($config[0]->RentalTax / 100.00);
|
$rentalPrice['alliance'] = $totalPriceMined * ($config[0]->RentalTax / 100.00);
|
||||||
$rentalPrice['outofalliance'] = $totalPriceMined * ($config[0]->AllyRentalTax / 100.00);
|
$rentalPrice['outofalliance'] = $totalPriceMined * ($config[0]->AllyRentalTax / 100.00);
|
||||||
|
|
||||||
//Format the rental price to the appropriate number
|
//Format the rental price to the appropriate number
|
||||||
$rentalPrice['alliance'] = number_format($rentalPrice['alliance'], 0, ".", ",");
|
$rentalPrice['alliance'] = number_format($rentalPrice['alliance'], 0, ".", ",");
|
||||||
$rentalPrice['outofalliance'] = number_format($rentalPrice['outofalliance'], 0, ".", ",");
|
$rentalPrice['outofalliance'] = number_format($rentalPrice['outofalliance'], 0, ".", ",");
|
||||||
@@ -280,6 +152,7 @@ class MoonCalc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function FetchNewPrices() {
|
public function FetchNewPrices() {
|
||||||
|
//Create the item id array which we will pull data for from Fuzzwork market api
|
||||||
$ItemIDs = array(
|
$ItemIDs = array(
|
||||||
"Tritanium" => 34,
|
"Tritanium" => 34,
|
||||||
"Pyerite" => 35,
|
"Pyerite" => 35,
|
||||||
@@ -317,154 +190,221 @@ class MoonCalc {
|
|||||||
"Promethium" => 16652,
|
"Promethium" => 16652,
|
||||||
"Thulium" => 16653,
|
"Thulium" => 16653,
|
||||||
);
|
);
|
||||||
$time = time();
|
|
||||||
$item = array();
|
//Create the time variable
|
||||||
|
$time = Carbon::now();
|
||||||
|
|
||||||
//Get the json data for each ItemId from https://market.fuzzwork.co.uk/api/
|
//Get the json data for each ItemId from https://market.fuzzwork.co.uk/api/
|
||||||
//Base url is https://market.fuzzwork.co.uk/aggregates/?region=10000002&types=34
|
//Base url is https://market.fuzzwork.co.uk/aggregates/?region=10000002&types=34
|
||||||
//Going to use curl for these requests
|
//Going to use curl for these requests
|
||||||
foreach($ItemIDs as $key => $value) {
|
foreach($ItemIDs as $key => $value) {
|
||||||
|
//Declare a new array each time we cycle through the for loop for the item
|
||||||
|
$item = array();
|
||||||
|
|
||||||
|
//Setup the guzzle client fetch object
|
||||||
$client = new Client(['base_uri' => 'https://market.fuzzwork.co.uk/aggregates/']);
|
$client = new Client(['base_uri' => 'https://market.fuzzwork.co.uk/aggregates/']);
|
||||||
|
//Setup the uri for the guzzle client
|
||||||
$uri = '?region=10000002&types=' . $value;
|
$uri = '?region=10000002&types=' . $value;
|
||||||
|
//Get the result from the guzzle client request
|
||||||
$result = $client->request('GET', $uri);
|
$result = $client->request('GET', $uri);
|
||||||
|
//Decode the request into an array from the json body return
|
||||||
$item = json_decode($result->getBody(), true);
|
$item = json_decode($result->getBody(), true);
|
||||||
|
|
||||||
DB::table('Prices')->where('Name', $key)->update([
|
//Save the entry into the database
|
||||||
'Name' => $key,
|
$price = new MineralPrice;
|
||||||
'ItemId' => $value,
|
$price->Name = $key;
|
||||||
'Price' => $item[$value]['sell']['median'],
|
$price->ItemId = $value;
|
||||||
'Time' => $time,
|
$price->Price = $item[$value]['sell']['median'];
|
||||||
]);
|
$price->Time = $time;
|
||||||
|
$price->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Run the update for the item pricing
|
||||||
$this->UpdateItemPricing();
|
$this->UpdateItemPricing();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function UpdateItemPricing() {
|
private function UpdateItemPricing() {
|
||||||
|
|
||||||
//Get the configuration from the config table
|
//Get the configuration from the config table
|
||||||
$config = DB::table('Config')->first();
|
$config = DB::table('Config')->first();
|
||||||
|
|
||||||
//Calculate refine rate
|
//Calculate refine rate
|
||||||
$refineRate = $config->RefineRate / 100.00;
|
$refineRate = $config->RefineRate / 100.00;
|
||||||
|
|
||||||
//Calculate the current time
|
//Calculate the current time
|
||||||
$time = time();
|
$time = Carbon::now();
|
||||||
//Get the max time from the database
|
//Calcualate the current time minus 30 days
|
||||||
$maxTime = DB::table('Prices')->where('ItemId', 34)->max('Time');
|
$pastTime = Carbon::now()->subDays(30);
|
||||||
|
|
||||||
//Get the price of the basic minerals
|
//Get the price of the basic minerals
|
||||||
$tritaniumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [34, $maxTime]);
|
$tritaniumPrice = MineralPrice::where(['ItemId' => 34])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$tritanium = DB::select( DB::raw('SELECT Price FROM Prices WHERE ItemId= :id AND Time= :time'), array('id' => 34, 'time' => $maxTime));
|
$pyeritePrice = MineralPrice::where(['ItemId' => 35])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$pyeritePrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [35, $maxTime]);
|
$mexallonPrice = MineralPrice::where(['ItemId' => 36])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$mexallonPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [36, $maxTime]);
|
$isogenPrice = MineralPrice::where(['ItemId' => 37])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$isogenPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [37, $maxTime]);
|
$nocxiumPrice = MineralPrice::where(['ItemId' => 38])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$nocxiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [38, $maxTime]);
|
$zydrinePrice = MineralPrice::where(['ItemId' => 39])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$zydrinePrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [39, $maxTime]);
|
$megacytePrice = MineralPrice::where(['ItemId' => 40])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$megacytePrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [40, $maxTime]);
|
$morphitePrice = MineralPrice::where(['ItemId' => 11399])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$morphitePrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [11399, $maxTime]);
|
$heliumIsotopesPrice = MineralPrice::where(['ItemId' => 16274])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$heliumIsotopesPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16274, $maxTime]);
|
$nitrogenIsotopesPrice = MineralPrice::where(['ItemId' => 17888])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$nitrogenIsotopesPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [17888, $maxTime]);
|
$oxygenIsotopesPrice = MineralPrice::where(['ItemId' => 17887])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$oxygenIsotopesPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [17887, $maxTime]);
|
$hydrogenIsotopesPrice = MineralPrice::where(['ItemId' => 17889])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$hydrogenIsotopesPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [17889, $maxTime]);
|
$liquidOzonePrice = MineralPrice::where(['ItemId' => 16273])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$liquidOzonePrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16273, $maxTime]);
|
$heavyWaterPrice = MineralPrice::where(['ItemId' => 16272])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$heavyWaterPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16272, $maxTime]);
|
$strontiumClathratesPrice = MineralPrice::where(['ItemId' => 16275])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$strontiumClathratesPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16275, $maxTime]);
|
|
||||||
//Get the price of the moongoo
|
//Get the price of the moongoo
|
||||||
$atmosphericGasesPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16634, $maxTime]);
|
$atmosphericGasesPrice = MineralPrice::where(['ItemId' => 16634])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$evaporiteDepositsPirce = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16635, $maxTime]);
|
$evaporiteDepositsPirce = MineralPrice::where(['ItemId' => 16635])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$hydrocarbonsPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16633, $maxTime]);
|
$hydrocarbonsPrice = MineralPrice::where(['ItemId' => 16633])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$silicatesPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16636, $maxTime]);
|
$silicatesPrice = MineralPrice::where(['ItemId' => 16636])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$cobaltPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16640, $maxTime]);
|
$cobaltPrice = MineralPrice::where(['ItemId' => 16640])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$scandiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16639, $maxTime]);
|
$scandiumPrice = MineralPrice::where(['ItemId' => 16639])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$titaniumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16638, $maxTime]);
|
$titaniumPrice = MineralPrice::where(['ItemId' => 16638])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$tungstenPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16637, $maxTime]);
|
$tungstenPrice = MineralPrice::where(['ItemId' => 16637])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$cadmiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16643, $maxTime]);
|
$cadmiumPrice = MineralPrice::where(['ItemId' => 16643])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$platinumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16644, $maxTime]);
|
$platinumPrice = MineralPrice::where(['ItemId' => 16644])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$vanadiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16642, $maxTime]);
|
$vanadiumPrice = MineralPrice::where(['ItemId' => 16642])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$chromiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16641, $maxTime]);
|
$chromiumPrice = MineralPrice::where(['ItemId' => 16641])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$technetiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16649, $maxTime]);
|
$technetiumPrice = MineralPrice::where(['ItemId' => 16649])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$hafniumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16648, $maxTime]);
|
$hafniumPrice = MineralPrice::where(['ItemId' => 16648])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$caesiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16647, $maxTime]);
|
$caesiumPrice = MineralPrice::where(['ItemId' => 16647])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$mercuryPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16646, $maxTime]);
|
$mercuryPrice = MineralPrice::where(['ItemId' => 16646])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$dysprosiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16650, $maxTime]);
|
$dysprosiumPrice = MineralPrice::where(['ItemId' => 16650])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$neodymiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16651, $maxTime]);
|
$neodymiumPrice = MineralPrice::where(['ItemId' => 16651])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$promethiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16652, $maxTime]);
|
$promethiumPrice = MineralPrice::where(['ItemId' => 16652])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
$thuliumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16653, $maxTime]);
|
$thuliumPrice = MineralPrice::where(['ItemId' => 16653])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||||
|
|
||||||
//Get the item compositions
|
//Get the item compositions
|
||||||
$items = DB::select('SELECT Name,ItemId FROM ItemComposition');
|
$items = DB::select('SELECT Name,ItemId FROM ItemComposition');
|
||||||
//Go through each of the items and update the price
|
//Go through each of the items and update the price
|
||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
//Get the item composition
|
//Get the item composition
|
||||||
$composition = DB::select('SELECT * FROM ItemComposition WHERE ItemId = ?', [$item->ItemId]);
|
$composition = ItemComposition::where('ItemId', $item->ItemId)->first();
|
||||||
|
|
||||||
//Calculate the Batch Price
|
//Calculate the Batch Price
|
||||||
$batchPrice = ( ($composition[0]->Tritanium * $tritaniumPrice[0]->Price) +
|
$batchPrice = ( ($composition->Tritanium * $tritaniumPrice) +
|
||||||
($composition[0]->Pyerite * $pyeritePrice[0]->Price) +
|
($composition->Pyerite * $pyeritePrice) +
|
||||||
($composition[0]->Mexallon * $mexallonPrice[0]->Price) +
|
($composition->Mexallon * $mexallonPrice) +
|
||||||
($composition[0]->Isogen * $isogenPrice[0]->Price) +
|
($composition->Isogen * $isogenPrice) +
|
||||||
($composition[0]->Nocxium * $nocxiumPrice[0]->Price) +
|
($composition->Nocxium * $nocxiumPrice) +
|
||||||
($composition[0]->Zydrine * $zydrinePrice[0]->Price) +
|
($composition->Zydrine * $zydrinePrice) +
|
||||||
($composition[0]->Megacyte * $megacytePrice[0]->Price) +
|
($composition->Megacyte * $megacytePrice) +
|
||||||
($composition[0]->Morphite * $morphitePrice[0]->Price) +
|
($composition->Morphite * $morphitePrice) +
|
||||||
($composition[0]->HeavyWater * $heavyWaterPrice[0]->Price) +
|
($composition->HeavyWater * $heavyWaterPrice) +
|
||||||
($composition[0]->LiquidOzone * $liquidOzonePrice[0]->Price) +
|
($composition->LiquidOzone * $liquidOzonePrice) +
|
||||||
($composition[0]->NitrogenIsotopes * $nitrogenIsotopesPrice[0]->Price) +
|
($composition->NitrogenIsotopes * $nitrogenIsotopesPrice) +
|
||||||
($composition[0]->HeliumIsotopes * $heliumIsotopesPrice[0]->Price) +
|
($composition->HeliumIsotopes * $heliumIsotopesPrice) +
|
||||||
($composition[0]->HydrogenIsotopes * $hydrogenIsotopesPrice[0]->Price) +
|
($composition->HydrogenIsotopes * $hydrogenIsotopesPrice) +
|
||||||
($composition[0]->OxygenIsotopes * $oxygenIsotopesPrice[0]->Price) +
|
($composition->OxygenIsotopes * $oxygenIsotopesPrice) +
|
||||||
($composition[0]->StrontiumClathrates * $strontiumClathratesPrice[0]->Price) +
|
($composition->StrontiumClathrates * $strontiumClathratesPrice) +
|
||||||
($composition[0]->AtmosphericGases * $atmosphericGasesPrice[0]->Price) +
|
($composition->AtmosphericGases * $atmosphericGasesPrice) +
|
||||||
($composition[0]->EvaporiteDeposits * $evaporiteDepositsPirce[0]->Price) +
|
($composition->EvaporiteDeposits * $evaporiteDepositsPirce) +
|
||||||
($composition[0]->Hydrocarbons * $hydrocarbonsPrice[0]->Price) +
|
($composition->Hydrocarbons * $hydrocarbonsPrice) +
|
||||||
($composition[0]->Silicates * $silicatesPrice[0]->Price) +
|
($composition->Silicates * $silicatesPrice) +
|
||||||
($composition[0]->Cobalt * $cobaltPrice[0]->Price) +
|
($composition->Cobalt * $cobaltPrice) +
|
||||||
($composition[0]->Scandium * $scandiumPrice[0]->Price) +
|
($composition->Scandium * $scandiumPrice) +
|
||||||
($composition[0]->Titanium * $titaniumPrice[0]->Price) +
|
($composition->Titanium * $titaniumPrice) +
|
||||||
($composition[0]->Tungsten * $tungstenPrice[0]->Price) +
|
($composition->Tungsten * $tungstenPrice) +
|
||||||
($composition[0]->Cadmium * $cadmiumPrice[0]->Price) +
|
($composition->Cadmium * $cadmiumPrice) +
|
||||||
($composition[0]->Platinum * $platinumPrice[0]->Price) +
|
($composition->Platinum * $platinumPrice) +
|
||||||
($composition[0]->Vanadium * $vanadiumPrice[0]->Price) +
|
($composition->Vanadium * $vanadiumPrice) +
|
||||||
($composition[0]->Chromium * $chromiumPrice[0]->Price)+
|
($composition->Chromium * $chromiumPrice)+
|
||||||
($composition[0]->Technetium * $technetiumPrice[0]->Price) +
|
($composition->Technetium * $technetiumPrice) +
|
||||||
($composition[0]->Hafnium * $hafniumPrice[0]->Price) +
|
($composition->Hafnium * $hafniumPrice) +
|
||||||
($composition[0]->Caesium * $caesiumPrice[0]->Price) +
|
($composition->Caesium * $caesiumPrice) +
|
||||||
($composition[0]->Mercury * $mercuryPrice[0]->Price) +
|
($composition->Mercury * $mercuryPrice) +
|
||||||
($composition[0]->Dysprosium * $dysprosiumPrice[0]->Price) +
|
($composition->Dysprosium * $dysprosiumPrice) +
|
||||||
($composition[0]->Neodymium * $neodymiumPrice[0]->Price) +
|
($composition->Neodymium * $neodymiumPrice) +
|
||||||
($composition[0]->Promethium * $promethiumPrice[0]->Price) +
|
($composition->Promethium * $promethiumPrice) +
|
||||||
($composition[0]->Thulium * $thuliumPrice[0]->Price));
|
($composition->Thulium * $thuliumPrice));
|
||||||
//Calculate the batch price with the refine rate included
|
//Calculate the batch price with the refine rate included
|
||||||
//Batch Price is base price for everything
|
//Batch Price is base price for everything
|
||||||
$batchPrice = $batchPrice * $refineRate;
|
$batchPrice = $batchPrice * $refineRate;
|
||||||
//Calculate the unit price
|
//Calculate the unit price
|
||||||
$price = $batchPrice / $composition[0]->BatchSize;
|
$price = $batchPrice / $composition->BatchSize;
|
||||||
//Calculate the m3 price
|
//Calculate the m3 price
|
||||||
$m3Price = $price / $composition[0]->m3Size;
|
$m3Price = $price / $composition->m3Size;
|
||||||
//Update the prices in the Prices table
|
|
||||||
DB::table('OrePrices')->where('Name', $composition[0]->Name)->update([
|
//Check if an item is in the table
|
||||||
'Name' => $composition[0]->Name,
|
$count = OrePrice::where('Name', $composition->Name)->count();
|
||||||
'ItemId' => $composition[0]->ItemId,
|
if($count == 0) {
|
||||||
'BatchPrice' => $batchPrice,
|
//If the ore wasn't found, then add a new entry
|
||||||
'UnitPrice' => $price,
|
$ore = new OrePrice;
|
||||||
'm3Price' => $m3Price,
|
$ore->Name = $composition->Name;
|
||||||
]);
|
$ore->ItemId = $composition->ItemId;
|
||||||
|
$ore->BatchPrice = $batchPrice;
|
||||||
|
$ore->UnitPrice = $price;
|
||||||
|
$ore->m3Price = $m3Price;
|
||||||
|
$ore->Time = $time;
|
||||||
|
$ore->save();
|
||||||
|
} else {
|
||||||
|
//Update the prices in the Prices table
|
||||||
|
OrePrice::where('Name', $composition->Name)->update([
|
||||||
|
'Name' => $composition->Name,
|
||||||
|
'ItemId' => $composition->ItemId,
|
||||||
|
'BatchPrice' => $batchPrice,
|
||||||
|
'UnitPrice' => $price,
|
||||||
|
'm3Price' => $m3Price,
|
||||||
|
'Time' => $time,
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function CalcOreUnits($ore, $percentage) {
|
||||||
|
//Specify the total pull amount
|
||||||
|
$totalPull = 5.55 * (3600.00 * 24.00 *30.00);
|
||||||
|
|
||||||
|
//Find the size of the asteroid from the database
|
||||||
|
$item = ItemComposition::where([
|
||||||
|
'Name' => $ore,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
//Get the m3 size from the item composition
|
||||||
|
$m3Size = $item->m3Size;
|
||||||
|
|
||||||
|
//Calculate the actual m3 from the total pull amount in m3 using the percentage of the ingredient
|
||||||
|
$actualm3 = floor($totalPull * $percentage);
|
||||||
|
|
||||||
|
//Calculate the units from the m3 pulled from the moon
|
||||||
|
$units = floor($actualm3 / $m3Size);
|
||||||
|
|
||||||
|
//Return the calculated data
|
||||||
|
return $units;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function CalculateTotalMoonPull() {
|
||||||
|
//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);
|
||||||
|
|
||||||
|
return $totalPull;
|
||||||
|
}
|
||||||
|
|
||||||
private function CalcPrice($ore, $percentage) {
|
private function CalcPrice($ore, $percentage) {
|
||||||
//Specify the total pull amount
|
//Specify the total pull amount
|
||||||
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
||||||
|
|
||||||
//Find the size of the asteroid from the database
|
//Find the size of the asteroid from the database
|
||||||
$m3Size = DB::table('ItemComposition')->where('Name', $ore)->value('m3Size');
|
$m3Size = DB::table('ItemComposition')->where('Name', $ore)->value('m3Size');
|
||||||
|
|
||||||
//Calculate the actual m3 from the total pull amount in m3 using the percentage of the ingredient
|
//Calculate the actual m3 from the total pull amount in m3 using the percentage of the ingredient
|
||||||
$actualm3 = floor($percentage * $totalPull);
|
$actualm3 = floor($percentage * $totalPull);
|
||||||
|
|
||||||
//Calculate the units once we have the size and actual m3 value
|
//Calculate the units once we have the size and actual m3 value
|
||||||
$units = floor($actualm3 / $m3Size);
|
$units = floor($actualm3 / $m3Size);
|
||||||
|
|
||||||
//Look up the unit price from the database
|
//Look up the unit price from the database
|
||||||
$unitPrice = DB::table('OrePrices')->where('Name', $ore)->value('UnitPrice');
|
$unitPrice = DB::table('ore_prices')->where('Name', $ore)->value('UnitPrice');
|
||||||
|
|
||||||
//Calculate the total amount from the units and unit price
|
//Calculate the total amount from the units and unit price
|
||||||
$total = $units * $unitPrice;
|
$total = $units * $unitPrice;
|
||||||
|
|
||||||
//Return the value
|
//Return the value
|
||||||
return $total;
|
return $total;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function ConvertToPercentage($quantity) {
|
private function ConvertToPercentage($quantity) {
|
||||||
|
//Perform the calculation and return the data
|
||||||
return $quantity / 100.00;
|
return $quantity / 100.00;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,4 +479,128 @@ class MoonCalc {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function ConvertPercentages(&$firstPerc, $firstQuan, &$secondPerc, $secondQuan, &$thirdPerc, $thirdQuan, &$fourthPerc, $fourthQuan) {
|
||||||
|
//Set the base percentages for the if statements
|
||||||
|
$firstPerc = 0.00;
|
||||||
|
$secondPerc = 0.00;
|
||||||
|
$thirdPerc = 0.00;
|
||||||
|
$fourthPerc = 0.00;
|
||||||
|
|
||||||
|
//Convert the quantities into numbers we want to utilize
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add up all the percentages
|
||||||
|
$totalPerc = $firstPerc + $secondPerc + $thirdPerc + $fourthPerc;
|
||||||
|
|
||||||
|
//If it is less than 1.00, then we need to normalize the decimal to be 100.0%.
|
||||||
|
if($totalPerc < 1.00) {
|
||||||
|
if($firstPerc > 0.00) {
|
||||||
|
$firstPerc = $firstPerc / $totalPerc;
|
||||||
|
} else {
|
||||||
|
$firstPerc = 0.00;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($secondPerc > 0.00) {
|
||||||
|
$secondPerc = $secondPerc / $totalPerc;
|
||||||
|
} else {
|
||||||
|
$secondPerc = 0.00;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($thirdPerc > 0.00) {
|
||||||
|
$thirdPerc = $thirdPerc / $totalPerc;
|
||||||
|
} else {
|
||||||
|
$thirdPerc = 0.00;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($fourthPerc > 0.00) {
|
||||||
|
$fourthPerc = $fourthPerc / $totalPerc;
|
||||||
|
} else {
|
||||||
|
$fourthPerc = 0.00;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function CalculateTotalPrices($firstOre, $firstPerc, &$firstTotal, $secondOre, $secondPerc, &$secondTotal, $thirdOre, $thirdPerc, &$thirdTotal, $fourthOre, $fourthPerc, &$fourthTotal) {
|
||||||
|
//Calculate the prices from the ores
|
||||||
|
if($firstOre != "None") {
|
||||||
|
$firstTotal = $this->CalcPrice($firstOre, $firstPerc);
|
||||||
|
} else {
|
||||||
|
$firstTotal = 0.00;
|
||||||
|
}
|
||||||
|
if($secondOre != "None") {
|
||||||
|
$secondTotal = $this->CalcPrice($secondOre, $secondPerc);
|
||||||
|
} else {
|
||||||
|
$secondTotal = 0.00;
|
||||||
|
}
|
||||||
|
if($thirdOre != "None") {
|
||||||
|
$thirdTotal = $this->CalcPrice($thirdOre, $thirdPerc);
|
||||||
|
} else {
|
||||||
|
$thirdTotal = 0.00;
|
||||||
|
}
|
||||||
|
if($fourthOre != "None") {
|
||||||
|
$fourthTotal = $this->CalcPrice($fourthOre, $fourthPerc);
|
||||||
|
} else {
|
||||||
|
$fourthTotal = 0.00;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function CalculateOnlyGooPrices($firstOre, $firstPerc, &$firstTotal, $secondOre, $secondPerc, &$secondTotal, $thirdOre, $thirdPerc, &$thirdTotal, $fourthOre, $fourthPerc, &$fourthTotal) {
|
||||||
|
//Calculate the price of each ore
|
||||||
|
if($firstOre != "None") {
|
||||||
|
if($this->IsRMoonGoo($firstOre)) {
|
||||||
|
$firstTotal = $this->CalcPrice($firstOre, $firstPerc);
|
||||||
|
} else {
|
||||||
|
$firstTotal = 0.00;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$firstTotal = 0.00;
|
||||||
|
}
|
||||||
|
if($secondOre != "None") {
|
||||||
|
if($this->IsRMoonGoo($secondOre)) {
|
||||||
|
$secondTotal = $this->CalcPrice($secondOre, $secondPerc);
|
||||||
|
} else {
|
||||||
|
$secondTotal = 0.00;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$secondTotal = 0.00;
|
||||||
|
}
|
||||||
|
if($thirdOre != "None") {
|
||||||
|
if($this->IsRMoonGoo($thirdOre)) {
|
||||||
|
$thirdTotal = $this->CalcPrice($thirdOre, $thirdPerc);
|
||||||
|
} else {
|
||||||
|
$thirdTotal = 0.00;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$thirdTotal = 0.00;
|
||||||
|
}
|
||||||
|
if($fourthOre != "None") {
|
||||||
|
if($this->IsRMoonGoo($fourthOre)) {
|
||||||
|
$fourthTotal = $this->CalcPrice($fourthOre, $fourthPerc);
|
||||||
|
} else {
|
||||||
|
$fourthTotal = 0.00;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$fourthTotal = 0.00;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
175
app/Library/SRP/SRPHelper.php
Normal file
175
app/Library/SRP/SRPHelper.php
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Library\SRP;
|
||||||
|
|
||||||
|
//Internal Libraries
|
||||||
|
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 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 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
368
app/Library/Structures/StructureHelper.php
Normal file
368
app/Library/Structures/StructureHelper.php
Normal file
@@ -0,0 +1,368 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
//App Library
|
||||||
|
use App\Jobs\Library\JobHelper;
|
||||||
|
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) {
|
||||||
|
//Declare some variables
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Get the refresh token from the database
|
||||||
|
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||||
|
//Create the esi authentication container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
|
||||||
|
//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) {
|
||||||
|
//Declare some variables
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Get the refresh token from the database
|
||||||
|
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||||
|
//Setup the esi authentication container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
|
||||||
|
//Get the structure information
|
||||||
|
$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) {
|
||||||
|
//Declare some variables
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Get the refresh token
|
||||||
|
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||||
|
//Setup the esi authentication container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
|
||||||
|
//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) {
|
||||||
|
//Declare some variables
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Get the refresh token
|
||||||
|
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||||
|
//Setup the esi authentication container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
|
||||||
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Library\Taxes;
|
namespace App\Library\Taxes;
|
||||||
|
|
||||||
use DB;
|
//Internal Library
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
use App\User;
|
//Models
|
||||||
|
use App\Models\User\User;
|
||||||
use App\Models\User\UserRole;
|
use App\Models\User\UserRole;
|
||||||
use App\Models\User\UserPermission;
|
use App\Models\User\UserPermission;
|
||||||
|
|
||||||
@@ -14,9 +14,10 @@ use App\Models\Finances\ReprocessingTaxJournal;
|
|||||||
use App\Models\Finances\StructureIndustryTaxJournal;
|
use App\Models\Finances\StructureIndustryTaxJournal;
|
||||||
use App\Models\Finances\PlanetProductionTaxJournal;
|
use App\Models\Finances\PlanetProductionTaxJournal;
|
||||||
use App\Models\Finances\OfficeFeesJournal;
|
use App\Models\Finances\OfficeFeesJournal;
|
||||||
use App\Models\Finances\CorpMarketJournal;
|
|
||||||
use App\Models\Finances\JumpBridgeJournal;
|
use App\Models\Finances\JumpBridgeJournal;
|
||||||
use App\Models\Finances\PISaleJournal;
|
use App\Models\Finances\PISaleJournal;
|
||||||
|
use App\Models\Finances\AllianceMarketJournal;
|
||||||
|
use App\Models\SRP\SRPShip;
|
||||||
|
|
||||||
class TaxesHelper {
|
class TaxesHelper {
|
||||||
|
|
||||||
@@ -32,22 +33,26 @@ class TaxesHelper {
|
|||||||
$this->end = $en;
|
$this->end = $en;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetJumpGateGross($start, $end) {
|
public function GetAllianceMarketGross($start, $end) {
|
||||||
$revenue = 0.00;
|
$revenue = 0.00;
|
||||||
|
|
||||||
$revenue = JumpBridgeJournal::where(['ref_type' => 'structure_gate_jump', 'second_party_id' => '98287666'])
|
$revenue = AllianceMarketJournal::where([
|
||||||
->whereBetween('date', [$start, $end])
|
'second_party_id' => '98287666',
|
||||||
->sum('amount');
|
'ref_type' => 'brokers_fee',
|
||||||
|
])->whereBetween('date', [$start, $end])
|
||||||
|
->sum('amount');
|
||||||
|
|
||||||
return $revenue;
|
return $revenue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetMarketGross($start, $end) {
|
public function GetJumpGateGross($start, $end) {
|
||||||
$revenue = 0.00;
|
$revenue = 0.00;
|
||||||
|
|
||||||
$revenue = CorpMarketJournal::where(['ref_type' => 'brokers_fee', 'second_party_id' => '98287666'])
|
$revenue = JumpBridgeJournal::where([
|
||||||
->whereBetween('date', [$start, $end])
|
'ref_type' => 'structure_gate_jump',
|
||||||
->sum('amount');
|
'second_party_id' => '98287666',
|
||||||
|
])->whereBetween('date', [$start, $end])
|
||||||
|
->sum('amount');
|
||||||
|
|
||||||
return $revenue;
|
return $revenue;
|
||||||
}
|
}
|
||||||
@@ -55,9 +60,11 @@ class TaxesHelper {
|
|||||||
public function GetIndustryGross($start, $end) {
|
public function GetIndustryGross($start, $end) {
|
||||||
$revenue = 0.00;
|
$revenue = 0.00;
|
||||||
|
|
||||||
$revenue = StructureIndustryTaxJournal::where(['ref_type' => 'industry_job_tax', 'second_party_id' => '98287666'])
|
$revenue = StructureIndustryTaxJournal::where([
|
||||||
->whereBetween('date', [$start, $end])
|
'ref_type' => 'industry_job_tax',
|
||||||
->sum('amount');
|
'second_party_id' => '98287666',
|
||||||
|
])->whereBetween('date', [$start, $end])
|
||||||
|
->sum('amount');
|
||||||
|
|
||||||
return $revenue;
|
return $revenue;
|
||||||
}
|
}
|
||||||
@@ -65,9 +72,11 @@ class TaxesHelper {
|
|||||||
public function GetReprocessingGross($start, $end) {
|
public function GetReprocessingGross($start, $end) {
|
||||||
$revenue = 0.00;
|
$revenue = 0.00;
|
||||||
|
|
||||||
$revenue = ReprocessingTaxJournal::where(['ref_type' => 'reprocessing_tax', 'second_party_id' => '98287666'])
|
$revenue = ReprocessingTaxJournal::where([
|
||||||
->whereBetween('date', [$start, $end])
|
'ref_type' => 'reprocessing_tax',
|
||||||
->sum('amount');
|
'second_party_id' => '98287666',
|
||||||
|
])->whereBetween('date', [$start, $end])
|
||||||
|
->sum('amount');
|
||||||
|
|
||||||
return $revenue;
|
return $revenue;
|
||||||
}
|
}
|
||||||
@@ -76,24 +85,35 @@ class TaxesHelper {
|
|||||||
$revenueImport = 0.00;
|
$revenueImport = 0.00;
|
||||||
$revenueExport = 0.00;
|
$revenueExport = 0.00;
|
||||||
|
|
||||||
$revenueImport = PlanetProductionTaxJournal::where(['ref_type' => 'planetary_import_tax', 'second_party_id' => '98287666'])
|
//Get the import revenue from the database
|
||||||
->whereBetween('date', [$start, $end])
|
$revenueImport = PlanetProductionTaxJournal::where([
|
||||||
->sum('amount');
|
'ref_type' => 'planetary_import_tax',
|
||||||
$revenueExport = PlanetProductionTaxJournal::where(['ref_type' => 'planetary_export_tax', 'second_party_id' => '98287666'])
|
'second_party_id' => '98287666',
|
||||||
->whereBetween('date', [$start, $end])
|
])->whereBetween('date', [$start, $end])
|
||||||
->sum('amount');
|
->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;
|
$finalRevenue = $revenueImport + $revenueExport;
|
||||||
|
|
||||||
|
//Return the values
|
||||||
return $finalRevenue;
|
return $finalRevenue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetOfficeGross($start, $end) {
|
public function GetOfficeGross($start, $end) {
|
||||||
$revenue = 0.00;
|
$revenue = 0.00;
|
||||||
|
|
||||||
$revenue = OfficeFeesJournal::where(['ref_type' => 'office_rental_fee', 'second_party_id' => '98287666'])
|
$revenue = OfficeFeesJournal::where([
|
||||||
->whereBetween('date', [$start, $end])
|
'ref_type' => 'office_rental_fee',
|
||||||
->sum('amount');
|
'second_party_id' => '98287666',
|
||||||
|
])->whereBetween('date', [$start, $end])
|
||||||
|
->sum('amount');
|
||||||
|
|
||||||
return $revenue;
|
return $revenue;
|
||||||
}
|
}
|
||||||
|
|||||||
156
app/Library/Wiki/WikiHelper.php
Normal file
156
app/Library/Wiki/WikiHelper.php
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Library\Wiki;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use App\Library\Lookups\LookupHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\User\User;
|
||||||
|
use App\Models\User\UserRole;
|
||||||
|
use App\Models\User\UserPermission;
|
||||||
|
use App\Models\Doku\DokuGroupNames;
|
||||||
|
use App\Models\Doku\DokuMember;
|
||||||
|
use App\Models\Doku\DokuUser;
|
||||||
|
use App\Models\Admin\AllowedLogin;
|
||||||
|
|
||||||
|
class WikiHelper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the user is allwoed or not allowed
|
||||||
|
*/
|
||||||
|
public function AllowedUser($user) {
|
||||||
|
//Declare some variables
|
||||||
|
$purge = true;
|
||||||
|
|
||||||
|
//Declare helper class
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
|
||||||
|
//Get the allowed logins list from the database
|
||||||
|
$legacy = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_id')->toArray();
|
||||||
|
$renter = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_id')->toArray();
|
||||||
|
|
||||||
|
$charIdTemp = User::where(['name' => $user])->get(['character_id']);
|
||||||
|
|
||||||
|
//Set the character id
|
||||||
|
$charId = $charIdTemp[0]->character_id;
|
||||||
|
|
||||||
|
//Set the corp id
|
||||||
|
$char = $lookup->GetCharacterInfo($charId);
|
||||||
|
$corpId = $char->corporation_id;
|
||||||
|
|
||||||
|
//Set the alliance id
|
||||||
|
$corp = $lookup->GetCorporationInfo($corpId);
|
||||||
|
$allianceId = $corp->alliance_id;
|
||||||
|
|
||||||
|
if(in_array($allianceId, $legacy) || in_array($allianceId, $renter) || $allianceId == 99004116) {
|
||||||
|
$purge = false;
|
||||||
|
} else {
|
||||||
|
$purge = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $purge;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a user to a particular group
|
||||||
|
*/
|
||||||
|
public function AddUserToGroup($userId, $groupId) {
|
||||||
|
//Get the group information
|
||||||
|
$groups = DokuGroupNames::all();
|
||||||
|
|
||||||
|
//Check if the user already belongs to the group
|
||||||
|
$userGroups = DokuMember::where(['gid' => $groupId])->count();
|
||||||
|
if($count > 0) {
|
||||||
|
//If the count is greater than zero then we don't need to do anything,
|
||||||
|
//just return false to indicate nothing was changed
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
//Get the group the person needs to be added to.
|
||||||
|
$newGroup = DokuGroupNames::where(['id' => $groupId])->first();
|
||||||
|
//Add the user to the group
|
||||||
|
DokuMember::insert([
|
||||||
|
'uid' => $userId,
|
||||||
|
'gid' => $groupId,
|
||||||
|
'groupname' => $newGroup->gname,
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Return true saying we have inserted the user into the group
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a user from a particular group
|
||||||
|
*/
|
||||||
|
public function RemoveUserFromGroup($userId, $groupId) {
|
||||||
|
//Remove the user from any groups he is associated with
|
||||||
|
DokuMember::where([
|
||||||
|
'uid' => $userId,
|
||||||
|
'gid' => $groupId,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a user from all groups
|
||||||
|
*/
|
||||||
|
public function RemoveUserFromAllGroups($userId) {
|
||||||
|
//Remove the user from all groups
|
||||||
|
DokuMember::where([
|
||||||
|
'uid' => $userId,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if a user is already in a group
|
||||||
|
*/
|
||||||
|
public function UserHasGroup($userId, $groupId) {
|
||||||
|
//Get the user information
|
||||||
|
$user = DokuUser::where(['id' => $userId])->first();
|
||||||
|
//Get all of the groups
|
||||||
|
$allGroups = DokuGroupNames::all();
|
||||||
|
|
||||||
|
//cycle through all of the groups, and all of the user's groups to see if the user
|
||||||
|
//is part of the group we are seeking
|
||||||
|
foreach($allGroups as $all) {
|
||||||
|
if($groupId === $all->id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//If we have made it here, then the user does not have the group, therefore,
|
||||||
|
//return the user doesn't have the group
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new user group
|
||||||
|
*/
|
||||||
|
public function AddNewUserGroup($groupName, $description) {
|
||||||
|
//Check if the user group already exists
|
||||||
|
DokuGroupNames::where(['gname' => $groupName])->count();
|
||||||
|
|
||||||
|
if($count == 0) {
|
||||||
|
DokuGroupNames::insert([
|
||||||
|
'gname' => $groupName,
|
||||||
|
'description' => $description,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all traces of a wiki user
|
||||||
|
*/
|
||||||
|
public function DeleteWikiUser($userId) {
|
||||||
|
//Delete the permissions of the user first.
|
||||||
|
DokuMember::where([
|
||||||
|
'uid' => $userId,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
//Delete the user from the user table
|
||||||
|
DokuUser::where(['id' => $userId])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/Models/Blacklist/BlacklistEntity.php
Normal file
29
app/Models/Blacklist/BlacklistEntity.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Blacklist;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class BlacklistEntity extends Model
|
||||||
|
{
|
||||||
|
//Table Name
|
||||||
|
public $table = 'alliance_blacklist';
|
||||||
|
|
||||||
|
//Timestamps
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'entity_id',
|
||||||
|
'entity_name',
|
||||||
|
'entity_type',
|
||||||
|
'reason',
|
||||||
|
'alts',
|
||||||
|
'lister_id',
|
||||||
|
'lister_name',
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models\Character;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class CharacterClone extends Model
|
|
||||||
{
|
|
||||||
// Table Name
|
|
||||||
public $table = 'clones';
|
|
||||||
|
|
||||||
// Timestamps
|
|
||||||
public $timestamps = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes that are mass assignable
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fillable = [
|
|
||||||
'character_id',
|
|
||||||
'active',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models\Corporation;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class CorpStructure extends Model
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Table Name
|
|
||||||
*/
|
|
||||||
protected $table = 'CorpStructures';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Timestamps
|
|
||||||
*/
|
|
||||||
public $timestamps = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes that are mass assignable
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fillable = [
|
|
||||||
'character_id',
|
|
||||||
'corporation_id',
|
|
||||||
'corporation_name',
|
|
||||||
'region',
|
|
||||||
'system',
|
|
||||||
'structure_name',
|
|
||||||
'structure_type',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models\Corporation;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class CorpTaxRatio extends Model
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Table Name
|
|
||||||
*/
|
|
||||||
protected $table = 'corp_tax_ratios';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Timestamps
|
|
||||||
*/
|
|
||||||
public $timestamps = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes that are mass assignable
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fillable = [
|
|
||||||
'corporation_id',
|
|
||||||
'corporation_name',
|
|
||||||
'structure_type',
|
|
||||||
'ratio',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -10,4 +10,9 @@ class DokuGroupNames extends Model
|
|||||||
protected $table = 'wiki_groupnames';
|
protected $table = 'wiki_groupnames';
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'gname',
|
||||||
|
'description',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,4 +10,10 @@ class DokuMember extends Model
|
|||||||
protected $table = 'wiki_member';
|
protected $table = 'wiki_member';
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'uid',
|
||||||
|
'gid',
|
||||||
|
'groupname',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,4 +11,11 @@ class DokuUser extends Model
|
|||||||
|
|
||||||
// Timestamps
|
// Timestamps
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'login',
|
||||||
|
'pass',
|
||||||
|
'name',
|
||||||
|
'mail',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ class EsiScope extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
public function user() {
|
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',
|
'character_id',
|
||||||
'access_token',
|
'access_token',
|
||||||
'refresh_token',
|
'refresh_token',
|
||||||
|
'inserted_at',
|
||||||
'expires_in',
|
'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,41 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models\Finances;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class CorpMarketJournal extends Model
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Table Name
|
|
||||||
*/
|
|
||||||
protected $table = 'corp_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',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
41
app/Models/Finances/SovBillJournal.php
Normal file
41
app/Models/Finances/SovBillJournal.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Finances;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class SovBillJournal extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Table Name
|
||||||
|
*/
|
||||||
|
protected $table = 'sov_bill_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,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',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
32
app/Models/Fleets/AllianceFleet.php
Normal file
32
app/Models/Fleets/AllianceFleet.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Fleets;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AllianceFleet extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Table Name
|
||||||
|
*/
|
||||||
|
protected $table = 'alliance_fleets';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timestamps
|
||||||
|
*/
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'fleet_id',
|
||||||
|
'fleet_commander_id',
|
||||||
|
'fleet_commander_name',
|
||||||
|
'member_count',
|
||||||
|
'fleet_opened_time',
|
||||||
|
'fleet_closed_time',
|
||||||
|
];
|
||||||
|
}
|
||||||
31
app/Models/Fleets/AllianceFleetMember.php
Normal file
31
app/Models/Fleets/AllianceFleetMember.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Fleets;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AllianceFleetMember extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Table Name
|
||||||
|
*/
|
||||||
|
protected $table = 'alliance_fleet_members';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timestamps
|
||||||
|
*/
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'fleet_id',
|
||||||
|
'character_id',
|
||||||
|
'character_name',
|
||||||
|
'fleet_joined_time',
|
||||||
|
'fleet_leaved_time',
|
||||||
|
];
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user