Compare commits
565 Commits
use-error-
...
refactor_s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53330514ac | ||
|
|
ba226d9ba3 | ||
|
|
95d136284d | ||
|
|
f5aea7b0d5 | ||
|
|
dfc63641dc | ||
|
|
07a51ec8b1 | ||
|
|
e0ec6795b5 | ||
|
|
5509d756b7 | ||
|
|
b16a978f1b | ||
|
|
55ba6279a4 | ||
|
|
a9eea830e3 | ||
|
|
af564935d5 | ||
|
|
3ee76be7e3 | ||
|
|
d58f87862c | ||
|
|
0b6859c491 | ||
|
|
727c0e458c | ||
|
|
870dc747db | ||
|
|
0fb3d83fac | ||
|
|
0d59ccd6a6 | ||
|
|
5da3ce3564 | ||
|
|
c3bbca30ad | ||
|
|
37f14fff3b | ||
|
|
eb6c51fabd | ||
|
|
5ecd2b6293 | ||
|
|
dccb788a88 | ||
|
|
d10fe77ee7 | ||
|
|
5e1d792bba | ||
|
|
9cf71976f6 | ||
|
|
15745d9737 | ||
|
|
bd97955b9e | ||
|
|
252d99421c | ||
|
|
5767a98ad8 | ||
|
|
0c820cbc0d | ||
|
|
db81701621 | ||
|
|
a05c33febf | ||
|
|
147fcfb8eb | ||
|
|
58a3d09b5f | ||
|
|
30a06a5942 | ||
|
|
6c6af78e08 | ||
|
|
3f79fd7ea7 | ||
|
|
9b06bbb6c3 | ||
|
|
ce30863177 | ||
|
|
d7f70146f4 | ||
|
|
867fa2f36e | ||
|
|
e1882ee6d2 | ||
|
|
7eee239378 | ||
|
|
4188849ae1 | ||
|
|
787e651778 | ||
|
|
ef9b6e3b07 | ||
|
|
06c599cc17 | ||
|
|
6105323877 | ||
|
|
0933a2d4ea | ||
|
|
a8d853c44a | ||
|
|
7e1b47708e | ||
|
|
979e4502ff | ||
|
|
99dd51a965 | ||
|
|
15c2169477 | ||
|
|
50fa6ce335 | ||
|
|
159a1d3f43 | ||
|
|
d1149730be | ||
|
|
46ad1d072f | ||
|
|
780ed91a10 | ||
|
|
bcb4bd9eb4 | ||
|
|
f50ccbcc49 | ||
|
|
0e9b3c9119 | ||
|
|
4933aa5784 | ||
|
|
d67addc69e | ||
|
|
02c80ff18a | ||
|
|
c01190fac2 | ||
|
|
017884f843 | ||
|
|
c49921f50f | ||
|
|
c49abb6aea | ||
|
|
ccd2019448 | ||
|
|
96191a5e93 | ||
|
|
c56affd663 | ||
|
|
3cf746d7df | ||
|
|
6b7af802af | ||
|
|
604a964462 | ||
|
|
2f72c66614 | ||
|
|
fdcc17ca2c | ||
|
|
cba1a56040 | ||
|
|
d9afde4610 | ||
|
|
42095c0167 | ||
|
|
2500375400 | ||
|
|
e4e1d0d50a | ||
|
|
16c8264e76 | ||
|
|
0ae9ce0aa9 | ||
|
|
50b8f180b3 | ||
|
|
914a647204 | ||
|
|
e9225ff3ea | ||
|
|
d0d4159088 | ||
|
|
69b6080bd8 | ||
|
|
b997d728fb | ||
|
|
ddead359d0 | ||
|
|
f3c4e55667 | ||
|
|
0d35335da7 | ||
|
|
feaa714304 | ||
|
|
e1a70023b1 | ||
|
|
de62359c67 | ||
|
|
12bda8fc7b | ||
|
|
fb4fe30049 | ||
|
|
b054017c9f | ||
|
|
524a442724 | ||
|
|
8aa298f6b0 | ||
|
|
1f34657734 | ||
|
|
0856ee648e | ||
|
|
1dafc970df | ||
|
|
94a074a193 | ||
|
|
2d49e1eff2 | ||
|
|
705bc6f0c0 | ||
|
|
b5b93fdd3a | ||
|
|
d9432baf7a | ||
|
|
90be2a4498 | ||
|
|
3886da8941 | ||
|
|
130e0c6242 | ||
|
|
4361a10818 | ||
|
|
aa8048ac15 | ||
|
|
710e738e8e | ||
|
|
3705b91439 | ||
|
|
707bdad192 | ||
|
|
242fe33f97 | ||
|
|
ded79469c1 | ||
|
|
d9fbf330e5 | ||
|
|
2cb9ac26cd | ||
|
|
185bc966e6 | ||
|
|
a7f7e4938f | ||
|
|
2883e79193 | ||
|
|
9c4191ae0a | ||
|
|
3a77b83e9c | ||
|
|
d9be2b5a5e | ||
|
|
69c43c610c | ||
|
|
4f957bcf71 | ||
|
|
5cda7cce48 | ||
|
|
41b94e7128 | ||
|
|
aa55fa6ff4 | ||
|
|
67a605c9a5 | ||
|
|
c2663ea1e0 | ||
|
|
3ee5713740 | ||
|
|
ab8a22f77e | ||
|
|
56e7ea6677 | ||
|
|
26d7572bcc | ||
|
|
8c9132aff9 | ||
|
|
382ebef8ca | ||
|
|
2be88cb955 | ||
|
|
3f36d5f9b3 | ||
|
|
f76da48448 | ||
|
|
8035326675 | ||
|
|
dfdd85abb1 | ||
|
|
063ea1892b | ||
|
|
e213053775 | ||
|
|
88d549e7c5 | ||
|
|
983a25aa5f | ||
|
|
bde05d6ed9 | ||
|
|
b5ffe54bd0 | ||
|
|
863c0a8b60 | ||
|
|
32551d55d7 | ||
|
|
7fc498a597 | ||
|
|
cb281c6408 | ||
|
|
f483cd448f | ||
|
|
78ca1026fd | ||
|
|
722d5a58e7 | ||
|
|
7461c3e0ca | ||
|
|
3c0f4181ae | ||
|
|
3699d79363 | ||
|
|
350b627ce1 | ||
|
|
ee046a8688 | ||
|
|
b34a7c8aad | ||
|
|
f92bf5dc20 | ||
|
|
4d9e85026a | ||
|
|
54fbd0540d | ||
|
|
b483bb1633 | ||
|
|
4db7358086 | ||
|
|
0dd6f41f66 | ||
|
|
684c20ae39 | ||
|
|
3153bbb13f | ||
|
|
3dc64cc5e0 | ||
|
|
c32f4e34b4 | ||
|
|
ca1886cebc | ||
|
|
a79dfea40a | ||
|
|
45ab49eeab | ||
|
|
8232618a9f | ||
|
|
9a651b567d | ||
|
|
97d00e5aa8 | ||
|
|
5b90d79494 | ||
|
|
b9cfdf2e54 | ||
|
|
1139acd9f3 | ||
|
|
b7ad80bd31 | ||
|
|
5ffd1b8daa | ||
|
|
9a2117466e | ||
|
|
7e3a062984 | ||
|
|
d274fb6963 | ||
|
|
27ba641aa5 | ||
|
|
5823197e6f | ||
|
|
cfc04a1d12 | ||
|
|
cae8aa7840 | ||
|
|
12da43303f | ||
|
|
fdfea390fb | ||
|
|
b04afbbc85 | ||
|
|
b964ce1025 | ||
|
|
6217cba201 | ||
|
|
68e3f375fc | ||
|
|
5689e940b8 | ||
|
|
e807cfab86 | ||
|
|
0b3f458561 | ||
|
|
001348c638 | ||
|
|
1b041af862 | ||
|
|
260b153689 | ||
|
|
05d74f7a92 | ||
|
|
dc85588d7f | ||
|
|
585f998cae | ||
|
|
d120585f94 | ||
|
|
166a700342 | ||
|
|
36b27fcda3 | ||
|
|
a44490e448 | ||
|
|
9aada2ec70 | ||
|
|
3f74ff25d2 | ||
|
|
ef82f954e5 | ||
|
|
3f311ba2fb | ||
|
|
96953aa2ed | ||
|
|
b797c37acb | ||
|
|
6c85ba3495 | ||
|
|
ac6411743b | ||
|
|
3f0245f88f | ||
|
|
c02647a0fa | ||
|
|
edca3f432c | ||
|
|
2218c94aa3 | ||
|
|
e609b39760 | ||
|
|
12522a3791 | ||
|
|
f6d7ea19e4 | ||
|
|
18ddffe8f9 | ||
|
|
9b03f46490 | ||
|
|
926a319552 | ||
|
|
9f8473e254 | ||
|
|
cb6e5042d9 | ||
|
|
c1a887b48b | ||
|
|
658c94ad8b | ||
|
|
0e61d0b195 | ||
|
|
ba12204842 | ||
|
|
1c3babacaf | ||
|
|
abdddbec44 | ||
|
|
eeabc8dc9d | ||
|
|
21f8ac8e52 | ||
|
|
a425c2b765 | ||
|
|
2a2666be0b | ||
|
|
c38222e956 | ||
|
|
0ce5832b6c | ||
|
|
b6340532d7 | ||
|
|
5fb43dd159 | ||
|
|
de57d71bf1 | ||
|
|
ba69259f2d | ||
|
|
c71411465a | ||
|
|
8cf1e4dceb | ||
|
|
66249a37ed | ||
|
|
96712cb398 | ||
|
|
fac4833b58 | ||
|
|
a12c9d053f | ||
|
|
8b3b68b308 | ||
|
|
4b02db5031 | ||
|
|
ab90c0cf05 | ||
|
|
cef7ddc719 | ||
|
|
3870095a28 | ||
|
|
a02e250b22 | ||
|
|
8ac5c0e471 | ||
|
|
a2d4dcf6e8 | ||
|
|
54044bfa5e | ||
|
|
e493cc964d | ||
|
|
29af210f4f | ||
|
|
34eb10ff73 | ||
|
|
ab0c009c0d | ||
|
|
7d7d58769c | ||
|
|
b68805cf83 | ||
|
|
245d5dc469 | ||
|
|
7d858129d9 | ||
|
|
65ce63bc9b | ||
|
|
54fba2f547 | ||
|
|
5eea9d1950 | ||
|
|
b84a634ec7 | ||
|
|
2fc88a0e08 | ||
|
|
bc540b6564 | ||
|
|
f53b852dff | ||
|
|
b83d1a043f | ||
|
|
4ab478bb97 | ||
|
|
b21c303e56 | ||
|
|
5128fd49e6 | ||
|
|
2d2d5bdc7e | ||
|
|
8364d26c9b | ||
|
|
efd6d7625f | ||
|
|
bdf5708bfc | ||
|
|
e95703cb18 | ||
|
|
7ad4a29970 | ||
|
|
cdb7ccb8f3 | ||
|
|
8270947ed2 | ||
|
|
4f7c8e0c3d | ||
|
|
d609ed50a4 | ||
|
|
b88f2054dd | ||
|
|
d7914e238d | ||
|
|
d7bde37842 | ||
|
|
454796e52a | ||
|
|
eef487d61b | ||
|
|
71dbc7abb0 | ||
|
|
d639d6fbc1 | ||
|
|
74088ea581 | ||
|
|
fff069824b | ||
|
|
d446773fdd | ||
|
|
f283b5fbe8 | ||
|
|
a5be18bb14 | ||
|
|
eb6f05faf7 | ||
|
|
118183ff58 | ||
|
|
2137890496 | ||
|
|
ebf6ce6980 | ||
|
|
9b22d6d493 | ||
|
|
5ebf0ed2b2 | ||
|
|
836893cba5 | ||
|
|
cd98b3817d | ||
|
|
727806372c | ||
|
|
5e1c736d49 | ||
|
|
6579fa72da | ||
|
|
82d6e1510f | ||
|
|
822ea96dfd | ||
|
|
b247fc33b9 | ||
|
|
2dcae780c0 | ||
|
|
5c3180ffa0 | ||
|
|
65eba30038 | ||
|
|
bbce7b40ca | ||
|
|
02a29c71ef | ||
|
|
6699995972 | ||
|
|
951f03094a | ||
|
|
354b00ef15 | ||
|
|
c93229179b | ||
|
|
a77a7065d7 | ||
|
|
4363e8b34c | ||
|
|
9adb2c24f3 | ||
|
|
634a4afa75 | ||
|
|
7650628d30 | ||
|
|
7f690a6238 | ||
|
|
b32ab6a06c | ||
|
|
4ff5fc1ff9 | ||
|
|
86f13a9735 | ||
|
|
c40209f500 | ||
|
|
a071fff954 | ||
|
|
8b50ef077d | ||
|
|
607f29030f | ||
|
|
a6bcd3c0c2 | ||
|
|
9b293afaac | ||
|
|
636c776620 | ||
|
|
d5f659024c | ||
|
|
832e50a71e | ||
|
|
fa19686248 | ||
|
|
c021609c13 | ||
|
|
655abe8be5 | ||
|
|
d96c5e1ba4 | ||
|
|
dddbf27d78 | ||
|
|
bae9982833 | ||
|
|
a807646d39 | ||
|
|
abe79df6dc | ||
|
|
fcefcc8184 | ||
|
|
04bb3eec83 | ||
|
|
f963b9a19f | ||
|
|
154d5d8d91 | ||
|
|
1582d81e5b | ||
|
|
7c85ad54eb | ||
|
|
7b31df7c14 | ||
|
|
83b4bf9cf8 | ||
|
|
6c996b7759 | ||
|
|
9e957baeb5 | ||
|
|
12fd9cd97a | ||
|
|
9e03c4ba6f | ||
|
|
3519a82ddd | ||
|
|
8eb1c487bc | ||
|
|
e835637ef0 | ||
|
|
eb35608bb5 | ||
|
|
3f07f682de | ||
|
|
a629df07bf | ||
|
|
9a13fcab23 | ||
|
|
f5705a1dde | ||
|
|
f325c4afdb | ||
|
|
1fddacd7d0 | ||
|
|
4af893df61 | ||
|
|
b8b3f91ce4 | ||
|
|
7f40f55343 | ||
|
|
b06e8d442d | ||
|
|
c269184c60 | ||
|
|
53c673dee2 | ||
|
|
50730fc4fb | ||
|
|
60a54cee79 | ||
|
|
446e962a50 | ||
|
|
79a4bb7316 | ||
|
|
2f76c1bc5b | ||
|
|
38b9f4a438 | ||
|
|
fe5fc6e0ce | ||
|
|
62747a0090 | ||
|
|
9ff2111055 | ||
|
|
b465cc98d8 | ||
|
|
4debaaea39 | ||
|
|
1328366a48 | ||
|
|
4facc4007e | ||
|
|
31da47e046 | ||
|
|
3105f53aff | ||
|
|
2047cfed09 | ||
|
|
e3268d32df | ||
|
|
6df8b0ac0e | ||
|
|
910f13c1f7 | ||
|
|
8ce2512f55 | ||
|
|
0ec415d4d0 | ||
|
|
2044570e95 | ||
|
|
b336c6273d | ||
|
|
5299b3e9f0 | ||
|
|
872b76b45f | ||
|
|
275cf4630e | ||
|
|
5c2660bd34 | ||
|
|
c7ae9d9dfa | ||
|
|
0bc98e971f | ||
|
|
8774da3921 | ||
|
|
c6c5cb73cf | ||
|
|
a97530367d | ||
|
|
43250ae881 | ||
|
|
04e96b8f20 | ||
|
|
98323185de | ||
|
|
9e5f6d656a | ||
|
|
7e14f8c6d6 | ||
|
|
ab3b655312 | ||
|
|
601d8d7e5f | ||
|
|
ca01261c1f | ||
|
|
15183c4822 | ||
|
|
fddbdafb99 | ||
|
|
a5dbece1a9 | ||
|
|
4f0f72b29e | ||
|
|
4183d1834f | ||
|
|
713bb104ec | ||
|
|
4998d60f39 | ||
|
|
7cf30003b6 | ||
|
|
f6bf2d03c4 | ||
|
|
6f44441a8b | ||
|
|
e7e5dfbdfa | ||
|
|
d62315fbe4 | ||
|
|
7f3f77dec8 | ||
|
|
82e56c6832 | ||
|
|
76c9015aa9 | ||
|
|
5d5f421294 | ||
|
|
367f02af86 | ||
|
|
7a1c721eca | ||
|
|
6423df2133 | ||
|
|
dc6a5bf998 | ||
|
|
0820dd9da4 | ||
|
|
aa6ab2df60 | ||
|
|
22a2cc0256 | ||
|
|
57fab0268b | ||
|
|
ad5768d8b2 | ||
|
|
35533c39d5 | ||
|
|
de403f6e07 | ||
|
|
549dec9f9e | ||
|
|
d4426e4686 | ||
|
|
b2a6349243 | ||
|
|
c5dbc5f6b8 | ||
|
|
7f2cae4f26 | ||
|
|
ce97e2a30f | ||
|
|
7d9a0eba04 | ||
|
|
010f66f4c9 | ||
|
|
9c6718b459 | ||
|
|
9f832a93c9 | ||
|
|
487d88c012 | ||
|
|
0e9f7153c0 | ||
|
|
7c8955b126 | ||
|
|
20fa4c39f9 | ||
|
|
f04a4a3cf5 | ||
|
|
cf07186ae8 | ||
|
|
51d63d57c6 | ||
|
|
e34f549e4c | ||
|
|
e1fcfc8dc1 | ||
|
|
9fe8a866e0 | ||
|
|
e8e3060a75 | ||
|
|
6aaf2f623f | ||
|
|
dfbccf50e8 | ||
|
|
a8813cca94 | ||
|
|
13dbf9ee74 | ||
|
|
f8bbb7ad9b | ||
|
|
3c7d455ee3 | ||
|
|
9fef27a448 | ||
|
|
d2b88a5107 | ||
|
|
4e35f389df | ||
|
|
e5b9d9a28b | ||
|
|
4111ef0d78 | ||
|
|
cfa56e2219 | ||
|
|
7f1dfcc935 | ||
|
|
6f3fb21fef | ||
|
|
a48e79a1fc | ||
|
|
c207d48430 | ||
|
|
991e48696a | ||
|
|
7974885041 | ||
|
|
4ef85bd529 | ||
|
|
6eab83a85a | ||
|
|
cce1f87da6 | ||
|
|
b460e8dc83 | ||
|
|
50cb7e65c9 | ||
|
|
9a73311a99 | ||
|
|
aec781e7df | ||
|
|
7f3c86165b | ||
|
|
10b45812c4 | ||
|
|
c3165717ed | ||
|
|
d0a351a132 | ||
|
|
68749e7e87 | ||
|
|
0abb5637e0 | ||
|
|
821dd158d1 | ||
|
|
6c9a402685 | ||
|
|
1b310f3a24 | ||
|
|
a2246b9645 | ||
|
|
1d89759706 | ||
|
|
206f8fe605 | ||
|
|
21d2217619 | ||
|
|
833bcb282f | ||
|
|
c54bff0f83 | ||
|
|
d3f30ced94 | ||
|
|
59832126cb | ||
|
|
680cce3ee2 | ||
|
|
6c5ec6a16c | ||
|
|
5d1f98bf93 | ||
|
|
973e2e5756 | ||
|
|
46ed076428 | ||
|
|
d3a555ce91 | ||
|
|
0f8e041809 | ||
|
|
8e1111c681 | ||
|
|
e8a22f3c5b | ||
|
|
d843cf8dcc | ||
|
|
1013dcae61 | ||
|
|
c30c649aaa | ||
|
|
bb1385369c | ||
|
|
c1caf6088e | ||
|
|
12dfe71ea8 | ||
|
|
ca89268716 | ||
|
|
43b109fac0 | ||
|
|
75c1e7658f | ||
|
|
e7c9c799bb | ||
|
|
6ab976f353 | ||
|
|
ec5731353a | ||
|
|
3283704fe8 | ||
|
|
540df32046 | ||
|
|
85486fa58c | ||
|
|
3618df2ec5 | ||
|
|
a201f22fdb | ||
|
|
6070d530cf | ||
|
|
6c0cf94473 | ||
|
|
ab63a19aff | ||
|
|
bf4b915168 | ||
|
|
0a9c2e354f | ||
|
|
038e86954b | ||
|
|
f6c1642bf2 | ||
|
|
47f1b3b14e | ||
|
|
198b76ebc2 | ||
|
|
5546f9676a | ||
|
|
46caa478d2 | ||
|
|
4d8569e754 | ||
|
|
4dc57f95e2 | ||
|
|
316ee6f810 | ||
|
|
509cc812ea | ||
|
|
d5f66bc0dd | ||
|
|
1e213c31ef | ||
|
|
91874dfe0b | ||
|
|
0e6eda5e8a | ||
|
|
24560b9362 | ||
|
|
3ea5d4ee40 | ||
|
|
697595d963 | ||
|
|
0bdd8a5917 | ||
|
|
e35dd2daa1 | ||
|
|
f71b69a739 | ||
|
|
499a3debcd |
@@ -97,7 +97,7 @@ API_TOKEN_EXPIRATION_YEARS=40
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: SECURITY HEADER SETTINGS
|
||||
# --------------------------------------------
|
||||
APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1,172.0.0.0/8
|
||||
APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1,172.16.0.0/12
|
||||
ALLOW_IFRAMING=false
|
||||
REFERRER_POLICY=same-origin
|
||||
ENABLE_CSP=false
|
||||
|
||||
3
.github/workflows/stale.yml
vendored
3
.github/workflows/stale.yml
vendored
@@ -14,7 +14,8 @@ jobs:
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
debug-only: true
|
||||
operations-per-run: 100 # just while we're debugging
|
||||
ascending: true
|
||||
operations-per-run: 1000 # just while we're debugging
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
days-before-stale: 60
|
||||
days-before-close: 7
|
||||
|
||||
2
.github/workflows/tests-mysql.yml
vendored
2
.github/workflows/tests-mysql.yml
vendored
@@ -76,4 +76,4 @@ jobs:
|
||||
DB_DATABASE: snipeit
|
||||
DB_PORT: ${{ job.services.mysql.ports[3306] }}
|
||||
DB_USERNAME: root
|
||||
run: php artisan test --parallel
|
||||
run: php artisan test
|
||||
|
||||
2
.github/workflows/tests-postgres.yml
vendored
2
.github/workflows/tests-postgres.yml
vendored
@@ -74,4 +74,4 @@ jobs:
|
||||
DB_PORT: ${{ job.services.postgresql.ports[5432] }}
|
||||
DB_USERNAME: snipeit
|
||||
DB_PASSWORD: password
|
||||
run: php artisan test --parallel
|
||||
run: php artisan test
|
||||
|
||||
2
.github/workflows/tests-sqlite.yml
vendored
2
.github/workflows/tests-sqlite.yml
vendored
@@ -58,4 +58,4 @@ jobs:
|
||||
- name: Execute tests (Unit and Feature tests) via PHPUnit
|
||||
env:
|
||||
DB_CONNECTION: sqlite_testing
|
||||
run: php artisan test --parallel
|
||||
run: php artisan test
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -47,6 +47,7 @@ storage/private_uploads/users/*
|
||||
tests/_data/scenarios
|
||||
tests/_output/*
|
||||
tests/_support/_generated/*
|
||||
tests/coverage/*
|
||||
/npm-debug.log
|
||||
/storage/oauth-private.key
|
||||
/storage/oauth-public.key
|
||||
|
||||
@@ -84,7 +84,11 @@ Since the release of the JSON REST API, several third-party developers have been
|
||||
|
||||
### Contributing
|
||||
|
||||
Please see the documentation on [contributing and developing for Snipe-IT](https://snipe-it.readme.io/docs/contributing-overview).
|
||||
Please refrain from submitting issues or pull requests generated by fully-automated tools. Maintainers reserve the right, at their sole discretion, to close such submissions and to block any account responsible for them.
|
||||
|
||||
Ideally, contributions should follow from a human-to-human discussion in the form of an issue.
|
||||
|
||||
Please see the complete documentation on [contributing and developing for Snipe-IT](https://snipe-it.readme.io/docs/contributing-overview).
|
||||
|
||||
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
|
||||
|
||||
|
||||
276
app/Console/Commands/LdapSync.php
Executable file → Normal file
276
app/Console/Commands/LdapSync.php
Executable file → Normal file
@@ -53,18 +53,22 @@ class LdapSync extends Command
|
||||
|
||||
ini_set('max_execution_time', env('LDAP_TIME_LIM', 600)); //600 seconds = 10 minutes
|
||||
ini_set('memory_limit', env('LDAP_MEM_LIM', '500M'));
|
||||
$ldap_result_username = Setting::getSettings()->ldap_username_field;
|
||||
$ldap_result_last_name = Setting::getSettings()->ldap_lname_field;
|
||||
$ldap_result_first_name = Setting::getSettings()->ldap_fname_field;
|
||||
$ldap_result_active_flag = Setting::getSettings()->ldap_active_flag;
|
||||
$ldap_result_emp_num = Setting::getSettings()->ldap_emp_num;
|
||||
$ldap_result_email = Setting::getSettings()->ldap_email;
|
||||
$ldap_result_phone = Setting::getSettings()->ldap_phone_field;
|
||||
$ldap_result_jobtitle = Setting::getSettings()->ldap_jobtitle;
|
||||
$ldap_result_country = Setting::getSettings()->ldap_country;
|
||||
$ldap_result_location = Setting::getSettings()->ldap_location;
|
||||
$ldap_result_dept = Setting::getSettings()->ldap_dept;
|
||||
$ldap_result_manager = Setting::getSettings()->ldap_manager;
|
||||
|
||||
$ldap_map = [
|
||||
"username" => Setting::getSettings()->ldap_username_field,
|
||||
"last_name" => Setting::getSettings()->ldap_lname_field,
|
||||
"first_name" => Setting::getSettings()->ldap_fname_field,
|
||||
"active_flag" => Setting::getSettings()->ldap_active_flag,
|
||||
"emp_num" => Setting::getSettings()->ldap_emp_num,
|
||||
"email" => Setting::getSettings()->ldap_email,
|
||||
"phone" => Setting::getSettings()->ldap_phone_field,
|
||||
"jobtitle" => Setting::getSettings()->ldap_jobtitle,
|
||||
"country" => Setting::getSettings()->ldap_country,
|
||||
"location" => Setting::getSettings()->ldap_location,
|
||||
"dept" => Setting::getSettings()->ldap_dept,
|
||||
"manager" => Setting::getSettings()->ldap_manager,
|
||||
];
|
||||
|
||||
$ldap_default_group = Setting::getSettings()->ldap_default_group;
|
||||
$search_base = Setting::getSettings()->ldap_base_dn;
|
||||
|
||||
@@ -107,14 +111,21 @@ class LdapSync extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* If a filter has been specified, use that
|
||||
* If a filter has been specified, use that, otherwise default to null
|
||||
*/
|
||||
if ($this->option('filter') != '') {
|
||||
$results = Ldap::findLdapUsers($search_base, -1, $this->option('filter'));
|
||||
$filter = $this->option('filter');
|
||||
} else {
|
||||
$results = Ldap::findLdapUsers($search_base);
|
||||
$filter = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* We only need to request the LDAP attributes that we process
|
||||
*/
|
||||
$attributes = array_values(array_filter($ldap_map));
|
||||
|
||||
$results = Ldap::findLdapUsers($search_base, -1, $filter, $attributes);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
if ($this->option('json_summary')) {
|
||||
$json_summary = ['error' => true, 'error_message' => $e->getMessage(), 'summary' => []];
|
||||
@@ -126,23 +137,24 @@ class LdapSync extends Command
|
||||
}
|
||||
|
||||
/* Determine which location to assign users to by default. */
|
||||
$location = null; // TODO - this would be better called "$default_location", which is more explicit about its purpose
|
||||
$default_location = null;
|
||||
if ($this->option('location') != '') {
|
||||
if ($location = Location::where('name', '=', $this->option('location'))->first()) {
|
||||
if ($default_location = Location::where('name', '=', $this->option('location'))->first()) {
|
||||
Log::debug('Location name ' . $this->option('location') . ' passed');
|
||||
Log::debug('Importing to ' . $location->name . ' (' . $location->id . ')');
|
||||
Log::debug('Importing to '.$default_location->name.' ('.$default_location->id.')');
|
||||
}
|
||||
|
||||
} elseif ($this->option('location_id')) {
|
||||
//TODO - figure out how or why this is an array?
|
||||
foreach($this->option('location_id') as $location_id) {
|
||||
if ($location = Location::where('id', '=', $location_id)->first()) {
|
||||
if ($default_location = Location::where('id', '=', $location_id)->first()) {
|
||||
Log::debug('Location ID ' . $location_id . ' passed');
|
||||
Log::debug('Importing to ' . $location->name . ' (' . $location->id . ')');
|
||||
Log::debug('Importing to '.$default_location->name.' ('.$default_location->id.')');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (! isset($location)) {
|
||||
if (!isset($default_location)) {
|
||||
Log::debug('That location is invalid or a location was not provided, so no location will be assigned by default.');
|
||||
}
|
||||
|
||||
@@ -183,17 +195,17 @@ class LdapSync extends Command
|
||||
}
|
||||
$usernames = [];
|
||||
for ($i = 0; $i < $location_users['count']; $i++) {
|
||||
if (array_key_exists($ldap_result_username, $location_users[$i])) {
|
||||
if (array_key_exists($ldap_map["username"], $location_users[$i])) {
|
||||
$location_users[$i]['ldap_location_override'] = true;
|
||||
$location_users[$i]['location_id'] = $ldap_loc['id'];
|
||||
$usernames[] = $location_users[$i][$ldap_result_username][0];
|
||||
$usernames[] = $location_users[$i][$ldap_map["username"]][0];
|
||||
}
|
||||
}
|
||||
|
||||
// Delete located users from the general group.
|
||||
foreach ($results as $key => $generic_entry) {
|
||||
if ((is_array($generic_entry)) && (array_key_exists($ldap_result_username, $generic_entry))) {
|
||||
if (in_array($generic_entry[$ldap_result_username][0], $usernames)) {
|
||||
if ((is_array($generic_entry)) && (array_key_exists($ldap_map["username"], $generic_entry))) {
|
||||
if (in_array($generic_entry[$ldap_map["username"]][0], $usernames)) {
|
||||
unset($results[$key]);
|
||||
}
|
||||
}
|
||||
@@ -218,77 +230,78 @@ class LdapSync extends Command
|
||||
|
||||
|
||||
for ($i = 0; $i < $results['count']; $i++) {
|
||||
$item = [];
|
||||
$item['username'] = $results[$i][$ldap_result_username][0] ?? '';
|
||||
$item['employee_number'] = $results[$i][$ldap_result_emp_num][0] ?? '';
|
||||
$item['lastname'] = $results[$i][$ldap_result_last_name][0] ?? '';
|
||||
$item['firstname'] = $results[$i][$ldap_result_first_name][0] ?? '';
|
||||
$item['email'] = $results[$i][$ldap_result_email][0] ?? '';
|
||||
$item['ldap_location_override'] = $results[$i]['ldap_location_override'] ?? '';
|
||||
$item['location_id'] = $results[$i]['location_id'] ?? '';
|
||||
$item['telephone'] = $results[$i][$ldap_result_phone][0] ?? '';
|
||||
$item['jobtitle'] = $results[$i][$ldap_result_jobtitle][0] ?? '';
|
||||
$item['country'] = $results[$i][$ldap_result_country][0] ?? '';
|
||||
$item['department'] = $results[$i][$ldap_result_dept][0] ?? '';
|
||||
$item['manager'] = $results[$i][$ldap_result_manager][0] ?? '';
|
||||
$item['location'] = $results[$i][$ldap_result_location][0] ?? '';
|
||||
$item = [];
|
||||
$item['username'] = $results[$i][$ldap_map["username"]][0] ?? '';
|
||||
$item['employee_number'] = $results[$i][$ldap_map["emp_num"]][0] ?? '';
|
||||
$item['lastname'] = $results[$i][$ldap_map["last_name"]][0] ?? '';
|
||||
$item['firstname'] = $results[$i][$ldap_map["first_name"]][0] ?? '';
|
||||
$item['email'] = $results[$i][$ldap_map["email"]][0] ?? '';
|
||||
$item['ldap_location_override'] = $results[$i]['ldap_location_override'] ?? '';
|
||||
$item['location_id'] = $results[$i]['location_id'] ?? '';
|
||||
$item['telephone'] = $results[$i][$ldap_map["phone"]][0] ?? '';
|
||||
$item['jobtitle'] = $results[$i][$ldap_map["jobtitle"]][0] ?? '';
|
||||
$item['country'] = $results[$i][$ldap_map["country"]][0] ?? '';
|
||||
$item['department'] = $results[$i][$ldap_map["dept"]][0] ?? '';
|
||||
$item['manager'] = $results[$i][$ldap_map["manager"]][0] ?? '';
|
||||
$item['location'] = $results[$i][$ldap_map["location"]][0] ?? '';
|
||||
$location = $default_location; //initially, set '$location' to the default_location (which may just be `null`)
|
||||
|
||||
// ONLY if you are using the "ldap_location" option *AND* you have an actual result
|
||||
if ($ldap_result_location && $item['location']) {
|
||||
$location = Location::firstOrCreate([
|
||||
'name' => $item['location'],
|
||||
]);
|
||||
}
|
||||
$department = Department::firstOrCreate([
|
||||
'name' => $item['department'],
|
||||
// ONLY if you are using the "ldap_location" option *AND* you have an actual result
|
||||
if ($ldap_map["location"] && $item['location']) {
|
||||
$location = Location::firstOrCreate([
|
||||
'name' => $item['location'],
|
||||
]);
|
||||
}
|
||||
$department = Department::firstOrCreate([
|
||||
'name' => $item['department'],
|
||||
]);
|
||||
|
||||
$user = User::where('username', $item['username'])->first();
|
||||
if ($user) {
|
||||
// Updating an existing user.
|
||||
$item['createorupdate'] = 'updated';
|
||||
} else {
|
||||
// Creating a new user.
|
||||
$user = new User;
|
||||
$user->password = $user->noPassword();
|
||||
$user->locale = app()->getLocale();
|
||||
$user->activated = 1; // newly created users can log in by default, unless AD's UAC is in use, or an active flag is set (below)
|
||||
$item['createorupdate'] = 'created';
|
||||
}
|
||||
$user = User::where('username', $item['username'])->first();
|
||||
if ($user) {
|
||||
// Updating an existing user.
|
||||
$item['createorupdate'] = 'updated';
|
||||
} else {
|
||||
// Creating a new user.
|
||||
$user = new User;
|
||||
$user->password = $user->noPassword();
|
||||
$user->locale = app()->getLocale();
|
||||
$user->activated = 1; // newly created users can log in by default, unless AD's UAC is in use, or an active flag is set (below)
|
||||
$item['createorupdate'] = 'created';
|
||||
}
|
||||
|
||||
//If a sync option is not filled in on the LDAP settings don't populate the user field
|
||||
if($ldap_result_username != null){
|
||||
if($ldap_map["username"] != null){
|
||||
$user->username = $item['username'];
|
||||
}
|
||||
if($ldap_result_last_name != null){
|
||||
if($ldap_map["last_name"] != null){
|
||||
$user->last_name = $item['lastname'];
|
||||
}
|
||||
if($ldap_result_first_name != null){
|
||||
if($ldap_map["first_name"] != null){
|
||||
$user->first_name = $item['firstname'];
|
||||
}
|
||||
if($ldap_result_emp_num != null){
|
||||
if($ldap_map["emp_num"] != null){
|
||||
$user->employee_num = e($item['employee_number']);
|
||||
}
|
||||
if($ldap_result_email != null){
|
||||
if($ldap_map["email"] != null){
|
||||
$user->email = $item['email'];
|
||||
}
|
||||
if($ldap_result_phone != null){
|
||||
if($ldap_map["phone"] != null){
|
||||
$user->phone = $item['telephone'];
|
||||
}
|
||||
if($ldap_result_jobtitle != null){
|
||||
if($ldap_map["jobtitle"] != null){
|
||||
$user->jobtitle = $item['jobtitle'];
|
||||
}
|
||||
if($ldap_result_country != null){
|
||||
if($ldap_map["country"] != null){
|
||||
$user->country = $item['country'];
|
||||
}
|
||||
if($ldap_result_dept != null){
|
||||
if($ldap_map["dept"] != null){
|
||||
$user->department_id = $department->id;
|
||||
}
|
||||
if($ldap_result_location != null){
|
||||
$user->location_id = $location ? $location->id : null;
|
||||
if($ldap_map["location"] != null){
|
||||
$user->location_id = $location?->id;
|
||||
}
|
||||
|
||||
if($ldap_result_manager != null){
|
||||
if($ldap_map["manager"] != null){
|
||||
if($item['manager'] != null) {
|
||||
// Check Cache first
|
||||
if (isset($manager_cache[$item['manager']])) {
|
||||
@@ -305,7 +318,7 @@ class LdapSync extends Command
|
||||
$ldap_manager = [
|
||||
"count" => 1,
|
||||
0 => [
|
||||
$ldap_result_username => [$item['manager']]
|
||||
$ldap_map["username"] => [$item['manager']]
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -314,7 +327,7 @@ class LdapSync extends Command
|
||||
|
||||
// Get the Manager's username
|
||||
// PHP LDAP returns every LDAP attribute as an array, and 90% of the time it's an array of just one item. But, hey, it's an array.
|
||||
$ldapManagerUsername = $ldap_manager[0][$ldap_result_username][0];
|
||||
$ldapManagerUsername = $ldap_manager[0][$ldap_map["username"]][0];
|
||||
|
||||
// Get User from Manager username.
|
||||
$ldap_manager = User::where('username', $ldapManagerUsername)->first();
|
||||
@@ -330,38 +343,38 @@ class LdapSync extends Command
|
||||
}
|
||||
}
|
||||
|
||||
// Sync activated state for Active Directory.
|
||||
if ( !empty($ldap_result_active_flag)) { // IF we have an 'active' flag set....
|
||||
// ....then *most* things that are truthy will activate the user. Anything falsey will deactivate them.
|
||||
// (Specifically, we don't handle a value of '0.0' correctly)
|
||||
$raw_value = @$results[$i][$ldap_result_active_flag][0];
|
||||
$filter_var = filter_var($raw_value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
|
||||
$boolean_cast = (bool)$raw_value;
|
||||
// Sync activated state for Active Directory.
|
||||
if (!empty($ldap_map["active_flag"])) { // IF we have an 'active' flag set....
|
||||
// ....then *most* things that are truthy will activate the user. Anything falsey will deactivate them.
|
||||
// (Specifically, we don't handle a value of '0.0' correctly)
|
||||
$raw_value = @$results[$i][$ldap_map["active_flag"]][0];
|
||||
$filter_var = filter_var($raw_value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
|
||||
$boolean_cast = (bool) $raw_value;
|
||||
|
||||
$user->activated = $filter_var ?? $boolean_cast; // if filter_var() was true or false, use that. If it's null, use the $boolean_cast
|
||||
$user->activated = $filter_var ?? $boolean_cast; // if filter_var() was true or false, use that. If it's null, use the $boolean_cast
|
||||
|
||||
} elseif (array_key_exists('useraccountcontrol', $results[$i]) ) {
|
||||
// ....otherwise, (ie if no 'active' LDAP flag is defined), IF the UAC setting exists,
|
||||
// ....then use the UAC setting on the account to determine can-log-in vs. cannot-log-in
|
||||
} elseif (array_key_exists('useraccountcontrol', $results[$i])) {
|
||||
// ....otherwise, (ie if no 'active' LDAP flag is defined), IF the UAC setting exists,
|
||||
// ....then use the UAC setting on the account to determine can-log-in vs. cannot-log-in
|
||||
|
||||
|
||||
/* The following is _probably_ the correct logic, but we can't use it because
|
||||
some users may have been dependent upon the previous behavior, and this
|
||||
could cause additional access to be available to users they don't want
|
||||
to allow to log in.
|
||||
/* The following is _probably_ the correct logic, but we can't use it because
|
||||
some users may have been dependent upon the previous behavior, and this
|
||||
could cause additional access to be available to users they don't want
|
||||
to allow to log in.
|
||||
|
||||
$useraccountcontrol = $results[$i]['useraccountcontrol'][0];
|
||||
if(
|
||||
// based on MS docs at: https://support.microsoft.com/en-us/help/305144/how-to-use-useraccountcontrol-to-manipulate-user-account-properties
|
||||
($useraccountcontrol & 0x200) && // is a NORMAL_ACCOUNT
|
||||
!($useraccountcontrol & 0x02) && // *and* _not_ ACCOUNTDISABLE
|
||||
!($useraccountcontrol & 0x10) // *and* _not_ LOCKOUT
|
||||
) {
|
||||
$user->activated = 1;
|
||||
} else {
|
||||
$user->activated = 0;
|
||||
} */
|
||||
$enabled_accounts = [
|
||||
$useraccountcontrol = $results[$i]['useraccountcontrol'][0];
|
||||
if(
|
||||
// based on MS docs at: https://support.microsoft.com/en-us/help/305144/how-to-use-useraccountcontrol-to-manipulate-user-account-properties
|
||||
($useraccountcontrol & 0x200) && // is a NORMAL_ACCOUNT
|
||||
!($useraccountcontrol & 0x02) && // *and* _not_ ACCOUNTDISABLE
|
||||
!($useraccountcontrol & 0x10) // *and* _not_ LOCKOUT
|
||||
) {
|
||||
$user->activated = 1;
|
||||
} else {
|
||||
$user->activated = 0;
|
||||
} */
|
||||
$enabled_accounts = [
|
||||
'512', // 0x200 NORMAL_ACCOUNT
|
||||
'544', // 0x220 NORMAL_ACCOUNT, PASSWD_NOTREQD
|
||||
'66048', // 0x10200 NORMAL_ACCOUNT, DONT_EXPIRE_PASSWORD
|
||||
@@ -374,44 +387,47 @@ class LdapSync extends Command
|
||||
'4260352', // 0x410200 NORMAL_ACCOUNT, DONT_EXPIRE_PASSWORD, DONT_REQ_PREAUTH
|
||||
'1049088', // 0x100200 NORMAL_ACCOUNT, NOT_DELEGATED
|
||||
'1114624', // 0x110200 NORMAL_ACCOUNT, DONT_EXPIRE_PASSWORD, NOT_DELEGATED,
|
||||
];
|
||||
$user->activated = (in_array($results[$i]['useraccountcontrol'][0], $enabled_accounts)) ? 1 : 0;
|
||||
];
|
||||
$user->activated = (in_array($results[$i]['useraccountcontrol'][0], $enabled_accounts)) ? 1 : 0;
|
||||
|
||||
// If we're not using AD, and there isn't an activated flag set, activate all users
|
||||
} /* implied 'else' here - leave the $user->activated flag alone. Newly-created accounts will be active.
|
||||
already-existing accounts will be however the administrator has set them */
|
||||
} /* implied 'else' here - leave the $user->activated flag alone. Newly-created accounts will be active.
|
||||
already-existing accounts will be however the administrator has set them */
|
||||
|
||||
|
||||
if ($item['ldap_location_override'] == true) {
|
||||
$user->location_id = $item['location_id'];
|
||||
} elseif ((isset($location)) && (! empty($location))) {
|
||||
if ((is_array($location)) && (array_key_exists('id', $location))) {
|
||||
$user->location_id = $location['id'];
|
||||
} elseif (is_object($location)) {
|
||||
$user->location_id = $location->id;
|
||||
}
|
||||
if ($item['ldap_location_override'] == true) {
|
||||
$user->location_id = $item['location_id'];
|
||||
} elseif ((isset($location)) && (!empty($location))) {
|
||||
if ((is_array($location)) && (array_key_exists('id', $location))) {
|
||||
$user->location_id = $location['id'];
|
||||
} elseif (is_object($location)) {
|
||||
$user->location_id = $location->id; //THIS is the magic line, this should do it.
|
||||
}
|
||||
$location = null;
|
||||
$user->ldap_import = 1;
|
||||
}
|
||||
// TODO - should we be NULLING locations if $location is really `null`, and that's what we came up with?
|
||||
// will that conflict with any overriding setting that the user set? Like, if they moved someone from
|
||||
// the 'null' location to somewhere, we wouldn't want to try to override that, right?
|
||||
$location = null;
|
||||
$user->ldap_import = 1;
|
||||
|
||||
$errors = '';
|
||||
$errors = '';
|
||||
|
||||
if ($user->save()) {
|
||||
$item['note'] = $item['createorupdate'];
|
||||
$item['status'] = 'success';
|
||||
if ( $item['createorupdate'] === 'created' && $ldap_default_group) {
|
||||
$user->groups()->attach($ldap_default_group);
|
||||
}
|
||||
|
||||
} else {
|
||||
foreach ($user->getErrors()->getMessages() as $key => $err) {
|
||||
$errors .= $err[0];
|
||||
}
|
||||
$item['note'] = $errors;
|
||||
$item['status'] = 'error';
|
||||
if ($user->save()) {
|
||||
$item['note'] = $item['createorupdate'];
|
||||
$item['status'] = 'success';
|
||||
if ($item['createorupdate'] === 'created' && $ldap_default_group) {
|
||||
$user->groups()->attach($ldap_default_group);
|
||||
}
|
||||
|
||||
array_push($summary, $item);
|
||||
} else {
|
||||
foreach ($user->getErrors()->getMessages() as $key => $err) {
|
||||
$errors .= $err[0];
|
||||
}
|
||||
$item['note'] = $errors;
|
||||
$item['status'] = 'error';
|
||||
}
|
||||
|
||||
array_push($summary, $item);
|
||||
}
|
||||
|
||||
if ($this->option('summary')) {
|
||||
|
||||
@@ -6,6 +6,7 @@ use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\Console\Helper\ProgressIndicator;
|
||||
|
||||
ini_set('max_execution_time', env('IMPORT_TIME_LIMIT', 600)); //600 seconds = 10 minutes
|
||||
ini_set('memory_limit', env('IMPORT_MEMORY_LIMIT', '500M'));
|
||||
@@ -29,6 +30,11 @@ class ObjectImportCommand extends Command
|
||||
*/
|
||||
protected $description = 'Import Items from CSV';
|
||||
|
||||
/**
|
||||
* The progress indicator instance.
|
||||
*/
|
||||
protected ProgressIndicator $progressIndicator;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
@@ -39,8 +45,6 @@ class ObjectImportCommand extends Command
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
private $bar;
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
@@ -48,6 +52,8 @@ class ObjectImportCommand extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->progressIndicator = new ProgressIndicator($this->output);
|
||||
|
||||
$filename = $this->argument('filename');
|
||||
$class = title_case($this->option('item-type'));
|
||||
$classString = "App\\Importer\\{$class}Importer";
|
||||
@@ -61,46 +67,25 @@ class ObjectImportCommand extends Command
|
||||
// This $logFile/useFiles() bit is currently broken, so commenting it out for now
|
||||
// $logFile = $this->option('logfile');
|
||||
// Log::useFiles($logFile);
|
||||
$this->comment('======= Importing Items from '.$filename.' =========');
|
||||
$this->progressIndicator->start('======= Importing Items from '.$filename.' =========');
|
||||
|
||||
$importer->import();
|
||||
|
||||
$this->bar = null;
|
||||
|
||||
if (! empty($this->errors)) {
|
||||
$this->comment('The following Errors were encountered.');
|
||||
foreach ($this->errors as $asset => $error) {
|
||||
$this->comment('Error: Item: '.$asset.' failed validation: '.json_encode($error));
|
||||
}
|
||||
} else {
|
||||
$this->comment('All Items imported successfully!');
|
||||
}
|
||||
$this->comment('');
|
||||
$this->progressIndicator->finish('Import finished.');
|
||||
}
|
||||
|
||||
public function errorCallback($item, $field, $errorString)
|
||||
public function errorCallback($item, $field, $error)
|
||||
{
|
||||
$this->errors[$item->name][$field] = $errorString;
|
||||
$this->output->write("\x0D\x1B[2K");
|
||||
|
||||
$this->warn('Error: Item: '.$item->name.' failed validation: '.json_encode($error));
|
||||
}
|
||||
|
||||
public function progress($count)
|
||||
public function progress($importedItemsCount)
|
||||
{
|
||||
if (! $this->bar) {
|
||||
$this->bar = $this->output->createProgressBar($count);
|
||||
}
|
||||
static $index = 0;
|
||||
$index++;
|
||||
if ($index < $count) {
|
||||
$this->bar->advance();
|
||||
} else {
|
||||
$this->bar->finish();
|
||||
}
|
||||
$this->progressIndicator->advance();
|
||||
}
|
||||
|
||||
// Tracks the current item for error messages
|
||||
private $updating;
|
||||
// An array of errors encountered while parsing
|
||||
private $errors;
|
||||
|
||||
/**
|
||||
* Log a message to file, configurable by the --log-file parameter.
|
||||
* If a warning message is passed, we'll spit it to the console as well.
|
||||
|
||||
@@ -50,7 +50,7 @@ class SendAcceptanceReminder extends Command
|
||||
$query->where('accepted_at', null)
|
||||
->where('declined_at', null);
|
||||
})
|
||||
->with(['assignedTo', 'checkoutable.assignedTo', 'checkoutable.model', 'checkoutable.admin'])
|
||||
->with(['assignedTo', 'checkoutable.assignedTo', 'checkoutable.model', 'checkoutable.adminuser'])
|
||||
->get();
|
||||
|
||||
$count = 0;
|
||||
|
||||
@@ -553,7 +553,7 @@ class Helper
|
||||
*/
|
||||
public static function statusLabelList()
|
||||
{
|
||||
$statuslabel_list = ['' => trans('general.select_statuslabel')] + Statuslabel::orderBy('default_label', 'desc')->orderBy('name', 'asc')->orderBy('deployable', 'desc')
|
||||
$statuslabel_list = ['' => trans('general.select_statuslabel')] + Statuslabel::orderBy('default_label', 'desc')->orderBy('name', 'asc')->orderBy('status_type', 'desc')
|
||||
->pluck('name', 'id')->toArray();
|
||||
|
||||
return $statuslabel_list;
|
||||
@@ -572,9 +572,9 @@ class Helper
|
||||
*/
|
||||
public static function deployableStatusLabelList()
|
||||
{
|
||||
$statuslabel_list = Statuslabel::where('deployable', '=', '1')->orderBy('default_label', 'desc')
|
||||
$statuslabel_list = Statuslabel::where('status_type', 'deployable')->orderBy('default_label', 'desc')
|
||||
->orderBy('name', 'asc')
|
||||
->orderBy('deployable', 'desc')
|
||||
->orderBy('status_type', 'desc')
|
||||
->pluck('name', 'id')->toArray();
|
||||
|
||||
return $statuslabel_list;
|
||||
@@ -1123,6 +1123,7 @@ class Helper
|
||||
'png' => 'far fa-image',
|
||||
'webp' => 'far fa-image',
|
||||
'avif' => 'far fa-image',
|
||||
'svg' => 'fas fa-vector-square',
|
||||
// word
|
||||
'doc' => 'far fa-file-word',
|
||||
'docx' => 'far fa-file-word',
|
||||
@@ -1135,7 +1136,7 @@ class Helper
|
||||
//Text
|
||||
'txt' => 'far fa-file-alt',
|
||||
'rtf' => 'far fa-file-alt',
|
||||
'xml' => 'far fa-file-alt',
|
||||
'xml' => 'fas fa-code',
|
||||
// Misc
|
||||
'pdf' => 'far fa-file-pdf',
|
||||
'lic' => 'far fa-save',
|
||||
@@ -1148,41 +1149,7 @@ class Helper
|
||||
return 'far fa-file';
|
||||
}
|
||||
|
||||
public static function show_file_inline($filename)
|
||||
{
|
||||
$extension = substr(strrchr($filename, '.'), 1);
|
||||
|
||||
if ($extension) {
|
||||
switch ($extension) {
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
case 'gif':
|
||||
case 'png':
|
||||
case 'webp':
|
||||
case 'avif':
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a random encrypted password.
|
||||
*
|
||||
* @author Wes Hulette <jwhulette@gmail.com>
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function generateEncyrptedPassword(): string
|
||||
{
|
||||
return bcrypt(self::generateUnencryptedPassword());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a random unencrypted password.
|
||||
|
||||
@@ -64,14 +64,19 @@ class IconHelper
|
||||
case 'kits':
|
||||
return 'fas fa-object-group';
|
||||
case 'assets':
|
||||
case 'asset':
|
||||
return 'fas fa-barcode';
|
||||
case 'accessories':
|
||||
case 'accessory':
|
||||
return 'far fa-keyboard';
|
||||
case 'components':
|
||||
case 'component':
|
||||
return 'far fa-hdd';
|
||||
case 'consumables':
|
||||
case 'consumable':
|
||||
return 'fas fa-tint';
|
||||
case 'licenses':
|
||||
case 'license':
|
||||
return 'far fa-save';
|
||||
case 'requestable':
|
||||
return 'fas fa-laptop';
|
||||
@@ -141,6 +146,8 @@ class IconHelper
|
||||
return 'fas fa-lock';
|
||||
case 'locations':
|
||||
return 'fas fa-map-marker-alt';
|
||||
case 'location':
|
||||
return 'fas fa-map-marker-alt';
|
||||
case 'superadmin':
|
||||
return 'fas fa-crown';
|
||||
case 'print':
|
||||
@@ -173,6 +180,10 @@ class IconHelper
|
||||
return 'fas fa-crosshairs';
|
||||
case 'oauth':
|
||||
return 'fas fa-user-secret';
|
||||
case 'employee_num' :
|
||||
return 'fa-regular fa-id-card';
|
||||
case 'department' :
|
||||
return 'fa-solid fa-building-user';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Http\Response;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
class StorageHelper
|
||||
{
|
||||
public static function downloader($filename, $disk = 'default') : BinaryFileResponse | RedirectResponse | StreamedResponse
|
||||
@@ -25,4 +26,64 @@ class StorageHelper
|
||||
return Storage::disk($disk)->download($filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This determines the file types that should be allowed inline and checks their fileinfo extension
|
||||
* to determine that they are safe to display inline.
|
||||
*
|
||||
* @author <A. Gianotto> [<snipe@snipe.net]>
|
||||
* @since v7.0.14
|
||||
* @param $file_with_path
|
||||
* @return bool
|
||||
*/
|
||||
public static function allowSafeInline($file_with_path) {
|
||||
|
||||
$allowed_inline = [
|
||||
'pdf',
|
||||
'svg',
|
||||
'jpg',
|
||||
'gif',
|
||||
'svg',
|
||||
'avif',
|
||||
'webp',
|
||||
'png',
|
||||
];
|
||||
|
||||
|
||||
// The file exists and is allowed to be displayed inline
|
||||
if (Storage::exists($file_with_path) && (in_array(pathinfo($file_with_path, PATHINFO_EXTENSION), $allowed_inline))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Decide whether to show the file inline or download it.
|
||||
*/
|
||||
public static function showOrDownloadFile($file, $filename) {
|
||||
|
||||
$headers = [];
|
||||
|
||||
if (request('inline') == 'true') {
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'inline',
|
||||
];
|
||||
|
||||
// This is NOT allowed as inline - force it to be displayed as text in the browser
|
||||
if (self::allowSafeInline($file) != true) {
|
||||
$headers = array_merge($headers, ['Content-Type' => 'text/plain']);
|
||||
}
|
||||
}
|
||||
|
||||
// Everything else seems okay, but the file doesn't exist on the server.
|
||||
if (Storage::missing($file)) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
|
||||
return Storage::download($file, $filename, $headers);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class AccessoriesController extends Controller
|
||||
$accessory->purchase_date = request('purchase_date');
|
||||
$accessory->purchase_cost = request('purchase_cost');
|
||||
$accessory->qty = request('qty');
|
||||
$accessory->user_id = auth()->id();
|
||||
$accessory->created_by = auth()->id();
|
||||
$accessory->supplier_id = request('supplier_id');
|
||||
$accessory->notes = request('notes');
|
||||
|
||||
|
||||
@@ -106,50 +106,29 @@ class AccessoriesFilesController extends Controller
|
||||
* @param int $accessoryId
|
||||
* @param int $fileId
|
||||
*/
|
||||
public function show($accessoryId = null, $fileId = null, $download = true) : View | RedirectResponse | Response | BinaryFileResponse | StreamedResponse
|
||||
public function show($accessoryId = null, $fileId = null) : View | RedirectResponse | Response | BinaryFileResponse | StreamedResponse
|
||||
{
|
||||
|
||||
Log::debug('Private filesystem is: '.config('filesystems.default'));
|
||||
$accessory = Accessory::find($accessoryId);
|
||||
|
||||
|
||||
|
||||
// the accessory is valid
|
||||
if (isset($accessory->id)) {
|
||||
if ($accessory = Accessory::find($accessoryId)) {
|
||||
$this->authorize('view', $accessory);
|
||||
$this->authorize('accessories.files', $accessory);
|
||||
|
||||
if (! $log = Actionlog::whereNotNull('filename')->where('item_id', $accessory->id)->find($fileId)) {
|
||||
return redirect()->route('accessories.index')->with('error', trans('admin/users/message.log_record_not_found'));
|
||||
}
|
||||
if ($log = Actionlog::whereNotNull('filename')->where('item_id', $accessory->id)->find($fileId)) {
|
||||
$file = 'private_uploads/accessories/'.$log->filename;
|
||||
|
||||
$file = 'private_uploads/accessories/'.$log->filename;
|
||||
|
||||
if (Storage::missing($file)) {
|
||||
Log::debug('FILE DOES NOT EXISTS for '.$file);
|
||||
Log::debug('URL should be '.Storage::url($file));
|
||||
|
||||
return response('File '.$file.' ('.Storage::url($file).') not found on server', 404)
|
||||
->header('Content-Type', 'text/plain');
|
||||
} else {
|
||||
|
||||
// Display the file inline
|
||||
if (request('inline') == 'true') {
|
||||
$headers = [
|
||||
'Content-Disposition' => 'inline',
|
||||
];
|
||||
return Storage::download($file, $log->filename, $headers);
|
||||
}
|
||||
|
||||
|
||||
// We have to override the URL stuff here, since local defaults in Laravel's Flysystem
|
||||
// won't work, as they're not accessible via the web
|
||||
if (config('filesystems.default') == 'local') { // TODO - is there any way to fix this at the StorageHelper layer?
|
||||
return StorageHelper::downloader($file);
|
||||
try {
|
||||
return StorageHelper::showOrDownloadFile($file, $log->filename);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->route('accessories.show', ['accessory' => $accessory])->with('error', trans('general.file_not_found'));
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('accessories.show', ['accessory' => $accessory])->with('error', trans('general.log_record_not_found'));
|
||||
|
||||
}
|
||||
|
||||
return redirect()->route('accessories.index')->with('error', trans('general.file_does_not_exist', ['id' => $fileId]));
|
||||
return redirect()->route('accessories.index')->with('error', trans('general.file_not_found'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class AccessoryCheckoutController extends Controller
|
||||
AccessoryCheckout::create([
|
||||
'accessory_id' => $accessory->id,
|
||||
'created_at' => Carbon::now(),
|
||||
'user_id' => Auth::id(),
|
||||
'created_by' => auth()->id(),
|
||||
'assigned_to' => $target->id,
|
||||
'assigned_type' => $target::class,
|
||||
'note' => $request->input('note'),
|
||||
|
||||
@@ -237,7 +237,11 @@ class AcceptanceController extends Controller
|
||||
}
|
||||
|
||||
$acceptance->accept($sig_filename, $item->getEula(), $pdf_filename, $request->input('note'));
|
||||
$acceptance->notify(new AcceptanceAssetAcceptedNotification($data));
|
||||
try {
|
||||
$acceptance->notify(new AcceptanceAssetAcceptedNotification($data));
|
||||
} catch (\Exception $e) {
|
||||
Log::warning($e);
|
||||
}
|
||||
event(new CheckoutAccepted($acceptance));
|
||||
|
||||
$return_msg = trans('admin/users/message.accepted');
|
||||
|
||||
@@ -56,8 +56,9 @@ class AccessoriesController extends Controller
|
||||
];
|
||||
|
||||
|
||||
$accessories = Accessory::select('accessories.*')->with('category', 'company', 'manufacturer', 'checkouts', 'location', 'supplier')
|
||||
->withCount('checkouts as checkouts_count');
|
||||
$accessories = Accessory::select('accessories.*')
|
||||
->with('category', 'company', 'manufacturer', 'checkouts', 'location', 'supplier', 'adminuser')
|
||||
->withCount('checkouts as checkouts_count');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$accessories = $accessories->TextSearch($request->input('search'));
|
||||
@@ -110,7 +111,10 @@ class AccessoriesController extends Controller
|
||||
break;
|
||||
case 'supplier':
|
||||
$accessories = $accessories->OrderSupplier($order);
|
||||
break;
|
||||
break;
|
||||
case 'created_by':
|
||||
$accessories = $accessories->OrderByCreatedByName($order);
|
||||
break;
|
||||
default:
|
||||
$accessories = $accessories->orderBy($column_sort, $order);
|
||||
break;
|
||||
@@ -133,7 +137,6 @@ class AccessoriesController extends Controller
|
||||
*/
|
||||
public function store(StoreAccessoryRequest $request)
|
||||
{
|
||||
$this->authorize('create', Accessory::class);
|
||||
$accessory = new Accessory;
|
||||
$accessory->fill($request->all());
|
||||
$accessory = $request->handleImages($accessory);
|
||||
@@ -193,9 +196,6 @@ class AccessoriesController extends Controller
|
||||
$this->authorize('view', Accessory::class);
|
||||
|
||||
$accessory = Accessory::with('lastCheckout')->findOrFail($id);
|
||||
if (! Company::isCurrentUserHasAccess($accessory)) {
|
||||
return ['total' => 0, 'rows' => []];
|
||||
}
|
||||
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
@@ -287,7 +287,7 @@ class AccessoriesController extends Controller
|
||||
AccessoryCheckout::create([
|
||||
'accessory_id' => $accessory->id,
|
||||
'created_at' => Carbon::now(),
|
||||
'user_id' => Auth::id(),
|
||||
'created_by' => auth()->id(),
|
||||
'assigned_to' => $target->id,
|
||||
'assigned_type' => $target::class,
|
||||
'note' => $request->input('note'),
|
||||
@@ -321,7 +321,7 @@ class AccessoriesController extends Controller
|
||||
$accessory = Accessory::find($accessory_checkout->accessory_id);
|
||||
$this->authorize('checkin', $accessory);
|
||||
|
||||
$logaction = $accessory->logCheckin(User::find($accessory_checkout->assigned_to), $request->input('note'));
|
||||
$accessory->logCheckin(User::find($accessory_checkout->assigned_to), $request->input('note'));
|
||||
|
||||
// Was the accessory updated?
|
||||
if ($accessory_checkout->delete()) {
|
||||
@@ -329,14 +329,6 @@ class AccessoriesController extends Controller
|
||||
$user = User::find($accessory_checkout->assigned_to);
|
||||
}
|
||||
|
||||
$data['log_id'] = $logaction->id;
|
||||
$data['first_name'] = $user->first_name;
|
||||
$data['last_name'] = $user->last_name;
|
||||
$data['item_name'] = $accessory->name;
|
||||
$data['checkin_date'] = $logaction->created_at;
|
||||
$data['item_tag'] = '';
|
||||
$data['note'] = $logaction->note;
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/accessories/message.checkin.success')));
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class AssetMaintenancesController extends Controller
|
||||
$this->authorize('view', Asset::class);
|
||||
|
||||
$maintenances = AssetMaintenance::select('asset_maintenances.*')
|
||||
->with('asset', 'asset.model', 'asset.location', 'asset.defaultLoc', 'supplier', 'asset.company', 'asset.assetstatus', 'admin');
|
||||
->with('asset', 'asset.model', 'asset.location', 'asset.defaultLoc', 'supplier', 'asset.company', 'asset.assetstatus', 'adminuser');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$maintenances = $maintenances->TextSearch($request->input('search'));
|
||||
@@ -48,6 +48,10 @@ class AssetMaintenancesController extends Controller
|
||||
$maintenances->where('asset_maintenances.supplier_id', '=', $request->input('supplier_id'));
|
||||
}
|
||||
|
||||
if ($request->filled('created_by')) {
|
||||
$maintenances->where('asset_maintenances.created_by', '=', $request->input('created_by'));
|
||||
}
|
||||
|
||||
if ($request->filled('asset_maintenance_type')) {
|
||||
$maintenances->where('asset_maintenance_type', '=', $request->input('asset_maintenance_type'));
|
||||
}
|
||||
@@ -69,7 +73,7 @@ class AssetMaintenancesController extends Controller
|
||||
'asset_tag',
|
||||
'asset_name',
|
||||
'serial',
|
||||
'user_id',
|
||||
'created_by',
|
||||
'supplier',
|
||||
'is_warranty',
|
||||
'status_label',
|
||||
@@ -79,8 +83,8 @@ class AssetMaintenancesController extends Controller
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
|
||||
|
||||
switch ($sort) {
|
||||
case 'user_id':
|
||||
$maintenances = $maintenances->OrderAdmin($order);
|
||||
case 'created_by':
|
||||
$maintenances = $maintenances->OrderByCreatedBy($order);
|
||||
break;
|
||||
case 'supplier':
|
||||
$maintenances = $maintenances->OrderBySupplier($order);
|
||||
@@ -124,7 +128,7 @@ class AssetMaintenancesController extends Controller
|
||||
// create a new model instance
|
||||
$maintenance = new AssetMaintenance();
|
||||
$maintenance->fill($request->all());
|
||||
$maintenance->user_id = Auth::id();
|
||||
$maintenance->created_by = auth()->id();
|
||||
|
||||
// Was the asset maintenance created?
|
||||
if ($maintenance->save()) {
|
||||
@@ -186,11 +190,8 @@ class AssetMaintenancesController extends Controller
|
||||
{
|
||||
$this->authorize('update', Asset::class);
|
||||
// Check if the asset maintenance exists
|
||||
$assetMaintenance = AssetMaintenance::findOrFail($assetMaintenanceId);
|
||||
|
||||
if (! Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, 'You cannot delete a maintenance for that asset'));
|
||||
}
|
||||
$assetMaintenance = AssetMaintenance::findOrFail($assetMaintenanceId);
|
||||
|
||||
$assetMaintenance->delete();
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ class AssetModelsController extends Controller
|
||||
'assets_count',
|
||||
'category',
|
||||
'fieldset',
|
||||
'deleted_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
$assetmodels = AssetModel::select([
|
||||
@@ -67,7 +69,7 @@ class AssetModelsController extends Controller
|
||||
'models.deleted_at',
|
||||
'models.updated_at',
|
||||
])
|
||||
->with('category', 'depreciation', 'manufacturer', 'fieldset.fields.defaultValues')
|
||||
->with('category', 'depreciation', 'manufacturer', 'fieldset.fields.defaultValues','adminuser')
|
||||
->withCount('assets as assets_count');
|
||||
|
||||
if ($request->input('status')=='deleted') {
|
||||
|
||||
@@ -56,7 +56,12 @@ class AssetsController extends Controller
|
||||
public function index(Request $request, $action = null, $upcoming_status = null) : JsonResponse | array
|
||||
{
|
||||
|
||||
$filter_non_deprecable_assets = false;
|
||||
|
||||
// This handles the legacy audit endpoints :(
|
||||
if ($action == 'audit') {
|
||||
$action = 'audits';
|
||||
}
|
||||
$filter_non_depreciable_assets = false;
|
||||
|
||||
/**
|
||||
* This looks MAD janky (and it is), but the AssetsController@index does a LOT of heavy lifting throughout the
|
||||
@@ -70,7 +75,7 @@ class AssetsController extends Controller
|
||||
* which would have been far worse of a mess. *sad face* - snipe (Sept 1, 2021)
|
||||
*/
|
||||
if (Route::currentRouteName()=='api.depreciation-report.index') {
|
||||
$filter_non_deprecable_assets = true;
|
||||
$filter_non_depreciable_assets = true;
|
||||
$transformer = 'App\Http\Transformers\DepreciationReportTransformer';
|
||||
$this->authorize('reports.view');
|
||||
} else {
|
||||
@@ -121,13 +126,13 @@ class AssetsController extends Controller
|
||||
}
|
||||
|
||||
$assets = Asset::select('assets.*')
|
||||
->with('location', 'assetstatus', 'company', 'defaultLoc','assignedTo',
|
||||
->with('location', 'assetstatus', 'company', 'defaultLoc','assignedTo', 'adminuser','model.depreciation',
|
||||
'model.category', 'model.manufacturer', 'model.fieldset','supplier'); //it might be tempting to add 'assetlog' here, but don't. It blows up update-heavy users.
|
||||
|
||||
|
||||
if ($filter_non_deprecable_assets) {
|
||||
$non_deprecable_models = AssetModel::select('id')->whereNotNull('depreciation_id')->get();
|
||||
$assets->InModelList($non_deprecable_models->toArray());
|
||||
if ($filter_non_depreciable_assets) {
|
||||
$non_depreciable_models = AssetModel::select('id')->whereNotNull('depreciation_id')->get();
|
||||
$assets->InModelList($non_depreciable_models->toArray());
|
||||
}
|
||||
|
||||
|
||||
@@ -154,8 +159,8 @@ class AssetsController extends Controller
|
||||
* Handle due and overdue audits and checkin dates
|
||||
*/
|
||||
switch ($action) {
|
||||
case 'audits':
|
||||
|
||||
// Audit (singular) is left over from earlier legacy APIs
|
||||
case 'audits' :
|
||||
switch ($upcoming_status) {
|
||||
case 'due':
|
||||
$assets->DueForAudit($settings);
|
||||
@@ -201,18 +206,14 @@ class AssetsController extends Controller
|
||||
case 'Pending':
|
||||
$assets->join('status_labels AS status_alias', function ($join) {
|
||||
$join->on('status_alias.id', '=', 'assets.status_id')
|
||||
->where('status_alias.deployable', '=', 0)
|
||||
->where('status_alias.pending', '=', 1)
|
||||
->where('status_alias.archived', '=', 0);
|
||||
->where('status_alias.status_type', '=', 'pending');
|
||||
});
|
||||
break;
|
||||
case 'RTD':
|
||||
$assets->whereNull('assets.assigned_to')
|
||||
->join('status_labels AS status_alias', function ($join) {
|
||||
$join->on('status_alias.id', '=', 'assets.status_id')
|
||||
->where('status_alias.deployable', '=', 1)
|
||||
->where('status_alias.pending', '=', 0)
|
||||
->where('status_alias.archived', '=', 0);
|
||||
->where('status_alias.status_type', '=', 'deployable');
|
||||
});
|
||||
break;
|
||||
case 'Undeployable':
|
||||
@@ -221,20 +222,15 @@ class AssetsController extends Controller
|
||||
case 'Archived':
|
||||
$assets->join('status_labels AS status_alias', function ($join) {
|
||||
$join->on('status_alias.id', '=', 'assets.status_id')
|
||||
->where('status_alias.deployable', '=', 0)
|
||||
->where('status_alias.pending', '=', 0)
|
||||
->where('status_alias.archived', '=', 1);
|
||||
->where('status_alias.status_type', '=', 'archived');
|
||||
});
|
||||
break;
|
||||
case 'Requestable':
|
||||
$assets->where('assets.requestable', '=', 1)
|
||||
->join('status_labels AS status_alias', function ($join) {
|
||||
$join->on('status_alias.id', '=', 'assets.status_id')
|
||||
->where('status_alias.deployable', '=', 1)
|
||||
->where('status_alias.pending', '=', 0)
|
||||
->where('status_alias.archived', '=', 0);
|
||||
->where('status_alias.status_type', '=', 'deployable');
|
||||
});
|
||||
|
||||
break;
|
||||
case 'Deployed':
|
||||
// more sad, horrible workarounds for laravel bugs when doing full text searches
|
||||
@@ -251,7 +247,7 @@ class AssetsController extends Controller
|
||||
// terrible workaround for complex-query Laravel bug in fulltext
|
||||
$assets->join('status_labels AS status_alias', function ($join) {
|
||||
$join->on('status_alias.id', '=', 'assets.status_id')
|
||||
->where('status_alias.archived', '=', 0);
|
||||
->where('status_alias.status_type', '!=', 'archived');
|
||||
});
|
||||
|
||||
// If there is a status ID, don't take show_archived_in_list into consideration
|
||||
@@ -260,6 +256,7 @@ class AssetsController extends Controller
|
||||
$join->on('status_alias.id', '=', 'assets.status_id');
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@@ -371,8 +368,33 @@ class AssetsController extends Controller
|
||||
case 'assigned_to':
|
||||
$assets->OrderAssigned($order);
|
||||
break;
|
||||
case 'created_by':
|
||||
$assets->OrderByCreatedByName($order);
|
||||
break;
|
||||
default:
|
||||
$assets->orderBy($column_sort, $order);
|
||||
$numeric_sort = false;
|
||||
|
||||
// Search through the custom fields array to see if we're sorting on a custom field
|
||||
if (array_search($column_sort, $all_custom_fields->pluck('db_column')->toArray()) !== false) {
|
||||
|
||||
// Check to see if this is a numeric field type
|
||||
foreach ($all_custom_fields as $field) {
|
||||
if (($field->db_column == $sort_override) && ($field->format == 'NUMERIC')) {
|
||||
$numeric_sort = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// This may not work for all databases, but it works for MySQL
|
||||
if ($numeric_sort) {
|
||||
$assets->orderByRaw(DB::getTablePrefix() . 'assets.' . $sort_override . ' * 1 ' . $order);
|
||||
} else {
|
||||
$assets->orderBy($sort_override, $order);
|
||||
}
|
||||
|
||||
} else {
|
||||
$assets->orderBy($column_sort, $order);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -544,8 +566,8 @@ class AssetsController extends Controller
|
||||
}
|
||||
|
||||
|
||||
if ($asset->assetstatus->getStatuslabelType() == 'pending') {
|
||||
$asset->use_text .= '('.$asset->assetstatus->getStatuslabelType().')';
|
||||
if ($asset->assetstatus->status_label == 'pending') {
|
||||
$asset->use_text .= '('.$asset->assetstatus->status_label.')';
|
||||
}
|
||||
|
||||
$asset->use_image = ($asset->getImageUrl()) ? $asset->getImageUrl() : null;
|
||||
@@ -568,7 +590,7 @@ class AssetsController extends Controller
|
||||
$asset->model()->associate(AssetModel::find((int) $request->get('model_id')));
|
||||
|
||||
$asset->fill($request->validated());
|
||||
$asset->user_id = Auth::id();
|
||||
$asset->created_by = auth()->id();
|
||||
|
||||
/**
|
||||
* this is here just legacy reasons. Api\AssetController
|
||||
@@ -750,9 +772,16 @@ class AssetsController extends Controller
|
||||
if ($asset = Asset::find($id)) {
|
||||
$this->authorize('delete', $asset);
|
||||
|
||||
DB::table('assets')
|
||||
->where('id', $asset->id)
|
||||
->update(['assigned_to' => null]);
|
||||
if ($asset->assignedTo) {
|
||||
|
||||
$target = $asset->assignedTo;
|
||||
$checkin_at = date('Y-m-d H:i:s');
|
||||
$originalValues = $asset->getRawOriginal();
|
||||
event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on delete', $checkin_at, $originalValues));
|
||||
DB::table('assets')
|
||||
->where('id', $asset->id)
|
||||
->update(['assigned_to' => null]);
|
||||
}
|
||||
|
||||
$asset->delete();
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ class CategoriesController extends Controller
|
||||
|
||||
$categories = Category::select([
|
||||
'id',
|
||||
'created_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'name', 'category_type',
|
||||
@@ -50,8 +51,10 @@ class CategoriesController extends Controller
|
||||
'eula_text',
|
||||
'require_acceptance',
|
||||
'checkin_email',
|
||||
'image'
|
||||
])->withCount('accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'licenses as licenses_count');
|
||||
'image',
|
||||
])
|
||||
->with('adminuser')
|
||||
->withCount('accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'licenses as licenses_count');
|
||||
|
||||
|
||||
/*
|
||||
@@ -91,13 +94,33 @@ class CategoriesController extends Controller
|
||||
$categories->where('checkin_email', '=', $request->input('checkin_email'));
|
||||
}
|
||||
|
||||
if ($request->filled('created_by')) {
|
||||
$categories->where('created_by', '=', $request->input('created_by'));
|
||||
}
|
||||
|
||||
if ($request->filled('created_at')) {
|
||||
$categories->where('created_at', '=', $request->input('created_at'));
|
||||
}
|
||||
|
||||
if ($request->filled('updated_at')) {
|
||||
$categories->where('updated_at', '=', $request->input('updated_at'));
|
||||
}
|
||||
|
||||
// Make sure the offset and limit are actually integers and do not exceed system limits
|
||||
$offset = ($request->input('offset') > $categories->count()) ? $categories->count() : app('api_offset_value');
|
||||
$limit = app('api_limit_value');
|
||||
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'assets_count';
|
||||
$categories->orderBy($sort, $order);
|
||||
$sort_override = $request->input('sort');
|
||||
$column_sort = in_array($sort_override, $allowed_columns) ? $sort_override : 'assets_count';
|
||||
|
||||
switch ($sort_override) {
|
||||
case 'created_by':
|
||||
$categories = $categories->OrderByCreatedBy($order);
|
||||
break;
|
||||
default:
|
||||
$categories = $categories->orderBy($column_sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
$total = $categories->count();
|
||||
$categories = $categories->skip($offset)->take($limit)->get();
|
||||
|
||||
@@ -42,7 +42,7 @@ class CompaniesController extends Controller
|
||||
|
||||
$companies = Company::withCount(['assets as assets_count' => function ($query) {
|
||||
$query->AssetsForShow();
|
||||
}])->withCount('licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'users as users_count');
|
||||
}])->withCount('assets as assets_count', 'licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'users as users_count');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$companies->TextSearch($request->input('search'));
|
||||
@@ -56,17 +56,29 @@ class CompaniesController extends Controller
|
||||
$companies->where('email', '=', $request->input('email'));
|
||||
}
|
||||
|
||||
if ($request->filled('created_by')) {
|
||||
$companies->where('created_by', '=', $request->input('created_by'));
|
||||
}
|
||||
|
||||
|
||||
// Make sure the offset and limit are actually integers and do not exceed system limits
|
||||
$offset = ($request->input('offset') > $companies->count()) ? $companies->count() : app('api_offset_value');
|
||||
$limit = app('api_limit_value');
|
||||
|
||||
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
|
||||
$companies->orderBy($sort, $order);
|
||||
$sort_override = $request->input('sort');
|
||||
$column_sort = in_array($sort_override, $allowed_columns) ? $sort_override : 'created_at';
|
||||
|
||||
switch ($sort_override) {
|
||||
case 'created_by':
|
||||
$companies = $companies->OrderByCreatedBy($order);
|
||||
break;
|
||||
default:
|
||||
$companies = $companies->orderBy($column_sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
$total = $companies->count();
|
||||
|
||||
$companies = $companies->skip($offset)->take($limit)->get();
|
||||
return (new CompaniesTransformer)->transformCompanies($companies, $total);
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ class ComponentsController extends Controller
|
||||
'name',
|
||||
'min_amt',
|
||||
'order_number',
|
||||
'model_number',
|
||||
'serial',
|
||||
'purchase_date',
|
||||
'purchase_cost',
|
||||
@@ -47,7 +48,7 @@ class ComponentsController extends Controller
|
||||
];
|
||||
|
||||
$components = Component::select('components.*')
|
||||
->with('company', 'location', 'category', 'assets', 'supplier');
|
||||
->with('company', 'location', 'category', 'assets', 'supplier', 'adminuser', 'manufacturer');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$components = $components->TextSearch($request->input('search'));
|
||||
@@ -69,6 +70,14 @@ class ComponentsController extends Controller
|
||||
$components->where('supplier_id', '=', $request->input('supplier_id'));
|
||||
}
|
||||
|
||||
if ($request->filled('manufacturer_id')) {
|
||||
$components->where('manufacturer_id', '=', $request->input('manufacturer_id'));
|
||||
}
|
||||
|
||||
if ($request->filled('model_number')) {
|
||||
$components->where('model_number', '=', $request->input('model_number'));
|
||||
}
|
||||
|
||||
if ($request->filled('location_id')) {
|
||||
$components->where('location_id', '=', $request->input('location_id'));
|
||||
}
|
||||
@@ -98,6 +107,12 @@ class ComponentsController extends Controller
|
||||
case 'supplier':
|
||||
$components = $components->OrderSupplier($order);
|
||||
break;
|
||||
case 'manufacturer':
|
||||
$components = $components->OrderManufacturer($order);
|
||||
break;
|
||||
case 'created_by':
|
||||
$components = $components->OrderByCreatedBy($order);
|
||||
break;
|
||||
default:
|
||||
$components = $components->orderBy($column_sort, $order);
|
||||
break;
|
||||
@@ -270,7 +285,7 @@ class ComponentsController extends Controller
|
||||
'component_id' => $component->id,
|
||||
'created_at' => Carbon::now(),
|
||||
'assigned_qty' => $request->get('assigned_qty', 1),
|
||||
'user_id' => auth()->id(),
|
||||
'created_by' => auth()->id(),
|
||||
'asset_id' => $request->get('assigned_to'),
|
||||
'note' => $request->get('note'),
|
||||
]);
|
||||
|
||||
@@ -86,9 +86,15 @@ class ConsumablesController extends Controller
|
||||
case 'company':
|
||||
$consumables = $consumables->OrderCompany($order);
|
||||
break;
|
||||
case 'remaining':
|
||||
$consumables = $consumables->OrderRemaining($order);
|
||||
break;
|
||||
case 'supplier':
|
||||
$consumables = $consumables->OrderSupplier($order);
|
||||
break;
|
||||
case 'created_by':
|
||||
$consumables = $consumables->OrderByCreatedBy($order);
|
||||
break;
|
||||
default:
|
||||
// This array is what determines which fields should be allowed to be sorted on ON the table itself.
|
||||
// These must match a column on the consumables table directly.
|
||||
@@ -207,7 +213,7 @@ class ConsumablesController extends Controller
|
||||
$consumable = Consumable::with(['consumableAssignments'=> function ($query) {
|
||||
$query->orderBy($query->getModel()->getTable().'.created_at', 'DESC');
|
||||
},
|
||||
'consumableAssignments.admin'=> function ($query) {
|
||||
'consumableAssignments.adminuser'=> function ($query) {
|
||||
},
|
||||
'consumableAssignments.user'=> function ($query) {
|
||||
},
|
||||
@@ -225,7 +231,8 @@ class ConsumablesController extends Controller
|
||||
'name' => ($consumable_assignment->user) ? $consumable_assignment->user->present()->nameUrl() : 'Deleted User',
|
||||
'created_at' => Helper::getFormattedDateObject($consumable_assignment->created_at, 'datetime'),
|
||||
'note' => ($consumable_assignment->note) ? e($consumable_assignment->note) : null,
|
||||
'admin' => ($consumable_assignment->admin) ? $consumable_assignment->admin->present()->nameUrl() : null,
|
||||
'admin' => ($consumable_assignment->adminuser) ? $consumable_assignment->adminuser->present()->nameUrl() : null, // legacy, so we don't change the shape of the response
|
||||
'created_by' => ($consumable_assignment->adminuser) ? $consumable_assignment->adminuser->present()->nameUrl() : null,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -251,6 +258,8 @@ class ConsumablesController extends Controller
|
||||
|
||||
$this->authorize('checkout', $consumable);
|
||||
|
||||
$consumable->checkout_qty = $request->input('checkout_qty', 1);
|
||||
|
||||
// Make sure there is at least one available to checkout
|
||||
if ($consumable->numRemaining() <= 0) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/consumables/message.checkout.unavailable')));
|
||||
@@ -261,6 +270,12 @@ class ConsumablesController extends Controller
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.invalid_item_category_single', ['type' => trans('general.consumable')])));
|
||||
}
|
||||
|
||||
// Make sure there is at least one available to checkout
|
||||
if ($consumable->numRemaining() <= 0 || $consumable->checkout_qty > $consumable->numRemaining()) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/consumables/message.checkout.unavailable', ['requested' => $consumable->checkout_qty, 'remaining' => $consumable->numRemaining() ])));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check if the user exists - @TODO: this should probably be handled via validation, not here??
|
||||
if (!$user = User::find($request->input('assigned_to'))) {
|
||||
@@ -271,14 +286,17 @@ class ConsumablesController extends Controller
|
||||
// Update the consumable data
|
||||
$consumable->assigned_to = $request->input('assigned_to');
|
||||
|
||||
$consumable->users()->attach($consumable->id,
|
||||
for ($i = 0; $i < $consumable->checkout_qty; $i++) {
|
||||
$consumable->users()->attach($consumable->id,
|
||||
[
|
||||
'consumable_id' => $consumable->id,
|
||||
'user_id' => $user->id,
|
||||
'created_by' => $user->id,
|
||||
'assigned_to' => $request->input('assigned_to'),
|
||||
'note' => $request->input('note'),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
event(new CheckoutableCheckedOut($consumable, $user, auth()->user(), $request->input('note')));
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ class DepartmentsController extends Controller
|
||||
$department->fill($request->all());
|
||||
$department = $request->handleImages($department);
|
||||
|
||||
$department->user_id = auth()->id();
|
||||
$department->created_by = auth()->id();
|
||||
$department->manager_id = ($request->filled('manager_id') ? $request->input('manager_id') : null);
|
||||
|
||||
if ($department->save()) {
|
||||
|
||||
@@ -32,7 +32,8 @@ class DepreciationsController extends Controller
|
||||
'licenses_count',
|
||||
];
|
||||
|
||||
$depreciations = Depreciation::select('id','name','months','depreciation_min','depreciation_type','user_id','created_at','updated_at')
|
||||
$depreciations = Depreciation::select('id','name','months','depreciation_min','depreciation_type','created_at','updated_at', 'created_by')
|
||||
->with('adminuser')
|
||||
->withCount('assets as assets_count')
|
||||
->withCount('models as models_count')
|
||||
->withCount('licenses as licenses_count');
|
||||
@@ -44,10 +45,18 @@ class DepreciationsController extends Controller
|
||||
// Make sure the offset and limit are actually integers and do not exceed system limits
|
||||
$offset = ($request->input('offset') > $depreciations->count()) ? $depreciations->count() : app('api_offset_value');
|
||||
$limit = app('api_limit_value');
|
||||
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
|
||||
$depreciations->orderBy($sort, $order);
|
||||
$sort_override = $request->input('sort');
|
||||
$column_sort = in_array($sort_override, $allowed_columns) ? $sort_override : 'created_at';
|
||||
|
||||
switch ($sort_override) {
|
||||
case 'created_by':
|
||||
$depreciations = $depreciations->OrderByCreatedBy($order);
|
||||
break;
|
||||
default:
|
||||
$depreciations = $depreciations->orderBy($column_sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
$total = $depreciations->count();
|
||||
$depreciations = $depreciations->skip($offset)->take($limit)->get();
|
||||
|
||||
@@ -23,9 +23,8 @@ class GroupsController extends Controller
|
||||
$this->authorize('superadmin');
|
||||
|
||||
$this->authorize('view', Group::class);
|
||||
$allowed_columns = ['id', 'name', 'created_at', 'users_count'];
|
||||
|
||||
$groups = Group::select('id', 'name', 'permissions', 'created_at', 'updated_at', 'created_by')->with('admin')->withCount('users as users_count');
|
||||
$groups = Group::select('id', 'name', 'permissions', 'created_at', 'updated_at', 'created_by')->with('adminuser')->withCount('users as users_count');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$groups = $groups->TextSearch($request->input('search'));
|
||||
@@ -35,13 +34,29 @@ class GroupsController extends Controller
|
||||
$groups->where('name', '=', $request->input('name'));
|
||||
}
|
||||
|
||||
// Make sure the offset and limit are actually integers and do not exceed system limits
|
||||
|
||||
$offset = ($request->input('offset') > $groups->count()) ? $groups->count() : app('api_offset_value');
|
||||
$limit = app('api_limit_value');
|
||||
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
|
||||
$groups->orderBy($sort, $order);
|
||||
|
||||
switch ($request->input('sort')) {
|
||||
case 'created_by':
|
||||
$groups = $groups->OrderByCreatedBy($order);
|
||||
break;
|
||||
default:
|
||||
// This array is what determines which fields should be allowed to be sorted on ON the table itself.
|
||||
// These must match a column on the consumables table directly.
|
||||
$allowed_columns = [
|
||||
'id',
|
||||
'name',
|
||||
'created_at',
|
||||
'users_count',
|
||||
];
|
||||
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
|
||||
$groups = $groups->orderBy($sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
$total = $groups->count();
|
||||
$groups = $groups->skip($offset)->take($limit)->get();
|
||||
|
||||
@@ -107,7 +107,7 @@ class LicenseSeatsController extends Controller
|
||||
|
||||
// attempt to update the license seat
|
||||
$licenseSeat->fill($request->all());
|
||||
$licenseSeat->user_id = auth()->id();
|
||||
$licenseSeat->created_by = auth()->id();
|
||||
|
||||
// check if this update is a checkin operation
|
||||
// 1. are relevant fields touched at all?
|
||||
|
||||
@@ -70,8 +70,8 @@ class LicensesController extends Controller
|
||||
$licenses->where('depreciation_id', '=', $request->input('depreciation_id'));
|
||||
}
|
||||
|
||||
if ($request->filled('user_id')) {
|
||||
$licenses->where('user_id', '=', $request->input('user_id'));
|
||||
if ($request->filled('created_by')) {
|
||||
$licenses->where('created_by', '=', $request->input('created_by'));
|
||||
}
|
||||
|
||||
if (($request->filled('maintained')) && ($request->input('maintained')=='true')) {
|
||||
@@ -117,7 +117,7 @@ class LicensesController extends Controller
|
||||
$licenses = $licenses->leftJoin('companies', 'licenses.company_id', '=', 'companies.id')->orderBy('companies.name', $order);
|
||||
break;
|
||||
case 'created_by':
|
||||
$licenses = $licenses->OrderCreatedBy($order);
|
||||
$licenses = $licenses->OrderByCreatedBy($order);
|
||||
break;
|
||||
default:
|
||||
$allowed_columns =
|
||||
@@ -182,7 +182,7 @@ class LicensesController extends Controller
|
||||
public function show($id) : JsonResponse | array
|
||||
{
|
||||
$this->authorize('view', License::class);
|
||||
$license = License::withCount('freeSeats')->findOrFail($id);
|
||||
$license = License::withCount('freeSeats as free_seats_count')->findOrFail($id);
|
||||
$license = $license->load('assignedusers', 'licenseSeats.user', 'licenseSeats.asset');
|
||||
|
||||
return (new LicensesTransformer)->transformLicense($license);
|
||||
@@ -220,7 +220,6 @@ class LicensesController extends Controller
|
||||
*/
|
||||
public function destroy($id) : JsonResponse
|
||||
{
|
||||
//
|
||||
$license = License::findOrFail($id);
|
||||
$this->authorize('delete', $license);
|
||||
|
||||
|
||||
@@ -25,11 +25,43 @@ class ManufacturersController extends Controller
|
||||
public function index(Request $request) : JsonResponse | array
|
||||
{
|
||||
$this->authorize('view', Manufacturer::class);
|
||||
$allowed_columns = ['id', 'name', 'url', 'support_url', 'support_email', 'warranty_lookup_url', 'support_phone', 'created_at', 'updated_at', 'image', 'assets_count', 'consumables_count', 'components_count', 'licenses_count'];
|
||||
$allowed_columns = [
|
||||
'id',
|
||||
'name',
|
||||
'url',
|
||||
'support_url',
|
||||
'support_email',
|
||||
'warranty_lookup_url',
|
||||
'support_phone',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'image',
|
||||
'assets_count',
|
||||
'consumables_count',
|
||||
'components_count',
|
||||
'licenses_count'
|
||||
];
|
||||
|
||||
$manufacturers = Manufacturer::select(
|
||||
['id', 'name', 'url', 'support_url', 'warranty_lookup_url', 'support_email', 'support_phone', 'created_at', 'updated_at', 'image', 'deleted_at']
|
||||
)->withCount('assets as assets_count')->withCount('licenses as licenses_count')->withCount('consumables as consumables_count')->withCount('accessories as accessories_count');
|
||||
$manufacturers = Manufacturer::select([
|
||||
'id',
|
||||
'name',
|
||||
'url',
|
||||
'support_url',
|
||||
'warranty_lookup_url',
|
||||
'support_email',
|
||||
'support_phone',
|
||||
'created_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'image',
|
||||
'deleted_at',
|
||||
])
|
||||
->with('adminuser')
|
||||
->withCount('assets as assets_count')
|
||||
->withCount('licenses as licenses_count')
|
||||
->withCount('consumables as consumables_count')
|
||||
->withCount('accessories as accessories_count')
|
||||
->withCount('components as components_count');
|
||||
|
||||
if ($request->input('deleted') == 'true') {
|
||||
$manufacturers->onlyTrashed();
|
||||
@@ -66,10 +98,18 @@ class ManufacturersController extends Controller
|
||||
// Make sure the offset and limit are actually integers and do not exceed system limits
|
||||
$offset = ($request->input('offset') > $manufacturers->count()) ? $manufacturers->count() : app('api_offset_value');
|
||||
$limit = app('api_limit_value');
|
||||
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
|
||||
$manufacturers->orderBy($sort, $order);
|
||||
$sort_override = $request->input('sort');
|
||||
$column_sort = in_array($sort_override, $allowed_columns) ? $sort_override : 'created_at';
|
||||
|
||||
switch ($sort_override) {
|
||||
case 'created_by':
|
||||
$manufacturers = $manufacturers->OrderByCreatedBy($order);
|
||||
break;
|
||||
default:
|
||||
$manufacturers = $manufacturers->orderBy($column_sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
$total = $manufacturers->count();
|
||||
$manufacturers = $manufacturers->skip($offset)->take($limit)->get();
|
||||
@@ -181,7 +221,7 @@ class ManufacturersController extends Controller
|
||||
$logaction->item_type = Manufacturer::class;
|
||||
$logaction->item_id = $manufacturer->id;
|
||||
$logaction->created_at = date('Y-m-d H:i:s');
|
||||
$logaction->user_id = auth()->id();
|
||||
$logaction->created_by = auth()->id();
|
||||
$logaction->logaction('restore');
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('success', trans('admin/manufacturers/message.restore.success')), 200);
|
||||
|
||||
@@ -23,9 +23,8 @@ class PredefinedKitsController extends Controller
|
||||
public function index(Request $request) : JsonResponse | array
|
||||
{
|
||||
$this->authorize('view', PredefinedKit::class);
|
||||
$allowed_columns = ['id', 'name'];
|
||||
|
||||
$kits = PredefinedKit::query();
|
||||
$kits = PredefinedKit::query()->with('adminuser');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$kits = $kits->TextSearch($request->input('search'));
|
||||
@@ -36,8 +35,25 @@ class PredefinedKitsController extends Controller
|
||||
$limit = app('api_limit_value');
|
||||
|
||||
$order = $request->input('order') === 'desc' ? 'desc' : 'asc';
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'name';
|
||||
$kits->orderBy($sort, $order);
|
||||
|
||||
switch ($request->input('sort')) {
|
||||
case 'created_by':
|
||||
$kits = $kits->OrderByCreatedBy($order);
|
||||
break;
|
||||
default:
|
||||
// This array is what determines which fields should be allowed to be sorted on ON the table itself.
|
||||
// These must match a column on the consumables table directly.
|
||||
$allowed_columns = [
|
||||
'id',
|
||||
'name',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
|
||||
$kits = $kits->orderBy($sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
$total = $kits->count();
|
||||
$kits = $kits->skip($offset)->take($limit)->get();
|
||||
|
||||
@@ -20,7 +20,7 @@ class ReportsController extends Controller
|
||||
{
|
||||
$this->authorize('reports.view');
|
||||
|
||||
$actionlogs = Actionlog::with('item', 'user', 'admin', 'target', 'location');
|
||||
$actionlogs = Actionlog::with('item', 'user', 'adminuser', 'target', 'location');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$actionlogs = $actionlogs->TextSearch(e($request->input('search')));
|
||||
@@ -48,8 +48,8 @@ class ReportsController extends Controller
|
||||
$actionlogs = $actionlogs->where('action_type', '=', $request->input('action_type'))->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
if ($request->filled('user_id')) {
|
||||
$actionlogs = $actionlogs->where('user_id', '=', $request->input('user_id'));
|
||||
if ($request->filled('created_by')) {
|
||||
$actionlogs = $actionlogs->where('created_by', '=', $request->input('created_by'));
|
||||
}
|
||||
|
||||
if ($request->filled('action_source')) {
|
||||
@@ -68,13 +68,14 @@ class ReportsController extends Controller
|
||||
'id',
|
||||
'created_at',
|
||||
'target_id',
|
||||
'user_id',
|
||||
'created_by',
|
||||
'accept_signature',
|
||||
'action_type',
|
||||
'note',
|
||||
'remote_ip',
|
||||
'user_agent',
|
||||
'action_source',
|
||||
'action_date',
|
||||
];
|
||||
|
||||
|
||||
@@ -86,8 +87,8 @@ class ReportsController extends Controller
|
||||
$order = ($request->input('order') == 'asc') ? 'asc' : 'desc';
|
||||
|
||||
switch ($request->input('sort')) {
|
||||
case 'admin':
|
||||
$actionlogs->OrderAdmin($order);
|
||||
case 'created_by':
|
||||
$actionlogs->OrderByCreatedBy($order);
|
||||
break;
|
||||
default:
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
|
||||
|
||||
@@ -25,9 +25,18 @@ class StatuslabelsController extends Controller
|
||||
public function index(Request $request) : array
|
||||
{
|
||||
$this->authorize('view', Statuslabel::class);
|
||||
$allowed_columns = ['id', 'name', 'created_at', 'assets_count', 'color', 'notes', 'default_label'];
|
||||
$allowed_columns = [
|
||||
'id',
|
||||
'name',
|
||||
'created_at',
|
||||
'assets_count',
|
||||
'color',
|
||||
'notes',
|
||||
'default_label',
|
||||
'status_type',
|
||||
];
|
||||
|
||||
$statuslabels = Statuslabel::withCount('assets as assets_count');
|
||||
$statuslabels = Statuslabel::with('adminuser')->withCount('assets as assets_count');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$statuslabels = $statuslabels->TextSearch($request->input('search'));
|
||||
@@ -41,23 +50,30 @@ class StatuslabelsController extends Controller
|
||||
// if a status_type is passed, filter by that
|
||||
if ($request->filled('status_type')) {
|
||||
if (strtolower($request->input('status_type')) == 'pending') {
|
||||
$statuslabels = $statuslabels->Pending();
|
||||
} elseif (strtolower($request->input('status_type')) == 'archived') {
|
||||
$statuslabels = $statuslabels->Archived();
|
||||
} elseif (strtolower($request->input('status_type')) == 'deployable') {
|
||||
$statuslabels = $statuslabels->Deployable();
|
||||
$statuslabels->where('status_type', '=', 'pending');
|
||||
} elseif (strtolower($request->input('status_type')) == 'archived') $statuslabels->where('status_type', '=', 'archived');
|
||||
elseif (strtolower($request->input('status_type')) == 'deployable') {
|
||||
$statuslabels->where('status_type', '=', 'deployable');
|
||||
} elseif (strtolower($request->input('status_type')) == 'undeployable') {
|
||||
$statuslabels = $statuslabels->Undeployable();
|
||||
$statuslabels->whereNot('status_type', 'deployable');
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the offset and limit are actually integers and do not exceed system limits
|
||||
$offset = ($request->input('offset') > $statuslabels->count()) ? $statuslabels->count() : app('api_offset_value');
|
||||
$limit = app('api_limit_value');
|
||||
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
|
||||
$statuslabels->orderBy($sort, $order);
|
||||
$sort_override = $request->input('sort');
|
||||
$column_sort = in_array($sort_override, $allowed_columns) ? $sort_override : 'created_at';
|
||||
|
||||
switch ($sort_override) {
|
||||
case 'created_by':
|
||||
$statuslabels = $statuslabels->OrderByCreatedBy($order);
|
||||
break;
|
||||
default:
|
||||
$statuslabels = $statuslabels->orderBy($column_sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
$total = $statuslabels->count();
|
||||
$statuslabels = $statuslabels->skip($offset)->take($limit)->get();
|
||||
@@ -76,19 +92,11 @@ class StatuslabelsController extends Controller
|
||||
public function store(Request $request) : JsonResponse
|
||||
{
|
||||
$this->authorize('create', Statuslabel::class);
|
||||
$request->except('deployable', 'pending', 'archived');
|
||||
|
||||
if (! $request->filled('type')) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, ['type' => ['Status label type is required.']]), 500);
|
||||
}
|
||||
|
||||
$statuslabel = new Statuslabel;
|
||||
$statuslabel->fill($request->all());
|
||||
|
||||
$statusType = Statuslabel::getStatuslabelTypesForDB($request->input('type'));
|
||||
$statuslabel->deployable = $statusType['deployable'];
|
||||
$statuslabel->pending = $statusType['pending'];
|
||||
$statuslabel->archived = $statusType['archived'];
|
||||
$statuslabel->status_type = $request->input('status_type');
|
||||
$statuslabel->color = $request->input('color');
|
||||
$statuslabel->show_in_nav = $request->input('show_in_nav', 0);
|
||||
$statuslabel->default_label = $request->input('default_label', 0);
|
||||
@@ -129,20 +137,12 @@ class StatuslabelsController extends Controller
|
||||
{
|
||||
$this->authorize('update', Statuslabel::class);
|
||||
$statuslabel = Statuslabel::findOrFail($id);
|
||||
|
||||
$request->except('deployable', 'pending', 'archived');
|
||||
|
||||
|
||||
if (! $request->filled('type')) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, 'Status label type is required.'));
|
||||
}
|
||||
|
||||
$statuslabel->fill($request->all());
|
||||
|
||||
$statusType = Statuslabel::getStatuslabelTypesForDB($request->input('type'));
|
||||
$statuslabel->deployable = $statusType['deployable'];
|
||||
$statuslabel->pending = $statusType['pending'];
|
||||
$statuslabel->archived = $statusType['archived'];
|
||||
$statuslabel->status_type = $request->input('status_type');
|
||||
$statuslabel->color = $request->input('color');
|
||||
$statuslabel->show_in_nav = $request->input('show_in_nav', 0);
|
||||
$statuslabel->default_label = $request->input('default_label', 0);
|
||||
@@ -190,7 +190,7 @@ class StatuslabelsController extends Controller
|
||||
$this->authorize('view', Statuslabel::class);
|
||||
|
||||
if (Setting::getSettings()->show_archived_in_list == 0 ) {
|
||||
$statuslabels = Statuslabel::withCount('assets')->where('archived','0')->get();
|
||||
$statuslabels = Statuslabel::withCount('assets')->whereNot('status_type','archived')->get();
|
||||
} else {
|
||||
$statuslabels = Statuslabel::withCount('assets')->get();
|
||||
}
|
||||
@@ -284,7 +284,7 @@ class StatuslabelsController extends Controller
|
||||
public function checkIfDeployable($id) : string
|
||||
{
|
||||
$statuslabel = Statuslabel::findOrFail($id);
|
||||
if ($statuslabel->getStatuslabelType() == 'deployable') {
|
||||
if ($statuslabel->status_type == 'deployable') {
|
||||
return '1';
|
||||
}
|
||||
|
||||
@@ -302,22 +302,22 @@ class StatuslabelsController extends Controller
|
||||
{
|
||||
|
||||
$this->authorize('view.selectlists');
|
||||
$statuslabels = Statuslabel::orderBy('default_label', 'desc')->orderBy('name', 'asc')->orderBy('deployable', 'desc');
|
||||
$statuslabels = Statuslabel::orderBy('default_label', 'desc')->orderBy('name', 'asc')->orderBy('status_type', 'desc');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$statuslabels = $statuslabels->where('name', 'LIKE', '%'.$request->get('search').'%');
|
||||
}
|
||||
|
||||
if ($request->filled('deployable')) {
|
||||
$statuslabels = $statuslabels->where('deployable', '=', '1');
|
||||
$statuslabels = $statuslabels->where('status_type', '=', 'deployable');
|
||||
}
|
||||
|
||||
if ($request->filled('pending')) {
|
||||
$statuslabels = $statuslabels->where('pending', '=', '1');
|
||||
$statuslabels = $statuslabels->where('status_type', '=', 'pending');
|
||||
}
|
||||
|
||||
if ($request->filled('archived')) {
|
||||
$statuslabels = $statuslabels->where('archived', '=', '1');
|
||||
$statuslabels = $statuslabels->where('status_type', '=', 'archived');
|
||||
}
|
||||
|
||||
$statuslabels = $statuslabels->orderBy('name', 'ASC')->paginate(50);
|
||||
|
||||
@@ -14,6 +14,7 @@ use App\Http\Transformers\UsersTransformer;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Company;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\License;
|
||||
use App\Models\User;
|
||||
@@ -42,13 +43,14 @@ class UsersController extends Controller
|
||||
|
||||
$users = User::select([
|
||||
'users.activated',
|
||||
'users.created_by',
|
||||
'users.address',
|
||||
'users.avatar',
|
||||
'users.city',
|
||||
'users.company_id',
|
||||
'users.country',
|
||||
'users.created_by',
|
||||
'users.created_at',
|
||||
'users.updated_at',
|
||||
'users.deleted_at',
|
||||
'users.department_id',
|
||||
'users.email',
|
||||
@@ -67,7 +69,6 @@ class UsersController extends Controller
|
||||
'users.state',
|
||||
'users.two_factor_enrolled',
|
||||
'users.two_factor_optin',
|
||||
'users.updated_at',
|
||||
'users.username',
|
||||
'users.zip',
|
||||
'users.remote',
|
||||
@@ -206,6 +207,10 @@ class UsersController extends Controller
|
||||
$users->where('autoassign_licenses', '=', $request->input('autoassign_licenses'));
|
||||
}
|
||||
|
||||
if ($request->filled('locale')) {
|
||||
$users = $users->where('users.locale', '=', $request->input('locale'));
|
||||
}
|
||||
|
||||
|
||||
if (($request->filled('deleted')) && ($request->input('deleted') == 'true')) {
|
||||
$users = $users->onlyTrashed();
|
||||
@@ -251,6 +256,7 @@ class UsersController extends Controller
|
||||
'groups',
|
||||
'activated',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'two_factor_enrolled',
|
||||
'two_factor_optin',
|
||||
'last_login',
|
||||
@@ -276,6 +282,7 @@ class UsersController extends Controller
|
||||
'end_date',
|
||||
'autoassign_licenses',
|
||||
'website',
|
||||
'locale',
|
||||
];
|
||||
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'first_name';
|
||||
@@ -365,6 +372,7 @@ class UsersController extends Controller
|
||||
|
||||
$user = new User;
|
||||
$user->fill($request->all());
|
||||
$user->company_id = Company::getIdForCurrentUser($request->input('company_id'));
|
||||
$user->created_by = auth()->id();
|
||||
|
||||
if ($request->has('permissions')) {
|
||||
@@ -446,6 +454,10 @@ class UsersController extends Controller
|
||||
|
||||
$user->fill($request->all());
|
||||
|
||||
if ($request->filled('company_id')) {
|
||||
$user->company_id = Company::getIdForCurrentUser($request->input('company_id'));
|
||||
}
|
||||
|
||||
if ($user->id == $request->input('manager_id')) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, 'You cannot be your own manager'));
|
||||
}
|
||||
@@ -686,7 +698,7 @@ class UsersController extends Controller
|
||||
$logaction->item_type = User::class;
|
||||
$logaction->item_id = $user->id;
|
||||
$logaction->created_at = date('Y-m-d H:i:s');
|
||||
$logaction->user_id = auth()->id();
|
||||
$logaction->created_by = auth()->id();
|
||||
$logaction->logaction('2FA reset');
|
||||
|
||||
return response()->json(['message' => trans('admin/settings/general.two_factor_reset_success')], 200);
|
||||
@@ -736,7 +748,7 @@ class UsersController extends Controller
|
||||
$logaction->item_type = User::class;
|
||||
$logaction->item_id = $user->id;
|
||||
$logaction->created_at = date('Y-m-d H:i:s');
|
||||
$logaction->user_id = auth()->id();
|
||||
$logaction->created_by = auth()->id();
|
||||
$logaction->logaction('restore');
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/users/message.success.restored')), 200);
|
||||
|
||||
@@ -109,7 +109,7 @@ class AssetMaintenancesController extends Controller
|
||||
$assetMaintenance->title = $request->input('title');
|
||||
$assetMaintenance->start_date = $request->input('start_date');
|
||||
$assetMaintenance->completion_date = $request->input('completion_date');
|
||||
$assetMaintenance->user_id = Auth::id();
|
||||
$assetMaintenance->created_by = auth()->id();
|
||||
|
||||
if (($assetMaintenance->completion_date !== null)
|
||||
&& ($assetMaintenance->start_date !== '')
|
||||
|
||||
@@ -78,7 +78,7 @@ class AssetModelsController extends Controller
|
||||
$model->manufacturer_id = $request->input('manufacturer_id');
|
||||
$model->category_id = $request->input('category_id');
|
||||
$model->notes = $request->input('notes');
|
||||
$model->user_id = Auth::id();
|
||||
$model->created_by = auth()->id();
|
||||
$model->requestable = $request->has('requestable');
|
||||
|
||||
if ($request->input('fieldset_id') != '') {
|
||||
@@ -237,7 +237,7 @@ class AssetModelsController extends Controller
|
||||
$logaction->item_type = AssetModel::class;
|
||||
$logaction->item_id = $model->id;
|
||||
$logaction->created_at = date('Y-m-d H:i:s');
|
||||
$logaction->user_id = auth()->id();
|
||||
$logaction->created_by = auth()->id();
|
||||
$logaction->logaction('restore');
|
||||
|
||||
|
||||
|
||||
@@ -61,43 +61,30 @@ class AssetFilesController extends Controller
|
||||
*/
|
||||
public function show($assetId = null, $fileId = null) : View | RedirectResponse | Response | StreamedResponse | BinaryFileResponse
|
||||
{
|
||||
$asset = Asset::find($assetId);
|
||||
// the asset is valid
|
||||
if (isset($asset->id)) {
|
||||
if ($asset = Asset::find($assetId)) {
|
||||
|
||||
$this->authorize('view', $asset);
|
||||
|
||||
if (! $log = Actionlog::whereNotNull('filename')->where('item_id', $asset->id)->find($fileId)) {
|
||||
return response('No matching record for that asset/file', 500)
|
||||
->header('Content-Type', 'text/plain');
|
||||
if ($log = Actionlog::whereNotNull('filename')->where('item_id', $asset->id)->find($fileId)) {
|
||||
$file = 'private_uploads/assets/'.$log->filename;
|
||||
|
||||
if ($log->action_type == 'audit') {
|
||||
$file = 'private_uploads/audits/'.$log->filename;
|
||||
}
|
||||
|
||||
try {
|
||||
return StorageHelper::showOrDownloadFile($file, $log->filename);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->route('hardware.show', ['hardware' => $asset])->with('error', trans('general.file_not_found'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$file = 'private_uploads/assets/'.$log->filename;
|
||||
|
||||
if ($log->action_type == 'audit') {
|
||||
$file = 'private_uploads/audits/'.$log->filename;
|
||||
}
|
||||
|
||||
if (! Storage::exists($file)) {
|
||||
return response('File '.$file.' not found on server', 404)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
|
||||
if (request('inline') == 'true') {
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'inline',
|
||||
];
|
||||
|
||||
return Storage::download($file, $log->filename, $headers);
|
||||
}
|
||||
|
||||
return StorageHelper::downloader($file);
|
||||
return redirect()->route('hardware.show', ['hardware' => $asset])->with('error', trans('general.log_record_not_found'));
|
||||
}
|
||||
// Prepare the error message
|
||||
$error = trans('admin/hardware/message.does_not_exist', ['id' => $fileId]);
|
||||
|
||||
// Redirect to the hardware management page
|
||||
return redirect()->route('hardware.index')->with('error', $error);
|
||||
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Assets;
|
||||
|
||||
use App\Events\CheckoutableCheckedIn;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ImageUploadRequest;
|
||||
@@ -16,7 +17,6 @@ use App\Models\Location;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\View\Label;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -111,8 +111,10 @@ class AssetsController extends Controller
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
$success = false;
|
||||
$successes = [];
|
||||
$failures = [];
|
||||
$serials = $request->input('serials');
|
||||
$asset = null;
|
||||
|
||||
for ($a = 1; $a <= count($asset_tags); $a++) {
|
||||
$asset = new Asset();
|
||||
@@ -132,7 +134,7 @@ class AssetsController extends Controller
|
||||
$asset->model_id = $request->input('model_id');
|
||||
$asset->order_number = $request->input('order_number');
|
||||
$asset->notes = $request->input('notes');
|
||||
$asset->user_id = Auth::id();
|
||||
$asset->created_by = auth()->id();
|
||||
$asset->status_id = request('status_id');
|
||||
$asset->warranty_months = request('warranty_months', null);
|
||||
$asset->purchase_cost = request('purchase_cost');
|
||||
@@ -199,20 +201,35 @@ class AssetsController extends Controller
|
||||
$asset->checkOut($target, auth()->user(), date('Y-m-d H:i:s'), $request->input('expected_checkin', null), 'Checked out on asset creation', $request->get('name'), $location);
|
||||
}
|
||||
|
||||
$success = true;
|
||||
|
||||
$successes[] = "<a href='" . route('hardware.show', ['hardware' => $asset->id]) . "' style='color: white;'>" . e($asset->asset_tag) . "</a>";
|
||||
|
||||
} else {
|
||||
$failures[] = join(",", $asset->getErrors()->all());
|
||||
}
|
||||
}
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
|
||||
|
||||
|
||||
if ($success) {
|
||||
if ($successes) {
|
||||
if ($failures) {
|
||||
//some succeeded, some failed
|
||||
return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets')) //FIXME - not tested
|
||||
->with('success-unescaped', trans_choice('admin/hardware/message.create.multi_success_linked', $successes, ['links' => join(", ", $successes)]))
|
||||
->with('warning', trans_choice('admin/hardware/message.create.partial_failure', $failures, ['failures' => join("; ", $failures)]));
|
||||
} else {
|
||||
if (count($successes) == 1) {
|
||||
//the most common case, keeping it so we don't have to make every use of that translation string be trans_choice'ed
|
||||
//and re-translated
|
||||
return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets'))
|
||||
->with('success-unescaped', trans('admin/hardware/message.create.success_linked', ['link' => route('hardware.show', ['hardware' => $asset->id]), 'id', 'tag' => e($asset->asset_tag)]));
|
||||
} else {
|
||||
//multi-success
|
||||
return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets'))
|
||||
->with('success-unescaped', trans_choice('admin/hardware/message.create.multi_success_linked', $successes, ['links' => join(", ", $successes)]));
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets'))
|
||||
->with('success-unescaped', trans('admin/hardware/message.create.success_linked', ['link' => route('hardware.show', ['hardware' => $asset->id]), 'id', 'tag' => e($asset->asset_tag)]));
|
||||
|
||||
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($asset->getErrors());
|
||||
@@ -328,16 +345,21 @@ class AssetsController extends Controller
|
||||
}
|
||||
$asset->supplier_id = $request->input('supplier_id', null);
|
||||
$asset->expected_checkin = $request->input('expected_checkin', null);
|
||||
|
||||
// If the box isn't checked, it's not in the request at all.
|
||||
$asset->requestable = $request->filled('requestable');
|
||||
$asset->requestable = $request->input('requestable', 0);
|
||||
$asset->rtd_location_id = $request->input('rtd_location_id', null);
|
||||
$asset->byod = $request->input('byod', 0);
|
||||
|
||||
$status = Statuslabel::find($asset->status_id);
|
||||
$status = Statuslabel::find($request->input('status_id'));
|
||||
|
||||
if ($status && $status->archived) {
|
||||
// This is a non-deployable status label - we should check the asset back in.
|
||||
if (($status && $status->status_type != 'deployable') && ($target = $asset->assignedTo)) {
|
||||
|
||||
$originalValues = $asset->getRawOriginal();
|
||||
$asset->assigned_to = null;
|
||||
$asset->assigned_type = null;
|
||||
$asset->accepted = null;
|
||||
|
||||
event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on asset update', date('Y-m-d H:i:s'), $originalValues));
|
||||
}
|
||||
|
||||
if ($asset->assigned_to == '') {
|
||||
@@ -422,7 +444,7 @@ class AssetsController extends Controller
|
||||
* @param int $assetId
|
||||
* @since [v1.0]
|
||||
*/
|
||||
public function destroy($assetId) : RedirectResponse
|
||||
public function destroy(Request $request, $assetId) : RedirectResponse
|
||||
{
|
||||
// Check if the asset exists
|
||||
if (is_null($asset = Asset::find($assetId))) {
|
||||
@@ -432,9 +454,17 @@ class AssetsController extends Controller
|
||||
|
||||
$this->authorize('delete', $asset);
|
||||
|
||||
DB::table('assets')
|
||||
->where('id', $asset->id)
|
||||
->update(['assigned_to' => null]);
|
||||
if ($asset->assignedTo) {
|
||||
|
||||
$target = $asset->assignedTo;
|
||||
$checkin_at = date('Y-m-d H:i:s');
|
||||
$originalValues = $asset->getRawOriginal();
|
||||
event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on delete', $checkin_at, $originalValues));
|
||||
DB::table('assets')
|
||||
->where('id', $asset->id)
|
||||
->update(['assigned_to' => null]);
|
||||
}
|
||||
|
||||
|
||||
if ($asset->image) {
|
||||
try {
|
||||
@@ -739,7 +769,7 @@ class AssetsController extends Controller
|
||||
Actionlog::firstOrCreate([
|
||||
'item_id' => $asset->id,
|
||||
'item_type' => Asset::class,
|
||||
'user_id' => auth()->id(),
|
||||
'created_by' => auth()->id(),
|
||||
'note' => 'Checkout imported by '.auth()->user()->present()->fullName().' from history importer',
|
||||
'target_id' => $item[$asset_tag][$batch_counter]['user_id'],
|
||||
'target_type' => User::class,
|
||||
@@ -767,7 +797,7 @@ class AssetsController extends Controller
|
||||
Actionlog::firstOrCreate([
|
||||
'item_id' => $item[$asset_tag][$batch_counter]['asset_id'],
|
||||
'item_type' => Asset::class,
|
||||
'user_id' => auth()->id(),
|
||||
'created_by' => auth()->id(),
|
||||
'note' => 'Checkin imported by '.auth()->user()->present()->fullName().' from history importer',
|
||||
'target_id' => null,
|
||||
'created_at' => $checkin_date,
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Models\AssetModel;
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\Setting;
|
||||
use App\View\Label;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -51,6 +52,10 @@ class BulkAssetsController extends Controller
|
||||
}
|
||||
|
||||
$asset_ids = $request->input('ids');
|
||||
if ($request->input('bulk_actions') === 'checkout') {
|
||||
$request->session()->flashInput(['selected_assets' => $asset_ids]);
|
||||
return redirect()->route('hardware.bulkcheckout.show');
|
||||
}
|
||||
|
||||
// Figure out where we need to send the user after the update is complete, and store that in the session
|
||||
$bulk_back_url = request()->headers->get('referer');
|
||||
@@ -271,6 +276,23 @@ class BulkAssetsController extends Controller
|
||||
$this->conditionallyAddItem($custom_field_column);
|
||||
}
|
||||
|
||||
if (!($asset->eol_explicit)) {
|
||||
if ($request->filled('model_id')) {
|
||||
$model = AssetModel::find($request->input('model_id'));
|
||||
if ($model->eol > 0) {
|
||||
if ($request->filled('purchase_date')) {
|
||||
$this->update_array['asset_eol_date'] = Carbon::parse($request->input('purchase_date'))->addMonths($model->eol)->format('Y-m-d');
|
||||
} else {
|
||||
$this->update_array['asset_eol_date'] = Carbon::parse($asset->purchase_date)->addMonths($model->eol)->format('Y-m-d');
|
||||
}
|
||||
} else {
|
||||
$this->update_array['asset_eol_date'] = null;
|
||||
}
|
||||
} elseif (($request->filled('purchase_date')) && ($asset->model->eol > 0)) {
|
||||
$this->update_array['asset_eol_date'] = Carbon::parse($request->input('purchase_date'))->addMonths($asset->model->eol)->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Blank out fields that were requested to be blanked out via checkbox
|
||||
*/
|
||||
@@ -281,6 +303,9 @@ class BulkAssetsController extends Controller
|
||||
|
||||
if ($request->input('null_purchase_date')=='1') {
|
||||
$this->update_array['purchase_date'] = null;
|
||||
if (!($asset->eol_explicit)) {
|
||||
$this->update_array['asset_eol_date'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->input('null_expected_checkin_date')=='1') {
|
||||
@@ -550,31 +575,34 @@ class BulkAssetsController extends Controller
|
||||
}
|
||||
|
||||
$errors = [];
|
||||
DB::transaction(function () use ($target, $admin, $checkout_at, $expected_checkin, $errors, $asset_ids, $request) {
|
||||
DB::transaction(function () use ($target, $admin, $checkout_at, $expected_checkin, &$errors, $asset_ids, $request) { //NOTE: $errors is passsed by reference!
|
||||
foreach ($asset_ids as $asset_id) {
|
||||
$asset = Asset::findOrFail($asset_id);
|
||||
$this->authorize('checkout', $asset);
|
||||
|
||||
$error = $asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e($request->get('note')), $asset->name, null);
|
||||
$checkout_success = $asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e($request->get('note')), $asset->name, null);
|
||||
|
||||
//TODO - I think this logic is duplicated in the checkOut method?
|
||||
if ($target->location_id != '') {
|
||||
$asset->location_id = $target->location_id;
|
||||
$asset->unsetEventDispatcher();
|
||||
$asset->save();
|
||||
// TODO - I don't know why this is being saved without events
|
||||
$asset::withoutEvents(function () use ($asset) {
|
||||
$asset->save();
|
||||
});
|
||||
}
|
||||
|
||||
if ($error) {
|
||||
array_merge_recursive($errors, $asset->getErrors()->toArray());
|
||||
if (!$checkout_success) {
|
||||
$errors = array_merge_recursive($errors, $asset->getErrors()->toArray());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (! $errors) {
|
||||
// Redirect to the new asset page
|
||||
return redirect()->to('hardware')->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
return redirect()->to('hardware')->with('success', trans_choice('admin/hardware/message.multi-checkout.success', $asset_ids));
|
||||
}
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->route('hardware.bulkcheckout.show')->with('error', trans('admin/hardware/message.checkout.error'))->withErrors($errors);
|
||||
return redirect()->route('hardware.bulkcheckout.show')->withInput()->with('error', trans_choice('admin/hardware/message.multi-checkout.error', $asset_ids))->withErrors($errors);
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return redirect()->route('hardware.bulkcheckout.show')->with('error', $e->getErrors());
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ class CategoriesController extends Controller
|
||||
$category->use_default_eula = $request->input('use_default_eula', '0');
|
||||
$category->require_acceptance = $request->input('require_acceptance', '0');
|
||||
$category->checkin_email = $request->input('checkin_email', '0');
|
||||
$category->user_id = Auth::id();
|
||||
$category->created_by = auth()->id();
|
||||
|
||||
$category = $request->handleImages($category);
|
||||
if ($category->save()) {
|
||||
|
||||
@@ -60,6 +60,7 @@ final class CompaniesController extends Controller
|
||||
$company->phone = $request->input('phone');
|
||||
$company->fax = $request->input('fax');
|
||||
$company->email = $request->input('email');
|
||||
$company->created_by = auth()->id();
|
||||
|
||||
$company = $request->handleImages($company);
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ class ComponentCheckoutController extends Controller
|
||||
$component->asset_id = $request->input('asset_id');
|
||||
$component->assets()->attach($component->id, [
|
||||
'component_id' => $component->id,
|
||||
'user_id' => auth()->user()->id,
|
||||
'created_by' => auth()->user()->id,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'assigned_qty' => $request->input('assigned_qty'),
|
||||
'asset_id' => $request->input('asset_id'),
|
||||
|
||||
@@ -73,6 +73,8 @@ class ComponentsController extends Controller
|
||||
$component->name = $request->input('name');
|
||||
$component->category_id = $request->input('category_id');
|
||||
$component->supplier_id = $request->input('supplier_id');
|
||||
$component->manufacturer_id = $request->input('manufacturer_id');
|
||||
$component->model_number = $request->input('model_number');
|
||||
$component->location_id = $request->input('location_id');
|
||||
$component->company_id = Company::getIdForCurrentUser($request->input('company_id'));
|
||||
$component->order_number = $request->input('order_number', null);
|
||||
@@ -81,7 +83,7 @@ class ComponentsController extends Controller
|
||||
$component->purchase_date = $request->input('purchase_date', null);
|
||||
$component->purchase_cost = $request->input('purchase_cost', null);
|
||||
$component->qty = $request->input('qty');
|
||||
$component->user_id = Auth::id();
|
||||
$component->created_by = auth()->id();
|
||||
$component->notes = $request->input('notes');
|
||||
|
||||
$component = $request->handleImages($component);
|
||||
@@ -150,6 +152,8 @@ class ComponentsController extends Controller
|
||||
$component->name = $request->input('name');
|
||||
$component->category_id = $request->input('category_id');
|
||||
$component->supplier_id = $request->input('supplier_id');
|
||||
$component->manufacturer_id = $request->input('manufacturer_id');
|
||||
$component->model_number = $request->input('model_number');
|
||||
$component->location_id = $request->input('location_id');
|
||||
$component->company_id = Company::getIdForCurrentUser($request->input('company_id'));
|
||||
$component->order_number = $request->input('order_number');
|
||||
|
||||
@@ -112,40 +112,25 @@ class ComponentsFilesController extends Controller
|
||||
public function show($componentId = null, $fileId = null)
|
||||
{
|
||||
Log::debug('Private filesystem is: '.config('filesystems.default'));
|
||||
$component = Component::find($componentId);
|
||||
|
||||
|
||||
// the component is valid
|
||||
if (isset($component->id)) {
|
||||
if ($component = Component::find($componentId)) {
|
||||
$this->authorize('view', $component);
|
||||
$this->authorize('components.files', $component);
|
||||
|
||||
if (! $log = Actionlog::whereNotNull('filename')->where('item_id', $component->id)->find($fileId)) {
|
||||
return response('No matching record for that asset/file', 500)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
if ($log = Actionlog::whereNotNull('filename')->where('item_id', $component->id)->find($fileId)) {
|
||||
|
||||
$file = 'private_uploads/components/'.$log->filename;
|
||||
$file = 'private_uploads/components/'.$log->filename;
|
||||
|
||||
if (Storage::missing($file)) {
|
||||
Log::debug('FILE DOES NOT EXISTS for '.$file);
|
||||
Log::debug('URL should be '.Storage::url($file));
|
||||
|
||||
return response('File '.$file.' ('.Storage::url($file).') not found on server', 404)
|
||||
->header('Content-Type', 'text/plain');
|
||||
} else {
|
||||
|
||||
// Display the file inline
|
||||
if (request('inline') == 'true') {
|
||||
$headers = [
|
||||
'Content-Disposition' => 'inline',
|
||||
];
|
||||
return Storage::download($file, $log->filename, $headers);
|
||||
try {
|
||||
return StorageHelper::showOrDownloadFile($file, $log->filename);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->route('components.show', ['component' => $component])->with('error', trans('general.file_not_found'));
|
||||
}
|
||||
|
||||
if (config('filesystems.default') == 'local') { // TODO - is there any way to fix this at the StorageHelper layer?
|
||||
return StorageHelper::downloader($file);
|
||||
}
|
||||
}
|
||||
return redirect()->route('components.show', ['component' => $component])->with('error', trans('general.log_record_not_found'));
|
||||
|
||||
}
|
||||
|
||||
return redirect()->route('components.index')->with('error', trans('general.file_does_not_exist', ['id' => $fileId]));
|
||||
|
||||
@@ -70,7 +70,7 @@ class ConsumableCheckoutController extends Controller
|
||||
$this->authorize('checkout', $consumable);
|
||||
|
||||
// If the quantity is not present in the request or is not a positive integer, set it to 1
|
||||
$quantity = $request->input('qty');
|
||||
$quantity = $request->input('checkout_qty');
|
||||
if (!isset($quantity) || !ctype_digit((string)$quantity) || $quantity <= 0) {
|
||||
$quantity = 1;
|
||||
}
|
||||
@@ -92,14 +92,16 @@ class ConsumableCheckoutController extends Controller
|
||||
// Update the consumable data
|
||||
$consumable->assigned_to = e($request->input('assigned_to'));
|
||||
|
||||
for($i = 0; $i < $quantity; $i++){
|
||||
for ($i = 0; $i < $quantity; $i++){
|
||||
$consumable->users()->attach($consumable->id, [
|
||||
'consumable_id' => $consumable->id,
|
||||
'user_id' => $admin_user->id,
|
||||
'created_by' => $admin_user->id,
|
||||
'assigned_to' => e($request->input('assigned_to')),
|
||||
'note' => $request->input('note'),
|
||||
]);
|
||||
}
|
||||
|
||||
$consumable->checkout_qty = $quantity;
|
||||
event(new CheckoutableCheckedOut($consumable, $user, auth()->user(), $request->input('note')));
|
||||
|
||||
$request->request->add(['checkout_to_type' => 'user']);
|
||||
|
||||
@@ -81,7 +81,7 @@ class ConsumablesController extends Controller
|
||||
$consumable->purchase_date = $request->input('purchase_date');
|
||||
$consumable->purchase_cost = $request->input('purchase_cost');
|
||||
$consumable->qty = $request->input('qty');
|
||||
$consumable->user_id = Auth::id();
|
||||
$consumable->created_by = auth()->id();
|
||||
$consumable->notes = $request->input('notes');
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ class ConsumablesController extends Controller
|
||||
$consumable = clone $consumable_to_close;
|
||||
$consumable->id = null;
|
||||
$consumable->image = null;
|
||||
$consumable->user_id = null;
|
||||
$consumable->created_by = null;
|
||||
|
||||
return view('consumables/edit')->with('item', $consumable);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,6 @@ class ConsumablesFilesController extends Controller
|
||||
* @since [v1.4]
|
||||
* @param int $consumableId
|
||||
* @param int $fileId
|
||||
* @return \Symfony\Consumable\HttpFoundation\Response
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function show($consumableId = null, $fileId = null)
|
||||
@@ -116,36 +115,18 @@ class ConsumablesFilesController extends Controller
|
||||
$this->authorize('view', $consumable);
|
||||
$this->authorize('consumables.files', $consumable);
|
||||
|
||||
if (! $log = Actionlog::whereNotNull('filename')->where('item_id', $consumable->id)->find($fileId)) {
|
||||
return response('No matching record for that asset/file', 500)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
if ($log = Actionlog::whereNotNull('filename')->where('item_id', $consumable->id)->find($fileId)) {
|
||||
$file = 'private_uploads/consumables/'.$log->filename;
|
||||
|
||||
$file = 'private_uploads/consumables/'.$log->filename;
|
||||
|
||||
if (Storage::missing($file)) {
|
||||
Log::debug('FILE DOES NOT EXISTS for '.$file);
|
||||
Log::debug('URL should be '.Storage::url($file));
|
||||
|
||||
return response('File '.$file.' ('.Storage::url($file).') not found on server', 404)
|
||||
->header('Content-Type', 'text/plain');
|
||||
} else {
|
||||
|
||||
// Display the file inline
|
||||
if (request('inline') == 'true') {
|
||||
$headers = [
|
||||
'Content-Disposition' => 'inline',
|
||||
];
|
||||
return Storage::download($file, $log->filename, $headers);
|
||||
}
|
||||
|
||||
|
||||
// We have to override the URL stuff here, since local defaults in Laravel's Flysystem
|
||||
// won't work, as they're not accessible via the web
|
||||
if (config('filesystems.default') == 'local') { // TODO - is there any way to fix this at the StorageHelper layer?
|
||||
return StorageHelper::downloader($file);
|
||||
try {
|
||||
return StorageHelper::showOrDownloadFile($file, $log->filename);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->route('consumables.show', ['consumable' => $consumable])->with('error', trans('general.file_not_found'));
|
||||
}
|
||||
}
|
||||
// The log record doesn't exist somehow
|
||||
return redirect()->route('consumables.show', ['consumable' => $consumable])->with('error', trans('general.log_record_not_found'));
|
||||
|
||||
}
|
||||
|
||||
return redirect()->route('consumables.index')->with('error', trans('general.file_does_not_exist', ['id' => $fileId]));
|
||||
|
||||
@@ -104,7 +104,7 @@ class CustomFieldsController extends Controller
|
||||
"auto_add_to_fieldsets" => $request->get("auto_add_to_fieldsets", 0),
|
||||
"show_in_listview" => $request->get("show_in_listview", 0),
|
||||
"show_in_requestable_list" => $request->get("show_in_requestable_list", 0),
|
||||
"user_id" => Auth::id()
|
||||
"user_id" => auth()->id()
|
||||
]);
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ class CustomFieldsController extends Controller
|
||||
$field->name = trim(e($request->get("name")));
|
||||
$field->element = e($request->get("element"));
|
||||
$field->field_values = $request->get("field_values");
|
||||
$field->user_id = Auth::id();
|
||||
$field->created_by = auth()->id();
|
||||
$field->help_text = $request->get("help_text");
|
||||
$field->show_in_email = $show_in_email;
|
||||
$field->is_unique = $request->get("is_unique", 0);
|
||||
|
||||
@@ -90,7 +90,7 @@ class CustomFieldsetsController extends Controller
|
||||
|
||||
$fieldset = new CustomFieldset([
|
||||
'name' => $request->get('name'),
|
||||
'user_id' => auth()->id(),
|
||||
'created_by' => auth()->id(),
|
||||
]);
|
||||
|
||||
$validator = Validator::make($request->all(), $fieldset->rules);
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use \Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
|
||||
/**
|
||||
@@ -44,6 +45,8 @@ class DashboardController extends Controller
|
||||
|
||||
return view('dashboard')->with('asset_stats', $asset_stats)->with('counts', $counts);
|
||||
} else {
|
||||
Session::reflash();
|
||||
|
||||
// Redirect to the profile page
|
||||
return redirect()->intended('account/view-assets');
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class DepartmentsController extends Controller
|
||||
$this->authorize('create', Department::class);
|
||||
$department = new Department;
|
||||
$department->fill($request->all());
|
||||
$department->user_id = auth()->id();
|
||||
$department->created_by = auth()->id();
|
||||
$department->manager_id = ($request->filled('manager_id') ? $request->input('manager_id') : null);
|
||||
$department->location_id = ($request->filled('location_id') ? $request->input('location_id') : null);
|
||||
$department->company_id = ($request->filled('company_id') ? $request->input('company_id') : null);
|
||||
|
||||
@@ -61,7 +61,7 @@ class DepreciationsController extends Controller
|
||||
// Depreciation data
|
||||
$depreciation->name = $request->input('name');
|
||||
$depreciation->months = $request->input('months');
|
||||
$depreciation->user_id = Auth::id();
|
||||
$depreciation->created_by = auth()->id();
|
||||
|
||||
$request->validate([
|
||||
'depreciation_min' => [
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* This controller provide the health route for
|
||||
@@ -15,13 +16,35 @@ use Illuminate\Routing\Controller as BaseController;
|
||||
*/
|
||||
class HealthController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('health');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a fixed JSON content ({ "status": "ok"}) which indicate the app is up and running
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ok',
|
||||
]);
|
||||
try {
|
||||
|
||||
if (DB::select('select 2 + 2')) {
|
||||
return response()->json([
|
||||
'status' => 'ok',
|
||||
]);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('Could not connect to database');
|
||||
return response()->json([
|
||||
'status' => 'database connection failed',
|
||||
], 500);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ class PredefinedKitsController extends Controller
|
||||
// Create a new Predefined Kit
|
||||
$kit = new PredefinedKit;
|
||||
$kit->name = $request->input('name');
|
||||
$kit->created_by = auth()->id();
|
||||
|
||||
if (! $kit->save()) {
|
||||
return redirect()->back()->withInput()->withErrors($kit->getErrors());
|
||||
|
||||
@@ -77,7 +77,7 @@ class LicenseCheckoutController extends Controller
|
||||
$this->authorize('checkout', $license);
|
||||
|
||||
$licenseSeat = $this->findLicenseSeatToCheckout($license, $seatId);
|
||||
$licenseSeat->user_id = Auth::id();
|
||||
$licenseSeat->created_by = auth()->id();
|
||||
$licenseSeat->notes = $request->input('notes');
|
||||
|
||||
|
||||
|
||||
@@ -112,37 +112,19 @@ class LicenseFilesController extends Controller
|
||||
$this->authorize('view', $license);
|
||||
$this->authorize('licenses.files', $license);
|
||||
|
||||
if (! $log = Actionlog::whereNotNull('filename')->where('item_id', $license->id)->find($fileId)) {
|
||||
return response('No matching record for that asset/file', 500)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
|
||||
$file = 'private_uploads/licenses/'.$log->filename;
|
||||
|
||||
if (Storage::missing($file)) {
|
||||
Log::debug('NOT EXISTS for '.$file);
|
||||
Log::debug('NOT EXISTS URL should be '.Storage::url($file));
|
||||
|
||||
return response('File '.$file.' ('.Storage::url($file).') not found on server', 404)
|
||||
->header('Content-Type', 'text/plain');
|
||||
} else {
|
||||
|
||||
if (request('inline') == 'true') {
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'inline',
|
||||
];
|
||||
|
||||
return Storage::download($file, $log->filename, $headers);
|
||||
}
|
||||
|
||||
// We have to override the URL stuff here, since local defaults in Laravel's Flysystem
|
||||
// won't work, as they're not accessible via the web
|
||||
if (config('filesystems.default') == 'local') { // TODO - is there any way to fix this at the StorageHelper layer?
|
||||
return StorageHelper::downloader($file);
|
||||
if ($log = Actionlog::whereNotNull('filename')->where('item_id', $license->id)->find($fileId)) {
|
||||
$file = 'private_uploads/licenses/'.$log->filename;
|
||||
|
||||
try {
|
||||
return StorageHelper::showOrDownloadFile($file, $log->filename);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->route('licenses.show', ['licenses' => $license])->with('error', trans('general.file_not_found'));
|
||||
}
|
||||
}
|
||||
|
||||
// The log record doesn't exist somehow
|
||||
return redirect()->route('licenses.show', ['licenses' => $license])->with('error', trans('general.log_record_not_found'));
|
||||
|
||||
}
|
||||
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.does_not_exist', ['id' => $fileId]));
|
||||
|
||||
@@ -99,7 +99,7 @@ class LicensesController extends Controller
|
||||
$license->supplier_id = $request->input('supplier_id');
|
||||
$license->category_id = $request->input('category_id');
|
||||
$license->termination_date = $request->input('termination_date');
|
||||
$license->user_id = Auth::id();
|
||||
$license->created_by = auth()->id();
|
||||
$license->min_amt = $request->input('min_amt');
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
|
||||
@@ -75,7 +75,7 @@ class LocationsController extends Controller
|
||||
$location->zip = $request->input('zip');
|
||||
$location->ldap_ou = $request->input('ldap_ou');
|
||||
$location->manager_id = $request->input('manager_id');
|
||||
$location->user_id = auth()->id();
|
||||
$location->created_by = auth()->id();
|
||||
$location->phone = request('phone');
|
||||
$location->fax = request('fax');
|
||||
|
||||
@@ -278,7 +278,7 @@ class LocationsController extends Controller
|
||||
$logaction->item_type = Location::class;
|
||||
$logaction->item_id = $location->id;
|
||||
$logaction->created_at = date('Y-m-d H:i:s');
|
||||
$logaction->user_id = auth()->id();
|
||||
$logaction->created_by = auth()->id();
|
||||
$logaction->logaction('restore');
|
||||
|
||||
return redirect()->route('locations.index')->with('success', trans('admin/locations/message.restore.success'));
|
||||
|
||||
@@ -61,7 +61,7 @@ class ManufacturersController extends Controller
|
||||
$this->authorize('create', Manufacturer::class);
|
||||
$manufacturer = new Manufacturer;
|
||||
$manufacturer->name = $request->input('name');
|
||||
$manufacturer->user_id = Auth::id();
|
||||
$manufacturer->created_by = auth()->id();
|
||||
$manufacturer->url = $request->input('url');
|
||||
$manufacturer->support_url = $request->input('support_url');
|
||||
$manufacturer->warranty_lookup_url = $request->input('warranty_lookup_url');
|
||||
@@ -219,7 +219,7 @@ class ManufacturersController extends Controller
|
||||
$logaction->item_type = Manufacturer::class;
|
||||
$logaction->item_id = $manufacturer->id;
|
||||
$logaction->created_at = date('Y-m-d H:i:s');
|
||||
$logaction->user_id = auth()->id();
|
||||
$logaction->created_by = auth()->id();
|
||||
$logaction->logaction('restore');
|
||||
|
||||
// Redirect them to the deleted page if there are more, otherwise the section index
|
||||
|
||||
@@ -40,7 +40,7 @@ class ModalController extends Controller
|
||||
$view = view("modals.${type}");
|
||||
|
||||
if ($type == "statuslabel") {
|
||||
$view->with('statuslabel_types', Helper::statusTypeList());
|
||||
$view->with('status_types', Helper::statusTypeList());
|
||||
}
|
||||
if (in_array($type, ['kit-model', 'kit-license', 'kit-consumable', 'kit-accessory'])) {
|
||||
$view->with('kitId', $itemId);
|
||||
|
||||
@@ -194,14 +194,14 @@ class ProfileController extends Controller
|
||||
*/
|
||||
public function printInventory() : View
|
||||
{
|
||||
$show_user = auth()->user();
|
||||
$show_users = User::where('id',auth()->user()->id)->get();
|
||||
|
||||
return view('users/print')
|
||||
->with('assets', auth()->user()->assets)
|
||||
->with('licenses', $show_user->licenses()->get())
|
||||
->with('accessories', $show_user->accessories()->get())
|
||||
->with('consumables', $show_user->consumables()->get())
|
||||
->with('show_user', $show_user)
|
||||
->with('assets', auth()->user()->assets())
|
||||
->with('licenses', auth()->user()->licenses()->get())
|
||||
->with('accessories', auth()->user()->accessories()->get())
|
||||
->with('consumables', auth()->user()->consumables()->get())
|
||||
->with('users', $show_users)
|
||||
->with('settings', Setting::getSettings());
|
||||
}
|
||||
|
||||
@@ -222,7 +222,12 @@ class ProfileController extends Controller
|
||||
return redirect()->back()->with('error', trans('admin/users/message.user_has_no_email'));
|
||||
}
|
||||
|
||||
$user->notify((new CurrentInventory($user)));
|
||||
try {
|
||||
$user->notify((new CurrentInventory($user)));
|
||||
} catch (\Exception $e) {
|
||||
\Log::error($e);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', trans('admin/users/general.user_notified'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,6 +703,10 @@ class ReportsController extends Controller
|
||||
$assets->whereBetween('assets.expected_checkin', [$request->input('expected_checkin_start'), $request->input('expected_checkin_end')]);
|
||||
}
|
||||
|
||||
if (($request->filled('asset_eol_date_start')) && ($request->filled('asset_eol_date_end'))) {
|
||||
$assets->whereBetween('assets.asset_eol_date', [$request->input('asset_eol_date_start'), $request->input('asset_eol_date_end')]);
|
||||
}
|
||||
|
||||
if (($request->filled('last_audit_start')) && ($request->filled('last_audit_end'))) {
|
||||
$last_audit_start = Carbon::parse($request->input('last_audit_start'))->startOfDay();
|
||||
$last_audit_end = Carbon::parse($request->input('last_audit_end'))->endOfDay();
|
||||
@@ -778,7 +782,7 @@ class ReportsController extends Controller
|
||||
}
|
||||
|
||||
if ($request->filled('eol')) {
|
||||
$row[] = ($asset->asset_eol_date) ? $asset->asset_eol_date : '';
|
||||
$row[] = ($asset->purchase_date != '') ? $asset->asset_eol_date : '';
|
||||
}
|
||||
|
||||
if ($request->filled('order')) {
|
||||
|
||||
@@ -7,6 +7,11 @@ use App\Helpers\StorageHelper;
|
||||
use App\Http\Requests\ImageUploadRequest;
|
||||
use App\Http\Requests\SettingsSamlRequest;
|
||||
use App\Http\Requests\SetupUserRequest;
|
||||
use App\Http\Requests\StoreLdapSettings;
|
||||
use App\Http\Requests\StoreLocalizationSettings;
|
||||
use App\Http\Requests\StoreNotificationSettings;
|
||||
use App\Http\Requests\StoreLabelSettings;
|
||||
use App\Http\Requests\StoreSecuritySettings;
|
||||
use App\Models\CustomField;
|
||||
use App\Models\Group;
|
||||
use App\Models\Setting;
|
||||
@@ -181,7 +186,7 @@ class SettingsController extends Controller
|
||||
$settings->brand = 1;
|
||||
$settings->locale = $request->input('locale', 'en-US');
|
||||
$settings->default_currency = $request->input('default_currency', 'USD');
|
||||
$settings->user_id = 1;
|
||||
$settings->created_by = 1;
|
||||
$settings->email_domain = $request->input('email_domain');
|
||||
$settings->email_format = $request->input('email_format');
|
||||
$settings->next_auto_tag_base = 1;
|
||||
@@ -273,20 +278,6 @@ class SettingsController extends Controller
|
||||
return view('settings/index', compact('settings'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the admin settings page.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
*
|
||||
* @since [v1.0]
|
||||
*/
|
||||
public function getEdit() : View
|
||||
|
||||
{
|
||||
$setting = Setting::getSettings();
|
||||
|
||||
return view('settings/general', compact('setting'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a form to allow a super admin to update settings.
|
||||
@@ -486,7 +477,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @since [v1.0]
|
||||
*/
|
||||
public function postSecurity(Request $request) : RedirectResponse
|
||||
public function postSecurity(StoreSecuritySettings $request) : RedirectResponse
|
||||
{
|
||||
$this->validate($request, [
|
||||
'pwd_secure_complexity' => 'array',
|
||||
@@ -556,7 +547,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @since [v1.0]
|
||||
*/
|
||||
public function postLocalization(Request $request) : RedirectResponse
|
||||
public function postLocalization(StoreLocalizationSettings $request) : RedirectResponse
|
||||
{
|
||||
if (is_null($setting = Setting::getSettings())) {
|
||||
return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error'));
|
||||
@@ -599,7 +590,7 @@ class SettingsController extends Controller
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
*/
|
||||
public function postAlerts(Request $request) : RedirectResponse
|
||||
public function postAlerts(StoreNotificationSettings $request) : RedirectResponse
|
||||
{
|
||||
if (is_null($setting = Setting::getSettings())) {
|
||||
return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error'));
|
||||
@@ -780,7 +771,7 @@ class SettingsController extends Controller
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v4.0]
|
||||
*/
|
||||
public function postLabels(Request $request) : RedirectResponse
|
||||
public function postLabels(StoreLabelSettings $request) : RedirectResponse
|
||||
{
|
||||
if (is_null($setting = Setting::getSettings())) {
|
||||
return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error'));
|
||||
@@ -859,26 +850,7 @@ class SettingsController extends Controller
|
||||
{
|
||||
$setting = Setting::getSettings();
|
||||
$groups = Group::pluck('name', 'id');
|
||||
|
||||
|
||||
/**
|
||||
* This validator is only temporary (famous last words.) - @snipe
|
||||
*/
|
||||
$messages = [
|
||||
'ldap_username_field.not_in' => '<code>sAMAccountName</code> (mixed case) will likely not work. You should use <code>samaccountname</code> (lowercase) instead. ',
|
||||
'ldap_auth_filter_query.not_in' => '<code>uid=samaccountname</code> is probably not a valid auth filter. You probably want <code>uid=</code> ',
|
||||
'ldap_filter.regex' => 'This value should probably not be wrapped in parentheses.',
|
||||
];
|
||||
|
||||
$validator = Validator::make($setting->toArray(), [
|
||||
'ldap_username_field' => 'not_in:sAMAccountName',
|
||||
'ldap_auth_filter_query' => 'not_in:uid=samaccountname|required_if:ldap_enabled,1',
|
||||
'ldap_filter' => 'nullable|regex:"^[^(]"|required_if:ldap_enabled,1',
|
||||
], $messages);
|
||||
|
||||
|
||||
|
||||
return view('settings.ldap', compact('setting', 'groups'))->withErrors($validator);
|
||||
return view('settings.ldap', compact('setting', 'groups'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -887,7 +859,7 @@ class SettingsController extends Controller
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v4.0]
|
||||
*/
|
||||
public function postLdapSettings(Request $request) : RedirectResponse
|
||||
public function postLdapSettings(StoreLdapSettings $request) : RedirectResponse
|
||||
{
|
||||
if (is_null($setting = Setting::getSettings())) {
|
||||
return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error'));
|
||||
|
||||
@@ -47,7 +47,7 @@ class StatuslabelsController extends Controller
|
||||
|
||||
return view('statuslabels/edit')
|
||||
->with('item', new Statuslabel)
|
||||
->with('statuslabel_types', Helper::statusTypeList());
|
||||
->with('status_types', Helper::statusTypeList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,19 +61,11 @@ class StatuslabelsController extends Controller
|
||||
// create a new model instance
|
||||
$statusLabel = new Statuslabel();
|
||||
|
||||
if ($request->missing('statuslabel_types')) {
|
||||
return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]);
|
||||
}
|
||||
|
||||
$statusType = Statuslabel::getStatuslabelTypesForDB($request->input('statuslabel_types'));
|
||||
|
||||
// Save the Statuslabel data
|
||||
$statusLabel->name = $request->input('name');
|
||||
$statusLabel->user_id = Auth::id();
|
||||
$statusLabel->created_by = auth()->id();
|
||||
$statusLabel->notes = $request->input('notes');
|
||||
$statusLabel->deployable = $statusType['deployable'];
|
||||
$statusLabel->pending = $statusType['pending'];
|
||||
$statusLabel->archived = $statusType['archived'];
|
||||
$statusLabel->status_type = $request->input('status_type');
|
||||
$statusLabel->color = $request->input('color');
|
||||
$statusLabel->show_in_nav = $request->input('show_in_nav', 0);
|
||||
$statusLabel->default_label = $request->input('default_label', 0);
|
||||
@@ -100,11 +92,7 @@ class StatuslabelsController extends Controller
|
||||
return redirect()->route('statuslabels.index')->with('error', trans('admin/statuslabels/message.does_not_exist'));
|
||||
}
|
||||
|
||||
$use_statuslabel_type = $item->getStatuslabelType();
|
||||
|
||||
$statuslabel_types = ['' => trans('admin/hardware/form.select_statustype')] + ['undeployable' => trans('admin/hardware/general.undeployable')] + ['pending' => trans('admin/hardware/general.pending')] + ['archived' => trans('admin/hardware/general.archived')] + ['deployable' => trans('admin/hardware/general.deployable')];
|
||||
|
||||
return view('statuslabels/edit', compact('item', 'statuslabel_types'))->with('use_statuslabel_type', $use_statuslabel_type);
|
||||
return view('statuslabels/edit', compact('item'))->with('status_types', Helper::statusTypeList());;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,17 +109,10 @@ class StatuslabelsController extends Controller
|
||||
return redirect()->route('statuslabels.index')->with('error', trans('admin/statuslabels/message.does_not_exist'));
|
||||
}
|
||||
|
||||
if (! $request->filled('statuslabel_types')) {
|
||||
return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]);
|
||||
}
|
||||
|
||||
// Update the Statuslabel data
|
||||
$statustype = Statuslabel::getStatuslabelTypesForDB($request->input('statuslabel_types'));
|
||||
$statuslabel->name = $request->input('name');
|
||||
$statuslabel->notes = $request->input('notes');
|
||||
$statuslabel->deployable = $statustype['deployable'];
|
||||
$statuslabel->pending = $statustype['pending'];
|
||||
$statuslabel->archived = $statustype['archived'];
|
||||
$statuslabel->status_type = $request->input('status_type');
|
||||
$statuslabel->color = $request->input('color');
|
||||
$statuslabel->show_in_nav = $request->input('show_in_nav', 0);
|
||||
$statuslabel->default_label = $request->input('default_label', 0);
|
||||
|
||||
@@ -62,7 +62,7 @@ class SuppliersController extends Controller
|
||||
$supplier->email = request('email');
|
||||
$supplier->notes = request('notes');
|
||||
$supplier->url = $supplier->addhttp(request('url'));
|
||||
$supplier->user_id = Auth::id();
|
||||
$supplier->created_by = auth()->id();
|
||||
$supplier = $request->handleImages($supplier);
|
||||
|
||||
if ($supplier->save()) {
|
||||
|
||||
@@ -13,6 +13,7 @@ use App\Models\Group;
|
||||
use App\Models\LicenseSeat;
|
||||
use App\Models\ConsumableAssignment;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -35,7 +36,7 @@ class BulkUsersController extends Controller
|
||||
*/
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$this->authorize('update', User::class);
|
||||
$this->authorize('view', User::class);
|
||||
|
||||
// Make sure there were users selected
|
||||
if (($request->filled('ids')) && (count($request->input('ids')) > 0)) {
|
||||
@@ -47,16 +48,18 @@ class BulkUsersController extends Controller
|
||||
|
||||
// bulk edit, display the bulk edit form
|
||||
if ($request->input('bulk_actions') == 'edit') {
|
||||
$this->authorize('update', User::class);
|
||||
return view('users/bulk-edit', compact('users'))
|
||||
->with('groups', Group::pluck('name', 'id'));
|
||||
|
||||
// bulk delete, display the bulk delete confirmation form
|
||||
} elseif ($request->input('bulk_actions') == 'delete') {
|
||||
$this->authorize('delete', User::class);
|
||||
return view('users/confirm-bulk-delete')->with('users', $users)->with('statuslabel_list', Helper::statusLabelList());
|
||||
|
||||
// merge, confirm they have at least 2 users selected and display the merge screen
|
||||
} elseif ($request->input('bulk_actions') == 'merge') {
|
||||
|
||||
$this->authorize('delete', User::class);
|
||||
if (($request->filled('ids')) && (count($request->input('ids')) > 1)) {
|
||||
return view('users/confirm-merge')->with('users', $users);
|
||||
// Not enough users selected, send them back
|
||||
@@ -76,6 +79,33 @@ class BulkUsersController extends Controller
|
||||
}
|
||||
return redirect()->back()->with('success', trans('admin/users/message.password_resets_sent'));
|
||||
|
||||
} elseif ($request->input('bulk_actions') == 'print') {
|
||||
$users = User::query()
|
||||
->with([
|
||||
'assets.assetlog',
|
||||
'assets.assignedAssets.assetlog',
|
||||
'assets.assignedAssets.defaultLoc',
|
||||
'assets.assignedAssets.location',
|
||||
'assets.assignedAssets.model.category',
|
||||
'assets.defaultLoc',
|
||||
'assets.location',
|
||||
'assets.model.category',
|
||||
'accessories.assetlog',
|
||||
'accessories.category',
|
||||
'accessories.manufacturer',
|
||||
'consumables.assetlog',
|
||||
'consumables.category',
|
||||
'consumables.manufacturer',
|
||||
'licenses.category',
|
||||
])
|
||||
->withTrashed()
|
||||
->findMany($request->input('ids'));
|
||||
|
||||
$users->each(fn($user) => $this->authorize('view', $user));
|
||||
|
||||
return view('users.print')
|
||||
->with('users', $users)
|
||||
->with('settings', Setting::getSettings());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +131,7 @@ class BulkUsersController extends Controller
|
||||
$user_raw_array = $request->input('ids');
|
||||
|
||||
// Remove the user from any updates.
|
||||
$user_raw_array = array_diff($user_raw_array, [Auth::id()]);
|
||||
$user_raw_array = array_diff($user_raw_array, [auth()->id()]);
|
||||
$manager_conflict = false;
|
||||
$users = User::whereIn('id', $user_raw_array)->where('id', '!=', auth()->id())->get();
|
||||
|
||||
@@ -118,6 +148,7 @@ class BulkUsersController extends Controller
|
||||
->conditionallyAddItem('activated')
|
||||
->conditionallyAddItem('start_date')
|
||||
->conditionallyAddItem('end_date')
|
||||
->conditionallyAddItem('city')
|
||||
->conditionallyAddItem('autoassign_licenses');
|
||||
|
||||
|
||||
@@ -156,12 +187,16 @@ class BulkUsersController extends Controller
|
||||
$this->update_array['end_date'] = null;
|
||||
}
|
||||
|
||||
if ($request->input('null_locale')=='1') {
|
||||
$this->update_array['locale'] = null;
|
||||
}
|
||||
|
||||
if (! $manager_conflict) {
|
||||
$this->conditionallyAddItem('manager_id');
|
||||
}
|
||||
// Save the updated info
|
||||
User::whereIn('id', $user_raw_array)
|
||||
->where('id', '!=', Auth::id())->update($this->update_array);
|
||||
->where('id', '!=', auth()->id())->update($this->update_array);
|
||||
|
||||
if (array_key_exists('location_id', $this->update_array)){
|
||||
Asset::where('assigned_type', User::class)
|
||||
@@ -223,7 +258,7 @@ class BulkUsersController extends Controller
|
||||
|
||||
$user_raw_array = request('ids');
|
||||
|
||||
if (($key = array_search(Auth::id(), $user_raw_array)) !== false) {
|
||||
if (($key = array_search(auth()->id(), $user_raw_array)) !== false) {
|
||||
unset($user_raw_array[$key]);
|
||||
}
|
||||
|
||||
@@ -288,7 +323,7 @@ class BulkUsersController extends Controller
|
||||
$logAction->item_type = $itemType;
|
||||
$logAction->target_id = $item->assigned_to;
|
||||
$logAction->target_type = User::class;
|
||||
$logAction->user_id = Auth::id();
|
||||
$logAction->created_at = auth()->id();
|
||||
$logAction->note = 'Bulk checkin items';
|
||||
$logAction->logaction('checkin from');
|
||||
}
|
||||
@@ -302,7 +337,7 @@ class BulkUsersController extends Controller
|
||||
$logAction->item_type = Accessory::class;
|
||||
$logAction->target_id = $accessoryUserRow->assigned_to;
|
||||
$logAction->target_type = User::class;
|
||||
$logAction->user_id = Auth::id();
|
||||
$logAction->created_at = auth()->id();
|
||||
$logAction->note = 'Bulk checkin items';
|
||||
$logAction->logaction('checkin from');
|
||||
}
|
||||
@@ -316,7 +351,7 @@ class BulkUsersController extends Controller
|
||||
$logAction->item_type = Consumable::class;
|
||||
$logAction->target_id = $consumableUserRow->assigned_to;
|
||||
$logAction->target_type = User::class;
|
||||
$logAction->user_id = Auth::id();
|
||||
$logAction->created_at = auth()->id();
|
||||
$logAction->note = 'Bulk checkin items';
|
||||
$logAction->logaction('checkin from');
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\UploadFileRequest;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
@@ -46,7 +43,7 @@ class UserFilesController extends Controller
|
||||
$logAction = new Actionlog();
|
||||
$logAction->item_id = $user->id;
|
||||
$logAction->item_type = User::class;
|
||||
$logAction->user_id = Auth::id();
|
||||
$logAction->created_by = auth()->id();
|
||||
$logAction->note = $request->input('notes');
|
||||
$logAction->target_id = null;
|
||||
$logAction->created_at = date("Y-m-d H:i:s");
|
||||
@@ -116,31 +113,30 @@ class UserFilesController extends Controller
|
||||
public function show($userId = null, $fileId = null)
|
||||
{
|
||||
|
||||
|
||||
if (empty($fileId)) {
|
||||
return redirect()->route('users.show')->with('error', 'Invalid file request');
|
||||
}
|
||||
|
||||
$user = User::find($userId);
|
||||
|
||||
// the license is valid
|
||||
if (isset($user->id)) {
|
||||
if ($user = User::find($userId)) {
|
||||
|
||||
$this->authorize('view', $user);
|
||||
|
||||
if ($log = Actionlog::whereNotNull('filename')->where('item_id', $user->id)->find($fileId)) {
|
||||
$file = 'private_uploads/users/'.$log->filename;
|
||||
|
||||
// Display the file inline
|
||||
if (request('inline') == 'true') {
|
||||
$headers = [
|
||||
'Content-Disposition' => 'inline',
|
||||
];
|
||||
return Storage::download('private_uploads/users/'.$log->filename, $log->filename, $headers);
|
||||
try {
|
||||
return StorageHelper::showOrDownloadFile($file, $log->filename);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->route('users.show', ['user' => $user])->with('error', trans('general.file_not_found'));
|
||||
}
|
||||
|
||||
return Storage::download('private_uploads/users/'.$log->filename);
|
||||
}
|
||||
|
||||
return redirect()->route('users.index')->with('error', trans('admin/users/message.log_record_not_found'));
|
||||
// The log record doesn't exist somehow
|
||||
return redirect()->route('users.show', ['user' => $user])->with('error', trans('general.log_record_not_found'));
|
||||
|
||||
|
||||
return redirect()->back()->with('error', trans('general.file_not_found'));
|
||||
}
|
||||
|
||||
// Redirect to the user management page if the user doesn't exist
|
||||
|
||||
@@ -372,7 +372,7 @@ class UsersController extends Controller
|
||||
$logaction->item_type = User::class;
|
||||
$logaction->item_id = $user->id;
|
||||
$logaction->created_at = date('Y-m-d H:i:s');
|
||||
$logaction->user_id = auth()->id();
|
||||
$logaction->created_by = auth()->id();
|
||||
$logaction->logaction('restore');
|
||||
|
||||
// Redirect them to the deleted page if there are more, otherwise the section index
|
||||
@@ -597,23 +597,37 @@ class UsersController extends Controller
|
||||
public function printInventory($id)
|
||||
{
|
||||
$this->authorize('view', User::class);
|
||||
if ($user = User::where('id', $id)->withTrashed()->first()) {
|
||||
|
||||
$user = User::where('id', $id)
|
||||
->with([
|
||||
'assets.assetlog',
|
||||
'assets.assignedAssets.assetlog',
|
||||
'assets.assignedAssets.defaultLoc',
|
||||
'assets.assignedAssets.location',
|
||||
'assets.assignedAssets.model.category',
|
||||
'assets.defaultLoc',
|
||||
'assets.location',
|
||||
'assets.model.category',
|
||||
'accessories.assetlog',
|
||||
'accessories.category',
|
||||
'accessories.manufacturer',
|
||||
'consumables.assetlog',
|
||||
'consumables.category',
|
||||
'consumables.manufacturer',
|
||||
'licenses.category',
|
||||
])
|
||||
->withTrashed()
|
||||
->first();
|
||||
|
||||
if ($user) {
|
||||
$this->authorize('view', $user);
|
||||
$assets = Asset::where('assigned_to', $id)->where('assigned_type', User::class)->with('model', 'model.category')->get();
|
||||
$accessories = $user->accessories()->get();
|
||||
$consumables = $user->consumables()->get();
|
||||
|
||||
return view('users/print')->with('assets', $assets)
|
||||
->with('licenses', $user->licenses()->get())
|
||||
->with('accessories', $accessories)
|
||||
->with('consumables', $consumables)
|
||||
->with('show_user', $user)
|
||||
return view('users.print')
|
||||
->with('users', [$user])
|
||||
->with('settings', Setting::getSettings());
|
||||
}
|
||||
|
||||
return redirect()->route('users.index')->with('error', trans('admin/users/message.user_not_found', compact('id')));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,7 @@ use App\Notifications\RequestAssetNotification;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use \Illuminate\Contracts\View\View;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to the ability for users
|
||||
@@ -179,8 +180,11 @@ class ViewAssetsController extends Controller
|
||||
$asset->decrement('requests_counter', 1);
|
||||
|
||||
$logaction->logaction('request canceled');
|
||||
$settings->notify(new RequestAssetCancelation($data));
|
||||
|
||||
try {
|
||||
$settings->notify(new RequestAssetCancelation($data));
|
||||
} catch (\Exception $e) {
|
||||
Log::warning($e);
|
||||
}
|
||||
return redirect()->route('requestable-assets')
|
||||
->with('success')->with('success', trans('admin/hardware/message.requests.canceled'));
|
||||
}
|
||||
@@ -188,7 +192,11 @@ class ViewAssetsController extends Controller
|
||||
$logaction->logaction('requested');
|
||||
$asset->request();
|
||||
$asset->increment('requests_counter', 1);
|
||||
$settings->notify(new RequestAssetNotification($data));
|
||||
try {
|
||||
$settings->notify(new RequestAssetNotification($data));
|
||||
} catch (\Exception $e) {
|
||||
Log::warning($e);
|
||||
}
|
||||
|
||||
return redirect()->route('requestable-assets')->with('success')->with('success', trans('admin/hardware/message.requests.success'));
|
||||
}
|
||||
|
||||
@@ -53,6 +53,10 @@ class Kernel extends HttpKernel
|
||||
\App\Http\Middleware\CheckLocale::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'health' => [
|
||||
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -69,5 +73,6 @@ class Kernel extends HttpKernel
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'health' => null,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -7,14 +7,19 @@ use Closure;
|
||||
|
||||
class CheckForSetup
|
||||
{
|
||||
|
||||
protected $except = [
|
||||
'_debugbar*',
|
||||
'health'
|
||||
];
|
||||
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
|
||||
/**
|
||||
* This is dumb
|
||||
* @todo Check on removing this, not sure if it's still needed
|
||||
* Skip this middleware for the debugbar and health check
|
||||
*/
|
||||
if ($request->is('_debugbar*')) {
|
||||
if ($request->is($this->except)) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
@@ -25,7 +30,7 @@ class CheckForSetup
|
||||
return $next($request);
|
||||
}
|
||||
} else {
|
||||
if (! ($request->is('setup*')) && ! ($request->is('.env')) && ! ($request->is('health'))) {
|
||||
if (! ($request->is('setup*')) && ! ($request->is('.env'))) {
|
||||
return redirect(config('app.url').'/setup');
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class ItemImportRequest extends FormRequest
|
||||
$fieldMappings = array_change_key_case(array_flip($import->field_map), CASE_LOWER);
|
||||
}
|
||||
$importer->setCallbacks([$this, 'log'], [$this, 'progress'], [$this, 'errorCallback'])
|
||||
->setUserId(Auth::id())
|
||||
->setUserId(auth()->id())
|
||||
->setUpdating($this->get('import-update'))
|
||||
->setShouldNotify($this->get('send-welcome'))
|
||||
->setUsernameFormat('firstname.lastname')
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Models\Setting;
|
||||
use Carbon\Carbon;
|
||||
use Carbon\Exceptions\InvalidFormatException;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use App\Rules\AssetCannotBeCheckedOutToNondeployableStatus;
|
||||
|
||||
class StoreAssetRequest extends ImageUploadRequest
|
||||
{
|
||||
@@ -28,7 +29,8 @@ class StoreAssetRequest extends ImageUploadRequest
|
||||
// Guard against users passing in an array for company_id instead of an integer.
|
||||
// If the company_id is not an integer then we simply use what was
|
||||
// provided to be caught by model level validation later.
|
||||
$idForCurrentUser = is_int($this->company_id)
|
||||
// The use of is_numeric accounts for 1 and '1'.
|
||||
$idForCurrentUser = is_numeric($this->company_id)
|
||||
? Company::getIdForCurrentUser($this->company_id)
|
||||
: $this->company_id;
|
||||
|
||||
@@ -61,6 +63,7 @@ class StoreAssetRequest extends ImageUploadRequest
|
||||
|
||||
return array_merge(
|
||||
$modelRules,
|
||||
['status_id' => [new AssetCannotBeCheckedOutToNondeployableStatus()]],
|
||||
parent::rules(),
|
||||
);
|
||||
}
|
||||
|
||||
41
app/Http/Requests/StoreLabelSettings.php
Normal file
41
app/Http/Requests/StoreLabelSettings.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class StoreLabelSettings extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::allows('superuser');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'labels_per_page' => 'numeric',
|
||||
'labels_width' => 'numeric',
|
||||
'labels_height' => 'numeric',
|
||||
'labels_pmargin_left' => 'numeric|nullable',
|
||||
'labels_pmargin_right' => 'numeric|nullable',
|
||||
'labels_pmargin_top' => 'numeric|nullable',
|
||||
'labels_pmargin_bottom' => 'numeric|nullable',
|
||||
'labels_display_bgutter' => 'numeric|nullable',
|
||||
'labels_display_sgutter' => 'numeric|nullable',
|
||||
'labels_fontsize' => 'numeric|min:5',
|
||||
'labels_pagewidth' => 'numeric|nullable',
|
||||
'labels_pageheight' => 'numeric|nullable',
|
||||
'qr_text' => 'max:31|nullable',
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Requests/StoreLdapSettings.php
Normal file
38
app/Http/Requests/StoreLdapSettings.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class StoreLdapSettings extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::allows('superuser');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'ldap_username_field' => 'not_in:sAMAccountName|required_if:ldap_enabled,1',
|
||||
'ldap_auth_filter_query' => 'not_in:uid=samaccountname|required_if:ldap_enabled,1',
|
||||
'ldap_filter' => 'nullable|regex:"^[^(]"|required_if:ldap_enabled,1',
|
||||
'ldap_server' => 'nullable|required_if:ldap_enabled,1|starts_with:ldap://,ldaps://',
|
||||
'ldap_uname' => 'nullable|required_if:ldap_enabled,1',
|
||||
'ldap_pword' => 'nullable|required_if:ldap_enabled,1',
|
||||
'ldap_basedn' => 'nullable|required_if:ldap_enabled,1',
|
||||
'ldap_fname_field' => 'nullable|required_if:ldap_enabled,1',
|
||||
'custom_forgot_pass_url' => 'nullable|url',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
30
app/Http/Requests/StoreLocalizationSettings.php
Normal file
30
app/Http/Requests/StoreLocalizationSettings.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class StoreLocalizationSettings extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::allows('superuser');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'default_currency' => 'required',
|
||||
'locale' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Http/Requests/StoreNotificationSettings.php
Normal file
37
app/Http/Requests/StoreNotificationSettings.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\Accessory;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class StoreNotificationSettings extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::allows('superuser');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'alert_email' => 'email_array|nullable',
|
||||
'admin_cc_email' => 'email|nullable',
|
||||
'alert_threshold' => 'numeric|nullable|gt:0',
|
||||
'alert_interval' => 'numeric|nullable|gt:0',
|
||||
'audit_warning_days' => 'numeric|nullable|gt:0',
|
||||
'due_checkin_days' => 'numeric|nullable|gt:0',
|
||||
'audit_interval' => 'numeric|nullable|gt:0',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
35
app/Http/Requests/StoreSecuritySettings.php
Normal file
35
app/Http/Requests/StoreSecuritySettings.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class StoreSecuritySettings extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::allows('superuser');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'pwd_secure_min' => 'numeric|required|min:8',
|
||||
'custom_forgot_pass_url' => 'url|nullable',
|
||||
'privacy_policy_link' => 'nullable|url',
|
||||
'login_remote_user_enabled' => 'numeric|nullable',
|
||||
'login_common_disabled' => 'numeric|nullable',
|
||||
'login_remote_user_custom_logout_url' => 'string|nullable',
|
||||
'login_remote_user_header_name' => 'string|nullable',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ trait MayContainCustomFields
|
||||
return str_starts_with($attributes, '_snipeit_');
|
||||
});
|
||||
// if there are custom fields, find the one's that don't exist on the model's fieldset and add an error to the validator's error bag
|
||||
if (count($request_fields) > 0) {
|
||||
if (count($request_fields) > 0 && $validator->errors()->isEmpty()) {
|
||||
$request_fields->diff($asset_model?->fieldset?->fields?->pluck('db_column'))
|
||||
->each(function ($request_field_name) use ($request_fields, $validator) {
|
||||
if (CustomField::where('db_column', $request_field_name)->exists()) {
|
||||
|
||||
@@ -38,9 +38,12 @@ class AccessoriesTransformer
|
||||
'purchase_cost' => Helper::formatCurrencyOutput($accessory->purchase_cost),
|
||||
'order_number' => ($accessory->order_number) ? e($accessory->order_number) : null,
|
||||
'min_qty' => ($accessory->min_amt) ? (int) $accessory->min_amt : null,
|
||||
'remaining_qty' => (int) $accessory->numRemaining(),
|
||||
'remaining_qty' => (int) ($accessory->qty - $accessory->checkouts_count),
|
||||
'checkouts_count' => $accessory->checkouts_count,
|
||||
|
||||
'created_by' => ($accessory->adminuser) ? [
|
||||
'id' => (int) $accessory->adminuser->id,
|
||||
'name'=> e($accessory->adminuser->present()->fullName()),
|
||||
] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($accessory->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($accessory->updated_at, 'datetime'),
|
||||
|
||||
@@ -57,7 +60,7 @@ class AccessoriesTransformer
|
||||
|
||||
$permissions_array['user_can_checkout'] = false;
|
||||
|
||||
if ($accessory->numRemaining() > 0) {
|
||||
if (($accessory->qty - $accessory->checkouts_count) > 0) {
|
||||
$permissions_array['user_can_checkout'] = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,8 @@ class ActionlogsTransformer
|
||||
if ($actionlog->item) {
|
||||
if ($actionlog->itemType() == 'asset') {
|
||||
$file_url = route('show/assetfile', ['assetId' => $actionlog->item->id, 'fileId' => $actionlog->id]);
|
||||
} elseif ($actionlog->itemType() == 'accessory') {
|
||||
$file_url = route('show.accessoryfile', ['accessoryId' => $actionlog->item->id, 'fileId' => $actionlog->id]);
|
||||
} elseif ($actionlog->itemType() == 'license') {
|
||||
$file_url = route('show.licensefile', ['licenseId' => $actionlog->item->id, 'fileId' => $actionlog->id]);
|
||||
} elseif ($actionlog->itemType() == 'user') {
|
||||
@@ -158,7 +160,6 @@ class ActionlogsTransformer
|
||||
[
|
||||
'url' => $file_url,
|
||||
'filename' => $actionlog->filename,
|
||||
'inlineable' => (bool) Helper::show_file_inline($actionlog->filename),
|
||||
] : null,
|
||||
|
||||
'item' => ($actionlog->item) ? [
|
||||
@@ -176,11 +177,17 @@ class ActionlogsTransformer
|
||||
'next_audit_date' => ($actionlog->itemType()=='asset') ? Helper::getFormattedDateObject($actionlog->calcNextAuditDate(null, $actionlog->item), 'date'): null,
|
||||
'days_to_next_audit' => $actionlog->daysUntilNextAudit($settings->audit_interval, $actionlog->item),
|
||||
'action_type' => $actionlog->present()->actionType(),
|
||||
'admin' => ($actionlog->admin) ? [
|
||||
'id' => (int) $actionlog->admin->id,
|
||||
'name' => e($actionlog->admin->getFullNameAttribute()),
|
||||
'first_name'=> e($actionlog->admin->first_name),
|
||||
'last_name'=> e($actionlog->admin->last_name)
|
||||
'admin' => ($actionlog->adminuser) ? [
|
||||
'id' => (int) $actionlog->adminuser->id,
|
||||
'name' => e($actionlog->adminuser->getFullNameAttribute()),
|
||||
'first_name'=> e($actionlog->adminuser->first_name),
|
||||
'last_name'=> e($actionlog->adminuser->last_name)
|
||||
] : null,
|
||||
'created_by' => ($actionlog->adminuser) ? [
|
||||
'id' => (int) $actionlog->adminuser->id,
|
||||
'name' => e($actionlog->adminuser->getFullNameAttribute()),
|
||||
'first_name'=> e($actionlog->adminuser->first_name),
|
||||
'last_name'=> e($actionlog->adminuser->last_name)
|
||||
] : null,
|
||||
'target' => ($actionlog->target) ? [
|
||||
'id' => (int) $actionlog->target->id,
|
||||
@@ -340,4 +347,4 @@ class ActionlogsTransformer
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class AssetMaintenancesTransformer
|
||||
'status_label' => ($assetmaintenance->asset->assetstatus) ? [
|
||||
'id' => (int) $assetmaintenance->asset->assetstatus->id,
|
||||
'name'=> e($assetmaintenance->asset->assetstatus->name),
|
||||
'status_type'=> e($assetmaintenance->asset->assetstatus->getStatuslabelType()),
|
||||
'status_type'=> e($assetmaintenance->asset->assetstatus->status_type),
|
||||
'status_meta' => e($assetmaintenance->asset->present()->statusMeta),
|
||||
] : null,
|
||||
'company' => (($assetmaintenance->asset) && ($assetmaintenance->asset->company)) ? [
|
||||
@@ -64,7 +64,14 @@ class AssetMaintenancesTransformer
|
||||
'start_date' => Helper::getFormattedDateObject($assetmaintenance->start_date, 'date'),
|
||||
'asset_maintenance_time' => $assetmaintenance->asset_maintenance_time,
|
||||
'completion_date' => Helper::getFormattedDateObject($assetmaintenance->completion_date, 'date'),
|
||||
'user_id' => ($assetmaintenance->admin) ? ['id' => $assetmaintenance->admin->id, 'name'=> e($assetmaintenance->admin->getFullNameAttribute())] : null,
|
||||
'user_id' => ($assetmaintenance->adminuser) ? [
|
||||
'id' => $assetmaintenance->adminuser->id,
|
||||
'name'=> e($assetmaintenance->adminuser->present()->fullName())
|
||||
] : null, // legacy to not change the shape of the API
|
||||
'created_by' => ($assetmaintenance->adminuser) ? [
|
||||
'id' => (int) $assetmaintenance->adminuser->id,
|
||||
'name'=> e($assetmaintenance->adminuser->present()->fullName()),
|
||||
] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($assetmaintenance->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($assetmaintenance->updated_at, 'datetime'),
|
||||
'is_warranty'=> $assetmaintenance->is_warranty,
|
||||
|
||||
@@ -8,7 +8,6 @@ use App\Models\Setting;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AssetsTransformer
|
||||
{
|
||||
@@ -45,8 +44,8 @@ class AssetsTransformer
|
||||
'status_label' => ($asset->assetstatus) ? [
|
||||
'id' => (int) $asset->assetstatus->id,
|
||||
'name'=> e($asset->assetstatus->name),
|
||||
'status_type'=> e($asset->assetstatus->getStatuslabelType()),
|
||||
'status_meta' => e($asset->present()->statusMeta),
|
||||
'status_type'=> e($asset->assetstatus->status_type),
|
||||
'status_meta' => e($asset->assetstatus->status_type),
|
||||
] : null,
|
||||
'category' => (($asset->model) && ($asset->model->category)) ? [
|
||||
'id' => (int) $asset->model->category->id,
|
||||
@@ -80,6 +79,10 @@ class AssetsTransformer
|
||||
'assigned_to' => $this->transformAssignedTo($asset),
|
||||
'warranty_months' => ($asset->warranty_months > 0) ? e($asset->warranty_months.' '.trans('admin/hardware/form.months')) : null,
|
||||
'warranty_expires' => ($asset->warranty_months > 0) ? Helper::getFormattedDateObject($asset->warranty_expires, 'date') : null,
|
||||
'created_by' => ($asset->adminuser) ? [
|
||||
'id' => (int) $asset->adminuser->id,
|
||||
'name'=> e($asset->adminuser->present()->fullName()),
|
||||
] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($asset->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($asset->updated_at, 'datetime'),
|
||||
'last_audit_date' => Helper::getFormattedDateObject($asset->last_audit_date, 'datetime'),
|
||||
|
||||
@@ -62,6 +62,10 @@ class CategoriesTransformer
|
||||
'consumables_count' => (int) $category->consumables_count,
|
||||
'components_count' => (int) $category->components_count,
|
||||
'licenses_count' => (int) $category->licenses_count,
|
||||
'created_by' => ($category->adminuser) ? [
|
||||
'id' => (int) $category->adminuser->id,
|
||||
'name'=> e($category->adminuser->present()->fullName()),
|
||||
] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($category->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($category->updated_at, 'datetime'),
|
||||
];
|
||||
|
||||
@@ -30,14 +30,18 @@ class CompaniesTransformer
|
||||
'fax' => ($company->fax!='') ? e($company->fax): null,
|
||||
'email' => ($company->email!='') ? e($company->email): null,
|
||||
'image' => ($company->image) ? Storage::disk('public')->url('companies/'.e($company->image)) : null,
|
||||
'created_at' => Helper::getFormattedDateObject($company->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($company->updated_at, 'datetime'),
|
||||
'assets_count' => (int) $company->assets_count,
|
||||
'licenses_count' => (int) $company->licenses_count,
|
||||
'accessories_count' => (int) $company->accessories_count,
|
||||
'consumables_count' => (int) $company->consumables_count,
|
||||
'components_count' => (int) $company->components_count,
|
||||
'users_count' => (int) $company->users_count,
|
||||
'created_by' => ($company->adminuser) ? [
|
||||
'id' => (int) $company->adminuser->id,
|
||||
'name'=> e($company->adminuser->present()->fullName()),
|
||||
] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($company->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($company->updated_at, 'datetime'),
|
||||
];
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
|
||||
@@ -38,6 +38,8 @@ class ComponentsTransformer
|
||||
'name' => e($component->category->name),
|
||||
] : null,
|
||||
'supplier' => ($component->supplier) ? ['id' => $component->supplier->id, 'name'=> e($component->supplier->name)] : null,
|
||||
'manufacturer' => ($component->manufacturer) ? ['id' => $component->manufacturer->id, 'name'=> e($component->manufacturer->name)] : null,
|
||||
'model_number' => ($component->model_number) ? e($component->model_number) : null,
|
||||
'order_number' => e($component->order_number),
|
||||
'purchase_date' => Helper::getFormattedDateObject($component->purchase_date, 'date'),
|
||||
'purchase_cost' => Helper::formatCurrencyOutput($component->purchase_cost),
|
||||
@@ -47,6 +49,10 @@ class ComponentsTransformer
|
||||
'name' => e($component->company->name),
|
||||
] : null,
|
||||
'notes' => ($component->notes) ? Helper::parseEscapedMarkedownInline($component->notes) : null,
|
||||
'created_by' => ($component->adminuser) ? [
|
||||
'id' => (int) $component->adminuser->id,
|
||||
'name'=> e($component->adminuser->present()->fullName()),
|
||||
] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($component->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($component->updated_at, 'datetime'),
|
||||
'user_can_checkout' => ($component->numRemaining() > 0) ? 1 : 0,
|
||||
|
||||
@@ -40,6 +40,10 @@ class ConsumablesTransformer
|
||||
'purchase_date' => Helper::getFormattedDateObject($consumable->purchase_date, 'date'),
|
||||
'qty' => (int) $consumable->qty,
|
||||
'notes' => ($consumable->notes) ? Helper::parseEscapedMarkedownInline($consumable->notes) : null,
|
||||
'created_by' => ($consumable->adminuser) ? [
|
||||
'id' => (int) $consumable->adminuser->id,
|
||||
'name'=> e($consumable->adminuser->present()->fullName()),
|
||||
] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($consumable->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($consumable->updated_at, 'datetime'),
|
||||
];
|
||||
|
||||
@@ -63,15 +63,12 @@ class DepreciationReportTransformer
|
||||
*/
|
||||
if (($asset->model) && ($asset->model->depreciation)) {
|
||||
$depreciated_value = Helper::formatCurrencyOutput($asset->getDepreciatedValue());
|
||||
if($asset->model->eol==0 || $asset->model->eol==null ){
|
||||
$monthly_depreciation = Helper::formatCurrencyOutput($asset->purchase_cost / $asset->model->depreciation->months);
|
||||
}
|
||||
else {
|
||||
$monthly_depreciation = Helper::formatCurrencyOutput(($asset->model->eol > 0 ? ($asset->purchase_cost / $asset->model->eol) : 0));
|
||||
}
|
||||
$monthly_depreciation =Helper::formatCurrencyOutput($asset->purchase_cost / $asset->model->depreciation->months);
|
||||
$diff = Helper::formatCurrencyOutput(($asset->purchase_cost - $asset->getDepreciatedValue()));
|
||||
}
|
||||
|
||||
else if($asset->model->eol !== null) {
|
||||
$monthly_depreciation = Helper::formatCurrencyOutput(($asset->model->eol > 0 ? ($asset->purchase_cost / $asset->model->eol) : 0));
|
||||
}
|
||||
|
||||
if ($asset->assigned) {
|
||||
$checkout_target = $asset->assigned->name;
|
||||
|
||||
@@ -31,6 +31,10 @@ class DepreciationsTransformer
|
||||
'assets_count' => $depreciation->assets_count,
|
||||
'models_count' => $depreciation->models_count,
|
||||
'licenses_count' => $depreciation->licenses_count,
|
||||
'created_by' => ($depreciation->adminuser) ? [
|
||||
'id' => (int) $depreciation->adminuser->id,
|
||||
'name'=> e($depreciation->adminuser->present()->fullName()),
|
||||
] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($depreciation->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($depreciation->updated_at, 'datetime')
|
||||
];
|
||||
|
||||
@@ -26,7 +26,10 @@ class GroupsTransformer
|
||||
'name' => e($group->name),
|
||||
'permissions' => json_decode($group->permissions),
|
||||
'users_count' => (int) $group->users_count,
|
||||
'created_by' => ($group->admin) ? e($group->admin->present()->fullName) : null,
|
||||
'created_by' => ($group->adminuser) ? [
|
||||
'id' => (int) $group->adminuser->id,
|
||||
'name'=> e($group->adminuser->present()->fullName()),
|
||||
] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($group->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($group->updated_at, 'datetime'),
|
||||
];
|
||||
|
||||
@@ -61,7 +61,7 @@ class LicensesTransformer
|
||||
'checkin' => Gate::allows('checkin', License::class),
|
||||
'clone' => Gate::allows('create', License::class),
|
||||
'update' => Gate::allows('update', License::class),
|
||||
'delete' => (Gate::allows('delete', License::class) && ($license->seats == $license->availCount()->count())) ? true : false,
|
||||
'delete' => (Gate::allows('delete', License::class) && ($license->free_seats_count > 0)) ? true : false,
|
||||
];
|
||||
|
||||
$array += $permissions_array;
|
||||
|
||||
@@ -36,6 +36,11 @@ class ManufacturersTransformer
|
||||
'licenses_count' => (int) $manufacturer->licenses_count,
|
||||
'consumables_count' => (int) $manufacturer->consumables_count,
|
||||
'accessories_count' => (int) $manufacturer->accessories_count,
|
||||
'components_count' => (int) $manufacturer->components_count,
|
||||
'created_by' => ($manufacturer->adminuser) ? [
|
||||
'id' => (int) $manufacturer->adminuser->id,
|
||||
'name'=> e($manufacturer->adminuser->present()->fullName()),
|
||||
] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($manufacturer->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($manufacturer->updated_at, 'datetime'),
|
||||
'deleted_at' => Helper::getFormattedDateObject($manufacturer->deleted_at, 'datetime'),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Transformers;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\PredefinedKit;
|
||||
use App\Models\SnipeModel;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
@@ -30,6 +31,12 @@ class PredefinedKitsTransformer
|
||||
$array = [
|
||||
'id' => (int) $kit->id,
|
||||
'name' => e($kit->name),
|
||||
'created_by' => ($kit->adminuser) ? [
|
||||
'id' => (int) $kit->adminuser->id,
|
||||
'name'=> e($kit->adminuser->present()->fullName()),
|
||||
] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($kit->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($kit->updated_at, 'datetime'),
|
||||
];
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
|
||||
@@ -24,12 +24,17 @@ class StatuslabelsTransformer
|
||||
$array = [
|
||||
'id' => (int) $statuslabel->id,
|
||||
'name' => e($statuslabel->name),
|
||||
'type' => $statuslabel->getStatuslabelType(),
|
||||
'type' => $statuslabel->status_type, // legacy - to be removed in later versions
|
||||
'status_type' => $statuslabel->status_type,
|
||||
'color' => ($statuslabel->color) ? e($statuslabel->color) : null,
|
||||
'show_in_nav' => ($statuslabel->show_in_nav == '1') ? true : false,
|
||||
'default_label' => ($statuslabel->default_label == '1') ? true : false,
|
||||
'assets_count' => (int) $statuslabel->assets_count,
|
||||
'notes' => e($statuslabel->notes),
|
||||
'created_by' => ($statuslabel->adminuser) ? [
|
||||
'id' => (int) $statuslabel->adminuser->id,
|
||||
'name'=> e($statuslabel->adminuser->present()->fullName()),
|
||||
] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($statuslabel->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($statuslabel->updated_at, 'datetime'),
|
||||
];
|
||||
|
||||
@@ -18,8 +18,8 @@ class AssetImporter extends ItemImporter
|
||||
|
||||
$this->defaultStatusLabelId = Statuslabel::first()->id;
|
||||
|
||||
if (!is_null(Statuslabel::deployable()->first())) {
|
||||
$this->defaultStatusLabelId = Statuslabel::deployable()->first()->id;
|
||||
if (!is_null(Statuslabel::where('status_type', 'deployable')->first())) {
|
||||
$this->defaultStatusLabelId = Statuslabel::where('status_type', 'deployable')->first()->id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ class AssetImporter extends ItemImporter
|
||||
$this->log('Asset '.$this->item['name'].' with serial number '.$this->item['serial'].' was created');
|
||||
|
||||
// If we have a target to checkout to, lets do so.
|
||||
//-- user_id is a property of the abstract class Importer, which this class inherits from and it's set by
|
||||
//-- created_by is a property of the abstract class Importer, which this class inherits from and it's set by
|
||||
//-- the class that needs to use it (command importer or GUI importer inside the project).
|
||||
if (isset($target) && ($target !== false)) {
|
||||
if (!is_null($asset->assigned_to)){
|
||||
@@ -186,7 +186,7 @@ class AssetImporter extends ItemImporter
|
||||
}
|
||||
}
|
||||
|
||||
$asset->fresh()->checkOut($target, $this->user_id, $checkout_date, null, 'Checkout from CSV Importer', $asset->name);
|
||||
$asset->fresh()->checkOut($target, $this->created_by, $checkout_date, null, 'Checkout from CSV Importer', $asset->name);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -58,7 +58,7 @@ class ComponentImporter extends ItemImporter
|
||||
if (isset($this->item['asset_tag']) && ($asset = Asset::where('asset_tag', $this->item['asset_tag'])->first())) {
|
||||
$component->assets()->attach($component->id, [
|
||||
'component_id' => $component->id,
|
||||
'user_id' => $this->user_id,
|
||||
'created_by' => $this->created_by,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'assigned_qty' => 1, // Only assign the first one to the asset
|
||||
'asset_id' => $asset->id,
|
||||
|
||||
@@ -21,8 +21,7 @@ abstract class Importer
|
||||
* Id of User performing import
|
||||
* @var
|
||||
*/
|
||||
|
||||
protected $user_id;
|
||||
protected $created_by;
|
||||
/**
|
||||
* Are we updating items in the import
|
||||
* @var bool
|
||||
@@ -149,21 +148,28 @@ abstract class Importer
|
||||
{
|
||||
$headerRow = $this->csv->fetchOne();
|
||||
$this->csv->setHeaderOffset(0); //explicitly sets the CSV document header record
|
||||
$results = $this->normalizeInputArray($this->csv->getRecords($headerRow));
|
||||
|
||||
$this->populateCustomFields($headerRow);
|
||||
|
||||
DB::transaction(function () use (&$results) {
|
||||
DB::transaction(function () use ($headerRow) {
|
||||
$importedItemsCount = 0;
|
||||
Model::unguard();
|
||||
$resultsCount = count($results);
|
||||
foreach ($results as $row) {
|
||||
|
||||
foreach ($this->csv->getRecords($headerRow) as $row) {
|
||||
//Lowercase header values to ensure we're comparing values properly.
|
||||
$row = array_change_key_case($row, CASE_LOWER);
|
||||
|
||||
$this->handle($row);
|
||||
|
||||
$importedItemsCount++;
|
||||
|
||||
if ($this->progressCallback) {
|
||||
call_user_func($this->progressCallback, $resultsCount);
|
||||
call_user_func($this->progressCallback, $importedItemsCount);
|
||||
}
|
||||
|
||||
$this->log('------------- Action Summary ----------------');
|
||||
}
|
||||
Model::reguard();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -236,22 +242,6 @@ abstract class Importer
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to lowercase header values to ensure we're comparing values properly.
|
||||
*
|
||||
* @param $results
|
||||
* @return array
|
||||
*/
|
||||
public function normalizeInputArray($results)
|
||||
{
|
||||
$newArray = [];
|
||||
foreach ($results as $index => $arrayToNormalize) {
|
||||
$newArray[$index] = array_change_key_case($arrayToNormalize);
|
||||
}
|
||||
|
||||
return $newArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Figure out the fieldname of the custom field
|
||||
*
|
||||
@@ -395,7 +385,7 @@ abstract class Importer
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches a user by user_id if user_name provided is a number
|
||||
* Matches a user by created_by if user_name provided is a number
|
||||
* @param string $user_name users full name from csv
|
||||
* @return User User Matching ID
|
||||
*/
|
||||
@@ -412,13 +402,13 @@ abstract class Importer
|
||||
/**
|
||||
* Sets the Id of User performing import.
|
||||
*
|
||||
* @param mixed $user_id the user id
|
||||
* @param mixed $created_by the user id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setUserId($user_id)
|
||||
public function setUserId($created_by)
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
$this->created_by = $created_by;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class ItemImporter extends Importer
|
||||
|
||||
$this->item['qty'] = $this->findCsvMatch($row, 'quantity');
|
||||
$this->item['requestable'] = $this->findCsvMatch($row, 'requestable');
|
||||
$this->item['user_id'] = $this->user_id;
|
||||
$this->item['created_by'] = $this->created_by;
|
||||
$this->item['serial'] = $this->findCsvMatch($row, 'serial');
|
||||
// NO need to call this method if we're running the user import.
|
||||
// TODO: Merge these methods.
|
||||
@@ -301,7 +301,7 @@ class ItemImporter extends Importer
|
||||
$category = new Category();
|
||||
$category->name = $asset_category;
|
||||
$category->category_type = $item_type;
|
||||
$category->user_id = $this->user_id;
|
||||
$category->created_by = $this->created_by;
|
||||
|
||||
if ($category->save()) {
|
||||
$this->log('Category '.$asset_category.' was created');
|
||||
@@ -425,7 +425,7 @@ class ItemImporter extends Importer
|
||||
//Otherwise create a manufacturer.
|
||||
$manufacturer = new Manufacturer();
|
||||
$manufacturer->name = trim($item_manufacturer);
|
||||
$manufacturer->user_id = $this->user_id;
|
||||
$manufacturer->created_by = $this->created_by;
|
||||
|
||||
if ($manufacturer->save()) {
|
||||
$this->log('Manufacturer '.$manufacturer->name.' was created');
|
||||
@@ -466,7 +466,7 @@ class ItemImporter extends Importer
|
||||
$location->city = '';
|
||||
$location->state = '';
|
||||
$location->country = '';
|
||||
$location->user_id = $this->user_id;
|
||||
$location->created_by = $this->created_by;
|
||||
|
||||
if ($location->save()) {
|
||||
$this->log('Location '.$asset_location.' was created');
|
||||
@@ -502,7 +502,7 @@ class ItemImporter extends Importer
|
||||
|
||||
$supplier = new Supplier();
|
||||
$supplier->name = $item_supplier;
|
||||
$supplier->user_id = $this->user_id;
|
||||
$supplier->created_by = $this->created_by;
|
||||
|
||||
if ($supplier->save()) {
|
||||
$this->log('Supplier '.$item_supplier.' was created');
|
||||
|
||||
@@ -103,13 +103,13 @@ class LicenseImporter extends ItemImporter
|
||||
|
||||
if ($checkout_target) {
|
||||
$targetLicense->assigned_to = $checkout_target->id;
|
||||
$targetLicense->user_id = Auth::id();
|
||||
$targetLicense->created_by = auth()->id();
|
||||
if ($asset) {
|
||||
$targetLicense->asset_id = $asset->id;
|
||||
}
|
||||
$targetLicense->save();
|
||||
} elseif ($asset) {
|
||||
$targetLicense->user_id = Auth::id();
|
||||
$targetLicense->created_by = auth()->id();
|
||||
$targetLicense->asset_id = $asset->id;
|
||||
$targetLicense->save();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user