Compare commits

...

405 Commits

Author SHA1 Message Date
516105c492 composer updates 2020-12-21 11:07:01 +00:00
e7b3093986 composer update 2020-12-21 11:01:29 +00:00
064cd2244b laravel rollback 2020-12-21 19:35:33 +09:00
b0bf2a107b composer update 2020-12-21 19:24:33 +09:00
09413522bb composer update 2020-12-06 10:28:55 +00:00
69d92960d9 blacklist updates 2020-12-04 06:57:20 -06:00
3f5ce7dbf4 blacklist modifications and moon admin new stuff 2020-12-04 06:55:48 -06:00
76658b85f1 list updated for flex structures 2020-11-30 11:25:28 -06:00
cbf2c3f9e4 flex structure removal 2020-11-09 04:23:50 -06:00
120c0808bb flex structure removal 2020-11-09 04:22:26 -06:00
e6ac3e9056 modified remove flex structure 2020-11-09 04:20:53 -06:00
52be26a099 modified remove flex structure 2020-11-09 04:17:34 -06:00
c75107e34a flex structure deletion 2020-11-09 04:09:50 -06:00
05c613bf61 flex structure deletion issue 2020-11-09 03:33:18 -06:00
5528a0e024 item prices update 2020-10-03 04:33:07 -05:00
98e69fcc25 item prices update 2020-10-03 04:32:28 -05:00
d3f33979e4 blacklist fix 2020-09-29 00:01:28 -05:00
46ee5cf3b1 moon calc library 2020-09-14 00:18:47 -05:00
7c72944d7d moon stuff 2020-09-13 23:59:59 -05:00
f665050d66 moon update pricing 2020-09-13 23:30:34 -05:00
393a412784 gas moon price stuff 2020-09-13 23:18:41 -05:00
30e859b552 moon calc 2020-09-13 22:47:11 -05:00
a70c0bf4e9 moon calc library 2020-09-13 22:43:00 -05:00
e745502542 update moon rental pricing 2020-09-13 21:48:46 -05:00
55acc5e487 added log info for updating rental prices 2020-09-13 21:38:58 -05:00
c0d2348fc3 added log info for updating rental prices 2020-09-13 21:33:44 -05:00
e5a225a687 moon calc changes 2020-09-13 21:01:07 -05:00
257a6e3eb6 moon price update stuff 2020-09-13 20:54:34 -05:00
7b5268f0a3 pricing for moons where moon goo is priced at half the value 2020-09-12 17:06:56 -05:00
b6fcbd1b4a updated srp form stuff 2020-09-07 05:14:30 -05:00
c19b417a5d rental updates 2020-09-03 01:55:41 -05:00
94307d105d rental admin controller 2020-09-03 01:54:06 -05:00
16e5a9808b rental admin controller 2020-09-03 01:53:06 -05:00
2239ec16a8 rental admin controller 2020-09-03 01:51:51 -05:00
0e6109c09a blacklist update to add removal notes 2020-08-30 07:52:11 -05:00
a242bffb28 moon blade for sidebar to allow others to see rental moons 2020-08-26 22:41:49 -05:00
6717cbad48 updated structure request redirect 2020-08-18 19:32:22 -05:00
b7762cc18d fixed structure request form hopefully. 2020-08-14 22:48:36 -05:00
6ee0d8fef1 structure request controller was missing a namespace it needed. 2020-08-14 22:40:17 -05:00
58ef54e859 created a new job 2020-08-12 03:58:14 -05:00
076079f981 created a new job 2020-08-12 03:50:04 -05:00
22d0171e13 created a new job 2020-08-12 03:48:58 -05:00
12b6f8b98c created a new job 2020-08-12 03:43:50 -05:00
978a028553 adjusted the moon calc database functions 2020-08-12 03:35:12 -05:00
685dabede3 item updates weren't working for whatever reason 2020-08-12 03:33:00 -05:00
b7bfe880f4 item updates weren't working for whatever reason 2020-08-12 03:32:06 -05:00
72502ae53f add form for system rentals 2020-08-12 03:02:04 -05:00
5688f6ebb8 add form for system rentals 2020-08-12 02:57:39 -05:00
b916d0364c add form for system rentals 2020-08-12 02:56:47 -05:00
15ec617fec add form for system rentals 2020-08-12 02:46:32 -05:00
cd7428e3c3 add form for system rentals 2020-08-12 02:44:34 -05:00
6023f9801f add form for system rentals 2020-08-12 02:44:10 -05:00
5dad7a0427 add form for system rentals 2020-08-12 02:29:25 -05:00
d156c69992 add form for system rentals 2020-08-12 02:28:25 -05:00
82c755409d add form for system rentals 2020-08-12 02:27:25 -05:00
2f7aee4aad add form for system rentals 2020-08-12 02:25:48 -05:00
1824deecae add form for system rentals 2020-08-12 02:23:46 -05:00
2d5a1194bf blade fix for system rentals 2020-08-12 02:17:14 -05:00
e936fc721e namespace fix 2020-08-12 02:15:58 -05:00
4ba1dd8a11 namespace fix 2020-08-12 02:15:00 -05:00
716371200b namespace issue 2020-08-12 02:13:46 -05:00
ed7e2c9bb4 system rentals pages 2020-08-12 02:12:49 -05:00
57fbc092c8 rental system web routes 2020-08-12 02:11:21 -05:00
5fd183f95c created form for rental costs similar to flex structures 2020-08-10 02:17:21 -05:00
8dd1377090 changed journal entries to 2 months rather than 1 month. 2020-08-09 23:41:11 -05:00
bb63f9697e supply chain controller 2020-08-07 14:23:48 -05:00
99f63627b2 supply chain controller 2020-08-07 14:21:40 -05:00
a50182b1e5 supply chain controller 2020-08-07 14:19:51 -05:00
d5c57aca1c supply chain controller 2020-08-07 14:18:39 -05:00
273cb2b775 supply chain controller 2020-08-07 14:16:56 -05:00
ec315dc63f supply chain controller 2020-08-07 14:14:58 -05:00
4c0126bf4b supply chain controller 2020-08-07 14:12:45 -05:00
40135f5861 supply chain controller 2020-08-07 14:11:20 -05:00
76cbe6a073 supply chain controller 2020-08-07 13:57:27 -05:00
a08959980a supply chain controller 2020-08-07 13:55:16 -05:00
4e1a454d4e supply chain controller 2020-08-07 13:54:46 -05:00
eef0d65d44 supply chain controller 2020-08-07 13:50:52 -05:00
bb84b15f3b supply chain controller 2020-08-07 13:50:16 -05:00
0f108a709c supply chain controller 2020-08-07 13:40:24 -05:00
eb6c1c7c3b supply chain controller 2020-08-07 13:33:13 -05:00
bb026d2cd9 updated supply chain contract controller 2020-08-07 13:31:00 -05:00
955e494e05 closed supply chain contract labeling on the dashboard 2020-08-07 12:35:37 -05:00
7d07bde52c removed debugging line in blade 2020-08-07 12:34:25 -05:00
8a7e84ebb8 delete supply chain contract 2020-08-07 12:32:52 -05:00
075ec5f6bf redirect after storing bid. 2020-08-07 12:31:21 -05:00
aa0d510b05 open contracts blade file 2020-08-07 12:28:43 -05:00
0962ffb372 open contracts 2020-08-07 12:26:21 -05:00
ea75ac6d25 open contracts 2020-08-07 12:23:36 -05:00
d0c16d60cd open contracts 2020-08-07 12:19:56 -05:00
fdebf19a26 changed form to button only and updated web routes 2020-08-07 12:18:33 -05:00
6367b1593d changed form to button only and updated web routes 2020-08-07 12:18:01 -05:00
7c9e5e8491 troubleshooting supply chain contracts 2020-08-07 12:12:16 -05:00
9e90e785a3 fixed includes for supply chain contract blades 2020-08-07 12:07:58 -05:00
0474936bfc stuff 2020-08-07 12:05:13 -05:00
430432a18b supply chain contract controller 2020-08-07 12:01:22 -05:00
9d45b67c73 new supply chain contract mail 2020-08-07 11:59:58 -05:00
3bd7b9c2fd fixed new contract blade 2020-08-07 11:56:46 -05:00
3b5952cd44 fixed new contract blade 2020-08-07 11:55:22 -05:00
910e32809f added migration to drop wormhole tables 2020-08-07 11:19:37 -05:00
c888741aef removed several things including wormholes which weren't being utilized at all 2020-08-07 10:38:47 -05:00
8f74542371 updated rental moon mail 2020-08-04 02:44:41 -05:00
e86e7f62d3 updated request moon blade to show dy-p 2020-08-02 14:06:16 -05:00
9054c47777 updated request moon blade to show dy-p 2020-08-02 14:05:07 -05:00
735ca514bc adjusted the structure request mail delay 2020-08-02 13:41:36 -05:00
f008087b71 removed contract stuff from admin dashboard 2020-08-02 13:32:16 -05:00
3f510e40e7 moons controller 2020-08-02 13:29:50 -05:00
03f00518c3 issue with modify user page 2020-08-01 06:09:02 -05:00
c512629637 issue with modify user page 2020-08-01 06:06:36 -05:00
c38ffd3643 modified people to be able to see rental moon stuff with a permission 2020-08-01 06:02:21 -05:00
4f8c08011a added mail to be sent to Minerva and Rock about moon requests being entered into the system. 2020-08-01 05:05:42 -05:00
d476978cde create command to replace item compositions from sde file 2020-07-29 02:25:33 -05:00
b32812217b removed wiki from the navbar 2020-07-26 01:16:01 -05:00
8cf4c98633 commands and job 2020-07-26 01:14:22 -05:00
cf98e875ee modified add allowed login. 2020-07-23 22:25:32 -05:00
427759a98e modified open and closed contract blades 2020-07-22 01:45:02 -05:00
b537aa6ea1 modified open and closed contract blades 2020-07-22 01:39:34 -05:00
c079ae3c60 added buttons to dashboard for supply chain contracts 2020-07-22 01:31:27 -05:00
4043037d87 added buttons to dashboard for supply chain contracts 2020-07-22 01:22:37 -05:00
9a9b71f479 added buttons to dashboard for supply chain contracts 2020-07-22 01:21:56 -05:00
77429e2013 added buttons to dashboard for supply chain contracts 2020-07-22 01:13:18 -05:00
7e8ae3ab68 added buttons to dashboard for supply chain contracts 2020-07-22 01:12:25 -05:00
838aa1612a added buttons to dashboard for supply chain contracts 2020-07-22 01:10:09 -05:00
204a6c10dc added buttons to dashboard for supply chain contracts 2020-07-22 01:09:26 -05:00
936a8831fa added buttons to dashboard for supply chain contracts 2020-07-22 01:07:25 -05:00
7c86d0d9df added buttons to dashboard for supply chain contracts 2020-07-22 01:06:01 -05:00
60814f7c1c added buttons to dashboard for supply chain contracts 2020-07-22 01:03:25 -05:00
f4a193ec91 created supply chain contract end command and job 2020-07-21 23:38:16 -05:00
686ff34a11 modified nav bar for supply chain contracts 2020-07-21 23:36:09 -05:00
00ac338981 updated routes and browser links 2020-07-21 01:43:10 -05:00
b9af1cb074 updated routes and browser links 2020-07-21 01:42:28 -05:00
8c885636de updated routes and browser links 2020-07-21 01:23:46 -05:00
b114a16bed updated routes and browser links 2020-07-21 01:23:29 -05:00
a096edb88f updated routes and browser links 2020-07-21 01:21:30 -05:00
890c805f37 updated routes and browser links 2020-07-21 01:20:14 -05:00
9fe794543e fixed typo 2020-07-20 22:50:01 -05:00
bda6d5bdee added ability to add B, M, b, or m for bids text box on the form. 2020-07-20 22:49:11 -05:00
997d29c88a supply chain stuff 2020-07-20 06:46:54 -05:00
2d2395a97d supply chain coding 2020-07-10 03:44:33 -05:00
cc04244df8 supply chain stuff 2020-07-09 02:14:55 -05:00
fd21d72887 supply chain contracts views 2020-07-08 03:19:16 -05:00
52ae227085 past contract stuff 2020-06-29 00:33:36 -05:00
e264f23237 past contract stuff 2020-06-29 00:33:07 -05:00
854438a2ee past contract stuff 2020-06-29 00:32:39 -05:00
9fc304040a past contracts for nav bar on admin dashboard menu 2020-06-29 00:32:04 -05:00
bf5748d58e past contracts for nav bar on admin dashboard menu 2020-06-29 00:27:16 -05:00
e9ed06dbf3 past contracts for nav bar on admin dashboard menu 2020-06-29 00:26:14 -05:00
510fe5257a past contracts for nav bar on admin dashboard menu 2020-06-29 00:25:14 -05:00
9b4e2fabfa past contracts for nav bar on admin dashboard menu 2020-06-29 00:24:51 -05:00
0dae280d9f past contracts for nav bar on admin dashboard menu 2020-06-29 00:24:17 -05:00
75e20fb5d9 past contracts for nav bar on admin dashboard menu 2020-06-29 00:22:51 -05:00
0c1174d113 past contracts for nav bar on admin dashboard menu 2020-06-29 00:22:12 -05:00
50ddedb652 past contracts for nav bar on admin dashboard menu 2020-06-29 00:01:47 -05:00
4a39921355 past contracts 2020-06-29 00:00:29 -05:00
5fb5503d3e past contracts 2020-06-28 23:59:27 -05:00
c50bbe8c25 contract re-work 2020-06-28 15:06:50 -05:00
dd82f8cb8b contract re-work 2020-06-28 15:06:25 -05:00
d2570cec55 mailing list change for contracts 2020-06-28 02:22:35 -05:00
01435c6cea mail formatting issue 2020-06-27 20:02:33 -05:00
ddf7ec0c27 modify user role 2020-06-27 12:17:00 -05:00
400b777484 modify user role 2020-06-27 12:16:30 -05:00
fbbd4409d0 black list update 2020-06-27 11:41:36 -05:00
37865e134c moons admin controller coloring for moon rentals 2020-06-23 22:58:50 -05:00
e010cf1327 new moon stuff 2020-06-23 11:00:09 -05:00
da5d642505 moon testing 2020-06-23 00:13:52 -05:00
1f1c001fde moon testing 2020-06-22 23:51:06 -05:00
fc5261a645 moon testing 2020-06-22 22:43:32 -05:00
4c3da5c4b1 moon testing 2020-06-22 22:28:15 -05:00
163c57c600 moon testing 2020-06-22 22:27:21 -05:00
545a691387 color issues 2020-06-22 21:05:42 -05:00
f8a77b7c29 color issues 2020-06-22 20:48:33 -05:00
f2c3507355 color issues 2020-06-22 20:46:39 -05:00
6cbe808b89 color issues 2020-06-22 20:46:01 -05:00
bed71908ae alliance moon testing 2020-06-22 20:39:27 -05:00
5a48e6af32 alliance moon testing 2020-06-22 20:36:31 -05:00
4c8e9d58fd alliance moon testing 2020-06-22 20:35:35 -05:00
31d79bcc32 alliance moon testing 2020-06-22 20:33:23 -05:00
db91d9410c alliance moon testing 2020-06-22 20:30:53 -05:00
405a785b65 alliance moon testing 2020-06-22 20:25:20 -05:00
6994cb1e94 alliance moon testing 2020-06-22 20:22:50 -05:00
49e1ec3638 update for troubleshooting 2020-06-22 20:18:31 -05:00
60d47747ba navbar fix 2020-06-17 21:58:45 -05:00
375b121eb8 request rental moon page 2020-06-09 23:41:53 -05:00
27939b153f navigation issue 2020-06-07 22:18:15 -05:00
18d1eee592 added market to flex structures to keep track of. 2020-06-07 00:05:53 -05:00
284c81a2e1 rental moon testing 2020-06-06 04:55:02 -05:00
13be193591 rental moon testing 2020-06-06 04:49:22 -05:00
ecaa9f8e86 rental moon testing 2020-06-06 04:47:13 -05:00
2f09747222 rental moon testing 2020-06-06 04:43:16 -05:00
cc0f7427b3 rental moon testing 2020-06-06 04:42:30 -05:00
87a7b255ce rental moon testing 2020-06-06 04:41:11 -05:00
f01e25a9c2 rental moon testing 2020-06-06 04:40:17 -05:00
a36eaee54e rental moon testing 2020-06-06 04:39:55 -05:00
0b06fea8ac rental moon testing 2020-06-06 04:39:16 -05:00
57ee594dd0 rental moon testing 2020-06-06 04:16:49 -05:00
9fb94f1fd4 rental moon testing 2020-06-06 04:12:12 -05:00
3c8ac639f8 rental moon testing 2020-06-06 04:11:29 -05:00
99f12b493b rental moon testing 2020-06-06 04:11:01 -05:00
8008fac0ff rental moon testing 2020-06-06 04:08:34 -05:00
c56dde238d rental moon testing 2020-06-06 04:08:02 -05:00
a5ff733311 rental moon testing 2020-06-06 04:06:16 -05:00
3d6a2a67ad rental moon testing 2020-06-06 04:04:27 -05:00
1717cd9d3b rental moon testing 2020-06-06 04:02:30 -05:00
d9619f17d0 rental moon testing 2020-06-06 04:01:51 -05:00
6f3d9fd7ff rental moon testing 2020-06-06 04:00:40 -05:00
9c53f969e6 rental moon testing 2020-06-06 03:59:39 -05:00
8211de1954 moon testing 2020-06-06 03:34:46 -05:00
cfcebf8b73 created a job for updating rental moon pull. may need to add constraints to it. 2020-06-06 03:23:18 -05:00
99cec351ec rental moon testing 2020-06-05 23:29:42 -05:00
9a56ffb829 moon testing 2020-06-05 04:53:25 -05:00
a54c8ed9a4 rental moon testing 2020-06-05 03:15:26 -05:00
29ef5527a9 rental moon testing 2020-06-05 03:13:31 -05:00
b073e6fac7 rental moon testing 2020-06-05 03:11:33 -05:00
3b64aaca66 rental moon testing 2020-06-05 03:00:59 -05:00
7cc3788f77 rental moon testing 2020-06-05 02:19:30 -05:00
dcaa848b0f rental moon testing 2020-06-05 02:09:44 -05:00
3b29dd2a91 rental moon testing 2020-06-05 01:59:53 -05:00
90d8245ab2 rental moon testing 2020-06-05 01:59:00 -05:00
d1308b6908 rental moon testing 2020-06-05 01:54:53 -05:00
1d875f2ce1 rental moon testing 2020-06-05 01:43:02 -05:00
6e95e7dd06 rental moon testing 2020-06-05 01:42:28 -05:00
4ff5a0b0a8 rental moon testing 2020-06-05 01:41:22 -05:00
b9aab0981e rental moon testing 2020-06-05 01:35:49 -05:00
41c9e22121 rental moon testing 2020-06-05 01:34:12 -05:00
b6f0da41e8 rental moon testing 2020-06-05 01:16:53 -05:00
60604f208c rental moon testing 2020-06-05 01:06:08 -05:00
f0650c2c29 rental moon testing 2020-06-05 01:04:51 -05:00
b82afbbb14 rental moon testing 2020-06-05 01:03:21 -05:00
c729b33852 rental moon testing 2020-06-04 23:43:37 -05:00
26df4f4875 rental moon testing 2020-06-04 23:42:42 -05:00
09ce007f9a rental moon testing 2020-06-04 23:42:19 -05:00
a2d17fcd2a rental moon testing 2020-06-04 23:38:33 -05:00
56762f42af modified migration for alliance rental moons 2020-06-04 23:35:07 -05:00
dbbe8139b7 store update moon function 2020-06-04 03:29:10 -05:00
af9a8e955b store update moon function 2020-06-04 03:28:59 -05:00
9b7eb27e01 removed files and transferred others to the new system. this is going to break so much shit. 2020-06-03 22:33:44 -05:00
cde4f3b6c7 rental moon stuffs 2020-06-03 22:26:48 -05:00
7e248c7055 created rental moons command as a placeholder 2020-06-03 04:33:31 -05:00
d70ec78cae removed moon stuff from console kernel 2020-06-03 04:32:36 -05:00
cb0fcbc582 removed moon stuff from console kernel 2020-06-03 04:32:03 -05:00
3b11dae932 created send moon rental payment reminder job 2020-06-03 04:30:25 -05:00
aec0671b4a created outline for payment reminder 2020-06-01 03:07:17 -05:00
6853ae9881 created outline for payment reminder 2020-06-01 02:50:28 -05:00
14b59ed418 created outline for payment reminder 2020-06-01 02:50:08 -05:00
f83f908cfa wrote job for updating moon rental paid states 2020-06-01 02:42:57 -05:00
3243bb8702 update moon rental paid state job 2020-05-29 22:06:12 -05:00
bff5dbef07 laid out framework for updating moon rental price, and moved some functions around in the moon calculation library 2020-05-29 01:41:52 -05:00
eb88bc7950 rewrite of the rental moon module 2020-05-28 05:06:40 -05:00
ef86ba749d rewrite of the rental moon module 2020-05-28 04:39:07 -05:00
8a21604adb removed old navbar and bootstrap template from the user layouts and the admin layouts 2020-05-28 00:02:10 -05:00
0cde363e96 layout cleanup 2020-05-27 05:09:28 -05:00
246c691ad5 navbar stuff 2020-05-27 05:02:47 -05:00
85b3f74741 fixed navbar stuff 2020-05-27 04:59:52 -05:00
2e356404f9 kernel 2020-05-27 04:51:57 -05:00
d0876e9411 commands data purge corp moon ledgers class 2020-05-27 04:47:35 -05:00
bc29df33b5 kernel 2020-05-27 04:46:13 -05:00
84e600fa52 updates for job connections 2020-05-27 04:33:05 -05:00
685681617c stuff 2020-05-27 03:57:23 -05:00
14acf05c03 stuff 2020-05-27 03:54:54 -05:00
9b74fd45a2 cut short 2020-05-27 03:53:47 -05:00
61f5467c65 model update 2020-05-27 03:50:02 -05:00
15f420ffe8 migrations 2020-05-27 03:48:42 -05:00
e6c6baeb8f migration update 2020-05-27 03:46:40 -05:00
5874e88ee0 fetch moon ledger job 2020-05-27 03:44:16 -05:00
765072e413 fetch moon ledger job 2020-05-27 03:43:00 -05:00
2e3468fe74 fetch moon ledger job 2020-05-27 03:42:40 -05:00
cce69f79c0 fetch moon ledger job 2020-05-27 03:36:14 -05:00
562802ec56 stuff 2020-05-27 03:24:42 -05:00
e052d624f4 stuff 2020-05-27 03:24:00 -05:00
e7424b9272 structure helper stuff 2020-05-27 03:22:43 -05:00
128172b597 update job 2020-05-27 03:04:25 -05:00
911d69044a changed structure helper function from private to public 2020-05-27 03:01:01 -05:00
9696a15e02 rental moon ledgers table 2020-05-27 02:59:14 -05:00
a70f45938a rental moon ledgers table 2020-05-27 02:55:02 -05:00
5f3639e945 fetch moon observer job 2020-05-27 02:49:39 -05:00
7ea6735167 fetch moon observers job 2020-05-27 01:23:35 -05:00
c736d1d4bf fetch moon observers job 2020-05-27 01:22:14 -05:00
580968a4a3 fetch moon observers job 2020-05-27 01:21:31 -05:00
75c3705fb0 fetch moon observers job 2020-05-27 01:21:00 -05:00
9fe4b47349 fetch moon observers job 2020-05-27 01:20:24 -05:00
419f529a29 fetch moon observers job 2020-05-27 01:18:40 -05:00
7438545e29 modified fetch moon observer job 2020-05-27 01:16:35 -05:00
43b3357834 modified fetch moon observer job 2020-05-27 01:15:48 -05:00
4c89da8248 modified the fetch moon observer job to disregard the structure library helper 2020-05-27 01:11:56 -05:00
9175fac141 modified some database table migrations 2020-05-27 01:08:17 -05:00
fde062134d removed a database I don't have plans for yet. 2020-05-27 01:07:18 -05:00
4c72b585c6 removed a database I don't have plans for yet. 2020-05-27 01:04:23 -05:00
b98820b7c9 fixed typo in moonupdatecommand.php 2020-05-27 00:59:24 -05:00
8b4ee2315c fixed typo in moonupdatecommand.php 2020-05-27 00:57:59 -05:00
3a994fdcde fixed typo in moonupdatecommand.php 2020-05-27 00:57:13 -05:00
297304e176 fixed typo in moonupdatecommand.php 2020-05-27 00:56:10 -05:00
01f18e6dfc fixed a task status description for update moon pricing. 2020-05-27 00:52:22 -05:00
48c52f14e3 reconfigured the sidebar menu system to just run include files 2020-05-25 04:29:33 -05:00
817108aaf1 number formatting on dashboard stuff 2020-05-24 23:30:05 -05:00
c3a390c28d modified entrance page to only show srp if the person is in Warped Intentions. 2020-05-24 23:26:02 -05:00
6142eb9ba5 modified admin moon blade to include number formatting back in correctly 2020-05-24 20:39:24 -05:00
66dab8c1b8 fixed an issue with the esi variable for get structure info in StructureHelper 2020-05-23 23:19:29 -05:00
5da41d4d04 removed some market stuff for the time being from the console commands 2020-05-23 23:12:07 -05:00
d25d566790 fixed a number formatting issue for display rental moons 2020-05-23 22:57:31 -05:00
fc01cbc636 fixed a formatting issue 2020-05-23 22:57:11 -05:00
a3a8def860 modified public contracts controller 2020-05-15 04:07:59 -05:00
b2bba1bf5f added new commands to the console kernel 2020-05-15 03:55:54 -05:00
5b959f9d6a modified the get market data command
created the purge market data command
modified the public contracts command
2020-05-15 03:53:22 -05:00
77a6e6b688 created get public contracts command 2020-05-15 03:36:13 -05:00
7abd2dece9 created public contracts command and get market data command 2020-05-15 03:00:39 -05:00
d08e6f5f8f created the command for get eve regions for artisan 2020-05-15 02:57:51 -05:00
32e17c30eb setup the get eve regions command 2020-05-15 02:52:36 -05:00
5b746a3e22 removed market group model
removed market price model
added command for GetEveRegions to be able to get all of the eve regional data into the database from time to time.
2020-05-15 02:51:46 -05:00
a84ea90c79 created get market region order job
created purge market region order job to get rid of old useless data
removed market price and market group from database tables
2020-05-15 02:50:52 -05:00
fbd7c37ccf created job for market groups 2020-05-15 01:31:38 -05:00
7f1fa7c101 created get eve regions job 2020-05-14 23:01:48 -05:00
7f5c40b996 created model for eve regions 2020-05-14 22:25:13 -05:00
5d12167324 modified public contracts to show the region the public contract is in. 2020-05-14 22:15:35 -05:00
2a08fd71a2 created relationships for public contract jobs and models 2020-05-14 22:10:28 -05:00
774d8b866e wrote the get public contract items job 2020-05-14 04:16:26 -05:00
e2db5ea804 create get public contracts job 2020-05-14 04:08:46 -05:00
5e435bdf1a created framework for market orders and public contracts 2020-05-14 03:51:58 -05:00
47b0949290 creating the moon rental invoice verify 2020-05-12 02:04:30 -05:00
50441d6152 added creation of invoice id to create invoice job 2020-05-12 00:49:18 -05:00
3230e2fec0 function was misspelled 2020-05-11 06:54:51 -05:00
39c934cdbe added invoice creation for the database to moon rental invoice 2020-05-11 01:12:10 -05:00
c6ad585d49 added invoice creation for the database to moon rental invoice 2020-05-11 01:11:13 -05:00
a3b712d709 updated commands for kernel for console 2020-05-11 00:22:36 -05:00
1b811aacdd deleted 2 migrations I am not ready to program on yet. 2020-05-11 00:03:37 -05:00
c4c52af1d3 removed eve mail library as it wasn't utilized 2020-05-11 00:02:11 -05:00
11cf735961 removed configuration of null cache from eve mail helper 2020-05-11 00:00:54 -05:00
ab9f6e5b52 removed job models for eve mail as it's no longer needed. updated all functions to the new programming method 2020-05-11 00:00:13 -05:00
da39f990a5 process wallet journal job model removed 2020-05-10 23:35:04 -05:00
806b872465 removed model for process structure job 2020-05-10 23:25:06 -05:00
6f00ffe0e8 removed job model for corp journal as it was never used 2020-05-10 23:17:57 -05:00
7217b5aeec removed model for asset job 2020-05-10 23:17:13 -05:00
307741a0e1 removed model for asset job 2020-05-10 23:17:00 -05:00
ad6a90d623 updated assets in order to not use a model to get rid of extra models that we don't need 2020-05-10 23:13:05 -05:00
7a89b65b15 moons update command written 2020-05-10 23:05:23 -05:00
cea92f1c70 added uses to moonupdatecommand 2020-05-10 22:40:29 -05:00
f9676665de kernel updates for comamnds 2020-05-10 22:37:58 -05:00
acb55a1ecb update 2020-05-10 22:32:03 -05:00
95a4636414 update 2020-05-10 22:29:26 -05:00
67f751f8d5 update 2020-05-10 22:28:24 -05:00
79b43acc40 update 2020-05-10 22:26:12 -05:00
719f54f90a update 2020-05-10 22:25:47 -05:00
1525d1095c removed and unneeded function from moon mailer command 2020-05-10 22:24:30 -05:00
f3e3406e04 updated rental moon command with the correct job calls in the right order
updated the horizon redis configuration to add new processes and a new job queue called moons for the new moon rental coding
2020-05-10 22:22:26 -05:00
08844a50f7 updated delays for jobs 2020-05-10 21:52:04 -05:00
524f2051ea modified namespace for commands being done 2020-05-10 19:29:09 -05:00
cd7f6f4876 modified namespace for commands being done 2020-05-10 19:28:45 -05:00
e855350b7f finished the purge moon ledger job 2020-05-10 19:16:37 -05:00
50b2e91ec6 created new job to purge old moon ledger records 2020-05-10 18:57:24 -05:00
b7291a93b7 created the job for fetch moon ledger 2020-05-10 18:46:58 -05:00
1d19732eeb created new migration for future projects 2020-05-10 17:48:16 -05:00
09f9e39e8b removed some unneeded extra lines for formatting 2020-05-10 17:06:25 -05:00
16f808ae53 updated solar system name functions in structure helper. added new functions to lookup helper. 2020-05-10 17:04:08 -05:00
b01bb72c1d cleaned up unused functions in the srp helper. 2020-05-10 16:38:16 -05:00
b8b01e87d1 cleaned up some functions in the MoonCalc Library. 2020-05-10 16:22:19 -05:00
40e18ccb7a fetch rental moon ledger and observer updates along with starting moon rental invoice job. up next is moon rental payment job. 2020-05-10 05:11:50 -05:00
8e93eececf composer update 2020-05-10 09:29:56 +00:00
c6f807ebad more work on rental moon ledgers 2020-05-10 04:23:49 -05:00
db6876cdca created jobs and command for processing moon rental payments 2020-05-09 12:44:40 -05:00
7df8a0e6ef deleted unnecessary line 2020-05-09 12:42:46 -05:00
cf56300676 cleaned up unnecessary commands as they got switched to working as jobs.
updated the structure library to be able to be passed the esi connection
added new jobs for the fetch stuff that was being previously done as commands.
2020-05-09 12:40:16 -05:00
1f3954cfe0 added new models and migrations for automatic tracking of moon rental payments 2020-05-09 12:26:40 -05:00
9c7dbbf1ba added some stuff into the callback middleware for testing. 2020-05-09 11:06:29 -05:00
15f60534f1 removed names from some routes, as they aren't needed. 2020-05-09 10:53:02 -05:00
6ef087b841 removed trim strings middleware from affecting passwords and password confirmations as those aren't used for login 2020-05-09 10:50:03 -05:00
6506c11ec1 removed callback middleware from taking affect 2020-05-09 10:48:55 -05:00
b56850956b added place holder function for the new moon ledger display function. 2020-05-09 10:45:53 -05:00
96a2fb1c3e created function for registering structures which should only be accessible by those with the correct scope. 2020-05-09 10:37:03 -05:00
f501514aa2 re-added esi scopes back to the navigation bar 2020-05-09 09:24:12 -05:00
5607763fd4 added model for registered corp mining observers 2020-05-09 09:11:59 -05:00
cf00909444 added new namespaces for all of the commands 2020-05-09 08:59:01 -05:00
09e56371e6 rental moon ledger and observer command 2020-05-09 08:07:22 -05:00
cf1d121fb3 fixed some issues on moon total worth 2020-05-08 01:06:36 -05:00
b00fd7d177 fixed some issues on moon total worth 2020-05-08 01:04:26 -05:00
59c29e3a40 fixed some issues on moon total worth 2020-05-08 01:03:20 -05:00
a493043aa4 fixed some issues on moon total worth 2020-05-08 01:02:02 -05:00
9d54cc06a1 fixed some issues on moon total worth 2020-05-08 00:59:31 -05:00
5f23fa3a19 wiki update 2020-05-07 01:58:34 -05:00
ace2648480 some poor fuck in Bolivia 2020-05-07 01:56:57 -05:00
aa3a2811e9 purge wiki button update 2020-05-07 01:49:38 -05:00
5859db3f67 purge wiki button update 2020-05-07 01:48:32 -05:00
d3ee45da2b purge wiki button update 2020-05-07 01:47:54 -05:00
1a277a7881 purge wiki button update 2020-05-07 01:46:54 -05:00
e0f83179fd purge wiki button update 2020-05-07 01:46:04 -05:00
3c50143dd4 wiki user group testing 2020-05-07 01:27:10 -05:00
cc4c01be6d wiki user group testing 2020-05-07 01:25:42 -05:00
125b2aed97 wiki user group testing 2020-05-07 01:22:22 -05:00
dd6c235df8 wiki user group testing 2020-05-07 01:17:20 -05:00
902fde2467 wiki user group testing 2020-05-07 01:16:30 -05:00
9561a076d7 added mining observers table
added corp observers table
added alliance rental moon ledgers
added corp moon ledgers table
modified wiki stuff groups
2020-05-07 01:13:18 -05:00
d796512f6a rental ledger 2020-05-06 22:21:52 -05:00
e3905253b7 included messages 2020-05-04 21:33:38 -05:00
6887b3c135 included messages 2020-05-04 21:31:09 -05:00
7a23437a87 menu options for navigation menu 2020-05-04 21:29:47 -05:00
a19bf7eac1 menu options for navigation menu 2020-05-04 21:28:19 -05:00
c1d7c53d57 menu options for navigation menu 2020-05-04 21:24:23 -05:00
7f81830ae8 flex structure mailer issue 2020-05-03 23:39:19 -05:00
5b64bd910a flex structure mailer issue 2020-05-03 23:37:55 -05:00
c578512188 flex structure mailer 2020-05-03 23:36:06 -05:00
73abaa1f66 updated navigation menu font icons 2020-04-29 22:53:18 -05:00
4bf274196e updated navigation menu font icons 2020-04-29 22:52:27 -05:00
4ea3064a37 updated navigation menu font icons 2020-04-29 22:48:08 -05:00
c1785a4618 updated navigation menu font icons 2020-04-29 22:42:18 -05:00
6528b15449 updated navigation menu font icons 2020-04-29 22:36:01 -05:00
01c3f52d62 updated navigation menu font icons 2020-04-29 22:35:02 -05:00
538f4a9ea6 updated navigation menu font icons 2020-04-29 22:33:19 -05:00
e1e67f47ec updated user side of the site with the new dashboard layout and menu navigation layout. 2020-04-29 21:31:33 -05:00
2644 changed files with 77998 additions and 71068 deletions

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Assets;
use Illuminate\Console\Command;
use DB;
@@ -15,9 +15,6 @@ use Commands\Library\CommandHelper;
use App\Library\Assets\AssetHelper;
use Seat\Eseye\Exceptions\RequestFailedException;
//Models
use App\Models\Jobs\JobProcessAsset;
class GetAssetsCommand extends Command
{
/**
@@ -93,11 +90,7 @@ class GetAssetsCommand extends Command
$pages = $assets->pages;
for($i = 1; $i <= $pages; $i++) {
$job = new JobProcessAsset;
$job->charId = $charId;
$job->corpId = $corpId;
$job->page = $i;
ProcessAssetsJob::dispatch($job)->onQueue('assets');
ProcessAssetsJob::dispatch($charId, $corpId, $i)->onQueue('assets');
}
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Corps;
//Internal Library
use Illuminate\Console\Command;

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Data;
//Internal Library
use Illuminate\Console\Command;
use Carbon\Carbon;
use Log;
//Library
use Commands\Library\CommandHelper;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Data;
//Internal Library
use Illuminate\Console\Command;

View File

@@ -1,29 +1,33 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Data;
//Internal Library
use Illuminate\Console\Command;
use Carbon\Carbon;
use Log;
//Models
use App\Models\Wormholes\AllianceWormhole;
//Library
use Commands\Library\CommandHelper;
class PurgeWormholes extends Command
//Jobs
use App\Jobs\Commands\Moons\PurgeMoonLedgerJob;
class PurgeCorpMoonLedgers extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'services:PurgeWormholeData';
protected $signature = 'data:PurgeCorpLedgers';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Purge stale wormhole data automatically';
protected $description = 'Purge old corp ledgers data';
/**
* Create a new command instance.
@@ -42,9 +46,11 @@ class PurgeWormholes extends Command
*/
public function handle()
{
//Time of now
$currentTime = Carbon::now();
$task = new CommandHelper('PurgeCorpLedgers');
$task->SetStartStatus();
AllianceWormhole::where('created_at', '<', $currentTime->subHours(48))->delete();
PurgeMoonLedgerJob::dispatch();
$task->SetStopStatus();
}
}

View File

@@ -1,28 +1,32 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Eve;
use Illuminate\Console\Command;
use Carbon\Carbon;
use Commands\Library\CommandHelper;
use Log;
//Library
use Commands\Library\CommandHelper;
use App\Library\Moons\MoonCalc;
class UpdateMoonPriceCommand extends Command
//Job
use App\Jobs\Commands\Eve\ItemPricesUpdateJob;
class ItemPricesUpdateCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'services:UpdateMoonPrice';
protected $signature = 'services:ItemPriceUpdate';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update moon pricing on a scheduled basis';
protected $description = 'Update mineral and ore prices';
/**
* Create a new command instance.
@@ -41,15 +45,14 @@ class UpdateMoonPriceCommand extends Command
*/
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 = new CommandHelper('ItemPriceUpdate');
$task->SetStartStatus();
$moonCalc = new MoonCalc();
$moonCalc->FetchNewPrices();
$moonHelper = new MoonCalc;
$moonHelper->FetchNewPrices();
//ItemPricesUpdateJob::dispatch()->onQueue('default');
//Mark the job as finished
$task->SetStopStatus();
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Files;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;

View File

@@ -0,0 +1,98 @@
<?php
namespace App\Console\Commands\Files;
//Internal Stuff
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
class UpdateItemCompositionFromSDECommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sde:update:ItemCompositions';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Updates item compositions from sql file.';
/**
* The SDE storage path
*
* @var
*/
protected $storage_path;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Query the sql file for the related database information
*
* @return mixed
*/
public function handle()
{
//Start by warning the user about the command which will be run
$this->comment('Warning! This Laravel command uses exec() to execute a ');
$this->comment('mysql shell command to import an extracted dump. Due');
$this->comment('to the way the command is constructed, should someone ');
$this->comment('view the current running processes of your server, they ');
$this->comment('will be able to see your SeAT database users password.');
$this->line('');
$this->line('Ensure that you understand this before continuing.');
//Test we have valid database parameters
DB::connection()->getDatabaseName();
//Warn the user about the operation to begin
if (! $this->confirm('Are you sure you want to update to the latest EVE SDE?', true)) {
$this->warn('Exiting');
return;
}
$fileName = $this->getSde();
$this->importSde($fileName);
}
/**
* Download the EVE Sde from Fuzzwork and save it
* in the storage_path/sde folder
*/
public function getSde() {
return $fileName;
}
/**
* Extract the SDE file downloaded and run the MySQL command to import the table into the database
*/
public function importSde($fileName) {
$import_command = 'mysql -u username -p password database < ' . $file;
//run the command
exec($import_command, $output, $exit_code);
if($exit_code !== 0) {
$this->error('Warning: Import failed with exit code ' .
$exit_code . ' and command outut: ' . implode('\n', $output));
}
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Finances;
use Illuminate\Console\Command;
use Log;
@@ -11,9 +11,6 @@ use App\Library\Finances\Helper\FinanceHelper;
//Jobs
use App\Jobs\ProcessWalletJournalJob;
//Models
use App\Models\Jobs\JobProcessWalletJournal;
class HoldingFinancesCommand extends Command
{
/**
@@ -64,11 +61,7 @@ class HoldingFinancesCommand extends Command
//Dispatch a single job for each page to process
for($i = 1; $i <= $pages; $i++) {
$job = new JobProcessWalletJournal;
$job->division = 1;
$job->charId = $config['primary'];
$job->page = $i;
ProcessWalletJournalJob::dispatch($job)->onQueue('journal');
ProcessWalletJournalJob::dispatch(1, $config['primary'], $i)->onQueue('journal');
}
//Get the total pages for the journal for the sov bills from the holding corporation
@@ -76,11 +69,7 @@ class HoldingFinancesCommand extends Command
//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');
ProcessWalletJournalJob::dispatch(6, $config['primary'], $i)->onQueue('journal');
}
//Mark the job as finished

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Finances;
use Illuminate\Console\Command;
use Log;
@@ -12,7 +12,6 @@ use App\Library\Finances\Helper\FinanceHelper;
use App\Jobs\ProcessWalletJournalJob;
//Models
use App\Models\Jobs\JobProcessWalletJournal;
use App\Models\Esi\EsiToken;
use App\Models\Esi\EsiScope;
@@ -103,15 +102,6 @@ class SovBillsCommand extends Command
//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");

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Flex;
//Internal Library
use Illuminate\Console\Command;
@@ -15,7 +15,6 @@ use Commands\Library\CommandHelper;
//Models
use App\Models\Flex\FlexStructure;
use App\Models\Mail\SentMail;
use App\Models\Jobs\JobSendEveMail;
class FlexStructureCommand extends Command
{
@@ -84,27 +83,23 @@ class FlexStructureCommand extends Command
//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 .= "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>";
$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);
$subject = "Warped Intentions Flex Structures Payment Due for " . $today->englishMonth;
ProcessSendEveMailJob::dispatch($body, (int)$structure->requestor_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
//Increment the delay for the mail to not hit the rate limits
$delay += 60;
//After the mail is dispatched, save the sent mail record
$this->SaveSentRecord($mail->sender, $mail->subject, $mail->body, $mail->recipient, $mail->recipient_type);
$this->SaveSentRecord($config['primary'], $subject, $body, (int)$structure->requestor_id, 'character');
}
//Mark the job as finished

View File

@@ -1,226 +0,0 @@
<?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';
}
}
}

View File

@@ -0,0 +1,90 @@
<?php
namespace App\Console\Commands\Moons;
//Internal Library
use Illuminate\Console\Command;
use Carbon\Carbon;
use Log;
//Jobs
use App\Jobs\Commands\Moons\FetchMoonLedgerJob;
use App\Jobs\Commands\Moons\FetchMoonObserverJob;
//Library
use Commands\Library\CommandHelper;
//Models
use App\Models\Esi\EsiScope;
class MoonsUpdateCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'services:MoonUpdate';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update all of the moons registered for observers and ledgers.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//Declare variables
$delay = 0;
$characters = array();
//Create the new command helper container
$task = new CommandHelper('MoonsUpdateCommand');
//Set the task start status
$task->SetStartStatus();
//Get all of the characters who have registered structures for moon ledgers
$miningChars = EsiScope::where([
'scope' => 'esi-industry.read_corporation_mining.v1',
])->get();
foreach($miningChars as $mChars) {
$universe = EsiScope::where([
'character_id' => $mChars->character_id,
'scope' => 'esi-universe.read_structures.v1',
])->first();
if($universe != null) {
array_push($characters, $universe->character_id);
}
}
//Cycle through each of the character Ids which have the correct scopes,
//and dispatch jobs accordingly.
foreach($characters as $charId) {
//Fetch all of the corp observers with the job dispatch
FetchMoonObserverJob::dispatch($charId);
//Fetch all of the corp ledgers with the job dispatch
FetchMoonLedgerJob::dispatch($charId);
}
//Set task done status
$task->SetStopStatus();
}
}

View File

@@ -0,0 +1,63 @@
<?php
namespace App\Console\Commands\RentalMoons;
//Internal Library
use Illuminate\Console\Command;
use Log;
use Carbon\Carbon;
//Library
use Commands\Library\CommandHelper;
//Jobs
use App\Jobs\Commands\RentalMoons\SendMoonRentalPaymentReminderJob;
use App\Jobs\Commands\RentalMoons\UpdateMoonRentalPaidState;
class AllianceRentalMoonInvoiceCreationCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'services:RentalInvoices';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Send out rental invoice reminders';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//Set the task as started
$task = new CommandHelper('AllianceRentalInvoice');
$task->SetStartStatus();
//Send the job for the invoice creation command
SendMoonRentalPaymentReminderJob::dispatch()->delay(Carbon::now()->addSeconds(10));
//Update the paid state for the moons
UpdateMoonRentalPaidState::dispatch()->delay(Carbon::now()->addSeconds(600));
//Set the task as stopped
$task->SetStopStatus();
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace App\Console\Commands\RentalMoons;
//Internal Library
use Illuminate\Console\Command;
use Log;
//Library
use Commands\Library\CommandHelper;
//Job
use App\Jobs\Commands\RentalMoons\UpdateMoonRentalPrice;
class AllianceRentalMoonUpdatePricingCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'services:UpdateRentalPrice';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update alliance rental moon prices.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//Setup the task handler
$task = new CommandHelper('AllianceRentalMoonPriceUpdater');
$task->SetStartStatus();
UpdateMoonRentalPrice::dispatch();
$task->SetStopStatus();
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Structures;
use Illuminate\Console\Command;
use Log;
@@ -15,7 +15,6 @@ use Seat\Eseye\Exceptions\RequestFailedException;
use App\Jobs\ProcessStructureJob;
//Models
use App\Models\Jobs\JobProcessStructure;
use App\Models\Esi\EsiScope;
use App\Models\Esi\EsiToken;
@@ -106,11 +105,7 @@ class GetStructuresCommand extends Command
$totalPages = $structures->pages;
for($i = 1; $i <= $totalPages; $i++) {
$job = new JobProcessStructure;
$job->charId = $charId;
$job->corpId = $corpId;
$job->page = $currentPage;
ProcessStructureJob::dispatch($job)->onQueue('structures');
ProcessStructureJob::dispatch($charId, $corpId, $currentPage)->onQueue('structures');
}
//Mark the job as finished

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Console\Commands\SupplyChain;
//Internal Library
use Illuminate\Console\Command;
use Log;
use Carbon\Carbon;
//Models
use App\Models\Contracts\SupplyChainContract;
//Job
use App\Jobs\Commands\SupplyChain\EndSupplyChainContractJob;
class EndSupplyChainContractCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'services:supplychain';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Checks and ends any supply chain contracts needs to be closed.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$today = Carbon::now();
//Get the supply chain contracts which are open, but need to be closed.
$contracts = SupplyChainContract::where([
'state' => 'open',
])->where('end_date', '>', $today)->get();
//Create jobs to complete each contract
foreach($contracts as $contract) {
EndSupplyChainContractJob::dispatch($contract)->onQueue('default');
}
}
}

View File

@@ -0,0 +1,133 @@
<?php
namespace App\Console\Commands\SystemRental;
//Internal Library
use Illuminate\Console\Command;
use Carbon\Carbon;
//Jobs
use App\Jobs\ProcessSendEveMailJob;
//Library
use Command\Library\CommandHelper;
//Models
use App\Models\Rentals\RentalSystem;
use App\Models\Mail\SentMail;
class SystemRentalCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'services:SystemRentals';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Mail out bill for system rentals.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//Create the new command helper container
$task = new CommandHelper('SystemRentalMailer');
//Add the entry into the jobs table saying the job has started
$task->SetStartStatus();
//Create other variables
$body = null;
$delay = 30;
//Get today's date
$today = Carbon::now();
$today->second = 2;
$today->minute = 0;
$today->hour = 0;
//Get the esi configuration
$config = config('esi');
//Get all of the contacts for the system rentals
$contacts = RentalSystem::select('contact_id')->orderBy('contact_id')->get();
//For each of the contacts send a reminder mail about the total of the systems they are paying for
foreach($contacts as $contact) {
//Get all of the systems
$systems = RentalSystem::where([
'contact_id' => $contact->contact_id,
])->get();
//Totalize the total cost of all of the systems
$totalCost = $this->TotalizeCost($systems);
//Build the body of the mail
$body = "System Rental Cost is due for the following systems:<br>";
foreach($systems as $system) {
$body .= $system->system_name . "<br>";
}
//Create the rest of the email body
$body .= "Total Cost: " . number_format($totalCost, 2, ".", ",");
$body .= "Please remite payment to White Wolves Holding.<br>";
$body .= "Sincerely,<br>";
$body .= "Warped Intentions Leadership<br>";
//Fill in the subject
$subject = "Warped Intentions System Rental Bill Due";
//Dispatch the mail job
ProcessSendEveMailJob::dispatch($body, (int)$contact->contact_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
//Increase the delay for the next mail job
$delay += 60;
//After the mail is dispatched, save the sent mail record
$this->SaveSentRecord($config['primary'], $subject, $body, (int)$contact->contact_id, 'character');
}
//Mark the job as finished
$task->SetStopStatus();
}
private function TotalizeCost($systems) {
//Declare the starting total cost
$totalCost = 0.00;
foreach($systems as $system) {
$totalCost += $system->rental_cost;
}
return $totalCost;
}
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
$sentmail = new SentMail;
$sentmail->sender = $sender;
$sentmail->subject = $subject;
$sentmail->body = $body;
$sentmail->recipient = $recipient;
$sentmail->recipient_type = $recipientType;
$sentmail->save();
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Users;
//Internal Library
use Illuminate\Console\Command;
@@ -9,6 +9,7 @@ use Log;
//Libraries
use Seat\Eseye\Exceptions\RequestFailedException;
use App\Library\Esi\Esi;
use App\Library\Wiki\WikiHelper;
//Models
use App\Models\User\User;
@@ -18,6 +19,8 @@ use App\Models\Esi\EsiToken;
use App\Models\User\UserPermission;
use App\Models\User\UserRole;
use App\Models\Admin\AllowedLogin;
use App\Models\Doku\DokuMember;
use App\Models\Doku\DokuUser;
/**
@@ -184,6 +187,13 @@ class PurgeUsers extends Command
EsiToken::where([
'character_id' => $user->character_id,
])->delete();
//Delete the user from the wiki
$wikiHelper = new WikiHelper;
//Get the uid from the wiki tables utilizing the character's name
$uid = DokuUser::where(['name' => $user->name])->first();
$wikiHelper->DeleteWikiUser($uid);
}
}
}

View File

@@ -17,18 +17,23 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
Commands\GetCorpsCommand::class,
Commands\UpdateMoonPriceCommand::class,
Commands\HoldingFinancesCommand::class,
Commands\MoonMailerCommand::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,
Commands\Corps\GetCorpsCommand::class,
Commands\Finances\HoldingFinancesCommand::class,
Commands\Structures\GetStructuresCommand::class,
Commands\Assets\GetAssetsCommand::class,
Commands\Users\PurgeUsers::class,
Commands\Flex\FlexStructureCommand::class,
Commands\Data\EmptyJumpBridges::class,
Commands\Finances\SovBillsCommand::class,
Commands\Data\CleanStaleDataCommand::class,
Commands\Moons\MoonsUpdateCommand::class,
Commands\Data\PurgeCorpMoonLedgers::class,
Commands\Eve\ItemPricesUpdateCommand::class,
/**
* Rental Moon Commands
*/
Commands\RentalMoons\AllianceRentalMoonInvoiceCreationCommand::class,
Commands\RentalMoons\AllianceRentalMoonUpdatePricingCommand::class,
];
/**
@@ -39,51 +44,51 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
//Command to get the holding journal finances
$schedule->command('services:HoldingJournal')
->hourly()
->withoutOverlapping();
//Command to update moon rental pricing
$schedule->command('services:UpdateMoonPrice')
->hourly()
->withoutOverlapping();
//Get the corps within the alliance
$schedule->command('services:GetCorps')
->monthlyOn(1, '09:00')
->withoutOverlapping();
//Update the moons, and send out mails for current moon rentals
$schedule->command('services:MoonMailer')
->monthlyOn(1, '00:01')
->withoutOverlapping();
//Get the structures within the alliance and their information
$schedule->command('services:GetStructures')
->dailyAt('09:00')
->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();
/**
* Rentals / Flex Schedule
*/
$schedule->command('services:UpdateRentalPrice')
->dailyAt('11:00')
->withoutOverlapping();
$schedule->command('services:FlexStructures')
->monthlyOn(2, '00:01');
/**
* Holding Corp Finance Schedule
*/
$schedule->command('services:HoldingJournal')
->hourlyAt('45')
->withoutOverlapping();
/**
* Get Information Schedule
*/
$schedule->command('services:GetCorps')
->monthlyOn(1, '09:00');
$schedule->command('services:GetStructures')
->dailyAt('09:00');
$schedule->command('services:GetAssets')
->hourlyAt('22');
/**
* Purge Data Schedule
*/
$schedule->command('services:CleanData')
->weekly(7, '11:00');
$schedule->command('data:PurgeCorpLedgers')
->monthly();
$schedule->command('services:PurgeUsers')
->dailyAt('23:00');
/**
* Item Update Schedule
*/
$schedule->command('services:ItemPriceUpdate')
->hourlyAt('30')
->withoutOverlapping();
}
/**

View File

@@ -38,7 +38,7 @@ class BlacklistController extends Controller
public function AddToBlacklist(Request $request) {
//Middleware needed for the function
$this->middleware('permission:alliance.recruiter');
$this->middleware('permission:blacklist.admin');
//Validate the user input
$this->validate($request, [
@@ -84,15 +84,16 @@ class BlacklistController extends Controller
}
//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(),
]);
$blacklist = new BlacklistEntity;
$blacklist->entity_id = $entityId;
$blacklist->entity_name = $request->name;
$blacklist->entity_type = $request->type;
$blacklist->reason = $request->reason;
$blacklist->alts = $request->alts;
$blacklist->lister_id = auth()->user()->getId();
$blacklist->lister_name = auth()->user()->getName();
$blacklist->validity = 'Valid';
$blacklist->save();
//Return to the view
return redirect('/blacklist/display/add')->with('success', $request->name . ' added to the blacklist.');
@@ -108,17 +109,22 @@ class BlacklistController extends Controller
public function RemoveFromBlacklist(Request $request) {
//Middleware needed
$this->middleware('permission:alliance.recruiter');
$this->middleware('permission:blacklist.admin');
//Validate the input request
$this->validate($request, [
'name' => 'required',
]);
//Delete the blacklist character
//Set the character on the blacklist to removed
BlacklistEntity::where([
'entity_name' => $request->name,
])->delete();
])->update([
'validity' => 'Invalid',
'removed_by_id' => auth()->user()->getId(),
'removed_by_name' => auth()->user()->getName(),
'removed_notes' => $request->notes,
]);
//Return the view
return redirect('/blacklist/display')->with('success', 'Character removed from the blacklist.');
@@ -127,7 +133,9 @@ class BlacklistController extends Controller
public function DisplayBlacklist() {
//Get the entire blacklist
$blacklist = BlacklistEntity::orderBy('entity_name', 'asc')->paginate(50);
$blacklist = BlacklistEntity::where([
'validity' => 'Valid',
])->orderBy('entity_name', 'asc')->paginate(50);
//Return the view with the data
return view('blacklist.list')->with('blacklist', $blacklist);
@@ -141,9 +149,9 @@ class BlacklistController extends Controller
]);
$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 . "%")
->orWhere('entity_type', 'like', "%" . $request->parameter . "%")
->orWhere('alts', 'like', "%" . $request->parameter . "%")
->orWhere('reason', 'like', "%" . $request->parameter . "%")
->orderBy('entity_name', 'asc')
->paginate(50);

View File

@@ -1,198 +0,0 @@
<?php
namespace App\Http\Controllers\Contracts;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Carbon\Carbon;
//Libraries
use App\Library\Esi\Mail;
//Jobs
use App\Jobs\ProcessSendEveMailJob;
//Models
use App\Models\User\User;
use App\Models\User\UserPermission;
use App\Models\Contracts\Contract;
use App\Models\Contracts\Bid;
use App\Models\Contracts\AcceptedBid;
use App\Models\Jobs\JobSendEveMail;
class ContractAdminController extends Controller
{
public function __construct() {
$this->middleware('auth');
$this->middleware('role:User');
$this->middleware('permission:contract.admin');
}
/**
* Contract display functions
*/
public function displayContractDashboard() {
$contracts = Contract::where(['finished' => false])->get();
return view('contracts.admin.contractpanel')->with('contracts', $contracts);
}
public function displayPastContracts() {
$contracts = Contract::where(['finished' => true])->get();
return view('contracs.admin.past')->with('contracts', $contracts);
}
/**
* New contract functionality
*/
public function displayNewContract() {
return view('contracts.admin.newcontract');
}
public function storeNewContract(Request $request) {
$this->validate($request, [
'name' => 'required',
'date' => 'required',
'body' => 'required',
'type' => 'required',
]);
$date = new Carbon($request->date);
$body = nl2br($request->body);
//Store the contract in the database
$contract = new Contract;
$contract->title = $request->name;
$contract->end_date = $request->date;
$contract->body = $body;
$contract->type = $request->type;
$contract->save();
//Send a mail out to all of the people who can bid on a contract
$this->NewContractMail();
return redirect('/contracts/admin/display')->with('success', 'Contract written.');
}
/**
* Used to store a finished contract in the database
*/
public function storeAcceptContract(Request $request) {
$this->validate($request, [
'contract_id' => 'required',
'bid_id' => 'required',
'character_id' => 'required',
'bid_amount' => 'required',
]);
//Update the contract
Contract::where([
'contract_id' => $request->contract_id,
])->update([
'finished' => true,
'final_cost' => $request->bid_amount,
]);
//Save the accepted bid in the database
$accepted = new AcceptedBid;
$accepted->contract_id = $request->contract_id;
$accepted->bid_id = $request->bid_id;
$accepted->bid_amount = $request->bid_amount;
$accepted->save();
return redirect('/contracts/admin/display')->with('success', 'Contract accepted and closed.');
}
/**
* Delete a contract from every user
*/
public function deleteContract($id) {
Contract::where(['contract_id' => $id])->delete();
Bid::where(['contract_id' => $id])->delete();
return redirect('/contracts/admin/display')->with('success', 'Contract has been deleted.');
}
/**
* End Contract Functionality
*/
public function displayEndContract($id) {
//Gather the information for the contract, and all bids on the contract
$contract = Contract::where(['contract_id' => $id])->first()->toArray();
$bids = Bid::where(['contract_id' => $id])->get()->toArray();
return view('contracts.admin.displayend')->with('contract', $contract)
->with('bids', $bids);
}
public function storeEndContract(Request $request) {
$this->validate($request, [
'contract_id' => 'required',
'accept' => 'required',
]);
//Declare class variables
$tries = 1;
//Get the esi config
$config = config('esi');
$contract = Contract::where(['contract_id' => $request->contract_id])->first()->toArray();
$bid = Bid::where(['id' => $request->accept, 'contract_id' => $request->contract_id])->first()->toArray();
//Send mail out to winner of the contract
$subject = 'Contract Won';
$body = 'You have been accepted to perform the following contract:<br>';
$body .= $contract['contract_id'] . ' : ' . $contract['title'] . '<br>';
$body .= 'Notes:<br>';
$body .= $contract['body'] . '<br>';
$body .= 'Please remit contract when the items are ready to Spatial Forces. Description should be the contract identification number. Request ISK should be the bid amount.';
$body .= 'Sincerely,<br>Spatial Forces Contracting Department';
//Setup the mail job
$mail = new 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');
//Tidy up the contract by doing a few things.
$this->TidyContract($contract, $bid);
//Redirect back to the contract admin dashboard.
return redirect('/contracts/admin/display')->with('success', 'Contract finalized. Mail has been sent to the queue for processing.');
}
private function TidyContract($contract, $bid) {
Contract::where(['contract_id' => $contract['contract_id']])->update([
'finished' => true,
]);
//Create the accepted contract entry into the table
$accepted = new AcceptedBid;
$accepted->contract_id = $contract['contract_id'];
$accepted->bid_id = $bid['id'];
$accepted->bid_amount = $bid['bid_amount'];
$accepted->notes = $bid['notes'];
$accepted->save();
}
private function NewContractMail() {
//Get 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');
}
}

View File

@@ -1,322 +0,0 @@
<?php
namespace App\Http\Controllers\Contracts;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Carbon\Carbon;
//Libraries
use App\Library\Lookups\LookupHelper;
//Models
use App\Models\User\User;
use App\Models\User\UserPermission;
use App\Models\Contracts\Contract;
use App\Models\Contracts\Bid;
class ContractController extends Controller
{
public function __construct() {
$this->middleware('auth');
$this->middleware('role:User');
}
/**
* Controller function to display the bids placed on contracts
*/
public function displayBids($id) {
$bids = Bids::where(['contract_id' => $id, 'character_name' => auth()->user()->getName()])->get();
return view('contracts.bids')->with('bids', $bids);
}
/**
*
* Controller function to display all current open contracts
*
*/
public function displayContracts() {
//Calculate today's date to know which contracts to display
$today = Carbon::now();
//Declare our array variables
$bids = array();
$contracts = array();
$i = 0;
//Fetch all of the current contracts from the database
$contractsTemp = Contract::where('end_date', '>=', $today)
->where(['finished' => false])->get()->toArray();
//Count the number of bids, and add them to the arrays
for($i = 0; $i < sizeof($contractsTemp); $i++) {
$tempCount = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->count('contract_id');
$bids = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->get()->toArray();
//Assemble the finaly array
$contracts[$i] = $contractsTemp[$i];
$contracts[$i]['bid_count'] = $tempCount;
$contracts[$i]['bids'] = $bids;
}
//Call for the view to be displayed
return view('contracts.allcontracts')->with('contracts', $contracts);
}
/**
* Controller function to display all current public contracts
*/
public function displayPublicContracts() {
//Calculate today's date to know which contracts to display
$today = Carbon::now();
//Declare our array variables
$bids = array();
$contracts = array();
$i = 0;
$lowestBid = null;
$lowestCorp = null;
$lowestChar = null;
//Fetch all of the current contracts from the database
$contractsTemp = Contract::where('end_date', '>=', $today)
->where(['type' => 'Public', 'finished' => false])->get()->toArray();
//Count the number of bids, and add them to the arrays
for($i = 0; $i < sizeof($contractsTemp); $i++) {
$tempCount = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->count('contract_id');
$bids = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->get()->toArray();
foreach($bids as $bid) {
if($lowestBid == null) {
$lowestBid = $bid['bid_amount'];
$lowestCorp = $bid['corporation_name'];
$lowestChar = $bid['character_name'];
} else {
if($bid['bid_amount'] < $lowestBid) {
$lowestBid = $bid['bid_amount'];
$lowestCorp = $bid['corporation_name'];
$lowestChar = $bid['character_name'];
}
}
}
if($lowestBid == null) {
$lowestBid = 'No Bids Placed.';
$lowestCorp = 'No Corporation has placed a bid.';
}
//Assemble the finaly array
$contracts[$i] = $contractsTemp[$i];
$contracts[$i]['bid_count'] = $tempCount;
$contracts[$i]['bids'] = $bids;
$contracts[$i]['lowestbid'] = $lowestBid;
$contracts[$i]['lowestcorp'] = $lowestCorp;
$contracts[$i]['lowestchar'] = $lowestChar;
//Reset the lowestBid back to null
$lowestBid = null;
}
//Call for the view to be displayed
return view('contracts.publiccontracts')->with('contracts', $contracts);
}
/**
* Controller function to display current private contracts
*/
public function displayPrivateContracts() {
//Declare our array variables
$bids = array();
$contracts = array();
$lowestBid = null;
//Calucate today's date to know which contracts to display
$today = Carbon::now();
//Fetch all of the current contracts from the database
$contractsTemp = Contract::where('end_date', '>=', $today)
->where(['type' => 'Private', 'finished' => false])->get();
//Count the number of bids, and add them to the arrays
for($i = 0; $i < sizeof($contractsTemp); $i++) {
$tempCount = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->count('contract_id');
$bids = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->get()->toArray();
foreach($bids as $bid) {
if($lowestBid == null) {
$lowestBid = $bid['bid_amount'];
} else {
if($bid['bid_amount'] < $lowestBid) {
$lowestBid = $bid['bid_amount'];
}
}
}
if($lowestBid == null) {
$lowestBid = 'No Bids Placed.';
}
//Assemble the finaly array
$contracts[$i] = $contractsTemp[$i];
$contracts[$i]['bid_count'] = $tempCount;
$contracts[$i]['bids'] = $bids;
$contracts[$i]['lowestbid'] = $lowestBid;
}
return view ('contracts.privatecontracts')->with('contracts', $contracts);
}
/**
* Controller function to display expired contracts
*
*/
public function displayExpiredContracts() {
//Calculate today's date to know which contracts to display
$today = Carbon::now();
//Retrieve the contracts from the database
$contracts = Contract::where('end_date', '<', $today)->get();
return view('contracts.expiredcontracts')->with('contracts', $contracts);
}
/**
* Controller function to display a page to allow a bid
*
*/
public function displayNewBid($id) {
$contractId = $id;
return view('contracts.enterbid')->with('contractId', $contractId);
}
/**
* Controller function to store a new bid
*/
public function storeBid(Request $request) {
//Valid the request from the enter bid page
$this->validate($request, [
'contract_id' => 'required',
'bid' => 'required',
]);
//Delcare some class variables we will need
$lookup = new LookupHelper;
$amount = 0.00;
//Convert the amount to a whole number from abbreviations
if($request->suffix == 'B') {
$amount = $request->bid * 1000000000.00;
} else if($request->suffix == 'M') {
$amount = $request->bid * 1000000.00;
} else {
$amount = $request->bid * 1.00;
}
if(isset($request->notes)) {
$notes = nl2br($request->notes);
} else {
$notes = null;
}
//Get the character id and character name from the auth of the user calling
//this function
$characterId = auth()->user()->getId();
$characterName = auth()->user()->getName();
//Use the lookup helper in order to find the user's corporation id and name
$char = $lookup->GetCharacterInfo($characterId);
$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
$found = Bid::where([
'contract_id' => $request->contract_id,
'character_id' => $characterId,
])->first();
if(isset($found->contract_id)) {
return redirect('/contracts/display/all')->with('error', 'You have already placed a bid for this contract. Please modify the existing bid.');
} else {
//Create the model object to save data to
$bid = new Bid;
$bid->contract_id = $request->contract_id;
$bid->bid_amount = $amount;
$bid->character_id = $characterId;
$bid->character_name = $characterName;
$bid->corporation_id = $corporationId;
$bid->corporation_name = $corporationName;
$bid->notes = $notes;
$bid->save();
//Redirect to the correct page
return redirect('/contracts/display/all')->with('success', 'Bid accepted.');
}
}
/**
* Controller function to delete a bid
*/
public function deleteBid($id) {
//Delete the bid entry from the database
Bid::where([
'id' => $id,
])->delete();
return redirect('/contracts/display/public')->with('success', 'Bid deleted.');
}
/**
* Controller function to display modify bid page
*/
public function displayModifyBid($id) {
//With the bid id number, look up the bid in the database to get the contract information
$bid = Bid::where(['id' => $id])->first();
//Retrieve the contract from the database
$contract = Contract::where(['contract_id' => $bid->contract_id])->first()->toArray();
return view('contracts.modifybid')->with('contract', $contract)
->with('bid', $bid);
}
/**
* Controller function to modify a bid
*/
public function modifyBid(Request $request) {
$this->validate($request, [
'bid' => 'required',
]);
$amount = $request->bid;
$type = $request->type;
$contractId = $request->contract_id;
if($request->suffix == 'B') {
$amount = $amount * 1000000000.00;
} else if($request->suffix == 'M') {
$amount = $amount * 1000000.00;
} else {
$amount = $amount * 1.00;
}
Bid::where([
'character_id' => auth()->user()->getId(),
'contract_id' => $contractId,
])->update([
'bid_amount' => $amount,
]);
if($type == 'public') {
return redirect('/contracts/display/public')->with('success', 'Bid modified.');
} else {
return redirect('/contracts/display/private')->with('success', 'Bid modified');
}
}
}

View File

@@ -0,0 +1,501 @@
<?php
namespace App\Http\Controllers\Contracts;
//Internal Libraries
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Carbon\Carbon;
//Libraries
use App\Library\Lookups\LookupHelper;
//Models
use App\Models\User\User;
use App\Models\Contracts\SupplyChainBid;
use App\Models\Contracts\SupplyChainContract;
//Jobs
use App\Jobs\ProcessSendEveMailJob;
class SupplyChainController extends Controller
{
/**
* Constructor
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('role:Renter');
}
/**
* Display the supply chain dashboard
* Should contain a section for open contracts, closed contracts, and expired contracts.
*/
public function displaySupplyChainDashboard() {
$openContracts = SupplyChainContract::where([
'state' => 'open',
])->get();
$closedContracts = SupplyChainContract::where([
'state' => 'closed',
])->get();
$completedContracts = SupplyChainContract::where([
'state' => 'completed',
])->get();
return view('supplychain.dashboard.main')->with('openContracts', $openContracts)
->with('closedContracts', $closedContracts)
->with('completedContracts', $completedContracts);
}
/**
* Display my supply chain contracts dashboard
* Should contain a section for open contracts, closed contracts, and expired contracts
*/
public function displayMySupplyChainDashboard() {
$openContracts = SupplyChainContract::where([
'issuer_id' => auth()->user()->getId(),
'state' => 'open',
])->get();
$closedContracts = SupplyChainContract::where([
'issuer_id' => auth()->user()->getId(),
'state' => 'closed',
])->get();
$completedContracts = SupplyChainContract::where([
'issuer_id' => auth()->user()->getId(),
'state' => 'completed',
])->get();
return view('supplychain.dashboard.main')->with('openContracts', $openContracts)
->with('closedContracts', $closedContracts)
->with('completedContracts', $completedContracts);
}
/**
* Display new contract page
*/
public function displayNewSupplyChainContract() {
return view('supplychain.forms.newcontract');
}
/**
* Store new contract page
*/
public function storeNewSupplyChainContract(Request $request) {
$this->validate($request, [
'name' => 'required',
'date' => 'required',
'delivery' => 'required',
'body' => 'required',
]);
$contract = new SupplyChainContract;
$contract->issuer_id = auth()->user()->getId();
$contract->issuer_name = auth()->user()->getName();
$contract->title = $request->name;
$contract->end_date = $request->date;
$contract->delivery_by = $request->delivery;
$contract->body = $request->body;
$contract->state = 'open';
$contract->bids = 0;
$contract->save();
$this->NewSupplyChainContractMail($contract);
return redirect('/supplychain/dashboard')->with('success', 'New Contract created.');
}
/**
* Display the delete contract page
*/
public function displayDeleteSupplyChainContract() {
$contracts = SupplyChainContract::where([
'issuer_id' => auth()->user()->getId(),
'state' => 'open',
])->get();
return view('supplychain.forms.delete')->with('contracts', $contracts);
}
/**
* Delete a supply chain contract
*/
public function deleteSupplyChainContract(Request $request) {
$this->validate($request, [
'contractId' => 'required',
]);
$contractId = $request->contractId;
/**
* Remove the supply chain contract if it's yours.
*/
$count = SupplyChainContract::where([
'issuer_id' => auth()->user()->getId(),
'contract_id' => $contractId,
])->count();
if($count > 0) {
//Remove the supply chain contract
SupplyChainContract::where([
'issuer_id' => auth()->user()->getId(),
'contract_id' => $contractId,
])->delete();
//Remove all bids associated with the supply chain contract
SupplyChainBid::where([
'contract_id' => $contractId,
])->delete();
return redirect('/supplychain/dashboard')->with('success', 'Supply Chain Contract deleted successfully.');
} else {
return redirect('/supplychain/dashboard')->with('error', 'Unable to delete supply chain contract.');
}
}
/**
* Display the end supply chain contrage page
*/
public function displayEndSupplyChainContract() {
return view('supplychain.forms.end');
}
/**
* Process the end supply chain contract page
*/
public function storeEndSupplyChainContract(Request $request) {
$this->validate($request, [
'accept' => 'required',
'contractId' => 'required',
]);
//Check to make sure the user owns the contract
$count = SupplyChainContract::where([
'issuer_name' => auth()->user()->getName(),
'contract_id' => $request->contractId,
])->count();
//If the count is greater than 0, the user owns the contract.
//Proceed with ending the contract
if($count > 0) {
SupplyChainContract::where([
])->update([
]);
SupplyChainBid::where([
])->update([
]);
return redirect('/supplychain/dashboard')->with('success', 'Contract ended, and mails sent to the winning bidder.');
} else {
//If the count is zero, then redirect with error messsage
return redirect('/supplychain/dashboard')->with('error', 'Contract was not yours to end.');
}
}
/**
* Display supply chain contract bids page
*/
public function displaySupplyChainBids() {
//Display bids for the user on a page
$bids = array();
$bidsCount = SupplyChainBid::where([
'entity_id' => auth()->user()->getId(),
'bid_type' => 'pending',
])->count();
$myBids = SupplyChainBid::where([
'entity_id' => auth()->user()->getId(),
'bid_type' => 'pending',
])->get();
foreach($myBids as $bid) {
//Declare the temporary array
$temp = array();
//Get the contract information for the bid
$contract = SupplyChainContract::where([
'contract_id' => $bid->contract_id,
])->first();
$temp['bid_id'] = $bid->bid_id;
$temp['contract_id'] = $bid->contract_id;
$temp['issuer_name'] = $contract->issuer_name;
$temp['title'] = $contract->title;
$temp['end_date'] = $contract->end_date;
$temp['body'] = $contract->body;
$temp['bid_amount'] = $bid->bid_amount;
array_push($bids, $temp);
}
return view('supplychain.dashboard.bids')->with('bids', $bids)
->with('bidsCount', $bidsCount);
}
/**
* Display expired supply chain contracts page
*/
public function displayExpiredSupplyChainContracts() {
return view('supplychain.dashboard.expired');
}
/**
* Display the new bid on a supply chain contract page
*/
public function displaySupplyChainContractBid($contract) {
$contractId = $contract;
return view('supplychain.forms.enterbid')->with('contractId', $contractId);
}
/**
* Enter a new bid on a supply chain contract
*/
public function storeSupplyChainContractBid(Request $request) {
$this->validate($request, [
'bid' => 'required',
'contract_id' => 'required',
]);
//Declare some needed variables
$bidAmount = 0.00;
//See if a bid has been placed by the user for this contract
$count = SupplyChainBid::where([
'entity_id' => auth()->user()->getId(),
'entity_name' => auth()->user()->getName(),
'contract_id' => $request->contract_id,
])->count();
//If the person already has a bid in, then deny them the option to place another bid on the same contract.
//Otherwise, enter the bid into the database
if($count > 0) {
return redirect('/supplychain/dashboard')->with('error', 'Unable to insert bid as one is already present for the supply chain contract.');
} else {
//Sanitize the bid amount
if(preg_match('(m|M|b|B)', $request->bid) === 1) {
if(preg_match('(m|M)', $request->bid) === 1) {
$cStringSize = strlen($request->bid);
$tempCol = str_split($request->bid, $cStringSize - 1);
$bidAmount = $tempCol[0];
$bidAmount = $bidAmount * 1000000.00;
} else if(preg_match('(b|B)', $request->bid) === 1) {
$cStringSize = strlen($request->bid);
$tempCol = str_split($request->bid, $cStringSize - 1);
$bidAmount = $tempCol[0];
$bidAmount = $bidAmount * 1000000000.00;
}
} else {
$bidAmount = $request->bid;
}
//Create the database entry
$bid = new SupplyChainBid;
$bid->contract_id = $request->contract_id;
$bid->bid_amount = $bidAmount;
$bid->entity_id = auth()->user()->getId();
$bid->entity_name = auth()->user()->getName();
$bid->entity_type = 'character';
if(isset($request->notes)) {
$bid->bid_note = $request->notes;
}
$bid->bid_type = 'pending';
$bid->save();
//Update the database entry for the supply chain contract bid number
$num = SupplyChainContract::where([
'contract_id' => $request->contract_id,
])->select('bids')->first();
//Increment the number of bids
$numBids = $num->bids + 1;
//Update the database
SupplyChainContract::where([
'contract_id' => $request->contract_id,
])->update([
'bids' => $numBids,
]);
return redirect('/supplychain/dashboard')->with('success', 'Bid succesfully entered into the contract.');
}
}
/**
* Delete a bid on a supply chain contract
*
* @var contractId
* @var bidId
*/
public function deleteSupplyChainContractBid($contractId, $bidId) {
//See if the user has put in a bid. If not, then redirect to failure.
$count = SupplyChainBid::where([
'contract_id' => $contractId,
'entity_id' => auth()->user()->getId(),
'bid_id' => $bidId,
])->count();
if($count > 0) {
SupplyChainBid::where([
'contract_id' => $contractId,
'entity_id' => auth()->user()->getId(),
'bid_id' => $bidId,
])->delete();
//Update the database entry for the supply chain contract bid number
$num = SupplyChainContract::where([
'contract_id' => $contractId,
])->select('bids')->first();
//Decrement the number of bids
$numBids = $num->bids - 1;
//Update the database
SupplyChainContract::where([
'contract_id' => $contractId,
])->update([
'bids' => $numBids,
]);
return redirect('/supplychain/dashboard')->with('success', 'Deleted supply chain contract bid.');
} else {
return redirect('/supplychain/dashboard')->with('error', 'No bid found to delete.');
}
}
/**
* Display the modify a bid on supply chain contract page
*/
public function displayModifySupplyChainContractBid(Request $request) {
$this->validate($request, [
'contract_id' => 'required',
]);
//Get the contract id
$contractId = $request->contract_id;
//Get the bid id to be modified later
$bid = SupplyChainBid::where([
'contract_id' => $contractId,
'entity_id' => auth()->user()->getId(),
])->first();
$bidId = $bid->id;
return view('supplychain.forms.modifybid')->with('contractId', $contractId)
->with('bidId', $bidId);
}
/**
* Modify a bid on a supply chain contract
*/
public function modifySupplyChainContractBid(Request $request) {
$this->validate($request, [
'bid_id' => 'required',
'contract_id' => 'required',
'bid_amount' => 'required',
]);
//Check for the owner of the bid
$count = SupplyChainBid::where([
'bid_id' => $request->bid_id,
'contract_id' => $request->contract_id,
'entity_id' => auth()->user()->getId(),
])->count();
if($count > 0) {
if(isset($request->bid_note)) {
SupplyChainBid::where([
'bid_id' => $request->bid_id,
'contract_id' => $request->contract_id,
'entity_id' => auth()->user()->getId(),
])->update([
'bid_amount' => $request->bid_amount,
'bid_note' => $request->bid_note,
]);
} else {
SupplyChainBid::where([
'bid_id' => $request->bid_id,
'contract_id' => $request->contract_id,
'entity_id' => auth()->user()->getId(),
])->update([
'bid_amount' => $request->bid_amount,
]);
}
return redirect('/supplychain/dashboard')->with('success', 'Modified supply chain contract bid.');
} else {
return redirect('/supplychain/dashboard')->with('error', 'Not able to modify supply chain contract bid.');
}
}
/**
* Send out a new supply chain contract mail
*/
private function NewSupplyChainContractMail(SupplyChainContract $contract) {
//Get the config for the esi
$config = config('esi');
$todayDate = Carbon::now()->toFormattedDateString();
$subject = 'New Supply Chain Contract ' . $todayDate;
$body = "A supply chain contract is available.<br>";
$body .= "Contract: " . $contract->title . "<br>";
$body .= "Notes: " . $contract->body . "<br>";
$body .= "Delivery Date: " . $contract->delivery_date . "<br>";
$body .= "<br>Sincerely on behalf of,<br>" . $contract->issuer_name . "<br>";
ProcessSendEveMailJob::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
}
/**
* Send out a mail when the supply chain contract has been deleted
*/
private function DeleteSupplyChainContractMail($contract) {
//Get the esi config
$config = config('esi');
$subject = 'Production Contract Removal';
$body = "A production contract has been deleted.<br>";
$body .= "Contract: " . $contract->title . "<br>";
$body .= "Notes: " . $contract->note . "<br>";
$body .= "<br>Sincerely on behalf of,<br>" . $contract->issuer_name;
ProcessSendEveMailJob::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
}
/**
* Tidy up datatables from a completed supply chain contract
*/
private function TidySupplyChainContract($contract, $bid) {
//Set the contract as finished
SupplyChainContract::where([
'contract_id' => $contract->contract_id,
])->update([
'state' => 'finished',
]);
//Set all of the bids as not_accepted as default
SupplyChainBid::where([
'contract_id' => $contract->contract_id,
])->update([
'bid_type' => 'not_accepted',
]);
//Set the correct bid as accepted
SupplyChainBid::where([
'contract_id' => $contract->contract_id,
'bid_id' => $bid->bid_id,
])->update([
'bid_type' => 'accepted',
]);
}
}

View File

@@ -18,6 +18,7 @@ use App\Models\User\User;
use App\Models\User\UserRole;
use App\Models\User\UserPermission;
use App\Models\User\AvailableUserPermission;
use App\Models\User\AvailableUserRole;
use App\Models\Admin\AllowedLogin;
use App\Models\Doku\DokuGroupNames;
use App\Models\Doku\DokuMember;
@@ -38,7 +39,7 @@ class AdminController extends Controller
$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');
$journal = DB::select('SELECT amount,reason,description,date FROM `player_donation_journal` WHERE corporation_id=98287666 AND date >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 2 MONTH) ORDER BY date DESC');
return view('admin.dashboards.walletjournal')->with('journal', $journal);
}
@@ -220,37 +221,41 @@ class AdminController extends Controller
$permissions[$p->permission] = $p->permission;
}
$roles = AvailableUserRole::all();
$role = $user->getRole();
//Pass the user information to the page for hidden text entries
return view('admin.user.modify')->with('user', $user)
->with('permissions', $permissions);
->with('permissions', $permissions)
->with('role', $role)
->with('roles', $roles);
}
public function modifyUser(Request $request) {
$type = $request->type;
if(isset($request->permission)) {
$permission = $request->permission;
}
if(isset($request->user)) {
$user = $request->user;
}
public function modifyRole(Request $request) {
$this->validate($request, [
'user' => 'required',
'role' => 'required|role!=None',
]);
return redirect('/admin/dashboard/users')->with('error', 'Not Implemented Yet.');
UserRole::where(['character_id' => $user])->update([
'role' => $request->role,
]);
return redirect('/admin/dashboard/users')->with('success', "User: " . $user . " has been modified to a new role: " . $request->role . ".");
}
public function addPermission(Request $request) {
//Get the user and permission from the form
$user = $request->user;
$character = $request->user;
$permission = $request->permission;
//Get the character id from the username using the user table
$character = User::where(['name' => $user])->get(['character_id']);
//Check to see if the character already has the permission
$check = UserPermission::where(['character_id' => $character[0]->character_id, 'permission' => $permission])->get(['permission']);
$check = UserPermission::where(['character_id' => $character, 'permission' => $permission])->get(['permission']);
if(!isset($check[0]->permission)) {
$perm = new UserPermission;
$perm->character_id = $character[0]->character_id;
$perm->character_id = $character;
$perm->permission = $permission;
$perm->save();
@@ -395,9 +400,14 @@ class AdminController extends Controller
}
//Add the user to the wiki group
$wikiHelper->AddUserToGroup($request->user, $request->groupname);
$results = $wikiHelper->AddUserToGroup($request->user, $request->groupname);
return redirect('/admin/dashboard/wiki')->with('success', 'User added to group for the wiki.');
//Redirect based on the results of the add user to group function
if($results) {
return redirect('/admin/dashboard/wiki')->with('success', 'User added to group for the wiki.');
} else {
return redirect('/admin/dashboard/wiki')->with('error', 'Failed at add user to group, or user was already part of the group.');
}
}
/**
@@ -465,19 +475,45 @@ class AdminController extends Controller
$lookup = new LookupHelper;
$wikiHelper = new WikiHelper;
//Get all of the users from the database
$users = User::all();
//Search the names and verify against the lookup table
//to find the corporation and / or alliance they belong to.
foreach($users as $user) {
//Let's look up the character in the user table by their name.
//If no name is found, then delete the user and have them start over with the wiki permissions
$count = User::where(['name' => $user])->count();
$count = DokuUser::where(['name' => $user->name])->count();
//If the user is found, then check if they are allowed on the wiki.
//If the the count == 0, then the user wasn't found on the wiki, so do nothing.
if($count > 0) {
//If the user is not allowed, then delete the user, otherwise, leave the user untouched
if(!$wikiHelper->AllowedUser($user)) {
$wikiHelper->DeleteWikiUser($user);
if(!$wikiHelper->AllowedUser($user->name)) {
$uid = $wikiHelper->GetUID($user->name);
$wikiHelper->DeleteWikiUser($uid);
}
}
}
//Get all of the DokuUsers and verify against the Users on the services page
$users = DokuUser::all();
//Search the names and verify against the lookup table to find the corporation / alliance the user belongs to.
foreach($users as $user) {
//Lookup the character in the user table on the services page
$count = User::where(['name' => $user->name])->count();
//If the user is found, then check if they are allowed on the wiki.
//If the count == 0, then delete the user anyways
if($count > 0 ) {
//If the user is not allowed, then delete the user, otherwise, leave them alone.
if(!$wikiHelper->AllowedUser($user->name)) {
$uid = $wikiHelper->GetUID($user->name);
$wikiHelper->DeleteWikiUser($uid);
} else {
$wikiHelper->DeleteWikiUser($user->id);
}
} else {
$wikiHelper->DeleteWikiUser($user);
}
}

View File

@@ -42,18 +42,55 @@ class AdminDashboardController extends Controller
}
//Declare variables we will need
$tHelper = new TaxesHelper();
$srpHelper = new SRPHelper();
$days = 30;
$sovBills = array();
$pi = array();
$industry = array();
$reprocessing = array();
$office = array();
$sprActual = array();
$srpLoss = array();
$months = 1;
$lava = new Lavacharts;
//Get the dates for the information being requested
$dates = $tHelper->GetTimeFrameInMonths($months);
//Get the data for the sov expenses for a graph
//Setup the charts
//Setup the chart to be able the show the categories for income
/*
$iChart = $lava->DataTable();
$iChart->addStringColumn('Categories')
->addNumberColumn('ISK')
->addRow(['pi', $pi])
->addRow(['industry', $industry])
->addRow(['reprocessing', $reprocessing])
->addRow(['offices', $office])
->addRow(['industry', $industry])
->addRow(['market', $market])
->addRow(['gate', $gate])
->addRow(['iBuyback', $iBuyback])
->addRow(['renters', $renters])
->addRow(['ops', $ops]);
*/
//Setup the chart to be able to show the categories for expenses
/*
$eChart = $lava->DataTable();
$eCjart->addStringColumn('Categories')
->addNumberColumn('ISK')
->addRow(['sov', $sovBills])
->addRow(['srp', $srpActual])
->addRow(['maintenance', $maintenance])
->addRow(['wardecs', $wardecs])
->addRow(['fcs', $fcs])
->addRow(['keepstar_fuel', $keepstarFuel])
->addRow(['fortizar_fuel', $fortizarFuel])
->addRow(['astrahus_fuel', $astrahusFuel])
->addRow(['sotiyo_fuel', $sotiyoFuel])
->addRow(['azbel_fuel', $azbelFuel])
->addRow(['raitaru_fuel', $raitaruFuel])
->addRow(['beacon_fuel', $beaconFuel])
->addRow(['bridge_fuel', $bridgeFuel])
->addRow(['jammer_fuel', $jammerFuel]);
*/
return view('admin.dashboards.dashboard');
}
}

View File

@@ -120,14 +120,29 @@ class FlexAdminController extends Controller
'structure_type' => 'required',
]);
FlexStructure::where([
$count = FlexStructure::where([
'requestor_id' => $request->requestor_id,
'requestor_corp_id' => $request->requestor_corp_id,
'system' => $request->system_id,
'system_id' => $request->system_id,
'structure_type' => $request->structure_type,
])->delete();
])->count();
return redirect('/flex/display')->with('success', 'Flex Structure Entry Removed.');
if($count > 0) {
FlexStructure::where([
'requestor_id' => $request->requestor_id,
'requestor_corp_id' => $request->requestor_corp_id,
'system_id' => $request->system_id,
'structure_type' => $request->structure_type,
])->delete();
return redirect('/flex/display')->with('success', 'Flex Structure Entry Removed.');
} else {
return redirect('/flex/display')->with('error', 'Could not find flex structure to delete.');
}
}
}

View File

@@ -7,12 +7,8 @@ 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
{

View File

@@ -6,6 +6,7 @@ namespace App\Http\Controllers\Logistics;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Log;
use Carbon\Carbon;
//Jobs
use App\Jobs\ProcessSendEveMailJob;
@@ -15,7 +16,6 @@ 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
@@ -63,7 +63,7 @@ class StructureRequestController extends Controller
])->get();
//Set the mail delay
$delay = 5;
$delay = 30;
foreach($fcTeam as $fc) {
$body = "Structure Anchor Request has been entered.<br>";
@@ -72,17 +72,12 @@ class StructureRequestController extends Controller
$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);
$subject = "New Structure Anchor Request";
ProcessSendEveMailJob::dispatch($body, (int)$fc->character_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
$delay += 15;
$delay += 30;
}
return redirect('/structures/display/requests');
return redirect('/dashboard')->with('success', 'Structure request successfully submitted.');
}
}

View File

@@ -18,15 +18,20 @@ use App\Library\Lookups\LookupHelper;
use App\Models\Esi\EsiToken;
use App\Models\Esi\EsiScope;
use App\Models\Lookups\ItemLookup;
use App\Models\MoonRent\MoonRental;
use App\Models\MoonRentals\AllianceRentalMoon;
use App\Models\Moon\RentalMoon;
use App\Models\Moon\CorpObserversRegistered;
use App\Models\Moon\CorpMoonObserver;
class MoonLedgerController extends Controller
{
public function __construct() {
$this->middleware('auth');
$this->middleware('role:User');
$this->middleware('permission:corp.lead');
}
public function displayMoonLedgerNew() {
}
public function displayMoonLedger() {
@@ -125,7 +130,7 @@ class MoonLedgerController extends Controller
}
}
return view('moons.ledger.corpmoons')->with('miningLedgers', $miningLedgers)
return view('moons.ledger.displayledger')->with('miningLedgers', $miningLedgers)
->with('structures', $structures);
}
@@ -228,7 +233,7 @@ class MoonLedgerController extends Controller
}
}
return view('moons.ledger.corpmoons')->with('miningLedgers', $miningLedgers)
->with('structures', $structures);
return view('moons.ledger.rentalledger')->with('miningLedgers', $miningLedgers)
->with('structures', $structures);
}
}

View File

@@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Auth;
use Carbon\Carbon;
use Log;
//Models
use App\Models\Moon\Config;
@@ -14,10 +15,9 @@ use App\Models\Moon\ItemComposition;
use App\Models\Moon\RentalMoon;
use App\Models\Moon\OrePrice;
use App\Models\Moon\Price;
use App\Models\MoonRent\MoonRental;
use App\Models\Moon\AllianceMoon;
use App\Models\MoonRentals\AllianceRentalMoon;
use App\Models\Moon\AllianceMoonRequest;
use App\Models\Jobs\JobSendEveMail;
//Library
use App\Library\Moons\MoonCalc;
@@ -29,6 +29,25 @@ use App\Jobs\ProcessSendEveMailJob;
class MoonsAdminController extends Controller
{
/**
* Variable for the class
*/
private $romans = [
'M' => 1000,
'CM' => 900,
'D' => 500,
'CD' => 400,
'C' => 100,
'XC' => 90,
'L' => 50,
'XL' => 40,
'X' => 10,
'IX' => 9,
'V' => 5,
'IV' => 4,
'I' => 1,
];
/**
* Constructor for the class
*/
@@ -130,172 +149,19 @@ class MoonsAdminController extends Controller
}
//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');
ProcessSendEveMailJob::dispatch($body, (int)$moon->requestor_id, 'character', 'Warped Intentions Moon Request', $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
return redirect('/moons/admin/display/request')->with('success', 'Moon has been processed, and mail has been sent out.');
}
/**
* Function to display the moons to admins
*/
public function displayRentalMoonsAdmin() {
$this->middleware('role:Admin');
$lookupHelper = new LookupHelper;
$contact = '';
$paid = '';
$rentalEnd = '';
$renter = '';
$ticker = '';
//Setup calls to the MoonCalc class
$moonCalc = new MoonCalc();
//Get all of the moons from the database
$moons = RentalMoon::orderBy('System', 'asc')->get();
//Declare the html variable and set it to null
$table = array();
//Set carbon dates as needed
$lastMonth = Carbon::now()->subMonth();
$today = Carbon::now();
foreach($moons as $moon) {
//Get the rental data for the moon
$count = MoonRental::where([
'System' => $moon->System,
'Planet' => $moon->Planet,
'Moon' => $moon->Moon,
])->count();
//Check if their is a current rental for a moon going on
if($count == 0) {
//If we don't find a rental record, mark the moon as not paid
$paid = 'No';
//If we don't find a rental record, set the rental date as last month
$rentalTemp = $lastMonth;
$rentalEnd = $rentalTemp->format('m-d');
//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
$contact = 'None';
//Set the renter info
$renter = 'None';
//Set the ticker info
$ticker = 'N/A';
//Set the type info as it's needed
$type = 'N/A';
} else {
//Get the rental data for the moon
$rental = MoonRental::where([
'System' => $moon->System,
'Planet' => $moon->Planet,
'Moon' => $moon->Moon,
])->first();
//If we find a rental record, mark the moon as whether it's paid or not
$paid = $rental->Paid;
$paidUntil = new Carbon($rental->Paid_Until);
$paidUntil = $paidUntil->format('m-d');
//Set the rental date up
$rentalTemp = new Carbon($rental->RentalEnd);
$rentalEnd = $rentalTemp->format('m-d');
//Set the contact name
$contact = $lookupHelper->CharacterIdToName($rental->Contact);
//Set up the renter whether it's a corporation in W4RP or another alliance
$ticker = $rental->RentalCorp;
$type = $rental->Type;
}
//Set the color for the table
if($rentalTemp->diffInDays($today) < 3 ) {
$color = 'table-warning';
} else if( $today > $rentalTemp) {
$color = 'table-success';
} else {
$color = 'table-danger';
}
//Calculate hte price of the moon based on what is in the moon
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity, $moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
//Add the data to the html string to be passed to the view
array_push($table, [
'SPM' => $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon,
'StructureName' => $moon->StructureName,
'AlliancePrice' => $price['alliance'],
'OutOfAlliancePrice' => $price['outofalliance'],
'RentalEnd' => $rentalEnd,
'RowColor' => $color,
'Paid' => $paid,
'PaidUntil' => $paidUntil,
'Contact' => $contact,
'Type' => $type,
'Renter' => $ticker,
]);
}
return view('moons.admin.adminmoon')->with('table', $table);
}
/**
* Function to remove a renter from a moon
*/
public function storeMoonRemoval(Request $request) {
$this->middleware('role:Admin');
$this->validate($request, [
'remove' => 'required',
]);
$str_array = explode(" - ", $request->remove);
//Decode the value for the SPM into a system, planet, and moon for the database to update
$system = $str_array[0];
$planet = $str_array[1];
$moon = $str_array[2];
$found = MoonRental::where([
'System' => $system,
'Planet' => $planet,
'Moon' => $moon,
])->count();
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
return redirect('/moons/admin/display/rentals')->with('error', 'Something went wrong.');
}
/**
* Function displays the ability for admins to update moons with who is renting, and when it ends.
* Function to display the ability for the admins to update moons with who is renting,
* and when it ends
*/
public function updateMoon() {
$this->middleware('role:Admin');
//Declare some variables
//Declare the variables we need
$system = null;
$planet = null;
$moon = null;
@@ -303,239 +169,427 @@ class MoonsAdminController extends Controller
$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();
//Get the moons and put in order by System, Planet, Moon number
$moons = AllianceRentalMoon::orderBy('System', 'ASC')
->orderBy('Planet', 'ASC')
->orderBy('Moon', 'ASC')
->get();
//Push our default value onto the stack
array_push($spmn, 'N/A');
//Form our array of strings for each system, planet, and moon combination.
//Form our array of strings for each system, planet, and moon combination
foreach($moons as $m) {
$temp = $m->System . " - " . $m->Planet . " - " . $m->Moon . " - " . $m->StructureName;
$temp = $m->system . " - " . $m->planet . " - " . $m->moon . " - " . $m->structure_name;
array_push($spmnTemp, $temp);
}
//From our temporary array with all the values in a numbered key, create the real array with the value being the key
//From the temporary array, build the final array
foreach($spmnTemp as $key => $value) {
$spmn[$value] = $value;
}
//Return the view and the form from the blade display
//Pass the data to the view as well
//Pass the data to the blade display
return view('moons.admin.updatemoon')->with('spmn', $spmn);
}
/**
* Store the updated moon
* Function to remove a renter from a moon
* New function based on new table. Will
* update description in a future update.
*/
public function storeUpdateMoon(Request $request) {
public function storeMoonRemoval(Request $request) {
//Check for the correct role for the user to utilize this function
$this->middleware('role:Admin');
//Declare some static variables as needed
//Validate the request
$this->validate($request, [
'remove' => 'required',
]);
//Explode the remove request to an array of strings
$str_array = explode(" - ", $request->remove);
//Decode the value for the SPM into a system, planet, and moon
$system = $str_array[0];
$planet = $str_array[1];
$moon = $str_array[2];
//Update the moon rental
AllianceRentalMoon::where([
'system' => $system,
'planet' => $planet,
'moon' => $moon,
])->update([
'rental_type' => 'Not Rented',
'rental_until' => null,
'rental_contact_id' => 0,
'rental_contact_type' => 'Not Rented',
'paid' => 'Not Rented',
'paid_until' => null,
'alliance_use_until' => null,
]);
//Once the action is completed, redirect to the original page
return redirect('/moons/admin/display/rentals')->with('success', 'Renter removed from the moon.');
}
/**
* Function to display the moons to admins
* New function based on new table. Will
* update description in a future update.
*/
public function displayRentalMoonsAdmin() {
//Declare variables for the function
$lookupHelper = new LookupHelper;
$moonCalc = new MoonCalc;
$contactId = null;
$contactType = null;
$paid = null;
$paidUntil = null;
$corpTicker = null;
$table = array();
//Setup the carbon date using Carbon\Carbon
$lastMonth = Carbon::now()->subMonth();
$today = Carbon::now();
//Get the moon rentals from the database
$rentalMoons = AllianceRentalMoon::orderBy('system', 'asc')->get();
//For each of the moons compile different data for the view for formatting
foreach($rentalMoons as $moon) {
//Check if a current rental for the moon is on going
if(($moon->rental_type == 'In Alliance' || $moon->rental_type == 'Out of Alliance')) {
$paid = $moon->paid;
$paidUntil = new Carbon($moon->paid_until);
$paidUntil = $paidUntil->format('m-d');
//Set the rental date up
$rentalTemp = new Carbon($moon->rental_until);
$rentalEnd = $rentalTemp->format('m-d');
//Set the correct color for the table
if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
$color = 'table-warning';
} else if($today->lessThan($rentalTemp)) {
$color = 'table-danger';
} else {
$color = 'table-primary';
}
//Set the contact name based on the contact type
if($moon->rental_contact_type == 'Alliance') {
$allianceInfo = $lookupHelper->GetAllianceInfo($moon->rental_contact_id);
//Set the contact name and ticker
$contact = $allianceInfo->name;
$ticker = $allianceInfo->ticker;
} else if($moon->rental_contact_type == 'Corporation') {
$corporationInfo = $lookupHelper->GetCorporationInfo($moon->rental_contact_id);
//Set the contact name and ticker
$contact = $corporationInfo->name;
$ticker = $corporationInfo->ticker;
} else if($moon->rental_contact_type == 'Character') {
$characterInfo = $lookupHelper->GetCharacterInfo($moon->rental_contact_id);
//Set the contact name
$contact = $characterInfo->name;
//Get the ticker for the character from the corporation he belongs to
$corpInfo = $lookupHelper->GetCorporationInfo($characterInfo->corporation_id);
$ticker = $corpInfo->ticker;
} else {
$contact = 'N/A';
$ticker = 'N/A';
$type = 'N/A';
$color = 'table-primary';
}
//Check if the moon is currently being utilized by the alliance
} else if($moon->rental_type == 'Alliance') {
//If the moon is in use by the alliance then the moon isn't paid for
$paid = 'No';
//Setup the rental end time as the end of the month
$rentalTemp = Carbon::now()->endOfMonth();
$rentalEnd = $rentalTemp->format('m-d');
//Set the color of the table
$color = 'table-info';
//Setup the paid time as the same as the rental end
$paidUntiltemp = $rentalTemp;
$paidUntil = $rentalEnd;
//Set the other information for the spreadsheet
$contact = 'Spatial Forces';
$renter = 'SP3C';
$ticker = 'SP3C';
$type = 'Alliance';
//The last case is the moon is not utilized by the Alliance or is not being rented
} else {
//If the moon is not being rented, or being utilized by the alliance then set paid to No
$paid = 'No';
//Setup the rental time to end as last month to show it's free
$rentalTemp = $lastMonth;
$rentalEnd = $rentalTemp->format('m-d');
//Setup the paid until as last month to show it's free
$paidUntilTemp = $lastMonth;
$paidUntil = $lastMonth->format('m-d');
//Setup the other variables with the correct information
$contact = 'None';
$renter = 'None';
$ticker = 'N/A';
$type = 'N/A';
//Set the color of the table
$color = 'table-primary';
}
//Set up the moon rental type
if($moon->rental_type == 'In Alliance') {
$type = 'IA';
//Setup the row color
if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
$color = 'table-warning';
} else if($today->lessThan($rentalTemp)) {
$color = 'table-danger';
} else {
$color = 'table-primary';
}
} else if($moon->rental_type == 'Out of Alliance') {
$type = 'OOA';
//Setup the row color
if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
$color = 'table-warning';
} else if($today->lessThan($rentalTemp)) {
$color = 'table-danger';
} else {
$color = 'table-primary';
}
} else if($moon->rental_type == 'Alliance') {
$type = 'W4RP';
//Set the row color
$color = 'table-info';
} else {
$type = 'N/A';
//Set the row color
$color = 'table-primary';
}
//Add the data to the html string to be passed to the view
array_push($table, [
'SPM' => $moon->system . " - " . $moon->planet . " - " . $moon->moon,
'StructureName' => $moon->structure_name,
'AlliancePrice' => $moon->alliance_rental_price,
'OutOfAlliancePrice' => $moon->out_of_alliance_rental_price,
'RentalEnd' => $rentalEnd,
'RowColor' => $color,
'Paid' => $moon->paid,
'PaidUntil' => $paidUntil,
'Contact' => $contact,
'Type' => $moon->rental_type,
'Renter' => $type,
]);
}
return view('moons.admin.adminmoon')->with('table', $table);
}
/**
* Function to store the updates from the moons.
* New function based on new table. Will update
* the description in a future update
*/
public function storeUpdateMoon(Request $request) {
//Require the site administration role
$this->middleware('role:Admin');
//Declare some variables we will need
$moonCalc = new MoonCalc;
$lookup = new LookupHelper;
$paid = false;
$system = null;
$planet = null;
$mn = null;
$name = null;
//Validate our request from the html form
$this->validate($request, [
'spmn' => 'required',
'contact' => 'required',
'contact_type' => 'required',
'paid_until' => 'required',
'rental_end' => 'required',
]);
//Decode the System, Planet, Moon, Name combinatio sent from the controller
//Decode the spmn
$str_array = explode(" - ", $request->spmn);
$system = $str_array[0];
$planet = $str_array[1];
$mn = $str_array[2];
$name = $str_array[3];
//Take the contact name and create a character_id from it
if($request->contact == 'None') {
$contact = -1;
} else {
$contact = $lookup->CharacterNameToId($request->contact);
}
//After we get the contact, from his name to the character Id, let's do some other functions before continuing.
//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
//Update the paid value from the request value
if($request->paid == 'Yes') {
$paid = 'Yes';
} else {
$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;
}
//Create the paid until date
if(isset($request->paid_until)) {
$paidUntil = new Carbon($request->paid_until . '00:00:01');
} else {
$paidUntil = Carbon::now();
}
//Setup the rental end and paid until variables
$rentalEnd = $request->rental_end . " 23:59:59";
$paidUntil = $request->paid_until . " 23:59:59";
//Create the rental end date
if(isset($request->rental_end)) {
$rentalEnd = new Carbon($request->rental_end . '23:59:59');
} else {
$rentalEnd = Carbon::now();
}
//Check if the alliance is renting the moon for itself
if($request->contact_type == 'Corporation' && $request->contact == 'Spatial Forces') {
AllianceRentalMoon::where([
'system' => $str_array[0],
'planet' => $str_array[1],
'moon' => $str_array[2],
])->update([
'rental_type' => 'Alliance',
'rental_until' => $request->rental_end . " 23:59:59",
'rental_contact_id' => 98287666,
'rental_contact_type' => 'Alliance',
'paid' => 'No',
'paid_until' => null,
'alliance_use_until' => $request->rental_end . " 23:59:59",
]);
} else if($request->contact_type == 'Character') {
//Get the character id from the lookup helper
$charId = $lookup->CharacterNameToId($request->contact);
//Get the character information including the corporation from the lookup tables
$char = $lookup->GetCharacterInfo($charId);
//Get the corporation id from the lookup helper, followed by the alliance id
//so we can determine if it's in alliance or out of alliance
$corp = $lookup->GetCorporationInfo($char->corporation_id);
//Calculate the price of the moon for when it's updated
$moon = RentalMoon::where([
'System' => $system,
'Planet' => $planet,
'Moon' => $mn,
])->first();
//Calculate the price of the rental and store it in the database
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
//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();
if($corp->alliance_id == 99004116) {
$type = 'In Alliance';
} 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();
$type = 'Out of Alliance';
}
} 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,
]);
AllianceRentalMoon::where([
'system' => $str_array[0],
'planet' => $str_array[1],
'moon' => $str_array[2],
])->update([
'rental_type' => $type,
'rental_until' => $request->rental_end . " 23:59:59",
'rental_contact_id' => $charId,
'rental_contact_type' => 'Character',
'paid' => $paid,
'paid_until' => $request->paid_until . " 23:59:59",
'alliance_use_until' => null,
]);
} else if($request->contact_type == 'Corporation') {
//Get the corporation id from the lookup helper
$corpId = $lookup->CorporationNameToId($request->contact);
//Get the corporation information to determine if they are in Warped Intentions or not.
$corporation = $lookup->GetCorporationInfo($request->contact);
if($corp->alliance_id == 99004116) {
$type = 'In Alliance';
} else {
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,
]);
$type = 'Out of Alliance';
}
} 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();
AllianceMoonRental::where([
'system' => $str_array[0],
'planet' => $str_array[1],
'moon' => $str_array[2],
])->update([
'rental_type' => $type,
'rental_until' => $request->rental_end . " 23:59:59",
'rental_contact_id' => $corpId,
'rental_contact_type' => 'Corporation',
'paid' => $paid,
'paid_until' => $request->paid_until . " 23:59:59",
'alliance_use_until' => null,
]);
}
//Redirect to the previous screen.
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Rental updated.');
}
public function ImportMoonSurveyData(Request $request) {
//Declare variables
$added = 0;
$updated = 0;
$moon = null;
$newMoon = false;
$num = 0;
$planet = null;
$moonNumber = null;
foreach(explode("\n", $request->input('data')) as $row) {
$cols = explode("\t", $row);
dd($cols);
}
return redirect('/admin/dashboard')->with('success', 'Import done: ' . $added . ' moons added ' . $updated . ' moons updated.');
}
private function romanNumberToInteger($roman) {
$result = 0;
foreach($this->romans as $key => $value) {
while(strpos($roman, $key) === 0) {
$result += $value;
$roman = substr($roman, strlen($key));
}
}
//Redirect to the update moon page
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Updated');
return $result;
}
private function integerToRomanNumber($number) {
$returnValue = '';
while($number > 0) {
foreach($this->romans as $roman => $int) {
if($number >= $int) {
$number -= $int;
$returnValue .= $roman;
break;
}
}
}
return $returnValue;
}
private function arrayToCsv(array $rows) {
//Declare needed variable as text null
$result = '';
//Open the temp file
$fp = fopen('php://temp', 'w');
//Process the file
foreach($rows as $fields) {
fputcsv($fp, $fields, ';', '"');
}
//Go back to the beginning of the file
rewind($fp);
//Continue through the buffer until the end
while(($buffer = fgets($fp, 4096)) !== false) {
$result .= $buffer;
}
//Close the temp file
fclose($fp);
//Return the result
return $result;
}
}

View File

@@ -12,17 +12,19 @@ use Carbon\Carbon;
//Models
use App\Models\Moon\Config;
use App\Models\Moon\ItemComposition;
use App\Models\Moon\RentalMoon;
use App\Models\Moon\OrePrice;
use App\Models\Moon\Price;
use App\Models\MoonRent\MoonRental;
use App\Models\Moon\AllianceMoon;
use App\Models\MoonRentals\AllianceRentalMoon;
use App\Models\Moon\AllianceMoonRequest;
//Library
use App\Library\Moons\MoonCalc;
use App\Library\Lookups\LookupHelper;
//Jobs
use App\Jobs\ProcessSendEveMailJob;
class MoonsController extends Controller
{
public function __construct() {
@@ -30,6 +32,10 @@ class MoonsController extends Controller
$this->middleware('role:Renter');
}
public function displayRentalMoonPage() {
return view('moons.user.requestrental');
}
/**
* Function to display all alliance moons and pass data to the blade template
*/
@@ -150,6 +156,7 @@ class MoonsController extends Controller
'Z-H2MA',
'B-KDOZ',
'E8-YS9',
'DY-P7Q',
];
//Declare lookup variables
@@ -176,20 +183,6 @@ class MoonsController extends Controller
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) {
@@ -226,87 +219,96 @@ class MoonsController extends Controller
'Availability' => 'Request Pending',
]);
//Send a mail over to the site admins to approve the moon request
$config = config('esi');
$body = 'A new moon request has been entered into the services site. Please approve or deny the request within 3 business days.<br><br>';
$body .= 'Sincerely,<br>';
$body .= 'W4RP Services Site';
$subject = 'New Moon Request Available';
ProcessSendEveMailJob::dispatch($body, 92947432, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
ProcessSendEveMailJob::dispatch($body, 92626011, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(60));
return redirect('/moons/display/request')->with('success', 'Moon request submitted.');
}
/**
* Function to display the moons and pass data to the blade template
* Function to display the moons and pass to the blade template
* Function description will be updated in a future release.
*/
public function displayRentalMoons() {
$rentalEnd = '';
//Get the user type from the user Auth class
$type = Auth::user()->getUserType();
//Setup calls to the MoonCalc class
$moonCalc = new MoonCalc();
//get all of the rental moons from the database
$moons = DB::table('RentalMoons')->orderBy('System', 'asc')->get();
//Set the rental date as last month for moons not rented
//Declare variables
$lastMonth = Carbon::now()->subMonth();
//Set a variable for today's date
$today = Carbon::now();
//declare the html variable and set it to null
$table = array();
$moonprice = null;
foreach($moons as $moon) {
//get the rental data for the moon
$rental = MoonRental::where([
'System' => $moon->System,
'Planet' => $moon->Planet,
'Moon' => $moon->Moon,
])->first();
if($rental == false) {
//If we don't find a rental record, set the rental date as last month
//Get the user type from the user Auth class
$type = auth()->user()->getUserType();
//Get all of the rental moons from the database
$moons = AllianceRentalMoon::orderBy('system', 'ASC')
->orderBy('planet', 'ASC')
->orderBy('moon', 'ASC')
->get();
//For each of the moons let's format the data for the display table
foreach($moons as $moon) {
$color = null;
$rentalTemp = null;
$rentalEnd = null;
//Check if someone is currently renting the moon
if($moon->rental_type == 'In Alliance' || $moon->rental_type == 'Out of Alliance') {
$rentalTemp = new Carbon($moon->rental_until);
$rentalEnd = $rentalTemp->format('m-d');
//Setup the correct color for the table
if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
$color = 'table-warning';
} else if($today->lessThan($rentalTemp)) {
$color = 'table-danger';
} else {
$color = 'table-primary';
}
} else if($moon->rental_type == 'Alliance') {
$rentalTemp = Carbon::now()->endOfMonth();
$rentalEnd = $rentalTemp->format('m-d');
$color = 'table-info';
} else {
//Set the rental date for if someone is not renting the moon
$rentalTemp = $lastMonth;
$rentalEnd = $rentalTemp->format('m-d');
} else {
//Set the rental date up
$rentalTemp = new Carbon($rental->RentalEnd);
$rentalEnd = $rentalTemp->format('m-d');
}
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
$worth = $moonCalc->SpatialMoonsTotalWorth($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
if($type == 'W4RP') {
$moonprice = $price['alliance'];
} else {
$moonprice = $price['outofalliance'];
}
if($rentalTemp->diffInDays($today) < 3 ) {
$color = 'table-warning';
} else if( $today > $rentalTemp) {
$color = 'table-primary';
} else {
$color = 'table-danger';
}
//Add the data to the html string to be passed to the view
//Get the price of the moon from the database based on if the person is in Warped Intentions
$userType = auth()->user()->getUserType();
if($userType == 'W4RP') {
$moonprice = $moon->alliance_rental_price;
} else {
$moonprice = $moon->out_of_alliance_rental_price;
}
//Add the data to the html array to be passed to the view
array_push($table, [
'SPM' => $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon,
'StructureName' => $moon->StructureName,
'FirstOre' => $moon->FirstOre,
'FirstQuantity' => $moon->FirstQuantity,
'SecondOre' => $moon->SecondOre,
'SecondQuantity' => $moon->SecondQuantity,
'ThirdOre' => $moon->ThirdOre,
'ThirdQuantity' => $moon->ThirdQuantity,
'FourthOre' => $moon->FourthOre,
'FourthQuantity' => $moon->FourthQuantity,
'Price' => $moonprice,
'Worth' => number_format($worth, "2", ".", ","),
'SPM' => $moon->system . " - " . $moon->planet . " - " . $moon->moon,
'StructureName' => $moon->structure_name,
'FirstOre' => $moon->first_ore,
'FirstQuantity' => number_format($moon->first_quantity, 0, ".", ","),
'SecondOre' => $moon->second_ore,
'SecondQuantity' => number_format($moon->second_quantity, 0, ".", ","),
'ThirdOre' => $moon->third_ore,
'ThirdQuantity' => number_format($moon->third_quantity, 0, ".", ","),
'FourthOre' => $moon->fourth_ore,
'FourthQuantity' => number_format($moon->fourth_quantity, 0, ".", ","),
'Price' => number_format($moonprice, 0, ".", ","),
'Worth' => number_format($moon->moon_worth, 0, ".", ","),
'RentalEnd' => $rentalEnd,
'RowColor' => $color,
]);
}
//Pass the data to the view
return view('moons.user.moon')->with('table', $table);
}
@@ -331,6 +333,10 @@ class MoonsController extends Controller
'Hydrocarbons' => 0,
'Silicates' => 0,
'Cobalt' => 0,
'Scandium' => 0,
'Titanium' => 0,
'Tungsten' => 0,
'Cadmium' => 0,
'Platinum' => 0,
'Vanadium'=> 0,
'Chromium' => 0,
@@ -383,11 +389,14 @@ class MoonsController extends Controller
$reprocessing = 0.84;
}
//Calculate the total moon goo value
$totalGoo = $moonCalc->SpatialMoonsOnlyGooTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
//Format the number to send to the blade
$totalGoo = number_format($totalGoo, 2, ".", ",");
//Get the total percentage of the ores, and normalize it to 1.00.
$totalPercent = $firstQuantity + $secondQuantity + $thirdQuantity + $fourthQuantity;
if($totalPercent < 1.00) {
$firstQuantity = $firstQuantity / $totalPercent;
$secondQuantity = $secondQuantity / $totalPercent;
$thirdQuantity = $thirdQuantity / $totalPercent;
$fourthQuantity = $fourthQuantity / $totalPercent;
}
//Calculate the total worth of the moon
$totalWorth = $moonCalc->SpatialMoonsTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
@@ -418,6 +427,10 @@ class MoonsController extends Controller
$composition['Hydrocarbons'] += floor(($firstComp->Hydrocarbons * $rUnits) * $reprocessing);
$composition['Silicates'] += floor(($firstComp->Silicates * $rUnits) * $reprocessing);
$composition['Cobalt'] += floor(($firstComp->Cobalt * $rUnits) * $reprocessing);
$composition['Scandium'] += floor(($firstComp->Scandium * $rUnits) * $reprocessing);
$composition['Titanium'] += floor(($firstComp->Titanium * $rUnits) * $reprocessing);
$composition['Tungsten'] += floor(($firstComp->Tungsten * $rUnits) * $reprocessing);
$composition['Cadmium'] += floor(($firstComp->Cadmium * $rUnits) * $reprocessing);
$composition['Platinum'] += floor(($firstComp->Platinium * $rUnits) * $reprocessing);
$composition['Vanadium'] += floor(($firstComp->Vanadium * $rUnits) * $reprocessing);
$composition['Chromium'] += floor(($firstComp->Chromium * $rUnits) * $reprocessing);
@@ -453,6 +466,10 @@ class MoonsController extends Controller
$composition['Hydrocarbons'] += floor(($secondComp->Hydrocarbons * $rUnits) * $reprocessing);
$composition['Silicates'] += floor(($secondComp->Silicates * $rUnits) * $reprocessing);
$composition['Cobalt'] += floor(($secondComp->Cobalt * $rUnits) * $reprocessing);
$composition['Scandium'] += floor(($secondComp->Scandium * $rUnits) * $reprocessing);
$composition['Titanium'] += floor(($secondComp->Titanium * $rUnits) * $reprocessing);
$composition['Tungsten'] += floor(($secondComp->Tungsten * $rUnits) * $reprocessing);
$composition['Cadmium'] += floor(($secondComp->Cadmium * $rUnits) * $reprocessing);
$composition['Platinum'] += floor(($secondComp->Platinium * $rUnits) * $reprocessing);
$composition['Vanadium'] += floor(($secondComp->Vanadium * $rUnits) * $reprocessing);
$composition['Chromium'] += floor(($secondComp->Chromium * $rUnits) * $reprocessing);
@@ -488,6 +505,10 @@ class MoonsController extends Controller
$composition['Hydrocarbons'] += floor(($thirdComp->Hydrocarbons * $rUnits) * $reprocessing);
$composition['Silicates'] += floor(($thirdComp->Silicates * $rUnits) * $reprocessing);
$composition['Cobalt'] += floor(($thirdComp->Cobalt * $rUnits) * $reprocessing);
$composition['Scandium'] += floor(($thirdComp->Scandium * $rUnits) * $reprocessing);
$composition['Titanium'] += floor(($thirdComp->Titanium * $rUnits) * $reprocessing);
$composition['Tungsten'] += floor(($thirdComp->Tungsten * $rUnits) * $reprocessing);
$composition['Cadmium'] += floor(($thirdComp->Cadmium * $rUnits) * $reprocessing);
$composition['Platinum'] += floor(($thirdComp->Platinium * $rUnits) * $reprocessing);
$composition['Vanadium'] += floor(($thirdComp->Vanadium * $rUnits) * $reprocessing);
$composition['Chromium'] += floor(($thirdComp->Chromium * $rUnits) * $reprocessing);
@@ -523,6 +544,10 @@ class MoonsController extends Controller
$composition['Hydrocarbons'] += floor(($fourthComp->Hydrocarbons * $rUnits) * $reprocessing);
$composition['Silicates'] += floor(($fourthComp->Silicates * $rUnits) * $reprocessing);
$composition['Cobalt'] += floor(($fourthComp->Cobalt * $rUnits) * $reprocessing);
$composition['Scandium'] += floor(($fourthComp->Scandium * $rUnits) * $reprocessing);
$composition['Titanium'] += floor(($fourthComp->Titanium * $rUnits) * $reprocessing);
$composition['Tungsten'] += floor(($fourthComp->Tungsten * $rUnits) * $reprocessing);
$composition['Cadmium'] += floor(($fourthComp->Cadmium * $rUnits) * $reprocessing);
$composition['Platinum'] += floor(($fourthComp->Platinium * $rUnits) * $reprocessing);
$composition['Vanadium'] += floor(($fourthComp->Vanadium * $rUnits) * $reprocessing);
$composition['Chromium'] += floor(($fourthComp->Chromium * $rUnits) * $reprocessing);
@@ -537,7 +562,6 @@ class MoonsController extends Controller
}
return view('moons.user.displayTotalWorth')->with('totalWorth', $totalWorth)
->with('totalGoo', $totalGoo)
->with('composition', $composition)
->with('reprocessing', $reprocessing);
}

View File

@@ -0,0 +1,62 @@
<?php
namespace App\Http\Controllers\Moons;
//Internal Library
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Auth;
use Log;
use Carbon\Carbon;
//Models
use App\Models\Moon\AllianceRentalMoon;
class RentalMoonsAdminController extends Controller
{
/**
* Construct
*/
public function __construct() {
$this->middleware('auth');
$this->middelware('role:user');
$this->middleware('permission:mining.director');
}
/**
* Function to display rental moons being used for the alliance
*/
public function displayAllianceUsageRentalMoons() {
}
/**
* Display the form for requesting new rental moon for the alliance
*/
public function displayRentalMoonForAllianceForm() {
}
/**
* Function to store when a new rental moon is requested
*/
public function storeRentalMoonForAlliance(Request $request) {
}
/**
* Function to display the form for figuring out item composition
*/
public function displayItemCompositionForm() {
}
/**
* Function to display the results of the form for figuring out item composition
*/
public function displayItemCompositionResults(Request $request) {
}
}

View File

@@ -85,8 +85,13 @@ class SRPAdminController extends Controller
//Calculate the recommended srp amount
foreach($payouts as $p) {
if($r['ship_type'] == $p->code) {
$temp['actual_srp'] = $r['loss_value'] * ($p->payout / 100.00 );
$temp['payout_percentage'] = $p->payout;
$payout = $p->payout;
if($temp['character_name'] == $temp['fleet_commander_name']) {
$payout = 100.00;
}
$temp['actual_srp'] = $r['loss_value'] * ($payout / 100.00 );
$temp['payout_percentage'] = $payout;
$sum_actual += $temp['actual_srp'];
}
}

View File

@@ -0,0 +1,156 @@
<?php
namespace App\Http\Controllers\SystemRentals;
//Internal Library
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Auth;
use DB;
use Carbon\Carbon;
//Models
use App\Models\SystemRentals\RentalSystem;
//Library
use App\Library\Lookups\LookupHelper;
use App\Library\Esi\Esi;
class RentalAdminController extends Controller
{
//Constructor
public function __construct() {
$this->middleware('auth');
$this->middleware('role:Admin');
}
/**
* Function to display all active rental systems and
* the information regarding the rental systems
*/
public function displayRentalSystems() {
//Get the rental systems from the database
$rentals = RentalSystem::all();
foreach($rentals as $rental) {
//Format the rental cost
if($rental->rental_cost > 1000000000.00) {
$rental->rental_cost = $rental->rental_cost / 1000000000.00;
$rental->rental_cost = $rental->rental_cost . "B";
} else if($rental->rental_cost > 1000000.00 && $rental->rental_cost < 999999999.99) {
$rental->rental_cost = $rental->rental_cost / 1000000.00;
$rental->rental_cost = $rental->rental_cost . "M";
}
//Format the date
$rental->paid_until = Carbon::parse($rental->paid_until)->format('Y-m-d');
}
//Return the view with the data
return view('rental.list')->with('rentals', $rentals);
}
/**
* Function to display form for adding new rental system
*/
public function displayAddRentalSystem() {
return view('rental.add');
}
/**
* Function to add new rental system to the database
*/
public function addRentalSystem(Request $request) {
$this->validate($request, [
'contact_name' => 'required',
'contact_corp_name' => 'required',
'system' => 'required',
'rental_cost' => 'required',
'paid_until' => 'required',
]);
//Declare the variables and classes needed
$lookup = new LookupHelper;
//From the character name find the character id
$charId = $lookup->CharacterNameToId($request->contact_name);
//From the corporation name find the corporation id
$corpId = $lookup->CorporationNameToId($request->contact_corp_name);
//From the system name find the system id
$systemId = $lookup->SystemNameToId($request->system);
//Sanitize the bid amount
if(preg_match('(m|M|b|B)', $request->rental_cost) === 1) {
if(preg_match('(m|M)', $request->rental_cost) === 1) {
$cStringSize = strlen($request->rental_cost);
$tempCol = str_split($request->rental_cost, $cStringSize - 1);
$rentalCost = $tempCol[0];
$rentalCost = $rentalCost * 1000000.00;
} else if(preg_match('(b|B)', $request->rental_cost) === 1) {
$cStringSize = strlen($request->rental_cost);
$tempCol = str_split($request->rental_cost, $cStringSize - 1);
$rentalCost = $tempCol[0];
$rentalCost = $rentalCost * 1000000000.00;
}
} else {
$rentalCost = $request->rental_cost;
}
//Create the database model
$rental = new RentalSystem;
$rental->contact_id = $charId;
$rental->contact_name = $request->contact_name;
$rental->corporation_id = $corpId;
$rental->corporation_name = $request->contact_corp_name;
$rental->system_id = $systemId;
$rental->system_name = $request->system;
$rental->rental_cost = $rentalCost;
$rental->paid_until = $request->paid_until;
$rental->save();
return redirect('/system/rental/dashboard')->with('success', 'Rental System Added.');
}
/**
* Function to update paid until section of the rental system in the database
*/
public function updateRentalSystem(Request $request) {
$this->validate($request, [
'paid_until' => 'required',
'contact_id' => 'required',
'corporation_id' => 'required',
'system_id' => 'required',
]);
RentalSystem::where([
'contact_id' => $request->contact_id,
'corporation_id' => $request->corporation_id,
'system_id' => $request->system_id,
])->update([
'paid_until' => $request->paid_until,
]);
return redirect('/system/rental/dashboard')->with('success', 'Rental System updated.');
}
/**
* Function to remove rental system from the database
*/
public function removeRentalSystem(Request $request) {
$this->validate($request, [
'contact_id' => 'required',
'corporation_id' => 'required',
'system_id' => 'required',
]);
RentalSystem::where([
'contact_id' => $request->contact_id,
'corporation_id' => $request->corporation_id,
'system_id' => $request->system_id,
])->delete();
return redirect('/system/rental/dashboard')->with('success', 'Removed renter from database.');
}
}

View File

@@ -1,148 +0,0 @@
<?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);
}
}

View File

@@ -60,7 +60,7 @@ class Kernel extends HttpKernel
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'callback' => \App\Http\Middleware\Callback::class,
//'callback' => \App\Http\Middleware\Callback::class,
'role' => \App\Http\Middleware\RequireRole::class,
'permission' => \App\Http\Middleware\RequirePermission::class,
];

View File

@@ -2,29 +2,120 @@
namespace App\Http\Middleware;
//Internal Library
use Closure;
use Illuminate\Support\Facades\Auth;
use Socialite;
use DB;
use App\Models\User\User;
//Libraries
use Seat\Eseye\Cache\NullCache;
use Seat\Eseye\Configuration;
use Seat\Eseye\Containers\EsiAuthentication;
use Seat\Eseye\Eseye;
//Models
use App\Models\User\User;
use App\Models\Esi\EsiToken;
use App\Models\Esi\EsiScope;
class Callback
{
/**
* Handle an incoming request.
* Handle an incoming request for callback. Set to handle the request after the
* login controller does what it needs to do.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
public function handle($request, Closure $next, $ssoUser)
{
return $next($request);
$response = $next($request);
if(isset($ssoUser->refreshToken)) {
//See if an access token is present for the user
$tokenCount = EsiToken::where(['character_id' => $ssoUser->id])->count();
if($tokenCount > 0) {
//Update the esi token
$this->UpdateEsiToken($ssoUser);
} else {
//Save the esi token
$this->SaveEsiToken($ssoUser);
}
//After creating or updating the token, update the table for the scopes.
$this->SetScopes($ssoUser->user['Scopes'], $ssoUser->id);
} else {
$created = $this->createAlt($ssoUser);
}
return $response;
}
/**
* Update the ESI Token
*/
private function UpdateEsiToken($eve_user) {
EsiToken::where('character_id', $eve_user->id)->update([
'character_id' => $eve_user->getId(),
'access_token' => $eve_user->token,
'refresh_token' => $eve_user->refreshToken,
'inserted_at' => time(),
'expires_in' => $eve_user->expiresIn,
]);
}
/**
* Create a new ESI Token in the database
*/
private function SaveEsiToken($eve_user) {
$token = new EsiToken;
$token->character_id = $eve_user->id;
$token->access_token = $eve_user->token;
$token->refresh_token = $eve_user->refreshToken;
$token->inserted_at = time();
$token->expires_in = $eve_user->expiresIn;
$token->save();
}
private function SetScopes($scopes, $charId) {
//Delete the current scopes, so we can add new scopes into the database
EsiScope::where('character_id', $charId)->delete();
$scopes = explode(' ', $scopes);
foreach($scopes as $scope) {
$data = new EsiScope;
$data->character_id = $charId;
$data->scope = $scope;
$data->save();
}
}
/**
* Check if an alt exists in the database, else, create and
* return the user object.
*
* @param \Laravel\Socialite\Two\User $user
*/
private function createAlt($user) {
$altCount = UserAlt::where('character_id', $user->id)->count();
if($altCount == 0) {
$newAlt = new UserAlt;
$newAlt->name = $user->getName();
$newAlt->main_id = auth()->user()->getId();
$newAlt->character_id = $user->id;
$newAlt->avatar = $user->avatar;
$newAlt->access_token = $user->token;
$newAlt->owner_hash = $user->owner_hash;
$newAlt->inserted_at = time();
$newAlt->expires_in = $user->expiresIn;
$newAlt->save();
return 1;
} else {
return 0;
}
}
}

View File

@@ -12,7 +12,6 @@ class TrimStrings extends Middleware
* @var array
*/
protected $except = [
'password',
'password_confirmation',
//
];
}

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Jobs\Commands\Eve;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Log;
//Library
use App\Library\Moons\MoonCalc;
class ItemPricesUpdateJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$moonHelper = new MoonCalc;
$moonHelper->FetchNewPrices();
}
}

View File

@@ -0,0 +1,152 @@
<?php
namespace App\Jobs\Commands\Moons;
//Internal Libraries
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Log;
//App Library
use Seat\Eseye\Exceptions\RequestFailedException;
use App\Library\Esi\Esi;
use App\Library\Lookups\LookupHelper;
use App\Library\Structures\StructureHelper;
//App Models
use App\Models\Moon\CorpMoonLedger;
use App\Models\Moon\CorpMoonObserver;
class FetchMoonLedgerJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Timeout in seconds
*
* @var int
*/
public $timeout = 3600;
/**
* Retries
*
* @var int
*/
public $retries = 3;
/**
* Private Variables
*/
private $charId;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($charId)
{
//Set the character id
$this->charId = $charId;
//Set the connection
$this->connection = 'redis';
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//Declare Variables
$esiHelper = new Esi;
$lookup = new LookupHelper;
$response = null;
$structureInfo = null;
//Get the configuration for the main site
$config = config('esi');
//Check for esi scope for the character
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($this->charId, 'esi-universe.read_structures.v1')) {
Log::critical('The primary character does not have the necessary scopes for FetchRentalMoonLedgerCommand.');
return;
}
//Get the refresh token if the scope checks have passed
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
//Setup the esi information
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
//Get the character data from the lookup table
$character = $lookup->GetCharacterInfo($this->charId);
//Get the corporation data from the lookup table
$corporation = $lookup->GetCorporationInfo($character->corporation_id);
//Setup the structure helper
$structure = new StructureHelper($this->charId, $character->corporation_id, $esi);
//Get the moon observers from the database
$observers = CorpMoonObserver::where([
'corporation_id' => $character->corporation_id,
])->get();
foreach($observers as $observer) {
//Try to get the ledger data from the esi
try {
$ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
'corporation_id' => $character->corporation_id,
'observer_id' => $observer->observer_id,
]);
} catch(RequestFailedException $e) {
//Log the exception
Log::critical('FetchMoonLedger job failed to get the mining ledgers.');
}
if($ledgers != null) {
foreach($ledgers as $ledger) {
//Get the ore name from the lookup table
$ore = $lookup->ItemIdToName($ledger->type_id);
//Get the character name from the lookup helper
$charInfo = $lookup->GetCharacterInfo($ledger->character_id);
//Get the corporation info from the lookup helper
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
//Get the recorded corporation information
$recordedCorpInfo = $lookup->GetCorporationInfo($ledger->recorded_corporation_id);
$entries[] = [
'corporation_id' => $corpInfo->corporation_id,
'corporation_name' => $corpInfo->name,
'character_id' => $ledger->character_id,
'character_name' => $charInfo->name,
'observer_id' => $observer->observer_id,
'observer_name' => $observer->observer_name,
'type_id' => $ledger->type_id,
'ore' => $ore,
'quantity' => $ledger->quantity,
'recorded_corporation_id' => $ledger->recorded_corporation_id,
'recorded_corporation_name' => $recordedCorpInfo->name,
'last_updated' => $ledger->last_updated,
'created_at' => $ledger->last_updated . ' 23:59:59',
'updated_at' => $ledger->last_updated . ' 23:59:59',
];
}
//Insert or ignore each entry into the database
CorpMoonLedger::insertOrIgnore($entries);
Log::info('FetchMoonLedgerJob inserted up to ' . count($entries) . 'into the database.');
}
}
}
}

View File

@@ -0,0 +1,130 @@
<?php
namespace App\Jobs\Commands\Moons;
//Internal Library
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Log;
//App Library
use Seat\Eseye\Exceptions\RequestFailedException;
use App\Library\Esi\Esi;
use App\Library\Lookups\LookupHelper;
use App\Library\Structures\StructureHelper;
//App Models
use App\Models\Moon\CorpMoonObserver;
class FetchMoonObserverJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Timeout in seconds
*
* @var int
*/
public $timeout = 3600;
/**
* Retries
*
* @var int
*/
public $retries = 3;
/**
* Private variables
*/
private $charId;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($charId)
{
//Set the character id
$this->charId = $charId;
//Set the connection
$this->connection = 'redis';
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//Declare some variables
$lookup = new LookupHelper;
$esiHelper = new Esi;
//Get the configuration from the main site
$config = config('esi');
//Check for the esi scope
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($this->charId, 'esi-universe.read_structures.v1')) {
Log::warning('Esi scopes were not found for Fetch Moon Observers job.');
return;
}
//Get the refresh token for the character
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
//Get the esi variable
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
//With the lookup helper, get the character information
$character = $lookup->GetCharacterInfo($this->charId);
//With the lookup helper, get the corporation information
$corporation = $lookup->GetCorporationInfo($character->corporation_id);
//Delcare the structure helper since we have the necessary data
$structureHelper = new StructureHelper($this->charId, $character->corporation_id, $esi);
//Get the mining observers for the corporation's from esi
try {
$response = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
'corporation_id' => $character->corporation_id,
]);
} catch(RequestFailedException $e) {
Log::critical('FetchMoonObservers failed to get the moon observers for the corporation');
return null;
}
//Run through the mining observers, and add them to the database as needed
foreach($response as $observer) {
$count = CorpMoonObserver::where(['observer_id' => $observer->observer_id])->count();
//If the observer is not found, then add it to the database
if($count == 0) {
//Get the structure information from the universe structure esi endpoint
$structureInfo = $structureHelper->GetStructureInfo($observer->observer_id);
//Create a new corp moon observer in the database
$obs = new CorpMoonObserver;
$obs->corporation_id = $character->corporation_id;
$obs->corporation_name = $corporation->name;
$obs->observer_id = $observer->observer_id;
$obs->observer_name = $structureInfo->name;
$obs->observer_owner_id = $structureInfo->owner_id;
$obs->solar_system_id = $structureInfo->solar_system_id;
$obs->observer_type = $observer->observer_type;
$obs->observer_type_id = $structureInfo->type_id;
$obs->last_updated = $observer->last_updated;
$obs->save();
} else {
CorpMoonObserver::where([
'observer_id' => $observer->observer_id,
])->update([
'last_updated' => $observer->last_updated,
]);
}
}
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Jobs\Commands\Moons;
//Internal Libraries
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Log;
use Carbon\Carbon;
//App Models
use App\Models\Moon\CorpMoonLedger;
class PurgeMoonLedgerJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Timeout in seconds
*
* @var int
*/
public $timeout = 3600;
/**
* Retries
*
* @var int
*/
public $retries = 3;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//Set the connection for the job
$this->connection = 'redis';
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$previous = Carbon::now()->subDays(60);
//Remove old ledger entries
CorpMoonLedger::where('created_at', '<', $previous)->delete();
}
}

View File

@@ -0,0 +1,143 @@
<?php
namespace App\Jobs\Commands;
//Internal Libraries
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Log;
//App Library
use Seat\Eseye\Exceptions\RequestFailedException;
use App\Library\Esi\Esi;
use App\Library\Lookups\LookupHelper;
//App Models
use App\Models\RentalMoonLedger;
use App\Models\RentalMoonObserver;
class FetchRentalMoonLedgerJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Timeout in seconds
*
* @var int
*/
public $timeout = 3600;
/**
* Retries
*
* @var int
*/
public $retries = 3;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//Declare variables
$esiHelper = new Esi;
$lookup = new LookupHelper;
$response = null;
$structureInfo = null;
$entries = array();
//Get the configuration for the main site
$config = config('esi');
//Check for the esi scope
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1')) {
Log::critical('The primary character does not have the necessary scopes for FetchRentalMoonLedgerCommand.');
return;
}
//Get the refresh token if scope checks have passed
$refreshToken = $esiHelper->GetRefreshtoken($config['primary']);
//Get the character data from the lookup table if possible or esi
$character = $lookup->GetCharacterInfo($config['primary']);
//Get all of the rental moon observers from the database
$observers = RentalMoonObserver::all();
//Dump the mining ledger table for rental moons
RentalMoonLedger::truncate();
//Foreach observer get the ledger
foreach($observers as $observer) {
//Get the observer name.
$observerInfo = Structure::where([
'structure_id' => $observer->observer_id,
])->first();
try {
$ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
'corporation_id' => $character->corporation_id,
'observer_id' => $observer->observer_id,
]);
} catch(RequestFailedException $e) {
//If an exception has occurred, then log it
Log::critical('FetchRentalMoonLedger command failed to get the mining ledger for observer id: ' . $observer->observer_id);
}
if($ledgers != null) {
foreach($ledgers as $ledger) {
//Get the ore name from the lookup table
$ore = $lookup->ItemIdToName($ledger->type_id);
//Get the character name from the lookup helper using the characterId
$charInfo = $lookup->GetCharacterInfo($ledger->character_id);
//Get the corporation information
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
//Get the recorded corporation information
$recordedCorpInfo = $lookup->GetCorporationInfo($ledger->recorded_corporation_id);
$entries[] = [
'corporation_id' => $corpInfo->corporation_id,
'corporation_name' => $corpInfo->name,
'character_id' => $ledger->character_id,
'character_name' => $charInfo->name,
'observer_id' => $observer->observer_id,
'observer_name' => $observerInfo->name,
'type_id' => $ledger->type_id,
'ore' => $ore,
'quantity' => $ledger->quantity,
'recorded_corporation_id' => $ledger->recorded_corporation_id,
'recorded_corporation_name' => $recordedCorpInfo->name,
'last_updated' => $ledger->last_updated,
'created_at' => $ledger->last_updated . ' 23:59:59',
'updated_at' => $ledger->last_updated . ' 23:59:59',
];
}
//Insert or ignore each of the records saved into the array through the foreach loop
RentalMoonLedger::insertOrIgnore($entries);
Log::info(
'FetchRentalMoonLedgerJob inserted up to ' .count($entires) . ' new ledger entries.'
);
}
}
}
}

View File

@@ -0,0 +1,97 @@
<?php
namespace App\Jobs\Commands;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Log;
//App Library
use Seat\Eseye\Exceptions\RequestFailedException;
use App\Library\Esi\Esi;
use App\Library\Lookups\LookupHelper;
//App Models
use App\Models\Moon\RentalMoonObserver;
class FetchRentalMoonObserversJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Timeout in seconds
*
* @var int
*/
public $timeout = 3600;
/**
* Retries
*
* @var int
*/
public $retries = 3;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//Declare some variables
$lookup = new LookupHelper;
$esi = new Esi;
$obss = array();
//Get the configuration for the main site
$config = config('esi');
//Check for the esi scope
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1')) {
Log::critical('The primary character does not have the necessary scopes for FetchRentalMoonObservers.');
return;
}
//Get the refresh token for spatial forces
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
//Get the character data from the lookup table if possible or esi
$character = $lookup->GetCharacterInfo($config['primary']);
//Get the mining observers for spatial forces from esi
try {
$responses = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
'corporation_id' => $character->corporation_id,
]);
} catch(RequestFailedException $e) {
Log::critical('RentalMoonObservers failed to get the moon observers for Spatial Forces.');
}
//Run through the mining observers, and add them to the database as needed
foreach($responses as $observer) {
//Populate the array with the data, so we can do an insert or ignore after the foreach loop is completed.
$obss[] = [
'observer_id' => $observer->observer_id,
'observer_type' => $observer->observer_type,
'last_updated' => $esi->DecodeDate($observer->last_updated)
];
}
RentalMoonObserver::insertOrIgnore($obss);
}
}

View File

@@ -0,0 +1,95 @@
<?php
namespace App\Jobs\Commands\PublicContracts;
//Internal Libraries
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Log;
use Carbon\Carbon;
//App Library
use Seat\Eseye\Exceptions\RequestFailedException;
use App\Library\Esi\Esi;
use App\Library\Lookups\LookupHelper;
//Jobs
use App\Jobs\Commands\PublicContracts\GetPublicContractItemsJob;
//Models
use App\Models\PublicContracts\PublicContract;
use App\Models\PublicContracts\PUblicContractItem;
class GetPublicContractItemsJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Private Variables
*/
private $esi;
private $contractId;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($esi, $contract)
{
//Setup the variables
$this->esi = $esi;
$this->contractId = $contract;
//Set the connection
$this->connection = 'redis';
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//Get the items from esi
$responses = $this->esi->invoke('get', '/contracts/public/items/{contract_id}/', [
'contract_id' => $this->contract,
]);
foreach($response as $resp) {
//See if the item exists
$count = PublicContractItems::where([
'record_id' => $resp->record_id,
])->count();
//If the item doesn't exist in the database, save it to the database
if($count == 0) {
$contractItem = new PublicContractItems;
if(isset($resp->is_blueprint_copy)) {
$contractItem->is_blueprint_copy = $resp->is_blueprint_copy;
}
$contractItem->is_included = $resp->is_included;
if(isset($resp->item_id)) {
$contractItem->item_id = $resp->item_id;
}
if(isset($resp->material_efficiency)) {
$contractItem->material_efficiency = $resp->material_efficiency;
}
$contractItem->quantity = $resp->quantity;
$contractItem->recorded_id = $resp->recorded_id;
if(isset($resp->runs)) {
$contractItem->runs = $resp->runs;
}
if(isset($resp->time_efficiency)) {
$contractItem->time_efficiency = $resp->time_efficiency;
}
$contractItem->type_id = $resp->type_id;
$contractItem->save();
}
}
}
}

View File

@@ -0,0 +1,115 @@
<?php
namespace App\Jobs\Commands\PublicContracts;
//Internal Libraries
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Log;
use Carbon\Carbon;
//App Library
use Seat\Eseye\Exceptions\RequestFailedException;
use App\Library\Esi\Esi;
use App\Library\Lookups\LookupHellper;
//Models
use App\Models\PublicContracts\PublicContract;
class GetPublicContractsJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Job Variables
*/
private $esi;
private $region;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($regionId, $esi = null)
{
//Setup the esi authentication container
if($esi == null) {
$this->esi = new Esi();
} else {
$this->esi = $esi;
}
//Set the region code
$this->region = $regionId;
//Set the connection
$this->connection = 'redis';
}
/**
* Execute the job.
* The job gets all of the contracts in a region
*
* @return void
*/
public function handle()
{
$responses = $this->esi->invoke('get', '/contracts/public/{region_id}/', [
'region_id' => $this->region,
]);
foreach($response as $resp) {
$count = PublicContract::where([
'contract_id' => $resp->contract_id,
])->count();
if($count == 0) {
$pub = new PublicContract;
$pub->region_id = $this->region;
if(isset($resp->buyout)) {
$pub->buyout = $resp->buyout;
}
if(isset($resp->collateral)) {
$pub->collateral = $resp->collateral;
}
$pub->contract_id = $resp->contract_id;
$pub->date_expired = $resp->date_expired;
$pub->date_issed = $resp->date_issed;
if(isset($resp->days_to_complete)) {
$pub->days_to_complete = $resp->days_to_complete;
}
if(isset($resp->end_location_id)) {
$pub->end_location_id = $resp->end_location_id;
}
if(isset($resp->for_corporation)) {
$pub->for_corporation = $resp->for_corporation;
}
$pub->issuer_corporation_id = $resp->issuer_corporation_id;
$pub->issuer_id = $resp->issuer_id;
if(isset($resp->price)) {
$pub->price = $resp->price;
}
if(isset($resp->reward)) {
$pub->reward = $resp->reward;
}
if(isset($resp->start_location_id)) {
$pub->start_location_id = $resp->start_location_id;
}
if(isset($resp->title)) {
$pub->title = $resp->title;
}
$pub->type = $resp->type;
if(isset($resp->volume)) {
$pub->volume = $resp->volume;
}
//Save the new contract
$pub->save();
//Dispatch a job to collect the contract items
GetPublicContractItemsJob::dispatch($this->esi, $resp->contract_id);
}
}
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace App\Jobs\Commands\PublicContracts;
//Internal Library
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Carbon\Carbon;
use Log;
//Library
//Models
use App\Models\PublicContracts\PublicContract;
use App\Models\PublicContracts\PublicContractItem;
/**
* Job to purge some old data from the public contracts
*/
class PurgePublicContracts implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//Set the connection
$this->connection = 'redis';
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//Get today's date
$today = Carbon::now();
//If the date for a contract has expired, then purge it from the system
$contracts = PublicContract::all();
//Check each contract to see if it has expired
foreach($contracts as $contract) {
//If the contract has expired, then delete the contract and all of it's items
if($today->greaterThan($contract->date_expired)) {
//Delete the contract
PublicContract::where([
'id' => $contract->id,
])->delete();
//Delete the items from the contract from the other table
PublicContract::where([
'contract_id' => $contract->id,
])->delete();
}
}
}
}

View File

@@ -0,0 +1,195 @@
<?php
namespace App\Jobs\Commands\RentalMoons;
//Internal Library
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Log;
use Carbon\Carbon;
//Library
use App\Library\Lookups\LookupHelper;
//Jobs
use App\Jobs\ProcessSendEvveMailJob;
//Models
use App\Models\MoonRentals\AllianceRentalMoon;
use App\Models\Mail\SentMail;
/**
* This job will send out a reminder about the moon rental payment being due
* when it's due based on the rental paid date versus rental date. If the paid
* date is in the future from today, then we don't need to send out a reminder.
* If the paid date is today or less, then we need to send out a reminder about
* paying for the moon rental.
*/
class SendMoonRentalPaymentReminderJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Timeout in seconds
*
* @var int
*/
public $timeout = 1600;
/**
* Retries
*
* @var int
*/
public $retries = 3;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//Set the queue connection
$this->connection = 'redis';
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//Get today's date
$today = Carbon::now();
$today->second = 1;
$today->minute = 0;
$today->hour = 0;
//Declare some other variables
$totalCost = 0.00;
$moonList = array();
$delay = 30;
$lookup = new LookupHelper;
$config = config('esi');
//Get all of the contacts from the rentals group
$contacts = AllianceMoonRental::select('rental_contact_id')->groupBy('rental_contact_id')->get();
//For each of the contacts, totalize the moon rentals, and create a reminder mail
foreach($contacts as $contact) {
//Get the moons the renter is renting, but only get the ones whose paid date is not after today.
$dues = $this->GetMoonDueList($contact->rental_contact_id);
//Get the list of moons for the mail body.
$alls = $this->GetMoonRentalList($contact->rental_contact_id);
//Totalize the cost for the moons whose rent is due
$cost = $this->TotalizeMoonCost($contact->rental_contact_id);
//For each of the rentals, build the mail body, and totalize the cost of the moon
$body = "Moon Rent is due for the following moons:<br>";
foreach($rentalsDue as $due) {
$body .= $due . "<br>";
}
//Put the price for the moons
$body .= "The price for next month's rent is " . number_format($cost, 0, ".", ",") . "<br>";
$body .= "Rental Payment is due on the 1st of the month. If the rental payment is not remitted to Spatial Forces by the 3rd of the month, the rental claim shall be forfeited.<br>";
$body .= "Rental Payment should be transferred to Spatial Forces.<br>";
$body .= "In the description of the payment please put the following transaction identification: " . $transId . "<br>";
$body .= "<br>";
$body .= $contact->contact_name . " is responsible for payment of the moons.<br>";
$body .= "The following moons are being rented:<br>";
foreach($alls as $all) {
$body .= $all . "<br>";
}
$body .= "<br>";
$body .= "Sincerely,<br>";
$body .= "Warped Intentions Leadership<br>";
//Create the subject line
$subject = "Warped Intentions Moon Rental Payment Due for " . $today->englishMonth;
//Dispatch the mail job if the contact type is a character, otherwise
//dispatch the job to the ceo of the corporation instead. If the contact is an alliance
//dispatch the job to the ceo of the holding corporation.
if($contact->contact_type == 'Character') {
ProcessSendEveMailJob::dispatch($body, (int)$contact->rental_contact_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
//Increment the delay to get ready for the next mail job
$delay += 30;
} else if($contact->contact_type == 'Corporation') {
//Get the CEO of the corporation from the lookup helper
$corporation = $lookup->GetCorporationInfo($contact->rental_contact_id);
$charId = $corporation->ceo_id;
//Send out the mail
ProcessSendEveMailJob::dispatch($body, (int)$charId, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
//Increment the delay to get ready for the next mail job
$delay += 30;
} else if($contact->contact_type == 'Alliance') {
//Get the holding corporation from the lookup helper
$alliance = $lookup->GetAllianceInfo($contact->rental_contact_id);
//Get the CEO of the corporation of the holding corp from the lookup helper
$corporation = $lookup->GetCorporationInfo($alliance->executor_corporation_id);
$charId = $corporation->ceo_id;
//Send out the mail
ProcessSendEveMailJob::dispatch($body, (int)$charId, 'character', $subject, $config['primaryh'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
//Increment the detaly to get ready for the next mail job
$delay += 30;
}
}
}
private function GetMoonRentalsList($contact) {
//Declare the variables
$list = array();
$moons = AllianceMoonRental::where([
'rental_contact_id' => $contact,
])->get();
foreach($moons as $moon) {
$temp = 'Rental: ' . $moon->region . ' - ' . $moon->system . ' - ' . $moon->planet . ' - ' . $moon->moon;
array_push($list, $temp);
}
//Return the list
return $list;
}
private function GetMoonDueList($contact) {
//Declare the variables
$list = array();
$moons = AllianceMoonRental::where([
'rental_contact_id' => $contact,
])->where('paid_until', '<=', $today)->get();
//Create the list
foreach($moons as $moon) {
$temp = 'Rental: ' . $moon->region . ' - ' . $moon->system . ' - ' . $moon->planet . ' - ' . $moon->moon;
array_push($list, $temp);
}
//Return the list
return $list;
}
private function TotalizeCost($rentals, $rentalType) {
//Declare the stuff we need
$totalCost = 0.00;
//Totalize the cost
foreach($rentals as $rental) {
if($rentalType = 'In Alliance') {
$totalCost += $rental->alliance_rental_price;
} else {
$totalCost += $rental->out_of_alliance_rental_price;
}
}
return $totalCost;
}
}

View File

@@ -0,0 +1,153 @@
<?php
namespace App\Jobs\Commands\RentalMoons;
//Internal Library
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Carbon\Carbon;
use Log;
//Library
use App\Library\Lookups\LookupHelper;
//Models
use App\Models\MoonRentals\AllianceRentalMoon;
//Jobs
use App\Jobs\ProcessSendEveMailJob;
class UpdateMoonRentalPaidState implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Timeout in seconds
*
* @var int
*/
public $timeout = 1600;
/**
* Retries
*
* @var int
*/
public $retries = 3;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//Set the queue connection up
$this->connection = 'redis';
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//Declare variables
$mailDelay = 5;
//Get all of the moons from the rental database
$moons = AllianceRentalMoons::all();
//Set today's date
$today = Carbon::now();
//Get the esi configuration
$esiConfig = config('esi');
/**
* For each of the moons check the rental until date, the paid until date,
* and compare them to today's current date.
*
* If the paid date is later than the rental until date, then update the rental until
* date to match the paid date. If the paid until date is today or less, then update the
* paid column of the moon to not paid. If the moon hasn't been paid 2 weeks after the first
* of the month, then remove the renter, and send an eve mail to alliance leadership, and the renter
* denoting failure of payment has resulted in the moon rental for the current month being
* revoked.
*/
foreach($moon as $rental) {
//Setup the rental date, paid until date, and today's date as functions of Carbon library
$rentedUntil = new Carbon($rental->rental_until);
$paidUntil = new Carbon($rental->paid_until);
//If the paid date is larger than the rental date, then update the rental date
if($paidUntil->greaterThan($rentedUntil)) {
AllianceMoonRental::where([
'region' => $rental->region,
'system' => $rental->system,
'planet' => $rental->planet,
'moon' => $rental->moon,
])->update([
'rental_until' => $rental->paid_until,
]);
}
//If the paid date is today or less, then update the paid column of the moon as not paid
if($paidUntil->greaterThanOrEqualTo($today)) {
AllianceMoonRental::where([
'region' => $rental->region,
'system' => $rental->system,
'planet' => $rental->planet,
'moon' => $rental->moon,
])->update([
'paid' => 'No',
]);
}
//If the moon hasn't been paid for in two weeks, then remove the renter,
//then send the renter and w4rp leadership a mail.
if($paidUntil->greaterThanOrEqualTo($today->subWeeks(2))) {
//Declare the lookup helper as it will be needed
$lookupHelper = new LookupHelper;
//Get the character id for Minerva Arbosa and Rock Onzo
$minerva = $lookupHelper->CharacterNameToId('Minerva Arbosa');
$rock = $lookupHelper->CharacterNameToId('Rock Onzo');
//Remove the renter
AllianceMoonRental::where([
'region' => $rental->region,
'system' => $rental->system,
'planet' => $rental->planet,
'moon' => $rental->moon,
])->update([
'rental_type' => 'Not Rented',
'rental_until' => null,
'rental_contact_id' => 0,
'rental_contact_type' => null,
'paid' => 'Not Rented',
'paid_until' => null,
]);
//Send a mail over to the alliance leadership, and the former renter with
//why the moon was removed.
$subject = "W4RP Moon Rental Cancelled";
//Dispatch the mail job
ProcessSendEveMailJob::dispatch($body, (int)$rental->rental_contact_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
$mailDelay += 30;
if($minerva != null) {
ProcessSendEveMailJob::dispatch($body, (int)$minerva, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
$mailDelay += 30;
}
if($rock != null) {
ProcessSendEveMailJob::dispatch($body, (int)$rock, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
}
}
}
}
}

View File

@@ -0,0 +1,104 @@
<?php
namespace App\Jobs\Commands\RentalMoons;
//Internal Library
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Log;
//Library
use App\Library\Moons\MoonCalc;
//Models
use App\Models\MoonRentals\AllianceRentalMoon;
/**
* This job performs the action of updating the moon rental price once per day.
*/
class UpdateMoonRentalPrice implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Timeout in seconds
*
* @var int
*/
public $timeout = 3200;
/**
* Retries
*
* @var int
*/
public $retries = 1;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//Set the connection for the job
$this->connection = 'redis';
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//Declare the helper for moon calculations
$moonHelper = new MoonCalc;
//Get all the moons from the rental database
$moons = AllianceRentalMoon::all();
/**
* Calculate the worth of each moon along with the rental prices.
* For all of the moon calculations, the price of the mineral is averaged,
* thereby, the price of the moon worth is also averaged based on the averaging
* of the mineral price.
*/
foreach($moons as $rental) {
//Calculate the total worth of the moon
$totalWorth = $moonHelper->SpatialMoonsTotalWorth(
$rental->first_ore, $rental->first_quantity,
$rental->second_ore, $rental->second_quantity,
$rental->third_ore, $rental->third_quantity,
$rental->fourth_ore, $rental->fourth_quantity,
);
//Calculate the rental prices of the moon
$rentalPrice = $moonHelper->SpatialMoons(
$rental->first_ore, $rental->first_quantity,
$rental->second_ore, $rental->second_quantity,
$rental->third_ore, $rental->third_quantity,
$rental->fourth_ore, $rental->fourth_quantity,
);
//Update the moon in the database
AllianceRentalMoon::where([
'region' => $rental->region,
'system' => $rental->system,
'planet' => $rental->planet,
'moon' => $rental->moon,
])->update([
'moon_worth' => $totalWorth,
'alliance_rental_price' => $rentalPrice['alliance'],
'out_of_alliance_rental_price' => $rentalPrice['outofalliance'],
]);
Log::info('Alliance Rental Moon: ' . $rental->region . ' : ' . $rental->system . ' : ' . $rental->planet . ' : ' . $rental->moon . ' : ' . $rental->structure_name);
Log::info('Total Worth: ' . $totalWorth);
Log::info('Alliance Rental Price: ' . $rentalPrice['alliance']);
Log::info('Out of Alliance Rental Price: ' . $rentalPrice['outofalliance']);
}
}
}

View File

@@ -0,0 +1,103 @@
<?php
namespace App\Jobs\Commands\RentalMoons;
//Internal Library
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Log;
use Carbon\Carbon;
//Library
use App\Library\Esi\Esi;
use Seat\Eseye\Exceptions\RequestFailedException;
//Models
use App\Models\MoonRentals\AllianceRentalMoon;
use App\Models\Esi\EsiScope;
use App\Models\Esi\EsiToken;
class UpdateRentalMoonPullJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//Set the queue connection
$this->connection = 'redis';
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//Setup the configuration variable for ESI
$config = config('esi');
//Setup the esi helper variable
$esiHelper = new Esi;
//Check for the esi scope
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
//Send a mail to the holding toon to update the esi scopes
return null;
}
//Is this valid?
AllianceRentalMoon::update([
'next_moon_pull' => null,
]);
//Reset all table entries to clear out the next moon pull entry
$allMoons = AllianceRentalMoon::all();
//Cycle through all of the moons, and make the next moon pull null
foreach($allMoons as $moon) {
AllianceRentalMoon::where([
'system' => $moon->system,
'planet' => $moon->planet,
'moon' => $moon->moon,
])->update([
'next_moon_pull' => null,
]);
}
//Get the refresh token
$token = $esiHelper->GetRefreshToken($config['primary']);
//Setup the esi authentication container
$esi = $esiHelper->SetupEsiAuthentication($token);
try {
$responses = $esi->invoke('get', '/corporation/{corporation_id}/mining/extractions/', [
'corporation_id' => 98287666,
]);
} catch(RequestExceptionFailed $e) {
return null;
}
foreach($response as $response) {
//Get whether the structure is being used by the alliance or not.
$usage = AllianceRentalMoon::where([
'structure_id' => $response->structure_id,
'rental_type' => 'Alliance',
])->count();
if($usage > 0) {
AllianceRentalMoon::where([
'structure_id' => $response->structure_id,
])->update([
'next_moon_pull' => $response->chunk_arrival_time,
]);
}
}
}
}

View File

@@ -0,0 +1,113 @@
<?php
namespace App\Jobs\Commands\SupplyChain;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Carbon\Carbon;
use Log;
//Library
use App\Library\Lookups\LookupHelper;
//Models
use App\Models\Contracts\SupplyChainBid;
use App\Models\Contracts\SupplyChainContract;
//Jobs
use App\Jobs\ProcessSendEveMailJob;
class EndSupplyChainContractJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Timeout in seconds
*
* @var int
*/
public $timeout = 1200;
/**
* Retries
*
* @var int
*/
public $retries = 3;
/**
* Private Variables
*/
private $contractId;
private $issuerId;
private $issuerName;
private $title;
private $endDate;
private $deliveryBy;
private $body;
private $state;
private $finalCost;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(SupplyChainContract $contract)
{
//Set the queue connection up
$this->connection = 'redis';
//Set the variables
$contractId = $contract->contract_id;
$issuerId = $contract->issuer_id;
$issuerName = $contract->issuer_name;
$title = $contract->title;
$endDate = $contract->end_date;
$deliveryBy = $contract->delivery_by;
$body = $contract->body;
$state = $contract->state;
$finalCost = $contract->final_cost;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//Declare variables
$bidId = null;
$bidAmount = null;
//Get all of the bids from the contract
$bids = SupplyChainBids::where([
'contract_id' => $contractId,
])->get();
//Loop through the bids and find the lowest bid
foreach($bids as $bid) {
if($bidId == null) {
$bidId = $bid->id;
$bidAmount = $bid->bid_amount;
} else {
if($bid->bid_amount < $bidAmount) {
$bidId = $bid->id;
$bidAmount = $bid->bid_amount;
}
}
}
//Clean up the bids and update the contract with the winning bid
SupplyChainContract::where([
'contract_id' => $this->contractId,
])->update([
'final_cost' => $bidAmount,
'winning_bid_id' => $bidId,
]);
}
}

View File

@@ -20,7 +20,6 @@ use Seat\Eseye\Exceptions\RequestFailedException;
use App\Library\Assets\AssetHelper;
//App Models
use App\Models\Jobs\JobProcessAsset;
use App\Models\Jobs\JobStatus;
use App\Models\Stock\Asset;
@@ -58,11 +57,11 @@ class ProcessAssetsJob implements ShouldQueue
*
* @return void
*/
public function __construct(JobProcessAsset $jpa)
public function __construct($charId, $corpId, $page)
{
$this->charId = $jpa->charId;
$this->corpId = $jpa->corpId;
$this->page = $jpa->page;
$this->charId = $charId;
$this->corpId = $corpId;
$this->page = $page;
//Set the connection for the job
$this->connection = 'redis';

View File

@@ -9,6 +9,7 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Log;
use Carbon\Carbon;
//Library
use App\Library\Esi\Esi;
@@ -21,7 +22,6 @@ 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
{
@@ -52,12 +52,12 @@ class ProcessSendEveMailJob implements ShouldQueue
*
* @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;
public function __construct($body, $recipient, $recipient_type, $subject, $sender) {
$this->body = $body;
$this->recipient = $recipient;
$this->recipient_type = $recipient_type;
$this->subject = $subject;
$this->sender = $sender;
$this->connection = 'redis';
}
@@ -84,10 +84,6 @@ class ProcessSendEveMailJob implements ShouldQueue
//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([

View File

@@ -13,7 +13,6 @@ use Illuminate\Foundation\Bus\Dispatchable;
use App\Library\Structures\StructureHelper;
//App Models
use App\Models\Jobs\JobProcessStructure;
use App\Models\Jobs\JobStatus;
class ProcessStructureJob implements ShouldQueue
@@ -44,11 +43,11 @@ class ProcessStructureJob implements ShouldQueue
*
* @return void
*/
public function __construct(JobProcessStructure $jps)
public function __construct($charId, $corpId, $page)
{
$this->charId = $jps->charId;
$this->corpId = $jps->corpId;
$this->page = $jps->page;
$this->charId = $charId;
$this->corpId = $corpId;
$this->page = $page;
//Set the connection for the job
$this->connection = 'redis';

View File

@@ -40,10 +40,10 @@ class ProcessWalletJournalJob implements ShouldQueue
*
* @return void
*/
public function __construct(JobProcessWalletJournal $pwj) {
$this->division = $pwj->division;
$this->charId = $pwj->charId;
$this->page = $pwj->page;
public function __construct($division, $charId, $page) {
$this->division = $division;
$this->charId = $charId;
$this->page = $page;
$this->connection = 'redis';
}

View File

@@ -11,7 +11,7 @@ use App\Jobs\Library\JobHelper;
use App\Library\Esi\Esi;
use Seat\Eseye\Exceptions\RequestFailedException;
use App\Models\Jobs\JobProcessAsset;
//Models
use App\Models\Jobs\JobStatus;
use App\Models\Stock\Asset;

View File

@@ -8,7 +8,6 @@ use Carbon\Carbon;
//Models
use App\Models\Esi\EsiToken;
use App\Models\Esi\EsiScope;
use App\Models\Jobs\JobSendEveMail;
//Jobs
use App\Jobs\ProcessSendEveMailJob;
@@ -41,14 +40,10 @@ class Esi {
$check = EsiScope::where(['character_id' => $charId, 'scope' => $scope])->count();
if($check == 0) {
//Compose a mail to send to the user if the scope is not found
$mail = new 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';
$subject = 'W4RP Services - Incorrect ESI Scope';
$body = "Please register on https://services.w4rp.space with the scope: " . $scope;
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay(5);
ProcessSendEveMailJob::dispatch($body, (int)$charId, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
return false;
}

View File

@@ -9,9 +9,7 @@ namespace App\Library\Finances\Helper;
//Internal Library
use Log;
//Job
use App\Jobs\ProcessSendEveMailJob;
use Carbon\Carbon;
//Models
use App\Models\Esi\EsiToken;

View File

@@ -105,6 +105,27 @@ class LookupHelper {
$newItem->save();
}
public function SystemIdToName($systemId) {
//Check if the solar system is stored in our database first
$solarSystem = $this->LookupSolarSystemId($systemId);
if($solarSystem != null) {
return $solarSystem->name;
} else {
try {
$solar = $this->esi->invoke('get', '/universe/systems/{system_id}/', [
'system_id' => $systemId,
]);
} catch(RequestFailedException $e) {
Log::warning('Failed to get system id from /universe/systems in Lookup Helper.');
return null;
}
$this->StoreSolarSystem($solar);
return $solar->name;
}
}
public function SystemNameToId($system) {
//Check if the solar system is stored in our own database first
@@ -132,6 +153,14 @@ class LookupHelper {
}
}
private function LookupSolarSystemId($systemId) {
$solar = SolarSystem::where([
'solar_system_id' => $systemId,
])->first();
return $solar;
}
private function LookupSolarSystem($system) {
$solar = SolarSystem::where([
'name' => $system,
@@ -141,10 +170,22 @@ class LookupHelper {
}
private function StoreSolarSystem($system) {
$solar = new SolarSystem;
$solar->name = $system->name;
$solar->solar_system_id = $system->id;
$solar->save();
if(isset($system->id)) {
SolarSystem::insertOrIgnore([
'name' => $system->name,
'solar_system_id' => $system->id,
]);
} else if(isset($system->system_id)) {
SolarSystem::insertOrIgnore([
'name' => $system->name,
'solar_system_id' => $system->system_id,
]);
} else {
$solar = new SolarSystem;
$solar->name = $system->name;
$solar->solar_system_id = $system->id;
$solar->save();
}
}
public function GetCharacterInfo($charId) {

View File

@@ -1,73 +0,0 @@
<?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;
}
}
}

View File

@@ -0,0 +1,74 @@
<?php
namespace App\Library\Market;
//Internal Library
use Log;
use Carbon\Carbon;
//Library
use App\Library\Esi\Esi;
class MarketHelper {
/**
* Private variables
*
* @var esi
*/
private $esi;
/**
* Class Construct
*/
public function __construct($esi = null) {
$this->esi = $esi;
}
/**
* Get the regional market orders
*
* @var region
*/
public function GetRegionalMarketOrders($region) {
}
/**
* Price an item out and return the different price schemes
*
* @var itemId
*/
public function PriceItem($itemId) {
}
/**
* Get the market group infromation
*
* @var group
*/
public function GetMarketGroup($group) {
}
/**
* Get the public contract items
*
* @var contractId
*/
public function GetPublicContractItem($contractId) {
}
/**
* Get market price for an item
*
* @var itemId
*/
public function GetMarketPrice($itemId) {
}
}
?>

View File

@@ -52,7 +52,7 @@ class MiningLedgerHelper {
//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')) {
Log::warning('Character: ' . $this->charId . ' did not have the appropriate esi scope for the mining ledger.');
return null;
}

View File

@@ -12,6 +12,7 @@ use DB;
use Carbon\Carbon;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
use Log;
//Models
use App\Models\Moon\Config;
@@ -20,8 +21,14 @@ use App\Models\Moon\RentalMoon;
use App\Models\Moon\OrePrice;
use App\Models\Moon\MineralPrice;
/**
* MoonCalc Library
*/
class MoonCalc {
/**
* Get the ore composition of an ore
*/
public function GetOreComposition($ore) {
$composition = ItemComposition::where([
'Name' => $ore,
@@ -30,10 +37,12 @@ class MoonCalc {
return $composition;
}
/**
* Calculate the total worth of a moon
*/
public function SpatialMoonsTotalWorth($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
//Get the total moon pull in m3
$totalPull = $this->CalculateTotalMoonPull();
//Declare variables
$totalPriceMined = 0.00;
//Get the configuration for pricing calculations
$config = DB::table('Config')->get();
@@ -42,90 +51,29 @@ class MoonCalc {
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
//Calculate the prices from the ores
$this->CalculateTotalPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
if($firstOre != 'None') {
$totalPriceMined += $this->CalcMoonPrice($firstOre, $firstPerc);
}
if($secondOre != 'None') {
$totalPriceMined += $this->CalcMoonPrice($secondOre, $secondPerc);
}
if($thirdOre != 'None') {
$totalPriceMined += $this->CalcMoonPrice($thirdOre, $thirdPerc);
}
if($fourthOre != 'None') {
$totalPriceMined += $this->CalcMoonPrice($fourthOre, $fourthPerc);
}
//Calculate the total to price to be mined in one month
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
//Return the rental price to the caller
return $totalPriceMined;
}
public function SpatialMoonsOnlyGooTotalWorth($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;
//Return the rental price to the caller
return $totalPriceMined;
}
public function SpatialMoonsOnlyGooMailer($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);
//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
$rentalPrice['alliance'] = number_format($rentalPrice['alliance'], 0, ".", ",");
$rentalPrice['outofalliance'] = number_format($rentalPrice['outofalliance'], 0, ".", ",");
//Return the rental price to the caller
return $rentalPrice;
}
/**
* Calculate the rental price
*/
public function SpatialMoons($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
//Get the total moon pull in m3
$totalPull = $this->CalculateTotalMoonPull();
//Declare variables
$totalPrice = 0.00;
//Get the configuration for pricing calculations
$config = DB::table('Config')->get();
@@ -134,23 +82,30 @@ class MoonCalc {
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
//Calculate the prices from the ores
$this->CalculateTotalPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
if($firstOre != 'None') {
$totalPrice += $this->CalcRentalPrice($firstOre, $firstPerc);
}
if($secondOre != 'None') {
$totalPrice += $this->CalcRentalPrice($secondOre, $secondPerc);
}
if($thirdOre != 'None') {
$totalPrice += $this->CalcRentalPrice($thirdOre, $thirdPerc);
}
if($fourthOre != 'None') {
$totalPrice += $this->CalcRentalPrice($fourthOre, $fourthPerc);
}
//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
$rentalPrice['alliance'] = number_format($rentalPrice['alliance'], 0, ".", ",");
$rentalPrice['outofalliance'] = number_format($rentalPrice['outofalliance'], 0, ".", ",");
$rentalPrice['alliance'] = $totalPrice * ($config[0]->RentalTax / 100.00);
$rentalPrice['outofalliance'] = $totalPrice * ($config[0]->AllyRentalTax / 100.00);
//Return the rental price to the caller
return $rentalPrice;
}
/**
* Fetch new prices for items from the market
*/
public function FetchNewPrices() {
//Create the item id array which we will pull data for from Fuzzwork market api
$ItemIDs = array(
@@ -223,6 +178,34 @@ class MoonCalc {
$this->UpdateItemPricing();
}
/**
* Calculate the ore units
*/
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;
}
/**
* Update item pricing after new prices were pulled
*/
private function UpdateItemPricing() {
//Get the configuration from the config table
$config = DB::table('Config')->first();
@@ -236,42 +219,42 @@ class MoonCalc {
$pastTime = Carbon::now()->subDays(30);
//Get the price of the basic minerals
$tritaniumPrice = MineralPrice::where(['ItemId' => 34])->whereDate('Time', '>', $pastTime)->avg('Price');
$pyeritePrice = MineralPrice::where(['ItemId' => 35])->whereDate('Time', '>', $pastTime)->avg('Price');
$mexallonPrice = MineralPrice::where(['ItemId' => 36])->whereDate('Time', '>', $pastTime)->avg('Price');
$isogenPrice = MineralPrice::where(['ItemId' => 37])->whereDate('Time', '>', $pastTime)->avg('Price');
$nocxiumPrice = MineralPrice::where(['ItemId' => 38])->whereDate('Time', '>', $pastTime)->avg('Price');
$zydrinePrice = MineralPrice::where(['ItemId' => 39])->whereDate('Time', '>', $pastTime)->avg('Price');
$megacytePrice = MineralPrice::where(['ItemId' => 40])->whereDate('Time', '>', $pastTime)->avg('Price');
$morphitePrice = MineralPrice::where(['ItemId' => 11399])->whereDate('Time', '>', $pastTime)->avg('Price');
$heliumIsotopesPrice = MineralPrice::where(['ItemId' => 16274])->whereDate('Time', '>', $pastTime)->avg('Price');
$nitrogenIsotopesPrice = MineralPrice::where(['ItemId' => 17888])->whereDate('Time', '>', $pastTime)->avg('Price');
$oxygenIsotopesPrice = MineralPrice::where(['ItemId' => 17887])->whereDate('Time', '>', $pastTime)->avg('Price');
$hydrogenIsotopesPrice = MineralPrice::where(['ItemId' => 17889])->whereDate('Time', '>', $pastTime)->avg('Price');
$liquidOzonePrice = MineralPrice::where(['ItemId' => 16273])->whereDate('Time', '>', $pastTime)->avg('Price');
$heavyWaterPrice = MineralPrice::where(['ItemId' => 16272])->whereDate('Time', '>', $pastTime)->avg('Price');
$strontiumClathratesPrice = MineralPrice::where(['ItemId' => 16275])->whereDate('Time', '>', $pastTime)->avg('Price');
$tritaniumPrice = MineralPrice::where(['ItemId' => 34])->where('Time', '>', $pastTime)->avg('Price');
$pyeritePrice = MineralPrice::where(['ItemId' => 35])->where('Time', '>', $pastTime)->avg('Price');
$mexallonPrice = MineralPrice::where(['ItemId' => 36])->where('Time', '>', $pastTime)->avg('Price');
$isogenPrice = MineralPrice::where(['ItemId' => 37])->where('Time', '>', $pastTime)->avg('Price');
$nocxiumPrice = MineralPrice::where(['ItemId' => 38])->where('Time', '>', $pastTime)->avg('Price');
$zydrinePrice = MineralPrice::where(['ItemId' => 39])->where('Time', '>', $pastTime)->avg('Price');
$megacytePrice = MineralPrice::where(['ItemId' => 40])->where('Time', '>', $pastTime)->avg('Price');
$morphitePrice = MineralPrice::where(['ItemId' => 11399])->where('Time', '>', $pastTime)->avg('Price');
$heliumIsotopesPrice = MineralPrice::where(['ItemId' => 16274])->where('Time', '>', $pastTime)->avg('Price');
$nitrogenIsotopesPrice = MineralPrice::where(['ItemId' => 17888])->where('Time', '>', $pastTime)->avg('Price');
$oxygenIsotopesPrice = MineralPrice::where(['ItemId' => 17887])->where('Time', '>', $pastTime)->avg('Price');
$hydrogenIsotopesPrice = MineralPrice::where(['ItemId' => 17889])->where('Time', '>', $pastTime)->avg('Price');
$liquidOzonePrice = MineralPrice::where(['ItemId' => 16273])->where('Time', '>', $pastTime)->avg('Price');
$heavyWaterPrice = MineralPrice::where(['ItemId' => 16272])->where('Time', '>', $pastTime)->avg('Price');
$strontiumClathratesPrice = MineralPrice::where(['ItemId' => 16275])->where('Time', '>', $pastTime)->avg('Price');
//Get the price of the moongoo
$atmosphericGasesPrice = MineralPrice::where(['ItemId' => 16634])->whereDate('Time', '>', $pastTime)->avg('Price');
$evaporiteDepositsPirce = MineralPrice::where(['ItemId' => 16635])->whereDate('Time', '>', $pastTime)->avg('Price');
$hydrocarbonsPrice = MineralPrice::where(['ItemId' => 16633])->whereDate('Time', '>', $pastTime)->avg('Price');
$silicatesPrice = MineralPrice::where(['ItemId' => 16636])->whereDate('Time', '>', $pastTime)->avg('Price');
$cobaltPrice = MineralPrice::where(['ItemId' => 16640])->whereDate('Time', '>', $pastTime)->avg('Price');
$scandiumPrice = MineralPrice::where(['ItemId' => 16639])->whereDate('Time', '>', $pastTime)->avg('Price');
$titaniumPrice = MineralPrice::where(['ItemId' => 16638])->whereDate('Time', '>', $pastTime)->avg('Price');
$tungstenPrice = MineralPrice::where(['ItemId' => 16637])->whereDate('Time', '>', $pastTime)->avg('Price');
$cadmiumPrice = MineralPrice::where(['ItemId' => 16643])->whereDate('Time', '>', $pastTime)->avg('Price');
$platinumPrice = MineralPrice::where(['ItemId' => 16644])->whereDate('Time', '>', $pastTime)->avg('Price');
$vanadiumPrice = MineralPrice::where(['ItemId' => 16642])->whereDate('Time', '>', $pastTime)->avg('Price');
$chromiumPrice = MineralPrice::where(['ItemId' => 16641])->whereDate('Time', '>', $pastTime)->avg('Price');
$technetiumPrice = MineralPrice::where(['ItemId' => 16649])->whereDate('Time', '>', $pastTime)->avg('Price');
$hafniumPrice = MineralPrice::where(['ItemId' => 16648])->whereDate('Time', '>', $pastTime)->avg('Price');
$caesiumPrice = MineralPrice::where(['ItemId' => 16647])->whereDate('Time', '>', $pastTime)->avg('Price');
$mercuryPrice = MineralPrice::where(['ItemId' => 16646])->whereDate('Time', '>', $pastTime)->avg('Price');
$dysprosiumPrice = MineralPrice::where(['ItemId' => 16650])->whereDate('Time', '>', $pastTime)->avg('Price');
$neodymiumPrice = MineralPrice::where(['ItemId' => 16651])->whereDate('Time', '>', $pastTime)->avg('Price');
$promethiumPrice = MineralPrice::where(['ItemId' => 16652])->whereDate('Time', '>', $pastTime)->avg('Price');
$thuliumPrice = MineralPrice::where(['ItemId' => 16653])->whereDate('Time', '>', $pastTime)->avg('Price');
$atmosphericGasesPrice = MineralPrice::where(['ItemId' => 16634])->where('Time', '>', $pastTime)->avg('Price');
$evaporiteDepositsPirce = MineralPrice::where(['ItemId' => 16635])->where('Time', '>', $pastTime)->avg('Price');
$hydrocarbonsPrice = MineralPrice::where(['ItemId' => 16633])->where('Time', '>', $pastTime)->avg('Price');
$silicatesPrice = MineralPrice::where(['ItemId' => 16636])->where('Time', '>', $pastTime)->avg('Price');
$cobaltPrice = MineralPrice::where(['ItemId' => 16640])->where('Time', '>', $pastTime)->avg('Price');
$scandiumPrice = MineralPrice::where(['ItemId' => 16639])->where('Time', '>', $pastTime)->avg('Price');
$titaniumPrice = MineralPrice::where(['ItemId' => 16638])->where('Time', '>', $pastTime)->avg('Price');
$tungstenPrice = MineralPrice::where(['ItemId' => 16637])->where('Time', '>', $pastTime)->avg('Price');
$cadmiumPrice = MineralPrice::where(['ItemId' => 16643])->where('Time', '>', $pastTime)->avg('Price');
$platinumPrice = MineralPrice::where(['ItemId' => 16644])->where('Time', '>', $pastTime)->avg('Price');
$vanadiumPrice = MineralPrice::where(['ItemId' => 16642])->where('Time', '>', $pastTime)->avg('Price');
$chromiumPrice = MineralPrice::where(['ItemId' => 16641])->where('Time', '>', $pastTime)->avg('Price');
$technetiumPrice = MineralPrice::where(['ItemId' => 16649])->where('Time', '>', $pastTime)->avg('Price');
$hafniumPrice = MineralPrice::where(['ItemId' => 16648])->where('Time', '>', $pastTime)->avg('Price');
$caesiumPrice = MineralPrice::where(['ItemId' => 16647])->where('Time', '>', $pastTime)->avg('Price');
$mercuryPrice = MineralPrice::where(['ItemId' => 16646])->where('Time', '>', $pastTime)->avg('Price');
$dysprosiumPrice = MineralPrice::where(['ItemId' => 16650])->where('Time', '>', $pastTime)->avg('Price');
$neodymiumPrice = MineralPrice::where(['ItemId' => 16651])->where('Time', '>', $pastTime)->avg('Price');
$promethiumPrice = MineralPrice::where(['ItemId' => 16652])->where('Time', '>', $pastTime)->avg('Price');
$thuliumPrice = MineralPrice::where(['ItemId' => 16653])->where('Time', '>', $pastTime)->avg('Price');
//Get the item compositions
$items = DB::select('SELECT Name,ItemId FROM ItemComposition');
@@ -350,43 +333,34 @@ class MoonCalc {
}
}
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;
}
/**
* Calculate the total amount pulled from a moon
*/
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);
$totalPull = 5.55 * 3600.00 * 24.00 *30.00;
//Return the total pull
return $totalPull;
}
private function CalcPrice($ore, $percentage) {
/**
* Calculate the rental price of a moon ore from the moon
*/
private function CalcRentalPrice($ore, $percentage) {
//Specify the total pull amount
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
$totalPull = $this->CalculateTotalMoonPull();
//Setup the total value at 0.00
$totalPrice = 0.00;
//Check to see what type of moon goo the moon is
$gasMoonOre = $this->IsGasMoonGoo($ore);
//Find the size of the asteroid from the database
$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
$actualm3 = floor($percentage * $totalPull);
@@ -395,19 +369,79 @@ class MoonCalc {
//Look up the unit price from the database
$unitPrice = DB::table('ore_prices')->where('Name', $ore)->value('UnitPrice');
//Calculate the total amount from the units and unit price
$total = $units * $unitPrice;
//Return the value
return $total;
//If the ore is a gas ore, then take only 50% of the price.
if($gasMoonOre == true) {
$totalPrice = $units * ($unitPrice / 2.00);
Log::warning('Found gas ore: ' . $totalPrice);
} else {
$totalPrice = $units * $unitPrice;
}
//Return the total
return $totalPrice;
}
/**
* Calculate the moon's total price
*/
private function CalcMoonPrice($ore, $percentage) {
//Specify the total pull amount
$totalPull = $this->CalculateTotalMoonPull();
//Setup the total value at 0.00
$totalPrice = 0.00;
//Find the size of the asteroid from the database
$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
$actualm3 = floor($percentage * $totalPull);
//Calculate the units once we have the size and actual m3 value
$units = floor($actualm3 / $m3Size);
//Look up the unit price from the database
$unitPrice = DB::table('ore_prices')->where('Name', $ore)->value('UnitPrice');
//Calculate the total amount from the units and the unit price.
$totalPrice = $units * $unitPrice;
//Return the value
return $totalPrice;
}
/**
* Convert a number to a percentage
*/
private function ConvertToPercentage($quantity) {
//Perform the calculation and return the data
return $quantity / 100.00;
}
/**
* Return if a type of ore is a gas moon goo
*/
private function IsGasMoonGoo($ore) {
$ores = [
'Zeolites' => 'Gas',
'Sylvite' => 'Gas',
'Bitumens' => 'Gas',
'Coesite' => 'Gas',
];
foreach($ores as $key => $value) {
if(strtolower($key) == strtolower($ore)) {
return $value;
}
}
return false;
}
/**
* Return the type of ore a particular moon ore is.
*/
private function IsRMoonGoo($ore) {
$ores = [
'Zeolites' => 'Gas',
@@ -433,21 +467,21 @@ class MoonCalc {
];
foreach($ores as $key => $value) {
if(strtolower($key) == strtolower($ore)) {
return true;
return $value;
}
}
//Return false if the ore is not found in an array
return false;
}
private function IsRMoon($ore) {
/**
* Return true if a moon ore is a moon ore, and false
* if the ore is not a moon ore.
*/
private function IsRMoonOre($ore) {
$ores = [
'Prime Arkonor' => 'Null',
'Cubic Bistot' => 'Null',
'Pellucid Crokite' => 'Null',
'Jet Ochre' => 'Null',
'Zeolites' => 'Gas',
'Sylvite' => 'Gas',
'Bitumens' => 'Gas',
@@ -480,6 +514,9 @@ class MoonCalc {
return false;
}
/**
* Convert percentages from quantities into a normalized percentage
*/
private function ConvertPercentages(&$firstPerc, $firstQuan, &$secondPerc, $secondQuan, &$thirdPerc, $thirdQuan, &$fourthPerc, $fourthQuan) {
//Set the base percentages for the if statements
$firstPerc = 0.00;
@@ -539,68 +576,4 @@ class MoonCalc {
}
}
}
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;
}
}
}

View File

@@ -0,0 +1,85 @@
<?php
namespace App\Library\RegionalContracts;
//Internal Library
use Log;
use Carbon\Carbon;
//Library
use App\Library\Esi\Esi;
class RegionalContractHelper {
/**
* Region variable
*
* @var int
*/
private $region;
/**
* ESI Variable
*
* @var esi
*/
private $esi;
/**
* Construct
*/
public function __construct($region, $esi) {
$this->region = $region;
$this->esi = $esi;
}
/**
* Get the contracts within a region
*
* @var private
*/
public function GetContracts() {
//Get the public contracts from the ESI
$responses = $this->esi->invoke('get', '/contracts/public/{region_id}/', [
'region_id' => $this->region,
]);
//Send the contracts back to the calling function
return $responses;
}
/**
* Price the regional contract
*
* @var buyout
* @var contract_id
* @var date_expired
* @var date_issued
* @var days_to_complete
* @var end_location_id
* @var issuer_id
* @var price
* @var title
* @var type [unknown, item_exchange, auction, courier, loan]
* @var volume
*/
public function PriceContract($contract) {
}
/**
* Function to get the items in a contract from ESI
*
* @var id
*/
public function GetContractItems($contractId) {
$items = $this->esi->invoke('get', '/contracts/public/items/{contract_id}/', [
'contract_id' => $contractId,
]);
return $items;
}
}
?>

View File

@@ -13,10 +13,6 @@ use App\Models\SRP\SrpShipType;
class SRPHelper {
public function __contruct() {
//
}
public function GetAllianceSRPActual($start, $end) {
$actual = 0.00;
@@ -39,75 +35,6 @@ class SRPHelper {
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;

View File

@@ -3,8 +3,6 @@
/**
* W4RP Services
* GNU Public License
*
* Finally works in it's current state. Need to move to a job process.
*/
namespace App\Library\Structures;
@@ -16,9 +14,9 @@ use Log;
use App\Jobs\Library\JobHelper;
use Seat\Eseye\Exceptions\RequestFailedException;
use App\Library\Esi\Esi;
use App\Library\Lookups\LookupHelper;
//App Models
use App\Models\Jobs\JobProcessStructure;
use App\Models\Jobs\JobStatus;
use App\Models\Structure\Structure;
use App\Models\Structure\Service;
@@ -31,24 +29,28 @@ class StructureHelper {
private $charId;
private $corpId;
private $page;
private $esi;
public function __construct($char, $corp) {
public function __construct($char, $corp, $esi = null) {
$this->charId = $char;
$this->corpId = $corp;
$this->esi = $esi;
}
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);
if($this->esi == null) {
//Get the refresh token from the database
$token = $esiHelper->GetRefreshToken($this->charId);
//Create the esi authentication container
$this->esi = $esiHelper->SetupEsiAuthentication($token);
}
//Try to get the ESI data
try {
$structures = $esi->page($page)
$structures = $this->esi->page($page)
->invoke('get', '/corporations/{corporation_id}/structures/', [
'corporation_id' => $this->corpId,
]);
@@ -67,7 +69,7 @@ class StructureHelper {
//Get the refresh token from the database
$token = $esiHelper->GetRefreshToken($this->charId);
//Setup the esi authentication container
$esi = $esiHelper->SetupEsiAuthentication($token);
$this->esi = $esiHelper->SetupEsiAuthentication($token);
//Get the structure information
$info = $this->GetStructureInfo($structure->structure_id);
@@ -79,45 +81,42 @@ class StructureHelper {
} else {
$this->UpdateExistingStructure($structure, $info);
}
}
private function GetSolarSystemName($systemId) {
//Declare some variables
$esiHelper = new Esi;
$lookup = new LookupHelper;
//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($this->esi == null) {
//Get the refresh token
$token = $esiHelper->GetRefreshToken($this->charId);
//Setup the esi authentication container
$this->esi = $esiHelper->SetupEsiAuthentication($token);
}
$solar = $lookup->SystemIdToName($systemId);
if($solar != null) {
return $solar->name;
return $solar;
} else {
return null;
}
}
private function GetStructureInfo($structureId) {
public 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);
if($this->esi == null) {
//Get the refresh token
$token = $esiHelper->GetRefreshToken($this->charId);
//Setup the esi authentication container
$this->esi = $esiHelper->SetupEsiAuthentication($token);
}
try {
$info = $esi->invoke('get', '/universe/structures/{structure_id}/', [
$info = $this->esi->invoke('get', '/universe/structures/{structure_id}/', [
'structure_id' => $structureId,
]);
} catch(RequestFailedException $e) {

View File

@@ -44,7 +44,11 @@ class WikiHelper {
//Set the alliance id
$corp = $lookup->GetCorporationInfo($corpId);
$allianceId = $corp->alliance_id;
if(isset($corp->alliance_id)) {
$allianceId = $corp->alliance_id;
} else {
$allianceId = 0;
}
if(in_array($allianceId, $legacy) || in_array($allianceId, $renter) || $allianceId == 99004116) {
$purge = false;
@@ -63,8 +67,7 @@ class WikiHelper {
$groups = DokuGroupNames::all();
//Check if the user already belongs to the group
$userGroups = DokuMember::where(['gid' => $groupId])->count();
if($count > 0) {
if(DokuMember::where(['gid' => $groupId, 'uid' => $userId])->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;
@@ -130,15 +133,11 @@ class WikiHelper {
* 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,
]);
}
//Insert or ignore the group if it's already there.
DokuGroupNames::insertOrIgnore([
'gname' => $groupName,
'description' => $description,
]);
}
/**
@@ -153,4 +152,11 @@ class WikiHelper {
//Delete the user from the user table
DokuUser::where(['id' => $userId])->delete();
}
/**
* Get uid from name
*/
public function GetUID($name) {
return DokuUser::where(['name' => $name])->first();
}
}

View File

@@ -1,30 +0,0 @@
<?php
namespace App\Models\Contracts;
use Illuminate\Database\Eloquent\Model;
class AcceptedBid extends Model
{
// Table Name
public $table = 'accepted_bids';
//Timestamps
public $timestamps = true;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'contract_id',
'bid_id',
'bid_amount',
'notes',
];
public function Contract() {
return $this->belongsTo(Contract::class);
}
}

View File

@@ -1,39 +0,0 @@
<?php
namespace App\Models\Contracts;
use Illuminate\Database\Eloquent\Model;
class Bid extends Model
{
// Table Name
public $table = 'contract_bids';
// Timestamps
public $timestamps = true;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'contract_id',
'bid_amount',
'character_name',
'character_id',
'corporation_name',
'corporation_id',
'notes',
];
protected $guarded = [];
public function ContractId() {
return $this->hasOne('App\Models\Contracts\Contract', 'id', 'contract_id');
}
public function Contract() {
return $this->belongsTo(Contract::class);
}
}

View File

@@ -1,38 +0,0 @@
<?php
namespace App\Models\Contracts;
use Illuminate\Database\Eloquent\Model;
class Contract extends Model
{
// Table Name
public $table = 'contracts';
// Timestamps
public $timestamps = true;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'title',
'type',
'end_date',
'body',
'final_cost',
'finished',
];
//One-to-Many relationship for the bids on a contract
public function Bids() {
return $this->hasMany('App\Models\Contracts\Bid', 'contract_id', 'id');
}
//One-to-One relationship for the accepted bid.
public function AcceptedBid() {
return $this->hasOne('App\Models\Contracts\AcceptedBid', 'contract_id', 'id');
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Models\Contracts;
use Illuminate\Database\Eloquent\Model;
class SupplyChainBid extends Model
{
//Table Name
public $table = 'supply_chain_bids';
// Timestamps
public $timestamps = true;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'contract_id',
'bid_amount',
'entity_id',
'entity_name',
'entity_type',
'bid_type',
'bid_note',
];
//Relationships
public function ContractId() {
return $this->hasOne('App\Models\Contracts\SupplyChainContract', 'contract_id', 'contract_id');
}
public function Contract() {
return $this->belongsTo(SupplyChainContract::class);
}
//Model functions
public function getContractId() {
return $this->contract_id;
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Models\Contracts;
use Illuminate\Database\Eloquent\Model;
class SupplyChainContract extends Model
{
//Table Name
public $table = 'supply_chain_contracts';
//Timestamps
public $timestamps = true;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'issuer_id',
'issuer_name',
'title',
'end_date',
'delivery_by',
'body',
'state',
'final_cost',
];
//Relationship
public function Bids() {
return $this->hasMany('App\Models\Contracts\SupplyChainBid', 'contract_id', 'id');
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class EveRegion extends Model
{
//Table Name
protected $table = 'eve_regions';
//Timestamps
public $timestamps = false;
/**
* Variables which are mass assignable
*
* @var array
*/
protected $fillable = [
'region_id',
'region_name',
];
}

View File

@@ -1,20 +0,0 @@
<?php
namespace App\Models\Jobs;
use Illuminate\Database\Eloquent\Model;
class JobProcessAsset extends Model
{
//no table name is needed
//Timestamps
public $timestamps = false;
protected $fillable = [
'charId',
'corpId',
'page',
'esi',
];
}

View File

@@ -1,20 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class JobProcessCorpJournal extends Model
{
//No table name is needed
//Timestamps
public $timestamps = false;
protected $fillable = [
'division',
'charId',
'corpId',
'page',
];
}

View File

@@ -1,25 +0,0 @@
<?php
namespace App\Models\Jobs;
use Illuminate\Database\Eloquent\Model;
class JobProcessStructure extends Model
{
//Table Name - Not Needed for a Job
//public $table = null;
//Timestamps
public $timestamps = false;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'charId',
'corpId',
'page',
];
}

View File

@@ -1,27 +0,0 @@
<?php
namespace App\Models\Jobs;
use Illuminate\Database\Eloquent\Model;
class JobProcessWalletJournal extends Model
{
//Table Name
//public $table = 'job_process_wallet_journal';
//Timestamps
public $timestamps = false;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'charId',
'division',
'page',
];
}
?>

View File

@@ -1,19 +0,0 @@
<?php
namespace App\Models\Jobs;
use Illuminate\Database\Eloquent\Model;
class JobSendEveMail extends Model
{
//Timestamps
public $timestamps = false;
protected $fillable = [
'sender',
'recipient',
'recipient_type',
'subject',
'body',
];
}

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Models\Market;
use Illuminate\Database\Eloquent\Model;
class MarketRegionOrder extends Model
{
//Table Name
protected $table = 'market_region_orders';
//Timestamps
public $timestamps = true;
/**
* Items which are mass assignable
*
* @var array
*/
protected $fillable = [
'region_id',
'duration',
'is_buy_order',
'issued',
'location_id',
'min_volume',
'order_id',
'price',
'range',
'system_id',
'type_id',
'volume_remain',
'volume_total',
];
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Models\Moon;
use Illuminate\Database\Eloquent\Model;
class CorpMoonLedger extends Model
{
//Table Name
protected $table = 'corp_moon_ledgers';
//Primary Key
public $primaryKey = 'id';
//Timestamps
public $timestamps = true;
protected $fillable = [
'corporation_id',
'corporation_name',
'character_id',
'character_name',
'observer_id',
'observer_name',
'type_id',
'ore',
'quantity',
'recorded_corporation_id',
'recorded_corporation_name',
'last_updated',
];
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Models\Moon;
use Illuminate\Database\Eloquent\Model;
class CorpMoonObserver extends Model
{
//Table Name
protected $table = 'corp_mining_observers';
//Primary Key
public $primaryKey = 'id';
//Timestamps
public $timestamps = true;
/**
* Attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'corporation_id',
'corporation_name',
'observer_id',
'observer_name',
'observer_type',
'observer_owner_id',
'solar_system_id',
'observer_type_id',
'last_updated',
];
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class RentalMoonInvoice extends Model
{
//Table Name
protected $table = 'alliance_moon_rental_invoices';
//Primary Key
public $primaryKey = 'id';
//Timestamps
public $timestamps = true;
/**
* Items which are mass assignable
*
* @var array
*/
protected $fillable = [
'character_id',
'character_name',
'corporation_id',
'corporation_name',
'rental_moons',
'invoice_amount',
'due_date',
'paid',
];
}

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Models\Moon;
use Illuminate\Database\Eloquent\Model;
class RentalMoonLedger extends Model
{
//Table Name
protected $table = 'alliance_rental_moon_ledgers';
//Primary Key
public $primaryKey = 'id';
//Timestamps
public $timestamps = true;
protected $fillable = [
'corporation_id',
'corporation_name',
'character_id',
'character_name',
'observer_id',
'observer_name',
'type_id',
'ore',
'quantity',
'recorded_corporation_id',
'recorded_corporation_name',
'last_updated',
];
/**
* Get the observer this belongs to
*/
public function observer() {
return $this->belongsTo('App\Models\Moon\RentalMoonObserver', 'observer_id', 'observer_id');
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Models\Moon;
use Illuminate\Database\Eloquent\Model;
class RentalMoonObserver extends Model
{
//Table Name
protected $table = 'alliance_mining_observers';
//Primary Key
public $primaryKey = 'id';
//Timestamps
public $timestamps = true;
protected $fillable = [
'corporation_id',
'corporation_name',
'observer_id',
'observer_name',
'observer_type',
'last_updated',
];
public function ledger() {
return $this->hasMany('App\Models\Moon\RentalMoonLedger', 'observer_id', 'observer_id');
}
}

View File

@@ -0,0 +1,99 @@
<?php
namespace App\Models\MoonRentals;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
class AllianceRentalMoon extends Model
{
//Table Name
protected $table = 'alliance_rental_moons';
//Primary Key
public $primaryKey = 'id';
//Timestamps
public $timestamps = false;
/**
* Items which are mass assignable by the model
*
* @var array
*/
protected $fillable = [
'region',
'system',
'planet',
'moon',
'structure_id',
'structure_name',
'first_ore',
'first_quantity',
'second_ore',
'second_quantity',
'third_ore',
'third_quantity',
'fourth_ore',
'fourth_quantity',
'moon_worth',
'alliance_rental_price',
'out_of_alliance_rental_price',
'rental_type',
'rental_until',
'rental_contact_id',
'rental_contact_type',
'paid',
'paid_until',
'alliance_use_until',
'next_moon_pull',
];
public function getPaidStatus() {
return $this->paid;
}
public function getNextMoonPull() {
return $this->next_moon_pull;
}
public function getRSPM() {
return $this->region . " - " . $this->system . " - " . $this->planet . " - " . $this->moon;
}
public function getOOARentalPrice() {
return $this->out_of_alliance_rental_price;
}
public function getIARentalPrice() {
return $this->alliance_rental_price;
}
public function getWorth() {
return $this->moon_worth;
}
public function getRentalType() {
return $this->rental_type;
}
public function isRented() {
$today = Carbon::now();
if($today->lessThan($this->rental_until)) {
return true;
} else {
return false;
}
}
public function isPaid() {
$today = Carbon::now();
if($today->lessThan($this->paid_until)) {
return true;
} else {
return false;
}
}
}

View File

@@ -1,32 +0,0 @@
<?php
namespace App\Models\MoonRent;
use Illuminate\Database\Eloquent\Model;
class MoonRental extends Model
{
// Table Name
protected $table = 'moon_rents';
//Primary Key
public $primaryKey = 'id';
//Timestamps
public $timestamps = false;
//Fillable Items
protected $fillable = [
'System',
'Planet',
'Moon',
'StructureId',
'RentalCorp',
'RentalEnd',
'Contact',
'Type',
'Price',
'Paid',
'Paid_Until',
];
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Models\MoonRent;
use Illuminate\Database\Eloquent\Model;
class MoonRentalInvoice extends Model
{
//Table Name
protected $table = 'alliance_moon_rental_invoices';
//Primary Key
public $primaryKey = 'id';
//Timestamps
public $timestamps = true;
/**
* These are the items which are mass assignable
*
* @var array
*/
protected $fillable = [
'invoice_id',
'character_id',
'character_name',
'corporation_id',
'corporation_name',
'rental_moons',
'invoice_amount',
'due_date',
'paid',
];
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Models\MoonRent;
use Illuminate\Database\Eloquent\Model;
class MoonRentalPayment extends Model
{
//Table Name
protected $table = 'alliance_moon_rental_payments';
//Primary Key
public $primaryKey = 'id';
//Timestamps
public $timestamps = true;
/**
* These are the items which are mass assignable
*
* @var array
*/
protected $fillable = [
'invoice_id',
'payment_amount',
'reference_id',
];
}

View File

@@ -25,4 +25,8 @@ class Service extends Model
'name',
'state',
];
public function structure() {
return $this->hasOne('App\Models\Structure\Structure', 'structure_id', 'structure_id');
}
}

View File

@@ -48,4 +48,8 @@ class Structure extends Model
'reinforce_weekday',
'unanchors_at',
];
public function services() {
return $this->hasMany('App\Models\Structure\Service', 'structure_id', 'structure_id');
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Models\SystemRentals;
use Illuminate\Database\Eloquent\Model;
class RentalSystem extends Model
{
/**
* Table Name
*/
public $table = 'alliance_rental_systems';
/**
* Timestamps
*/
public $timestamps = true;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'contact_id',
'contact_name',
'corporation_id',
'corporation_name',
'system_id',
'system_name',
'rental_cost',
'paid_until',
];
}

View File

@@ -10,7 +10,7 @@ use App\Models\User\UserRole;
use App\Models\User\UserPermission;
use App\Models\Esi\EsiScope;
use App\Models\Esi\EsiToken;
use App\Models\MoonRent\MoonRental;
use App\Models\MoonRentals\AllianceRentalMoon;
use App\Models\SRP\SRPShip;
class User extends Authenticatable
@@ -121,8 +121,8 @@ class User extends Authenticatable
}
public function isMoonRenter() {
$moonRental = MoonRental::where([
'Contact' => $this->character_id,
$moonRental = AllianceRentalMoon::where([
'rental_contact_id' => $this->character_id,
])->first();
if($moonRental != null) {
@@ -133,7 +133,6 @@ class User extends Authenticatable
}
public function srpOpen() {
return SRPShip::where([
'character_id' => $this->character_id,
'approved' => 'Under Review',

View File

@@ -10,8 +10,8 @@
"eveseat/eseye": "^1.1",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.3",
"khill/lavacharts": "3.1.*",
"laravel/framework": "5.8.*",
"khill/lavacharts": "^3.1.14",
"laravel/framework": "^5.8",
"laravel/horizon": "^3.1",
"laravel/socialite": "^3.1",
"laravel/tinker": "^1.0",

1622
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -148,9 +148,10 @@ return [
'mail',
'structures',
'assets',
'moons',
],
'balance' => 'auto',
'processes' => 10,
'processes' => 12,
'tries' => 3,
],
],
@@ -164,9 +165,10 @@ return [
'mail',
'structures',
'assets',
'moons',
],
'balance' => 'auto',
'processes' => 10,
'processes' => 12,
'tries' => 3,
],
],

View File

@@ -27,6 +27,7 @@ class CreateFlexStructuresTable extends Migration
'Cyno Beacon',
'Jump Bridge',
'Super Construction Facilities',
'Market',
]);
$table->double('structure_cost', 20, 2);
$table->dateTime('paid_until');

View File

@@ -1,52 +0,0 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateFleetTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if(!Schema::hasTable('alliance_fleets')) {
Schema::create('alliance_fleets', function(Blueprint $table) {
$table->bigIncrements('id');
$table->bigUnsignedInteger('fleet_id');
$table->bigUnsignedInteger('fleet_commander_id');
$table->string('fleet_commander_name')->nullable();
$table->unsignedInteger('member_count');
$table->dateTime('fleet_opened_time');
$table->dateTime('fleet_closed_time')->nullable();
$table->timestamps();
});
}
if(!Schema::hasTable('alliance_fleet_members')) {
Schema::create('alliance_fleet_members', function(Blueprint $table) {
$table->bigIncrements('id');
$table->bigUnsignedInteger('fleet_id');
$table->bigUnsignedInteger('character_id');
$table->string('character_name');
$table->dateTime('fleet_joined_time');
$table->dateTime('fleet_leaved_time');
$table->timestamps();
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('alliance_fleets');
Schema::dropIfExists('alliance_fleet_members');
}
}

View File

@@ -0,0 +1,94 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateRentalMoonLedgerTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if(!Schema::hasTable('alliance_mining_observers')) {
Schema::create('alliance_mining_observers', function(Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('corporation_id');
$table->string('corporation_name')->nullable();
$table->unsignedBigInteger('observer_id');
$table->string('observer_name')->nullable();
$table->string('observer_type')->nullable();
$table->dateTime('last_updated');
$table->timestamps();
});
}
if(!Schema::hasTable('alliance_rental_moon_ledgers')) {
Schema::create('alliance_rental_moon_ledgers', function(Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('corporation_id');
$table->string('corporation_name')->nullable();
$table->unsignedBigInteger('character_id');
$table->string('character_name')->nullable();
$table->unsignedBigInteger('observer_id');
$table->string('observer_name')->nullable();
$table->unsignedBigInteger('type_id');
$table->string('ore');
$table->unsignedBigInteger('quantity');
$table->unsignedBigInteger('recorded_corporation_id');
$table->string('record_corporation_name');
$table->dateTime('last_updated');
$table->timestamps();
});
}
if(!Schema::hasTable('corp_mining_observers')) {
Schema::create('corp_mining_observers', function(Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('corporation_id');
$table->string('corporation_name')->nullable();
$table->unsignedBigInteger('observer_id');
$table->string('observer_name')->nullable();
$table->string('observer_type')->nullable();
$table->unsignedBigInteger('observer_owner_id');
$table->unsignedBigInteger('solar_system_id');
$table->unsignedBigInteger('observer_type_id');
$table->dateTime('last_updated');
$table->timestamps();
});
}
if(!Schema::hasTable('corp_moon_ledgers')) {
Schema::create('corp_moon_ledgers', function(Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('corporation_id');
$table->string('corporation_name')->nullable();
$table->unsignedBigInteger('character_id');
$table->string('character_name')->nullable();
$table->unsignedBigInteger('observer_id');
$table->string('observer_name')->nullable();
$table->unsignedBigInteger('type_id');
$table->string('ore');
$table->unsignedBigInteger('quantity');
$table->unsignedBigInteger('recorded_corporation_id');
$table->string('recorded_corporation_name')->nullable();
$table->dateTime('last_updated');
$table->timestamps();
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('alliance_rental_moon_ledgers');
Schema::dropIfExists('corp_moon_ledgers');
}
}

Some files were not shown because too many files have changed in this diff Show More