Compare commits
903 Commits
use-tcpdf-
...
v8.3.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a7c7fdebf | ||
|
|
65ff3d414a | ||
|
|
9fa38b70c8 | ||
|
|
470172f53f | ||
|
|
81261d9e36 | ||
|
|
3ab2e20119 | ||
|
|
b773d576ea | ||
|
|
23feb64b5a | ||
|
|
87fe9d9d3d | ||
|
|
b1ef3f51cb | ||
|
|
e1b6488f8e | ||
|
|
a472dede2b | ||
|
|
263cc3f7a1 | ||
|
|
d355812433 | ||
|
|
1afc14f5ab | ||
|
|
8947b667ae | ||
|
|
6b41796d44 | ||
|
|
6efe8eb55b | ||
|
|
4c8f8918e8 | ||
|
|
4cb5bb1855 | ||
|
|
eb007e025a | ||
|
|
18aefa9dee | ||
|
|
2ec540bd36 | ||
|
|
1374ec408a | ||
|
|
8f8fed2b79 | ||
|
|
a1e6f01fe9 | ||
|
|
d7496f22e5 | ||
|
|
7de25a1c37 | ||
|
|
78da89340c | ||
|
|
60606115fe | ||
|
|
57b49fc31c | ||
|
|
6e90c8f6e6 | ||
|
|
a7ff2595a5 | ||
|
|
1edea6abef | ||
|
|
3339d1999f | ||
|
|
df3e8ec0f3 | ||
|
|
2dbec867d9 | ||
|
|
b91d23023d | ||
|
|
cc234c60b8 | ||
|
|
f1883c8004 | ||
|
|
79f6ddc8ee | ||
|
|
89f439a18d | ||
|
|
79eb5bfad9 | ||
|
|
3a36b7dafd | ||
|
|
1fe2fd9891 | ||
|
|
5fdb999ece | ||
|
|
5a38d9c2b6 | ||
|
|
b1c7dc6cbb | ||
|
|
b21b2ac41c | ||
|
|
1396c597ef | ||
|
|
46af72ee4e | ||
|
|
e3e8f553c8 | ||
|
|
549928d3d1 | ||
|
|
abefec9628 | ||
|
|
b483eeded4 | ||
|
|
fab85dafa8 | ||
|
|
955faed919 | ||
|
|
3ff516180d | ||
|
|
0c8ca6d6b0 | ||
|
|
a5de077e04 | ||
|
|
c0a99d6b52 | ||
|
|
a1e65cd897 | ||
|
|
5d65f1ffc5 | ||
|
|
b7193a06fd | ||
|
|
cba090f8eb | ||
|
|
0d6baa1081 | ||
|
|
bc60d796a3 | ||
|
|
85a208526b | ||
|
|
c3ac0a750d | ||
|
|
0f111127a5 | ||
|
|
cd266a6bef | ||
|
|
0f4945621c | ||
|
|
9a477f227b | ||
|
|
3c81257325 | ||
|
|
218fe9ebdc | ||
|
|
24bb45ab97 | ||
|
|
85f39de540 | ||
|
|
5cc3277e2d | ||
|
|
d5ef7f3204 | ||
|
|
cb47d01f51 | ||
|
|
ee499c1385 | ||
|
|
4ae4af5c10 | ||
|
|
b0f5fe7e25 | ||
|
|
fd32585efc | ||
|
|
c675bb7252 | ||
|
|
e65d11d71e | ||
|
|
c2680334f1 | ||
|
|
1217a02ec1 | ||
|
|
143a091f45 | ||
|
|
49ecc93dbe | ||
|
|
1735fb6bed | ||
|
|
8fefc11b4d | ||
|
|
1a3b22171c | ||
|
|
5e773be260 | ||
|
|
c317a1dc8b | ||
|
|
9401ffc83c | ||
|
|
479a852446 | ||
|
|
9188fb03f0 | ||
|
|
36bb91cbc3 | ||
|
|
56e5ab8bc6 | ||
|
|
607eb6ca03 | ||
|
|
ad745cc84b | ||
|
|
5a13d5ea6f | ||
|
|
0b065eb7fe | ||
|
|
e2c0e4bc66 | ||
|
|
655b0e6778 | ||
|
|
cd785c9fc3 | ||
|
|
23885f5166 | ||
|
|
44ef39e419 | ||
|
|
e05a0ef565 | ||
|
|
0ea9c0647f | ||
|
|
00b9ba2b75 | ||
|
|
f1e3bc9531 | ||
|
|
7360e093b2 | ||
|
|
5f639bc24f | ||
|
|
884d2a9552 | ||
|
|
fd8a8b29b1 | ||
|
|
4e1ef40c05 | ||
|
|
00af0ddff5 | ||
|
|
2467e823a5 | ||
|
|
224642fcb5 | ||
|
|
59518ca2c5 | ||
|
|
dfb7c73069 | ||
|
|
70eccceab3 | ||
|
|
3f69b70367 | ||
|
|
94a0a2f8be | ||
|
|
7e23596ab8 | ||
|
|
3c58a5dd3d | ||
|
|
51789ccbf3 | ||
|
|
6ae4a9aa1a | ||
|
|
0aebd669b2 | ||
|
|
2a92c4899d | ||
|
|
530089895a | ||
|
|
ae8289fc8c | ||
|
|
90f4dfb48b | ||
|
|
ec2eddf538 | ||
|
|
44d31d4b39 | ||
|
|
4934e7666c | ||
|
|
35bf0d020e | ||
|
|
4934dc85ac | ||
|
|
5ceb50d7e5 | ||
|
|
ae7ccbb7bd | ||
|
|
1cd9fc47aa | ||
|
|
013c50607a | ||
|
|
d7bf9b7f2e | ||
|
|
4702fdddc6 | ||
|
|
dd06a530c0 | ||
|
|
c36125dc95 | ||
|
|
ae43f93d0a | ||
|
|
8918b17f77 | ||
|
|
dfd05e8b5b | ||
|
|
3daa6dd051 | ||
|
|
14e43192e6 | ||
|
|
6cf88b1792 | ||
|
|
6b9839367f | ||
|
|
34fcf5d616 | ||
|
|
1cf3c74e67 | ||
|
|
16b57b931e | ||
|
|
3457e7d617 | ||
|
|
edbe8001e6 | ||
|
|
71644c1cbe | ||
|
|
03fd8df8bd | ||
|
|
71d622b6dd | ||
|
|
689d5a2d58 | ||
|
|
b2e9eb866c | ||
|
|
c8b7782d1d | ||
|
|
673f936689 | ||
|
|
2ca0d39e51 | ||
|
|
908c8bc397 | ||
|
|
93082e1e87 | ||
|
|
ef0a6aa25e | ||
|
|
b9f4dc1e9d | ||
|
|
90afec864e | ||
|
|
b082fb6692 | ||
|
|
4bbbd786cd | ||
|
|
0c1b2a54e7 | ||
|
|
a6ded20ede | ||
|
|
9b96314371 | ||
|
|
85e16ecd51 | ||
|
|
2ac36cdfd6 | ||
|
|
e40c532354 | ||
|
|
9404dff79c | ||
|
|
55b324d8d6 | ||
|
|
3ed2e2d79e | ||
|
|
3152d9eadd | ||
|
|
f1266ab5d6 | ||
|
|
e70f1408aa | ||
|
|
664e3984e3 | ||
|
|
665c13e238 | ||
|
|
8a667b20c2 | ||
|
|
3693241292 | ||
|
|
a384245368 | ||
|
|
3c3acff79b | ||
|
|
e15de83a95 | ||
|
|
636fccbf97 | ||
|
|
7d8ed399a8 | ||
|
|
272385db6c | ||
|
|
9334b8df47 | ||
|
|
e0bc2ae86f | ||
|
|
2f019bb033 | ||
|
|
291be64aa0 | ||
|
|
75c83236ff | ||
|
|
72be171917 | ||
|
|
4ddee4ac40 | ||
|
|
43cd0d7eb3 | ||
|
|
6b693e2644 | ||
|
|
eeea69d8f2 | ||
|
|
72cf921a4b | ||
|
|
32882f81e7 | ||
|
|
36f5099932 | ||
|
|
bec88a0441 | ||
|
|
6e67e3a8a0 | ||
|
|
4dc3c30354 | ||
|
|
947ccf911d | ||
|
|
06f313febe | ||
|
|
b387136b8f | ||
|
|
31614c5da1 | ||
|
|
146b5a3085 | ||
|
|
397cc1754a | ||
|
|
ff1297cac5 | ||
|
|
8af3cf4056 | ||
|
|
9edec9e212 | ||
|
|
be4362c59a | ||
|
|
8461b147de | ||
|
|
82bdd43168 | ||
|
|
533d82d4d8 | ||
|
|
6f990dd1de | ||
|
|
be848598e3 | ||
|
|
62a58fa23b | ||
|
|
7d0742054f | ||
|
|
dcf7e83507 | ||
|
|
407c2bf0c8 | ||
|
|
c46227ee94 | ||
|
|
d8171eb056 | ||
|
|
c67ca500db | ||
|
|
0081e7b731 | ||
|
|
4e6483d3ed | ||
|
|
0ddf0002c4 | ||
|
|
ad0daf33b9 | ||
|
|
c614c44d4c | ||
|
|
8a46579588 | ||
|
|
fb9fb9c097 | ||
|
|
d9399534ce | ||
|
|
17a749bbed | ||
|
|
0b60c6a939 | ||
|
|
25ce63f00b | ||
|
|
2462bc05b3 | ||
|
|
c3748da0b1 | ||
|
|
90c242a441 | ||
|
|
52239a88b5 | ||
|
|
7a3596c86d | ||
|
|
ac8a9e38f0 | ||
|
|
5c08f3a27e | ||
|
|
2dc11a84bf | ||
|
|
2960ea15f5 | ||
|
|
17aab4c490 | ||
|
|
59d0f0d292 | ||
|
|
27d13a113a | ||
|
|
c58e999fbb | ||
|
|
a02a96d5c4 | ||
|
|
47e9e4704d | ||
|
|
b2ad9d404e | ||
|
|
925d48640d | ||
|
|
5216dd75bf | ||
|
|
028b4e7b79 | ||
|
|
b8b45d2d81 | ||
|
|
4b2b2cb68e | ||
|
|
625a46a2c2 | ||
|
|
be4ace293e | ||
|
|
ebc1e27c22 | ||
|
|
764b363bbc | ||
|
|
705474dc14 | ||
|
|
e639d7726b | ||
|
|
357e85d358 | ||
|
|
9da9166442 | ||
|
|
8ea339f0ef | ||
|
|
e29b0aa6a4 | ||
|
|
d2157868f2 | ||
|
|
89b36ba63f | ||
|
|
1d3dfa1fa4 | ||
|
|
89cfafd933 | ||
|
|
ca567eec8a | ||
|
|
75cfcb83aa | ||
|
|
41da31c379 | ||
|
|
e81f63f46b | ||
|
|
ade03e4827 | ||
|
|
63a4d1ad33 | ||
|
|
33a4c88c3a | ||
|
|
69c5dbfc23 | ||
|
|
cf1bccfd65 | ||
|
|
99acf018f1 | ||
|
|
f04d6f37e5 | ||
|
|
1f79776b8f | ||
|
|
11e5f851f0 | ||
|
|
4ca1db8a1b | ||
|
|
14b829aa30 | ||
|
|
384652b3df | ||
|
|
469069b471 | ||
|
|
9db65c6ae9 | ||
|
|
1346e33e99 | ||
|
|
ab9cc447aa | ||
|
|
cb63c12d2f | ||
|
|
fe9e0444b4 | ||
|
|
6ce0fd20ce | ||
|
|
a18957dbe9 | ||
|
|
13d5b724ee | ||
|
|
b383cd9493 | ||
|
|
c7d8203da9 | ||
|
|
96b5c1d8e1 | ||
|
|
882ee80424 | ||
|
|
e977771fe4 | ||
|
|
4339e4552e | ||
|
|
9bca5912d9 | ||
|
|
b54d222943 | ||
|
|
23756ba1c7 | ||
|
|
e4e613550a | ||
|
|
d1207444db | ||
|
|
06f060161d | ||
|
|
73e0628124 | ||
|
|
7393c4170b | ||
|
|
73e185bf9d | ||
|
|
0bad75b263 | ||
|
|
74b98083e2 | ||
|
|
9034b5ec11 | ||
|
|
77153c3e78 | ||
|
|
927f557672 | ||
|
|
86fb089901 | ||
|
|
630ea05e17 | ||
|
|
7df5196083 | ||
|
|
01f7b5d709 | ||
|
|
07227887f6 | ||
|
|
ec47ee3573 | ||
|
|
13d3b103f1 | ||
|
|
7062962cc8 | ||
|
|
fde447846a | ||
|
|
319cb1bd1e | ||
|
|
58cda5ae6d | ||
|
|
251a3db880 | ||
|
|
30b6dcd767 | ||
|
|
05f6622912 | ||
|
|
36183ac19d | ||
|
|
f6a823e0a8 | ||
|
|
312353551d | ||
|
|
4bdfd0e115 | ||
|
|
fd5c9cee38 | ||
|
|
84bf71802c | ||
|
|
786b20708e | ||
|
|
35739c2eef | ||
|
|
1914a71623 | ||
|
|
dcc53886d9 | ||
|
|
21ef87ef09 | ||
|
|
0e957cad84 | ||
|
|
b67f808da9 | ||
|
|
ad69447b53 | ||
|
|
b4614df88c | ||
|
|
7171247cdc | ||
|
|
6d0084f108 | ||
|
|
29359f42ae | ||
|
|
cf875bf872 | ||
|
|
13c0d335d3 | ||
|
|
ceb33409b5 | ||
|
|
83597d4a8b | ||
|
|
81eefc5448 | ||
|
|
082bc3ece4 | ||
|
|
b2406b61fb | ||
|
|
15698d7694 | ||
|
|
990cd82f97 | ||
|
|
c87829b3e8 | ||
|
|
6799c41d65 | ||
|
|
80c059be58 | ||
|
|
aa3f896538 | ||
|
|
85c728f313 | ||
|
|
d8c17a8a5e | ||
|
|
50e210b2db | ||
|
|
850939367c | ||
|
|
bf4fef9bf7 | ||
|
|
d5175961a4 | ||
|
|
ba3fb8cd66 | ||
|
|
e7e1d6a232 | ||
|
|
712345f3a0 | ||
|
|
54c9bc3dcb | ||
|
|
e796c0da4a | ||
|
|
cf8ff0f43e | ||
|
|
e67ce23a7c | ||
|
|
d9fb7dc754 | ||
|
|
a66bb95a81 | ||
|
|
2249dad9d7 | ||
|
|
c66fa33b2e | ||
|
|
5c4fa630ae | ||
|
|
56eebb9db4 | ||
|
|
ede74ad24e | ||
|
|
d9773f107e | ||
|
|
27542a8f91 | ||
|
|
5dc07b94aa | ||
|
|
e09112f46a | ||
|
|
d7acf721ae | ||
|
|
50a17a82b6 | ||
|
|
eff5232828 | ||
|
|
7eb032d646 | ||
|
|
3eb29b1cdb | ||
|
|
e065f22f8e | ||
|
|
c1b4ba1f85 | ||
|
|
eeaec471f0 | ||
|
|
0d3c8678d8 | ||
|
|
bbddf5f95b | ||
|
|
3b8c8b3af9 | ||
|
|
84753aa13f | ||
|
|
90b84451d8 | ||
|
|
54c8ae41cc | ||
|
|
7d32b1a724 | ||
|
|
69ffd63ca6 | ||
|
|
4857c19eb6 | ||
|
|
d535e23da0 | ||
|
|
30e02544ab | ||
|
|
ee53925bd2 | ||
|
|
c9961f63b4 | ||
|
|
40495b8a17 | ||
|
|
b1de98f05d | ||
|
|
6bc9a82a7a | ||
|
|
09e843a800 | ||
|
|
6504ee37bd | ||
|
|
082bff2fa8 | ||
|
|
ab7bd86336 | ||
|
|
eada0b0bb5 | ||
|
|
f221f9f22a | ||
|
|
6731e44a0d | ||
|
|
acc37045e4 | ||
|
|
a7c5899c16 | ||
|
|
80b02635a9 | ||
|
|
f90de5ec67 | ||
|
|
9a3e046530 | ||
|
|
7f56e461fe | ||
|
|
1da37e0d38 | ||
|
|
0004d4936c | ||
|
|
7a6fdc4e0a | ||
|
|
2eb727bd0c | ||
|
|
57af507170 | ||
|
|
e37f87465c | ||
|
|
324070f345 | ||
|
|
e1aa843b6d | ||
|
|
e652a7fd61 | ||
|
|
2397bfbad0 | ||
|
|
7e2bc8e452 | ||
|
|
00e8fd0483 | ||
|
|
6d8bf2c665 | ||
|
|
77b79dbd95 | ||
|
|
72466f1aab | ||
|
|
dafc6c5136 | ||
|
|
6901deccbf | ||
|
|
5a9c906eb9 | ||
|
|
b95b60b49e | ||
|
|
14408ef18f | ||
|
|
c790147a5c | ||
|
|
6b87c90e02 | ||
|
|
80c39c5ef3 | ||
|
|
2b4d5222eb | ||
|
|
9604ecebad | ||
|
|
9a3e84d84c | ||
|
|
0d67970a45 | ||
|
|
913b9f0c40 | ||
|
|
610a5745f0 | ||
|
|
dff12324c6 | ||
|
|
f340390fc8 | ||
|
|
643960c829 | ||
|
|
be81e74921 | ||
|
|
1737018325 | ||
|
|
2bee8729e4 | ||
|
|
484d5ba76e | ||
|
|
798685d0b8 | ||
|
|
cb7654ae90 | ||
|
|
039564e74c | ||
|
|
e164595a0f | ||
|
|
d29e09a3ff | ||
|
|
00c394345a | ||
|
|
dffcb62fa1 | ||
|
|
8c668b72b7 | ||
|
|
b54ecd4da0 | ||
|
|
87a7e3501b | ||
|
|
daefec3013 | ||
|
|
183a9742c4 | ||
|
|
04b83f8176 | ||
|
|
335ab3f064 | ||
|
|
7dd493da35 | ||
|
|
560bd6da92 | ||
|
|
a5824ccc5f | ||
|
|
830a7964a4 | ||
|
|
b1359c3277 | ||
|
|
0ba8f5cc5a | ||
|
|
6fb9e2c38e | ||
|
|
eebc2ab8be | ||
|
|
b65b3151ee | ||
|
|
1d24b7985b | ||
|
|
526bb2c650 | ||
|
|
c450c0ddb8 | ||
|
|
13a0f49f5f | ||
|
|
199eefafa1 | ||
|
|
c5b58f9ecc | ||
|
|
6b68fe4de6 | ||
|
|
3461bbfdb3 | ||
|
|
51f6927076 | ||
|
|
4298aad008 | ||
|
|
823c67400d | ||
|
|
3160d1064d | ||
|
|
1d88cf443f | ||
|
|
7b6c0c3a40 | ||
|
|
fdb0651bf4 | ||
|
|
c39d484611 | ||
|
|
c42996429f | ||
|
|
a091baf5a6 | ||
|
|
918426a2fa | ||
|
|
c076b37c9b | ||
|
|
7c58bfa282 | ||
|
|
0caaba156d | ||
|
|
c22575812d | ||
|
|
0ede4da816 | ||
|
|
98e23ff92e | ||
|
|
00a17cd55e | ||
|
|
643d44af22 | ||
|
|
b934f43db0 | ||
|
|
c7bdad649a | ||
|
|
18c2508d2f | ||
|
|
4dcfd8b353 | ||
|
|
726116574d | ||
|
|
27f02014ca | ||
|
|
f80f1acaa7 | ||
|
|
39d5ffeceb | ||
|
|
48ba7eed3e | ||
|
|
f39afe5a65 | ||
|
|
7612ee6b08 | ||
|
|
2ed2b0101a | ||
|
|
5ca9d31964 | ||
|
|
2fcd8cd261 | ||
|
|
0ffa47a2c6 | ||
|
|
9caa240fdb | ||
|
|
3ffb73a516 | ||
|
|
cc1132be87 | ||
|
|
1c31f126ef | ||
|
|
d8eaf2676f | ||
|
|
e203d4dee3 | ||
|
|
b47d773e13 | ||
|
|
a8d0a4a95d | ||
|
|
3fb0804cef | ||
|
|
6811ebcd52 | ||
|
|
4fe7bfb851 | ||
|
|
fb60985d03 | ||
|
|
8f575923cf | ||
|
|
0ecfd02649 | ||
|
|
420aaf4f61 | ||
|
|
0c35f213e1 | ||
|
|
f68813af13 | ||
|
|
37a90d0ce9 | ||
|
|
02f1291e8f | ||
|
|
92e4f6b5d9 | ||
|
|
7b7738fbcc | ||
|
|
3101212c49 | ||
|
|
3f0ac103a1 | ||
|
|
59bd6ca360 | ||
|
|
22fe9a786e | ||
|
|
31197604a3 | ||
|
|
d2ee8de9ac | ||
|
|
03d3fb6a5f | ||
|
|
e33b1b6c90 | ||
|
|
30520297e8 | ||
|
|
78ca1d1335 | ||
|
|
6159ee8c2c | ||
|
|
5cd5392958 | ||
|
|
0dcdfc5d14 | ||
|
|
d0e068f1c0 | ||
|
|
f42a2d7457 | ||
|
|
d29619b67c | ||
|
|
f5235cb835 | ||
|
|
ee830e0cb4 | ||
|
|
0cd3be003d | ||
|
|
c93e35ec77 | ||
|
|
9538a76232 | ||
|
|
05876bb124 | ||
|
|
8bcd5a6d2a | ||
|
|
a36afbcb25 | ||
|
|
ebd8d085cf | ||
|
|
505148b024 | ||
|
|
3eefeec4ce | ||
|
|
b61419c1ce | ||
|
|
f590fcffbc | ||
|
|
e87e924ac2 | ||
|
|
90f261bab6 | ||
|
|
f7dfb09a4d | ||
|
|
3135917127 | ||
|
|
52afa3d36d | ||
|
|
242aa60e04 | ||
|
|
7a3c2c27ff | ||
|
|
5d124360c2 | ||
|
|
365d7448d5 | ||
|
|
9a0102c723 | ||
|
|
2f77f2cb2b | ||
|
|
528e3a2106 | ||
|
|
032a664d4c | ||
|
|
aac1864c9b | ||
|
|
e3477f3306 | ||
|
|
6620a4f87b | ||
|
|
c0e9dff5bf | ||
|
|
2d961c435a | ||
|
|
7c95f03166 | ||
|
|
31e5c13b50 | ||
|
|
4a9fe4f981 | ||
|
|
4fcc5587ee | ||
|
|
6ca49a20ce | ||
|
|
28f293fdc1 | ||
|
|
b3e7619adc | ||
|
|
6e56d56137 | ||
|
|
2528f6a07b | ||
|
|
423d07c919 | ||
|
|
cc608de4bf | ||
|
|
f999a68608 | ||
|
|
db78a9f18f | ||
|
|
816039f48e | ||
|
|
ae240bae6d | ||
|
|
9e30c69e6d | ||
|
|
43c7de9049 | ||
|
|
7e51c5db81 | ||
|
|
0ee3c45e7b | ||
|
|
981e69929c | ||
|
|
1eae5d12fc | ||
|
|
8863208333 | ||
|
|
5f38a74a72 | ||
|
|
fe15dacb1f | ||
|
|
c2d44cf2f2 | ||
|
|
7f1bdb6f34 | ||
|
|
7cdfaa93ec | ||
|
|
59ccc70303 | ||
|
|
f1584b722d | ||
|
|
b0305e12d2 | ||
|
|
4d8c5a86a4 | ||
|
|
58f76b5c99 | ||
|
|
7c4ee632cf | ||
|
|
b6b0f716eb | ||
|
|
bd0e04ed15 | ||
|
|
8599981d44 | ||
|
|
6fc6e95c67 | ||
|
|
43b585bde8 | ||
|
|
710f89291f | ||
|
|
5f835aa009 | ||
|
|
d5ca543719 | ||
|
|
4c6249eb9e | ||
|
|
016900bad8 | ||
|
|
2e8ae33761 | ||
|
|
0d325060da | ||
|
|
1a6e98e18f | ||
|
|
97e34595f6 | ||
|
|
a179d5234b | ||
|
|
64c6121fdb | ||
|
|
08d8954a85 | ||
|
|
4f20955d0d | ||
|
|
3a703c8bcf | ||
|
|
ccbffa086b | ||
|
|
07ee4be840 | ||
|
|
4cc9b2d312 | ||
|
|
24dddae1d1 | ||
|
|
ad0165d085 | ||
|
|
39dc38c5d1 | ||
|
|
046ce19dbb | ||
|
|
33263f5a93 | ||
|
|
8ef8e76300 | ||
|
|
73cfdae9e7 | ||
|
|
54a3e41281 | ||
|
|
d59ba6da84 | ||
|
|
1b28b06934 | ||
|
|
ff3e69a56c | ||
|
|
6b975a5fb4 | ||
|
|
3a02b15124 | ||
|
|
5f73d81935 | ||
|
|
002b5c0f6f | ||
|
|
8086842570 | ||
|
|
51f2d5a664 | ||
|
|
db63ad1cf4 | ||
|
|
b74b76de75 | ||
|
|
a1b1498106 | ||
|
|
1158851ea7 | ||
|
|
e1ab9e959e | ||
|
|
2bbac3ae9d | ||
|
|
e889b1d5e5 | ||
|
|
233bf856f4 | ||
|
|
bca843e06c | ||
|
|
30a79a1278 | ||
|
|
0f92dee2c4 | ||
|
|
f04efede15 | ||
|
|
f0dfdf6720 | ||
|
|
e26d731382 | ||
|
|
d684d3e559 | ||
|
|
47c54cb998 | ||
|
|
592cb2b3ec | ||
|
|
f5a7871a2e | ||
|
|
ec411fa0db | ||
|
|
5da79cd5ca | ||
|
|
a850a9bb83 | ||
|
|
13c971b171 | ||
|
|
1cee7e43ed | ||
|
|
5e81c63d6e | ||
|
|
479b7a3f94 | ||
|
|
f7cfee77c9 | ||
|
|
65a8126a13 | ||
|
|
a39bc102d5 | ||
|
|
81d930c4d2 | ||
|
|
6839623061 | ||
|
|
7de2809d42 | ||
|
|
98ec6b6886 | ||
|
|
04827f00cc | ||
|
|
660bfc6578 | ||
|
|
1152cd5537 | ||
|
|
17456482d6 | ||
|
|
a0431e1912 | ||
|
|
f30e8497b2 | ||
|
|
06495bc45d | ||
|
|
26067916b3 | ||
|
|
c36ee4852b | ||
|
|
2cb992ad44 | ||
|
|
ee5aac8008 | ||
|
|
083b7be6c0 | ||
|
|
e24854558f | ||
|
|
e4314cf426 | ||
|
|
4106e4e45c | ||
|
|
05f143db2b | ||
|
|
64aeaeeeea | ||
|
|
61db37ab0d | ||
|
|
f9c4d921e7 | ||
|
|
ca099df573 | ||
|
|
28b584b8bc | ||
|
|
70449e694d | ||
|
|
8395ea552d | ||
|
|
dc66452633 | ||
|
|
53ce44ac91 | ||
|
|
c7c3243bbc | ||
|
|
8bdd77d33d | ||
|
|
acd7d0db3a | ||
|
|
2bfadb8a3c | ||
|
|
0912e4af7b | ||
|
|
5aa5c48018 | ||
|
|
8cdd998f79 | ||
|
|
050d4d6b25 | ||
|
|
366cd11238 | ||
|
|
58d6443331 | ||
|
|
101b8afb56 | ||
|
|
5df5c47945 | ||
|
|
a04740ba86 | ||
|
|
425ad93ac5 | ||
|
|
8a44144c20 | ||
|
|
ee82c70582 | ||
|
|
c87e8e606b | ||
|
|
37a50dd953 | ||
|
|
a2669a3084 | ||
|
|
77da22f4dd | ||
|
|
7830ffe202 | ||
|
|
1c9e20d59f | ||
|
|
320edac286 | ||
|
|
d49878371d | ||
|
|
d2575a5d9b | ||
|
|
ea6cf72580 | ||
|
|
2118155b37 | ||
|
|
ba4f5bb71f | ||
|
|
d5a74a5a8b | ||
|
|
23be1df360 | ||
|
|
b5c1a1da4c | ||
|
|
c11e784f51 | ||
|
|
06f51c8f9c | ||
|
|
181bcbbda6 | ||
|
|
d008ead6a4 | ||
|
|
75924be958 | ||
|
|
b1a6e3f8a2 | ||
|
|
06712a6041 | ||
|
|
62b16339a9 | ||
|
|
9a2f1a36ba | ||
|
|
95cc4d3a73 | ||
|
|
497eeeb2e0 | ||
|
|
4be21ca249 | ||
|
|
e8598e214e | ||
|
|
54b1d65e3c | ||
|
|
f7648496d3 | ||
|
|
59a57c7197 | ||
|
|
5659b26827 | ||
|
|
ee4443aaf0 | ||
|
|
839dcad358 | ||
|
|
d67933ab49 | ||
|
|
0eb3f6b952 | ||
|
|
68b0f80fce | ||
|
|
93489529a3 | ||
|
|
511be74e74 | ||
|
|
bdee067803 | ||
|
|
32156cace3 | ||
|
|
30688114be | ||
|
|
34088bcc17 | ||
|
|
07835766cc | ||
|
|
251851ec6a | ||
|
|
049a669186 | ||
|
|
d29f13bae9 | ||
|
|
c758355df9 | ||
|
|
79d97a83af | ||
|
|
85bd47c240 | ||
|
|
473ead9616 | ||
|
|
cf2850933c | ||
|
|
ff2564c57a | ||
|
|
91d3848246 | ||
|
|
c031f0b45e | ||
|
|
fdbb9568ae | ||
|
|
d817883459 | ||
|
|
12255979ac | ||
|
|
366b61850b | ||
|
|
89be6bd183 | ||
|
|
e120331a2c | ||
|
|
cb8a212d96 | ||
|
|
7aec431ac5 | ||
|
|
d19681dea1 | ||
|
|
bf2299daf8 | ||
|
|
164930d0dd | ||
|
|
387dbac809 | ||
|
|
3b661e5a99 | ||
|
|
90c1c0e655 | ||
|
|
21d8e7695b | ||
|
|
1acc452cfe | ||
|
|
1375e1feee | ||
|
|
2187adf59a | ||
|
|
0dcb315d9d | ||
|
|
327ccbd0c9 | ||
|
|
f571d400e6 | ||
|
|
293aa52335 | ||
|
|
ca178ae9a7 | ||
|
|
d0c810e418 | ||
|
|
d496d2caeb | ||
|
|
e70b75c350 | ||
|
|
a50befeda5 | ||
|
|
e2616e8039 | ||
|
|
904266debe | ||
|
|
72d5783795 | ||
|
|
d699fb1473 | ||
|
|
fab1a6c33a | ||
|
|
be73c30194 | ||
|
|
451646fe4f | ||
|
|
decc919991 | ||
|
|
e0b4005921 | ||
|
|
3ef36e7534 | ||
|
|
1949e1e1e9 | ||
|
|
3358382358 | ||
|
|
3eca3ecd75 | ||
|
|
140c6b91b0 | ||
|
|
a5315ec240 | ||
|
|
93f1656e0b | ||
|
|
f1d006c236 | ||
|
|
b0b5a96694 | ||
|
|
7dbe9a85f4 | ||
|
|
d2c39528d5 | ||
|
|
0420543c94 | ||
|
|
aae0db902b | ||
|
|
88dae7cef7 | ||
|
|
e5cb17e934 | ||
|
|
9d609805f2 | ||
|
|
e2b9ca8254 | ||
|
|
e16a2fe8af | ||
|
|
22d61a533d | ||
|
|
af408bb45f | ||
|
|
24bfbc06f0 | ||
|
|
5eb9f353b5 | ||
|
|
473ce15f47 | ||
|
|
eb9cfbaed6 | ||
|
|
faeb037ff9 | ||
|
|
07602f697d | ||
|
|
11abb0fdb1 | ||
|
|
deeb2fa543 | ||
|
|
ef8d5ff11e | ||
|
|
91f3e07b83 | ||
|
|
c29bdbdacb | ||
|
|
a20d104d2f | ||
|
|
a61dd8ac17 | ||
|
|
7ee9a690ea | ||
|
|
5ba94c6c41 | ||
|
|
9fa855c837 | ||
|
|
9251007574 | ||
|
|
cc73b984cb | ||
|
|
548ef97c32 | ||
|
|
ed8a486726 | ||
|
|
1ab0911fc8 | ||
|
|
bdbaea7294 | ||
|
|
5cfd1f6fb2 | ||
|
|
5eda67381f | ||
|
|
2c8b8bfaf2 | ||
|
|
8f3159751a | ||
|
|
4b05e55b29 | ||
|
|
3d3c13fcd0 | ||
|
|
88e1d8a8cf | ||
|
|
e007db34e2 | ||
|
|
f9f06d2c02 | ||
|
|
234f7d00c8 | ||
|
|
9924553da5 | ||
|
|
df38d7e3ed | ||
|
|
44dd061619 | ||
|
|
7603a932b1 | ||
|
|
138e7acc13 | ||
|
|
e863d3e7e5 | ||
|
|
c8e401f5ed | ||
|
|
3ba20a8e28 | ||
|
|
ebae63752f | ||
|
|
8bc73901cf | ||
|
|
b4f70d9244 | ||
|
|
21e9f2bba3 | ||
|
|
881f4e3d6a | ||
|
|
b141945add |
@@ -3206,7 +3206,8 @@
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/3755203?v=4",
|
||||
"profile": "https://github.com/swift2512",
|
||||
"contributions": [
|
||||
"bug"
|
||||
"bug",
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
163
.github/ISSUE_TEMPLATE/Bug-Report.yml
vendored
Normal file
163
.github/ISSUE_TEMPLATE/Bug-Report.yml
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
name: Bug Report
|
||||
description: File a bug report.
|
||||
title: "[Bug]: "
|
||||
projects: ["grokability/snipe-it"]
|
||||
type: bug
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this bug report! Most issues are documented in the [Snipe-IT repository's issues](https://github.com/grokability/snipe-it/issues) or in the official [Common Issues section of the Documentation](https://snipe-it.readme.io/docs/common-issues#/) and are due to the following:
|
||||
|
||||
- `.env` misconfiguration
|
||||
- [Server Permissions](https://snipe-it.readme.io/docs/debugging-permissions#/)
|
||||
- [Database Migrations](https://snipe-it.readme.io/docs/database-issues#run-migrations)
|
||||
|
||||
Please make sure you've checked these resources before submitting a new issue. If you find an existing issue, please add your context to it instead of opening a new issue. If your issue is more of a question, consider [opening a new discussion](https://github.com/grokability/snipe-it/discussions) or [pop by our Discord](https://discord.gg/yZFtShAcKk) instead of creating an issue.
|
||||
|
||||
**Please write your bug report in English.** You can use tools like [DeepL](https://www.deepl.com) or [Google Translate](https://translate.google.com/) to translate if necessary.
|
||||
|
||||
**If you choose to upload screenshots or videos (which we always encourage), please make sure they do not contain any sensitive information.**
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Snipe-IT Version
|
||||
description: What version of Snipe-IT are you seeing this issue on? You can find the version number in the footer of any page in Snipe-IT.
|
||||
placeholder: ex. v8.3.2 - build 19577 (master)
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: php-version
|
||||
attributes:
|
||||
label: PHP Version
|
||||
description: What version of PHP are you running? You can find the version of PHP your webserver is running in the `Admin Settings` section in the footer, and the cli version by running `php -v` via command line .
|
||||
placeholder: ex. v8.3.1 (web), PHP 8.4.12 (cli)
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: composer-version
|
||||
attributes:
|
||||
label: Composer Version
|
||||
description: What version of composer are you running? You can find the version number by running `composer --version`.
|
||||
placeholder: ex. 2.8.10
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: db-version
|
||||
attributes:
|
||||
label: MySQL/MariaDB version
|
||||
description: What database are you using, and what version?
|
||||
placeholder: ex. MySQL 5.7
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: install-method
|
||||
attributes:
|
||||
label: How did you install Snipe-IT?
|
||||
options:
|
||||
- Git install
|
||||
- Manual install (downloading zip/tar.gz)
|
||||
- Docker
|
||||
- install.sh
|
||||
- Hosted by Grokability
|
||||
- Other
|
||||
- Not sure
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: upgrade-or-fresh
|
||||
attributes:
|
||||
label: Is this a fresh install or an upgrade?
|
||||
options:
|
||||
- Fresh install
|
||||
- Upgrade
|
||||
- NA
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: what-happened
|
||||
attributes:
|
||||
label: What happened?
|
||||
description: Also tell us, what did you expect to happen?
|
||||
placeholder: Tell us what you see! (Be nice!)
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: browsers
|
||||
attributes:
|
||||
label: What browsers are you seeing the problem on?
|
||||
multiple: true
|
||||
options:
|
||||
- Firefox
|
||||
- Chrome
|
||||
- Safari
|
||||
- Microsoft Edge
|
||||
- Other
|
||||
- type: dropdown
|
||||
id: on-demo
|
||||
attributes:
|
||||
label: Can you reproduce this on the public demo?
|
||||
description: You can check this at https://demo.snipeitapp.com.
|
||||
options:
|
||||
- 'Yes'
|
||||
- 'No'
|
||||
- N/A
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: fmcs
|
||||
attributes:
|
||||
label: Do you have full multiple company support enabled?
|
||||
description: You can check this in your Snipe-IT installation at `Admin Settings > General Settings > Scoping`.
|
||||
options:
|
||||
- 'Yes'
|
||||
- 'No'
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: fmcs-location
|
||||
attributes:
|
||||
label: If you have full multiple company support enabled, do you have location scoping to company enabled?
|
||||
description: You can check this in your Snipe-IT installation at `Admin Settings > General Settings > Scoping`.
|
||||
options:
|
||||
- 'Yes'
|
||||
- 'No'
|
||||
- I do not have full multiple company support enabled
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: server-logs
|
||||
attributes:
|
||||
label: Application log output
|
||||
description: Please copy and paste any relevant log output from `storage/logs/laravel.log`. This will be automatically formatted into code, so no need for backticks.
|
||||
render: shell
|
||||
- type: textarea
|
||||
id: browser-logs
|
||||
attributes:
|
||||
label: Browser console output
|
||||
description: Please copy and paste any relevant log output from your browser console. This will be automatically formatted into code, so no need for backticks.
|
||||
render: shell
|
||||
- type: checkboxes
|
||||
id: common-issues
|
||||
attributes:
|
||||
label: Common Issues
|
||||
description: Please make sure you have done the following before submitting your issue.
|
||||
options:
|
||||
- label: I have searched this repo for existing issues related to my issue (including closed issues)
|
||||
required: true
|
||||
- label: My APP_URL is set correctly in my .env file (including http or https and no trailing slash)
|
||||
required: true
|
||||
- label: I have searched the official Snipe-IT documentation and have checked the Common Issues documentation (where applicable)
|
||||
required: true
|
||||
- label: I have run database migrations (where applicable).
|
||||
required: true
|
||||
- label: I have attached screenshots and/or videos of the issue (where applicable)
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: terms
|
||||
attributes:
|
||||
label: Code of Conduct
|
||||
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/grokability/snipe-it/blob/master/CODE_OF_CONDUCT.md).
|
||||
options:
|
||||
- label: I agree to follow this project's Code of Conduct
|
||||
required: true
|
||||
38
.github/ISSUE_TEMPLATE/Feature-Request.yml
vendored
Normal file
38
.github/ISSUE_TEMPLATE/Feature-Request.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
name: Feature Request
|
||||
description: Request a new feature.
|
||||
title: "[Feature]: "
|
||||
projects: ["grokability/snipe-it"]
|
||||
type: feature
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this feature request! Please make sure to search the existing issues in this repository to see if your feature has already been requested, and feel free to add your context to any existing requests.
|
||||
|
||||
**Please write your issue in English.** You can use tools like [DeepL](https://www.deepl.com) or [Google Translate](https://translate.google.com/) to translate if necessary.
|
||||
|
||||
**If you choose to upload screenshots or videos (which we always encourage), please make sure they do not contain any sensitive information.**
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Snipe-IT Version
|
||||
description: What version of Snipe-IT are you currently running? You can find the version number in the footer of any page in Snipe-IT.
|
||||
placeholder: ex. v8.3.1 - build 19577 (master)
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: feature-description
|
||||
attributes:
|
||||
label: How can we help?
|
||||
description: Let us know in detail what feature you'd like to see added. While we can't promise to implement every feature request, we do read every one and take them into consideration when planning future releases.
|
||||
placeholder: Tell us what you'd like to see in Snipe-IT! (Be nice!)
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: terms
|
||||
attributes:
|
||||
label: Code of Conduct
|
||||
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/grokability/snipe-it/blob/master/CODE_OF_CONDUCT.md).
|
||||
options:
|
||||
- label: I agree to follow this project's Code of Conduct
|
||||
required: true
|
||||
6
.github/workflows/SA-codeql.yml
vendored
6
.github/workflows/SA-codeql.yml
vendored
@@ -30,10 +30,10 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
uses: github/codeql-action/init@v4
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v3
|
||||
uses: github/codeql-action/autobuild@v4
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
uses: github/codeql-action/analyze@v4
|
||||
|
||||
2
.github/workflows/codacy-analysis.yml
vendored
2
.github/workflows/codacy-analysis.yml
vendored
@@ -52,6 +52,6 @@ jobs:
|
||||
|
||||
# Upload the SARIF file generated in the previous step
|
||||
- name: Upload SARIF results file
|
||||
uses: github/codeql-action/upload-sarif@v3
|
||||
uses: github/codeql-action/upload-sarif@v4
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
2
.github/workflows/stale.yml
vendored
2
.github/workflows/stale.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
issues: write
|
||||
# pull-requests: write
|
||||
steps:
|
||||
- uses: actions/stale@v9
|
||||
- uses: actions/stale@v10
|
||||
with:
|
||||
debug-only: true
|
||||
ascending: true
|
||||
|
||||
@@ -52,7 +52,7 @@ Thanks goes to all of these wonderful people ([emoji key](https://github.com/ken
|
||||
| [<img src="https://avatars.githubusercontent.com/u/2565989?v=4" width="110px;"/><br /><sub>coach1988</sub>](https://github.com/coach1988)<br />[💻](https://github.com/snipe/snipe-it/commits?author=coach1988 "Code") | [<img src="https://avatars.githubusercontent.com/u/11910225?v=4" width="110px;"/><br /><sub>MrM</sub>](https://github.com/mauro-miatello)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mauro-miatello "Code") | [<img src="https://avatars.githubusercontent.com/u/60405354?v=4" width="110px;"/><br /><sub>koiakoia</sub>](https://github.com/koiakoia)<br />[💻](https://github.com/snipe/snipe-it/commits?author=koiakoia "Code") | [<img src="https://avatars.githubusercontent.com/u/5323832?v=4" width="110px;"/><br /><sub>Mustafa Online</sub>](https://github.com/mustafa-online)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mustafa-online "Code") | [<img src="https://avatars.githubusercontent.com/u/104601439?v=4" width="110px;"/><br /><sub>franceslui</sub>](https://github.com/franceslui)<br />[💻](https://github.com/snipe/snipe-it/commits?author=franceslui "Code") | [<img src="https://avatars.githubusercontent.com/u/125313163?v=4" width="110px;"/><br /><sub>Q4kK</sub>](https://github.com/Q4kK)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Q4kK "Code") | [<img src="https://avatars.githubusercontent.com/u/55590532?v=4" width="110px;"/><br /><sub>squintfox</sub>](https://github.com/squintfox)<br />[💻](https://github.com/snipe/snipe-it/commits?author=squintfox "Code") |
|
||||
| [<img src="https://avatars.githubusercontent.com/u/1380084?v=4" width="110px;"/><br /><sub>Jeff Clay</sub>](https://github.com/jeffclay)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jeffclay "Code") | [<img src="https://avatars.githubusercontent.com/u/52716446?v=4" width="110px;"/><br /><sub>Phil J R</sub>](https://github.com/PP-JN-RL)<br />[💻](https://github.com/snipe/snipe-it/commits?author=PP-JN-RL "Code") | [<img src="https://avatars.githubusercontent.com/u/1496725?v=4" width="110px;"/><br /><sub>i_virus</sub>](https://www.corelight.com/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=chandanchowdhury "Code") | [<img src="https://avatars.githubusercontent.com/u/1020541?v=4" width="110px;"/><br /><sub>Paul Grime</sub>](https://github.com/gitgrimbo)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gitgrimbo "Code") | [<img src="https://avatars.githubusercontent.com/u/922815?v=4" width="110px;"/><br /><sub>Lee Porte</sub>](https://leeporte.co.uk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=LeePorte "Code") | [<img src="https://avatars.githubusercontent.com/u/23613427?v=4" width="110px;"/><br /><sub>BRYAN </sub>](https://github.com/bryanlopezinc)<br />[💻](https://github.com/snipe/snipe-it/commits?author=bryanlopezinc "Code") [⚠️](https://github.com/snipe/snipe-it/commits?author=bryanlopezinc "Tests") | [<img src="https://avatars.githubusercontent.com/u/64061710?v=4" width="110px;"/><br /><sub>U-H-T</sub>](https://github.com/U-H-T)<br />[💻](https://github.com/snipe/snipe-it/commits?author=U-H-T "Code") |
|
||||
| [<img src="https://avatars.githubusercontent.com/u/5395363?v=4" width="110px;"/><br /><sub>Matt Tyree</sub>](https://github.com/Tyree)<br />[📖](https://github.com/snipe/snipe-it/commits?author=Tyree "Documentation") | [<img src="https://avatars.githubusercontent.com/u/292081?v=4" width="110px;"/><br /><sub>Florent Bervas</sub>](http://spoontux.net)<br />[💻](https://github.com/snipe/snipe-it/commits?author=FlorentDotMe "Code") | [<img src="https://avatars.githubusercontent.com/u/4498077?v=4" width="110px;"/><br /><sub>Daniel Albertsen</sub>](https://ditscheri.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=dbakan "Code") | [<img src="https://avatars.githubusercontent.com/u/100710244?v=4" width="110px;"/><br /><sub>r-xyz</sub>](https://github.com/r-xyz)<br />[💻](https://github.com/snipe/snipe-it/commits?author=r-xyz "Code") | [<img src="https://avatars.githubusercontent.com/u/47491036?v=4" width="110px;"/><br /><sub>Steven Mainor</sub>](https://github.com/DrekiDegga)<br />[💻](https://github.com/snipe/snipe-it/commits?author=DrekiDegga "Code") | [<img src="https://avatars.githubusercontent.com/u/65785975?v=4" width="110px;"/><br /><sub>arne-kroeger</sub>](https://github.com/arne-kroeger)<br />[💻](https://github.com/snipe/snipe-it/commits?author=arne-kroeger "Code") | [<img src="https://avatars.githubusercontent.com/u/167117705?v=4" width="110px;"/><br /><sub>Glukose1</sub>](https://github.com/Glukose1)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Glukose1 "Code") |
|
||||
| [<img src="https://avatars.githubusercontent.com/u/1197791?v=4" width="110px;"/><br /><sub>Scarzy</sub>](https://github.com/Scarzy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Scarzy "Code") | [<img src="https://avatars.githubusercontent.com/u/37372069?v=4" width="110px;"/><br /><sub>setpill</sub>](https://github.com/setpill)<br />[💻](https://github.com/snipe/snipe-it/commits?author=setpill "Code") | [<img src="https://avatars.githubusercontent.com/u/3755203?v=4" width="110px;"/><br /><sub>swift2512</sub>](https://github.com/swift2512)<br />[🐛](https://github.com/snipe/snipe-it/issues?q=author%3Aswift2512 "Bug reports") | [<img src="https://avatars.githubusercontent.com/u/6136439?v=4" width="110px;"/><br /><sub>Darren Rainey</sub>](https://darrenraineys.co.uk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=DarrenRainey "Code") | [<img src="https://avatars.githubusercontent.com/u/133033121?v=4" width="110px;"/><br /><sub>maciej-poleszczyk</sub>](https://github.com/maciej-poleszczyk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=maciej-poleszczyk "Code") | [<img src="https://avatars.githubusercontent.com/u/143394709?v=4" width="110px;"/><br /><sub>Sebastian Groß</sub>](https://github.com/sgross-emlix)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sgross-emlix "Code") | [<img src="https://avatars.githubusercontent.com/u/41107778?v=4" width="110px;"/><br /><sub>Anouar Touati</sub>](https://github.com/AnouarTouati)<br />[💻](https://github.com/snipe/snipe-it/commits?author=AnouarTouati "Code") |
|
||||
| [<img src="https://avatars.githubusercontent.com/u/1197791?v=4" width="110px;"/><br /><sub>Scarzy</sub>](https://github.com/Scarzy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Scarzy "Code") | [<img src="https://avatars.githubusercontent.com/u/37372069?v=4" width="110px;"/><br /><sub>setpill</sub>](https://github.com/setpill)<br />[💻](https://github.com/snipe/snipe-it/commits?author=setpill "Code") | [<img src="https://avatars.githubusercontent.com/u/3755203?v=4" width="110px;"/><br /><sub>swift2512</sub>](https://github.com/swift2512)<br />[🐛](https://github.com/snipe/snipe-it/issues?q=author%3Aswift2512 "Bug reports") [💻](https://github.com/snipe/snipe-it/commits?author=swift2512 "Code") | [<img src="https://avatars.githubusercontent.com/u/6136439?v=4" width="110px;"/><br /><sub>Darren Rainey</sub>](https://darrenraineys.co.uk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=DarrenRainey "Code") | [<img src="https://avatars.githubusercontent.com/u/133033121?v=4" width="110px;"/><br /><sub>maciej-poleszczyk</sub>](https://github.com/maciej-poleszczyk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=maciej-poleszczyk "Code") | [<img src="https://avatars.githubusercontent.com/u/143394709?v=4" width="110px;"/><br /><sub>Sebastian Groß</sub>](https://github.com/sgross-emlix)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sgross-emlix "Code") | [<img src="https://avatars.githubusercontent.com/u/41107778?v=4" width="110px;"/><br /><sub>Anouar Touati</sub>](https://github.com/AnouarTouati)<br />[💻](https://github.com/snipe/snipe-it/commits?author=AnouarTouati "Code") |
|
||||
| [<img src="https://avatars.githubusercontent.com/u/25596663?v=4" width="110px;"/><br /><sub>aHVzY2g</sub>](https://github.com/aHVzY2g)<br />[💻](https://github.com/snipe/snipe-it/commits?author=aHVzY2g "Code") | [<img src="https://avatars.githubusercontent.com/u/13408130?v=4" width="110px;"/><br /><sub>林博仁 Buo-ren Lin</sub>](https://brlin.me)<br />[💻](https://github.com/snipe/snipe-it/commits?author=brlin-tw "Code") | [<img src="https://avatars.githubusercontent.com/u/18550946?v=4" width="110px;"/><br /><sub>Adugna Gizaw</sub>](https://orbalia.pythonanywhere.com/)<br />[🌍](#translation-addex12 "Translation") | [<img src="https://avatars.githubusercontent.com/u/760989?v=4" width="110px;"/><br /><sub>Jesse Ostrander</sub>](https://github.com/jostrander)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jostrander "Code") | [<img src="https://avatars.githubusercontent.com/u/31522486?v=4" width="110px;"/><br /><sub>James M</sub>](https://github.com/azmcnutt)<br />[💻](https://github.com/snipe/snipe-it/commits?author=azmcnutt "Code") | [<img src="https://avatars.githubusercontent.com/u/5183146?v=4" width="110px;"/><br /><sub>Fiala06</sub>](https://github.com/Fiala06)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Fiala06 "Code") | [<img src="https://avatars.githubusercontent.com/u/28693782?v=4" width="110px;"/><br /><sub>Nathan Taylor</sub>](https://github.com/ntaylor-86)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ntaylor-86 "Code") |
|
||||
| [<img src="https://avatars.githubusercontent.com/u/16699443?v=4" width="110px;"/><br /><sub>fvollmer</sub>](https://github.com/fvollmer)<br />[💻](https://github.com/snipe/snipe-it/commits?author=fvollmer "Code") | [<img src="https://avatars.githubusercontent.com/u/109086466?v=4" width="110px;"/><br /><sub>36864</sub>](https://github.com/36864)<br />[💻](https://github.com/snipe/snipe-it/commits?author=36864 "Code") | [<img src="https://avatars.githubusercontent.com/u/365751?v=4" width="110px;"/><br /><sub>Daniel O'Connor</sub>](http://clockwerx.blogspot.com/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=CloCkWeRX "Code") | [<img src="https://avatars.githubusercontent.com/u/102852568?v=4" width="110px;"/><br /><sub>BeatSpark</sub>](https://github.com/BeatSpark)<br />[💻](https://github.com/snipe/snipe-it/commits?author=BeatSpark "Code") | [<img src="https://avatars.githubusercontent.com/u/59203607?v=4" width="110px;"/><br /><sub>mrdahbi</sub>](https://github.com/mrdahbi)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mrdahbi "Code") | [<img src="https://avatars.githubusercontent.com/u/6661332?v=4" width="110px;"/><br /><sub>Fabian Schmid</sub>](http://sr.solutions)<br />[💻](https://github.com/snipe/snipe-it/commits?author=chfsx "Code") | [<img src="https://avatars.githubusercontent.com/u/1288116?v=4" width="110px;"/><br /><sub>Chris Olin</sub>](https://www.chrisolin.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=realchrisolin "Code") |
|
||||
| [<img src="https://avatars.githubusercontent.com/u/3803132?v=4" width="110px;"/><br /><sub>Dan</sub>](https://github.com/mnemonicly)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mnemonicly "Code") | [<img src="https://avatars.githubusercontent.com/u/43917728?v=4" width="110px;"/><br /><sub>Nebel</sub>](https://github.com/NebelKreis)<br />[💻](https://github.com/snipe/snipe-it/commits?author=NebelKreis "Code") | [<img src="https://avatars.githubusercontent.com/u/132433803?v=4" width="110px;"/><br /><sub>test1337ahp</sub>](https://github.com/test1337ahp)<br />[💻](https://github.com/snipe/snipe-it/commits?author=test1337ahp "Code") | [<img src="https://avatars.githubusercontent.com/u/1916566?v=4" width="110px;"/><br /><sub>Jonathon Reinhart</sub>](https://github.com/JonathonReinhart)<br />[💻](https://github.com/snipe/snipe-it/commits?author=JonathonReinhart "Code") | [<img src="https://avatars.githubusercontent.com/u/484742?v=4" width="110px;"/><br /><sub>aranar-pro</sub>](https://github.com/aranar-pro)<br />[💻](https://github.com/snipe/snipe-it/commits?author=aranar-pro "Code") | [<img src="https://avatars.githubusercontent.com/u/27019397?v=4" width="110px;"/><br /><sub>Phil</sub>](https://github.com/phil-flip)<br />[💻](https://github.com/snipe/snipe-it/commits?author=phil-flip "Code") | [<img src="https://avatars.githubusercontent.com/u/6473460?v=4" width="110px;"/><br /><sub>Steffy Fort</sub>](https://fe80.fr/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=fe80 "Code") |
|
||||
|
||||
59
app/Actions/Categories/DestroyCategoryAction.php
Normal file
59
app/Actions/Categories/DestroyCategoryAction.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Categories;
|
||||
|
||||
use App\Exceptions\ItemStillHasAccessories;
|
||||
use App\Exceptions\ItemStillHasAssetModels;
|
||||
use App\Exceptions\ItemStillHasAssets;
|
||||
use App\Exceptions\ItemStillHasComponents;
|
||||
use App\Exceptions\ItemStillHasConsumables;
|
||||
use App\Exceptions\ItemStillHasLicenses;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class DestroyCategoryAction
|
||||
{
|
||||
/**
|
||||
* @throws ItemStillHasAssets
|
||||
* @throws ItemStillHasAssetModels
|
||||
* @throws ItemStillHasComponents
|
||||
* @throws ItemStillHasAccessories
|
||||
* @throws ItemStillHasLicenses
|
||||
* @throws ItemStillHasConsumables
|
||||
*/
|
||||
static function run(Category $category): bool
|
||||
{
|
||||
$category->loadCount([
|
||||
'assets as assets_count',
|
||||
'accessories as accessories_count',
|
||||
'consumables as consumables_count',
|
||||
'components as components_count',
|
||||
'licenses as licenses_count',
|
||||
'models as models_count'
|
||||
]);
|
||||
|
||||
if ($category->assets_count > 0) {
|
||||
throw new ItemStillHasAssets($category);
|
||||
}
|
||||
if ($category->accessories_count > 0) {
|
||||
throw new ItemStillHasAccessories($category);
|
||||
}
|
||||
if ($category->consumables_count > 0) {
|
||||
throw new ItemStillHasConsumables($category);
|
||||
}
|
||||
if ($category->components_count > 0) {
|
||||
throw new ItemStillHasComponents($category);
|
||||
}
|
||||
if ($category->licenses_count > 0) {
|
||||
throw new ItemStillHasLicenses($category);
|
||||
}
|
||||
if ($category->models_count > 0) {
|
||||
throw new ItemStillHasAssetModels($category);
|
||||
}
|
||||
|
||||
Storage::disk('public')->delete('categories'.'/'.$category->image);
|
||||
$category->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
63
app/Actions/Manufacturers/DeleteManufacturerAction.php
Normal file
63
app/Actions/Manufacturers/DeleteManufacturerAction.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Manufacturers;
|
||||
|
||||
use App\Exceptions\ItemStillHasAccessories;
|
||||
use App\Exceptions\ItemStillHasAssets;
|
||||
use App\Exceptions\ItemStillHasComponents;
|
||||
use App\Exceptions\ItemStillHasConsumables;
|
||||
use App\Exceptions\ItemStillHasLicenses;
|
||||
use App\Models\Manufacturer;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class DeleteManufacturerAction
|
||||
{
|
||||
/**
|
||||
* @throws ItemStillHasAssets
|
||||
* @throws ItemStillHasComponents
|
||||
* @throws ItemStillHasAccessories
|
||||
* @throws ItemStillHasLicenses
|
||||
* @throws ItemStillHasConsumables
|
||||
*/
|
||||
static function run(Manufacturer $manufacturer): bool
|
||||
{
|
||||
$manufacturer->loadCount([
|
||||
'assets as assets_count',
|
||||
'accessories as accessories_count',
|
||||
'consumables as consumables_count',
|
||||
'components as components_count',
|
||||
'licenses as licenses_count',
|
||||
]);
|
||||
|
||||
if ($manufacturer->assets_count > 0) {
|
||||
throw new ItemStillHasAssets($manufacturer);
|
||||
}
|
||||
if ($manufacturer->accessories_count > 0) {
|
||||
throw new ItemStillHasAccessories($manufacturer);
|
||||
}
|
||||
if ($manufacturer->consumables_count > 0) {
|
||||
throw new ItemStillHasConsumables($manufacturer);
|
||||
}
|
||||
if ($manufacturer->components_count > 0) {
|
||||
throw new ItemStillHasComponents($manufacturer);
|
||||
}
|
||||
if ($manufacturer->licenses_count > 0) {
|
||||
throw new ItemStillHasLicenses($manufacturer);
|
||||
}
|
||||
|
||||
if ($manufacturer->image) {
|
||||
try {
|
||||
Storage::disk('public')->delete('manufacturers/'.$manufacturer->image);
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e);
|
||||
}
|
||||
}
|
||||
|
||||
$manufacturer->delete();
|
||||
//dd($manufacturer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
72
app/Actions/Suppliers/DestroySupplierAction.php
Normal file
72
app/Actions/Suppliers/DestroySupplierAction.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Suppliers;
|
||||
|
||||
use App\Exceptions\ItemStillHasAccessories;
|
||||
use App\Exceptions\ItemStillHasComponents;
|
||||
use App\Exceptions\ItemStillHasConsumables;
|
||||
use App\Models\Supplier;
|
||||
use App\Exceptions\ItemStillHasAssets;
|
||||
use App\Exceptions\ItemStillHasMaintenances;
|
||||
use App\Exceptions\ItemStillHasLicenses;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class DestroySupplierAction
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @throws ItemStillHasLicenses
|
||||
* @throws ItemStillHasAssets
|
||||
* @throws ItemStillHasMaintenances
|
||||
* @throws ItemStillHasAccessories
|
||||
* @throws ItemStillHasConsumables
|
||||
* @throws ItemStillHasComponents
|
||||
*/
|
||||
static function run(Supplier $supplier): bool
|
||||
{
|
||||
$supplier->loadCount([
|
||||
'maintenances as maintenances_count',
|
||||
'assets as assets_count',
|
||||
'licenses as licenses_count',
|
||||
'accessories as accessories_count',
|
||||
'consumables as consumables_count',
|
||||
'components as components_count',
|
||||
]);
|
||||
if ($supplier->assets_count > 0) {
|
||||
throw new ItemStillHasAssets($supplier);
|
||||
}
|
||||
|
||||
if ($supplier->maintenances_count > 0) {
|
||||
throw new ItemStillHasMaintenances($supplier);
|
||||
}
|
||||
|
||||
if ($supplier->licenses_count > 0) {
|
||||
throw new ItemStillHasLicenses($supplier);
|
||||
}
|
||||
|
||||
if ($supplier->accessories_count > 0) {
|
||||
throw new ItemStillHasAccessories($supplier);
|
||||
}
|
||||
|
||||
if ($supplier->consumables_count > 0) {
|
||||
throw new ItemStillHasConsumables($supplier);
|
||||
}
|
||||
|
||||
if ($supplier->components_count > 0) {
|
||||
throw new ItemStillHasComponents($supplier);
|
||||
}
|
||||
|
||||
if ($supplier->image) {
|
||||
try {
|
||||
Storage::disk('public')->delete('suppliers/'.$supplier->image);
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$supplier->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -317,9 +317,21 @@ class LdapSync extends Command
|
||||
if($ldap_map["jobtitle"] != null){
|
||||
$user->jobtitle = $item['jobtitle'];
|
||||
}
|
||||
if($ldap_map["address"] != null){
|
||||
$user->address = $item['address'];
|
||||
}
|
||||
if($ldap_map["city"] != null){
|
||||
$user->city = $item['city'];
|
||||
}
|
||||
if($ldap_map["state"] != null){
|
||||
$user->state = $item['state'];
|
||||
}
|
||||
if($ldap_map["country"] != null){
|
||||
$user->country = $item['country'];
|
||||
}
|
||||
if($ldap_map["zip"] != null){
|
||||
$user->zip = $item['zip'];
|
||||
}
|
||||
if($ldap_map["dept"] != null){
|
||||
$user->department_id = $department->id;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Actionlog;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class RemoveInvalidUploadDeleteActionLogItems extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'snipeit:remove-invalid-upload-delete-action-log-items';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Permanently remove invalid "upload deleted" action log items that have a null filename. This command can potentially result in deleted files being "resurrected" in the UI.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$invalidLogs = Actionlog::query()
|
||||
->where('action_type', 'upload deleted')
|
||||
->whereNull('filename')
|
||||
->withTrashed()
|
||||
->get();
|
||||
|
||||
$this->info("{$invalidLogs->count()} invalid log items found.");
|
||||
|
||||
if ($invalidLogs->count() === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->table(['ID', 'Action Type', 'Item Type', 'Item ID', 'Created At', 'Deleted At'], $invalidLogs->map(fn($log) => [
|
||||
$log->id,
|
||||
$log->action_type,
|
||||
$log->item_type,
|
||||
$log->item_id,
|
||||
$log->created_at,
|
||||
$log->deleted_at,
|
||||
])->toArray());
|
||||
|
||||
if ($this->confirm("Do you wish to remove {$invalidLogs->count()} log items?")) {
|
||||
$invalidLogs->each(fn($log) => $log->forceDelete());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Console\Commands;
|
||||
use Illuminate\Console\Command;
|
||||
use ZipArchive;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use enshrined\svgSanitize\Sanitizer;
|
||||
|
||||
class SQLStreamer {
|
||||
private $input;
|
||||
@@ -242,9 +243,10 @@ class RestoreFromBackup extends Command
|
||||
|
||||
$private_dirs = [
|
||||
'storage/private_uploads/accessories',
|
||||
'storage/private_uploads/assetmodels',
|
||||
'storage/private_uploads/maintenances',
|
||||
'storage/private_uploads/models',
|
||||
'storage/private_uploads/assetmodels' => 'storage/private_uploads/models', //this was changed from assetmodels => models Aug 10 2025
|
||||
'storage/private_uploads/asset_maintenances' => 'storage/private_uploads/maintenances', //this was changed from asset_maintenances => maintenances Aug 10 2025
|
||||
'storage/private_uploads/maintenances', //but let 'maintenances' take precedence
|
||||
'storage/private_uploads/models', //and let 'models' take precedence
|
||||
'storage/private_uploads/assets', // these are asset _files_, not the pictures.
|
||||
'storage/private_uploads/audits',
|
||||
'storage/private_uploads/components',
|
||||
@@ -262,7 +264,7 @@ class RestoreFromBackup extends Command
|
||||
];
|
||||
$public_dirs = [
|
||||
'public/uploads/accessories',
|
||||
'public/uploads/assetmodels',
|
||||
// 'public/uploads/assetmodels' => 'public/uploads/models', //according to git, this was _never_ a thing... (see below)
|
||||
'public/uploads/maintenances',
|
||||
'public/uploads/assets', // these are asset _pictures_, not asset files
|
||||
'public/uploads/avatars',
|
||||
@@ -273,7 +275,7 @@ class RestoreFromBackup extends Command
|
||||
'public/uploads/departments',
|
||||
'public/uploads/locations',
|
||||
'public/uploads/manufacturers',
|
||||
'public/uploads/models',
|
||||
'public/uploads/models', // ...it's been this way for 9 years (as of late 2025)
|
||||
'public/uploads/suppliers',
|
||||
];
|
||||
|
||||
@@ -286,8 +288,6 @@ class RestoreFromBackup extends Command
|
||||
'public/uploads/favicon-uploaded.*',
|
||||
];
|
||||
|
||||
$all_files = $private_dirs + $public_dirs;
|
||||
|
||||
$sqlfiles = [];
|
||||
$sqlfile_indices = [];
|
||||
|
||||
@@ -295,6 +295,20 @@ class RestoreFromBackup extends Command
|
||||
$boring_files = [];
|
||||
$unsafe_files = [];
|
||||
|
||||
$good_extensions = config('filesystems.allowed_upload_extensions_array');
|
||||
|
||||
$private_extensions = array_merge($good_extensions, ["csv", "key"]); //add csv, and 'key'
|
||||
$public_extensions = array_diff($good_extensions, ["xml"]); //remove xml
|
||||
|
||||
$sanitizer = new Sanitizer();
|
||||
|
||||
/**
|
||||
* TODO: I _hate_ the "continue 3" thing we keep doing here
|
||||
* I think a better approach might be to have the "each file" stuff be in a method on this class, and the
|
||||
* boring_files and interesting_files be properties on it that we fill out. Then, in that method, we could
|
||||
* just do a 'return' once the file is actually handled (yay or nay). We could also start to break out some of
|
||||
* the _other_ things that we do into their own methods too? But I don't care about that as much.
|
||||
*/
|
||||
for ($i = 0; $i < $za->numFiles; $i++) {
|
||||
$stat_results = $za->statIndex($i);
|
||||
// echo "index: $i\n";
|
||||
@@ -309,7 +323,7 @@ class RestoreFromBackup extends Command
|
||||
// skip macOS resource fork files (?!?!?!)
|
||||
if (strpos($raw_path, '__MACOSX') !== false && strpos($raw_path, '._') !== false) {
|
||||
//print "SKIPPING macOS Resource fork file: $raw_path\n";
|
||||
$boring_files[] = $raw_path;
|
||||
// $boring_files[] = $raw_path; //stop adding this to the boring files list; it's just confusing
|
||||
continue;
|
||||
}
|
||||
if (@pathinfo($raw_path, PATHINFO_EXTENSION) == 'sql') {
|
||||
@@ -318,44 +332,70 @@ class RestoreFromBackup extends Command
|
||||
$sqlfile_indices[] = $i;
|
||||
continue;
|
||||
}
|
||||
if ($raw_path[-1] == '/') {
|
||||
//last character is '/' - this is a directory, and we don't need it, and we don't need to warn about it
|
||||
continue;
|
||||
}
|
||||
if (in_array(basename($raw_path), [".gitkeep", ".gitignore", ".DS_Store"])) {
|
||||
//skip these boring files silently without reporting on them; they're stupid
|
||||
continue;
|
||||
}
|
||||
$extension = strtolower(pathinfo($raw_path, PATHINFO_EXTENSION));
|
||||
|
||||
foreach (array_merge($private_dirs, $public_dirs) as $dir) {
|
||||
$last_pos = strrpos($raw_path, $dir . '/');
|
||||
if ($last_pos !== false) {
|
||||
//print("INTERESTING - last_pos is $last_pos when searching $raw_path for $dir - last_pos+strlen(\$dir) is: ".($last_pos+strlen($dir))." and strlen(\$rawpath) is: ".strlen($raw_path)."\n");
|
||||
//print("We would copy $raw_path to $dir.\n"); //FIXME append to a path?
|
||||
$interesting_files[$raw_path] = ['dest' => $dir, 'index' => $i];
|
||||
continue 2;
|
||||
if ($last_pos + strlen($dir) + 1 == strlen($raw_path)) {
|
||||
// we don't care about that; we just want files with the appropriate prefix
|
||||
//print("FOUND THE EXACT DIRECTORY: $dir AT: $raw_path!!!\n");
|
||||
foreach (['public' => $public_dirs, 'private' => $private_dirs] as $purpose => $dirs) {
|
||||
$allowed_extensions = match ($purpose) {
|
||||
'public' => $public_extensions,
|
||||
'private' => $private_extensions,
|
||||
};
|
||||
foreach ($dirs as $dir => $destdir) {
|
||||
if (is_int($dir)) {
|
||||
$dir = $destdir;
|
||||
}
|
||||
$last_pos = strrpos($raw_path, $dir . '/');
|
||||
if ($last_pos !== false) {
|
||||
//print("INTERESTING - last_pos is $last_pos when searching $raw_path for $dir - last_pos+strlen(\$dir) is: ".($last_pos+strlen($dir))." and strlen(\$rawpath) is: ".strlen($raw_path)."\n");
|
||||
//print("We would copy $raw_path to $dir.\n"); //FIXME append to a path?
|
||||
//the CSV bit, below, is because we store CSV files as "blahcsv" - without an extension
|
||||
if (!in_array($extension, $allowed_extensions) && !($dir == "storage/private_uploads/imports" && substr($raw_path, -3) == "csv" && $extension == "")) {
|
||||
$unsafe_files[] = $raw_path;
|
||||
Log::debug($raw_path . ' from directory ' . $dir . ' is being skipped');
|
||||
} else {
|
||||
if ($dir != $destdir) {
|
||||
Log::debug("Getting ready to save file $raw_path to new directory $destdir");
|
||||
}
|
||||
$interesting_files[$raw_path] = ['dest' => $destdir, 'index' => $i];
|
||||
}
|
||||
continue 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$good_extensions = config('filesystems.allowed_upload_extensions_array');
|
||||
|
||||
foreach (array_merge($private_files, $public_files) as $file) {
|
||||
$has_wildcard = (strpos($file, '*') !== false);
|
||||
if ($has_wildcard) {
|
||||
$file = substr($file, 0, -1); //trim last character (which should be the wildcard)
|
||||
}
|
||||
$last_pos = strrpos($raw_path, $file); // no trailing slash!
|
||||
if ($last_pos !== false) {
|
||||
$extension = strtolower(pathinfo($raw_path, PATHINFO_EXTENSION));
|
||||
if (!in_array($extension, $good_extensions)) {
|
||||
// gathering potentially unsafe files here to return at exit
|
||||
$unsafe_files[] = $raw_path;
|
||||
Log::debug('Potentially unsafe file '.$raw_path.' is being skipped');
|
||||
$boring_files[] = $raw_path;
|
||||
continue 2;
|
||||
foreach (['public' => $public_files, 'private' => $private_files] as $purpose => $files) {
|
||||
$allowed_extensions = match ($purpose) {
|
||||
'public' => $public_extensions,
|
||||
'private' => $private_extensions,
|
||||
};
|
||||
foreach ($files as $file) {
|
||||
$has_wildcard = (strpos($file, '*') !== false);
|
||||
if ($has_wildcard) {
|
||||
$file = substr($file, 0, -1); //trim last character (which should be the wildcard)
|
||||
}
|
||||
//print("INTERESTING - last_pos is $last_pos when searching $raw_path for $file - last_pos+strlen(\$file) is: ".($last_pos+strlen($file))." and strlen(\$rawpath) is: ".strlen($raw_path)."\n");
|
||||
//no wildcards found in $file, process 'normally'
|
||||
if ($last_pos + strlen($file) == strlen($raw_path) || $has_wildcard) { //again, no trailing slash. or this is a wildcard and we just take it.
|
||||
// print("FOUND THE EXACT FILE: $file AT: $raw_path!!!\n"); //we *do* care about this, though.
|
||||
$interesting_files[$raw_path] = ['dest' => dirname($file), 'index' => $i];
|
||||
continue 2;
|
||||
$last_pos = strrpos($raw_path, $file); // no trailing slash!
|
||||
if ($last_pos !== false) {
|
||||
if (!in_array($extension, $allowed_extensions)) {
|
||||
// gathering potentially unsafe files here to return at exit
|
||||
$unsafe_files[] = $raw_path;
|
||||
Log::debug('Potentially unsafe file ' . $raw_path . ' is being skipped');
|
||||
$boring_files[] = $raw_path;
|
||||
continue 3;
|
||||
}
|
||||
//print("INTERESTING - last_pos is $last_pos when searching $raw_path for $file - last_pos+strlen(\$file) is: ".($last_pos+strlen($file))." and strlen(\$rawpath) is: ".strlen($raw_path)."\n");
|
||||
//no wildcards found in $file, process 'normally'
|
||||
if ($last_pos + strlen($file) == strlen($raw_path) || $has_wildcard) { //again, no trailing slash. or this is a wildcard and we just take it.
|
||||
// print("FOUND THE EXACT FILE: $file AT: $raw_path!!!\n"); //we *do* care about this, though.
|
||||
$interesting_files[$raw_path] = ['dest' => dirname($file), 'index' => $i];
|
||||
continue 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -492,18 +532,25 @@ class RestoreFromBackup extends Command
|
||||
}
|
||||
foreach ($interesting_files as $pretty_file_name => $file_details) {
|
||||
$ugly_file_name = $za->statIndex($file_details['index'])['name'];
|
||||
$fp = $za->getStream($ugly_file_name);
|
||||
//$this->info("Weird problem, here are file details? ".print_r($file_details,true));
|
||||
if (!is_dir($file_details['dest'])) {
|
||||
mkdir($file_details['dest'], 0755, true); //0755 is what Laravel uses, so we do that
|
||||
$migrated_file_name = $file_details['dest'] . '/' . basename($pretty_file_name);
|
||||
if (strcasecmp(substr($pretty_file_name, -4), ".svg") === 0) {
|
||||
$svg_contents = $za->getFromIndex($file_details['index']);
|
||||
$cleaned_svg = $sanitizer->sanitize($svg_contents);
|
||||
file_put_contents($migrated_file_name, $cleaned_svg);
|
||||
} else {
|
||||
$fp = $za->getStream($ugly_file_name);
|
||||
//$this->info("Weird problem, here are file details? ".print_r($file_details,true));
|
||||
if (!is_dir($file_details['dest'])) {
|
||||
mkdir($file_details['dest'], 0755, true); //0755 is what Laravel uses, so we do that
|
||||
}
|
||||
$migrated_file = fopen($migrated_file_name, 'w');
|
||||
while (($buffer = fgets($fp, SQLStreamer::$buffer_size)) !== false) {
|
||||
fwrite($migrated_file, $buffer);
|
||||
}
|
||||
fclose($migrated_file);
|
||||
fclose($fp);
|
||||
//$this->info("Wrote $ugly_file_name to $pretty_file_name");
|
||||
}
|
||||
$migrated_file = fopen($file_details['dest'].'/'.basename($pretty_file_name), 'w');
|
||||
while (($buffer = fgets($fp, SQLStreamer::$buffer_size)) !== false) {
|
||||
fwrite($migrated_file, $buffer);
|
||||
}
|
||||
fclose($migrated_file);
|
||||
fclose($fp);
|
||||
//$this->info("Wrote $ugly_file_name to $pretty_file_name");
|
||||
if ($bar) {
|
||||
$bar->advance();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Mail\ExpiringAssetsMail;
|
||||
use App\Mail\ExpiringLicenseMail;
|
||||
use App\Models\Asset;
|
||||
@@ -52,19 +53,73 @@ class SendExpirationAlerts extends Command
|
||||
->filter(fn($item) => !empty($item))
|
||||
->all();
|
||||
// Expiring Assets
|
||||
$assets = Asset::getExpiringWarrantee($alert_interval);
|
||||
$assets = Asset::getExpiringWarrantyOrEol($alert_interval);
|
||||
|
||||
if ($assets->count() > 0) {
|
||||
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $alert_interval]));
|
||||
|
||||
Mail::to($recipients)->send(new ExpiringAssetsMail($assets, $alert_interval));
|
||||
|
||||
$this->table(
|
||||
[
|
||||
trans('general.id'),
|
||||
trans('admin/hardware/form.tag'),
|
||||
trans('admin/hardware/form.model'),
|
||||
trans('general.model_no'),
|
||||
trans('general.purchase_date'),
|
||||
trans('admin/hardware/form.eol_rate'),
|
||||
trans('admin/hardware/form.eol_date'),
|
||||
trans('admin/hardware/form.warranty_expires'),
|
||||
],
|
||||
$assets->map(fn($item) =>
|
||||
[
|
||||
trans('general.id') => $item->id,
|
||||
trans('admin/hardware/form.tag') => $item->asset_tag,
|
||||
trans('admin/hardware/form.model') => $item->model->name,
|
||||
trans('general.model_no') => $item->model->model_number,
|
||||
trans('general.purchase_date') => $item->purchase_date_formatted,
|
||||
trans('admin/hardware/form.eol_rate') => $item->model->eol,
|
||||
trans('admin/hardware/form.eol_date') => $item->eol_date ? $item->eol_formatted_date .' ('.$item->eol_diff_for_humans.')' : '',
|
||||
trans('admin/hardware/form.warranty_expires') => $item->warranty_expires ? $item->warranty_expires_formatted_date .' ('.$item->warranty_expires_diff_for_humans.')' : '',
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
// Expiring licenses
|
||||
$licenses = License::getExpiringLicenses($alert_interval);
|
||||
$licenses = License::query()->ExpiringLicenses($alert_interval)
|
||||
->with('manufacturer','category')
|
||||
->orderBy('expiration_date', 'ASC')
|
||||
->orderBy('termination_date', 'ASC')
|
||||
->get();
|
||||
if ($licenses->count() > 0) {
|
||||
$this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $alert_interval]));
|
||||
Mail::to($recipients)->send(new ExpiringLicenseMail($licenses, $alert_interval));
|
||||
|
||||
$this->table(
|
||||
[
|
||||
trans('general.id'),
|
||||
trans('general.name'),
|
||||
trans('general.purchase_date'),
|
||||
trans('admin/licenses/form.expiration'),
|
||||
trans('mail.expires'),
|
||||
trans('admin/licenses/form.termination_date'),
|
||||
trans('mail.terminates')],
|
||||
$licenses->map(fn($item) => [
|
||||
trans('general.id') => $item->id,
|
||||
trans('general.name') => $item->name,
|
||||
trans('general.purchase_date') => $item->purchase_date_formatted,
|
||||
trans('admin/licenses/form.expiration') => $item->expires_formatted_date,
|
||||
trans('mail.expires') => $item->expires_formatted_date ? $item->expires_diff_for_humans : '',
|
||||
trans('admin/licenses/form.termination_date') => $item->terminates_formatted_date,
|
||||
trans('mail.terminates') => $item->terminates_diff_for_humans
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
// Send a message even if the count is 0
|
||||
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $alert_interval]));
|
||||
$this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $alert_interval]));
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
if ($settings->alert_email == '') {
|
||||
$this->error('Could not send email. No alert email configured in settings');
|
||||
|
||||
@@ -47,7 +47,7 @@ class SendUpcomingAuditReport extends Command
|
||||
$today = Carbon::now();
|
||||
$interval_date = $today->copy()->addDays($interval);
|
||||
|
||||
$assets = Asset::whereNull('deleted_at')->dueOrOverdueForAudit($settings)->orderBy('assets.next_audit_date', 'desc')->get();
|
||||
$assets = Asset::whereNull('deleted_at')->dueOrOverdueForAudit($settings)->orderBy('assets.next_audit_date', 'asc')->get();
|
||||
$this->info($assets->count() . ' assets must be audited in on or before ' . $interval_date . ' is deadline');
|
||||
|
||||
|
||||
@@ -61,6 +61,28 @@ class SendUpcomingAuditReport extends Command
|
||||
|
||||
$this->info('Sending Admin SendUpcomingAuditNotification to: ' . $settings->alert_email);
|
||||
Mail::to($recipients)->send(new SendUpcomingAuditMail($assets, $settings->audit_warning_days));
|
||||
|
||||
$this->table(
|
||||
[
|
||||
trans('general.id'),
|
||||
trans('general.name'),
|
||||
trans('general.last_audit'),
|
||||
trans('general.next_audit_date'),
|
||||
trans('mail.Days'),
|
||||
trans('mail.supplier'),
|
||||
trans('mail.assigned_to'),
|
||||
|
||||
],
|
||||
$assets->map(fn($item) => [
|
||||
trans('general.id') => $item->id,
|
||||
trans('general.name') => $item->display_name,
|
||||
trans('general.last_audit') => $item->last_audit_formatted_date,
|
||||
trans('general.next_audit_date') => $item->next_audit_formatted_date,
|
||||
trans('mail.Days') => round($item->next_audit_diff_in_days),
|
||||
trans('mail.supplier') => $item->supplier ? $item->supplier->name : '',
|
||||
trans('mail.assigned_to') => $item->assignedTo ? $item->assignedTo->display_name : '',
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
10
app/Exceptions/ItemStillHasAccessories.php
Normal file
10
app/Exceptions/ItemStillHasAccessories.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class ItemStillHasAccessories extends ItemStillHasChildren
|
||||
{
|
||||
//
|
||||
}
|
||||
10
app/Exceptions/ItemStillHasAssetModels.php
Normal file
10
app/Exceptions/ItemStillHasAssetModels.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class ItemStillHasAssetModels extends ItemStillHasChildren
|
||||
{
|
||||
//
|
||||
}
|
||||
9
app/Exceptions/ItemStillHasAssets.php
Normal file
9
app/Exceptions/ItemStillHasAssets.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class ItemStillHasAssets extends ItemStillHasChildren
|
||||
{
|
||||
}
|
||||
14
app/Exceptions/ItemStillHasChildren.php
Normal file
14
app/Exceptions/ItemStillHasChildren.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class ItemStillHasChildren extends Exception
|
||||
{
|
||||
//public function __construct($message, $code = 0, Exception $previous = null, $parent, $children)
|
||||
//{
|
||||
// trans()
|
||||
//
|
||||
//}
|
||||
}
|
||||
10
app/Exceptions/ItemStillHasComponents.php
Normal file
10
app/Exceptions/ItemStillHasComponents.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class ItemStillHasComponents extends ItemStillHasChildren
|
||||
{
|
||||
//
|
||||
}
|
||||
10
app/Exceptions/ItemStillHasConsumables.php
Normal file
10
app/Exceptions/ItemStillHasConsumables.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class ItemStillHasConsumables extends ItemStillHasChildren
|
||||
{
|
||||
//
|
||||
}
|
||||
10
app/Exceptions/ItemStillHasLicenses.php
Normal file
10
app/Exceptions/ItemStillHasLicenses.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class ItemStillHasLicenses extends ItemStillHasChildren
|
||||
{
|
||||
//
|
||||
}
|
||||
10
app/Exceptions/ItemStillHasMaintenances.php
Normal file
10
app/Exceptions/ItemStillHasMaintenances.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class ItemStillHasMaintenances extends ItemStillHasChildren
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -95,7 +95,7 @@ class Helper
|
||||
$Parsedown->setSafeMode(true);
|
||||
|
||||
if ($str) {
|
||||
return $Parsedown->text($str);
|
||||
return $Parsedown->text(strip_tags($str));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ class Helper
|
||||
$Parsedown->setSafeMode(true);
|
||||
|
||||
if ($str) {
|
||||
return $Parsedown->line($str);
|
||||
return $Parsedown->line(strip_tags($str));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,6 +435,34 @@ class Helper
|
||||
return $colors[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string has any RTL characters
|
||||
* @param $value
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasRtl($string) {
|
||||
$rtlChar = '/[\x{0590}-\x{083F}]|[\x{08A0}-\x{08FF}]|[\x{FB1D}-\x{FDFF}]|[\x{FE70}-\x{FEFF}]/u';
|
||||
return preg_match($rtlChar, $string) != 0;
|
||||
}
|
||||
|
||||
// is chinese, japanese or korean language
|
||||
public static function isCjk($string) {
|
||||
return Helper::isChinese($string) || Helper::isJapanese($string) || Helper::isKorean($string);
|
||||
}
|
||||
|
||||
public static function isChinese($string) {
|
||||
return preg_match("/\p{Han}+/u", $string);
|
||||
}
|
||||
|
||||
public static function isJapanese($string) {
|
||||
return preg_match('/[\x{4E00}-\x{9FBF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}]/u', $string);
|
||||
}
|
||||
|
||||
public static function isKorean($string) {
|
||||
return preg_match('/[\x{3130}-\x{318F}\x{AC00}-\x{D7AF}]/u', $string);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increases or decreases the brightness of a color by a percentage of the current brightness.
|
||||
*
|
||||
|
||||
@@ -195,6 +195,10 @@ class IconHelper
|
||||
case 'note':
|
||||
case 'notes':
|
||||
return 'fas fa-sticky-note';
|
||||
case 'tip':
|
||||
return 'fa-solid fa-lightbulb';
|
||||
case 'highlight':
|
||||
return 'fa-solid fa-highlighter';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,33 +8,23 @@ use App\Events\ItemAccepted;
|
||||
use App\Events\ItemDeclined;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\CheckoutAcceptanceResponseMail;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\CheckoutAcceptance;
|
||||
use App\Models\Company;
|
||||
use App\Models\Contracts\Acceptable;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\License;
|
||||
use App\Models\Component;
|
||||
use App\Models\Consumable;
|
||||
use App\Notifications\AcceptanceAssetAcceptedNotification;
|
||||
use App\Notifications\AcceptanceAssetAcceptedToUserNotification;
|
||||
use App\Notifications\AcceptanceAssetDeclinedNotification;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Http\Controllers\SettingsController;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Carbon\Carbon;
|
||||
use \Illuminate\Contracts\View\View;
|
||||
use \Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Helpers\Helper;
|
||||
|
||||
class AcceptanceController extends Controller
|
||||
{
|
||||
@@ -85,6 +75,10 @@ class AcceptanceController extends Controller
|
||||
public function store(Request $request, $id) : RedirectResponse
|
||||
{
|
||||
$acceptance = CheckoutAcceptance::find($id);
|
||||
$assigned_user = User::find($acceptance->assigned_to_id);
|
||||
$settings = Setting::getSettings();
|
||||
$sig_filename='';
|
||||
|
||||
|
||||
if (is_null($acceptance)) {
|
||||
return redirect()->route('account.accept')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||
@@ -107,140 +101,84 @@ class AcceptanceController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the signature and save it
|
||||
* Check for the signature directory
|
||||
*/
|
||||
if (! Storage::exists('private_uploads/signatures')) {
|
||||
Storage::makeDirectory('private_uploads/signatures', 775);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for the eula-pdfs directory
|
||||
*/
|
||||
if (! Storage::exists('private_uploads/eula-pdfs')) {
|
||||
Storage::makeDirectory('private_uploads/eula-pdfs', 775);
|
||||
}
|
||||
|
||||
$item = $acceptance->checkoutable_type::find($acceptance->checkoutable_id);
|
||||
$display_model = '';
|
||||
$pdf_view_route = '';
|
||||
$pdf_filename = 'accepted-eula-'.date('Y-m-d-h-i-s').'.pdf';
|
||||
$sig_filename='';
|
||||
|
||||
|
||||
|
||||
// If signatures are required, make sure we have one
|
||||
if (Setting::getSettings()->require_accept_signature == '1') {
|
||||
|
||||
// The item was accepted, check for a signature
|
||||
if ($request->filled('signature_output')) {
|
||||
$sig_filename = 'siglog-' . Str::uuid() . '-' . date('Y-m-d-his') . '.png';
|
||||
$data_uri = $request->input('signature_output');
|
||||
$encoded_image = explode(',', $data_uri);
|
||||
$decoded_image = base64_decode($encoded_image[1]);
|
||||
Storage::put('private_uploads/signatures/' . $sig_filename, (string)$decoded_image);
|
||||
|
||||
// No image data is present, kick them back.
|
||||
// This mostly only applies to users on super-duper crapola browsers *cough* IE *cough*
|
||||
} else {
|
||||
return redirect()->back()->with('error', trans('general.shitty_browser'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Convert PDF logo to base64 for TCPDF
|
||||
// This is needed for TCPDF to properly embed the image if it's a png and the cache isn't writable
|
||||
$encoded_logo = null;
|
||||
if ($settings->acceptance_pdf_logo) {
|
||||
$encoded_logo = base64_encode(file_get_contents(public_path() . '/uploads/' . $settings->acceptance_pdf_logo));
|
||||
}
|
||||
|
||||
// Get the data array ready for the notifications and PDF generation
|
||||
$data = [
|
||||
'item_tag' => $item->asset_tag,
|
||||
'item_name' => $item->name, // this handles licenses seats, which don't have a 'name' field
|
||||
'item_model' => $item->model?->name,
|
||||
'item_serial' => $item->serial,
|
||||
'item_status' => $item->assetstatus?->name,
|
||||
'eula' => $item->getEula(),
|
||||
'note' => $request->input('note'),
|
||||
'check_out_date' => Helper::getFormattedDateObject($acceptance->created_at, 'datetime', false),
|
||||
'accepted_date' => Helper::getFormattedDateObject(now()->format('Y-m-d H:i:s'), 'datetime', false),
|
||||
'declined_date' => Helper::getFormattedDateObject(now()->format('Y-m-d H:i:s'), 'datetime', false),
|
||||
'assigned_to' => $assigned_user->display_name,
|
||||
'email' => $assigned_user->email,
|
||||
'employee_num' => $assigned_user->employee_num,
|
||||
'site_name' => $settings->site_name,
|
||||
'company_name' => $item->company?->name?? $settings->site_name,
|
||||
'signature' => (($sig_filename && array_key_exists('1', $encoded_image))) ? $encoded_image[1] : null,
|
||||
'logo' => ($encoded_logo) ?? null,
|
||||
'date_settings' => $settings->date_display_format,
|
||||
'admin' => auth()->user()->present()?->fullName,
|
||||
'qty' => $acceptance->qty ?? 1,
|
||||
];
|
||||
|
||||
|
||||
if ($request->input('asset_acceptance') == 'accepted') {
|
||||
|
||||
/**
|
||||
* Check for the eula-pdfs directory
|
||||
*/
|
||||
if (! Storage::exists('private_uploads/eula-pdfs')) {
|
||||
Storage::makeDirectory('private_uploads/eula-pdfs', 775);
|
||||
}
|
||||
|
||||
if (Setting::getSettings()->require_accept_signature == '1') {
|
||||
|
||||
// Check if the signature directory exists, if not create it
|
||||
if (!Storage::exists('private_uploads/signatures')) {
|
||||
Storage::makeDirectory('private_uploads/signatures', 775);
|
||||
}
|
||||
$pdf_filename = 'accepted-'.$acceptance->checkoutable_id.'-'.$acceptance->display_checkoutable_type.'-eula-'.date('Y-m-d-h-i-s').'.pdf';
|
||||
|
||||
// The item was accepted, check for a signature
|
||||
if ($request->filled('signature_output')) {
|
||||
$sig_filename = 'siglog-' . Str::uuid() . '-' . date('Y-m-d-his') . '.png';
|
||||
$data_uri = $request->input('signature_output');
|
||||
$encoded_image = explode(',', $data_uri);
|
||||
$decoded_image = base64_decode($encoded_image[1]);
|
||||
Storage::put('private_uploads/signatures/' . $sig_filename, (string)$decoded_image);
|
||||
|
||||
// No image data is present, kick them back.
|
||||
// This mostly only applies to users on super-duper crapola browsers *cough* IE *cough*
|
||||
} else {
|
||||
return redirect()->back()->with('error', trans('general.shitty_browser'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$assigned_user = User::find($acceptance->assigned_to_id);
|
||||
// this is horrible
|
||||
switch($acceptance->checkoutable_type){
|
||||
case 'App\Models\Asset':
|
||||
$pdf_view_route ='account.accept.accept-asset-eula';
|
||||
$asset_model = AssetModel::find($item->model_id);
|
||||
if (!$asset_model) {
|
||||
return redirect()->back()->with('error', trans('admin/models/message.does_not_exist'));
|
||||
}
|
||||
$display_model = $asset_model->name;
|
||||
break;
|
||||
|
||||
case 'App\Models\Accessory':
|
||||
$pdf_view_route ='account.accept.accept-accessory-eula';
|
||||
$accessory = Accessory::find($item->id);
|
||||
$display_model = $accessory->name;
|
||||
break;
|
||||
|
||||
case 'App\Models\LicenseSeat':
|
||||
$pdf_view_route ='account.accept.accept-license-eula';
|
||||
$license = License::find($item->license_id);
|
||||
$display_model = $license->name;
|
||||
break;
|
||||
|
||||
case 'App\Models\Component':
|
||||
$pdf_view_route ='account.accept.accept-component-eula';
|
||||
$component = Component::find($item->id);
|
||||
$display_model = $component->name;
|
||||
break;
|
||||
|
||||
case 'App\Models\Consumable':
|
||||
$pdf_view_route ='account.accept.accept-consumable-eula';
|
||||
$consumable = Consumable::find($item->id);
|
||||
$display_model = $consumable->name;
|
||||
break;
|
||||
}
|
||||
// if ($acceptance->checkoutable_type == 'App\Models\Asset') {
|
||||
// $pdf_view_route ='account.accept.accept-asset-eula';
|
||||
// $asset_model = AssetModel::find($item->model_id);
|
||||
// $display_model = $asset_model->name;
|
||||
// $assigned_to = User::find($item->assigned_to)->present()->fullName;
|
||||
//
|
||||
// } elseif ($acceptance->checkoutable_type== 'App\Models\Accessory') {
|
||||
// $pdf_view_route ='account.accept.accept-accessory-eula';
|
||||
// $accessory = Accessory::find($item->id);
|
||||
// $display_model = $accessory->name;
|
||||
// $assigned_to = User::find($item->assignedTo);
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gather the data for the PDF. We fire this whether there is a signature required or not,
|
||||
* since we want the moment-in-time proof of what the EULA was when they accepted it.
|
||||
*/
|
||||
$branding_settings = SettingsController::getPDFBranding();
|
||||
|
||||
$path_logo = "";
|
||||
|
||||
// Check for the PDF logo path and use that, otherwise use the regular logo path
|
||||
if (!is_null($branding_settings->acceptance_pdf_logo)) {
|
||||
$path_logo = public_path() . '/uploads/' . $branding_settings->acceptance_pdf_logo;
|
||||
} elseif (!is_null($branding_settings->logo)) {
|
||||
$path_logo = public_path() . '/uploads/' . $branding_settings->logo;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'item_tag' => $item->asset_tag,
|
||||
'item_model' => $display_model,
|
||||
'item_serial' => $item->serial,
|
||||
'item_status' => $item->assetstatus?->name,
|
||||
'eula' => $item->getEula(),
|
||||
'note' => $request->input('note'),
|
||||
'check_out_date' => Carbon::parse($acceptance->created_at)->format('Y-m-d'),
|
||||
'accepted_date' => Carbon::parse($acceptance->accepted_at)->format('Y-m-d'),
|
||||
'assigned_to' => $assigned_user->present()->fullName,
|
||||
'company_name' => $branding_settings->site_name,
|
||||
'signature' => ($sig_filename) ? storage_path() . '/private_uploads/signatures/' . $sig_filename : null,
|
||||
'logo' => $path_logo,
|
||||
'date_settings' => $branding_settings->date_display_format,
|
||||
'admin' => auth()->user()->present()?->fullName,
|
||||
];
|
||||
|
||||
if ($pdf_view_route!='') {
|
||||
Log::debug($pdf_filename.' is the filename, and the route was specified.');
|
||||
$pdf = Pdf::loadView($pdf_view_route, $data);
|
||||
Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf->output());
|
||||
}
|
||||
// Generate the PDF content
|
||||
$pdf_content = $acceptance->generateAcceptancePdf($data, $acceptance);
|
||||
Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf_content);
|
||||
|
||||
// Log the acceptance
|
||||
$acceptance->accept($sig_filename, $item->getEula(), $pdf_filename, $request->input('note'));
|
||||
|
||||
// Send the PDF to the signing user
|
||||
@@ -248,9 +186,8 @@ class AcceptanceController extends Controller
|
||||
|
||||
// Add the attachment for the signing user into the $data array
|
||||
$data['file'] = $pdf_filename;
|
||||
$locale = $assigned_user->locale;
|
||||
try {
|
||||
$assigned_user->notify((new AcceptanceAssetAcceptedToUserNotification($data))->locale($locale));
|
||||
$assigned_user->notify((new AcceptanceAssetAcceptedToUserNotification($data))->locale($assigned_user->locale));
|
||||
} catch (\Exception $e) {
|
||||
Log::warning($e);
|
||||
}
|
||||
@@ -264,95 +201,21 @@ class AcceptanceController extends Controller
|
||||
|
||||
$return_msg = trans('admin/users/message.accepted');
|
||||
|
||||
// Item was declined
|
||||
} else {
|
||||
|
||||
/**
|
||||
* Check for the eula-pdfs directory
|
||||
*/
|
||||
if (! Storage::exists('private_uploads/eula-pdfs')) {
|
||||
Storage::makeDirectory('private_uploads/eula-pdfs', 775);
|
||||
for ($i = 0; $i < ($acceptance->qty ?? 1); $i++) {
|
||||
$acceptance->decline($sig_filename, $request->input('note'));
|
||||
}
|
||||
|
||||
if (Setting::getSettings()->require_accept_signature == '1') {
|
||||
|
||||
// Check if the signature directory exists, if not create it
|
||||
if (!Storage::exists('private_uploads/signatures')) {
|
||||
Storage::makeDirectory('private_uploads/signatures', 775);
|
||||
}
|
||||
|
||||
// The item was accepted, check for a signature
|
||||
if ($request->filled('signature_output')) {
|
||||
$sig_filename = 'siglog-' . Str::uuid() . '-' . date('Y-m-d-his') . '.png';
|
||||
$data_uri = $request->input('signature_output');
|
||||
$encoded_image = explode(',', $data_uri);
|
||||
$decoded_image = base64_decode($encoded_image[1]);
|
||||
Storage::put('private_uploads/signatures/' . $sig_filename, (string)$decoded_image);
|
||||
|
||||
// No image data is present, kick them back.
|
||||
// This mostly only applies to users on super-duper crapola browsers *cough* IE *cough*
|
||||
} else {
|
||||
return redirect()->back()->with('error', trans('general.shitty_browser'));
|
||||
}
|
||||
}
|
||||
|
||||
// Format the data to send the declined notification
|
||||
$branding_settings = SettingsController::getPDFBranding();
|
||||
|
||||
// This is the most horriblest
|
||||
switch($acceptance->checkoutable_type){
|
||||
case 'App\Models\Asset':
|
||||
$asset_model = AssetModel::find($item->model_id);
|
||||
$display_model = $asset_model->name;
|
||||
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
|
||||
break;
|
||||
|
||||
case 'App\Models\Accessory':
|
||||
$accessory = Accessory::find($item->id);
|
||||
$display_model = $accessory->name;
|
||||
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
|
||||
break;
|
||||
|
||||
case 'App\Models\LicenseSeat':
|
||||
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
|
||||
break;
|
||||
|
||||
case 'App\Models\Component':
|
||||
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
|
||||
break;
|
||||
|
||||
case 'App\Models\Consumable':
|
||||
$consumable = Consumable::find($item->id);
|
||||
$display_model = $consumable->name;
|
||||
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
|
||||
break;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'item_tag' => $item->asset_tag,
|
||||
'item_model' => $display_model,
|
||||
'item_serial' => $item->serial,
|
||||
'item_status' => $item->assetstatus?->name,
|
||||
'note' => $request->input('note'),
|
||||
'declined_date' => Carbon::parse($acceptance->declined_at)->format('Y-m-d'),
|
||||
'signature' => ($sig_filename) ? storage_path() . '/private_uploads/signatures/' . $sig_filename : null,
|
||||
'assigned_to' => $assigned_to,
|
||||
'company_name' => $branding_settings->site_name,
|
||||
'date_settings' => $branding_settings->date_display_format,
|
||||
];
|
||||
|
||||
if ($pdf_view_route!='') {
|
||||
Log::debug($pdf_filename.' is the filename, and the route was specified.');
|
||||
$pdf = Pdf::loadView($pdf_view_route, $data);
|
||||
Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf->output());
|
||||
}
|
||||
|
||||
$acceptance->decline($sig_filename, $request->input('note'));
|
||||
$acceptance->notify(new AcceptanceAssetDeclinedNotification($data));
|
||||
Log::debug('New event acceptance.');
|
||||
event(new CheckoutDeclined($acceptance));
|
||||
$return_msg = trans('admin/users/message.declined');
|
||||
}
|
||||
|
||||
|
||||
// Send an email notification if one is requested
|
||||
if ($acceptance->alert_on_response_id) {
|
||||
try {
|
||||
$recipient = User::find($acceptance->alert_on_response_id);
|
||||
@@ -371,9 +234,10 @@ class AcceptanceController extends Controller
|
||||
Log::warning($e);
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->to('account/accept')->with('success', $return_msg);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Actionlog;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use \Illuminate\Http\Response;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use \Illuminate\Http\Response;
|
||||
|
||||
class ActionlogController extends Controller
|
||||
{
|
||||
public function displaySig($filename) : RedirectResponse | Response | bool
|
||||
@@ -39,17 +41,29 @@ class ActionlogController extends Controller
|
||||
|
||||
public function getStoredEula($filename) : Response | BinaryFileResponse | RedirectResponse
|
||||
{
|
||||
$this->authorize('view', \App\Models\Asset::class);
|
||||
|
||||
if (config('filesystems.default') == 's3_private') {
|
||||
return redirect()->away(Storage::disk('s3_private')->temporaryUrl('private_uploads/eula-pdfs/'.$filename, now()->addMinutes(5)));
|
||||
if ($actionlog = Actionlog::where('filename', $filename)->with('user')->with('target')->firstOrFail()) {
|
||||
|
||||
$this->authorize('view', $actionlog->target);
|
||||
$this->authorize('view', $actionlog->user);
|
||||
|
||||
|
||||
if (config('filesystems.default') == 's3_private') {
|
||||
return redirect()->away(Storage::disk('s3_private')->temporaryUrl('private_uploads/eula-pdfs/' . $filename, now()->addMinutes(5)));
|
||||
}
|
||||
|
||||
if (Storage::exists('private_uploads/eula-pdfs/' . $filename)) {
|
||||
|
||||
if (request()->input('inline') == 'true') {
|
||||
return response()->file(config('app.private_uploads') . '/eula-pdfs/' . $filename);
|
||||
}
|
||||
|
||||
return response()->download(config('app.private_uploads') . '/eula-pdfs/' . $filename);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('error', trans('general.file_does_not_exist'));
|
||||
}
|
||||
|
||||
if (Storage::exists('private_uploads/eula-pdfs/'.$filename)) {
|
||||
return response()->download(config('app.private_uploads').'/eula-pdfs/'.$filename);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('error', trans('general.file_does_not_exist'));
|
||||
|
||||
return redirect()->back()->with('error', trans('general.record_not_found'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,15 @@ class AccessoriesController extends Controller
|
||||
'notes',
|
||||
'checkouts_count',
|
||||
'qty',
|
||||
// These are *relationships* so we wouldn't normally include them in this array,
|
||||
// since they would normally create a `column not found` error,
|
||||
// BUT we account for them in the ordering switch down at the end of this method
|
||||
// DO NOT ADD ANYTHING TO THIS LIST WITHOUT CHECKING THE ORDERING SWITCH BELOW!
|
||||
'company',
|
||||
'location',
|
||||
'category',
|
||||
'supplier',
|
||||
'manufacturer',
|
||||
];
|
||||
|
||||
|
||||
@@ -61,10 +70,23 @@ class AccessoriesController extends Controller
|
||||
->with('category', 'company', 'manufacturer', 'checkouts', 'location', 'supplier', 'adminuser')
|
||||
->withCount('checkouts as checkouts_count');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$accessories = $accessories->TextSearch($request->input('search'));
|
||||
$filter = [];
|
||||
|
||||
if ($request->filled('filter')) {
|
||||
$filter = json_decode($request->input('filter'), true);
|
||||
$filter = array_filter($filter, function ($key) use ($allowed_columns) {
|
||||
return in_array($key, $allowed_columns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
}
|
||||
|
||||
if ((! is_null($filter)) && (count($filter)) > 0) {
|
||||
$accessories->ByFilter($filter);
|
||||
} elseif ($request->filled('search')) {
|
||||
$accessories->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
|
||||
if ($request->filled('company_id')) {
|
||||
$accessories->where('accessories.company_id', '=', $request->input('company_id'));
|
||||
}
|
||||
|
||||
@@ -46,11 +46,20 @@ class AssetModelsController extends Controller
|
||||
'manufacturer',
|
||||
'requestable',
|
||||
'assets_count',
|
||||
'assets_assigned_count',
|
||||
'assets_archived_count',
|
||||
'remaining',
|
||||
'category',
|
||||
'fieldset',
|
||||
'deleted_at',
|
||||
'updated_at',
|
||||
'require_serial',
|
||||
// These are *relationships* so we wouldn't normally include them in this array,
|
||||
// since they would normally create a `column not found` error,
|
||||
// BUT we account for them in the ordering switch down at the end of this method
|
||||
// DO NOT ADD ANYTHING TO THIS LIST WITHOUT CHECKING THE ORDERING SWITCH BELOW!
|
||||
'manufacturer',
|
||||
'category',
|
||||
];
|
||||
|
||||
$assetmodels = AssetModel::select([
|
||||
@@ -73,7 +82,28 @@ class AssetModelsController extends Controller
|
||||
'models.require_serial'
|
||||
])
|
||||
->with('category', 'depreciation', 'manufacturer', 'fieldset.fields.defaultValues', 'adminuser')
|
||||
->withCount('assets as assets_count');
|
||||
->withCount('assets as assets_count')
|
||||
->withCount('availableAssets as remaining')
|
||||
->withCount('assignedAssets as assets_assigned_count')
|
||||
->withCount('archivedAssets as assets_archived_count');
|
||||
|
||||
$filter = [];
|
||||
|
||||
if ($request->filled('filter')) {
|
||||
$filter = json_decode($request->input('filter'), true);
|
||||
|
||||
$filter = array_filter($filter, function ($key) use ($allowed_columns) {
|
||||
return in_array($key, $allowed_columns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
}
|
||||
|
||||
if ((! is_null($filter)) && (count($filter)) > 0) {
|
||||
$assetmodels->ByFilter($filter);
|
||||
} elseif ($request->filled('search')) {
|
||||
$assetmodels->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
|
||||
if ($request->input('status')=='deleted') {
|
||||
$assetmodels->onlyTrashed();
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Events\CheckoutableCheckedIn;
|
||||
use App\Http\Requests\StoreAssetRequest;
|
||||
use App\Http\Requests\UpdateAssetRequest;
|
||||
use App\Http\Traits\MigratesLegacyAssetLocations;
|
||||
use App\Http\Transformers\ComponentsTransformer;
|
||||
use App\Models\AccessoryCheckout;
|
||||
use App\Models\CheckoutAcceptance;
|
||||
use App\Models\LicenseSeat;
|
||||
@@ -115,6 +116,22 @@ class AssetsController extends Controller
|
||||
'asset_eol_date',
|
||||
'requestable',
|
||||
'jobtitle',
|
||||
// These are *relationships* so we wouldn't normally include them in this array,
|
||||
// since they would normally create a `column not found` error,
|
||||
// BUT we account for them in the ordering switch down at the end of this method
|
||||
// DO NOT ADD ANYTHING TO THIS LIST WITHOUT CHECKING THE ORDERING SWITCH BELOW!
|
||||
'company',
|
||||
'model',
|
||||
'location',
|
||||
'rtd_location',
|
||||
'category',
|
||||
'status_label',
|
||||
'manufacturer',
|
||||
'supplier',
|
||||
'jobtitle',
|
||||
'assigned_to',
|
||||
'created_by',
|
||||
|
||||
];
|
||||
|
||||
$all_custom_fields = CustomField::all(); //used as a 'cache' of custom fields throughout this page load
|
||||
@@ -131,6 +148,7 @@ class AssetsController extends Controller
|
||||
$filter = array_filter($filter, function ($key) use ($allowed_columns) {
|
||||
return in_array($key, $allowed_columns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
}
|
||||
|
||||
$assets = Asset::select('assets.*')
|
||||
@@ -165,7 +183,7 @@ class AssetsController extends Controller
|
||||
// Search custom fields by column name
|
||||
foreach ($all_custom_fields as $field) {
|
||||
if ($request->filled($field->db_column_name()) && $field->db_column_name()) {
|
||||
$assets->where($field->db_column_name(), '=', $request->input($field->db_column_name()));
|
||||
$assets->where('assets.'.$field->db_column_name(), '=', $request->input($field->db_column_name()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1290,9 +1308,19 @@ class AssetsController extends Controller
|
||||
|
||||
public function assignedAssets(Request $request, Asset $asset) : JsonResponse | array
|
||||
{
|
||||
$this->authorize('view', Asset::class);
|
||||
$this->authorize('view', $asset);
|
||||
|
||||
return [];
|
||||
// to do
|
||||
$query = Asset::where([
|
||||
'assigned_to' => $asset->id,
|
||||
'assigned_type' => Asset::class,
|
||||
]);
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
$assets = $query->applyOffsetAndLimit($total)->get();
|
||||
|
||||
return (new AssetsTransformer)->transformAssets($assets, $total);
|
||||
}
|
||||
|
||||
public function assignedAccessories(Request $request, Asset $asset) : JsonResponse | array
|
||||
@@ -1312,6 +1340,18 @@ class AssetsController extends Controller
|
||||
return (new AssetsTransformer)->transformCheckedoutAccessories($accessory_checkouts, $total);
|
||||
}
|
||||
|
||||
public function assignedComponents(Request $request, Asset $asset): JsonResponse|array
|
||||
{
|
||||
$this->authorize('view', Asset::class);
|
||||
$this->authorize('view', $asset);
|
||||
|
||||
$asset->loadCount('components');
|
||||
$total = $asset->components_count;
|
||||
|
||||
$components = $asset->load(['components' => fn($query) => $query->applyOffsetAndLimit($total)])->components;
|
||||
|
||||
return (new ComponentsTransformer)->transformComponents($components, $total);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate asset labels by tag
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Actions\Categories\DestroyCategoryAction;
|
||||
use App\Exceptions\ItemStillHasChildren;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Transformers\CategoriesTransformer;
|
||||
@@ -38,6 +40,8 @@ class CategoriesController extends Controller
|
||||
'consumables_count',
|
||||
'components_count',
|
||||
'licenses_count',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'image',
|
||||
'notes',
|
||||
];
|
||||
@@ -59,6 +63,23 @@ class CategoriesController extends Controller
|
||||
->withCount('accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'licenses as licenses_count', 'models as models_count');
|
||||
|
||||
|
||||
$filter = [];
|
||||
|
||||
if ($request->filled('filter')) {
|
||||
$filter = json_decode($request->input('filter'), true);
|
||||
|
||||
$filter = array_filter($filter, function ($key) use ($allowed_columns) {
|
||||
return in_array($key, $allowed_columns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
}
|
||||
|
||||
if ((! is_null($filter)) && (count($filter)) > 0) {
|
||||
$categories->ByFilter($filter);
|
||||
} elseif ($request->filled('search')) {
|
||||
$categories->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
/*
|
||||
* This checks to see if we should override the Admin Setting to show archived assets in list.
|
||||
* We don't currently use it within the Snipe-IT GUI, but will be useful for API integrations where they
|
||||
@@ -72,10 +93,6 @@ class CategoriesController extends Controller
|
||||
$categories = $categories->withCount('showableAssets as assets_count');
|
||||
}
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$categories = $categories->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
if ($request->filled('name')) {
|
||||
$categories->where('name', '=', $request->input('name'));
|
||||
}
|
||||
@@ -209,17 +226,21 @@ class CategoriesController extends Controller
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id) : JsonResponse
|
||||
public function destroy(Category $category): JsonResponse
|
||||
{
|
||||
$this->authorize('delete', Category::class);
|
||||
$category = Category::withCount('assets as assets_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'licenses as licenses_count', 'models as models_count')->findOrFail($id);
|
||||
|
||||
if (! $category->isDeletable()) {
|
||||
try {
|
||||
DestroyCategoryAction::run(category: $category);
|
||||
} catch (ItemStillHasChildren $e) {
|
||||
return response()->json(
|
||||
Helper::formatStandardApiResponse('error', null, trans('admin/categories/message.assoc_items', ['asset_type'=>$category->category_type]))
|
||||
Helper::formatStandardApiResponse('error', null, trans('general.bulk_delete_associations.general_assoc_warning', ['asset_type' => $category->category_type]))
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
return response()->json(
|
||||
Helper::formatStandardApiResponse('error', null, trans('general.something_went_wrong'))
|
||||
);
|
||||
}
|
||||
$category->delete();
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/categories/message.delete.success')));
|
||||
}
|
||||
|
||||
@@ -45,16 +45,40 @@ class ComponentsController extends Controller
|
||||
'qty',
|
||||
'image',
|
||||
'notes',
|
||||
// These are *relationships* so we wouldn't normally include them in this array,
|
||||
// since they would normally create a `column not found` error,
|
||||
// BUT we account for them in the ordering switch down at the end of this method
|
||||
// DO NOT ADD ANYTHING TO THIS LIST WITHOUT CHECKING THE ORDERING SWITCH BELOW!
|
||||
'company',
|
||||
'location',
|
||||
'category',
|
||||
'manufacturer',
|
||||
'supplier',
|
||||
|
||||
];
|
||||
|
||||
$components = Component::select('components.*')
|
||||
->with('company', 'location', 'category', 'assets', 'supplier', 'adminuser', 'manufacturer', 'uncontrainedAssets')
|
||||
->withSum('uncontrainedAssets', 'components_assets.assigned_qty');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$components = $components->TextSearch($request->input('search'));
|
||||
$filter = [];
|
||||
|
||||
if ($request->filled('filter')) {
|
||||
$filter = json_decode($request->input('filter'), true);
|
||||
|
||||
$filter = array_filter($filter, function ($key) use ($allowed_columns) {
|
||||
return in_array($key, $allowed_columns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
}
|
||||
|
||||
if ((! is_null($filter)) && (count($filter)) > 0) {
|
||||
$components->ByFilter($filter);
|
||||
} elseif ($request->filled('search')) {
|
||||
$components->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
|
||||
if ($request->filled('name')) {
|
||||
$components->where('name', '=', $request->input('name'));
|
||||
}
|
||||
|
||||
@@ -31,10 +31,53 @@ class ConsumablesController extends Controller
|
||||
$consumables = Consumable::with('company', 'location', 'category', 'supplier', 'manufacturer')
|
||||
->withCount('users as consumables_users_count');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$consumables = $consumables->TextSearch(e($request->input('search')));
|
||||
// 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',
|
||||
'order_number',
|
||||
'min_amt',
|
||||
'purchase_date',
|
||||
'purchase_cost',
|
||||
'company',
|
||||
'category',
|
||||
'model_number',
|
||||
'item_no',
|
||||
'manufacturer',
|
||||
'location',
|
||||
'qty',
|
||||
'image',
|
||||
// These are *relationships* so we wouldn't normally include them in this array,
|
||||
// since they would normally create a `column not found` error,
|
||||
// BUT we account for them in the ordering switch down at the end of this method
|
||||
// DO NOT ADD ANYTHING TO THIS LIST WITHOUT CHECKING THE ORDERING SWITCH BELOW!
|
||||
'company',
|
||||
'location',
|
||||
'category',
|
||||
'supplier',
|
||||
'manufacturer',
|
||||
];
|
||||
|
||||
|
||||
$filter = [];
|
||||
|
||||
if ($request->filled('filter')) {
|
||||
$filter = json_decode($request->input('filter'), true);
|
||||
|
||||
$filter = array_filter($filter, function ($key) use ($allowed_columns) {
|
||||
return in_array($key, $allowed_columns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
}
|
||||
|
||||
if ((! is_null($filter)) && (count($filter)) > 0) {
|
||||
$consumables->ByFilter($filter);
|
||||
} elseif ($request->filled('search')) {
|
||||
$consumables->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
|
||||
if ($request->filled('name')) {
|
||||
$consumables->where('name', '=', $request->input('name'));
|
||||
}
|
||||
@@ -96,25 +139,6 @@ class ConsumablesController extends Controller
|
||||
$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.
|
||||
$allowed_columns = [
|
||||
'id',
|
||||
'name',
|
||||
'order_number',
|
||||
'min_amt',
|
||||
'purchase_date',
|
||||
'purchase_cost',
|
||||
'company',
|
||||
'category',
|
||||
'model_number',
|
||||
'item_no',
|
||||
'manufacturer',
|
||||
'location',
|
||||
'qty',
|
||||
'image'
|
||||
];
|
||||
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
|
||||
$consumables = $consumables->orderBy($sort, $order);
|
||||
break;
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Transformers\LicensesTransformer;
|
||||
use App\Http\Transformers\SelectlistTransformer;
|
||||
use App\Models\License;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -25,6 +26,15 @@ class LicensesController extends Controller
|
||||
$this->authorize('view', License::class);
|
||||
|
||||
$licenses = License::with('company', 'manufacturer', 'supplier','category', 'adminuser')->withCount('freeSeats as free_seats_count');
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
if ($request->input('status')=='inactive') {
|
||||
$licenses->ExpiredLicenses();
|
||||
} elseif ($request->input('status')=='expiring') {
|
||||
$licenses->ExpiringLicenses($settings->alert_interval);
|
||||
} else {
|
||||
$licenses->ActiveLicenses();
|
||||
}
|
||||
|
||||
if ($request->filled('company_id')) {
|
||||
$licenses->where('licenses.company_id', '=', $request->input('company_id'));
|
||||
@@ -94,6 +104,8 @@ class LicensesController extends Controller
|
||||
$licenses->onlyTrashed();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Make sure the offset and limit are actually integers and do not exceed system limits
|
||||
$offset = ($request->input('offset') > $licenses->count()) ? $licenses->count() : app('api_offset_value');
|
||||
$limit = app('api_limit_value');
|
||||
|
||||
@@ -37,10 +37,14 @@ class LocationsController extends Controller
|
||||
'address',
|
||||
'address2',
|
||||
'assets_count',
|
||||
'assets_count',
|
||||
'assigned_assets_count',
|
||||
'rtd_assets_count',
|
||||
'accessories_count',
|
||||
'assigned_accessories_count',
|
||||
'assigned_assets_count',
|
||||
'assigned_assets_count',
|
||||
'components_count',
|
||||
'consumables_count',
|
||||
'users_count',
|
||||
'children_count',
|
||||
'city',
|
||||
'country',
|
||||
'created_at',
|
||||
@@ -54,7 +58,6 @@ class LocationsController extends Controller
|
||||
'rtd_assets_count',
|
||||
'state',
|
||||
'updated_at',
|
||||
'users_count',
|
||||
'zip',
|
||||
'notes',
|
||||
];
|
||||
@@ -79,8 +82,9 @@ class LocationsController extends Controller
|
||||
'locations.currency',
|
||||
'locations.company_id',
|
||||
'locations.notes',
|
||||
'locations.created_by',
|
||||
'locations.deleted_at',
|
||||
])
|
||||
->withCount('assignedAssets as assigned_assets_count')
|
||||
->withCount('assignedAssets as assigned_assets_count')
|
||||
->withCount('assets as assets_count')
|
||||
->withCount('assignedAccessories as assigned_accessories_count')
|
||||
@@ -88,6 +92,8 @@ class LocationsController extends Controller
|
||||
->withCount('rtd_assets as rtd_assets_count')
|
||||
->withCount('children as children_count')
|
||||
->withCount('users as users_count')
|
||||
->withCount('consumables as consumables_count')
|
||||
->withCount('components as components_count')
|
||||
->with('adminuser');
|
||||
|
||||
// Only scope locations if the setting is enabled
|
||||
@@ -131,6 +137,14 @@ class LocationsController extends Controller
|
||||
$locations->where('locations.company_id', '=', $request->input('company_id'));
|
||||
}
|
||||
|
||||
if ($request->filled('parent_id')) {
|
||||
$locations->where('locations.parent_id', '=', $request->input('parent_id'));
|
||||
}
|
||||
|
||||
if ($request->input('status') == 'deleted') {
|
||||
$locations->onlyTrashed();
|
||||
}
|
||||
|
||||
// Make sure the offset and limit are actually integers and do not exceed system limits
|
||||
$offset = ($request->input('offset') > $locations->count()) ? $locations->count() : app('api_offset_value');
|
||||
$limit = app('api_limit_value');
|
||||
@@ -224,8 +238,13 @@ class LocationsController extends Controller
|
||||
])
|
||||
->withCount('assignedAssets as assigned_assets_count')
|
||||
->withCount('assets as assets_count')
|
||||
->withCount('assignedAccessories as assigned_accessories_count')
|
||||
->withCount('accessories as accessories_count')
|
||||
->withCount('rtd_assets as rtd_assets_count')
|
||||
->withCount('children as children_count')
|
||||
->withCount('users as users_count')
|
||||
->withCount('consumables as consumables_count')
|
||||
->withCount('components as components_count')
|
||||
->findOrFail($id);
|
||||
|
||||
return (new LocationsTransformer)->transformLocation($location);
|
||||
@@ -320,11 +339,15 @@ class LocationsController extends Controller
|
||||
{
|
||||
$this->authorize('delete', Location::class);
|
||||
$location = Location::withCount('assignedAssets as assigned_assets_count')
|
||||
->withCount('assignedAssets as assigned_assets_count')
|
||||
->withCount('assets as assets_count')
|
||||
->withCount('assignedAccessories as assigned_accessories_count')
|
||||
->withCount('accessories as accessories_count')
|
||||
->withCount('rtd_assets as rtd_assets_count')
|
||||
->withCount('children as children_count')
|
||||
->withCount('users as users_count')
|
||||
->withCount('accessories as accessories_count')
|
||||
->withCount('consumables as consumables_count')
|
||||
->withCount('components as components_count')
|
||||
->findOrFail($id);
|
||||
|
||||
if (! $location->isDeletable()) {
|
||||
|
||||
@@ -52,6 +52,10 @@ class MaintenancesController extends Controller
|
||||
$maintenances->where('maintenances.created_by', '=', $request->input('created_by'));
|
||||
}
|
||||
|
||||
if ($request->filled('url')) {
|
||||
$maintenances->where('maintenances.url', '=', $request->input('url'));
|
||||
}
|
||||
|
||||
if ($request->filled('asset_maintenance_type')) {
|
||||
$maintenances->where('asset_maintenance_type', '=', $request->input('asset_maintenance_type'));
|
||||
}
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Actions\Manufacturers\DeleteManufacturerAction;
|
||||
use App\Exceptions\ItemStillHasAccessories;
|
||||
use App\Exceptions\ItemStillHasAssets;
|
||||
use App\Exceptions\ItemStillHasChildren;
|
||||
use App\Exceptions\ItemStillHasComponents;
|
||||
use App\Exceptions\ItemStillHasConsumables;
|
||||
use App\Exceptions\ItemStillHasLicenses;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Transformers\ManufacturersTransformer;
|
||||
@@ -184,19 +191,19 @@ class ManufacturersController extends Controller
|
||||
* @since [v4.0]
|
||||
* @param int $id
|
||||
*/
|
||||
public function destroy($id) : JsonResponse
|
||||
public function destroy(Manufacturer $manufacturer): JsonResponse
|
||||
{
|
||||
$this->authorize('delete', Manufacturer::class);
|
||||
$manufacturer = Manufacturer::findOrFail($id);
|
||||
$this->authorize('delete', $manufacturer);
|
||||
|
||||
if ($manufacturer->isDeletable()) {
|
||||
$manufacturer->delete();
|
||||
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/manufacturers/message.delete.success')));
|
||||
try {
|
||||
DeleteManufacturerAction::run($manufacturer);
|
||||
} catch (ItemStillHasChildren $e) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.bulk_delete_associations.general_assoc_warning', ['item' => trans('general.manufacturer')])));
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.something_went_wrong')));
|
||||
}
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/manufacturers/message.assoc_users')));
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/manufacturers/message.delete.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Actions\Suppliers\DestroySupplierAction;
|
||||
use App\Exceptions\ItemStillHasAccessories;
|
||||
use App\Exceptions\ItemStillHasComponents;
|
||||
use App\Exceptions\ItemStillHasConsumables;
|
||||
use App\Exceptions\ItemStillHasMaintenances;
|
||||
use App\Exceptions\ItemStillHasAssets;
|
||||
use App\Exceptions\ItemStillHasLicenses;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Transformers\SelectlistTransformer;
|
||||
@@ -191,27 +198,40 @@ class SuppliersController extends Controller
|
||||
* @since [v4.0]
|
||||
* @param int $id
|
||||
*/
|
||||
public function destroy($id) : JsonResponse
|
||||
public function destroy(Supplier $supplier): JsonResponse
|
||||
{
|
||||
$this->authorize('delete', Supplier::class);
|
||||
$supplier = Supplier::with('maintenances', 'assets', 'licenses')->withCount('maintenances as maintenances_count', 'assets as assets_count', 'licenses as licenses_count')->findOrFail($id);
|
||||
$this->authorize('delete', $supplier);
|
||||
|
||||
|
||||
if ($supplier->assets_count > 0) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/suppliers/message.delete.assoc_assets', ['asset_count' => (int) $supplier->assets_count])));
|
||||
try {
|
||||
DestroySupplierAction::run(supplier: $supplier);
|
||||
} catch (ItemStillHasAssets $e) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.bulk_delete_associations.assoc_assets', [
|
||||
'asset_count' => (int) $supplier->assets_count, 'item' => trans('general.supplier')
|
||||
])));
|
||||
} catch (ItemStillHasMaintenances $e) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.bulk_delete_associations.assoc_maintenances', [
|
||||
'asset_maintenances_count' => $supplier->asset_maintenances_count, 'item' => trans('general.supplier')
|
||||
])));
|
||||
} catch (ItemStillHasLicenses $e) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.bulk_delete_associations.assoc_licenses', [
|
||||
'licenses_count' => (int) $supplier->licenses_count, 'item' => trans('general.supplier')
|
||||
])));
|
||||
} catch (ItemStillHasAccessories $e) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.bulk_delete_associations.assoc_accessories', [
|
||||
'accessories_count' => (int) $supplier->accessories_count, 'item' => trans('general.supplier')
|
||||
])));
|
||||
} catch (ItemStillHasConsumables $e) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.bulk_delete_associations.assoc_consumables', [
|
||||
'consumables_count' => (int) $supplier->consumables_count, 'item' => trans('general.supplier')
|
||||
])));
|
||||
} catch (ItemStillHasComponents $e) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.bulk_delete_associations.assoc_components', [
|
||||
'components_count' => (int) $supplier->components_count, 'item' => trans('general.supplier')
|
||||
])));
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.something_went_wrong')));
|
||||
}
|
||||
|
||||
if ($supplier->maintenances_count > 0) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/suppliers/message.delete.assoc_maintenances', ['maintenances_count' => $supplier->maintenances_count])));
|
||||
}
|
||||
|
||||
if ($supplier->licenses_count > 0) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/suppliers/message.delete.assoc_licenses', ['licenses_count' => (int) $supplier->licenses_count])));
|
||||
}
|
||||
|
||||
$supplier->delete();
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/suppliers/message.delete.success')));
|
||||
}
|
||||
|
||||
|
||||
@@ -193,8 +193,12 @@ class UploadedFilesController extends Controller
|
||||
|
||||
|
||||
// Check for the file
|
||||
$log = Actionlog::find($file_id)->where('item_type', self::$map_object_type[$object_type])
|
||||
->where('item_id', $object->id)->first();
|
||||
$log = Actionlog::query()
|
||||
->where('id', $file_id)
|
||||
->where('action_type', 'uploaded')
|
||||
->where('item_type', self::$map_object_type[$object_type])
|
||||
->where('item_id', $object->id)
|
||||
->first();
|
||||
|
||||
if ($log) {
|
||||
// Check the file actually exists, and delete it
|
||||
@@ -213,4 +217,4 @@ class UploadedFilesController extends Controller
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans_choice('general.file_upload_status.delete.error', 1)), 500);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,9 +103,75 @@ class UsersController extends Controller
|
||||
'managedLocations as manages_locations_count'
|
||||
]);
|
||||
|
||||
$allowed_columns =
|
||||
[
|
||||
'last_name',
|
||||
'first_name',
|
||||
'display_name',
|
||||
'email',
|
||||
'jobtitle',
|
||||
'username',
|
||||
'employee_num',
|
||||
'groups',
|
||||
'activated',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'two_factor_enrolled',
|
||||
'two_factor_optin',
|
||||
'last_login',
|
||||
'assets_count',
|
||||
'licenses_count',
|
||||
'consumables_count',
|
||||
'accessories_count',
|
||||
'manages_users_count',
|
||||
'manages_locations_count',
|
||||
'phone',
|
||||
'mobile',
|
||||
'address',
|
||||
'city',
|
||||
'state',
|
||||
'country',
|
||||
'zip',
|
||||
'id',
|
||||
'ldap_import',
|
||||
'two_factor_optin',
|
||||
'two_factor_enrolled',
|
||||
'remote',
|
||||
'vip',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'autoassign_licenses',
|
||||
'website',
|
||||
'locale',
|
||||
'notes',
|
||||
'employee_num',
|
||||
|
||||
if ($request->filled('search') != '') {
|
||||
$users = $users->TextSearch($request->input('search'));
|
||||
// These are *relationships* so we wouldn't normally include them in this array,
|
||||
// since they would normally create a `column not found` error,
|
||||
// BUT we account for them in the ordering switch down at the end of this method
|
||||
// DO NOT ADD ANYTHING TO THIS LIST WITHOUT CHECKING THE ORDERING SWITCH BELOW!
|
||||
'company',
|
||||
'location',
|
||||
'department',
|
||||
'manager',
|
||||
'created_by',
|
||||
|
||||
];
|
||||
|
||||
$filter = [];
|
||||
|
||||
if ($request->filled('filter')) {
|
||||
$filter = json_decode($request->input('filter'), true);
|
||||
$filter = array_filter($filter, function ($key) use ($allowed_columns) {
|
||||
return in_array($key, $allowed_columns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
}
|
||||
|
||||
if ((! is_null($filter)) && (count($filter)) > 0) {
|
||||
$users->ByFilter($filter);
|
||||
} elseif ($request->filled('search')) {
|
||||
$users->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
if ($request->filled('activated')) {
|
||||
@@ -286,49 +352,6 @@ class UsersController extends Controller
|
||||
$users->orderBy('first_name', $order);
|
||||
break;
|
||||
default:
|
||||
$allowed_columns =
|
||||
[
|
||||
'last_name',
|
||||
'first_name',
|
||||
'display_name',
|
||||
'email',
|
||||
'jobtitle',
|
||||
'username',
|
||||
'employee_num',
|
||||
'groups',
|
||||
'activated',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'two_factor_enrolled',
|
||||
'two_factor_optin',
|
||||
'last_login',
|
||||
'assets_count',
|
||||
'licenses_count',
|
||||
'consumables_count',
|
||||
'accessories_count',
|
||||
'manages_users_count',
|
||||
'manages_locations_count',
|
||||
'phone',
|
||||
'mobile',
|
||||
'address',
|
||||
'city',
|
||||
'state',
|
||||
'country',
|
||||
'zip',
|
||||
'id',
|
||||
'ldap_import',
|
||||
'two_factor_optin',
|
||||
'two_factor_enrolled',
|
||||
'remote',
|
||||
'vip',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'autoassign_licenses',
|
||||
'website',
|
||||
'locale',
|
||||
'notes',
|
||||
];
|
||||
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'first_name';
|
||||
$users = $users->orderBy($sort, $order);
|
||||
break;
|
||||
|
||||
@@ -363,7 +363,7 @@ class AssetsController extends Controller
|
||||
$asset->purchase_cost = $request->input('purchase_cost', null);
|
||||
$asset->purchase_date = $request->input('purchase_date', null);
|
||||
$asset->next_audit_date = $request->input('next_audit_date', null);
|
||||
if ($request->filled('purchase_date') && !$request->filled('asset_eol_date') && ($asset->model->eol > 0)) {
|
||||
if ($request->filled('purchase_date') && !$request->filled('asset_eol_date') && ($asset->model?->eol > 0)) {
|
||||
$asset->purchase_date = $request->input('purchase_date', null);
|
||||
$asset->asset_eol_date = Carbon::parse($request->input('purchase_date'))->addMonths($asset->model->eol)->format('Y-m-d');
|
||||
$asset->eol_explicit = false;
|
||||
@@ -379,7 +379,7 @@ class AssetsController extends Controller
|
||||
} else {
|
||||
$asset->eol_explicit = true;
|
||||
}
|
||||
} elseif (!$request->filled('asset_eol_date') && (($asset->model->eol) == 0)) {
|
||||
} elseif (!$request->filled('asset_eol_date') && (($asset->model?->eol) == 0)) {
|
||||
$asset->asset_eol_date = null;
|
||||
$asset->eol_explicit = false;
|
||||
}
|
||||
@@ -398,6 +398,7 @@ class AssetsController extends Controller
|
||||
$asset->assigned_to = null;
|
||||
$asset->assigned_type = null;
|
||||
$asset->accepted = null;
|
||||
$asset->last_checkin = now();
|
||||
event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on asset update with '.$status->getStatuslabelType().' status', date('Y-m-d H:i:s'), $originalValues));
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ class BulkAssetsController extends Controller
|
||||
$modelNames = [];
|
||||
|
||||
foreach($models as $model) {
|
||||
$modelNames[] = $model->model->name;
|
||||
$modelNames[] = $model->model?->name;
|
||||
}
|
||||
|
||||
if ($request->filled('bulk_actions')) {
|
||||
@@ -240,10 +240,6 @@ class BulkAssetsController extends Controller
|
||||
$custom_fields_to_null[str_replace('null', '', $key)] = $value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (! $request->filled('ids') || count($request->input('ids')) == 0) {
|
||||
return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.update.no_assets_selected'));
|
||||
@@ -274,6 +270,7 @@ class BulkAssetsController extends Controller
|
||||
|| ($request->filled('company_id'))
|
||||
|| ($request->filled('status_id'))
|
||||
|| ($request->filled('model_id'))
|
||||
|| ($request->filled('notes'))
|
||||
|| ($request->filled('next_audit_date'))
|
||||
|| ($request->filled('asset_eol_date'))
|
||||
|| ($request->filled('null_name'))
|
||||
@@ -470,7 +467,7 @@ class BulkAssetsController extends Controller
|
||||
*/
|
||||
|
||||
// Does the model have a fieldset?
|
||||
if ($asset->model->fieldset) {
|
||||
if ($asset->model?->fieldset) {
|
||||
foreach ($asset->model->fieldset->fields as $field) {
|
||||
|
||||
// null custom fields
|
||||
@@ -621,9 +618,25 @@ class BulkAssetsController extends Controller
|
||||
{
|
||||
$this->authorize('checkout', Asset::class);
|
||||
|
||||
$alreadyAssigned = collect();
|
||||
|
||||
if (old('selected_assets') && is_array(old('selected_assets'))) {
|
||||
$assets = Asset::findMany(old('selected_assets'));
|
||||
|
||||
[$assignable, $alreadyAssigned] = $assets->partition(function (Asset $asset) {
|
||||
return !$asset->assigned_to;
|
||||
});
|
||||
|
||||
session()->flashInput(['selected_assets' => $assignable->pluck('id')->values()->toArray()]);
|
||||
}
|
||||
|
||||
$do_not_change = ['' => trans('general.do_not_change')];
|
||||
$status_label_list = $do_not_change + Helper::deployableStatusLabelList();
|
||||
return view('hardware/bulk-checkout')->with('statusLabel_list', $status_label_list);
|
||||
|
||||
return view('hardware/bulk-checkout', [
|
||||
'statusLabel_list' => $status_label_list,
|
||||
'removed_assets' => $alreadyAssigned,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -647,6 +660,30 @@ class BulkAssetsController extends Controller
|
||||
|
||||
$assets = Asset::findOrFail($asset_ids);
|
||||
|
||||
// Prevent checking out assets that are already checked out
|
||||
if ($assets->pluck('assigned_to')->unique()->filter()->isNotEmpty()) {
|
||||
// re-add the asset ids so the assets select is re-populated
|
||||
$request->session()->flashInput(['selected_assets' => $asset_ids]);
|
||||
|
||||
return redirect(route('hardware.bulkcheckout.show'))
|
||||
->with('error', trans('general.error_assets_already_checked_out'));
|
||||
}
|
||||
|
||||
// Prevent checking out assets across companies if FMCS enabled
|
||||
if (Setting::getSettings()->full_multiple_companies_support && $target->company_id) {
|
||||
$company_ids = $assets->pluck('company_id')->unique();
|
||||
|
||||
// if there is more than one unique company id or the singular company id does not match
|
||||
// then the checkout is invalid
|
||||
if ($company_ids->count() > 1 || $company_ids->first() != $target->company_id) {
|
||||
// re-add the asset ids so the assets select is re-populated
|
||||
$request->session()->flashInput(['selected_assets' => $asset_ids]);
|
||||
|
||||
return redirect(route('hardware.bulkcheckout.show'))
|
||||
->with('error', trans('general.error_user_company_multiple'));
|
||||
}
|
||||
}
|
||||
|
||||
if (request('checkout_to_type') == 'asset') {
|
||||
foreach ($asset_ids as $asset_id) {
|
||||
if ($target->id == $asset_id) {
|
||||
|
||||
59
app/Http/Controllers/BulkCategoriesController.php
Normal file
59
app/Http/Controllers/BulkCategoriesController.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Actions\Categories\DestroyCategoryAction;
|
||||
use App\Exceptions\ItemStillHasAccessories;
|
||||
use App\Exceptions\ItemStillHasAssetModels;
|
||||
use App\Exceptions\ItemStillHasAssets;
|
||||
use App\Exceptions\ItemStillHasComponents;
|
||||
use App\Exceptions\ItemStillHasConsumables;
|
||||
use App\Exceptions\ItemStillHasLicenses;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BulkCategoriesController extends Controller
|
||||
{
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
$this->authorize('delete', Category::class);
|
||||
|
||||
$errors = [];
|
||||
$success_count = 0;
|
||||
|
||||
foreach ($request->ids as $id) {
|
||||
$category = Category::find($id);
|
||||
if (is_null($category)) {
|
||||
$errors[] = trans('admin/categories/message.does_not_exist');
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
DestroyCategoryAction::run(category: $category);
|
||||
$success_count++;
|
||||
} catch (ItemStillHasAccessories $e) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_assets_no_count', ['item_name' => $category->name, 'item' => trans('general.category')]);
|
||||
} catch (ItemStillHasAssetModels) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_asset_models_no_count', ['item_name' => $category->name, 'item' => trans('general.category')]);
|
||||
} catch (ItemStillHasAssets) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_assets_no_count', ['item_name' => $category->name, 'item' => trans('general.category')]);
|
||||
} catch (ItemStillHasComponents) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_components_no_count', ['item_name' => $category->name, 'item' => trans('general.category')]);
|
||||
} catch (ItemStillHasConsumables) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_consumables_no_count', ['item_name' => $category->name, 'item' => trans('general.category')]);
|
||||
} catch (ItemStillHasLicenses) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_licenses_no_count', ['item_name' => $category->name, 'item' => trans('general.category')]);;
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
$errors[] = trans('general.something_went_wrong');
|
||||
}
|
||||
}
|
||||
if (count($errors) > 0) {
|
||||
if ($success_count > 0) {
|
||||
return redirect()->route('categories.index')->with('success', trans_choice('admin/categories/message.delete.partial_success', $success_count, ['count' => $success_count]))->with('multi_error_messages', $errors);
|
||||
}
|
||||
return redirect()->route('categories.index')->with('multi_error_messages', $errors);
|
||||
} else {
|
||||
return redirect()->route('categories.index')->with('success', trans('admin/categories/message.delete.bulk_success'));
|
||||
}
|
||||
}
|
||||
}
|
||||
57
app/Http/Controllers/BulkManufacturersController.php
Normal file
57
app/Http/Controllers/BulkManufacturersController.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Actions\Manufacturers\DeleteManufacturerAction;
|
||||
use App\Exceptions\ItemStillHasAccessories;
|
||||
use App\Exceptions\ItemStillHasAssetModels;
|
||||
use App\Exceptions\ItemStillHasAssets;
|
||||
use App\Exceptions\ItemStillHasChildren;
|
||||
use App\Exceptions\ItemStillHasComponents;
|
||||
use App\Exceptions\ItemStillHasConsumables;
|
||||
use App\Exceptions\ItemStillHasLicenses;
|
||||
use App\Models\Manufacturer;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BulkManufacturersController extends Controller
|
||||
{
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
$this->authorize('delete', Manufacturer::class);
|
||||
|
||||
$errors = [];
|
||||
$success_count = 0;
|
||||
foreach ($request->ids as $id) {
|
||||
$manufacturer = Manufacturer::find($id);
|
||||
if (is_null($manufacturer)) {
|
||||
$errors[] = trans('admin/manufacturers/message.does_not_exist');
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
DeleteManufacturerAction::run(manufacturer: $manufacturer);
|
||||
$success_count++;
|
||||
} catch (ItemStillHasAssets $e) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_assets_no_count', ['item_name' => $manufacturer->name, 'item' => trans('general.manufacturer')]);
|
||||
} catch (ItemStillHasAccessories $e) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_accessories_no_count', ['item_name' => $manufacturer->name, 'item' => trans('general.manufacturer')]);
|
||||
} catch (ItemStillHasConsumables $e) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_consumables_no_count', ['item_name' => $manufacturer->name, 'item' => trans('general.manufacturer')]);
|
||||
} catch (ItemStillHasComponents $e) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_components_no_count', ['item_name' => $manufacturer->name, 'item' => trans('general.manufacturer')]);
|
||||
} catch (ItemStillHasLicenses $e) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_licenses_no_count', ['item_name' => $manufacturer->name, 'item' => trans('general.manufacturer')]);;
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
$errors[] = trans('general.something_went_wrong');
|
||||
}
|
||||
}
|
||||
if (count($errors) > 0) {
|
||||
if ($success_count > 0) {
|
||||
return redirect()->route('manufacturers.index')->with('success', trans_choice('admin/manufacturers/message.delete.partial_success', $success_count, ['count' => $success_count]))->with('multi_error_messages', $errors);
|
||||
}
|
||||
return redirect()->route('manufacturers.index')->with('multi_error_messages', $errors);
|
||||
} else {
|
||||
return redirect()->route('manufacturers.index')->with('success', trans('admin/manufacturers/message.delete.bulk_success'));
|
||||
}
|
||||
}
|
||||
}
|
||||
58
app/Http/Controllers/BulkSuppliersController.php
Normal file
58
app/Http/Controllers/BulkSuppliersController.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Actions\Suppliers\DestroySupplierAction;
|
||||
use App\Exceptions\ItemStillHasAccessories;
|
||||
use App\Exceptions\ItemStillHasComponents;
|
||||
use App\Exceptions\ItemStillHasConsumables;
|
||||
use App\Exceptions\ItemStillHasMaintenances;
|
||||
use App\Exceptions\ItemStillHasAssets;
|
||||
use App\Exceptions\ItemStillHasLicenses;
|
||||
use App\Models\Supplier;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BulkSuppliersController extends Controller
|
||||
{
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
$this->authorize('delete', Supplier::class);
|
||||
|
||||
$errors = [];
|
||||
$success_count = 0;
|
||||
|
||||
foreach ($request->ids as $id) {
|
||||
$supplier = Supplier::find($id);
|
||||
if (is_null($supplier)) {
|
||||
$errors[] = trans('admin/suppliers/message.delete.not_found');
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
DestroySupplierAction::run(supplier: $supplier);
|
||||
} catch (ItemStillHasAssets $e) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_assets', ['asset_count' => (int) $supplier->assets_count, 'item' => trans('general.supplier'), 'item_name' => $supplier->name]);
|
||||
} catch (ItemStillHasMaintenances $e) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_maintenances', ['asset_maintenances_count' => $supplier->asset_maintenances_count, 'item' => trans('general.supplier'), 'item_name' => $supplier->name]);
|
||||
} catch (ItemStillHasLicenses $e) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_licenses', ['licenses_count' => (int) $supplier->licenses_count, 'item' => trans('general.supplier'), 'item_name' => $supplier->name]);
|
||||
} catch (ItemStillHasAccessories $e) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_accessories', ['accessories_count' => (int) $supplier->accessories_count, 'item' => trans('general.supplier'), 'item_name' => $supplier->name]);
|
||||
} catch (ItemStillHasConsumables $e) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_consumables', ['consumables_count' => (int) $supplier->consumables_count, 'item' => trans('general.supplier'), 'item_name' => $supplier->name]);
|
||||
} catch (ItemStillHasComponents $e) {
|
||||
$errors[] = trans('general.bulk_delete_associations.assoc_components', ['components_count' => (int) $supplier->components_count, 'item' => trans('general.supplier'), 'item_name' => $supplier->name]);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
$errors[] = trans('general.something_went_wrong');
|
||||
}
|
||||
}
|
||||
if (count($errors) > 0) {
|
||||
if ($success_count > 0) {
|
||||
return redirect()->route('suppliers.index')->with('success', trans_choice('admin/suppliers/message.delete.partial_success', $success_count, ['count' => $success_count]))->with('multi_error_messages', $errors);
|
||||
}
|
||||
return redirect()->route('suppliers.index')->with('multi_error_messages', $errors);
|
||||
} else {
|
||||
return redirect()->route('suppliers.index')->with('success', trans('admin/suppliers/message.delete.bulk_success'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,14 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Actions\Categories\DestroyCategoryAction;
|
||||
use App\Exceptions\ItemStillHasAccessories;
|
||||
use App\Exceptions\ItemStillHasAssetModels;
|
||||
use App\Exceptions\ItemStillHasAssets;
|
||||
use App\Exceptions\ItemStillHasChildren;
|
||||
use App\Exceptions\ItemStillHasComponents;
|
||||
use App\Exceptions\ItemStillHasConsumables;
|
||||
use App\Exceptions\ItemStillHasLicenses;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Requests\ImageUploadRequest;
|
||||
use App\Models\Category;
|
||||
@@ -143,20 +151,18 @@ class CategoriesController extends Controller
|
||||
* @since [v1.0]
|
||||
* @param int $categoryId
|
||||
*/
|
||||
public function destroy($categoryId) : RedirectResponse
|
||||
public function destroy(Category $category): RedirectResponse
|
||||
{
|
||||
$this->authorize('delete', Category::class);
|
||||
// Check if the category exists
|
||||
if (is_null($category = Category::withCount('assets as assets_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'licenses as licenses_count', 'models as models_count')->findOrFail($categoryId))) {
|
||||
return redirect()->route('categories.index')->with('error', trans('admin/categories/message.not_found'));
|
||||
try {
|
||||
DestroyCategoryAction::run($category);
|
||||
} catch (ItemStillHasChildren $e) {
|
||||
return redirect()->route('categories.index')->with('error', trans('general.bulk_delete_associations.general_assoc_warning', ['item' => trans('general.category')]));
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
return redirect()->route('categories.index')->with('error', trans('admin/categories/message.delete.error'));
|
||||
}
|
||||
|
||||
if (! $category->isDeletable()) {
|
||||
return redirect()->route('categories.index')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=> $category->category_type]));
|
||||
}
|
||||
|
||||
Storage::disk('public')->delete('categories'.'/'.$category->image);
|
||||
$category->delete();
|
||||
return redirect()->route('categories.index')->with('success', trans('admin/categories/message.delete.success'));
|
||||
}
|
||||
|
||||
|
||||
@@ -102,13 +102,15 @@ class ComponentCheckoutController extends Controller
|
||||
return redirect()->route('components.checkout.show', $componentId)->with('error', trans('general.error_user_company'));
|
||||
}
|
||||
|
||||
$component->checkout_qty = $request->input('assigned_qty');
|
||||
|
||||
// Update the component data
|
||||
$component->asset_id = $request->input('asset_id');
|
||||
$component->assets()->attach($component->id, [
|
||||
'component_id' => $component->id,
|
||||
'created_by' => auth()->user()->id,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'assigned_qty' => $request->input('assigned_qty'),
|
||||
'assigned_qty' => $component->checkout_qty,
|
||||
'asset_id' => $request->input('asset_id'),
|
||||
'note' => $request->input('note'),
|
||||
]);
|
||||
|
||||
@@ -25,7 +25,7 @@ class LicenseCheckoutController extends Controller
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param $id
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
* @return \Illuminate\Contracts\View\View |\Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function create(License $license)
|
||||
@@ -39,6 +39,11 @@ class LicenseCheckoutController extends Controller
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkout.not_enough_seats'));
|
||||
}
|
||||
|
||||
// Make sure the license is expired or terminated
|
||||
if ($license->isInactive()) {
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkout.license_is_inactive'));
|
||||
}
|
||||
|
||||
// We don't currently allow checking out licenses to locations, so we'll reset that to user if needed
|
||||
if (session()->get('checkout_to_type') == 'location') {
|
||||
session()->put(['checkout_to_type' => 'user']);
|
||||
@@ -70,8 +75,19 @@ class LicenseCheckoutController extends Controller
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.not_found'));
|
||||
}
|
||||
|
||||
|
||||
$this->authorize('checkout', $license);
|
||||
|
||||
// Make sure there is at least one available to checkout
|
||||
if ($license->availCount()->count() < 1) {
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkout.not_enough_seats'));
|
||||
}
|
||||
|
||||
// Make sure the license is expired or terminated
|
||||
if ($license->isInactive()) {
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkout.license_is_inactive'));
|
||||
}
|
||||
|
||||
$licenseSeat = $this->findLicenseSeatToCheckout($license, $seatId);
|
||||
$licenseSeat->created_by = auth()->id();
|
||||
$licenseSeat->notes = $request->input('notes');
|
||||
@@ -114,6 +130,7 @@ class LicenseCheckoutController extends Controller
|
||||
throw new \Illuminate\Http\Exceptions\HttpResponseException(redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkout.not_enough_seats')));
|
||||
}
|
||||
|
||||
|
||||
if (! $licenseSeat->license->is($license)) {
|
||||
throw new \Illuminate\Http\Exceptions\HttpResponseException(redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkout.mismatch')));
|
||||
}
|
||||
|
||||
@@ -256,6 +256,9 @@ class LicensesController extends Controller
|
||||
else {
|
||||
$checkedout_seats_count = ($total_seats_count - $available_seats_count);
|
||||
}
|
||||
if($license->isInactive()){
|
||||
session()->flash('warning', (trans('admin/licenses/message.checkout.license_is_inactive')));
|
||||
}
|
||||
|
||||
$this->authorize('view', $license);
|
||||
return view('licenses.view', compact('license'))
|
||||
|
||||
@@ -189,30 +189,36 @@ class LocationsController extends Controller
|
||||
{
|
||||
$this->authorize('delete', Location::class);
|
||||
|
||||
if (is_null($location = Location::find($locationId))) {
|
||||
$location = Location::withCount('assignedAssets as assigned_assets_count')
|
||||
->withCount('assets as assets_count')
|
||||
->withCount('assignedAccessories as assigned_accessories_count')
|
||||
->withCount('accessories as accessories_count')
|
||||
->withCount('rtd_assets as rtd_assets_count')
|
||||
->withCount('children as children_count')
|
||||
->withCount('users as users_count')
|
||||
->withCount('consumables as consumables_count')
|
||||
->withCount('components as components_count')
|
||||
->find($locationId);
|
||||
|
||||
if (!$location) {
|
||||
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.does_not_exist'));
|
||||
}
|
||||
|
||||
if ($location->users()->count() > 0) {
|
||||
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_users'));
|
||||
} elseif ($location->children()->count() > 0) {
|
||||
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_child_loc'));
|
||||
} elseif ($location->assets()->count() > 0) {
|
||||
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets'));
|
||||
} elseif ($location->assignedassets()->count() > 0) {
|
||||
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets'));
|
||||
}
|
||||
if ($location->isDeletable()) {
|
||||
|
||||
if ($location->image) {
|
||||
try {
|
||||
Storage::disk('public')->delete('locations/'.$location->image);
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e);
|
||||
if ($location->image) {
|
||||
try {
|
||||
Storage::disk('public')->delete('locations/'.$location->image);
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e);
|
||||
}
|
||||
}
|
||||
$location->delete();
|
||||
return redirect()->to(route('locations.index'))->with('success', trans('admin/locations/message.delete.success'));
|
||||
} else {
|
||||
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_users'));
|
||||
}
|
||||
$location->delete();
|
||||
|
||||
return redirect()->to(route('locations.index'))->with('success', trans('admin/locations/message.delete.success'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,23 +253,41 @@ class LocationsController extends Controller
|
||||
$this->authorize('view', Location::class);
|
||||
|
||||
if ($location = Location::where('id', $id)->first()) {
|
||||
$parent = Location::where('id', $location->parent_id)->first();
|
||||
$manager = User::where('id', $location->manager_id)->first();
|
||||
$company = Company::where('id', $location->company_id)->first();
|
||||
$users = User::where('location_id', $id)->with('company', 'department', 'location')->get();
|
||||
$assets = Asset::where('assigned_to', $id)->where('assigned_type', Location::class)->with('model', 'model.category')->get();
|
||||
return view('locations/print')
|
||||
->with('assets', $assets)
|
||||
->with('users',$users)
|
||||
->with('assigned', false)
|
||||
->with('assets', $location->assets)
|
||||
->with('assignedAssets', $location->assignedAssets)
|
||||
->with('accessories', $location->accessories)
|
||||
->with('assignedAccessories', $location->assignedAccessories)
|
||||
->with('users',$location->users)
|
||||
->with('location', $location)
|
||||
->with('parent', $parent)
|
||||
->with('manager', $manager)
|
||||
->with('company', $company);
|
||||
->with('consumables', $location->consumables)
|
||||
->with('components', $location->components)
|
||||
->with('children', $location->children);
|
||||
}
|
||||
|
||||
return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist'));
|
||||
}
|
||||
|
||||
public function print_all_assigned($id) : View | RedirectResponse
|
||||
{
|
||||
$this->authorize('view', Location::class);
|
||||
if ($location = Location::where('id', $id)->first()) {
|
||||
return view('locations/print')
|
||||
->with('assigned', true)
|
||||
->with('assets', $location->assets)
|
||||
->with('assignedAssets', $location->assignedAssets)
|
||||
->with('accessories', $location->accessories)
|
||||
->with('assignedAccessories', $location->assignedAccessories)
|
||||
->with('users',$location->users)
|
||||
->with('location', $location)
|
||||
->with('consumables', $location->consumables)
|
||||
->with('components', $location->components)
|
||||
->with('children', $location->children);
|
||||
}
|
||||
return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a view that presents a form to clone a location.
|
||||
@@ -321,33 +345,12 @@ class LocationsController extends Controller
|
||||
return redirect()->route('locations.index')->with('success', trans('admin/locations/message.restore.success'));
|
||||
}
|
||||
|
||||
// Check validation
|
||||
return redirect()->back()->with('error', trans('general.could_not_restore', ['item_type' => trans('general.location'), 'error' => $location->getErrors()->first()]));
|
||||
}
|
||||
|
||||
return redirect()->back()->with('error', trans('admin/models/message.does_not_exist'));
|
||||
|
||||
}
|
||||
public function print_all_assigned($id) : View | RedirectResponse
|
||||
{
|
||||
$this->authorize('view', Location::class);
|
||||
if ($location = Location::where('id', $id)->first()) {
|
||||
$parent = Location::where('id', $location->parent_id)->first();
|
||||
$manager = User::where('id', $location->manager_id)->first();
|
||||
$company = Company::where('id', $location->company_id)->first();
|
||||
$users = User::where('location_id', $id)->with('company', 'department', 'location')->get();
|
||||
$assets = Asset::where('location_id', $id)->with('model', 'model.category')->get();
|
||||
return view('locations/print')
|
||||
->with('assets', $assets)
|
||||
->with('users',$users)
|
||||
->with('location', $location)
|
||||
->with('parent', $parent)
|
||||
->with('manager', $manager)
|
||||
->with('company', $company);
|
||||
}
|
||||
return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a view that allows the user to bulk delete locations
|
||||
@@ -366,8 +369,12 @@ class LocationsController extends Controller
|
||||
$locations = Location::whereIn('id', $locations_raw_array)
|
||||
->withCount('assignedAssets as assigned_assets_count')
|
||||
->withCount('assets as assets_count')
|
||||
->withCount('assignedAccessories as assigned_accessories_count')
|
||||
->withCount('accessories as accessories_count')
|
||||
->withCount('rtd_assets as rtd_assets_count')
|
||||
->withCount('children as children_count')
|
||||
->withCount('consumables as consumables_count')
|
||||
->withCount('components as components_count')
|
||||
->withCount('users as users_count')->get();
|
||||
|
||||
$valid_count = 0;
|
||||
@@ -400,9 +407,13 @@ class LocationsController extends Controller
|
||||
$locations = Location::whereIn('id', $locations_raw_array)
|
||||
->withCount('assignedAssets as assigned_assets_count')
|
||||
->withCount('assets as assets_count')
|
||||
->withCount('assignedAccessories as assigned_accessories_count')
|
||||
->withCount('accessories as accessories_count')
|
||||
->withCount('rtd_assets as rtd_assets_count')
|
||||
->withCount('children as children_count')
|
||||
->withCount('users as users_count')->get();
|
||||
->withCount('users as users_count')
|
||||
->withCount('consumables as consumables_count')
|
||||
->withCount('components as components_count')->get();
|
||||
|
||||
$success_count = 0;
|
||||
$error_count = 0;
|
||||
|
||||
@@ -78,6 +78,7 @@ class MaintenancesController extends Controller
|
||||
$maintenance->is_warranty = $request->input('is_warranty');
|
||||
$maintenance->cost = $request->input('cost');
|
||||
$maintenance->notes = $request->input('notes');
|
||||
$maintenance->url = $request->input('url');
|
||||
|
||||
// Save the asset maintenance data
|
||||
$maintenance->asset_id = $asset->id;
|
||||
@@ -152,6 +153,7 @@ class MaintenancesController extends Controller
|
||||
$maintenance->name = $request->input('name');
|
||||
$maintenance->start_date = $request->input('start_date');
|
||||
$maintenance->completion_date = $request->input('completion_date');
|
||||
$maintenance->url = $request->input('url');
|
||||
|
||||
|
||||
// Todo - put this in a getter/setter?
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Actions\Manufacturers\DeleteManufacturerAction;
|
||||
use App\Exceptions\ItemStillHasAccessories;
|
||||
use App\Exceptions\ItemStillHasAssets;
|
||||
use App\Exceptions\ItemStillHasChildren;
|
||||
use App\Exceptions\ItemStillHasComponents;
|
||||
use App\Exceptions\ItemStillHasConsumables;
|
||||
use App\Exceptions\ItemStillHasLicenses;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Requests\ImageUploadRequest;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Manufacturer;
|
||||
@@ -157,32 +165,18 @@ class ManufacturersController extends Controller
|
||||
* @param int $manufacturerId
|
||||
* @since [v1.0]
|
||||
*/
|
||||
public function destroy($manufacturerId) : RedirectResponse
|
||||
public function destroy(Manufacturer $manufacturer): RedirectResponse
|
||||
{
|
||||
$this->authorize('delete', Manufacturer::class);
|
||||
if (is_null($manufacturer = Manufacturer::withTrashed()->withCount('models as models_count')->find($manufacturerId))) {
|
||||
return redirect()->route('manufacturers.index')->with('error', trans('admin/manufacturers/message.not_found'));
|
||||
$this->authorize('delete', $manufacturer);
|
||||
try {
|
||||
DeleteManufacturerAction::run($manufacturer);
|
||||
} catch (ItemStillHasChildren $e) {
|
||||
return redirect()->route('manufacturers.index')->with('error', trans('general.bulk_delete_associations.general_assoc_warning', ['item' => trans('general.manufacturer')]));
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
return redirect()->route('manufacturers.index')->with('error', trans('general.something_went_wrong'));
|
||||
}
|
||||
|
||||
if (! $manufacturer->isDeletable()) {
|
||||
return redirect()->route('manufacturers.index')->with('error', trans('admin/manufacturers/message.assoc_users'));
|
||||
}
|
||||
|
||||
if ($manufacturer->image) {
|
||||
try {
|
||||
Storage::disk('public')->delete('manufacturers/'.$manufacturer->image);
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e);
|
||||
}
|
||||
}
|
||||
|
||||
// Soft delete the manufacturer if active, permanent delete if is already deleted
|
||||
if ($manufacturer->deleted_at === null) {
|
||||
$manufacturer->delete();
|
||||
} else {
|
||||
$manufacturer->forceDelete();
|
||||
}
|
||||
// Redirect to the manufacturers management page
|
||||
return redirect()->route('manufacturers.index')->with('success', trans('admin/manufacturers/message.delete.success'));
|
||||
}
|
||||
|
||||
|
||||
@@ -274,22 +274,18 @@ class ReportsController extends Controller
|
||||
$target_name = '';
|
||||
|
||||
if ($actionlog->target) {
|
||||
if ($actionlog->targetType() == 'user') {
|
||||
$target_name = $actionlog->target->display_name;
|
||||
} else {
|
||||
$target_name = $actionlog->target->getDisplayNameAttribute();
|
||||
}
|
||||
$target_name = $actionlog->target->display_name;
|
||||
}
|
||||
|
||||
if($actionlog->item){
|
||||
$item_name = e($actionlog->item->getDisplayNameAttribute());
|
||||
if ($actionlog->item){
|
||||
$item_name = e($actionlog->item->display_name);
|
||||
} else {
|
||||
$item_name = '';
|
||||
}
|
||||
|
||||
$row = [
|
||||
$actionlog->created_at,
|
||||
($actionlog->adminuser) ? e($actionlog->adminuser->display_name) : '',
|
||||
($actionlog->adminuser) ? $actionlog->adminuser->display_name : '',
|
||||
$actionlog->present()->actionType(),
|
||||
e($actionlog->itemType()),
|
||||
($actionlog->itemType() == 'user') ? $actionlog->filename : $item_name,
|
||||
@@ -298,10 +294,10 @@ class ReportsController extends Controller
|
||||
(($actionlog->item) && ($actionlog->item->model)) ? $actionlog->item->model->model_number : null,
|
||||
$target_name,
|
||||
($actionlog->note) ? e($actionlog->note) : '',
|
||||
$actionlog->log_meta,
|
||||
$actionlog->remote_ip,
|
||||
$actionlog->user_agent,
|
||||
$actionlog->action_source,
|
||||
$actionlog->log_meta,
|
||||
];
|
||||
fputcsv($handle, $row);
|
||||
}
|
||||
@@ -440,10 +436,8 @@ class ReportsController extends Controller
|
||||
// Open output stream
|
||||
$handle = fopen('php://output', 'w');
|
||||
stream_set_timeout($handle, 2000);
|
||||
|
||||
if ($request->filled('use_bom')) {
|
||||
fprintf($handle, chr(0xEF).chr(0xBB).chr(0xBF));
|
||||
}
|
||||
|
||||
fprintf($handle, chr(0xEF).chr(0xBB).chr(0xBF));
|
||||
|
||||
$header = [];
|
||||
|
||||
@@ -689,6 +683,14 @@ class ReportsController extends Controller
|
||||
$assets->whereBetween('assets.purchase_date', [$request->input('purchase_start'), $request->input('purchase_end')]);
|
||||
}
|
||||
|
||||
if ($request->filled('purchase_cost_start')) {
|
||||
if ($request->filled('purchase_cost_end')) {
|
||||
$assets->whereBetween('assets.purchase_cost', [$request->input('purchase_cost_start'), $request->input('purchase_cost_end')]);
|
||||
} else {
|
||||
$assets->where('assets.purchase_cost', ">", $request->input('purchase_cost_start'));
|
||||
}
|
||||
}
|
||||
|
||||
if (($request->filled('created_start')) && ($request->filled('created_end'))) {
|
||||
$created_start = Carbon::parse($request->input('created_start'))->startOfDay();
|
||||
$created_end = Carbon::parse($request->input('created_end'))->endOfDay();
|
||||
|
||||
@@ -2,10 +2,18 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Actions\Suppliers\DestroySupplierAction;
|
||||
use App\Exceptions\ItemStillHasAccessories;
|
||||
use App\Exceptions\ItemStillHasComponents;
|
||||
use App\Exceptions\ItemStillHasConsumables;
|
||||
use App\Exceptions\ItemStillHasMaintenances;
|
||||
use App\Exceptions\ItemStillHasAssets;
|
||||
use App\Exceptions\ItemStillHasLicenses;
|
||||
use App\Http\Requests\ImageUploadRequest;
|
||||
use App\Models\Supplier;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use \Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Suppliers for
|
||||
@@ -118,30 +126,41 @@ class SuppliersController extends Controller
|
||||
*
|
||||
* @param int $supplierId
|
||||
*/
|
||||
public function destroy($supplierId) : RedirectResponse
|
||||
public function destroy(Supplier $supplier): RedirectResponse
|
||||
{
|
||||
$this->authorize('delete', Supplier::class);
|
||||
if (is_null($supplier = Supplier::with('maintenances', 'assets', 'licenses')->withCount('maintenances as maintenances_count', 'assets as assets_count', 'licenses as licenses_count')->find($supplierId))) {
|
||||
return redirect()->route('suppliers.index')->with('error', trans('admin/suppliers/message.not_found'));
|
||||
try {
|
||||
DestroySupplierAction::run(supplier: $supplier);
|
||||
} catch (ItemStillHasAssets $e) {
|
||||
return redirect()->route('suppliers.index')->with('error', trans('general.bulk_delete_associations.assoc_assets', [
|
||||
'asset_count' => (int) $supplier->assets_count, 'item' => trans('general.supplier')
|
||||
]));
|
||||
} catch (ItemStillHasMaintenances $e) {
|
||||
return redirect()->route('suppliers.index')->with('error', trans('general.bulk_delete_associations.assoc_maintenances', [
|
||||
'asset_maintenances_count' => $supplier->asset_maintenances_count, 'item' => trans('general.supplier')
|
||||
]));
|
||||
} catch (ItemStillHasLicenses $e) {
|
||||
return redirect()->route('suppliers.index')->with('error', trans('general.bulk_delete_associations.assoc_licenses', [
|
||||
'licenses_count' => (int) $supplier->licenses_count, 'item' => trans('general.supplier')
|
||||
]));
|
||||
} catch (ItemStillHasAccessories $e) {
|
||||
return redirect()->route('suppliers.index')->with('error', trans('general.bulk_delete_associations.assoc_accessories', [
|
||||
'accessories_count' => (int) $supplier->accessories_count, 'item' => trans('general.supplier')
|
||||
]));
|
||||
} catch (ItemStillHasConsumables $e) {
|
||||
return redirect()->route('suppliers.index')->with('error', trans('general.bulk_delete_associations.assoc_consumables', [
|
||||
'consumables_count' => (int) $supplier->consumables_count, 'item' => trans('general.supplier')
|
||||
]));
|
||||
} catch (ItemStillHasComponents $e) {
|
||||
return redirect()->route('suppliers.index')->with('error', trans('general.bulk_delete_associations.assoc_components', [
|
||||
'components_count' => (int) $supplier->components_count, 'item' => trans('general.supplier')
|
||||
]));
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
return redirect()->route('suppliers.index')->with('error', trans('admin/suppliers/message.delete.error'));
|
||||
}
|
||||
|
||||
if ($supplier->assets_count > 0) {
|
||||
return redirect()->route('suppliers.index')->with('error', trans('admin/suppliers/message.delete.assoc_assets', ['asset_count' => (int) $supplier->assets_count]));
|
||||
}
|
||||
|
||||
if ($supplier->maintenances_count > 0) {
|
||||
return redirect()->route('suppliers.index')->with('error', trans('admin/suppliers/message.delete.assoc_maintenances', ['maintenances_count' => $supplier->maintenances_count]));
|
||||
}
|
||||
|
||||
if ($supplier->licenses_count > 0) {
|
||||
return redirect()->route('suppliers.index')->with('error', trans('admin/suppliers/message.delete.assoc_licenses', ['licenses_count' => (int) $supplier->licenses_count]));
|
||||
}
|
||||
|
||||
$supplier->delete();
|
||||
|
||||
return redirect()->route('suppliers.index')->with('success',
|
||||
trans('admin/suppliers/message.delete.success')
|
||||
);
|
||||
return redirect()->route('suppliers.index')->with('success', trans('admin/suppliers/message.delete.success'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,6 +173,5 @@ class SuppliersController extends Controller
|
||||
{
|
||||
$this->authorize('view', Supplier::class);
|
||||
return view('suppliers/view', compact('supplier'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,7 @@ class AssetCountForSidebar
|
||||
}
|
||||
|
||||
try {
|
||||
$total_assets = Asset::count();
|
||||
if ($settings->show_archived_in_list != '1') {
|
||||
$total_assets -= Asset::Archived()->count();
|
||||
}
|
||||
$total_assets = Asset::AssetsForShow()->count();
|
||||
view()->share('total_assets', $total_assets);
|
||||
} catch (\Exception $e) {
|
||||
Log::debug($e);
|
||||
|
||||
@@ -14,6 +14,15 @@ class CustomAssetReportRequest extends Request
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
if($this->filled('purchase_cost_end') && !$this->filled('purchase_cost_start')){
|
||||
$this->merge(['purchase_cost_start' => 0 ]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@@ -24,6 +33,7 @@ class CustomAssetReportRequest extends Request
|
||||
return [
|
||||
'purchase_start' => 'date|date_format:Y-m-d|nullable',
|
||||
'purchase_end' => 'date|date_format:Y-m-d|nullable',
|
||||
'purchase_cost_end' => 'numeric|nullable|gte:purchase_cost_start',
|
||||
'created_start' => 'date|date_format:Y-m-d|nullable',
|
||||
'created_end' => 'date|date_format:Y-m-d|nullable',
|
||||
'checkout_date_start' => 'date|date_format:Y-m-d|nullable',
|
||||
|
||||
@@ -26,6 +26,7 @@ class StoreAssetRequest extends ImageUploadRequest
|
||||
|
||||
public function prepareForValidation(): void
|
||||
{
|
||||
parent::prepareForValidation(); // call ImageUploadRequest thing
|
||||
// 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.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Traits;
|
||||
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -38,20 +39,13 @@ trait ConvertsBase64ToFiles
|
||||
if (!$base64Contents) {
|
||||
return;
|
||||
}
|
||||
|
||||
// autogenerate filenames
|
||||
if ($filename == 'auto'){
|
||||
$header = explode(';', $base64Contents, 2)[0];
|
||||
// Grab the image type from the header while we're at it.
|
||||
$filename = $key . '.' . substr($header, strpos($header, '/')+1);
|
||||
}
|
||||
|
||||
// Generate a temporary path to store the Base64 contents
|
||||
$tempFilePath = tempnam(sys_get_temp_dir(), $filename);
|
||||
|
||||
// Store the contents using a stream, or by decoding manually
|
||||
// Store the contents using a stream, or throw an Error (which doesn't do anything?)
|
||||
if (Str::startsWith($base64Contents, 'data:') && count(explode(',', $base64Contents)) > 1) {
|
||||
$source = fopen($base64Contents, 'r');
|
||||
$source = fopen($base64Contents, 'r'); // PHP has special processing for "data:" URL's
|
||||
$destination = fopen($tempFilePath, 'w');
|
||||
|
||||
stream_copy_to_stream($source, $destination);
|
||||
@@ -59,7 +53,8 @@ trait ConvertsBase64ToFiles
|
||||
fclose($source);
|
||||
fclose($destination);
|
||||
} else {
|
||||
file_put_contents($tempFilePath, base64_decode($base64Contents, true));
|
||||
// TODO - to get a better error message here, can we maybe do something with modifying the errorBag?
|
||||
throw new ValidationException("Need Base64 URL starting with 'data:'"); // This doesn't actually throw?
|
||||
}
|
||||
|
||||
$uploadedFile = new UploadedFile($tempFilePath, $filename, null, null, true);
|
||||
|
||||
@@ -36,6 +36,7 @@ class AccessoriesTransformer
|
||||
'qty' => ($accessory->qty) ? (int) $accessory->qty : null,
|
||||
'purchase_date' => ($accessory->purchase_date) ? Helper::getFormattedDateObject($accessory->purchase_date, 'date') : null,
|
||||
'purchase_cost' => Helper::formatCurrencyOutput($accessory->purchase_cost),
|
||||
'total_cost' => Helper::formatCurrencyOutput($accessory->totalCostSum()),
|
||||
'order_number' => ($accessory->order_number) ? e($accessory->order_number) : null,
|
||||
'min_qty' => ($accessory->min_amt) ? (int) $accessory->min_amt : null, // Legacy - should phase out - replaced by below, for the bootstrap table formatter
|
||||
'min_amt' => ($accessory->min_amt) ? (int) $accessory->min_amt : null,
|
||||
|
||||
@@ -147,7 +147,7 @@ class ActionlogsTransformer
|
||||
[
|
||||
'url' => $actionlog->uploads_file_url(),
|
||||
'filename' => $actionlog->filename,
|
||||
'inlineable' => StorageHelper::allowSafeInline($actionlog->uploads_file_url()),
|
||||
'inlineable' => StorageHelper::allowSafeInline($actionlog->uploads_file_path()),
|
||||
'exists_on_disk' => Storage::exists($actionlog->uploads_file_path()) ? true : false,
|
||||
] : null,
|
||||
|
||||
@@ -155,7 +155,7 @@ class ActionlogsTransformer
|
||||
'id' => (int) $actionlog->item->id,
|
||||
'name' => e($actionlog->item->display_name) ?? null,
|
||||
'type' => e($actionlog->itemType()),
|
||||
'serial' =>e($actionlog->item->serial) ? e($actionlog->item->serial) : null
|
||||
'serial' => e($actionlog->item->serial) ? e($actionlog->item->serial) : null
|
||||
] : null,
|
||||
'location' => ($actionlog->location) ? [
|
||||
'id' => (int) $actionlog->location->id,
|
||||
@@ -168,7 +168,7 @@ class ActionlogsTransformer
|
||||
'action_type' => $actionlog->present()->actionType(),
|
||||
'admin' => ($actionlog->adminuser) ? [
|
||||
'id' => (int) $actionlog->adminuser->id,
|
||||
'name' => e($actionlog->adminuser->display_name),
|
||||
'name' => e($actionlog->adminuser->display_name) ?? null,
|
||||
'first_name'=> e($actionlog->adminuser->first_name),
|
||||
'last_name'=> e($actionlog->adminuser->last_name)
|
||||
] : null,
|
||||
@@ -180,7 +180,7 @@ class ActionlogsTransformer
|
||||
] : null,
|
||||
'target' => ($actionlog->target) ? [
|
||||
'id' => (int) $actionlog->target->id,
|
||||
'name' => ($actionlog->target->display_name) ?? null,
|
||||
'name' => e($actionlog->target->display_name) ?? null,
|
||||
'type' => e($actionlog->targetType()),
|
||||
] : null,
|
||||
|
||||
|
||||
@@ -48,12 +48,15 @@ class AssetModelsTransformer
|
||||
'image' => ($assetmodel->image != '') ? Storage::disk('public')->url('models/'.e($assetmodel->image)) : null,
|
||||
'model_number' => ($assetmodel->model_number ? e($assetmodel->model_number): null),
|
||||
'min_amt' => ($assetmodel->min_amt) ? (int) $assetmodel->min_amt : null,
|
||||
'remaining' => (int) ($assetmodel->assets_count - $assetmodel->min_amt),
|
||||
|
||||
'depreciation' => ($assetmodel->depreciation) ? [
|
||||
'id' => (int) $assetmodel->depreciation->id,
|
||||
'name'=> e($assetmodel->depreciation->name),
|
||||
] : null,
|
||||
'assets_count' => (int) $assetmodel->assets_count,
|
||||
'assets_assigned_count' => (int) $assetmodel->assets_assigned_count,
|
||||
'assets_archived_count' => (int) $assetmodel->assets_archived_count,
|
||||
'remaining' => (int) ($assetmodel->assets_count - (int) $assetmodel->assets_assigned_count) - (int) $assetmodel->assets_archived_count,
|
||||
'category' => ($assetmodel->category) ? [
|
||||
'id' => (int) $assetmodel->category->id,
|
||||
'name'=> e($assetmodel->category->name),
|
||||
|
||||
@@ -43,6 +43,7 @@ class ComponentsTransformer
|
||||
'order_number' => e($component->order_number),
|
||||
'purchase_date' => Helper::getFormattedDateObject($component->purchase_date, 'date'),
|
||||
'purchase_cost' => Helper::formatCurrencyOutput($component->purchase_cost),
|
||||
'total_cost' => Helper::formatCurrencyOutput($component->totalCostSum()),
|
||||
'remaining' => (int) $component->numRemaining(),
|
||||
'company' => ($component->company) ? [
|
||||
'id' => (int) $component->company->id,
|
||||
|
||||
@@ -37,6 +37,7 @@ class ConsumablesTransformer
|
||||
'remaining' => $consumable->numRemaining(),
|
||||
'order_number' => e($consumable->order_number),
|
||||
'purchase_cost' => Helper::formatCurrencyOutput($consumable->purchase_cost),
|
||||
'total_cost' => Helper::formatCurrencyOutput($consumable->totalCostSum()),
|
||||
'purchase_date' => Helper::getFormattedDateObject($consumable->purchase_date, 'date'),
|
||||
'qty' => (int) $consumable->qty,
|
||||
'notes' => ($consumable->notes) ? Helper::parseEscapedMarkedownInline($consumable->notes) : null,
|
||||
|
||||
@@ -51,7 +51,7 @@ class LicenseSeatsTransformer
|
||||
'reassignable' => (bool) $seat->license->reassignable,
|
||||
'notes' => e($seat->notes),
|
||||
'user_can_checkout' => (($seat->assigned_to == '') && ($seat->asset_id == '')),
|
||||
'disabled' => $seat->unreassignable_seat,
|
||||
'disabled' => $seat->unreassignable_seat || $seat->license->isInactive(),
|
||||
];
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
|
||||
@@ -31,11 +31,11 @@ class LicensesTransformer
|
||||
'purchase_order' => ($license->purchase_order) ? e($license->purchase_order) : null,
|
||||
'purchase_date' => Helper::getFormattedDateObject($license->purchase_date, 'date'),
|
||||
'termination_date' => Helper::getFormattedDateObject($license->termination_date, 'date'),
|
||||
'expiration_date' => Helper::getFormattedDateObject($license->expiration_date, 'date'),
|
||||
'depreciation' => ($license->depreciation) ? ['id' => (int) $license->depreciation->id,'name'=> e($license->depreciation->name)] : null,
|
||||
'purchase_cost' => Helper::formatCurrencyOutput($license->purchase_cost),
|
||||
'purchase_cost_numeric' => $license->purchase_cost,
|
||||
'notes' => Helper::parseEscapedMarkedownInline($license->notes),
|
||||
'expiration_date' => Helper::getFormattedDateObject($license->expiration_date, 'date'),
|
||||
'seats' => (int) $license->seats,
|
||||
'free_seats_count' => (int) $license->free_seats_count - License::unReassignableCount($license),
|
||||
'remaining' => (int) $license->free_seats_count,
|
||||
@@ -54,7 +54,7 @@ class LicensesTransformer
|
||||
'updated_at' => Helper::getFormattedDateObject($license->updated_at, 'datetime'),
|
||||
'deleted_at' => Helper::getFormattedDateObject($license->deleted_at, 'datetime'),
|
||||
'user_can_checkout' => (bool) ($license->free_seats_count > 0),
|
||||
|
||||
'disabled' => $license->isInactive(),
|
||||
];
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
|
||||
@@ -53,6 +53,9 @@ class LocationsTransformer
|
||||
'assets_count' => (int) $location->assets_count,
|
||||
'rtd_assets_count' => (int) $location->rtd_assets_count,
|
||||
'users_count' => (int) $location->users_count,
|
||||
'consumables_count' => (int) $location->consumables_count,
|
||||
'components_count' => (int) $location->components_count,
|
||||
'children_count' => (int) $location->children_count,
|
||||
'currency' => ($location->currency) ? e($location->currency) : null,
|
||||
'ldap_ou' => ($location->ldap_ou) ? e($location->ldap_ou) : null,
|
||||
'notes' => Helper::parseEscapedMarkedownInline($location->notes),
|
||||
@@ -76,12 +79,13 @@ class LocationsTransformer
|
||||
];
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
'update' => Gate::allows('update', Location::class) ? true : false,
|
||||
'update' => (Gate::allows('update', Location::class) && ($location->deleted_at == '')),
|
||||
'delete' => $location->isDeletable(),
|
||||
'bulk_selectable' => [
|
||||
'delete' => $location->isDeletable()
|
||||
],
|
||||
'clone' => (Gate::allows('create', Location::class) && ($location->deleted_at == '')),
|
||||
'restore' => (Gate::allows('create', Location::class) && ($location->deleted_at != '')),
|
||||
];
|
||||
|
||||
$array += $permissions_array;
|
||||
|
||||
@@ -66,6 +66,7 @@ class MaintenancesTransformer
|
||||
'id' => $assetmaintenance->supplier->id,
|
||||
'name'=> e($assetmaintenance->supplier->name)
|
||||
] : null,
|
||||
'url' => ($assetmaintenance->url) ? e($assetmaintenance->url) : null,
|
||||
'cost' => Helper::formatCurrencyOutput($assetmaintenance->cost),
|
||||
'asset_maintenance_type' => e($assetmaintenance->asset_maintenance_type),
|
||||
'start_date' => Helper::getFormattedDateObject($assetmaintenance->start_date, 'date'),
|
||||
|
||||
@@ -96,8 +96,8 @@ class CheckoutableListener
|
||||
|
||||
if (!empty($to)) {
|
||||
try {
|
||||
Mail::to(array_flatten($to))->send($mailable->locale($notifiable->locale));
|
||||
Mail::to(array_flatten($cc))->send($mailable->locale(Setting::getSettings()->locale));
|
||||
$toMail = (clone $mailable)->locale($notifiable->locale);
|
||||
Mail::to(array_flatten($to))->send($toMail);
|
||||
Log::info('Checkout Mail sent to checkout target');
|
||||
} catch (ClientException $e) {
|
||||
Log::debug("Exception caught during checkout email: " . $e->getMessage());
|
||||
@@ -105,6 +105,16 @@ class CheckoutableListener
|
||||
Log::debug("Exception caught during checkout email: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
if (!empty($cc)) {
|
||||
try {
|
||||
$ccMail = (clone $mailable)->locale(Setting::getSettings()->locale);
|
||||
Mail::to(array_flatten($cc))->send($ccMail);
|
||||
} catch (ClientException $e) {
|
||||
Log::debug("Exception caught during checkout email: " . $e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Log::debug("Exception caught during checkout email: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($shouldSendWebhookNotification) {
|
||||
@@ -179,16 +189,26 @@ class CheckoutableListener
|
||||
|
||||
[$to, $cc] = $this->generateEmailRecipients($shouldSendEmailToUser, $shouldSendEmailToAlertAddress, $notifiable);
|
||||
|
||||
try {
|
||||
if (!empty($to)) {
|
||||
Mail::to(array_flatten($to))->send($mailable->locale($notifiable->locale));
|
||||
Mail::to(array_flatten($cc))->send($mailable->locale(Setting::getSettings()->locale));
|
||||
Log::info('Checkin Mail sent to CC addresses');
|
||||
if (!empty($to)) {
|
||||
try {
|
||||
$toMail = (clone $mailable)->locale($notifiable->locale);
|
||||
Mail::to(array_flatten($to))->send($toMail);
|
||||
Log::info('Checkin Mail sent to checkin target');
|
||||
} catch (ClientException $e) {
|
||||
Log::debug("Exception caught during checkin email: " . $e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Log::debug("Exception caught during checkin email: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
if (!empty($cc)) {
|
||||
try {
|
||||
$ccMail = (clone $mailable)->locale(Setting::getSettings()->locale);
|
||||
Mail::to(array_flatten($cc))->send($ccMail);
|
||||
} catch (ClientException $e) {
|
||||
Log::debug("Exception caught during checkin email: " . $e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Log::debug("Exception caught during checkin email: " . $e->getMessage());
|
||||
}
|
||||
} catch (ClientException $e) {
|
||||
Log::debug("Exception caught during checkin email: " . $e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Log::debug("Exception caught during checkin email: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,6 +262,12 @@ class CheckoutableListener
|
||||
$acceptance->checkoutable()->associate($event->checkoutable);
|
||||
$acceptance->assignedTo()->associate($event->checkedOutTo);
|
||||
|
||||
$acceptance->qty = 1;
|
||||
|
||||
if (isset($event->checkoutable->checkout_qty)) {
|
||||
$acceptance->qty = $event->checkoutable->checkout_qty;
|
||||
}
|
||||
|
||||
$category = $this->getCategoryFromCheckoutable($event->checkoutable);
|
||||
|
||||
if ($category?->alert_on_response) {
|
||||
|
||||
@@ -43,7 +43,7 @@ class CheckoutAccessoryMail extends Mailable
|
||||
|
||||
return new Envelope(
|
||||
from: $from,
|
||||
subject: trans('mail.Accessory_Checkout_Notification'),
|
||||
subject: trans_choice('mail.Accessory_Checkout_Notification', $this->checkout_qty),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -83,17 +83,19 @@ class CheckoutAccessoryMail extends Mailable
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
private function introductionLine(): string
|
||||
{
|
||||
if ($this->target instanceof Location) {
|
||||
return trans('mail.new_item_checked_location', ['location' => $this->target->name ]);
|
||||
return trans_choice('mail.new_item_checked_location', $this->checkout_qty, ['location' => $this->target->name]);
|
||||
}
|
||||
|
||||
if ($this->requiresAcceptance()) {
|
||||
return trans('mail.new_item_checked_with_acceptance');
|
||||
return trans_choice('mail.new_item_checked_with_acceptance', $this->checkout_qty);
|
||||
}
|
||||
|
||||
if (!$this->requiresAcceptance()) {
|
||||
return trans('mail.new_item_checked');
|
||||
return trans_choice('mail.new_item_checked', $this->checkout_qty);
|
||||
}
|
||||
|
||||
// we shouldn't get here but let's send a default message just in case
|
||||
|
||||
@@ -138,14 +138,15 @@ class CheckoutAssetMail extends Mailable
|
||||
private function introductionLine(): string
|
||||
{
|
||||
if ($this->firstTimeSending && $this->target instanceof Location) {
|
||||
return trans('mail.new_item_checked_location', ['location' => $this->target->name ]);
|
||||
return trans_choice('mail.new_item_checked_location', 1, ['location' => $this->target->name]);
|
||||
}
|
||||
|
||||
if ($this->firstTimeSending && $this->requiresAcceptance()) {
|
||||
return trans('mail.new_item_checked_with_acceptance');
|
||||
return trans_choice('mail.new_item_checked_with_acceptance', 1);
|
||||
}
|
||||
|
||||
if ($this->firstTimeSending && !$this->requiresAcceptance()) {
|
||||
return trans('mail.new_item_checked');
|
||||
return trans_choice('mail.new_item_checked', 1);
|
||||
}
|
||||
|
||||
if (!$this->firstTimeSending && $this->requiresAcceptance()) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class CheckoutComponentMail extends Mailable
|
||||
$this->note = $note;
|
||||
$this->target = $checkedOutTo;
|
||||
$this->acceptance = $acceptance;
|
||||
$this->qty = $component->assets->first()?->pivot?->assigned_qty;
|
||||
$this->qty = $component->checkout_qty;
|
||||
|
||||
$this->settings = Setting::getSettings();
|
||||
}
|
||||
|
||||
@@ -309,27 +309,6 @@ class Accessory extends SnipeModel
|
||||
return $this->category->require_acceptance ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for a category-specific EULA, and if that doesn't exist,
|
||||
* checks for a settings level EULA
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @return string
|
||||
*/
|
||||
public function getEula()
|
||||
{
|
||||
|
||||
if ($this->category->eula_text) {
|
||||
return Helper::parseEscapedMarkedown($this->category->eula_text);
|
||||
} elseif ((Setting::getSettings()->default_eula_text) && ($this->category->use_default_eula == '1')) {
|
||||
return Helper::parseEscapedMarkedown(Setting::getSettings()->default_eula_text);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check how many items within an accessory are checked out
|
||||
*
|
||||
@@ -378,6 +357,10 @@ class Accessory extends SnipeModel
|
||||
|
||||
$accessory_checkout->limit(1)->delete();
|
||||
}
|
||||
public function totalCostSum() {
|
||||
|
||||
return $this->purchase_cost !== null ? $this->qty * $this->purchase_cost : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* -----------------------------------------------
|
||||
@@ -407,7 +390,91 @@ class Accessory extends SnipeModel
|
||||
* BEGIN QUERY SCOPES
|
||||
* -----------------------------------------------
|
||||
**/
|
||||
/**
|
||||
* Query builder scope to search on text filters for complex Bootstrap Tables API
|
||||
*
|
||||
* @param \Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $filter JSON array of search keys and terms
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
|
||||
public function scopeByFilter($query, $filter)
|
||||
{
|
||||
return $query->where(
|
||||
function ($query) use ($filter) {
|
||||
foreach ($filter as $fieldname => $search_val) {
|
||||
|
||||
if ($fieldname == 'name') {
|
||||
$query->where('accessories.name', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'notes') {
|
||||
$query->where('accessories.notes', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'model_number') {
|
||||
$query->where('accessories.model_number', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'order_number') {
|
||||
$query->where('accessories.order_number', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'purchase_cost') {
|
||||
$query->where('accessories.purchase_cost', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'location') {
|
||||
$query->whereHas(
|
||||
'location', function ($query) use ($search_val) {
|
||||
$query->where('locations.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ($fieldname == 'manufacturer') {
|
||||
$query->whereHas(
|
||||
'manufacturer', function ($query) use ($search_val) {
|
||||
$query->where('manufacturers.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($fieldname == 'supplier') {
|
||||
$query->whereHas(
|
||||
'supplier', function ($query) use ($search_val) {
|
||||
$query->where('suppliers.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($fieldname == 'category') {
|
||||
$query->whereHas(
|
||||
'category', function ($query) use ($search_val) {
|
||||
$query->where('categories.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ($fieldname == 'company') {
|
||||
$query->whereHas(
|
||||
'company', function ($query) use ($search_val) {
|
||||
$query->where('companies.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on created_by name
|
||||
|
||||
@@ -493,6 +493,10 @@ class Actionlog extends SnipeModel
|
||||
return 'private_uploads/eula-pdfs/'.$this->filename;
|
||||
}
|
||||
|
||||
if ($this->action_type == 'audit') {
|
||||
return 'private_uploads/audits/'.$this->filename;
|
||||
}
|
||||
|
||||
switch ($this->item_type) {
|
||||
case Accessory::class:
|
||||
return 'private_uploads/accessories/'.$this->filename;
|
||||
|
||||
@@ -161,7 +161,6 @@ class Asset extends Depreciable
|
||||
'eol_explicit',
|
||||
'last_audit_date',
|
||||
'next_audit_date',
|
||||
'asset_eol_date',
|
||||
'last_checkin',
|
||||
'last_checkout',
|
||||
];
|
||||
@@ -228,7 +227,6 @@ class Asset extends Depreciable
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function customFieldValidationRules()
|
||||
{
|
||||
|
||||
@@ -267,7 +265,6 @@ class Asset extends Depreciable
|
||||
return parent::save($params);
|
||||
}
|
||||
|
||||
|
||||
public function getDisplayNameAttribute()
|
||||
{
|
||||
return $this->present()->name();
|
||||
@@ -278,22 +275,136 @@ class Asset extends Depreciable
|
||||
*
|
||||
* @return \Carbon\Carbon|null
|
||||
*/
|
||||
public function getWarrantyExpiresAttribute()
|
||||
|
||||
|
||||
protected function warrantyExpires(): Attribute
|
||||
{
|
||||
if (isset($this->attributes['warranty_months']) && isset($this->attributes['purchase_date'])) {
|
||||
if (is_string($this->attributes['purchase_date']) || is_string($this->attributes['purchase_date'])) {
|
||||
$purchase_date = \Carbon\Carbon::parse($this->attributes['purchase_date']);
|
||||
} else {
|
||||
$purchase_date = \Carbon\Carbon::instance($this->attributes['purchase_date']);
|
||||
}
|
||||
$purchase_date->setTime(0, 0, 0);
|
||||
|
||||
return $purchase_date->addMonths((int) $this->attributes['warranty_months']);
|
||||
}
|
||||
|
||||
return null;
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => ($attributes['warranty_months'] && $attributes['purchase_date']) ? Carbon::parse($attributes['purchase_date'])->addMonths($attributes['warranty_months']) : null,
|
||||
);
|
||||
}
|
||||
|
||||
protected function warrantyExpiresFormattedDate(): Attribute
|
||||
{
|
||||
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => Helper::getFormattedDateObject($this->warrantyExpires, 'date', false)
|
||||
);
|
||||
}
|
||||
|
||||
protected function warrantyExpiresDiff(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => $this->warrantyExpires ? round((Carbon::now()->diffInDays($this->warrantyExpires))) : null,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
protected function warrantyExpiresDiffForHumans(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => $this->warrantyExpires ? Carbon::parse($this->warrantyExpires)->diffForHumans() : null,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function lastAuditFormattedDate(): Attribute
|
||||
{
|
||||
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => Helper::getFormattedDateObject($this->last_audit_date, 'datetime', false)
|
||||
);
|
||||
}
|
||||
|
||||
protected function lastAuditDiff(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => $this->warrantyExpires ? round((Carbon::now()->diffInDays($this->warrantyExpires))) : null,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
protected function lastAuditDiffForHumans(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => $attributes['last_audit_date'] ? Carbon::parse($attributes['last_audit_date'])->diffForHumans() : null,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
protected function nextAuditFormattedDate(): Attribute
|
||||
{
|
||||
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => Helper::getFormattedDateObject($this->next_audit_date, 'date', false)
|
||||
);
|
||||
}
|
||||
|
||||
protected function nextAuditDiffInDays(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => $attributes['next_audit_date'] ? Carbon::now()->diffInDays($attributes['next_audit_date']) : null,
|
||||
);
|
||||
}
|
||||
|
||||
protected function nextAuditDiffForHumans(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => $attributes['next_audit_date'] ? Carbon::parse($attributes['next_audit_date'])->diffForHumans() : null,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
protected function eolDate(): Attribute
|
||||
{
|
||||
|
||||
return Attribute:: make(
|
||||
get: function(mixed $value, array $attributes) {
|
||||
if ($attributes['asset_eol_date'] && $attributes['eol_explicit'] == '1') {
|
||||
return Carbon::parse($attributes['asset_eol_date']);
|
||||
} elseif ($attributes['purchase_date'] && $this->model && ((int) $this->model->eol > 0)) {
|
||||
return Carbon::parse($attributes['purchase_date'])->addMonths((int) $this->model->eol);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function eolFormattedDate(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => $this->eolDate ? Helper::getFormattedDateObject($this->eolDate, 'date', false) : null,
|
||||
);
|
||||
}
|
||||
|
||||
protected function eolDiffInDays(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => $this->eolDate ? round((Carbon::now()->diffInDays(Carbon::parse($this->eolDate), false, 1))) : null,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
protected function eolDiffForHumans(): Attribute
|
||||
{
|
||||
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => $this->eolDate ? Carbon::parse($this->eolDate)->diffForHumans() : null,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
protected function expectedCheckinFormattedDate(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => array_key_exists('expected_checkin', $attributes) ? Helper::getFormattedDateObject($attributes['expected_checkin'], 'date', false) : null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Establishes the asset -> company relationship
|
||||
@@ -824,21 +935,26 @@ class Asset extends Depreciable
|
||||
* @since [v2.0]
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getExpiringWarrantee($days = 30)
|
||||
public static function getExpiringWarrantyOrEol($days = 30)
|
||||
{
|
||||
$days = (is_null($days)) ? 30 : $days;
|
||||
|
||||
return self::where('archived', '=', '0') // this can stay for right now, as `archived` defaults to 0 at the db level, but should probably be replaced with assetstatus->archived?
|
||||
->whereNotNull('warranty_months')
|
||||
->whereNotNull('purchase_date')
|
||||
->whereNull('deleted_at')
|
||||
|
||||
return self::where('archived', '=', '0')
|
||||
->NotArchived()
|
||||
->whereRaw(
|
||||
'DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) <= DATE_ADD(NOW(), INTERVAL '
|
||||
. $days
|
||||
. ' DAY) AND DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) > NOW()'
|
||||
)
|
||||
->orderByRaw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH)')
|
||||
->whereNull('deleted_at')
|
||||
->where(function ($query) use ($days) {
|
||||
// Check for manual asset EOL first
|
||||
$query->where(function ($query) use ($days) {
|
||||
$query->whereNotNull('asset_eol_date')
|
||||
->whereBetween('asset_eol_date', [Carbon::now(), Carbon::now()->addDays($days)]);
|
||||
// Otherwise use the warranty months + purchase date + threshold
|
||||
})->orWhere(function ($query) use ($days) {
|
||||
$query->whereNotNull('purchase_date')
|
||||
->whereNotNull('warranty_months')
|
||||
->whereBetween('purchase_date', [Carbon::now(), Carbon::now()->addMonths('assets.warranty_months')->addDays($days)]);
|
||||
});
|
||||
})
|
||||
->orderBy('asset_eol_date', 'ASC')
|
||||
->orderBy('purchase_date', 'ASC')
|
||||
->get();
|
||||
}
|
||||
|
||||
@@ -1019,31 +1135,6 @@ class Asset extends Depreciable
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks for a category-specific EULA, and if that doesn't exist,
|
||||
* checks for a settings level EULA
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v4.0]
|
||||
* @return string | false
|
||||
*/
|
||||
public function getEula()
|
||||
{
|
||||
|
||||
if (($this->model) && ($this->model->category)) {
|
||||
if (($this->model->category->eula_text) && ($this->model->category->use_default_eula == 0)) {
|
||||
return Helper::parseEscapedMarkedown($this->model->category->eula_text);
|
||||
} elseif ($this->model->category->use_default_eula == 1) {
|
||||
return Helper::parseEscapedMarkedown(Setting::getSettings()->default_eula_text);
|
||||
} else {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public function getComponentCost()
|
||||
{
|
||||
$cost = 0;
|
||||
@@ -1796,16 +1887,32 @@ class Asset extends Depreciable
|
||||
);
|
||||
}
|
||||
|
||||
if ($fieldname =='assigned_to') {
|
||||
if ($fieldname == 'assigned_to') {
|
||||
$query->whereHasMorph(
|
||||
'assignedTo', [User::class], function ($query) use ($search_val) {
|
||||
$query->where(
|
||||
function ($query) use ($search_val) {
|
||||
$query->where('users.first_name', 'LIKE', '%'.$search_val.'%')
|
||||
->orWhere('users.last_name', 'LIKE', '%'.$search_val.'%');
|
||||
->orWhere('users.last_name', 'LIKE', '%'.$search_val.'%')
|
||||
->orWhere('users.username', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
)->orWhereHasMorph(
|
||||
'assignedTo', [Location::class], function ($query) use ($search_val) {
|
||||
$query->where('locations.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
)->orWhereHasMorph(
|
||||
'assignedTo', [Asset::class], function ($query) use ($search_val) {
|
||||
$query->where(
|
||||
function ($query) use ($search_val) {
|
||||
// Don't use the asset table prefix here because it will pull from the original asset,
|
||||
// not the subselect we're doing here to get the assigned asset
|
||||
$query->where('name', 'LIKE', '%'.$search_val.'%')
|
||||
->orWhere('asset_tag', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1845,52 +1952,69 @@ class Asset extends Depreciable
|
||||
}
|
||||
|
||||
if ($fieldname == 'model') {
|
||||
$query->where(
|
||||
function ($query) use ($search_val) {
|
||||
$query->whereHas(
|
||||
'model', function ($query) use ($search_val) {
|
||||
$query->where('models.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
$query->whereHas(
|
||||
'model', function ($query) use ($search_val) {
|
||||
$query->where('models.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($fieldname == 'model_number') {
|
||||
$query->where(
|
||||
function ($query) use ($search_val) {
|
||||
$query->whereHas(
|
||||
'model', function ($query) use ($search_val) {
|
||||
$query->where('models.model_number', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
$query->whereHas(
|
||||
'model', function ($query) use ($search_val) {
|
||||
$query->where('models.model_number', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($fieldname == 'company') {
|
||||
$query->where(
|
||||
function ($query) use ($search_val) {
|
||||
$query->whereHas(
|
||||
'company', function ($query) use ($search_val) {
|
||||
$query->where('companies.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
$query->whereHas(
|
||||
'company', function ($query) use ($search_val) {
|
||||
$query->where('companies.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ($fieldname == 'supplier') {
|
||||
$query->where(
|
||||
function ($query) use ($search_val) {
|
||||
$query->whereHas(
|
||||
'supplier', function ($query) use ($search_val) {
|
||||
$query->where('suppliers.name', 'LIKE', '%'.$search_val.'%');
|
||||
$query->whereHas(
|
||||
'supplier', function ($query) use ($search_val) {
|
||||
$query->where('suppliers.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ($fieldname == 'status_label') {
|
||||
$query->whereHas(
|
||||
'assetstatus', function ($query) use ($search_val) {
|
||||
$query->where('status_labels.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ($fieldname == 'jobtitle') {
|
||||
$query->where(function ($query) use ($search_val) {
|
||||
if (is_array($search_val)) {
|
||||
$query->whereHasMorph(
|
||||
'assignedTo',
|
||||
[User::class],
|
||||
function ($query) use ($search_val) {
|
||||
$query->whereIn('users.jobtitle', $search_val);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
$query->whereHasMorph(
|
||||
'assignedTo',
|
||||
[User::class],
|
||||
function ($query) use ($search_val) {
|
||||
$query->where(function ($query) use ($search_val) {
|
||||
$query->where('users.jobtitle', 'LIKE', '%' . $search_val . '%');
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1917,7 +2041,7 @@ class Asset extends Depreciable
|
||||
*/
|
||||
|
||||
if (($fieldname!='category') && ($fieldname!='model_number') && ($fieldname!='rtd_location') && ($fieldname!='location') && ($fieldname!='supplier')
|
||||
&& ($fieldname!='status_label') && ($fieldname!='assigned_to') && ($fieldname!='model') && ($fieldname!='company') && ($fieldname!='manufacturer')
|
||||
&& ($fieldname!='status_label') && ($fieldname!='assigned_to') && ($fieldname!='model') && ($fieldname!='jobtitle') && ($fieldname!='company') && ($fieldname!='manufacturer')
|
||||
) {
|
||||
$query->where('assets.'.$fieldname, 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
@@ -122,6 +122,22 @@ class AssetModel extends SnipeModel
|
||||
return $this->hasMany(\App\Models\Asset::class, 'model_id');
|
||||
}
|
||||
|
||||
|
||||
public function availableAssets()
|
||||
{
|
||||
return $this->hasMany(\App\Models\Asset::class, 'model_id')->RTD();
|
||||
}
|
||||
|
||||
public function assignedAssets()
|
||||
{
|
||||
return $this->hasMany(\App\Models\Asset::class, 'model_id')->Deployed();
|
||||
}
|
||||
|
||||
public function archivedAssets()
|
||||
{
|
||||
return $this->hasMany(\App\Models\Asset::class, 'model_id')->Archived();
|
||||
}
|
||||
|
||||
/**
|
||||
* Establishes the model -> category relationship
|
||||
*
|
||||
@@ -240,6 +256,57 @@ class AssetModel extends SnipeModel
|
||||
* -----------------------------------------------
|
||||
**/
|
||||
|
||||
/**
|
||||
* Query builder scope to search on text filters for complex Bootstrap Tables API
|
||||
*
|
||||
* @param \Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $filter JSON array of search keys and terms
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeByFilter($query, $filter)
|
||||
{
|
||||
return $query->where(
|
||||
function ($query) use ($filter) {
|
||||
foreach ($filter as $fieldname => $search_val) {
|
||||
|
||||
if ($fieldname == 'name') {
|
||||
$query->where('models.name', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'notes') {
|
||||
$query->where('models.notes', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'model_number') {
|
||||
$query->where('models.model_number', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'category') {
|
||||
$query->whereHas(
|
||||
'category', function ($query) use ($search_val) {
|
||||
$query->where('categories.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ($fieldname == 'manufacturer') {
|
||||
$query->whereHas(
|
||||
'manufacturer', function ($query) use ($search_val) {
|
||||
$query->where('manufacturers.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* scopeInCategory
|
||||
* Get all models that are in the array of category ids
|
||||
|
||||
@@ -290,6 +290,35 @@ class Category extends SnipeModel
|
||||
* -----------------------------------------------
|
||||
**/
|
||||
|
||||
/**
|
||||
* Query builder scope to search on text filters for complex Bootstrap Tables API
|
||||
*
|
||||
* @param \Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $filter JSON array of search keys and terms
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeByFilter($query, $filter)
|
||||
{
|
||||
return $query->where(
|
||||
function ($query) use ($filter) {
|
||||
foreach ($filter as $fieldname => $search_val) {
|
||||
|
||||
if ($fieldname == 'name') {
|
||||
$query->where('categories.name', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'category_type') {
|
||||
$query->where('categories.category_type', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope for whether or not the category requires acceptance
|
||||
*
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use TCPDF;
|
||||
|
||||
class CheckoutAcceptance extends Model
|
||||
{
|
||||
@@ -129,8 +132,7 @@ class CheckoutAcceptance extends Model
|
||||
/**
|
||||
* Filter checkout acceptences by the user
|
||||
*
|
||||
* @param Illuminate\Database\Eloquent\Builder $query
|
||||
* @param User $user
|
||||
* @param User $user
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeForUser(Builder $query, User $user)
|
||||
@@ -141,11 +143,114 @@ class CheckoutAcceptance extends Model
|
||||
/**
|
||||
* Filter to only get pending acceptances
|
||||
*
|
||||
* @param Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopePending(Builder $query)
|
||||
{
|
||||
return $query->whereNull('accepted_at')->whereNull('declined_at');
|
||||
}
|
||||
|
||||
public function scopeDeclined(Builder $query)
|
||||
{
|
||||
return $query->whereNull('accepted_at')->whereNotNull('declined_at');
|
||||
}
|
||||
|
||||
protected function displayCheckoutableType(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value) => strtolower(str_replace('App\Models\\', '', $this->checkoutable_type)),
|
||||
);
|
||||
}
|
||||
|
||||
public function generateAcceptancePdf($data, $pdf_filename) {
|
||||
|
||||
// set some language dependent data:
|
||||
$lg = Array();
|
||||
$lg['a_meta_charset'] = 'UTF-8';
|
||||
$lg['w_page'] = 'page';
|
||||
|
||||
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
|
||||
$pdf->setRTL(false);
|
||||
$pdf->setLanguageArray($lg);
|
||||
$pdf->SetFontSubsetting(true);
|
||||
$pdf->SetCreator('Snipe-IT Asset Management System');
|
||||
$pdf->SetAuthor($data['assigned_to']);
|
||||
$pdf->SetTitle('Asset Acceptance: '.$data['item_tag']);
|
||||
$pdf->SetSubject('Asset Acceptance: '.$data['item_tag']);
|
||||
$pdf->SetKeywords('Snipe-IT, assets, acceptance, eula, tos');
|
||||
$pdf->SetFont('dejavusans', '', 8, '', true);
|
||||
$pdf->SetPrintHeader(false);
|
||||
$pdf->SetPrintFooter(false);
|
||||
|
||||
$pdf->AddPage();
|
||||
if ($data['logo'] != null) {
|
||||
$pdf->writeHTML('<img src="@'.$data['logo'].'">', true, 0, true, 0, '');
|
||||
} else {
|
||||
$pdf->writeHTML('<h3>'.$data['site_name'].'</h3><br /><br />', true, 0, true, 0, 'C');
|
||||
}
|
||||
|
||||
$pdf->Ln();
|
||||
$pdf->writeHTML(trans('general.date') . ': ' . Helper::getFormattedDateObject(now(), 'datetime', false), true, 0, true, 0, '');
|
||||
|
||||
if ($data['company_name'] != null) {
|
||||
$pdf->writeHTML(trans('general.company') . ': ' . e($data['company_name']), true, 0, true, 0, '');
|
||||
}
|
||||
if ($data['item_tag'] != null) {
|
||||
$pdf->writeHTML(trans('general.asset_tag') . ': ' . e($data['item_tag']), true, 0, true, 0, '');
|
||||
}
|
||||
if ($data['item_name'] != null) {
|
||||
$pdf->writeHTML(trans('general.name') . ': ' . e($data['item_name']), true, 0, true, 0, '');
|
||||
}
|
||||
if ($data['item_model'] != null) {
|
||||
$pdf->writeHTML(trans('general.asset_model') . ': ' . e($data['item_model']), true, 0, true, 0, '');
|
||||
}
|
||||
if ($data['item_serial'] != null) {
|
||||
$pdf->writeHTML(trans('admin/hardware/form.serial').': '.e($data['item_serial']), true, 0, true, 0, '');
|
||||
}
|
||||
if (($data['qty'] != null) && ($data['qty'] > 1)) {
|
||||
$pdf->writeHTML(trans('general.qty').': '.e($data['qty']), true, 0, true, 0, '');
|
||||
}
|
||||
$pdf->writeHTML(trans('general.assignee').': '.e($data['assigned_to']) . ($data['employee_num'] ? ' ('.$data['employee_num'].')' : ''), true, 0, true, 0, '');
|
||||
if ($data['email'] != null) {
|
||||
$pdf->writeHTML(trans('general.email').': '.e($data['email']), true, 0, true, 0, '');
|
||||
}
|
||||
$pdf->Ln();
|
||||
$pdf->writeHTML('<hr>', true, 0, true, 0, '');
|
||||
|
||||
|
||||
// Break the EULA into lines based on newlines, and check each line for RTL or CJK characters
|
||||
$eula_lines = preg_split("/\r\n|\n|\r/", $data['eula']);
|
||||
|
||||
foreach ($eula_lines as $eula_line) {
|
||||
Helper::hasRtl($eula_line) ? $pdf->setRTL(true) : $pdf->setRTL(false);
|
||||
Helper::isCjk($eula_line) ? $pdf->SetFont('cid0cs', '', 9) : $pdf->SetFont('dejavusans', '', 8, '', true);
|
||||
|
||||
$pdf->writeHTML(Helper::parseEscapedMarkedown($eula_line), true, 0, true, 0, '');
|
||||
}
|
||||
$pdf->Ln();
|
||||
$pdf->Ln();
|
||||
$pdf->setRTL(false);
|
||||
$pdf->Ln();
|
||||
|
||||
if ($data['signature'] != null) {
|
||||
$pdf->writeHTML('<img src="@'.$data['signature'].'">', true, 0, true, 0, '');
|
||||
$pdf->writeHTML('<hr>', true, 0, true, 0, '');
|
||||
$pdf->writeHTML(e($data['assigned_to']), true, 0, true, 0, 'C');
|
||||
$pdf->Ln();
|
||||
}
|
||||
|
||||
if ($data['note'] != null) {
|
||||
Helper::isCjk($data['note']) ? $pdf->SetFont('cid0cs', '', 9) : $pdf->SetFont('dejavusans', '', 8, '', true);
|
||||
$pdf->writeHTML(trans('general.notes') . ': ' . e($data['note']), true, 0, true, 0, '');
|
||||
$pdf->Ln();
|
||||
}
|
||||
|
||||
|
||||
$pdf->writeHTML(trans('general.assigned_date').': '.e($data['check_out_date']), true, 0, true, 0, '');
|
||||
$pdf->writeHTML(trans('general.accepted_date').': '.e($data['accepted_date']), true, 0, true, 0, '');
|
||||
|
||||
return $pdf->Output($pdf_filename, 'S');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,24 +217,6 @@ class Component extends SnipeModel
|
||||
return $this->category->require_acceptance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for a category-specific EULA, and if that doesn't exist,
|
||||
* checks for a settings level EULA
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v4.0]
|
||||
* @return string | false
|
||||
*/
|
||||
public function getEula()
|
||||
{
|
||||
if ($this->category->eula_text) {
|
||||
return Helper::parseEscapedMarkedown($this->category->eula_text);
|
||||
} elseif ((Setting::getSettings()->default_eula_text) && ($this->category->use_default_eula == '1')) {
|
||||
return Helper::parseEscapedMarkedown(Setting::getSettings()->default_eula_text);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Establishes the component -> action logs relationship
|
||||
@@ -306,7 +288,10 @@ class Component extends SnipeModel
|
||||
return $this->qty - $this->numCheckedOut();
|
||||
}
|
||||
|
||||
public function totalCostSum() {
|
||||
|
||||
return $this->purchase_cost !== null ? $this->qty * $this->purchase_cost : null;
|
||||
}
|
||||
/**
|
||||
* -----------------------------------------------
|
||||
* BEGIN MUTATORS
|
||||
@@ -336,6 +321,97 @@ class Component extends SnipeModel
|
||||
* -----------------------------------------------
|
||||
**/
|
||||
|
||||
/**
|
||||
* Query builder scope to search on text filters for complex Bootstrap Tables API
|
||||
*
|
||||
* @param \Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $filter JSON array of search keys and terms
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeByFilter($query, $filter)
|
||||
{
|
||||
return $query->where(
|
||||
function ($query) use ($filter) {
|
||||
foreach ($filter as $fieldname => $search_val) {
|
||||
|
||||
if ($fieldname == 'name') {
|
||||
$query->where('components.name', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'notes') {
|
||||
$query->where('components.notes', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'model_number') {
|
||||
$query->where('components.model_number', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'order_number') {
|
||||
$query->where('components.order_number', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'serial') {
|
||||
$query->where('components.serial', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'serial') {
|
||||
$query->where('components.serial', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'purchase_cost') {
|
||||
$query->where('components.purchase_cost', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'location') {
|
||||
$query->whereHas(
|
||||
'location', function ($query) use ($search_val) {
|
||||
$query->where('locations.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ($fieldname == 'manufacturer') {
|
||||
$query->whereHas(
|
||||
'manufacturer', function ($query) use ($search_val) {
|
||||
$query->where('manufacturers.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($fieldname == 'supplier') {
|
||||
$query->whereHas(
|
||||
'supplier', function ($query) use ($search_val) {
|
||||
$query->where('suppliers.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($fieldname == 'category') {
|
||||
$query->whereHas(
|
||||
'category', function ($query) use ($search_val) {
|
||||
$query->where('categories.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ($fieldname == 'company') {
|
||||
$query->whereHas(
|
||||
'company', function ($query) use ($search_val) {
|
||||
$query->where('companies.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on company
|
||||
|
||||
@@ -285,25 +285,6 @@ class Consumable extends SnipeModel
|
||||
return $this->category->require_acceptance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for a category-specific EULA, and if that doesn't exist,
|
||||
* checks for a settings level EULA
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v4.0]
|
||||
* @return string | false
|
||||
*/
|
||||
public function getEula()
|
||||
{
|
||||
if ($this->category->eula_text) {
|
||||
return Helper::parseEscapedMarkedown($this->category->eula_text);
|
||||
} elseif ((Setting::getSettings()->default_eula_text) && ($this->category->use_default_eula == '1')) {
|
||||
return Helper::parseEscapedMarkedown(Setting::getSettings()->default_eula_text);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check how many items within a consumable are checked out
|
||||
*
|
||||
@@ -331,7 +312,10 @@ class Consumable extends SnipeModel
|
||||
|
||||
return $remaining;
|
||||
}
|
||||
public function totalCostSum() {
|
||||
|
||||
return $this->purchase_cost !== null ? $this->qty * $this->purchase_cost : null;
|
||||
}
|
||||
/**
|
||||
* -----------------------------------------------
|
||||
* BEGIN MUTATORS
|
||||
@@ -361,6 +345,99 @@ class Consumable extends SnipeModel
|
||||
* -----------------------------------------------
|
||||
**/
|
||||
|
||||
/**
|
||||
* Query builder scope to search on text filters for complex Bootstrap Tables API
|
||||
*
|
||||
* @param \Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $filter JSON array of search keys and terms
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeByFilter($query, $filter)
|
||||
{
|
||||
return $query->where(
|
||||
function ($query) use ($filter) {
|
||||
foreach ($filter as $fieldname => $search_val) {
|
||||
|
||||
if ($fieldname == 'name') {
|
||||
$query->where('consumables.name', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'notes') {
|
||||
$query->where('consumables.notes', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'model_number') {
|
||||
$query->where('consumables.model_number', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'order_number') {
|
||||
$query->where('consumables.order_number', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'item_no') {
|
||||
$query->where('consumables.item_no', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'serial') {
|
||||
$query->where('consumables.serial', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'purchase_cost') {
|
||||
$query->where('consumables.purchase_cost', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'location') {
|
||||
$query->whereHas(
|
||||
'location', function ($query) use ($search_val) {
|
||||
$query->where('locations.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ($fieldname == 'manufacturer') {
|
||||
$query->whereHas(
|
||||
'manufacturer', function ($query) use ($search_val) {
|
||||
$query->where('manufacturers.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($fieldname == 'supplier') {
|
||||
$query->whereHas(
|
||||
'supplier', function ($query) use ($search_val) {
|
||||
$query->where('suppliers.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($fieldname == 'category') {
|
||||
$query->whereHas(
|
||||
'category', function ($query) use ($search_val) {
|
||||
$query->where('categories.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ($fieldname == 'company') {
|
||||
$query->whereHas(
|
||||
'company', function ($query) use ($search_val) {
|
||||
$query->where('companies.name', 'LIKE', '%'.$search_val.'%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on company
|
||||
*
|
||||
|
||||
@@ -229,7 +229,7 @@ class DefaultLabel extends RectangleSheet
|
||||
static::writeText(
|
||||
$pdf, $record->get('title'),
|
||||
$textX1, 0,
|
||||
'freesans', 'b', $this->textSize, 'L',
|
||||
Helper::isCjk($record->get('title')) ? 'cid0cs' : 'freesans', 'b', $this->textSize, 'L',
|
||||
$textW, $this->textSize,
|
||||
true, 0
|
||||
);
|
||||
@@ -246,11 +246,12 @@ class DefaultLabel extends RectangleSheet
|
||||
static::writeText(
|
||||
$pdf, (($field['label']) ? $field['label'].' ' : '') . $field['value'],
|
||||
$textX1, $textY,
|
||||
'freesans', '', $this->textSize, 'L',
|
||||
Helper::isCjk($field['label']) ? 'cid0cs' : 'freesans', '', $this->textSize, 'L',
|
||||
$textW, $this->textSize,
|
||||
true, 0
|
||||
);
|
||||
|
||||
|
||||
$textY += $this->textSize + self::TEXT_MARGIN;
|
||||
$fieldsDone++;
|
||||
}
|
||||
|
||||
@@ -211,29 +211,36 @@ abstract class Label
|
||||
*/
|
||||
public final function writeText(TCPDF $pdf, $text, $x, $y, $font=null, $style=null, $size=null, $align='L', $width=null, $height=null, $squash=false, $border=0, $spacing=0)
|
||||
{
|
||||
|
||||
|
||||
$prevFamily = $pdf->getFontFamily();
|
||||
$prevStyle = $pdf->getFontStyle();
|
||||
$prevSizePt = $pdf->getFontSizePt();
|
||||
|
||||
|
||||
$text = !empty($text) ? $text : '';
|
||||
|
||||
$fontFamily = !empty($font) ? $font : $prevFamily;
|
||||
$fontStyle = !empty($style) ? $style : $prevStyle;
|
||||
if ($size) { $fontSizePt = Helper::convertUnit($size, $this->getUnit(), 'pt', true);
|
||||
} else { $fontSizePt = $prevSizePt;
|
||||
|
||||
|
||||
if ($size) {
|
||||
$fontSizePt = Helper::convertUnit($size, $this->getUnit(), 'pt', true);
|
||||
} else {
|
||||
$fontSizePt = $prevSizePt;
|
||||
}
|
||||
|
||||
$pdf->SetFontSpacing($spacing);
|
||||
|
||||
$parts = collect(explode('**', $text))
|
||||
->map(
|
||||
function ($part, $index) use ($pdf, $fontFamily, $fontStyle, $fontSizePt) {
|
||||
function ($part, $index) use ($pdf, $fontFamily, $fontStyle, $fontSizePt, $text) {
|
||||
$modStyle = ($index % 2 == 1) ? 'B' : $fontStyle;
|
||||
$pdf->setFont($fontFamily, $modStyle, $fontSizePt);
|
||||
return [
|
||||
'text' => $part,
|
||||
'text_width' => $pdf->GetStringWidth($part),
|
||||
'font_family' => $fontFamily,
|
||||
'font_family' => Helper::isCjk($text) ? 'cid0cs' : $fontFamily,
|
||||
'font_style' => $modStyle,
|
||||
'font_size' => $fontSizePt,
|
||||
];
|
||||
|
||||
107
app/Models/Labels/Tapes/Brother/TZe_24mm_E.php
Normal file
107
app/Models/Labels/Tapes/Brother/TZe_24mm_E.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Labels\Tapes\Brother;
|
||||
|
||||
class TZe_24mm_E extends TZe_24mm
|
||||
{
|
||||
private const BARCODE_MARGIN = 1.50;
|
||||
private const TAG_SIZE = 2.00;
|
||||
private const TITLE_SIZE = 2.80;
|
||||
private const TITLE_MARGIN = 0.50;
|
||||
private const LABEL_SIZE = 2.00;
|
||||
private const LABEL_MARGIN = - 0.35;
|
||||
private const FIELD_SIZE = 2.80;
|
||||
private const FIELD_MARGIN = 0.15;
|
||||
private const BARCODE1D_SIZE = - 1.00;
|
||||
|
||||
public function getUnit() { return 'mm'; }
|
||||
public function getWidth() { return 45.0; }
|
||||
public function getHeight() { return 15; }
|
||||
public function getSupportAssetTag() { return true; }
|
||||
public function getSupport1DBarcode() { return true; }
|
||||
public function getSupport2DBarcode() { return true; }
|
||||
public function getSupportFields() { return 3; }
|
||||
public function getSupportLogo() { return false; }
|
||||
public function getSupportTitle() { return true; }
|
||||
|
||||
public function preparePDF($pdf) {}
|
||||
|
||||
public function write($pdf, $record) {
|
||||
$pa = $this->getPrintableArea();
|
||||
|
||||
$currentX = $pa->x1;
|
||||
$currentY = $pa->y1;
|
||||
$usableWidth = $pa->w;
|
||||
|
||||
|
||||
$usableHeight = $pa->h - self::BARCODE1D_SIZE;
|
||||
$barcodeSize = $usableHeight - self::TAG_SIZE;
|
||||
|
||||
if ($record->has('barcode2d')) {
|
||||
static::writeText(
|
||||
$pdf, $record->get('tag'),
|
||||
$pa->x1, $pa->y2 - self::TAG_SIZE - self::BARCODE1D_SIZE,
|
||||
'freesans', 'b', self::TAG_SIZE, 'C',
|
||||
$barcodeSize, self::TAG_SIZE, true, 0
|
||||
);
|
||||
static::write2DBarcode(
|
||||
$pdf, $record->get('barcode2d')->content, $record->get('barcode2d')->type,
|
||||
$currentX, $currentY,
|
||||
$barcodeSize, $barcodeSize
|
||||
);
|
||||
$currentX += $barcodeSize + self::BARCODE_MARGIN;
|
||||
$usableWidth -= $barcodeSize + self::BARCODE_MARGIN;
|
||||
} else {
|
||||
static::writeText(
|
||||
$pdf, $record->get('tag'),
|
||||
$pa->x1, $pa->y2 - self::TAG_SIZE - self::BARCODE1D_SIZE,
|
||||
'freesans', 'B', self::TAG_SIZE, 'R',
|
||||
$usableWidth, self::TAG_SIZE, true, 0
|
||||
);
|
||||
}
|
||||
|
||||
if ($record->has('title')) {
|
||||
static::writeText(
|
||||
$pdf, $record->get('title'),
|
||||
$currentX, $currentY,
|
||||
'freesans', 'B', self::TITLE_SIZE, 'L',
|
||||
$usableWidth, self::TITLE_SIZE, true, 0
|
||||
);
|
||||
$currentY += self::TITLE_SIZE + self::TITLE_MARGIN;
|
||||
}
|
||||
|
||||
foreach ($record->get('fields') as $field) {
|
||||
// Write label and value on the same line
|
||||
// Calculate label width with proportional character spacing
|
||||
$labelWidth = $pdf->GetStringWidth($field['label'], 'freesans', '', self::LABEL_SIZE);
|
||||
$charCount = strlen($field['label']);
|
||||
$spacingPerChar = 0.5;
|
||||
$totalSpacing = $charCount * $spacingPerChar;
|
||||
$adjustedWidth = $labelWidth + $totalSpacing;
|
||||
|
||||
static::writeText(
|
||||
$pdf, $field['label'],
|
||||
$currentX, $currentY,
|
||||
'freesans', 'B', self::LABEL_SIZE, 'L',
|
||||
$adjustedWidth, self::LABEL_SIZE, true, 0, $spacingPerChar
|
||||
);
|
||||
|
||||
static::writeText(
|
||||
$pdf, $field['value'],
|
||||
$currentX + $adjustedWidth + 2, $currentY,
|
||||
'freesans', 'B', self::FIELD_SIZE, 'L',
|
||||
$usableWidth - $adjustedWidth - 2, self::FIELD_SIZE, true, 0, 0.3
|
||||
);
|
||||
|
||||
$currentY += max(self::LABEL_SIZE, self::FIELD_SIZE) + self::FIELD_MARGIN;
|
||||
}
|
||||
|
||||
|
||||
if ($record->has('barcode1d')) {
|
||||
static::write1DBarcode(
|
||||
$pdf, $record->get('barcode1d')->content, $record->get('barcode1d')->type,
|
||||
$currentX, $barcodeSize + self::BARCODE_MARGIN, $usableWidth - self::TAG_SIZE, self::TAG_SIZE
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,13 @@ class Ldap extends Model
|
||||
if (env('LDAPTLS_CACERT')) {
|
||||
putenv('LDAPTLS_CACERT='.env('LDAPTLS_CACERT'));
|
||||
}
|
||||
// You _were_ allowed to do this *after* the ldap_connect() in some versions of PHP, but it's not how they want
|
||||
// you to anymore, and it seems to not work at all in later PHP versions.
|
||||
if (Setting::getSettings()->ldap_client_tls_cert && Setting::getSettings()->ldap_client_tls_key) {
|
||||
ldap_set_option(null, LDAP_OPT_X_TLS_CERTFILE, Setting::get_client_side_cert_path());
|
||||
ldap_set_option(null, LDAP_OPT_X_TLS_KEYFILE, Setting::get_client_side_key_path());
|
||||
}
|
||||
|
||||
$connection = @ldap_connect($ldap_host);
|
||||
|
||||
if (! $connection) {
|
||||
@@ -89,11 +96,6 @@ class Ldap extends Model
|
||||
ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, $ldap_version);
|
||||
ldap_set_option($connection, LDAP_OPT_NETWORK_TIMEOUT, 20);
|
||||
|
||||
if (Setting::getSettings()->ldap_client_tls_cert && Setting::getSettings()->ldap_client_tls_key) {
|
||||
ldap_set_option(null, LDAP_OPT_X_TLS_CERTFILE, Setting::get_client_side_cert_path());
|
||||
ldap_set_option(null, LDAP_OPT_X_TLS_KEYFILE, Setting::get_client_side_key_path());
|
||||
}
|
||||
|
||||
if ($ldap_use_tls=='1') {
|
||||
ldap_start_tls($connection);
|
||||
}
|
||||
|
||||
@@ -8,12 +8,14 @@ use App\Models\Traits\HasUploads;
|
||||
use App\Models\Traits\Searchable;
|
||||
use App\Presenters\Presentable;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
|
||||
class License extends Depreciable
|
||||
{
|
||||
use HasFactory;
|
||||
@@ -155,6 +157,29 @@ class License extends Depreciable
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected function terminatesFormattedDate(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => $attributes['termination_date'] ? Helper::getFormattedDateObject($attributes['termination_date'], 'date', false) : null,
|
||||
);
|
||||
}
|
||||
|
||||
protected function terminatesDiffInDays(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => $attributes['termination_date'] ? Carbon::now()->diffInDays($attributes['termination_date']) : null,
|
||||
);
|
||||
}
|
||||
|
||||
protected function terminatesDiffForHumans(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => $attributes['termination_date'] ? Carbon::parse($attributes['termination_date'])->diffForHumans() : null,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function prepareLimitChangeRule($parameters, $field)
|
||||
{
|
||||
$actual_seat_count = $this->licenseseats()->count(); //we use the *actual* seat count here, in case your license has gone wonky
|
||||
@@ -296,6 +321,38 @@ class License extends Depreciable
|
||||
}
|
||||
$this->attributes['termination_date'] = $value;
|
||||
}
|
||||
|
||||
public function isInactive(): bool
|
||||
{
|
||||
$day = now()->startOfDay();
|
||||
|
||||
$expired = $this->expiration_date && $this->asDateTime($this->expiration_date)->startofDay()->lessThanOrEqualTo($day);
|
||||
|
||||
$terminated = $this->termination_date && $this->asDateTime($this->termination_date)->startofDay()->lessThanOrEqualTo($day);
|
||||
|
||||
|
||||
return $this->isExpired() || $this->isTerminated();
|
||||
}
|
||||
|
||||
public function isExpired(): bool
|
||||
{
|
||||
$day = now()->startOfDay();
|
||||
|
||||
$expired = $this->expiration_date && $this->asDateTime($this->expiration_date)->startofDay()->lessThanOrEqualTo($day);
|
||||
|
||||
return $expired;
|
||||
}
|
||||
|
||||
public function isTerminated(): bool
|
||||
{
|
||||
$day = now()->startOfDay();
|
||||
|
||||
$terminated = $this->termination_date && $this->asDateTime($this->termination_date)->startofDay()->lessThanOrEqualTo($day);
|
||||
|
||||
|
||||
return $terminated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets free_seat_count attribute
|
||||
*
|
||||
@@ -375,27 +432,6 @@ class License extends Depreciable
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for a category-specific EULA, and if that doesn't exist,
|
||||
* checks for a settings level EULA
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v4.0]
|
||||
* @return string | false
|
||||
*/
|
||||
public function getEula()
|
||||
{
|
||||
if ($this->category) {
|
||||
if ($this->category->eula_text) {
|
||||
return Helper::parseEscapedMarkedown($this->category->eula_text);
|
||||
} elseif ($this->category->use_default_eula == '1') {
|
||||
return Helper::parseEscapedMarkedown(Setting::getSettings()->default_eula_text);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Establishes the license -> assigned user relationship
|
||||
@@ -596,7 +632,7 @@ class License extends Depreciable
|
||||
{
|
||||
$count = 0;
|
||||
if (!$license->reassignable) {
|
||||
$count = licenseSeat::query()->where('unreassignable_seat', '=', true)
|
||||
$count = LicenseSeat::query()->where('unreassignable_seat', '=', true)
|
||||
->where('license_id', '=', $license->id)
|
||||
->count();
|
||||
}
|
||||
@@ -694,25 +730,74 @@ class License extends Depreciable
|
||||
return $this->hasMany(\App\Models\LicenseSeat::class)->whereNull('assigned_to')->whereNull('deleted_at')->whereNull('asset_id');
|
||||
}
|
||||
|
||||
public function scopeActiveLicenses($query)
|
||||
{
|
||||
|
||||
return $query->whereNull('licenses.deleted_at')
|
||||
|
||||
// The termination date is null or within range
|
||||
->where(function ($query) {
|
||||
$query->whereNull('termination_date')
|
||||
->orWhereDate('termination_date', '>', [Carbon::now()]);
|
||||
})
|
||||
->where(function ($query) {
|
||||
$query->whereNull('expiration_date')
|
||||
->orWhereDate('expiration_date', '>', [Carbon::now()]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns expiring licenses
|
||||
*
|
||||
* @todo should refactor. I don't like get() in model methods
|
||||
* Expiried/terminated licenses scope
|
||||
*
|
||||
* @author A. Gianotto <snipe@snipe.net>
|
||||
* @since [v1.0]
|
||||
* @return \Illuminate\Database\Eloquent\Relations\Relation
|
||||
* @see \App\Console\Commands\SendExpiringLicenseNotifications
|
||||
*/
|
||||
public static function getExpiringLicenses($days = 60)
|
||||
public function scopeExpiredLicenses($query)
|
||||
{
|
||||
$days = (is_null($days)) ? 60 : $days;
|
||||
return $query->whereDate('termination_date', '<=', Carbon::now())// The termination date is null or within range
|
||||
->orWhere(function ($query) {
|
||||
$query->whereDate('expiration_date', '<=', Carbon::now());
|
||||
})
|
||||
->whereNull('licenses.deleted_at');
|
||||
}
|
||||
|
||||
return self::whereNotNull('expiration_date')
|
||||
->whereNull('deleted_at')
|
||||
->whereRaw('DATE_SUB(`expiration_date`,INTERVAL '.$days.' DAY) <= DATE(NOW()) ')
|
||||
->where('expiration_date', '>', date('Y-m-d'))
|
||||
->orderBy('expiration_date', 'ASC')
|
||||
->get();
|
||||
/**
|
||||
* Expiring/terminating licenses scope
|
||||
*
|
||||
* This checks if:
|
||||
*
|
||||
* 1) The license has not been deleted
|
||||
* 2) The expiration date is between now and the number of days specified
|
||||
* 3) There is an expiration date set and the termination date has not passed
|
||||
* 4) The license termination date is null or has not passed
|
||||
*
|
||||
* @author A. Gianotto <snipe@snipe.net>
|
||||
* @since [v1.0]
|
||||
* @return \Illuminate\Database\Eloquent\Relations\Relation
|
||||
* @see \App\Console\Commands\SendExpiringLicenseNotifications
|
||||
*/
|
||||
public function scopeExpiringLicenses($query, $days = 60)
|
||||
{
|
||||
return $query// The termination date is null or within range
|
||||
->where(function ($query) use ($days) {
|
||||
$query->whereNull('termination_date')
|
||||
->orWhereBetween('termination_date', [Carbon::now(), Carbon::now()->addDays($days)]);
|
||||
})
|
||||
->where(function ($query) use ($days) {
|
||||
$query->whereNotNull('expiration_date')
|
||||
// Handle expiring licenses without termination dates
|
||||
->where(function ($query) use ($days) {
|
||||
$query->whereNull('termination_date')
|
||||
->whereBetween('expiration_date', [Carbon::now(), Carbon::now()->addDays($days)]);
|
||||
})
|
||||
|
||||
// Handle expiring licenses with termination dates in the future
|
||||
->orWhere(function ($query) use ($days) {
|
||||
$query->whereBetween('termination_date', [Carbon::now(), Carbon::now()->addDays($days)]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Models\Traits\CompanyableChildTrait;
|
||||
use App\Notifications\CheckinLicenseNotification;
|
||||
use App\Notifications\CheckoutLicenseNotification;
|
||||
use App\Presenters\Presentable;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
@@ -64,6 +65,21 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild
|
||||
return $this->license->getEula();
|
||||
}
|
||||
|
||||
protected function name(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value) => $this->license->name,
|
||||
);
|
||||
}
|
||||
|
||||
protected function displayName(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value) => $this->license->name,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Establishes the seat -> license relationship
|
||||
*
|
||||
|
||||
@@ -43,6 +43,7 @@ class Location extends SnipeModel
|
||||
'company_id' => 'integer',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Whether the model should inject its identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
@@ -113,13 +114,19 @@ class Location extends SnipeModel
|
||||
{
|
||||
|
||||
return Gate::allows('delete', $this)
|
||||
&& ($this->assets_count == 0)
|
||||
&& ($this->assigned_assets_count == 0)
|
||||
&& ($this->children_count == 0)
|
||||
&& ($this->accessories_count == 0)
|
||||
&& ($this->users_count == 0);
|
||||
&& ($this->deleted_at == '')
|
||||
&& (($this->assets_count ?? $this->assets()->count()) === 0)
|
||||
&& (($this->assigned_assets_count ?? $this->assignedAssets()->count()) === 0)
|
||||
&& (($this->accessories_count ?? $this->accessories()->count()) === 0)
|
||||
&& (($this->assigned_accessories_count ?? $this->assignedAccessories()->count()) === 0)
|
||||
&& (($this->children_count ?? $this->children()->count()) === 0)
|
||||
&& (($this->components_count ?? $this->components()->count()) === 0)
|
||||
&& (($this->consumables_count ?? $this->consumables()->count()) === 0)
|
||||
&& (($this->rtd_assets_count ?? $this->rtd_assets()->count()) === 0)
|
||||
&& (($this->users_count ?? $this->users()->count()) === 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Establishes the user -> location relationship
|
||||
*
|
||||
|
||||
@@ -38,6 +38,7 @@ class Maintenance extends SnipeModel implements ICompanyableChild
|
||||
'completion_date' => 'date_format:Y-m-d|nullable|after_or_equal:start_date',
|
||||
'notes' => 'string|nullable',
|
||||
'cost' => 'numeric|nullable|gte:0|max:99999999999999999.99',
|
||||
'url' => 'nullable|url|max:255',
|
||||
];
|
||||
|
||||
|
||||
@@ -57,6 +58,7 @@ class Maintenance extends SnipeModel implements ICompanyableChild
|
||||
'asset_maintenance_time',
|
||||
'notes',
|
||||
'cost',
|
||||
'url',
|
||||
];
|
||||
|
||||
use Searchable;
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
|
||||
class SnipeModel extends Model
|
||||
{
|
||||
@@ -17,6 +20,37 @@ class SnipeModel extends Model
|
||||
$this->attributes['purchase_date'] = $value;
|
||||
}
|
||||
|
||||
|
||||
protected function purchaseDateFormatted(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => $attributes['purchase_date'] ? Helper::getFormattedDateObject(Carbon::parse($attributes['purchase_date']), 'date', false) : null,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected function expiresDiffInDays(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => array_key_exists('expiration_date', $attributes) ? Carbon::now()->diffInDays($attributes['expiration_date']) : null,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected function expiresDiffForHumans(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => array_key_exists('expiration_date', $attributes) ? Carbon::parse($attributes['expiration_date'])->diffForHumans() : null,
|
||||
);
|
||||
}
|
||||
|
||||
protected function expiresFormattedDate(): Attribute
|
||||
{
|
||||
return Attribute:: make(
|
||||
get: fn(mixed $value, array $attributes) => array_key_exists('expiration_date', $attributes) ? Helper::getFormattedDateObject($attributes['expiration_date'], 'date', false) : null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
@@ -156,6 +190,20 @@ class SnipeModel extends Model
|
||||
$this->attributes['status_id'] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies offset (from request) and limit to query.
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param int $total
|
||||
* @return void
|
||||
*/
|
||||
public function scopeApplyOffsetAndLimit(Builder $query, int $total)
|
||||
{
|
||||
$offset = (Request::input('offset') > $total) ? $total : app('api_offset_value');
|
||||
$limit = app('api_limit_value');
|
||||
|
||||
$query->skip($offset)->take($limit);
|
||||
}
|
||||
|
||||
protected function displayName(): Attribute
|
||||
{
|
||||
@@ -165,4 +213,27 @@ class SnipeModel extends Model
|
||||
}
|
||||
|
||||
|
||||
public function getEula()
|
||||
{
|
||||
|
||||
// This is - for now - only for assets, where the asset model is the thing tied to the category
|
||||
if (($this->model) && ($this->model->category)) {
|
||||
if (($this->model->category->eula_text) && ($this->model->category->use_default_eula == 0)) {
|
||||
return $this->model->category->eula_text;
|
||||
} elseif ($this->model->category->use_default_eula == 1) {
|
||||
return Setting::getSettings()->default_eula_text;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// For everything else, just check the category for EULA info
|
||||
} elseif (($this->category) && ($this->category->eula_text)) {
|
||||
return $this->category->eula_text;
|
||||
} elseif ((Setting::getSettings()->default_eula_text) && (($this->category) && ($this->category->use_default_eula == '1'))) {
|
||||
return Setting::getSettings()->default_eula_text;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -863,6 +863,141 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
||||
return new \stdClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope to search on text filters for complex Bootstrap Tables API
|
||||
*
|
||||
* @param \Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $filter JSON array of search keys and terms
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeByFilter($query, $filter)
|
||||
{
|
||||
return $query->where(
|
||||
function ($query) use ($filter) {
|
||||
foreach ($filter as $fieldname => $search_val) {
|
||||
|
||||
if ($fieldname == 'first_name') {
|
||||
$query->where('users.first_name', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
if ($fieldname == 'last_name') {
|
||||
$query->where('users.last_name', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'display_name') {
|
||||
$query->where('users.display_name', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'name') {
|
||||
$query->where('users.last_name', 'LIKE', '%' . $search_val . '%')
|
||||
->orWhere('users.first_name', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'username') {
|
||||
$query->where('users.username', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'email') {
|
||||
$query->where('users.email', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'phone') {
|
||||
$query->where('users.phone', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'mobile') {
|
||||
$query->where('users.mobile', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'phone') {
|
||||
$query->where('users.phone', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'jobtitle') {
|
||||
$query->where('users.jobtitle', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'created_at') {
|
||||
$query->where('users.created_at', '=', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'updated_at') {
|
||||
$query->where('users.updated_at', '=', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'start_date') {
|
||||
$query->where('users.start_date', '=', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'end_date') {
|
||||
$query->where('users.end_date', '=', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'employee_num') {
|
||||
$query->where('users.employee_num', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'locale') {
|
||||
$query->where('users.locale', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'address') {
|
||||
$query->where('users.address', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'state') {
|
||||
$query->where('users.state', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'zip') {
|
||||
$query->where('users.zip', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'country') {
|
||||
$query->where('users.country', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'vip') {
|
||||
$query->where('users.vip', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'remote') {
|
||||
$query->where('users.remote', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'start_date') {
|
||||
$query->where('users.purchase_date', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'notes') {
|
||||
$query->where('users.notes', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
if ($fieldname == 'location') {
|
||||
$query->whereHas(
|
||||
'location', function ($query) use ($search_val) {
|
||||
$query->where('locations.name', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ($fieldname == 'company') {
|
||||
$query->whereHas(
|
||||
'company', function ($query) use ($search_val) {
|
||||
$query->where('companies.name', 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to search user by name with spaces in it.
|
||||
* We don't use the advancedTextSearch() scope because that searches
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use AllowDynamicProperties;
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -10,7 +11,7 @@ use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class AcceptanceAssetAcceptedNotification extends Notification
|
||||
#[AllowDynamicProperties] class AcceptanceAssetAcceptedNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
@@ -22,15 +23,18 @@ class AcceptanceAssetAcceptedNotification extends Notification
|
||||
public function __construct($params)
|
||||
{
|
||||
$this->item_tag = $params['item_tag'];
|
||||
$this->item_name = $params['item_name'];
|
||||
$this->item_model = $params['item_model'];
|
||||
$this->item_serial = $params['item_serial'];
|
||||
$this->item_status = $params['item_status'];
|
||||
$this->accepted_date = Helper::getFormattedDateObject($params['accepted_date'], 'date', false);
|
||||
$this->accepted_date = Helper::getFormattedDateObject($params['accepted_date'], 'datetime', false);
|
||||
$this->assigned_to = $params['assigned_to'];
|
||||
$this->note = $params['note'];
|
||||
$this->company_name = $params['company_name'];
|
||||
$this->admin = $params['admin'] ?? null;
|
||||
$this->settings = Setting::getSettings();
|
||||
$this->file = $params['file'] ?? null;
|
||||
$this->qty = $params['qty'] ?? null;
|
||||
$this->note = $params['note'] ?? null;
|
||||
$this->admin = $params['admin'] ?? null;
|
||||
|
||||
}
|
||||
|
||||
@@ -65,6 +69,7 @@ class AcceptanceAssetAcceptedNotification extends Notification
|
||||
$message = (new MailMessage)->markdown('notifications.markdown.asset-acceptance',
|
||||
[
|
||||
'item_tag' => $this->item_tag,
|
||||
'item_name' => $this->item_name,
|
||||
'item_model' => $this->item_model,
|
||||
'item_serial' => $this->item_serial,
|
||||
'item_status' => $this->item_status,
|
||||
@@ -72,8 +77,9 @@ class AcceptanceAssetAcceptedNotification extends Notification
|
||||
'accepted_date' => $this->accepted_date,
|
||||
'assigned_to' => $this->assigned_to,
|
||||
'company_name' => $this->company_name,
|
||||
'intro_text' => trans('mail.acceptance_asset_accepted'),
|
||||
'admin' => $this->admin,
|
||||
'qty' => $this->qty,
|
||||
'intro_text' => trans('mail.acceptance_asset_accepted'),
|
||||
])
|
||||
->subject(trans('mail.acceptance_asset_accepted'));
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use AllowDynamicProperties;
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class AcceptanceAssetAcceptedToUserNotification extends Notification
|
||||
#[AllowDynamicProperties] class AcceptanceAssetAcceptedToUserNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
@@ -20,16 +21,18 @@ class AcceptanceAssetAcceptedToUserNotification extends Notification
|
||||
public function __construct($params)
|
||||
{
|
||||
$this->item_tag = $params['item_tag'];
|
||||
$this->item_name = $params['item_name'];
|
||||
$this->item_model = $params['item_model'];
|
||||
$this->item_serial = $params['item_serial'];
|
||||
$this->item_status = $params['item_status'];
|
||||
$this->accepted_date = Helper::getFormattedDateObject($params['accepted_date'], 'date', false);
|
||||
$this->accepted_date = Helper::getFormattedDateObject($params['accepted_date'], 'datetime', false);
|
||||
$this->assigned_to = $params['assigned_to'];
|
||||
$this->note = $params['note'];
|
||||
$this->note = $params['note'] ?? null;
|
||||
$this->company_name = $params['company_name'];
|
||||
$this->settings = Setting::getSettings();
|
||||
$this->file = $params['file'] ?? null;
|
||||
|
||||
$this->qty = $params['qty'] ?? null;
|
||||
$this->admin = $params['admin'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,6 +62,7 @@ class AcceptanceAssetAcceptedToUserNotification extends Notification
|
||||
$message = (new MailMessage)->markdown('notifications.markdown.asset-acceptance',
|
||||
[
|
||||
'item_tag' => $this->item_tag,
|
||||
'item_name' => $this->item_name,
|
||||
'item_model' => $this->item_model,
|
||||
'item_serial' => $this->item_serial,
|
||||
'item_status' => $this->item_status,
|
||||
@@ -66,10 +70,12 @@ class AcceptanceAssetAcceptedToUserNotification extends Notification
|
||||
'accepted_date' => $this->accepted_date,
|
||||
'assigned_to' => $this->assigned_to,
|
||||
'company_name' => $this->company_name,
|
||||
'intro_text' => trans('mail.acceptance_asset_accepted_to_user', ['site_name' => $this->company_name ?? $this->settings->site_name]),
|
||||
'admin' => $this->admin,
|
||||
'qty' => $this->qty,
|
||||
'intro_text' => trans_choice('mail.acceptance_asset_accepted_to_user', $this->qty, ['qty' => $this->qty, 'site_name' => $this->settings->site_name]),
|
||||
])
|
||||
->attach($pdf_path)
|
||||
->subject(trans('mail.acceptance_asset_accepted_to_user', ['site_name' => $this->settings->site_name]));
|
||||
->subject(trans_choice('mail.acceptance_asset_accepted_to_user', $this->qty, ['qty' => $this->qty, 'site_name' => $this->settings->site_name]));
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ class AcceptanceAssetDeclinedNotification extends Notification
|
||||
$this->assigned_to = $params['assigned_to'];
|
||||
$this->company_name = $params['company_name'];
|
||||
$this->settings = Setting::getSettings();
|
||||
$this->qty = $params['qty'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,6 +70,7 @@ class AcceptanceAssetDeclinedNotification extends Notification
|
||||
'declined_date' => $this->declined_date,
|
||||
'assigned_to' => $this->assigned_to,
|
||||
'company_name' => $this->company_name,
|
||||
'qty' => $this->qty,
|
||||
'intro_text' => trans('mail.acceptance_asset_declined'),
|
||||
])
|
||||
->subject(trans('mail.acceptance_asset_declined'));
|
||||
|
||||
@@ -61,7 +61,7 @@ use NotificationChannels\MicrosoftTeams\MicrosoftTeamsMessage;
|
||||
->from(($this->settings->webhook_botname) ? $this->settings->webhook_botname : 'Snipe-Bot')
|
||||
->to($channel)
|
||||
->attachment(function ($attachment) {
|
||||
$item = $this->params['item'];
|
||||
$item = $this->params['item'] ?? null;
|
||||
$admin_user = $this->params['admin'];
|
||||
$fields = [
|
||||
'By' => '<'.$admin_user->present()->viewUrl().'|'.$admin_user->display_name.'>',
|
||||
|
||||
@@ -168,14 +168,14 @@ class AssetObserver
|
||||
public function saving(Asset $asset)
|
||||
{
|
||||
// determine if calculated eol and then calculate it - this should only happen on a new asset
|
||||
if (is_null($asset->asset_eol_date) && !is_null($asset->purchase_date) && ($asset->model->eol > 0)){
|
||||
if (is_null($asset->asset_eol_date) && !is_null($asset->purchase_date) && ($asset->model?->eol > 0)) {
|
||||
$asset->asset_eol_date = $asset->purchase_date->addMonths($asset->model->eol)->format('Y-m-d');
|
||||
$asset->eol_explicit = false;
|
||||
}
|
||||
|
||||
// determine if explicit and set eol_explicit to true
|
||||
if (!is_null($asset->asset_eol_date) && !is_null($asset->purchase_date)) {
|
||||
if($asset->model->eol > 0) {
|
||||
if ($asset->model?->eol > 0) {
|
||||
$months = (int) Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date, true);
|
||||
if($months != $asset->model->eol) {
|
||||
$asset->eol_explicit = true;
|
||||
@@ -184,9 +184,9 @@ class AssetObserver
|
||||
} elseif (!is_null($asset->asset_eol_date) && is_null($asset->purchase_date)) {
|
||||
$asset->eol_explicit = true;
|
||||
}
|
||||
if ((!is_null($asset->asset_eol_date)) && (!is_null($asset->purchase_date)) && (is_null($asset->model->eol) || ($asset->model->eol == 0))) {
|
||||
|
||||
if ((!is_null($asset->asset_eol_date)) && (!is_null($asset->purchase_date)) && (is_null($asset->model?->eol) || ($asset->model?->eol == 0))) {
|
||||
$asset->eol_explicit = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,13 @@ class AccessoryPresenter extends Presenter
|
||||
'field' => 'purchase_cost',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.purchase_cost'),
|
||||
'title' => trans('general.unit_cost'),
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
], [
|
||||
'field' => 'total_cost',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.total_cost'),
|
||||
'footerFormatter' => 'sumFormatterQuantity',
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
], [
|
||||
|
||||
@@ -53,7 +53,7 @@ class AssetModelPresenter extends Presenter
|
||||
],
|
||||
[
|
||||
'field' => 'manufacturer',
|
||||
'searchable' => false,
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'switchable' => true,
|
||||
'title' => trans('general.manufacturer'),
|
||||
@@ -62,7 +62,7 @@ class AssetModelPresenter extends Presenter
|
||||
],
|
||||
[
|
||||
'field' => 'model_number',
|
||||
'searchable' => false,
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'switchable' => true,
|
||||
'title' => trans('admin/models/table.modelnumber'),
|
||||
@@ -89,17 +89,36 @@ class AssetModelPresenter extends Presenter
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
'footerFormatter' => 'qtySumFormatter',
|
||||
],
|
||||
|
||||
[
|
||||
'field' => 'assets_assigned_count',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'switchable' => true,
|
||||
'title' => trans('general.assigned'),
|
||||
'visible' => true,
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
'footerFormatter' => 'qtySumFormatter',
|
||||
],
|
||||
[
|
||||
'field' => 'remaining',
|
||||
'searchable' => false,
|
||||
'sortable' => false,
|
||||
'sortable' => true,
|
||||
'switchable' => true,
|
||||
'title' => trans('general.remaining'),
|
||||
'visible' => true,
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
'footerFormatter' => 'qtySumFormatter',
|
||||
],
|
||||
[
|
||||
'field' => 'assets_archived_count',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'switchable' => true,
|
||||
'title' => trans('general.archived'),
|
||||
'visible' => true,
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
'footerFormatter' => 'qtySumFormatter',
|
||||
],
|
||||
[
|
||||
'field' => 'depreciation',
|
||||
'searchable' => false,
|
||||
@@ -111,7 +130,7 @@ class AssetModelPresenter extends Presenter
|
||||
],
|
||||
[
|
||||
'field' => 'category',
|
||||
'searchable' => false,
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'switchable' => true,
|
||||
'title' => trans('general.category'),
|
||||
|
||||
@@ -14,6 +14,11 @@ class CategoryPresenter extends Presenter
|
||||
public static function dataTableLayout()
|
||||
{
|
||||
$layout = [
|
||||
[
|
||||
'field' => 'checkbox',
|
||||
'checkbox' => true,
|
||||
'titleTooltip' => trans('general.select_all_none'),
|
||||
],
|
||||
[
|
||||
'field' => 'id',
|
||||
'searchable' => false,
|
||||
@@ -92,7 +97,7 @@ class CategoryPresenter extends Presenter
|
||||
'formatter' => 'usersLinkObjFormatter',
|
||||
], [
|
||||
'field' => 'created_at',
|
||||
'searchable' => true,
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'switchable' => true,
|
||||
'title' => trans('general.created_at'),
|
||||
@@ -100,7 +105,7 @@ class CategoryPresenter extends Presenter
|
||||
'formatter' => 'dateDisplayFormatter',
|
||||
], [
|
||||
'field' => 'updated_at',
|
||||
'searchable' => true,
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'switchable' => true,
|
||||
'title' => trans('general.updated_at'),
|
||||
|
||||
@@ -79,6 +79,25 @@ class ComponentPresenter extends Presenter
|
||||
'title' => trans('general.manufacturer'),
|
||||
'visible' => false,
|
||||
'formatter' => 'manufacturersLinkObjFormatter',
|
||||
], [
|
||||
'field' => 'location',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.location'),
|
||||
'formatter' => 'locationsLinkObjFormatter',
|
||||
], [
|
||||
'field' => 'order_number',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.order_number'),
|
||||
'visible' => true,
|
||||
], [
|
||||
'field' => 'purchase_date',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.purchase_date'),
|
||||
'visible' => true,
|
||||
'formatter' => 'dateDisplayFormatter',
|
||||
], [
|
||||
'field' => 'min_amt',
|
||||
'searchable' => false,
|
||||
@@ -103,33 +122,20 @@ class ComponentPresenter extends Presenter
|
||||
'visible' => true,
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
'footerFormatter' => 'qtySumFormatter',
|
||||
], [
|
||||
'field' => 'location',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.location'),
|
||||
'formatter' => 'locationsLinkObjFormatter',
|
||||
], [
|
||||
'field' => 'order_number',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.order_number'),
|
||||
'visible' => true,
|
||||
], [
|
||||
'field' => 'purchase_date',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.purchase_date'),
|
||||
'visible' => true,
|
||||
'formatter' => 'dateDisplayFormatter',
|
||||
], [
|
||||
'field' => 'purchase_cost',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.purchase_cost'),
|
||||
'title' => trans('general.unit_cost'),
|
||||
'visible' => true,
|
||||
'footerFormatter' => 'sumFormatterQuantity',
|
||||
'class' => 'text-right',
|
||||
], [
|
||||
'field' => 'total_cost',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.total_cost'),
|
||||
'footerFormatter' => 'sumFormatterQuantity',
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
], [
|
||||
'field' => 'notes',
|
||||
'searchable' => true,
|
||||
|
||||
@@ -67,35 +67,6 @@ class ConsumablePresenter extends Presenter
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.model_no'),
|
||||
], [
|
||||
'field' => 'item_no',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'title' => trans('admin/consumables/general.item_no'),
|
||||
], [
|
||||
'field' => 'qty',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'title' => trans('admin/components/general.total'),
|
||||
'visible' => true,
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
'footerFormatter' => 'qtySumFormatter',
|
||||
], [
|
||||
'field' => 'remaining',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'title' => trans('admin/components/general.remaining'),
|
||||
'visible' => true,
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
'footerFormatter' => 'qtySumFormatter',
|
||||
], [
|
||||
'field' => 'min_amt',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.min_amt'),
|
||||
'visible' => true,
|
||||
'formatter' => 'minAmtFormatter',
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
], [
|
||||
'field' => 'location',
|
||||
'searchable' => true,
|
||||
@@ -103,6 +74,12 @@ class ConsumablePresenter extends Presenter
|
||||
'title' => trans('general.location'),
|
||||
'formatter' => 'locationsLinkObjFormatter',
|
||||
], [
|
||||
'field' => 'item_no',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'title' => trans('admin/consumables/general.item_no'),
|
||||
], [
|
||||
|
||||
'field' => 'manufacturer',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
@@ -122,12 +99,42 @@ class ConsumablePresenter extends Presenter
|
||||
'title' => trans('general.purchase_date'),
|
||||
'visible' => true,
|
||||
'formatter' => 'dateDisplayFormatter',
|
||||
], [
|
||||
'field' => 'min_amt',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.min_amt'),
|
||||
'visible' => true,
|
||||
'formatter' => 'minAmtFormatter',
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
], [
|
||||
'field' => 'qty',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'title' => trans('admin/components/general.total'),
|
||||
'visible' => true,
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
'footerFormatter' => 'qtySumFormatter',
|
||||
], [
|
||||
'field' => 'remaining',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'title' => trans('admin/components/general.remaining'),
|
||||
'visible' => true,
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
'footerFormatter' => 'qtySumFormatter',
|
||||
], [
|
||||
'field' => 'purchase_cost',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.purchase_cost'),
|
||||
'title' => trans('general.unit_cost'),
|
||||
'visible' => true,
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
], [
|
||||
'field' => 'total_cost',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.total_cost'),
|
||||
'footerFormatter' => 'sumFormatterQuantity',
|
||||
'class' => 'text-right text-padding-number-cell',
|
||||
], [
|
||||
|
||||
@@ -48,6 +48,13 @@ class LicensePresenter extends Presenter
|
||||
'sortable' => true,
|
||||
'title' => trans('admin/licenses/form.expiration'),
|
||||
'formatter' => 'dateDisplayFormatter',
|
||||
], [
|
||||
'field' => 'termination_date',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'visible' => false,
|
||||
'title' => trans('admin/licenses/form.termination_date'),
|
||||
'formatter' => 'dateDisplayFormatter',
|
||||
], [
|
||||
'field' => 'license_email',
|
||||
'searchable' => true,
|
||||
@@ -110,14 +117,6 @@ class LicensePresenter extends Presenter
|
||||
'title' => trans('general.purchase_date'),
|
||||
'formatter' => 'dateDisplayFormatter',
|
||||
],
|
||||
[
|
||||
'field' => 'termination_date',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'visible' => false,
|
||||
'title' => trans('admin/licenses/form.termination_date'),
|
||||
'formatter' => 'dateDisplayFormatter',
|
||||
],
|
||||
[
|
||||
'field' => 'depreciation',
|
||||
'searchable' => true,
|
||||
@@ -202,7 +201,7 @@ class LicensePresenter extends Presenter
|
||||
'switchable' => false,
|
||||
'title' => trans('general.checkin').'/'.trans('general.checkout'),
|
||||
'visible' => true,
|
||||
'formatter' => 'licensesInOutFormatter',
|
||||
'formatter' => 'licenseInOutFormatter',
|
||||
'printIgnore' => true,
|
||||
];
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user