Compare commits
638 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7865fbea7e | ||
|
|
5fcbf9091e | ||
|
|
fedd2b638c | ||
|
|
22f44e342f | ||
|
|
f7eb013935 | ||
|
|
1c28f893e7 | ||
|
|
195dfd752d | ||
|
|
cc788d3b62 | ||
|
|
e54021e7be | ||
|
|
918db39eba | ||
|
|
213fe2ecea | ||
|
|
6e70352d0b | ||
|
|
d2403cdadb | ||
|
|
9a4f5e0ba8 | ||
|
|
502e4d672a | ||
|
|
99205bf72e | ||
|
|
b3d673b0aa | ||
|
|
baf51eb430 | ||
|
|
d8fc50c351 | ||
|
|
ba5057181e | ||
|
|
4c4dee0bf1 | ||
|
|
589c3a2be3 | ||
|
|
991f182f89 | ||
|
|
f44b03f5a9 | ||
|
|
5fd50040d3 | ||
|
|
5302108556 | ||
|
|
592c62de75 | ||
|
|
27c1bc0271 | ||
|
|
3744a68daf | ||
|
|
c209b7bb5d | ||
|
|
f04493c1ab | ||
|
|
62edf14893 | ||
|
|
0d11e32523 | ||
|
|
5484b06df8 | ||
|
|
9f3116e4e3 | ||
|
|
f144d671ff | ||
|
|
b294635e17 | ||
|
|
36234cc0e8 | ||
|
|
5c87003196 | ||
|
|
cc5d36f8be | ||
|
|
1359a4f88a | ||
|
|
1e1362bdbc | ||
|
|
813106efd3 | ||
|
|
08d129c2ea | ||
|
|
8491e57258 | ||
|
|
d86fb098a8 | ||
|
|
e21f8e46d4 | ||
|
|
b3a6ec2804 | ||
|
|
0034938c04 | ||
|
|
d2587337e4 | ||
|
|
8b2045523d | ||
|
|
e7e10c24be | ||
|
|
f06852f48d | ||
|
|
2f9fff7130 | ||
|
|
0b788f64f7 | ||
|
|
facf1d42f7 | ||
|
|
e77aae703b | ||
|
|
76f52dd89b | ||
|
|
0e980f7229 | ||
|
|
2f5d550df6 | ||
|
|
3acf5f76fe | ||
|
|
4be8ae7f3d | ||
|
|
029dd43ecd | ||
|
|
cf8feb37e1 | ||
|
|
648531f4cc | ||
|
|
11505d5d06 | ||
|
|
1d04897b32 | ||
|
|
eddcc0fbbd | ||
|
|
bd80a77b78 | ||
|
|
edc30a31c1 | ||
|
|
f5636f325d | ||
|
|
426bf3803b | ||
|
|
739d3c72b7 | ||
|
|
60c38a0c47 | ||
|
|
9566fbd3cd | ||
|
|
e41ee1bcf8 | ||
|
|
bc14f225af | ||
|
|
07148c1503 | ||
|
|
fcb5eea951 | ||
|
|
7a4bf26733 | ||
|
|
2c2910d1dd | ||
|
|
1dae7a2fe4 | ||
|
|
e19ab329bd | ||
|
|
922cb90cb3 | ||
|
|
765295136a | ||
|
|
7579333ad3 | ||
|
|
543ea28b72 | ||
|
|
fefd6d60f6 | ||
|
|
a7b8b4bf55 | ||
|
|
7cafa194c1 | ||
|
|
b37f78dbbf | ||
|
|
e20cd42cc2 | ||
|
|
7b99f81f72 | ||
|
|
f1bbdc9e59 | ||
|
|
5219fb63a1 | ||
|
|
dcc379c3fa | ||
|
|
0fb8dc3418 | ||
|
|
f4e9d245d0 | ||
|
|
c75a2051ff | ||
|
|
691ec164b1 | ||
|
|
7b596c750d | ||
|
|
b346556caa | ||
|
|
93ec7068df | ||
|
|
5f65f993a0 | ||
|
|
a9441521a4 | ||
|
|
2dede67ae9 | ||
|
|
6bf17e7d47 | ||
|
|
a3240da707 | ||
|
|
a28fee1ff4 | ||
|
|
57e5af2f69 | ||
|
|
8d3a214475 | ||
|
|
58eedce6fe | ||
|
|
f91704a372 | ||
|
|
f53c68e040 | ||
|
|
99e55f84f0 | ||
|
|
798ea75f3d | ||
|
|
913e6a5709 | ||
|
|
34f6d5ab45 | ||
|
|
86c0194e9a | ||
|
|
dfb2b9b569 | ||
|
|
7fae380ab6 | ||
|
|
4ca8272efc | ||
|
|
5d4bbc393e | ||
|
|
984275ff05 | ||
|
|
e6f70f2ab7 | ||
|
|
f7de252f67 | ||
|
|
532b299c40 | ||
|
|
5dcc63dc74 | ||
|
|
6eb8acf319 | ||
|
|
862251ab36 | ||
|
|
95a9742571 | ||
|
|
81d0921782 | ||
|
|
0fa556da1d | ||
|
|
05bc238c9a | ||
|
|
782813ab49 | ||
|
|
cbca126d9d | ||
|
|
a9ffe8d210 | ||
|
|
c242abb42e | ||
|
|
2c722ffc4f | ||
|
|
484c47cef8 | ||
|
|
f38dc37152 | ||
|
|
6133f09056 | ||
|
|
2a959edeba | ||
|
|
8995d689b8 | ||
|
|
f08bec6c78 | ||
|
|
d920d91786 | ||
|
|
e35b3745eb | ||
|
|
e8252d9468 | ||
|
|
8fff6a1a06 | ||
|
|
0eff821928 | ||
|
|
9e605e0f79 | ||
|
|
8fb991110e | ||
|
|
b383ebee48 | ||
|
|
138313dcb9 | ||
|
|
f254958db9 | ||
|
|
09eff88679 | ||
|
|
24b356dba4 | ||
|
|
91bca5fcba | ||
|
|
96a469db36 | ||
|
|
9ab05e7037 | ||
|
|
52a99faf68 | ||
|
|
94cf1f8741 | ||
|
|
e2a8f9b790 | ||
|
|
409f5cc4fd | ||
|
|
3b5e4c44eb | ||
|
|
69a7ea63e2 | ||
|
|
aac379daeb | ||
|
|
1d3472b5c4 | ||
|
|
66a590b774 | ||
|
|
dc4472e9e9 | ||
|
|
6bfd428c2e | ||
|
|
f4623bd277 | ||
|
|
1f04d7aafd | ||
|
|
78efeec368 | ||
|
|
5b15a2fc0a | ||
|
|
68f1fa0340 | ||
|
|
9293f17707 | ||
|
|
a4b32e2328 | ||
|
|
d109ca30e2 | ||
|
|
3b4a651dd9 | ||
|
|
a4ac53e2e9 | ||
|
|
cf1b5a7685 | ||
|
|
0789eb8b07 | ||
|
|
7f674fdd35 | ||
|
|
500aa37e3c | ||
|
|
efe668d26d | ||
|
|
90db97b980 | ||
|
|
bc3d27fac6 | ||
|
|
55b9f1207d | ||
|
|
2bbb6001a8 | ||
|
|
af7b7664c5 | ||
|
|
c31362655c | ||
|
|
c6a956382f | ||
|
|
bab0bda174 | ||
|
|
bb52a8417c | ||
|
|
e3d7be23cb | ||
|
|
3d5545494e | ||
|
|
7f1a535b30 | ||
|
|
254234b0dc | ||
|
|
3566f37981 | ||
|
|
e6259eb6e1 | ||
|
|
eeb3d1eb42 | ||
|
|
79295f6434 | ||
|
|
285e4e2e52 | ||
|
|
5587b64d64 | ||
|
|
f0f2a5aa67 | ||
|
|
061317866b | ||
|
|
65ffc01583 | ||
|
|
f5f7a63a23 | ||
|
|
b6a7fd1cec | ||
|
|
6245f92e16 | ||
|
|
0abab2107c | ||
|
|
afc7116260 | ||
|
|
0b3d2b46e0 | ||
|
|
f786e07179 | ||
|
|
b2469bb34f | ||
|
|
b721bfcc84 | ||
|
|
f16ce09a7a | ||
|
|
bbe9df306b | ||
|
|
1bd7392531 | ||
|
|
2002dfca17 | ||
|
|
38c2ecbd0c | ||
|
|
ce97faa8d4 | ||
|
|
31ca4bff8c | ||
|
|
6f9033b2fd | ||
|
|
8864f81402 | ||
|
|
71ba1af647 | ||
|
|
b894a4c19a | ||
|
|
c3a44f25fd | ||
|
|
1f36e7997f | ||
|
|
33b5c26da5 | ||
|
|
e5a7e6619f | ||
|
|
d2e2c1c05f | ||
|
|
557b8b0ded | ||
|
|
37d4cf3afb | ||
|
|
b716db225f | ||
|
|
fbe093705d | ||
|
|
db278e9109 | ||
|
|
88798435f6 | ||
|
|
6220f0d8a5 | ||
|
|
30716b349b | ||
|
|
7a8c8233a2 | ||
|
|
7a2abcca33 | ||
|
|
9a40e5e651 | ||
|
|
893bcd0533 | ||
|
|
f1a911d305 | ||
|
|
8e8d9118e9 | ||
|
|
9c108873e9 | ||
|
|
6fe5d00e9b | ||
|
|
a85d5cfe92 | ||
|
|
6b257cc287 | ||
|
|
2952497a60 | ||
|
|
9018af4f1d | ||
|
|
5204e84703 | ||
|
|
55eaea0110 | ||
|
|
671a125c62 | ||
|
|
eb827cdbe6 | ||
|
|
5504dd435f | ||
|
|
608bb1b5b1 | ||
|
|
88b64034e8 | ||
|
|
694c6f3ec6 | ||
|
|
1d82f80e73 | ||
|
|
e21fa37254 | ||
|
|
1ef44721f5 | ||
|
|
528630a8d3 | ||
|
|
856a760d89 | ||
|
|
9179b6d9c4 | ||
|
|
4ce91a4f5d | ||
|
|
aff93d8f2b | ||
|
|
e4ab4024c5 | ||
|
|
612f23f6e0 | ||
|
|
1d543f83d4 | ||
|
|
88ca852dcf | ||
|
|
9fe2a7f81d | ||
|
|
a988011f0c | ||
|
|
c816870083 | ||
|
|
c5c46b7283 | ||
|
|
8bb8306f80 | ||
|
|
d91e8bfee5 | ||
|
|
2b3e5c8800 | ||
|
|
5b00a8ae33 | ||
|
|
5ee6e7f94b | ||
|
|
f90271dae5 | ||
|
|
e1423bd9d9 | ||
|
|
557714e7b7 | ||
|
|
3df62a200f | ||
|
|
a65ea639ed | ||
|
|
defed52caa | ||
|
|
035f7a5292 | ||
|
|
0ea3100896 | ||
|
|
2e0c2bd190 | ||
|
|
ceca76b344 | ||
|
|
a062769672 | ||
|
|
af6a794ae9 | ||
|
|
f4ac087c83 | ||
|
|
4898dd8e23 | ||
|
|
a090b6a9d2 | ||
|
|
023910472c | ||
|
|
25bf10b125 | ||
|
|
dfb0c09c51 | ||
|
|
41c8d6302a | ||
|
|
83547e3fed | ||
|
|
0d92ffc7ed | ||
|
|
3d0525bc51 | ||
|
|
808cd0f728 | ||
|
|
f5b3df697c | ||
|
|
29a36b5d1c | ||
|
|
ec131a7416 | ||
|
|
3da49ceb60 | ||
|
|
a19cef07bf | ||
|
|
c39e6d7006 | ||
|
|
60f6895919 | ||
|
|
bfa4812482 | ||
|
|
a083cdba18 | ||
|
|
438f484d68 | ||
|
|
f95d780fcf | ||
|
|
79fe092c81 | ||
|
|
027f6a7c12 | ||
|
|
76fe2af0af | ||
|
|
e490185533 | ||
|
|
deba4d2b81 | ||
|
|
a8cc29f062 | ||
|
|
c9e6a75ea8 | ||
|
|
7efa7ec03f | ||
|
|
9eef7a94ab | ||
|
|
244eceadec | ||
|
|
28fdbdd5d8 | ||
|
|
4584990cc3 | ||
|
|
4f3c932bb1 | ||
|
|
d7f2bceea2 | ||
|
|
18c1b2b477 | ||
|
|
174e3e720a | ||
|
|
fdaa279930 | ||
|
|
a4323a0308 | ||
|
|
ec4bed436c | ||
|
|
636c558fe6 | ||
|
|
29873f9c22 | ||
|
|
912ee20f3c | ||
|
|
9f10080243 | ||
|
|
b3c386663f | ||
|
|
f2d25ff777 | ||
|
|
dec9d959db | ||
|
|
2aafdb1400 | ||
|
|
c6b02cdc02 | ||
|
|
f0c825a9b3 | ||
|
|
79c035da11 | ||
|
|
9deafd771e | ||
|
|
cbc09f3a12 | ||
|
|
22c4d79cfb | ||
|
|
71b9a15c9c | ||
|
|
db328e1ce5 | ||
|
|
8b4c85d69a | ||
|
|
78a51d3675 | ||
|
|
a5bcf53146 | ||
|
|
9f97b4aefd | ||
|
|
62468199af | ||
|
|
c220315cb0 | ||
|
|
5a3233da37 | ||
|
|
80109071a2 | ||
|
|
c43bb670d2 | ||
|
|
14874d8e8a | ||
|
|
ff793f1cb5 | ||
|
|
500f6d7baf | ||
|
|
ee9a229c0e | ||
|
|
8140bdaa88 | ||
|
|
5979a18852 | ||
|
|
5efb803b60 | ||
|
|
fd4a8edae9 | ||
|
|
e9fdf06bf6 | ||
|
|
0a5b72e71e | ||
|
|
51168e8e10 | ||
|
|
cefdca3d22 | ||
|
|
cc5eee1890 | ||
|
|
d3864db5e1 | ||
|
|
ece8ae3adc | ||
|
|
e25829c759 | ||
|
|
92afd5f232 | ||
|
|
b934d2e504 | ||
|
|
8cf70e7e20 | ||
|
|
cdfd720c65 | ||
|
|
c0f791cf13 | ||
|
|
290cf79778 | ||
|
|
8af1481749 | ||
|
|
d8f404096c | ||
|
|
ea2f7617df | ||
|
|
b6c258bb12 | ||
|
|
804b49cefb | ||
|
|
305b0d8edb | ||
|
|
05996019e5 | ||
|
|
31a967e072 | ||
|
|
0b56ebf291 | ||
|
|
fcc87b3219 | ||
|
|
82fca0c72d | ||
|
|
51661b0a21 | ||
|
|
e8670fe591 | ||
|
|
bee1dfc4a6 | ||
|
|
83c8449aca | ||
|
|
9dba1bb3e5 | ||
|
|
76e3398d44 | ||
|
|
a7e12931fa | ||
|
|
ba04c64567 | ||
|
|
8c8352ecc6 | ||
|
|
64b670033d | ||
|
|
b9d102a5fb | ||
|
|
77076e02e8 | ||
|
|
c6a761a5ad | ||
|
|
6f3a90c48b | ||
|
|
8f160a8590 | ||
|
|
2278d5bfd8 | ||
|
|
66ac147c9e | ||
|
|
05e0d15ae4 | ||
|
|
8562f018ed | ||
|
|
0cbdcce3ea | ||
|
|
980be65193 | ||
|
|
3aaaea37e4 | ||
|
|
964c594c4c | ||
|
|
9430c4bf43 | ||
|
|
538757317b | ||
|
|
fe986f7c51 | ||
|
|
09105871d9 | ||
|
|
e84a6059f4 | ||
|
|
09f20873df | ||
|
|
2adc1e8ba9 | ||
|
|
4a6c18532b | ||
|
|
921f882680 | ||
|
|
f79e5add58 | ||
|
|
d98d06377e | ||
|
|
22fdd05314 | ||
|
|
8c15a4e0c6 | ||
|
|
9250b45e6e | ||
|
|
3a1de3d2a5 | ||
|
|
b59dd11304 | ||
|
|
b6222abb7c | ||
|
|
dcf8e4f5ef | ||
|
|
f195073ac3 | ||
|
|
452a9d6725 | ||
|
|
1d74ddc547 | ||
|
|
932b589a14 | ||
|
|
671e514785 | ||
|
|
1e2ebdb69c | ||
|
|
148751d927 | ||
|
|
efecdfaea0 | ||
|
|
ab9c84a6b6 | ||
|
|
8711bc0dbd | ||
|
|
0adebd1ec8 | ||
|
|
43c1e893c0 | ||
|
|
7ce63e653b | ||
|
|
e5129a8b98 | ||
|
|
a922c1a298 | ||
|
|
f4aa812d96 | ||
|
|
0c9e41e1fa | ||
|
|
1d6320a88f | ||
|
|
4696e799ed | ||
|
|
2e08a91c53 | ||
|
|
4fd35573ad | ||
|
|
caf2cdbf6f | ||
|
|
c0293a7c1c | ||
|
|
17405f5de1 | ||
|
|
bfefa10462 | ||
|
|
55a140045b | ||
|
|
897bd2c56e | ||
|
|
7321c5937f | ||
|
|
98700cab8b | ||
|
|
3d07635820 | ||
|
|
59b18a6ada | ||
|
|
ce525c1985 | ||
|
|
a0d163a3c4 | ||
|
|
faab971931 | ||
|
|
38eb16dfea | ||
|
|
4494456cad | ||
|
|
876dde1280 | ||
|
|
17ee904828 | ||
|
|
4f1b58cd35 | ||
|
|
edcd3afc3e | ||
|
|
e433b0f9d8 | ||
|
|
f137e516a6 | ||
|
|
ba38b841cb | ||
|
|
f7c6697a69 | ||
|
|
498fc3762d | ||
|
|
eb24eb1fff | ||
|
|
3e5e6ba99a | ||
|
|
0396267388 | ||
|
|
4577ba39d7 | ||
|
|
7eef1b4bcf | ||
|
|
578da128e9 | ||
|
|
bb4d49690f | ||
|
|
7eb94d16a1 | ||
|
|
65bd33c274 | ||
|
|
0f7aa21a59 | ||
|
|
ee0814716a | ||
|
|
f56e1768b6 | ||
|
|
012afe99e2 | ||
|
|
0c02b6d24e | ||
|
|
2f34336f2b | ||
|
|
afe6f43a1b | ||
|
|
738e33b165 | ||
|
|
566fd4d2e1 | ||
|
|
c61887da21 | ||
|
|
6852b74317 | ||
|
|
4c266fdcf4 | ||
|
|
c26a2f8291 | ||
|
|
a994e54726 | ||
|
|
172c7c75a8 | ||
|
|
487fd17ce3 | ||
|
|
65353fa422 | ||
|
|
4f4920615c | ||
|
|
c162c02304 | ||
|
|
1bb1480f67 | ||
|
|
8dceacc2b4 | ||
|
|
ffae537400 | ||
|
|
5ce7882bf5 | ||
|
|
b36594f508 | ||
|
|
59c9c22a59 | ||
|
|
9097681c13 | ||
|
|
567f741d95 | ||
|
|
9b1fb90519 | ||
|
|
b567ffdcfe | ||
|
|
9d44607b8f | ||
|
|
35ee52212f | ||
|
|
e9e32fdb00 | ||
|
|
6c130ce8ac | ||
|
|
dd7db0de93 | ||
|
|
70efac8fa7 | ||
|
|
6e2556eefd | ||
|
|
fb6a545cc6 | ||
|
|
e5c1e41966 | ||
|
|
61617a2629 | ||
|
|
a3e80882c1 | ||
|
|
31980c55de | ||
|
|
d1022e8ff7 | ||
|
|
e6ff447ee8 | ||
|
|
1123272ae8 | ||
|
|
74aa562a3b | ||
|
|
74773ac912 | ||
|
|
9764d2ad24 | ||
|
|
d03b8c6528 | ||
|
|
99a355145e | ||
|
|
7233e2dded | ||
|
|
eed50112d5 | ||
|
|
5aee5a3f3d | ||
|
|
f21c7ba312 | ||
|
|
9d7455f022 | ||
|
|
b748e7ed5e | ||
|
|
84a717c6ad | ||
|
|
a202e1657c | ||
|
|
30ec919048 | ||
|
|
4ae4083b7b | ||
|
|
dec9ac1ac8 | ||
|
|
8776d28d3b | ||
|
|
231dea0ebc | ||
|
|
cceeb5c8a2 | ||
|
|
579334b5fc | ||
|
|
3a82fbe714 | ||
|
|
143071fa0c | ||
|
|
0589652edb | ||
|
|
b772d8e527 | ||
|
|
b96d4dcf1f | ||
|
|
dc32e4bdb0 | ||
|
|
43f2a530f5 | ||
|
|
6ece593629 | ||
|
|
33de0ec8a9 | ||
|
|
8e17714c12 | ||
|
|
32fc052c3b | ||
|
|
17febca466 | ||
|
|
8572a9771b | ||
|
|
3ea294c0e6 | ||
|
|
2b3b2e3197 | ||
|
|
a9d9234fb3 | ||
|
|
a11d9b84a4 | ||
|
|
936ff707c7 | ||
|
|
def69b1aaa | ||
|
|
4818e1b8ca | ||
|
|
623f21e51f | ||
|
|
bd524ff2f3 | ||
|
|
04ab522ee3 | ||
|
|
f672b14468 | ||
|
|
b0973de1a6 | ||
|
|
fe06ef10f1 | ||
|
|
14ca690441 | ||
|
|
2de0a3669e | ||
|
|
c7c63e8432 | ||
|
|
adf6afbb43 | ||
|
|
69b90fb65e | ||
|
|
97ea68b15c | ||
|
|
badc763c06 | ||
|
|
b6a14d2c9c | ||
|
|
d59dd0f636 | ||
|
|
d68d95a915 | ||
|
|
15d4344efb | ||
|
|
dc10f18188 | ||
|
|
2522bfee9c | ||
|
|
d7f8615964 | ||
|
|
88dff754b1 | ||
|
|
ecd21074fb | ||
|
|
12caa48390 | ||
|
|
cc7be5f947 | ||
|
|
5b489e003d | ||
|
|
8c1f4b006e | ||
|
|
3a52c19428 | ||
|
|
279ad6d80a | ||
|
|
b786791401 | ||
|
|
1c12b6e13b | ||
|
|
c06539dee3 | ||
|
|
3b9544d1f3 | ||
|
|
da9bb07041 | ||
|
|
5d9b9ad590 | ||
|
|
f95502ae35 | ||
|
|
877daba096 | ||
|
|
b3b8ab493e | ||
|
|
1859c8f5ab | ||
|
|
87ba042b2d | ||
|
|
6fb0ef908d | ||
|
|
c4a30cc646 | ||
|
|
cf56f70b3a | ||
|
|
f84e6a34cc | ||
|
|
85360a7c7f | ||
|
|
9e0b3afa91 | ||
|
|
416455fe01 | ||
|
|
53a1511cac | ||
|
|
733921f1f9 | ||
|
|
3ecaa99990 | ||
|
|
ab9729c39a | ||
|
|
104cc2bf11 | ||
|
|
1659c3f1a6 | ||
|
|
caa8ec3178 | ||
|
|
0c794c103b | ||
|
|
53175d5035 | ||
|
|
0bd09f9c46 | ||
|
|
27d795508d | ||
|
|
368ac5b85d | ||
|
|
d5635f32e5 | ||
|
|
f47075c180 | ||
|
|
0a5e4b9b7b | ||
|
|
85624205b4 | ||
|
|
2330e5ee57 | ||
|
|
c9c5ce6ee0 | ||
|
|
fc3a59d193 | ||
|
|
950519be5d |
@@ -809,6 +809,80 @@
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "TheVakman",
|
||||
"name": "Lawrence",
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/18545156?v=4",
|
||||
"profile": "https://github.com/TheVakman",
|
||||
"contributions": [
|
||||
"test",
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "uknzaeinozpas",
|
||||
"name": "uknzaeinozpas",
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/22473767?v=4",
|
||||
"profile": "https://github.com/uknzaeinozpas",
|
||||
"contributions": [
|
||||
"test",
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Gelob",
|
||||
"name": "Ryan",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/422752?v=4",
|
||||
"profile": "https://github.com/Gelob",
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "vcordes79",
|
||||
"name": "vcordes79",
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/10672546?v=4",
|
||||
"profile": "https://github.com/vcordes79",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "fordster78",
|
||||
"name": "fordster78",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/27958330?v=4",
|
||||
"profile": "https://github.com/fordster78",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "CronKz",
|
||||
"name": "CronKz",
|
||||
"avatar_url": "https://avatars0.githubusercontent.com/u/34064225?v=4",
|
||||
"profile": "https://github.com/CronKz",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "tdb",
|
||||
"name": "Tim Bishop",
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/585486?v=4",
|
||||
"profile": "https://github.com/tdb",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "seanmcilvenna",
|
||||
"name": "Sean McIlvenna",
|
||||
"avatar_url": "https://avatars2.githubusercontent.com/u/5384694?v=4",
|
||||
"profile": "https://www.seanmcilvenna.com",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -97,10 +97,11 @@ LOGIN_LOCKOUT_DURATION=60
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: MISC
|
||||
# --------------------------------------------
|
||||
APP_LOG=daily
|
||||
APP_LOG=single
|
||||
APP_LOG_MAX_FILES=10
|
||||
APP_LOCKED=false
|
||||
FILESYSTEM_DISK=local
|
||||
APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1
|
||||
ALLOW_IFRAMING=false
|
||||
APP_CIPHER=AES-256-CBC
|
||||
GOOGLE_MAPS_API=
|
||||
|
||||
4
.github/ISSUE_TEMPLATE.md
vendored
4
.github/ISSUE_TEMPLATE.md
vendored
@@ -28,8 +28,8 @@
|
||||
- What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error
|
||||
- If a stacktrace is provided in the error, include that too.
|
||||
- Any errors that appear in your browser's error console.
|
||||
- Confirm whether the error is reproduceable on the demo: https://snipeitapp.com/demo.
|
||||
- Include any additional information you can find in `app/storage/logs` and your webserver's logs.
|
||||
- Confirm whether the error is reproducible on the demo: https://snipeitapp.com/demo.
|
||||
- Include any additional information you can find in `storage/logs` and your webserver's logs.
|
||||
- Include what you've done so far in the installation, and if you got any error messages along the way.
|
||||
- Indicate whether or not you've manually edited any data directly in the database
|
||||
|
||||
|
||||
19
.github/stale.yml
vendored
Normal file
19
.github/stale.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 60
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- pinned
|
||||
- security
|
||||
- ready for dev
|
||||
- bounty
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs. Thank you
|
||||
for your contributions!
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
||||
@@ -13,6 +13,8 @@ services:
|
||||
php:
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.2
|
||||
- 7.1.4
|
||||
|
||||
# execute any number of scripts before the test run, custom env's are available as variables
|
||||
before_script:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
[](https://travis-ci.org/snipe/snipe-it) [](http://waffle.io/snipe/snipe-it) []() [](https://crowdin.com/project/snipe-it) [](https://gitter.im/snipe/snipe-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://hub.docker.com/r/snipe/snipe-it/) [](https://twitter.com/snipeyhead) [](https://zenhub.io) [](https://www.codacy.com/app/snipe/snipe-it?utm_source=github.com&utm_medium=referral&utm_content=snipe/snipe-it&utm_campaign=Badge_Grade)
|
||||
[](#contributors)
|
||||
[](https://travis-ci.org/snipe/snipe-it) [](https://crowdin.com/project/snipe-it) [](https://gitter.im/snipe/snipe-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://hub.docker.com/r/snipe/snipe-it/) [](https://twitter.com/snipeyhead) [](https://www.codacy.com/app/snipe/snipe-it?utm_source=github.com&utm_medium=referral&utm_content=snipe/snipe-it&utm_campaign=Badge_Grade)
|
||||
[](#contributors)
|
||||
[](https://www.codetriage.com/snipe/snipe-it)
|
||||
|
||||
|
||||
## Snipe-IT - Open Source Asset Management System
|
||||
@@ -68,7 +69,8 @@ Thanks goes to all of these wonderful people ([emoji key](https://github.com/ken
|
||||
| [<img src="https://avatars2.githubusercontent.com/u/857740?v=3" width="110px;"/><br /><sub>Gil Rutkowski</sub>](http://FlashingCursor.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=flashingcursor "Code") | [<img src="https://avatars3.githubusercontent.com/u/129360?v=3" width="110px;"/><br /><sub>Desmond Morris</sub>](http://www.desmondmorris.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=desmondmorris "Code") | [<img src="https://avatars2.githubusercontent.com/u/52936?v=3" width="110px;"/><br /><sub>Nick Peelman</sub>](http://peelman.us)<br />[💻](https://github.com/snipe/snipe-it/commits?author=peelman "Code") | [<img src="https://avatars0.githubusercontent.com/u/53161?v=3" width="110px;"/><br /><sub>Abraham Vegh</sub>](https://abrahamvegh.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=abrahamvegh "Code") | [<img src="https://avatars0.githubusercontent.com/u/2818680?v=3" width="110px;"/><br /><sub>Mohamed Rashid</sub>](https://github.com/rashivkp)<br />[📖](https://github.com/snipe/snipe-it/commits?author=rashivkp "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/1509456?v=3" width="110px;"/><br /><sub>Kasey</sub>](http://hinchk.github.io)<br />[💻](https://github.com/snipe/snipe-it/commits?author=HinchK "Code") | [<img src="https://avatars2.githubusercontent.com/u/10522541?v=3" width="110px;"/><br /><sub>Brett</sub>](https://github.com/BrettFagerlund)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=BrettFagerlund "Tests") |
|
||||
| [<img src="https://avatars2.githubusercontent.com/u/16108587?v=3" width="110px;"/><br /><sub>Jason Spriggs</sub>](http://jasonspriggs.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jasonspriggs "Code") | [<img src="https://avatars2.githubusercontent.com/u/1134568?v=3" width="110px;"/><br /><sub>Nate Felton</sub>](http://n8felton.wordpress.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=n8felton "Code") | [<img src="https://avatars2.githubusercontent.com/u/14036694?v=3" width="110px;"/><br /><sub>Manasses Ferreira</sub>](http://homepages.dcc.ufmg.br/~manassesferreira)<br />[💻](https://github.com/snipe/snipe-it/commits?author=manassesferreira "Code") | [<img src="https://avatars0.githubusercontent.com/u/15913949?v=3" width="110px;"/><br /><sub>Steve</sub>](https://github.com/steveelwood)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=steveelwood "Tests") | [<img src="https://avatars1.githubusercontent.com/u/3361683?v=3" width="110px;"/><br /><sub>matc</sub>](http://twitter.com/matc)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=matc "Tests") | [<img src="https://avatars3.githubusercontent.com/u/7405702?v=3" width="110px;"/><br /><sub>Cole R. Davis</sub>](http://www.davisracingteam.com)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=VanillaNinjaD "Tests") | [<img src="https://avatars2.githubusercontent.com/u/10167681?v=3" width="110px;"/><br /><sub>gibsonjoshua55</sub>](https://github.com/gibsonjoshua55)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gibsonjoshua55 "Code") |
|
||||
| [<img src="https://avatars2.githubusercontent.com/u/2809241?v=4" width="110px;"/><br /><sub>Robin Temme</sub>](https://github.com/zwerch)<br />[💻](https://github.com/snipe/snipe-it/commits?author=zwerch "Code") | [<img src="https://avatars0.githubusercontent.com/u/6961695?v=4" width="110px;"/><br /><sub>Iman</sub>](https://github.com/imanghafoori1)<br />[💻](https://github.com/snipe/snipe-it/commits?author=imanghafoori1 "Code") | [<img src="https://avatars1.githubusercontent.com/u/6551003?v=4" width="110px;"/><br /><sub>Richard Hofman</sub>](https://github.com/richardhofman6)<br />[💻](https://github.com/snipe/snipe-it/commits?author=richardhofman6 "Code") | [<img src="https://avatars0.githubusercontent.com/u/3697569?v=4" width="110px;"/><br /><sub>gizzmojr</sub>](https://github.com/gizzmojr)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gizzmojr "Code") | [<img src="https://avatars3.githubusercontent.com/u/404729?v=4" width="110px;"/><br /><sub>Jenny Li</sub>](https://github.com/imjennyli)<br />[📖](https://github.com/snipe/snipe-it/commits?author=imjennyli "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/869227?v=4" width="110px;"/><br /><sub>Geoff Young</sub>](https://github.com/GeoffYoung)<br />[💻](https://github.com/snipe/snipe-it/commits?author=GeoffYoung "Code") | [<img src="https://avatars3.githubusercontent.com/u/1068477?v=4" width="110px;"/><br /><sub>Elliot Blackburn</sub>](http://www.elliotblackburn.com)<br />[📖](https://github.com/snipe/snipe-it/commits?author=BlueHatbRit "Documentation") |
|
||||
| [<img src="https://avatars1.githubusercontent.com/u/6357451?v=4" width="110px;"/><br /><sub>Tõnis Ormisson</sub>](http://andmemasin.eu)<br />[💻](https://github.com/snipe/snipe-it/commits?author=TonisOrmisson "Code") | [<img src="https://avatars0.githubusercontent.com/u/449411?v=4" width="110px;"/><br /><sub>Nicolai Essig</sub>](http://www.nicolai-essig.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=thakilla "Code") | [<img src="https://avatars1.githubusercontent.com/u/14809698?v=4" width="110px;"/><br /><sub>Danielle</sub>](https://github.com/techincolor)<br />[📖](https://github.com/snipe/snipe-it/commits?author=techincolor "Documentation") |
|
||||
| [<img src="https://avatars1.githubusercontent.com/u/6357451?v=4" width="110px;"/><br /><sub>Tõnis Ormisson</sub>](http://andmemasin.eu)<br />[💻](https://github.com/snipe/snipe-it/commits?author=TonisOrmisson "Code") | [<img src="https://avatars0.githubusercontent.com/u/449411?v=4" width="110px;"/><br /><sub>Nicolai Essig</sub>](http://www.nicolai-essig.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=thakilla "Code") | [<img src="https://avatars1.githubusercontent.com/u/14809698?v=4" width="110px;"/><br /><sub>Danielle</sub>](https://github.com/techincolor)<br />[📖](https://github.com/snipe/snipe-it/commits?author=techincolor "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/18545156?v=4" width="110px;"/><br /><sub>Lawrence</sub>](https://github.com/TheVakman)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=TheVakman "Tests") [🐛](https://github.com/snipe/snipe-it/issues?q=author%3ATheVakman "Bug reports") | [<img src="https://avatars1.githubusercontent.com/u/22473767?v=4" width="110px;"/><br /><sub>uknzaeinozpas</sub>](https://github.com/uknzaeinozpas)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=uknzaeinozpas "Tests") [💻](https://github.com/snipe/snipe-it/commits?author=uknzaeinozpas "Code") | [<img src="https://avatars3.githubusercontent.com/u/422752?v=4" width="110px;"/><br /><sub>Ryan</sub>](https://github.com/Gelob)<br />[📖](https://github.com/snipe/snipe-it/commits?author=Gelob "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/10672546?v=4" width="110px;"/><br /><sub>vcordes79</sub>](https://github.com/vcordes79)<br />[💻](https://github.com/snipe/snipe-it/commits?author=vcordes79 "Code") |
|
||||
| [<img src="https://avatars3.githubusercontent.com/u/27958330?v=4" width="110px;"/><br /><sub>fordster78</sub>](https://github.com/fordster78)<br />[💻](https://github.com/snipe/snipe-it/commits?author=fordster78 "Code") | [<img src="https://avatars0.githubusercontent.com/u/34064225?v=4" width="110px;"/><br /><sub>CronKz</sub>](https://github.com/CronKz)<br />[💻](https://github.com/snipe/snipe-it/commits?author=CronKz "Code") | [<img src="https://avatars1.githubusercontent.com/u/585486?v=4" width="110px;"/><br /><sub>Tim Bishop</sub>](https://github.com/tdb)<br />[💻](https://github.com/snipe/snipe-it/commits?author=tdb "Code") | [<img src="https://avatars2.githubusercontent.com/u/5384694?v=4" width="110px;"/><br /><sub>Sean McIlvenna</sub>](https://www.seanmcilvenna.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=seanmcilvenna "Code") |
|
||||
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
||||
|
||||
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
|
||||
|
||||
@@ -16,7 +16,7 @@ class LdapSync extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'snipeit:ldap-sync {--location=} {--location_id=} {--summary} {--json_summary}';
|
||||
protected $signature = 'snipeit:ldap-sync {--location=} {--location_id=} {--base_dn=} {--summary} {--json_summary}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -67,27 +67,25 @@ class LdapSync extends Command
|
||||
|
||||
$summary = array();
|
||||
|
||||
$results = Ldap::findLdapUsers();
|
||||
|
||||
// Retrieve locations with a mapped OU, and sort them from the shallowest to deepest OU (see #3993)
|
||||
$ldap_ou_locations = Location::where('ldap_ou', '!=', '')->get()->toArray();
|
||||
$ldap_ou_lengths = array();
|
||||
|
||||
foreach ($ldap_ou_locations as $location) {
|
||||
$ldap_ou_lengths[] = strlen($location["ldap_ou"]);
|
||||
}
|
||||
|
||||
array_multisort($ldap_ou_lengths, SORT_ASC, $ldap_ou_locations);
|
||||
|
||||
if (sizeof($ldap_ou_locations) > 0) {
|
||||
LOG::debug('Some locations have special OUs set. Locations will be automatically set for users in those OUs.');
|
||||
try {
|
||||
if ($this->option('base_dn') != '') {
|
||||
$search_base = $this->option('base_dn');
|
||||
LOG::debug('Importing users from specified base DN: \"'.$search_base.'\".');
|
||||
} else {
|
||||
$search_base = null;
|
||||
}
|
||||
$results = Ldap::findLdapUsers($search_base);
|
||||
} catch (\Exception $e) {
|
||||
if ($this->option('json_summary')) {
|
||||
$json_summary = [ "error" => true, "error_message" => $e->getMessage(), "summary" => [] ];
|
||||
$this->info(json_encode($json_summary));
|
||||
}
|
||||
LOG::error($e);
|
||||
return [];
|
||||
}
|
||||
|
||||
// Inject location information fields
|
||||
for ($i = 0; $i < $results["count"]; $i++) {
|
||||
$results[$i]["ldap_location_override"] = false;
|
||||
$results[$i]["location_id"] = 0;
|
||||
}
|
||||
/* Determine which location to assign users to by default. */
|
||||
$location = NULL;
|
||||
|
||||
if ($this->option('location')!='') {
|
||||
$location = Location::where('name', '=', $this->option('location'))->first();
|
||||
@@ -97,40 +95,61 @@ class LdapSync extends Command
|
||||
$location = Location::where('id', '=', $this->option('location_id'))->first();
|
||||
LOG::debug('Location ID '.$this->option('location_id').' passed');
|
||||
LOG::debug('Importing to '.$location->name.' ('.$location->id.')');
|
||||
} else {
|
||||
$location = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($location)) {
|
||||
LOG::debug('That location is invalid or a location was not provided, so no location will be assigned by default.');
|
||||
}
|
||||
|
||||
// Grab subsets based on location-specific DNs, and overwrite location for these users.
|
||||
foreach ($ldap_ou_locations as $ldap_loc) {
|
||||
$location_users = Ldap::findLdapUsers($ldap_loc["ldap_ou"]);
|
||||
$usernames = array();
|
||||
for ($i = 0; $i < $location_users["count"]; $i++) {
|
||||
$location_users[$i]["ldap_location_override"] = true;
|
||||
$location_users[$i]["location_id"] = $ldap_loc["id"];
|
||||
$usernames[] = $location_users[$i][$ldap_result_username][0];
|
||||
/* Process locations with explicitly defined OUs, if doing a full import. */
|
||||
if ($this->option('base_dn')=='') {
|
||||
// Retrieve locations with a mapped OU, and sort them from the shallowest to deepest OU (see #3993)
|
||||
$ldap_ou_locations = Location::where('ldap_ou', '!=', '')->get()->toArray();
|
||||
$ldap_ou_lengths = array();
|
||||
|
||||
foreach ($ldap_ou_locations as $location) {
|
||||
$ldap_ou_lengths[] = strlen($location["ldap_ou"]);
|
||||
}
|
||||
|
||||
// Delete located users from the general group.
|
||||
foreach ($results as $key => $generic_entry) {
|
||||
if (in_array($generic_entry[$ldap_result_username][0], $usernames)) {
|
||||
unset($results[$key]);
|
||||
array_multisort($ldap_ou_lengths, SORT_ASC, $ldap_ou_locations);
|
||||
|
||||
if (sizeof($ldap_ou_locations) > 0) {
|
||||
LOG::debug('Some locations have special OUs set. Locations will be automatically set for users in those OUs.');
|
||||
}
|
||||
|
||||
// Inject location information fields
|
||||
for ($i = 0; $i < $results["count"]; $i++) {
|
||||
$results[$i]["ldap_location_override"] = false;
|
||||
$results[$i]["location_id"] = 0;
|
||||
}
|
||||
|
||||
// Grab subsets based on location-specific DNs, and overwrite location for these users.
|
||||
foreach ($ldap_ou_locations as $ldap_loc) {
|
||||
$location_users = Ldap::findLdapUsers($ldap_loc["ldap_ou"]);
|
||||
$usernames = array();
|
||||
for ($i = 0; $i < $location_users["count"]; $i++) {
|
||||
$location_users[$i]["ldap_location_override"] = true;
|
||||
$location_users[$i]["location_id"] = $ldap_loc["id"];
|
||||
$usernames[] = $location_users[$i][$ldap_result_username][0];
|
||||
}
|
||||
}
|
||||
|
||||
$global_count = $results['count'];
|
||||
$results = array_merge($location_users, $results);
|
||||
$results['count'] = $global_count;
|
||||
// Delete located users from the general group.
|
||||
foreach ($results as $key => $generic_entry) {
|
||||
if (in_array($generic_entry[$ldap_result_username][0], $usernames)) {
|
||||
unset($results[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$global_count = $results['count'];
|
||||
$results = array_merge($location_users, $results);
|
||||
$results['count'] = $global_count;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create user account entries in Snipe-IT */
|
||||
$tmp_pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
|
||||
$pass = bcrypt($tmp_pass);
|
||||
|
||||
|
||||
for ($i = 0; $i < $results["count"]; $i++) {
|
||||
if (empty($ldap_result_active_flag) || $results[$i][$ldap_result_active_flag][0] == "TRUE") {
|
||||
|
||||
@@ -170,7 +189,7 @@ class LdapSync extends Command
|
||||
|
||||
if ($item['ldap_location_override'] == true) {
|
||||
$user->location_id = $item['location_id'];
|
||||
} else if ($location) {
|
||||
} elseif ((isset($location)) && (!empty($location))) {
|
||||
$user->location_id = e($location->id);
|
||||
}
|
||||
|
||||
@@ -198,9 +217,9 @@ class LdapSync extends Command
|
||||
if ($this->option('summary')) {
|
||||
for ($x = 0; $x < count($summary); $x++) {
|
||||
if ($summary[$x]['status']=='error') {
|
||||
$this->error('ERROR: '.$summary[$x]['firstname'].' '.$summary[$x]['lastname'].' (username: '.$summary[$x]['username'].' was not imported: '.$summary[$x]['note']);
|
||||
$this->error('ERROR: '.$summary[$x]['firstname'].' '.$summary[$x]['lastname'].' (username: '.$summary[$x]['username'].') was not imported: '.$summary[$x]['note']);
|
||||
} else {
|
||||
$this->info('User '.$summary[$x]['firstname'].' '.$summary[$x]['lastname'].' (username: '.$summary[$x]['username'].' was '.strtoupper($summary[$x]['createorupdate']).'.');
|
||||
$this->info('User '.$summary[$x]['firstname'].' '.$summary[$x]['lastname'].' (username: '.$summary[$x]['username'].') was '.strtoupper($summary[$x]['createorupdate']).'.');
|
||||
}
|
||||
}
|
||||
} else if ($this->option('json_summary')) {
|
||||
|
||||
@@ -49,7 +49,7 @@ class RecryptFromMcrypt extends Command
|
||||
// If not, we can try to use the current APP_KEY if looks like it's old
|
||||
$legacy_key = env('LEGACY_APP_KEY');
|
||||
$key_parts = explode(':', $legacy_key);
|
||||
$legacy_cipher = env('LEGACY_CIPHER');
|
||||
$legacy_cipher = env('LEGACY_CIPHER', 'rijndael-256');
|
||||
$errors = array();
|
||||
|
||||
if (!$legacy_key) {
|
||||
|
||||
105
app/Console/Commands/RegenerateAssetTags.php
Normal file
105
app/Console/Commands/RegenerateAssetTags.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Setting;
|
||||
use DB;
|
||||
use Artisan;
|
||||
|
||||
class RegenerateAssetTags extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'snipeit:regenerate-tags {--start=} {--output= : info|warn|error|all} ';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'This utility will regenerate all asset tags. THIS IS DATA-DESTRUCTIVE AND SHOULD BE USED WITH CAUTION. ';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
if ($this->confirm('This will regenerate all of the asset tags within your system. This action is data-destructive and should be used with caution. Do you wish to continue?'))
|
||||
{
|
||||
|
||||
$output['info'] = [];
|
||||
$output['warn'] = [];
|
||||
$output['error'] = [];
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
$start_tag = ($this->option('start')) ? $this->option('start') : (($settings->next_auto_tag_base) ? Setting::getSettings()->next_auto_tag_base : 1) ;
|
||||
|
||||
$this->info('Starting at '.$start_tag);
|
||||
|
||||
$total_assets = Asset::orderBy('id','asc')->get();
|
||||
$bar = $this->output->createProgressBar(count($total_assets));
|
||||
|
||||
try {
|
||||
Artisan::call('backup:run');
|
||||
} catch (\Exception $e) {
|
||||
$output['error'][] = $e;
|
||||
}
|
||||
|
||||
foreach ($total_assets as $asset) {
|
||||
|
||||
$start_tag++;
|
||||
$output['info'][] = 'Asset tag:'.$asset->asset_tag;
|
||||
$asset->asset_tag = $settings->auto_increment_prefix.$settings->auto_increment_prefix.$start_tag;
|
||||
|
||||
if ($settings->zerofill_count > 0) {
|
||||
$asset->asset_tag = $settings->auto_increment_prefix.Asset::zerofill($start_tag, $settings->zerofill_count);
|
||||
}
|
||||
|
||||
$output['info'][] = 'New Asset tag:'.$asset->asset_tag;
|
||||
|
||||
// Use forceSave here to override model level validation
|
||||
$asset->forceSave();
|
||||
}
|
||||
|
||||
$bar->finish();
|
||||
$this->info("\n");
|
||||
|
||||
|
||||
if (($this->option('output')=='all') || ($this->option('output')=='info')) {
|
||||
foreach ($output['info'] as $key => $output_text) {
|
||||
$this->info($output_text);
|
||||
}
|
||||
}
|
||||
if (($this->option('output')=='all') || ($this->option('output')=='warn')) {
|
||||
foreach ($output['warn'] as $key => $output_text) {
|
||||
$this->warn($output_text);
|
||||
}
|
||||
}
|
||||
if (($this->option('output')=='all') || ($this->option('output')=='error')) {
|
||||
foreach ($output['error'] as $key => $output_text) {
|
||||
$this->error($output_text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
148
app/Console/Commands/SyncAssetLocations.php
Normal file
148
app/Console/Commands/SyncAssetLocations.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\CustomField;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Asset;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class SyncAssetLocations extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'snipeit:sync-asset-locations {--output= : info|warn|error|all} ';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'This utility will sync the location_id of assets based on current state. It should not normally be needed, but is a safeguard in case we missed something in the Great Migration when flattening the assets to location relationship.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$output['info'] = [];
|
||||
$output['warn'] = [];
|
||||
$output['error'] = [];
|
||||
|
||||
$total_assets = Asset::whereNull('deleted_at')->get();
|
||||
$bar = $this->output->createProgressBar(count($total_assets));
|
||||
|
||||
// Unassigned
|
||||
$rtd_assets = Asset::whereNull('assigned_to')->whereNull('deleted_at')->with('defaultLoc')->get();
|
||||
$output['info'][] = 'There are '.$rtd_assets->count().' unassigned assets.';
|
||||
|
||||
foreach ($rtd_assets as $rtd_asset) {
|
||||
$output['info'][] = 'Setting Unassigned Asset ' . $rtd_asset->id . ' ('.$rtd_asset->asset_tag.') to location: ' . $rtd_asset->rtd_location_id . " because their default location is: " . $rtd_asset->rtd_location_id;
|
||||
$rtd_asset->location_id=$rtd_asset->rtd_location_id;
|
||||
$rtd_asset->unsetEventDispatcher();
|
||||
$rtd_asset->save();
|
||||
$bar->advance();
|
||||
}
|
||||
|
||||
$assigned_user_assets = Asset::where('assigned_type','App\Models\User')->whereNotNull('assigned_to')->whereNull('deleted_at')->get();
|
||||
$output['info'][] = 'There are '.$assigned_user_assets->count().' assets checked out to users.';
|
||||
foreach ($assigned_user_assets as $assigned_user_asset) {
|
||||
if (($assigned_user_asset->assignedTo) && ($assigned_user_asset->assignedTo->userLoc)) {
|
||||
$new_location=$assigned_user_asset->assignedTo->userloc->id;
|
||||
$output['info'][] ='Setting User Asset ' . $assigned_user_asset->id . ' ('.$assigned_user_asset->asset_tag.') to ' . $assigned_user_asset->assignedTo->userLoc->name . ' which is id: ' . $new_location;
|
||||
} else {
|
||||
$output['warn'][] ='Asset ' . $assigned_user_asset->id . ' ('.$assigned_user_asset->asset_tag.') still has no location! ';
|
||||
$new_location = $assigned_user_asset->rtd_location_id;
|
||||
}
|
||||
$assigned_user_asset->location_id=$new_location;
|
||||
$assigned_user_asset->unsetEventDispatcher();
|
||||
$assigned_user_asset->save();
|
||||
$bar->advance();
|
||||
|
||||
}
|
||||
|
||||
$assigned_location_assets = Asset::where('assigned_type','App\Models\Location')
|
||||
->whereNotNull('assigned_to')->whereNull('deleted_at')->get();
|
||||
$output['info'][] = 'There are '.$assigned_location_assets->count().' assets checked out to locations.';
|
||||
|
||||
foreach ($assigned_location_assets as $assigned_location_asset) {
|
||||
if ($assigned_location_asset->assignedTo) {
|
||||
$assigned_location_asset->location_id = $assigned_location_asset->assignedTo->id;
|
||||
$output['info'][] ='Setting Location Assigned asset ' . $assigned_location_asset->id . ' ('.$assigned_location_asset->asset_tag.') that is checked out to '.$assigned_location_asset->assignedTo->name.' (#'.$assigned_location_asset->assignedTo->id.') to location: ' . $assigned_location_asset->assetLoc()->id;
|
||||
$assigned_location_asset->unsetEventDispatcher();
|
||||
$assigned_location_asset->save();
|
||||
} else {
|
||||
$output['warn'][] ='Asset ' . $assigned_location_asset->id . ' ('.$assigned_location_asset->asset_tag.') did not return a valid associated location - perhaps it was deleted?';
|
||||
}
|
||||
$bar->advance();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Assigned to assets
|
||||
$assigned_asset_assets = Asset::where('assigned_type','App\Models\Asset')
|
||||
->whereNotNull('assigned_to')->whereNull('deleted_at')->get();
|
||||
$output['info'][] ='Asset-assigned assets: '.$assigned_asset_assets->count();
|
||||
|
||||
foreach ($assigned_asset_assets as $assigned_asset_asset) {
|
||||
|
||||
// Check to make sure there aren't any invalid relationships
|
||||
if ($assigned_asset_asset->assetLoc()) {
|
||||
$assigned_asset_asset->location_id = $assigned_asset_asset->assetLoc()->id;
|
||||
$output['info'][] ='Setting Asset Assigned asset ' . $assigned_asset_asset->assetLoc()->id. ' ('.$assigned_asset_asset->asset_tag.') location to: ' . $assigned_asset_asset->assetLoc()->id;
|
||||
$assigned_asset_asset->unsetEventDispatcher();
|
||||
$assigned_asset_asset->save();
|
||||
} else {
|
||||
$output['warn'][] ='Asset Assigned asset ' . $assigned_asset_asset->id. ' ('.$assigned_asset_asset->asset_tag.') does not seem to have a valid location';
|
||||
}
|
||||
|
||||
$bar->advance();
|
||||
|
||||
}
|
||||
|
||||
$unlocated_assets = Asset::whereNull("location_id")->whereNull('deleted_at')->get();
|
||||
$output['info'][] ='Assets still without a location: '.$unlocated_assets->count();
|
||||
foreach($unlocated_assets as $unlocated_asset) {
|
||||
$output['warn'][] ='Asset: '.$unlocated_asset->id.' still has no location. ';
|
||||
$bar->advance();
|
||||
}
|
||||
|
||||
$bar->finish();
|
||||
$this->info("\n");
|
||||
|
||||
|
||||
if (($this->option('output')=='all') || ($this->option('output')=='info')) {
|
||||
foreach ($output['info'] as $key => $output_text) {
|
||||
$this->info($output_text);
|
||||
}
|
||||
}
|
||||
if (($this->option('output')=='all') || ($this->option('output')=='warn')) {
|
||||
foreach ($output['warn'] as $key => $output_text) {
|
||||
$this->warn($output_text);
|
||||
}
|
||||
}
|
||||
if (($this->option('output')=='all') || ($this->option('output')=='error')) {
|
||||
foreach ($output['error'] as $key => $output_text) {
|
||||
$this->error($output_text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
135
app/Console/Commands/Version.php
Normal file
135
app/Console/Commands/Version.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class Version extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'version:update {--branch=master} {--type=patch}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$use_branch = $this->option('branch');
|
||||
$use_type = $this->option('type');
|
||||
$git_branch = trim(shell_exec('git rev-parse --abbrev-ref HEAD'));
|
||||
$build_version = trim(shell_exec('git rev-list --count '.$use_branch));
|
||||
$versionFile = 'config/version.php';
|
||||
$full_hash_version = str_replace("\n", '', shell_exec('git describe master --tags'));
|
||||
|
||||
$version = explode('-', $full_hash_version);
|
||||
$app_version = $current_app_version = $version[0];
|
||||
$hash_version = (array_key_exists('2', $version)) ? $version[2] : '';
|
||||
$prerelease_version = '';
|
||||
|
||||
$this->line('Branch is: '.$use_branch);
|
||||
$this->line('Type is: '.$use_type);
|
||||
$this->line('Current version is: '.$full_hash_version);
|
||||
|
||||
if (count($version)==3) {
|
||||
$this->line('This does not look like an alpha/beta release.');
|
||||
} else {
|
||||
if (array_key_exists('3',$version)) {
|
||||
$this->line('The current version looks like a beta release.');
|
||||
$prerelease_version = $version[1];
|
||||
$hash_version = $version[3];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$app_version_raw = explode('.', $app_version);
|
||||
|
||||
$maj = str_replace('v', '', $app_version_raw[0]);
|
||||
$min = $app_version_raw[1];
|
||||
$patch = '';
|
||||
|
||||
|
||||
|
||||
// This is a major release that might not have a third .0
|
||||
if (array_key_exists(2, $app_version_raw)) {
|
||||
$patch = $app_version_raw[2];
|
||||
}
|
||||
|
||||
if ($use_type=='major') {
|
||||
$app_version = "v".($maj + 1).".$min.$patch";
|
||||
} elseif ($use_type=='minor') {
|
||||
$app_version = "v"."$maj.".($min + 1).".$patch";
|
||||
} elseif ($use_type=='pre') {
|
||||
$pre_raw = str_replace('beta','', $prerelease_version);
|
||||
$pre_raw = str_replace('alpha','', $pre_raw);
|
||||
$pre_raw = str_ireplace('rc','', $pre_raw);
|
||||
$pre_raw = $pre_raw++;
|
||||
$this->line('Setting the pre-release to '. $prerelease_version.'-'.$pre_raw);
|
||||
$app_version = "v"."$maj.".($min + 1).".$patch";
|
||||
} elseif ($use_type=='patch') {
|
||||
$app_version = "v" . "$maj.$min." . ($patch + 1);
|
||||
// If nothing is passed, leave the version as it is, just increment the build
|
||||
} else {
|
||||
$app_version = "v" . "$maj.$min." . $patch;
|
||||
}
|
||||
|
||||
// Determine if this tag already exists, or if this prior to a release
|
||||
$this->line('Running: git rev-parse master '.$current_app_version);
|
||||
// $pre_release = trim(shell_exec('git rev-parse '.$use_branch.' '.$current_app_version.' 2>&1 1> /dev/null'));
|
||||
|
||||
if ($use_branch=='develop') {
|
||||
$app_version = $app_version.'-pre';
|
||||
}
|
||||
|
||||
$full_app_version = $app_version.' - build '.$build_version.'-'.$hash_version;
|
||||
|
||||
|
||||
$array = var_export(
|
||||
array(
|
||||
'app_version' => $app_version,
|
||||
'full_app_version' => $full_app_version,
|
||||
'build_version' => $build_version,
|
||||
'prerelease_version' => $prerelease_version,
|
||||
'hash_version' => $hash_version,
|
||||
'full_hash' => $full_hash_version,
|
||||
'branch' => $git_branch),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Construct our file content
|
||||
$content = <<<CON
|
||||
<?php
|
||||
return $array;
|
||||
CON;
|
||||
|
||||
// And finally write the file and output the current version
|
||||
\File::put($versionFile, $content);
|
||||
$this->info('Setting NEW version: '. $full_app_version.' ('.$git_branch.')');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class Versioning extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'versioning:update';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Generate and update app\'s version via git.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
|
||||
$versionFile = 'config/version.php';
|
||||
$hash_version = str_replace("\n", '', shell_exec('git describe --tags'));
|
||||
|
||||
$version = explode('-', $hash_version);
|
||||
|
||||
$array = var_export(
|
||||
array(
|
||||
'app_version' => $version[0],
|
||||
'build_version' => $version[1],
|
||||
'hash_version' => $version[2],
|
||||
'full_hash' => $hash_version),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
// Construct our file content
|
||||
$content = <<<CON
|
||||
<?php
|
||||
return $array;
|
||||
CON;
|
||||
|
||||
// And finally write the file and output the current version
|
||||
\File::put($versionFile, $content);
|
||||
$this->line('Setting version: '. config('version.app_version').' build '.config('version.build_version').' ('.config('version.hash_version').')');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return array(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -19,14 +19,16 @@ class Kernel extends ConsoleKernel
|
||||
Commands\SendInventoryAlerts::class,
|
||||
Commands\SendExpectedCheckinAlerts::class,
|
||||
Commands\ObjectImportCommand::class,
|
||||
Commands\Versioning::class,
|
||||
Commands\Version::class,
|
||||
Commands\SystemBackup::class,
|
||||
Commands\DisableLDAP::class,
|
||||
Commands\Purge::class,
|
||||
Commands\LdapSync::class,
|
||||
Commands\FixDoubleEscape::class,
|
||||
Commands\RecryptFromMcrypt::class,
|
||||
Commands\ResetDemoSettings::class
|
||||
Commands\ResetDemoSettings::class,
|
||||
Commands\SyncAssetLocations::class,
|
||||
Commands\RegenerateAssetTags::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -127,7 +127,13 @@ class Helper
|
||||
$floatString = str_replace(",", "", $floatString);
|
||||
$floatString = str_replace($LocaleInfo["decimal_point"], ".", $floatString);
|
||||
// Strip Currency symbol
|
||||
$floatString = str_replace($LocaleInfo['currency_symbol'], '', $floatString);
|
||||
// If no currency symbol is set, default to $ because Murica
|
||||
$currencySymbol = $LocaleInfo['currency_symbol'];
|
||||
if (empty($currencySymbol)) {
|
||||
$currencySymbol = '$';
|
||||
}
|
||||
|
||||
$floatString = str_replace($currencySymbol, '', $floatString);
|
||||
return floatval($floatString);
|
||||
}
|
||||
|
||||
@@ -454,19 +460,19 @@ class Helper
|
||||
*/
|
||||
public static function checkLowInventory()
|
||||
{
|
||||
$consumables = Consumable::with('users')->whereNotNull('min_amt')->get();
|
||||
$accessories = Accessory::with('users')->whereNotNull('min_amt')->get();
|
||||
$components = Component::with('assets')->whereNotNull('min_amt')->get();
|
||||
$consumables = Consumable::withCount('consumableAssignments')->whereNotNull('min_amt')->get();
|
||||
$accessories = Accessory::withCount('users')->whereNotNull('min_amt')->get();
|
||||
$components = Component::withCount('assets')->whereNotNull('min_amt')->get();
|
||||
|
||||
$avail_consumables = 0;
|
||||
$items_array = array();
|
||||
$all_count = 0;
|
||||
|
||||
foreach ($consumables as $consumable) {
|
||||
$avail = $consumable->numRemaining();
|
||||
$avail = $consumable->qty - $consumable->consumable_assignment_count; //$consumable->numRemaining();
|
||||
if ($avail < ($consumable->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
|
||||
if ($consumable->qty > 0) {
|
||||
$percent = number_format((($consumable->numRemaining() / $consumable->qty) * 100), 0);
|
||||
$percent = number_format((($avail / $consumable->qty) * 100), 0);
|
||||
} else {
|
||||
$percent = 100;
|
||||
}
|
||||
@@ -475,7 +481,7 @@ class Helper
|
||||
$items_array[$all_count]['name'] = $consumable->name;
|
||||
$items_array[$all_count]['type'] = 'consumables';
|
||||
$items_array[$all_count]['percent'] = $percent;
|
||||
$items_array[$all_count]['remaining']=$consumable->numRemaining();
|
||||
$items_array[$all_count]['remaining'] = $avail;
|
||||
$items_array[$all_count]['min_amt']=$consumable->min_amt;
|
||||
$all_count++;
|
||||
}
|
||||
@@ -484,11 +490,11 @@ class Helper
|
||||
}
|
||||
|
||||
foreach ($accessories as $accessory) {
|
||||
$avail = $accessory->numRemaining();
|
||||
$avail = $accessory->qty - $accessory->users_count;
|
||||
if ($avail < ($accessory->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
|
||||
|
||||
if ($accessory->qty > 0) {
|
||||
$percent = number_format((($accessory->numRemaining() / $accessory->qty) * 100), 0);
|
||||
$percent = number_format((($avail / $accessory->qty) * 100), 0);
|
||||
} else {
|
||||
$percent = 100;
|
||||
}
|
||||
@@ -497,7 +503,7 @@ class Helper
|
||||
$items_array[$all_count]['name'] = $accessory->name;
|
||||
$items_array[$all_count]['type'] = 'accessories';
|
||||
$items_array[$all_count]['percent'] = $percent;
|
||||
$items_array[$all_count]['remaining']=$accessory->numRemaining();
|
||||
$items_array[$all_count]['remaining'] = $avail;
|
||||
$items_array[$all_count]['min_amt']=$accessory->min_amt;
|
||||
$all_count++;
|
||||
}
|
||||
@@ -505,10 +511,10 @@ class Helper
|
||||
}
|
||||
|
||||
foreach ($components as $component) {
|
||||
$avail = $component->numRemaining();
|
||||
$avail = $component->qty - $component->assets_count;
|
||||
if ($avail < ($component->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
|
||||
if ($component->qty > 0) {
|
||||
$percent = number_format((($component->numRemaining() / $component->qty) * 100), 0);
|
||||
$percent = number_format((($avail / $component->qty) * 100), 0);
|
||||
} else {
|
||||
$percent = 100;
|
||||
}
|
||||
@@ -517,7 +523,7 @@ class Helper
|
||||
$items_array[$all_count]['name'] = $component->name;
|
||||
$items_array[$all_count]['type'] = 'components';
|
||||
$items_array[$all_count]['percent'] = $percent;
|
||||
$items_array[$all_count]['remaining']=$component->numRemaining();
|
||||
$items_array[$all_count]['remaining'] = $avail;
|
||||
$items_array[$all_count]['min_amt']=$component->min_amt;
|
||||
$all_count++;
|
||||
}
|
||||
@@ -725,5 +731,62 @@ class Helper
|
||||
}
|
||||
|
||||
|
||||
// Nicked from Drupal :)
|
||||
// Returns a file size limit in bytes based on the PHP upload_max_filesize
|
||||
// and post_max_size
|
||||
public static function file_upload_max_size() {
|
||||
static $max_size = -1;
|
||||
|
||||
if ($max_size < 0) {
|
||||
// Start with post_max_size.
|
||||
$post_max_size = Helper::parse_size(ini_get('post_max_size'));
|
||||
if ($post_max_size > 0) {
|
||||
$max_size = $post_max_size;
|
||||
}
|
||||
|
||||
// If upload_max_size is less, then reduce. Except if upload_max_size is
|
||||
// zero, which indicates no limit.
|
||||
$upload_max = Helper::parse_size(ini_get('upload_max_filesize'));
|
||||
if ($upload_max > 0 && $upload_max < $max_size) {
|
||||
$max_size = $upload_max;
|
||||
}
|
||||
}
|
||||
return $max_size;
|
||||
}
|
||||
|
||||
public static function file_upload_max_size_readable() {
|
||||
static $max_size = -1;
|
||||
|
||||
if ($max_size < 0) {
|
||||
// Start with post_max_size.
|
||||
$post_max_size = Helper::parse_size(ini_get('post_max_size'));
|
||||
if ($post_max_size > 0) {
|
||||
$max_size = ini_get('post_max_size');
|
||||
}
|
||||
|
||||
// If upload_max_size is less, then reduce. Except if upload_max_size is
|
||||
// zero, which indicates no limit.
|
||||
$upload_max = Helper::parse_size(ini_get('upload_max_filesize'));
|
||||
if ($upload_max > 0 && $upload_max < $max_size) {
|
||||
$max_size = ini_get('upload_max_filesize');
|
||||
}
|
||||
}
|
||||
return $max_size;
|
||||
}
|
||||
|
||||
public static function parse_size($size) {
|
||||
$unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
|
||||
$size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
|
||||
if ($unit) {
|
||||
// Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
|
||||
return round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
|
||||
}
|
||||
else {
|
||||
return round($size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@ class AccessoriesController extends Controller
|
||||
$accessories->where('company_id','=',$request->input('company_id'));
|
||||
}
|
||||
|
||||
if ($request->has('category_id')) {
|
||||
$accessories->where('category_id','=',$request->input('category_id'));
|
||||
}
|
||||
|
||||
if ($request->has('manufacturer_id')) {
|
||||
$accessories->where('manufacturer_id','=',$request->input('manufacturer_id'));
|
||||
}
|
||||
|
||||
@@ -40,10 +40,24 @@ class AssetMaintenancesController extends Controller
|
||||
$maintenances = $maintenances->TextSearch(e($request->input('search')));
|
||||
}
|
||||
|
||||
if ($request->has('asset_id')) {
|
||||
$maintenances->where('asset_id', '=', $request->input('asset_id'));
|
||||
}
|
||||
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
|
||||
$allowed_columns = ['id','title','asset_maintenance_time','asset_maintenance_type','cost','start_date','completion_date','notes','user_id'];
|
||||
$allowed_columns = [
|
||||
'id',
|
||||
'title',
|
||||
'asset_maintenance_time',
|
||||
'asset_maintenance_type',
|
||||
'cost',
|
||||
'start_date',
|
||||
'completion_date',
|
||||
'notes',
|
||||
'user_id'
|
||||
];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
|
||||
|
||||
@@ -56,11 +70,9 @@ class AssetMaintenancesController extends Controller
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$total = $maintenances->count();
|
||||
$maintenances = $maintenances->skip($offset)->take($limit)->get();
|
||||
|
||||
|
||||
return (new AssetMaintenancesTransformer())->transformAssetMaintenances($maintenances, $maintenances->count());
|
||||
return (new AssetMaintenancesTransformer())->transformAssetMaintenances($maintenances, $total);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,20 +30,21 @@ class AssetModelsController extends Controller
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->authorize('view', AssetModel::class);
|
||||
$allowed_columns = ['id','image','name','model_number','eol','notes','created_at','manufacturer'];
|
||||
$allowed_columns = ['id','image','name','model_number','eol','notes','created_at','manufacturer','assets_count'];
|
||||
|
||||
$assetmodels = AssetModel::select(['models.id','models.image','models.name','model_number','eol','models.notes','models.created_at','category_id','manufacturer_id','depreciation_id','fieldset_id', 'models.deleted_at'])
|
||||
->with('category','depreciation', 'manufacturer','fieldset')
|
||||
->withCount('assets');
|
||||
|
||||
if ($request->has('search')) {
|
||||
$assetmodels->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
|
||||
if ($request->has('status')) {
|
||||
$assetmodels->onlyTrashed();
|
||||
}
|
||||
|
||||
if ($request->has('search')) {
|
||||
$assetmodels->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
$offset = $request->input('offset', 0);
|
||||
$limit = $request->input('limit', 50);
|
||||
@@ -60,6 +61,7 @@ class AssetModelsController extends Controller
|
||||
}
|
||||
|
||||
|
||||
|
||||
$total = $assetmodels->count();
|
||||
$assetmodels = $assetmodels->skip($offset)->take($limit)->get();
|
||||
return (new AssetModelsTransformer)->transformAssetModels($assetmodels, $total);
|
||||
@@ -182,25 +184,43 @@ class AssetModelsController extends Controller
|
||||
*/
|
||||
public function selectlist(Request $request)
|
||||
{
|
||||
$this->authorize('view', AssetModel::class);
|
||||
|
||||
$assetmodels = AssetModel::select([
|
||||
'models.id',
|
||||
'models.name',
|
||||
'models.image',
|
||||
'models.model_number',
|
||||
]);
|
||||
'models.manufacturer_id',
|
||||
'models.category_id',
|
||||
])->with('manufacturer','category');
|
||||
|
||||
$settings = \App\Models\Setting::getSettings();
|
||||
|
||||
if ($request->has('search')) {
|
||||
$assetmodels = $assetmodels->where('models.name', 'LIKE', '%'.$request->get('search').'%')
|
||||
->orWhere('models.model_number', 'LIKE', '%'.$request->get('search').'%');
|
||||
$assetmodels = $assetmodels->SearchByManufacturerOrCat($request->input('search'));
|
||||
}
|
||||
$assetmodels = $assetmodels->paginate(50);
|
||||
|
||||
$assetmodels = $assetmodels->OrderCategory('ASC')->OrderManufacturer('ASC')->orderby('models.name', 'asc')->orderby('models.model_number', 'asc')->paginate(50);
|
||||
|
||||
foreach ($assetmodels as $assetmodel) {
|
||||
$assetmodel->use_text = $assetmodel->present()->modelName;
|
||||
$assetmodel->use_image = ($assetmodel->image) ? url('/').'/uploads/models/'.$assetmodel->image : null;
|
||||
|
||||
$assetmodel->use_text = '';
|
||||
|
||||
if ($settings->modellistCheckedValue('category')) {
|
||||
$assetmodel->use_text .= (($assetmodel->category) ? e($assetmodel->category->name).' - ' : '');
|
||||
}
|
||||
|
||||
if ($settings->modellistCheckedValue('manufacturer')) {
|
||||
$assetmodel->use_text .= (($assetmodel->manufacturer) ? e($assetmodel->manufacturer->name).' ' : '');
|
||||
}
|
||||
|
||||
$assetmodel->use_text .= e($assetmodel->name);
|
||||
|
||||
if (($settings->modellistCheckedValue('model_number')) && ($assetmodel->model_number!='')) {
|
||||
$assetmodel->use_text .= ' (#'.e($assetmodel->model_number).')';
|
||||
}
|
||||
|
||||
$assetmodel->use_image = ($settings->modellistCheckedValue('image') && ($assetmodel->image)) ? url('/').'/uploads/models/'.$assetmodel->image : null;
|
||||
}
|
||||
|
||||
return (new SelectlistTransformer)->transformSelectlist($assetmodels);
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\AssetRequest;
|
||||
use App\Http\Requests\AssetCheckoutRequest;
|
||||
use App\Http\Transformers\AssetsTransformer;
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
@@ -53,7 +54,9 @@ class AssetsController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
$this->authorize('index', Asset::class);
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
$allowed_columns = [
|
||||
'id',
|
||||
@@ -71,34 +74,34 @@ class AssetsController extends Controller
|
||||
'updated_at',
|
||||
'purchase_date',
|
||||
'purchase_cost',
|
||||
'last_audit_date',
|
||||
'next_audit_date',
|
||||
'warranty_months',
|
||||
];
|
||||
|
||||
$filter = array();
|
||||
|
||||
if ($request->has('filter')) {
|
||||
$filter = json_decode($request->input('filter'));
|
||||
}
|
||||
|
||||
|
||||
$all_custom_fields = CustomField::all(); //used as a 'cache' of custom fields throughout this page load
|
||||
foreach ($all_custom_fields as $field) {
|
||||
$allowed_columns[]=$field->db_column_name();
|
||||
}
|
||||
|
||||
$assets = Company::scopeCompanyables(Asset::select('assets.*'))->with(
|
||||
'location', 'assetstatus', 'assetlog', 'company', 'defaultLoc','assignedTo',
|
||||
$assets = Company::scopeCompanyables(Asset::select('assets.*'),"company_id","assets")
|
||||
->with('location', 'assetstatus', 'assetlog', 'company', 'defaultLoc','assignedTo',
|
||||
'model.category', 'model.manufacturer', 'model.fieldset','supplier');
|
||||
|
||||
|
||||
if (count($filter) > 0) {
|
||||
$assets->ByFilter($filter);
|
||||
} elseif ($request->has('search')) {
|
||||
$assets->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// These are used by the API to query against specific ID numbers
|
||||
|
||||
// These are used by the API to query against specific ID numbers.
|
||||
// They are also used by the individual searches on detail pages like
|
||||
// locations, etc.
|
||||
if ($request->has('status_id')) {
|
||||
$assets->where('assets.status_id', '=', $request->input('status_id'));
|
||||
}
|
||||
@@ -112,13 +115,19 @@ class AssetsController extends Controller
|
||||
}
|
||||
|
||||
if ($request->has('location_id')) {
|
||||
$assets->ByLocationId($request->input('location_id'));
|
||||
$assets->where('assets.location_id', '=', $request->input('location_id'));
|
||||
// dd($assets->toSql());
|
||||
}
|
||||
|
||||
if ($request->has('supplier_id')) {
|
||||
$assets->where('assets.supplier_id', '=', $request->input('supplier_id'));
|
||||
}
|
||||
|
||||
if (($request->has('assigned_to')) && ($request->has('assigned_type'))) {
|
||||
$assets->where('assets.assigned_to', '=', $request->input('assigned_to'))
|
||||
->where('assets.assigned_type', '=', $request->input('assigned_type'));
|
||||
}
|
||||
|
||||
if ($request->has('company_id')) {
|
||||
$assets->where('assets.company_id', '=', $request->input('company_id'));
|
||||
}
|
||||
@@ -137,7 +146,6 @@ class AssetsController extends Controller
|
||||
$limit = $request->input('limit', 50);
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
|
||||
// This is used by the sidenav, mostly
|
||||
|
||||
// We switched from using query scopes here because of a Laravel bug
|
||||
@@ -190,11 +198,27 @@ class AssetsController extends Controller
|
||||
$assets->where('assets.assigned_to', '>', '0');
|
||||
break;
|
||||
default:
|
||||
// terrible workaround for complex-query Laravel bug in fulltext
|
||||
$assets->join('status_labels AS status_alias',function ($join) {
|
||||
$join->on('status_alias.id', "=", "assets.status_id")
|
||||
->where('status_alias.archived', '=', 0);
|
||||
});
|
||||
|
||||
if ((!$request->has('status_id')) && ($settings->show_archived_in_list!='1')) {
|
||||
// terrible workaround for complex-query Laravel bug in fulltext
|
||||
$assets->join('status_labels AS status_alias',function ($join) {
|
||||
$join->on('status_alias.id', "=", "assets.status_id")
|
||||
->where('status_alias.archived', '=', 0);
|
||||
});
|
||||
|
||||
// If there is a status ID, don't take show_archived_in_list into consideration
|
||||
} else {
|
||||
$assets->join('status_labels AS status_alias',function ($join) {
|
||||
$join->on('status_alias.id', "=", "assets.status_id");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (count($filter) > 0) {
|
||||
$assets->ByFilter($filter);
|
||||
} elseif ($request->has('search')) {
|
||||
$assets->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
|
||||
@@ -226,6 +250,8 @@ class AssetsController extends Controller
|
||||
break;
|
||||
case 'location':
|
||||
$assets->OrderLocation($order);
|
||||
case 'rtd_location':
|
||||
$assets->OrderRtdLocation($order);
|
||||
break;
|
||||
case 'status_label':
|
||||
$assets->OrderStatus($order);
|
||||
@@ -240,7 +266,8 @@ class AssetsController extends Controller
|
||||
$assets->orderBy($column_sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$total = $assets->count();
|
||||
$assets = $assets->skip($offset)->take($limit)->get();
|
||||
return (new AssetsTransformer)->transformAssets($assets, $total);
|
||||
@@ -275,31 +302,42 @@ class AssetsController extends Controller
|
||||
*/
|
||||
public function selectlist(Request $request)
|
||||
{
|
||||
$this->authorize('view', Asset::class);
|
||||
|
||||
$assets = Company::scopeCompanyables(Asset::select([
|
||||
'assets.id',
|
||||
'assets.name',
|
||||
'assets.asset_tag',
|
||||
'assets.model_id',
|
||||
]))->with('model')->RTD();
|
||||
'assets.assigned_to',
|
||||
'assets.assigned_type',
|
||||
'assets.status_id'
|
||||
])->with('model', 'assetstatus', 'assignedTo')->NotArchived());
|
||||
|
||||
|
||||
if ($request->has('search')) {
|
||||
$assets = $assets->where('assets.name', 'LIKE', '%'.$request->get('search').'%')
|
||||
->orWhere('assets.asset_tag', 'LIKE', '%'.$request->get('search').'%')
|
||||
->join('models AS assets_models',function ($join) use ($request) {
|
||||
$join->on('assets_models.id', "=", "assets.model_id");
|
||||
})->orWhere('assets_models.name','LIKE','%'.$request->get('search').'%');
|
||||
$assets = $assets->AssignedSearch($request->input('search'));
|
||||
}
|
||||
|
||||
|
||||
$assets = $assets->paginate(50);
|
||||
|
||||
// Loop through and set some custom properties for the transformer to use.
|
||||
// This lets us have more flexibility in special cases like assets, where
|
||||
// they may not have a ->name value but we want to display something anyway
|
||||
foreach ($assets as $asset) {
|
||||
|
||||
|
||||
$asset->use_text = $asset->present()->fullName;
|
||||
|
||||
if (($asset->checkedOutToUser()) && ($asset->assigned)) {
|
||||
$asset->use_text .= ' → '.$asset->assigned->getFullNameAttribute();
|
||||
}
|
||||
|
||||
|
||||
if ($asset->assetstatus->getStatuslabelType()=='pending') {
|
||||
$asset->use_text .= '('.$asset->assetstatus->getStatuslabelType().')';
|
||||
}
|
||||
|
||||
$asset->use_image = ($asset->getImageUrl()) ? $asset->getImageUrl() : null;
|
||||
}
|
||||
|
||||
@@ -330,7 +368,7 @@ class AssetsController extends Controller
|
||||
$asset->model_id = $request->get('model_id');
|
||||
$asset->order_number = $request->get('order_number');
|
||||
$asset->notes = $request->get('notes');
|
||||
$asset->asset_tag = $request->get('asset_tag');
|
||||
$asset->asset_tag = $request->get('asset_tag', Asset::autoincrement_asset());
|
||||
$asset->user_id = Auth::id();
|
||||
$asset->archived = '0';
|
||||
$asset->physical = '1';
|
||||
@@ -417,31 +455,34 @@ class AssetsController extends Controller
|
||||
$asset->requestable = $request->get('requestable') : '';
|
||||
($request->has('rtd_location_id')) ?
|
||||
$asset->rtd_location_id = $request->get('rtd_location_id') : '';
|
||||
($request->has('rtd_location_id')) ?
|
||||
$asset->location_id = $request->get('rtd_location_id') : '';
|
||||
($request->has('company_id')) ?
|
||||
$asset->company_id = Company::getIdForCurrentUser($request->get('company_id')) : '';
|
||||
|
||||
if ($request->has('model_id')) {
|
||||
if (($model = AssetModel::find($request->get('model_id'))) && (isset($model->fieldset))) {
|
||||
foreach ($model->fieldset->fields as $field) {
|
||||
if ($request->has($field->convertUnicodeDbSlug())) {
|
||||
$asset->{$field->convertUnicodeDbSlug()} = e($request->input($field->convertUnicodeDbSlug()));
|
||||
}
|
||||
|
||||
// Update custom fields
|
||||
if (($model = AssetModel::find($asset->model_id)) && (isset($model->fieldset))) {
|
||||
foreach ($model->fieldset->fields as $field) {
|
||||
if ($request->has($field->convertUnicodeDbSlug())) {
|
||||
$asset->{$field->convertUnicodeDbSlug()} = e($request->input($field->convertUnicodeDbSlug()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($asset->save()) {
|
||||
|
||||
if ($request->get('assigned_user')) {
|
||||
$target = User::find(request('assigned_user'));
|
||||
} elseif ($request->get('assigned_asset')) {
|
||||
$target = Asset::find(request('assigned_asset'));
|
||||
} elseif ($request->get('assigned_location')) {
|
||||
$target = Location::find(request('assigned_location'));
|
||||
if (($request->has('assigned_user')) && ($target = User::find($request->get('assigned_user')))) {
|
||||
$location = $target->location_id;
|
||||
} elseif (($request->has('assigned_asset')) && ($target = Asset::find($request->get('assigned_asset')))) {
|
||||
$location = $target->location_id;
|
||||
} elseif (($request->has('assigned_location')) && ($target = Location::find($request->get('assigned_location')))) {
|
||||
$location = $target->id;
|
||||
}
|
||||
|
||||
if (isset($target)) {
|
||||
$asset->checkOut($target, Auth::user(), date('Y-m-d H:i:s'), '', 'Checked out on asset update', e($request->get('name')));
|
||||
$asset->checkOut($target, Auth::user(), date('Y-m-d H:i:s'), '', 'Checked out on asset update', e($request->get('name')), $location);
|
||||
}
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('success', $asset, trans('admin/hardware/message.update.success')));
|
||||
@@ -490,7 +531,7 @@ class AssetsController extends Controller
|
||||
* @since [v4.0]
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function checkout(Request $request, $asset_id)
|
||||
public function checkout(AssetCheckoutRequest $request, $asset_id)
|
||||
{
|
||||
$this->authorize('checkout', Asset::class);
|
||||
$asset = Asset::findOrFail($asset_id);
|
||||
@@ -506,23 +547,37 @@ class AssetsController extends Controller
|
||||
'id' => $asset->id,
|
||||
'asset_tag' => $asset->asset_tag,
|
||||
];
|
||||
if ($request->has('user_id')) {
|
||||
$target = User::find($request->input('user_id'));
|
||||
$error_payload['target_id'] = $request->input('user_id');
|
||||
$error_payload['target_type'] = User::class;
|
||||
// Don't let the user check an asset out to itself
|
||||
} elseif ($request->has('asset_id')) {
|
||||
$target = Asset::where('id','!=',$asset_id)->find($request->input('asset_id'));
|
||||
$error_payload['target_id'] = $request->input('asset_id');
|
||||
$error_payload['target_type'] = Asset::class;
|
||||
} elseif ($request->has('location_id')) {
|
||||
$target = Location::find($request->input('location_id'));
|
||||
$error_payload['target_id'] = $request->input('location_id');
|
||||
$error_payload['target_type'] = Location::class;
|
||||
|
||||
|
||||
// This item is checked out to a location
|
||||
if (request('checkout_to_type')=='location') {
|
||||
$target = Location::find(request('assigned_location'));
|
||||
$asset->location_id = ($target) ? $target->id : '';
|
||||
$error_payload['target_id'] = $request->input('assigned_location');
|
||||
$error_payload['target_type'] = 'location';
|
||||
|
||||
} elseif (request('checkout_to_type')=='asset') {
|
||||
$target = Asset::where('id','!=',$asset_id)->find(request('assigned_asset'));
|
||||
$asset->location_id = $target->rtd_location_id;
|
||||
// Override with the asset's location_id if it has one
|
||||
if ($target->location_id!='') {
|
||||
$asset->location_id = ($target) ? $target->location_id : '';
|
||||
}
|
||||
$error_payload['target_id'] = $request->input('assigned_asset');
|
||||
$error_payload['target_type'] = 'asset';
|
||||
|
||||
} elseif (request('checkout_to_type')=='user') {
|
||||
// Fetch the target and set the asset's new location_id
|
||||
$target = User::find(request('assigned_user'));
|
||||
$asset->location_id = ($target) ? $target->location_id : '';
|
||||
$error_payload['target_id'] = $request->input('assigned_user');
|
||||
$error_payload['target_type'] = 'user';
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!isset($target)) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', $error_payload, 'No valid checkout target specified for asset '.e($asset->asset_tag).'.'));
|
||||
return response()->json(Helper::formatStandardApiResponse('error', $error_payload, 'Checkout target for asset '.e($asset->asset_tag).' is invalid - '.$error_payload['target_type'].' does not exist.'));
|
||||
}
|
||||
|
||||
|
||||
@@ -537,13 +592,11 @@ class AssetsController extends Controller
|
||||
$asset->location_id = $target->rtd_location_id;
|
||||
}
|
||||
|
||||
// Overwrite that if the target has a location ID though
|
||||
if ($target->location_id!='') {
|
||||
$asset->location_id = $target->location_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ($asset->checkOut($target, Auth::user(), $checkout_at, $expected_checkin, $note, $asset_name)) {
|
||||
if ($asset->checkOut($target, Auth::user(), $checkout_at, $expected_checkin, $note, $asset_name, $asset->location_id)) {
|
||||
return response()->json(Helper::formatStandardApiResponse('success', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkout.success')));
|
||||
}
|
||||
|
||||
@@ -559,7 +612,7 @@ class AssetsController extends Controller
|
||||
* @since [v4.0]
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function checkin($asset_id)
|
||||
public function checkin(Request $request, $asset_id)
|
||||
{
|
||||
$this->authorize('checkin', Asset::class);
|
||||
$asset = Asset::findOrFail($asset_id);
|
||||
@@ -577,6 +630,13 @@ class AssetsController extends Controller
|
||||
$asset->assignedTo()->disassociate($asset);
|
||||
$asset->accepted = null;
|
||||
$asset->name = e(Input::get('name'));
|
||||
$asset->location_id = $asset->rtd_location_id;
|
||||
|
||||
if ($request->has('location_id')) {
|
||||
$asset->location_id = $request->input('location_id');
|
||||
}
|
||||
|
||||
$asset->location_id = $asset->rtd_location_id;
|
||||
|
||||
if (Input::has('status_id')) {
|
||||
$asset->status_id = e(Input::get('status_id'));
|
||||
@@ -639,7 +699,11 @@ class AssetsController extends Controller
|
||||
|
||||
|
||||
if ($asset) {
|
||||
// We don't want to log this as a normal update, so let's bypass that
|
||||
$asset->unsetEventDispatcher();
|
||||
$asset->next_audit_date = $request->input('next_audit_date');
|
||||
$asset->last_audit_date = date('Y-m-d h:i:s');
|
||||
|
||||
if ($asset->save()) {
|
||||
$log = $asset->logAudit(request('note'),request('location_id'));
|
||||
return response()->json(Helper::formatStandardApiResponse('success', [
|
||||
|
||||
@@ -21,7 +21,7 @@ class CategoriesController extends Controller
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->authorize('view', Category::class);
|
||||
$allowed_columns = ['id', 'name','category_type','use_default_eula','eula_text', 'require_acceptance','checkin_email', 'assets_count', 'accessories_count', 'consumables_count', 'components_count', 'image'];
|
||||
$allowed_columns = ['id', 'name','category_type', 'category_type','use_default_eula','eula_text', 'require_acceptance','checkin_email', 'assets_count', 'accessories_count', 'consumables_count', 'components_count', 'image'];
|
||||
|
||||
$categories = Category::select(['id', 'created_at', 'updated_at', 'name','category_type','use_default_eula','eula_text', 'require_acceptance','checkin_email','image'])
|
||||
->withCount('assets', 'accessories', 'consumables', 'components');
|
||||
@@ -141,7 +141,6 @@ class CategoriesController extends Controller
|
||||
*/
|
||||
public function selectlist(Request $request, $category_type = 'asset')
|
||||
{
|
||||
$this->authorize('view', Categories::class);
|
||||
|
||||
$categories = Category::select([
|
||||
'id',
|
||||
|
||||
@@ -22,12 +22,20 @@ class CompaniesController extends Controller
|
||||
{
|
||||
$this->authorize('view', Company::class);
|
||||
|
||||
$allowed_columns = ['id','name'];
|
||||
$allowed_columns = [
|
||||
'id',
|
||||
'name',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'users_count',
|
||||
'assets_count',
|
||||
'licenses_count',
|
||||
'accessories_count',
|
||||
'consumables_count',
|
||||
'components_count',
|
||||
];
|
||||
|
||||
$companies = Company::withCount('assets','licenses','accessories','consumables','components','users')
|
||||
->withCount('users')->withCount('users')->withCount('assets')
|
||||
->withCount('licenses')->withCount('accessories')
|
||||
->withCount('consumables')->withCount('components');
|
||||
$companies = Company::withCount('assets','licenses','accessories','consumables','components','users');
|
||||
|
||||
if ($request->has('search')) {
|
||||
$companies->TextSearch($request->input('search'));
|
||||
@@ -153,7 +161,6 @@ class CompaniesController extends Controller
|
||||
*/
|
||||
public function selectlist(Request $request)
|
||||
{
|
||||
$this->authorize('view', Company::class);
|
||||
|
||||
$companies = Company::select([
|
||||
'companies.id',
|
||||
|
||||
@@ -31,6 +31,10 @@ class ComponentsController extends Controller
|
||||
$components = $components->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
if ($request->has('company_id')) {
|
||||
$components->where('company_id','=',$request->input('company_id'));
|
||||
}
|
||||
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
|
||||
@@ -149,7 +153,7 @@ class ComponentsController extends Controller
|
||||
*/
|
||||
public function getAssets(Request $request, $id)
|
||||
{
|
||||
$this->authorize('index', Asset::class);
|
||||
$this->authorize('view', \App\Models\Asset::class);
|
||||
|
||||
$component = Component::findOrFail($id);
|
||||
$assets = $component->assets();
|
||||
|
||||
@@ -160,7 +160,6 @@ class ConsumablesController extends Controller
|
||||
*/
|
||||
public function getDataView($consumableId)
|
||||
{
|
||||
//$consumable = Consumable::find($consumableID);
|
||||
$consumable = Consumable::with(array('consumableAssignments'=>
|
||||
function ($query) {
|
||||
$query->orderBy('created_at', 'DESC');
|
||||
@@ -171,17 +170,15 @@ class ConsumablesController extends Controller
|
||||
},
|
||||
))->find($consumableId);
|
||||
|
||||
// $consumable->load('consumableAssignments.admin','consumableAssignments.user');
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($consumable)) {
|
||||
return ['total' => 0, 'rows' => []];
|
||||
}
|
||||
$this->authorize('view', Component::class);
|
||||
$this->authorize('view', Consumable::class);
|
||||
$rows = array();
|
||||
|
||||
foreach ($consumable->consumableAssignments as $consumable_assignment) {
|
||||
$rows[] = [
|
||||
'name' => $consumable_assignment->user->present()->nameUrl(),
|
||||
'name' => ($consumable_assignment->user) ? $consumable_assignment->user->present()->nameUrl() : 'Deleted User',
|
||||
'created_at' => ($consumable_assignment->created_at->format('Y-m-d H:i:s')=='-0001-11-30 00:00:00') ? '' : $consumable_assignment->created_at->format('Y-m-d H:i:s'),
|
||||
'admin' => ($consumable_assignment->admin) ? $consumable_assignment->admin->present()->nameUrl() : '',
|
||||
];
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Transformers\CustomFieldsTransformer;
|
||||
use App\Models\CustomField;
|
||||
use App\Models\CustomFieldset;
|
||||
use Illuminate\Http\Request;
|
||||
use Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CustomFieldsController extends Controller
|
||||
{
|
||||
@@ -27,6 +30,81 @@ class CustomFieldsController extends Controller
|
||||
$total = count($fields);
|
||||
return (new CustomFieldsTransformer)->transformCustomFields($fields, $total);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the given field
|
||||
* @author [V. Cordes] [<volker@fdatek.de>]
|
||||
* @param int $id
|
||||
* @since [v4.1.10]
|
||||
* @return View
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$this->authorize('show', CustomField::class);
|
||||
if ($field = CustomField::find($id)) {
|
||||
return (new CustomFieldsTransformer)->transformCustomField($field);
|
||||
}
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/custom_fields/message.field.invalid')), 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified field
|
||||
*
|
||||
* @author [V. Cordes] [<volker@fdatek.de>]
|
||||
* @since [v4.1.10]
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$this->authorize('edit', CustomField::class);
|
||||
$field = CustomField::findOrFail($id);
|
||||
$data = $request->all();
|
||||
|
||||
$validator = Validator::make($data, $field->validationRules());
|
||||
if ($validator->fails()) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, $validator->errors()));
|
||||
}
|
||||
|
||||
$field->fill($data);
|
||||
|
||||
if ($field->save()) {
|
||||
return response()->json(Helper::formatStandardApiResponse('success', $field, trans('admin/custom_fields/message.field.update.success')));
|
||||
}
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, $field->getErrors()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store a newly created field.
|
||||
*
|
||||
* @author [V. Cordes] [<volker@fdatek.de>]
|
||||
* @since [v4.1.10]
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$this->authorize('create', CustomField::class);
|
||||
$field = new CustomField;
|
||||
|
||||
$data = $request->all();
|
||||
$validator = Validator::make($data, $field->validationRules());
|
||||
if ($validator->fails()) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, $validator->errors()));
|
||||
}
|
||||
$field->fill($data);
|
||||
|
||||
if ($field->save()) {
|
||||
return response()->json(Helper::formatStandardApiResponse('success', $field, trans('admin/custom_fields/message.field.create.success')));
|
||||
}
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, $field->getErrors()));
|
||||
|
||||
}
|
||||
|
||||
public function postReorder(Request $request, $id)
|
||||
{
|
||||
$fieldset = CustomFieldset::find($id);
|
||||
@@ -47,6 +125,38 @@ class CustomFieldsController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function associate(Request $request, $field_id)
|
||||
{
|
||||
$this->authorize('edit', CustomFieldset::class);
|
||||
$field = CustomField::findOrFail($field_id);
|
||||
|
||||
$fieldset_id = $request->input('fieldset_id');
|
||||
foreach ($field->fieldset as $fieldset) {
|
||||
if ($fieldset->id == $fieldset_id) {
|
||||
return response()->json(Helper::formatStandardApiResponse('success', $fieldset, trans('admin/custom_fields/message.fieldset.update.success')));
|
||||
}
|
||||
}
|
||||
|
||||
$fieldset = CustomFieldset::findOrFail($fieldset_id);
|
||||
$fieldset->fields()->attach($field->id, ["required" => ($request->input('required') == "on"), "order" => $request->input('order', $fieldset->fields->count())]);
|
||||
return response()->json(Helper::formatStandardApiResponse('success', $fieldset, trans('admin/custom_fields/message.fieldset.update.success')));
|
||||
}
|
||||
|
||||
public function disassociate(Request $request, $field_id)
|
||||
{
|
||||
$this->authorize('edit', CustomFieldset::class);
|
||||
$field = CustomField::findOrFail($field_id);
|
||||
|
||||
$fieldset_id = $request->input('fieldset_id');
|
||||
foreach ($field->fieldset as $fieldset) {
|
||||
if ($fieldset->id == $fieldset_id) {
|
||||
$fieldset->fields()->detach($field->id);
|
||||
return response()->json(Helper::formatStandardApiResponse('success', $fieldset, trans('admin/custom_fields/message.fieldset.update.success')));
|
||||
}
|
||||
}
|
||||
$fieldset = CustomFieldset::findOrFail($fieldset_id);
|
||||
return response()->json(Helper::formatStandardApiResponse('success', $fieldset, trans('admin/custom_fields/message.fieldset.update.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a custom field.
|
||||
@@ -62,7 +172,7 @@ class CustomFieldsController extends Controller
|
||||
if ($field->fieldset->count() >0) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, 'Field is in use.'));
|
||||
}
|
||||
|
||||
|
||||
$field->delete();
|
||||
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/custom_fields/message.field.delete.success')));
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ class CustomFieldsetsController extends Controller
|
||||
{
|
||||
$this->authorize('delete', CustomFieldset::class);
|
||||
$fieldset = CustomFieldset::findOrFail($id);
|
||||
|
||||
|
||||
$modelsCount = $fieldset->models->count();
|
||||
$fieldsCount = $fieldset->fields->count();
|
||||
|
||||
@@ -141,7 +141,23 @@ class CustomFieldsetsController extends Controller
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, 'Unspecified error'));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return JSON containing a list of fields belonging to a fieldset.
|
||||
*
|
||||
* @author [V. Cordes] [<volker@fdatek.de>]
|
||||
* @since [v4.1.10]
|
||||
* @param $fieldsetId
|
||||
* @return string JSON
|
||||
*/
|
||||
public function fields($id)
|
||||
{
|
||||
$this->authorize('view', CustomFieldset::class);
|
||||
$set = CustomFieldset::findOrFail($id);
|
||||
$fields = $set->fields->get();
|
||||
return (new CustomFieldsTransformer)->transformCustomFields($fields, $fields->count());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -122,7 +122,6 @@ class DepartmentsController extends Controller
|
||||
*/
|
||||
public function selectlist(Request $request)
|
||||
{
|
||||
$this->authorize('view', Department::class);
|
||||
|
||||
$departments = Department::select([
|
||||
'id',
|
||||
|
||||
@@ -20,7 +20,7 @@ class GroupsController extends Controller
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->authorize('view', Group::class);
|
||||
$allowed_columns = ['id','name','created_at'];
|
||||
$allowed_columns = ['id','name','created_at', 'users_count'];
|
||||
|
||||
$groups = Group::select('id','name','permissions','created_at','updated_at')->withCount('users');
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ namespace App\Http\Controllers\Api;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Transformers\LicensesTransformer;
|
||||
use App\Http\Transformers\LicenseSeatsTransformer;
|
||||
use App\Models\License;
|
||||
use App\Models\LicenseSeat;
|
||||
use App\Models\Company;
|
||||
|
||||
class LicensesController extends Controller
|
||||
@@ -21,11 +23,8 @@ class LicensesController extends Controller
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->authorize('view', License::class);
|
||||
$licenses = Company::scopeCompanyables(License::with('company', 'licenseSeatsRelation', 'manufacturer', 'supplier'));
|
||||
$licenses = Company::scopeCompanyables(License::with('company', 'manufacturer', 'freeSeats', 'supplier')->withCount('freeSeats'));
|
||||
|
||||
if ($request->has('search')) {
|
||||
$licenses = $licenses->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
if ($request->has('company_id')) {
|
||||
$licenses->where('company_id','=',$request->input('company_id'));
|
||||
@@ -71,30 +70,38 @@ class LicensesController extends Controller
|
||||
$licenses->where('supplier_id','=',$request->input('supplier_id'));
|
||||
}
|
||||
|
||||
|
||||
if ($request->has('search')) {
|
||||
$licenses = $licenses->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
|
||||
switch ($request->input('sort')) {
|
||||
case 'manufacturer':
|
||||
$licenses = $licenses->OrderManufacturer($order);
|
||||
case 'manufacturer':
|
||||
$licenses = $licenses->leftJoin('manufacturers', 'licenses.manufacturer_id', '=', 'manufacturers.id')->orderBy('manufacturers.name', $order);
|
||||
break;
|
||||
case 'supplier':
|
||||
$licenses = $licenses->OrderSupplier($order);
|
||||
$licenses = $licenses->leftJoin('suppliers', 'licenses.supplier_id', '=', 'suppliers.id')->orderBy('suppliers.name', $order);
|
||||
break;
|
||||
case 'company':
|
||||
$licenses = $licenses->OrderCompany($order);
|
||||
$licenses = $licenses->leftJoin('companies', 'licenses.company_id', '=', 'companies.id')->orderBy('companies.name', $order);
|
||||
break;
|
||||
default:
|
||||
$allowed_columns = ['id','name','purchase_cost','expiration_date','purchase_order','order_number','notes','purchase_date','serial','company','license_name','license_email'];
|
||||
$allowed_columns = ['id','name','purchase_cost','expiration_date','purchase_order','order_number','notes','purchase_date','serial','company','license_name','license_email','free_seats_count','seats'];
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
|
||||
$licenses = $licenses->orderBy($sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$total = $licenses->count();
|
||||
|
||||
$licenses = $licenses->skip($offset)->take($limit)->get();
|
||||
return (new LicensesTransformer)->transformLicenses($licenses, $total);
|
||||
|
||||
@@ -161,4 +168,38 @@ class LicensesController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get license seat listing
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $licenseId
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function seats(Request $request, $licenseId)
|
||||
{
|
||||
|
||||
if ($license = License::find($licenseId)) {
|
||||
|
||||
$seats = LicenseSeat::where('license_id', $licenseId)->with('license', 'user', 'asset');
|
||||
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
$total = $seats->count();
|
||||
$seats = $seats->skip($offset)->take($limit)->get();
|
||||
|
||||
if ($seats) {
|
||||
return (new LicenseSeatsTransformer)->transformLicenseSeats($seats, $total);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/licenses/message.does_not_exist')), 200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class LocationsController extends Controller
|
||||
$allowed_columns = [
|
||||
'id','name','address','address2','city','state','country','zip','created_at',
|
||||
'updated_at','parent_id', 'manager_id','image',
|
||||
'rtd_assets_count','users_count','assets_count'];
|
||||
'assigned_assets_count','users_count','assets_count','currency'];
|
||||
|
||||
$locations = Location::with('parent', 'manager', 'childLocations')->select([
|
||||
'locations.id',
|
||||
@@ -41,7 +41,7 @@ class LocationsController extends Controller
|
||||
'locations.updated_at',
|
||||
'locations.image',
|
||||
'locations.currency'
|
||||
])->withCount('rtd_assets')
|
||||
])->withCount('assignedAssets')
|
||||
->withCount('assets')
|
||||
->withCount('users');
|
||||
|
||||
@@ -152,7 +152,6 @@ class LocationsController extends Controller
|
||||
*/
|
||||
public function selectlist(Request $request)
|
||||
{
|
||||
$this->authorize('view', Location::class);
|
||||
|
||||
$locations = Location::select([
|
||||
'locations.id',
|
||||
|
||||
@@ -22,7 +22,7 @@ class ManufacturersController extends Controller
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->authorize('view', Manufacturer::class);
|
||||
$allowed_columns = ['id','name','url','support_url','support_email','support_phone','created_at','updated_at','image'];
|
||||
$allowed_columns = ['id','name','url','support_url','support_email','support_phone','created_at','updated_at','image', 'assets_count', 'consumables_count', 'components_count', 'licenses_count'];
|
||||
|
||||
$manufacturers = Manufacturer::select(
|
||||
array('id','name','url','support_url','support_email','support_phone','created_at','updated_at','image')
|
||||
@@ -132,7 +132,6 @@ class ManufacturersController extends Controller
|
||||
*/
|
||||
public function selectlist(Request $request)
|
||||
{
|
||||
$this->authorize('view', Manufacturers::class);
|
||||
|
||||
$manufacturers = Manufacturer::select([
|
||||
'id',
|
||||
|
||||
@@ -42,19 +42,21 @@ class ReportsController extends Controller
|
||||
|
||||
$allowed_columns = [
|
||||
'id',
|
||||
'created_at'
|
||||
'created_at',
|
||||
'target_id',
|
||||
'user_id',
|
||||
'action_type',
|
||||
'note'
|
||||
];
|
||||
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
$order = ($request->input('order') == 'asc') ? 'asc' : 'desc';
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
$total = $actionlogs->count();
|
||||
$actionlogs = $actionlogs->orderBy($sort, $order);
|
||||
$actionlogs = $actionlogs->skip($offset)->take($limit)->get();
|
||||
return (new ActionlogsTransformer)->transformActionlogs($actionlogs, $total);
|
||||
|
||||
$actionlogs = $actionlogs->orderBy($sort, $order)->skip($offset)->take($limit)->get();
|
||||
|
||||
return response()->json((new ActionlogsTransformer)->transformActionlogs($actionlogs, $total), 200, ['Content-Type' => 'application/json;charset=utf8'], JSON_UNESCAPED_UNICODE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,11 +108,11 @@ class SettingsController extends Controller
|
||||
if (!config('app.lock_passwords')) {
|
||||
try {
|
||||
Mail::send('emails.test', [], function ($m) {
|
||||
$m->to(config('mail.from.address'), config('mail.from.name'));
|
||||
$m->to(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.test_email'));
|
||||
});
|
||||
return response()->json(['message' => 'Mail sent to '.config('mail.from.address')], 200);
|
||||
return response()->json(['message' => 'Mail sent to '.config('mail.reply_to.address')], 200);
|
||||
} catch (Exception $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,6 @@ class SuppliersController extends Controller
|
||||
*/
|
||||
public function selectlist(Request $request)
|
||||
{
|
||||
$this->authorize('view', Supplier::class);
|
||||
|
||||
$suppliers = Supplier::select([
|
||||
'id',
|
||||
|
||||
@@ -58,21 +58,16 @@ class UsersController extends Controller
|
||||
$users = Company::scopeCompanyables($users);
|
||||
|
||||
|
||||
if ($request->has('search')) {
|
||||
$users = $users->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
|
||||
if (($request->has('deleted')) && ($request->input('deleted')=='true')) {
|
||||
$users = $users->GetDeleted();
|
||||
}
|
||||
|
||||
if ($request->has('company_id')) {
|
||||
$users = $users->where('company_id', '=', $request->input('company_id'));
|
||||
$users = $users->where('users.company_id', '=', $request->input('company_id'));
|
||||
}
|
||||
|
||||
if ($request->has('location_id')) {
|
||||
$users = $users->where('location_id', '=', $request->input('location_id'));
|
||||
$users = $users->where('users.location_id', '=', $request->input('location_id'));
|
||||
}
|
||||
|
||||
if ($request->has('group_id')) {
|
||||
@@ -80,7 +75,11 @@ class UsersController extends Controller
|
||||
}
|
||||
|
||||
if ($request->has('department_id')) {
|
||||
$users = $users->where('department_id','=',$request->input('department_id'));
|
||||
$users = $users->where('users.department_id','=',$request->input('department_id'));
|
||||
}
|
||||
|
||||
if ($request->has('search')) {
|
||||
$users = $users->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
@@ -111,6 +110,8 @@ class UsersController extends Controller
|
||||
$users = $users->orderBy($sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$total = $users->count();
|
||||
$users = $users->skip($offset)->take($limit)->get();
|
||||
return (new UsersTransformer)->transformUsers($users, $total);
|
||||
@@ -127,11 +128,11 @@ class UsersController extends Controller
|
||||
*/
|
||||
public function selectlist(Request $request)
|
||||
{
|
||||
$this->authorize('view', User::class);
|
||||
|
||||
$users = User::select(
|
||||
[
|
||||
'users.id',
|
||||
'users.username',
|
||||
'users.employee_num',
|
||||
'users.first_name',
|
||||
'users.last_name',
|
||||
@@ -160,8 +161,12 @@ class UsersController extends Controller
|
||||
}
|
||||
$name_str .= e($user->first_name);
|
||||
|
||||
if ($user->username!='') {
|
||||
$name_str .= ' ('.e($user->username).')';
|
||||
}
|
||||
|
||||
if ($user->employee_num!='') {
|
||||
$name_str .= ' (#'.e($user->employee_num).')';
|
||||
$name_str .= ' - #'.e($user->employee_num);
|
||||
}
|
||||
|
||||
$user->use_text = $name_str;
|
||||
@@ -225,6 +230,10 @@ class UsersController extends Controller
|
||||
$user = User::findOrFail($id);
|
||||
$user->fill($request->all());
|
||||
|
||||
if ($user->id == $request->input('manager_id')) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, 'You cannot be your own manager'));
|
||||
}
|
||||
|
||||
if ($request->has('password')) {
|
||||
$user->password = bcrypt($request->input('password'));
|
||||
}
|
||||
|
||||
@@ -63,85 +63,6 @@ class AssetMaintenancesController extends Controller
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates the JSON response for asset maintenances listing view.
|
||||
*
|
||||
* @see AssetMaintenancesController::getIndex() method that generates view
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
* @since [v1.8]
|
||||
* @return String JSON
|
||||
*/
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
$maintenances = AssetMaintenance::with('asset', 'supplier', 'asset.company', 'admin');
|
||||
|
||||
if (Input::has('search')) {
|
||||
$maintenances = $maintenances->TextSearch(e($request->input('search')));
|
||||
}
|
||||
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
|
||||
$allowed_columns = ['id','title','asset_maintenance_time','asset_maintenance_type','cost','start_date','completion_date','notes','user_id'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
|
||||
|
||||
switch ($sort) {
|
||||
case 'user_id':
|
||||
$maintenances = $maintenances->OrderAdmin($order);
|
||||
break;
|
||||
default:
|
||||
$maintenances = $maintenances->orderBy($sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
$maintenancesCount = $maintenances->count();
|
||||
$maintenances = $maintenances->skip($offset)->take($limit)->get();
|
||||
|
||||
$rows = array();
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
foreach ($maintenances as $maintenance) {
|
||||
$actions = '';
|
||||
if (Gate::allows('update', Asset::class)) {
|
||||
$actions .= Helper::generateDatatableButton('edit', route('maintenances.edit', $maintenance->id));
|
||||
$actions .= Helper::generateDatatableButton(
|
||||
'delete',
|
||||
route('maintenances.destroy', $maintenance->id),
|
||||
$enabled = true,
|
||||
trans('admin/asset_maintenances/message.delete.confirm'),
|
||||
$maintenance->title
|
||||
);
|
||||
}
|
||||
|
||||
if (($maintenance->cost) && (isset($maintenance->asset)) && ($maintenance->asset->location) && ($maintenance->asset->location->currency!='')) {
|
||||
$maintenance_cost = $maintenance->asset->location->currency.$maintenance->cost;
|
||||
} else {
|
||||
$maintenance_cost = $settings->default_currency.$maintenance->cost;
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $maintenance->id,
|
||||
'asset_name' => ($maintenance->asset) ? (string)link_to_route('maintenances.show', $maintenance->asset->present()->Name(), ['maintenance' => $maintenance->asset->id]) : 'Deleted Asset' ,
|
||||
'title' => $maintenance->title,
|
||||
'notes' => $maintenance->notes,
|
||||
'supplier' => ($maintenance->supplier) ? (string)link_to_route('suppliers.show', $maintenance->supplier->name, ['maintenance'=>$maintenance->supplier->id]) : 'Deleted Supplier',
|
||||
'cost' => $maintenance_cost,
|
||||
'asset_maintenance_type' => e($maintenance->asset_maintenance_type),
|
||||
'start_date' => $maintenance->start_date,
|
||||
'asset_maintenance_time' => $maintenance->asset_maintenance_time,
|
||||
'completion_date' => $maintenance->completion_date,
|
||||
'user_id' => ($maintenance->admin) ? (string)link_to_route('users.show', $maintenance->admin->present()->fullName(), ['user'=>$maintenance->admin->id]) : '',
|
||||
'actions' => $actions,
|
||||
'company' => ($maintenance->asset->company) ? $maintenance->asset->company->name : ''
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $maintenancesCount, 'rows' => $rows);
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a form view to create a new asset maintenance.
|
||||
@@ -154,16 +75,21 @@ class AssetMaintenancesController extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$asset = null;
|
||||
|
||||
if ($asset = Asset::find(request('asset_id'))) {
|
||||
// We have to set this so that the correct property is set in the select2 ajax dropdown
|
||||
$asset->asset_id = $asset->id;
|
||||
}
|
||||
|
||||
// Prepare Asset Maintenance Type List
|
||||
$assetMaintenanceType = [
|
||||
'' => 'Select an asset maintenance type',
|
||||
] + AssetMaintenance::getImprovementOptions();
|
||||
// Mark the selected asset, if it came in
|
||||
// Render the view
|
||||
|
||||
return view('asset_maintenances/edit')
|
||||
->with('asset_list', Helper::detailedAssetList())
|
||||
->with('selectedAsset', request('asset_id'))
|
||||
->with('supplier_list', Helper::suppliersList())
|
||||
->with('asset', $asset)
|
||||
->with('assetMaintenanceType', $assetMaintenanceType)
|
||||
->with('item', new AssetMaintenance);
|
||||
}
|
||||
@@ -260,9 +186,7 @@ class AssetMaintenancesController extends Controller
|
||||
// Get Supplier List
|
||||
// Render the view
|
||||
return view('asset_maintenances/edit')
|
||||
->with('asset_list', Helper::detailedAssetList())
|
||||
->with('selectedAsset', null)
|
||||
->with('supplier_list', Helper::suppliersList())
|
||||
->with('assetMaintenanceType', $assetMaintenanceType)
|
||||
->with('item', $assetMaintenance);
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ class AssetModelsController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->authorize('index', AssetModel::class);
|
||||
return view('models/index');
|
||||
}
|
||||
|
||||
@@ -52,6 +53,7 @@ class AssetModelsController extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$this->authorize('create', AssetModel::class);
|
||||
$category_type = 'asset';
|
||||
return view('models/edit')->with('category_type',$category_type)
|
||||
->with('depreciation_list', Helper::depreciationList())
|
||||
@@ -69,6 +71,7 @@ class AssetModelsController extends Controller
|
||||
public function store(ImageUploadRequest $request)
|
||||
{
|
||||
|
||||
$this->authorize('create', AssetModel::class);
|
||||
// Create a new asset model
|
||||
$model = new AssetModel;
|
||||
|
||||
@@ -91,7 +94,7 @@ class AssetModelsController extends Controller
|
||||
|
||||
$image = Input::file('image');
|
||||
$file_name = str_slug($image->getClientOriginalName()) . "." . $image->getClientOriginalExtension();
|
||||
$path = public_path('uploads/models/');
|
||||
$path = app('models_upload_path');
|
||||
|
||||
if ($image->getClientOriginalExtension()!='svg') {
|
||||
Image::make($image->getRealPath())->resize(500, null, function ($constraint) {
|
||||
@@ -124,7 +127,8 @@ class AssetModelsController extends Controller
|
||||
*/
|
||||
public function apiStore(Request $request)
|
||||
{
|
||||
//COPYPASTA!!!! FIXME
|
||||
//COPYPASTA!!!! FIXME
|
||||
$this->authorize('create', AssetModel::class);
|
||||
$model = new AssetModel;
|
||||
|
||||
$settings=Input::all();
|
||||
@@ -162,6 +166,7 @@ class AssetModelsController extends Controller
|
||||
*/
|
||||
public function edit($modelId = null)
|
||||
{
|
||||
$this->authorize('edit', AssetModel::class);
|
||||
if ($item = AssetModel::find($modelId)) {
|
||||
$category_type = 'asset';
|
||||
$view = View::make('models/edit', compact('item','category_type'));
|
||||
@@ -185,21 +190,21 @@ class AssetModelsController extends Controller
|
||||
*/
|
||||
public function update(ImageUploadRequest $request, $modelId = null)
|
||||
{
|
||||
$this->authorize('edit', AssetModel::class);
|
||||
// Check if the model exists
|
||||
if (is_null($model = AssetModel::find($modelId))) {
|
||||
// Redirect to the models management page
|
||||
return redirect()->route('models.index')->with('error', trans('admin/models/message.does_not_exist'));
|
||||
}
|
||||
|
||||
$model->depreciation_id = $request->input('depreciation_id');
|
||||
$model->eol = $request->input('eol');
|
||||
$model->depreciation_id = $request->input('depreciation_id');
|
||||
$model->eol = $request->input('eol');
|
||||
$model->name = $request->input('name');
|
||||
$model->model_number = $request->input('model_number');
|
||||
$model->manufacturer_id = $request->input('manufacturer_id');
|
||||
$model->category_id = $request->input('category_id');
|
||||
$model->notes = $request->input('notes');
|
||||
|
||||
$model->requestable = Input::has('requestable');
|
||||
$model->requestable = $request->input('requestable', '0');
|
||||
|
||||
if ($request->input('custom_fieldset')=='') {
|
||||
$model->fieldset_id = null;
|
||||
@@ -207,35 +212,38 @@ class AssetModelsController extends Controller
|
||||
$model->fieldset_id = $request->input('custom_fieldset');
|
||||
}
|
||||
|
||||
if (Input::file('image')) {
|
||||
$old_image = $model->image;
|
||||
|
||||
$image = Input::file('image');
|
||||
$file_name = str_slug($image->getClientOriginalName()) . "." . $image->getClientOriginalExtension();
|
||||
$path = public_path('uploads/models/');
|
||||
$old_image = $path.$model->image;
|
||||
// Set the model's image property to null if the image is being deleted
|
||||
if ($request->input('image_delete') == 1) {
|
||||
$model->image = null;
|
||||
}
|
||||
|
||||
try {
|
||||
unlink($old_image);
|
||||
} catch (\Exception $e) {
|
||||
\Log::error($e);
|
||||
}
|
||||
if ($request->file('image')) {
|
||||
$image = $request->file('image');
|
||||
$file_name = $model->id.'-'.str_slug($image->getClientOriginalName()) . "." . $image->getClientOriginalExtension();
|
||||
|
||||
if ($image->getClientOriginalExtension()!='svg') {
|
||||
Image::make($image->getRealPath())->resize(500, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save($path.'/'.$file_name);
|
||||
})->save(app('models_upload_path').$file_name);
|
||||
} else {
|
||||
$image->move($path, $file_name);
|
||||
$image->move(app('models_upload_path'), $file_name);
|
||||
}
|
||||
$model->image = $file_name;
|
||||
|
||||
}
|
||||
|
||||
if ($request->input('image_delete') == 1 && Input::file('image') == "") {
|
||||
$model->image = null;
|
||||
if ((($request->file('image')) && (isset($old_image)) && ($old_image!='')) || ($request->input('image_delete') == 1)) {
|
||||
try {
|
||||
unlink(app('models_upload_path').$old_image);
|
||||
} catch (\Exception $e) {
|
||||
\Log::error($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($model->save()) {
|
||||
return redirect()->route("models.index")->with('success', trans('admin/models/message.update.success'));
|
||||
}
|
||||
@@ -253,6 +261,7 @@ class AssetModelsController extends Controller
|
||||
*/
|
||||
public function destroy($modelId)
|
||||
{
|
||||
$this->authorize('delete', AssetModel::class);
|
||||
// Check if the model exists
|
||||
if (is_null($model = AssetModel::find($modelId))) {
|
||||
return redirect()->route('models.index')->with('error', trans('admin/models/message.not_found'));
|
||||
@@ -289,7 +298,7 @@ class AssetModelsController extends Controller
|
||||
*/
|
||||
public function getRestore($modelId = null)
|
||||
{
|
||||
|
||||
$this->authorize('create', AssetModel::class);
|
||||
// Get user information
|
||||
$model = AssetModel::withTrashed()->find($modelId);
|
||||
|
||||
@@ -320,6 +329,7 @@ class AssetModelsController extends Controller
|
||||
*/
|
||||
public function show($modelId = null)
|
||||
{
|
||||
$this->authorize('view', AssetModel::class);
|
||||
$model = AssetModel::withTrashed()->find($modelId);
|
||||
|
||||
if (isset($model->id)) {
|
||||
@@ -391,20 +401,39 @@ class AssetModelsController extends Controller
|
||||
|
||||
$models_raw_array = Input::get('ids');
|
||||
|
||||
if (is_array($models_raw_array)) {
|
||||
$models = AssetModel::whereIn('id', $models_raw_array)->get();
|
||||
$nochange = ['NC' => 'No Change'];
|
||||
$fieldset_list = $nochange + Helper::customFieldsetList();
|
||||
$depreciation_list = $nochange + Helper::depreciationList();
|
||||
$category_list = $nochange + Helper::categoryList('asset');
|
||||
$manufacturer_list = $nochange + Helper::manufacturerList();
|
||||
// Make sure some IDs have been selected
|
||||
if ((is_array($models_raw_array)) && (count($models_raw_array) > 0)) {
|
||||
|
||||
|
||||
$models = AssetModel::whereIn('id', $models_raw_array)->withCount('assets')->orderBy('assets_count', 'ASC')->get();
|
||||
|
||||
// If deleting....
|
||||
if ($request->input('bulk_actions')=='delete') {
|
||||
$valid_count = 0;
|
||||
foreach ($models as $model) {
|
||||
if ($model->assets_count == 0) {
|
||||
$valid_count++;
|
||||
}
|
||||
}
|
||||
return view('models/bulk-delete', compact('models'))->with('valid_count', $valid_count);
|
||||
|
||||
// Otherwise display the bulk edit screen
|
||||
} else {
|
||||
|
||||
$nochange = ['NC' => 'No Change'];
|
||||
$fieldset_list = $nochange + Helper::customFieldsetList();
|
||||
$depreciation_list = $nochange + Helper::depreciationList();
|
||||
$category_list = $nochange + Helper::categoryList('asset');
|
||||
$manufacturer_list = $nochange + Helper::manufacturerList();
|
||||
|
||||
|
||||
return view('models/bulk-edit', compact('models'))
|
||||
->with('manufacturer_list', $manufacturer_list)
|
||||
->with('category_list', $category_list)
|
||||
->with('fieldset_list', $fieldset_list)
|
||||
->with('depreciation_list', $depreciation_list);
|
||||
}
|
||||
|
||||
|
||||
return view('models/bulk-edit', compact('models'))
|
||||
->with('manufacturer_list', $manufacturer_list)
|
||||
->with('category_list', $category_list)
|
||||
->with('fieldset_list', $fieldset_list)
|
||||
->with('depreciation_list', $depreciation_list);
|
||||
}
|
||||
|
||||
return redirect()->route('models.index')
|
||||
@@ -427,6 +456,7 @@ class AssetModelsController extends Controller
|
||||
$models_raw_array = Input::get('ids');
|
||||
$update_array = array();
|
||||
|
||||
|
||||
if (($request->has('manufacturer_id') && ($request->input('manufacturer_id')!='NC'))) {
|
||||
$update_array['manufacturer_id'] = $request->input('manufacturer_id');
|
||||
}
|
||||
@@ -453,4 +483,52 @@ class AssetModelsController extends Controller
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and delete the given Asset Models. An Asset Model
|
||||
* cannot be deleted if there are associated assets.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $modelId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postBulkDelete(Request $request)
|
||||
{
|
||||
$models_raw_array = Input::get('ids');
|
||||
|
||||
if ((is_array($models_raw_array)) && (count($models_raw_array) > 0)) {
|
||||
|
||||
$models = AssetModel::whereIn('id', $models_raw_array)->withCount('assets')->get();
|
||||
|
||||
$del_error_count = 0;
|
||||
$del_count = 0;
|
||||
|
||||
foreach ($models as $model) {
|
||||
\Log::debug($model->id);
|
||||
|
||||
if ($model->assets_count > 0) {
|
||||
$del_error_count++;
|
||||
} else {
|
||||
$model->delete();
|
||||
$del_count++;
|
||||
}
|
||||
}
|
||||
|
||||
\Log::debug($del_count);
|
||||
\Log::debug($del_error_count);
|
||||
|
||||
if ($del_error_count == 0) {
|
||||
return redirect()->route('models.index')
|
||||
->with('success', trans('admin/models/message.bulkdelete.success',['success_count'=> $del_count] ));
|
||||
}
|
||||
|
||||
return redirect()->route('models.index')
|
||||
->with('warning', trans('admin/models/message.bulkdelete.success_partial', ['fail_count'=>$del_error_count, 'success_count'=> $del_count]));
|
||||
}
|
||||
|
||||
return redirect()->route('models.index')
|
||||
->with('error', trans('admin/models/message.bulkdelete.error'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -160,6 +160,10 @@ class AssetsController extends Controller
|
||||
$asset->requestable = request('requestable', 0);
|
||||
$asset->rtd_location_id = request('rtd_location_id', null);
|
||||
|
||||
if ($asset->assigned_to=='') {
|
||||
$asset->location_id = $request->input('rtd_location_id', null);
|
||||
}
|
||||
|
||||
// Create the image (if one was chosen.)
|
||||
if ($request->has('image')) {
|
||||
$image = $request->input('image');
|
||||
@@ -199,8 +203,6 @@ class AssetsController extends Controller
|
||||
|
||||
// Update custom fields in the database.
|
||||
// Validation for these fields is handled through the AssetRequest form request
|
||||
// FIXME: No idea why this is returning a Builder error on db_column_name.
|
||||
// Need to investigate and fix. Using static method for now.
|
||||
$model = AssetModel::find($request->get('model_id'));
|
||||
|
||||
if ($model->fieldset) {
|
||||
@@ -217,16 +219,21 @@ class AssetsController extends Controller
|
||||
|
||||
// Was the asset created?
|
||||
if ($asset->save()) {
|
||||
$asset->logCreate();
|
||||
|
||||
|
||||
if (request('assigned_user')) {
|
||||
$target = User::find(request('assigned_user'));
|
||||
$location = $target->location_id;
|
||||
} elseif (request('assigned_asset')) {
|
||||
$target = Asset::find(request('assigned_asset'));
|
||||
$location = $target->location_id;
|
||||
} elseif (request('assigned_location')) {
|
||||
$target = Location::find(request('assigned_location'));
|
||||
$location = $target->id;
|
||||
}
|
||||
|
||||
if (isset($target)) {
|
||||
$asset->checkOut($target, Auth::user(), date('Y-m-d H:i:s'), '', 'Checked out on asset creation', e(Input::get('name')));
|
||||
$asset->checkOut($target, Auth::user(), date('Y-m-d H:i:s'), '', 'Checked out on asset creation', e(Input::get('name')), $location);
|
||||
}
|
||||
// Redirect to the asset listing page
|
||||
\Session::flash('success', trans('admin/hardware/message.create.success'));
|
||||
@@ -289,6 +296,11 @@ class AssetsController extends Controller
|
||||
$asset->requestable = $request->has('requestable');
|
||||
$asset->rtd_location_id = $request->input('rtd_location_id', null);
|
||||
|
||||
if ($asset->assigned_to=='') {
|
||||
$asset->location_id = $request->input('rtd_location_id', null);
|
||||
}
|
||||
|
||||
|
||||
if ($request->has('image_delete')) {
|
||||
unlink(public_path().'/uploads/assets/'.$asset->image);
|
||||
$asset->image = '';
|
||||
@@ -390,13 +402,6 @@ class AssetsController extends Controller
|
||||
|
||||
$asset->delete();
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->item_type = Asset::class;
|
||||
$logaction->item_id = $asset->id;
|
||||
$logaction->created_at = date("Y-m-d H:i:s");
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->logaction('deleted');
|
||||
|
||||
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.delete.success'));
|
||||
}
|
||||
|
||||
@@ -419,8 +424,13 @@ class AssetsController extends Controller
|
||||
|
||||
$this->authorize('checkout', $asset);
|
||||
|
||||
if ($asset->availableForCheckout()) {
|
||||
return view('hardware/checkout', compact('asset'));
|
||||
}
|
||||
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkout.not_available'));
|
||||
|
||||
// Get the dropdown of users and then pass it to the checkout view
|
||||
return view('hardware/checkout', compact('asset'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -441,17 +451,34 @@ class AssetsController extends Controller
|
||||
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkout.not_available'));
|
||||
}
|
||||
$this->authorize('checkout', $asset);
|
||||
|
||||
if (request('assigned_user')) {
|
||||
$target = User::find(request('assigned_user'));
|
||||
} elseif (request('assigned_asset')) {
|
||||
$target = Asset::where('id','!=',$assetId)->find(request('assigned_asset'));
|
||||
} elseif (request('assigned_location')) {
|
||||
$target = Location::find(request('assigned_location'));
|
||||
}
|
||||
// $user = User::find(Input::get('assigned_to'));
|
||||
$admin = Auth::user();
|
||||
|
||||
|
||||
// This item is checked out to a location
|
||||
if (request('checkout_to_type')=='location') {
|
||||
$target = Location::find(request('assigned_location'));
|
||||
$asset->location_id = ($target) ? $target->id : '';
|
||||
|
||||
} elseif (request('checkout_to_type')=='asset') {
|
||||
$target = Asset::where('id','!=',$assetId)->find(request('assigned_asset'));
|
||||
$asset->location_id = $target->rtd_location_id;
|
||||
// Override with the asset's location_id if it has one
|
||||
if ($target->location_id!='') {
|
||||
$asset->location_id = ($target) ? $target->location_id : '';
|
||||
}
|
||||
|
||||
} elseif (request('checkout_to_type')=='user') {
|
||||
// Fetch the target and set the asset's new location_id
|
||||
$target = User::find(request('assigned_user'));
|
||||
$asset->location_id = ($target) ? $target->location_id : '';
|
||||
}
|
||||
|
||||
// No valid target was found - error out
|
||||
if (!$target) {
|
||||
return redirect()->back()->with('error', trans('admin/hardware/message.checkout.error'))->withErrors($asset->getErrors());
|
||||
}
|
||||
|
||||
|
||||
if ((Input::has('checkout_at')) && (Input::get('checkout_at')!= date("Y-m-d"))) {
|
||||
$checkout_at = Input::get('checkout_at');
|
||||
} else {
|
||||
@@ -464,22 +491,12 @@ class AssetsController extends Controller
|
||||
$expected_checkin = '';
|
||||
}
|
||||
|
||||
// Set the location ID to the RTD location id if there is one
|
||||
if ($asset->rtd_location_id!='') {
|
||||
$asset->location_id = $target->rtd_location_id;
|
||||
}
|
||||
|
||||
// Overwrite that if the target has a location ID though
|
||||
if ($target->location_id!='') {
|
||||
$asset->location_id = $target->location_id;
|
||||
}
|
||||
|
||||
if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e(Input::get('note')), Input::get('name'))) {
|
||||
// Redirect to the new asset page
|
||||
return redirect()->route("hardware.index")->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
}
|
||||
|
||||
// Redirect to the asset management page with error
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->to("hardware/$assetId/checkout")->with('error', trans('admin/hardware/message.checkout.error'))->withErrors($asset->getErrors());
|
||||
}
|
||||
|
||||
@@ -546,6 +563,8 @@ class AssetsController extends Controller
|
||||
$asset->status_id = e(Input::get('status_id'));
|
||||
}
|
||||
|
||||
$asset->location_id = $asset->rtd_location_id;
|
||||
|
||||
if (Input::has('location_id')) {
|
||||
$asset->location_id = e(Input::get('location_id'));
|
||||
}
|
||||
@@ -556,6 +575,7 @@ class AssetsController extends Controller
|
||||
|
||||
$data['log_id'] = $logaction->id;
|
||||
$data['first_name'] = get_class($target) == User::class ? $target->first_name : '';
|
||||
$data['last_name'] = get_class($target) == User::class ? $target->last_name : '';
|
||||
$data['item_name'] = $asset->present()->name();
|
||||
$data['checkin_date'] = $logaction->created_at;
|
||||
$data['item_tag'] = $asset->asset_tag;
|
||||
@@ -643,20 +663,23 @@ class AssetsController extends Controller
|
||||
|
||||
if ($settings->qr_code == '1') {
|
||||
$asset = Asset::withTrashed()->find($assetId);
|
||||
$size = Helper::barcodeDimensions($settings->barcode_type);
|
||||
$qr_file = public_path().'/uploads/barcodes/qr-'.str_slug($asset->asset_tag).'-'.str_slug($asset->id).'.png';
|
||||
if ($asset) {
|
||||
$size = Helper::barcodeDimensions($settings->barcode_type);
|
||||
$qr_file = public_path().'/uploads/barcodes/qr-'.str_slug($asset->asset_tag).'-'.str_slug($asset->id).'.png';
|
||||
|
||||
if (isset($asset->id, $asset->asset_tag)) {
|
||||
if (file_exists($qr_file)) {
|
||||
$header = ['Content-type' => 'image/png'];
|
||||
return response()->file($qr_file, $header);
|
||||
} else {
|
||||
$barcode = new \Com\Tecnick\Barcode\Barcode();
|
||||
$barcode_obj = $barcode->getBarcodeObj($settings->barcode_type, route('hardware.show', $asset->id), $size['height'], $size['width'], 'black', array(-2, -2, -2, -2));
|
||||
file_put_contents($qr_file, $barcode_obj->getPngData());
|
||||
return response($barcode_obj->getPngData())->header('Content-type', 'image/png');
|
||||
if (isset($asset->id, $asset->asset_tag)) {
|
||||
if (file_exists($qr_file)) {
|
||||
$header = ['Content-type' => 'image/png'];
|
||||
return response()->file($qr_file, $header);
|
||||
} else {
|
||||
$barcode = new \Com\Tecnick\Barcode\Barcode();
|
||||
$barcode_obj = $barcode->getBarcodeObj($settings->barcode_type, route('hardware.show', $asset->id), $size['height'], $size['width'], 'black', array(-2, -2, -2, -2));
|
||||
file_put_contents($qr_file, $barcode_obj->getPngData());
|
||||
return response($barcode_obj->getPngData())->header('Content-type', 'image/png');
|
||||
}
|
||||
}
|
||||
}
|
||||
return 'That asset is invalid';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -890,6 +913,14 @@ class AssetsController extends Controller
|
||||
if (isset($asset->id)) {
|
||||
// Restore the asset
|
||||
Asset::withTrashed()->where('id', $assetId)->restore();
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->item_type = Asset::class;
|
||||
$logaction->item_id = $asset->id;
|
||||
$logaction->created_at = date("Y-m-d H:i:s");
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->logaction('restored');
|
||||
|
||||
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.restore.success'));
|
||||
}
|
||||
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||
@@ -916,8 +947,8 @@ class AssetsController extends Controller
|
||||
|
||||
$destinationPath = config('app.private_uploads').'/assets';
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
foreach ($request->file('image') as $file) {
|
||||
if ($request->hasFile('assetfile')) {
|
||||
foreach ($request->file('assetfile') as $file) {
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
$filename = 'hardware-'.$asset->id.'-'.str_random(8);
|
||||
$filename .= '-'.str_slug($file->getClientOriginalName()).'.'.$extension;
|
||||
@@ -1052,70 +1083,81 @@ class AssetsController extends Controller
|
||||
* @internal param array $assets
|
||||
* @since [v2.0]
|
||||
*/
|
||||
public function postBulkSave()
|
||||
public function postBulkSave(Request $request)
|
||||
{
|
||||
$this->authorize('update', Asset::class);
|
||||
if (Input::has('ids')) {
|
||||
$assets = Input::get('ids');
|
||||
if ((Input::has('purchase_date'))
|
||||
|| (Input::has('purchase_cost'))
|
||||
|| (Input::has('supplier_id'))
|
||||
|| (Input::has('order_number'))
|
||||
|| (Input::has('warranty_months'))
|
||||
|| (Input::has('rtd_location_id'))
|
||||
|| (Input::has('requestable'))
|
||||
|| (Input::has('company_id'))
|
||||
|| (Input::has('status_id'))
|
||||
|| (Input::has('model_id'))
|
||||
|
||||
\Log::debug($request->input('ids'));
|
||||
|
||||
if (($request->has('ids')) && (count($request->input('ids')) > 0)) {
|
||||
$assets = $request->input('ids');
|
||||
if (($request->has('purchase_date'))
|
||||
|| ($request->has('purchase_cost'))
|
||||
|| ($request->has('supplier_id'))
|
||||
|| ($request->has('order_number'))
|
||||
|| ($request->has('warranty_months'))
|
||||
|| ($request->has('rtd_location_id'))
|
||||
|| ($request->has('requestable'))
|
||||
|| ($request->has('company_id'))
|
||||
|| ($request->has('status_id'))
|
||||
|| ($request->has('model_id'))
|
||||
) {
|
||||
foreach ($assets as $key => $value) {
|
||||
$update_array = array();
|
||||
|
||||
if (Input::has('purchase_date')) {
|
||||
$update_array['purchase_date'] = e(Input::get('purchase_date'));
|
||||
if ($request->has('purchase_date')) {
|
||||
$update_array['purchase_date'] = $request->input('purchase_date');
|
||||
}
|
||||
if (Input::has('purchase_cost')) {
|
||||
$update_array['purchase_cost'] = Helper::ParseFloat(e(Input::get('purchase_cost')));
|
||||
if ($request->has('purchase_cost')) {
|
||||
$update_array['purchase_cost'] = Helper::ParseFloat($request->input('purchase_cost'));
|
||||
}
|
||||
if (Input::has('supplier_id')) {
|
||||
$update_array['supplier_id'] = e(Input::get('supplier_id'));
|
||||
if ($request->has('supplier_id')) {
|
||||
$update_array['supplier_id'] = $request->input('supplier_id');
|
||||
}
|
||||
if (Input::has('model_id')) {
|
||||
$update_array['model_id'] = e(Input::get('model_id'));
|
||||
if ($request->has('model_id')) {
|
||||
$update_array['model_id'] = $request->input('model_id');
|
||||
}
|
||||
if (Input::has('company_id')) {
|
||||
if (Input::get('company_id')=="clear") {
|
||||
if ($request->has('company_id')) {
|
||||
if ($request->input('company_id')=="clear") {
|
||||
$update_array['company_id'] = null;
|
||||
} else {
|
||||
$update_array['company_id'] = e(Input::get('company_id'));
|
||||
$update_array['company_id'] = $request->input('company_id');
|
||||
}
|
||||
}
|
||||
if (Input::has('order_number')) {
|
||||
$update_array['order_number'] = e(Input::get('order_number'));
|
||||
if ($request->has('order_number')) {
|
||||
$update_array['order_number'] = $request->input('order_number');
|
||||
}
|
||||
if (Input::has('warranty_months')) {
|
||||
$update_array['warranty_months'] = e(Input::get('warranty_months'));
|
||||
if ($request->has('warranty_months')) {
|
||||
$update_array['warranty_months'] = $request->input('warranty_months');
|
||||
}
|
||||
if (Input::has('rtd_location_id')) {
|
||||
$update_array['rtd_location_id'] = e(Input::get('rtd_location_id'));
|
||||
|
||||
|
||||
if ($request->has('rtd_location_id')) {
|
||||
$update_array['rtd_location_id'] = $request->input('rtd_location_id');
|
||||
if (($request->has('update_real_loc'))
|
||||
&& (($request->input('update_real_loc')) == '1'))
|
||||
{
|
||||
$update_array['location_id'] = $request->input('rtd_location_id');
|
||||
}
|
||||
}
|
||||
if (Input::has('status_id')) {
|
||||
$update_array['status_id'] = e(Input::get('status_id'));
|
||||
|
||||
if ($request->has('status_id')) {
|
||||
$update_array['status_id'] = $request->input('status_id');
|
||||
}
|
||||
if (Input::has('requestable')) {
|
||||
$update_array['requestable'] = e(Input::get('requestable'));
|
||||
if ($request->has('requestable')) {
|
||||
$update_array['requestable'] = $request->input('requestable');
|
||||
}
|
||||
|
||||
DB::table('assets')
|
||||
->where('id', $key)
|
||||
->update($update_array);
|
||||
} // endforeach
|
||||
return redirect()->to("hardware")->with('success', trans('admin/hardware/message.update.success'));
|
||||
return redirect()->route("hardware.index")->with('success', trans('admin/hardware/message.update.success'));
|
||||
// no values given, nothing to update
|
||||
}
|
||||
return redirect()->to("hardware")->with('info', trans('admin/hardware/message.update.nothing_updated'));
|
||||
return redirect()->route("hardware.index")->with('warning', trans('admin/hardware/message.update.nothing_updated'));
|
||||
} // endif
|
||||
return redirect()->to("hardware");
|
||||
return redirect()->route("hardware.index")->with('warning', trans('No assets selected, so nothing was updated.'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1165,9 +1207,14 @@ class AssetsController extends Controller
|
||||
$user = User::find(e(Input::get('assigned_to')));
|
||||
$admin = Auth::user();
|
||||
|
||||
if (!$user) {
|
||||
return redirect()->route('hardware/bulkcheckout')->withInput()->with('error', trans('admin/hardware/message.checkout.user_does_not_exist'));
|
||||
}
|
||||
|
||||
if (!is_array(Input::get('selected_assets'))) {
|
||||
return redirect()->route('hardware/bulkcheckout')->withInput()->with('error', trans('admin/hardware/message.checkout.no_assets_selected'));
|
||||
}
|
||||
|
||||
$asset_ids = array_filter(Input::get('selected_assets'));
|
||||
|
||||
if ((Input::has('checkout_at')) && (Input::get('checkout_at')!= date("Y-m-d"))) {
|
||||
@@ -1182,6 +1229,7 @@ class AssetsController extends Controller
|
||||
$expected_checkin = '';
|
||||
}
|
||||
|
||||
|
||||
$errors = [];
|
||||
DB::transaction(function () use ($user, $admin, $checkout_at, $expected_checkin, $errors, $asset_ids) {
|
||||
|
||||
@@ -1190,6 +1238,14 @@ class AssetsController extends Controller
|
||||
$this->authorize('checkout', $asset);
|
||||
$error = $asset->checkOut($user, $admin, $checkout_at, $expected_checkin, e(Input::get('note')), null);
|
||||
|
||||
if ($user->location_id!='') {
|
||||
$asset->location_id = $user->location_id;
|
||||
$asset->unsetEventDispatcher();
|
||||
$asset->save();
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ($error) {
|
||||
array_merge_recursive($errors, $asset->getErrors()->toArray());
|
||||
}
|
||||
@@ -1216,12 +1272,14 @@ class AssetsController extends Controller
|
||||
|
||||
public function audit($id)
|
||||
{
|
||||
$settings = Setting::getSettings();
|
||||
$this->authorize('audit', Asset::class);
|
||||
$dt = Carbon::now()->addMonths(12)->toDateString();
|
||||
$dt = Carbon::now()->addMonths($settings->audit_interval)->toDateString();
|
||||
$asset = Asset::findOrFail($id);
|
||||
return view('hardware/audit')->with('asset', $asset)->with('next_audit_date', $dt)->with('locations_list');
|
||||
}
|
||||
|
||||
|
||||
public function auditStore(Request $request, $id)
|
||||
{
|
||||
$this->authorize('audit', Asset::class);
|
||||
@@ -1237,7 +1295,11 @@ class AssetsController extends Controller
|
||||
}
|
||||
|
||||
$asset = Asset::findOrFail($id);
|
||||
// We don't want to log this as a normal update, so let's bypass that
|
||||
$asset->unsetEventDispatcher();
|
||||
|
||||
$asset->next_audit_date = $request->input('next_audit_date');
|
||||
$asset->last_audit_date = date('Y-m-d h:i:s');
|
||||
|
||||
if ($asset->save()) {
|
||||
$asset->logAudit(request('note'), request('location_id'));
|
||||
|
||||
@@ -12,4 +12,12 @@ class RegisterController extends Controller
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
public function showRegistrationForm() {
|
||||
abort(404,'Page not found');
|
||||
}
|
||||
|
||||
public function register() {
|
||||
abort(404,'Page not found');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ class CategoriesController extends Controller
|
||||
public function index()
|
||||
{
|
||||
// Show the page
|
||||
$this->authorize('view', Category::class);
|
||||
return view('categories/index');
|
||||
}
|
||||
|
||||
@@ -55,6 +56,7 @@ class CategoriesController extends Controller
|
||||
public function create()
|
||||
{
|
||||
// Show the page
|
||||
$this->authorize('create', Category::class);
|
||||
$category_types= Helper::categoryTypeList();
|
||||
return view('categories/edit')->with('item', new Category)
|
||||
->with('category_types', $category_types);
|
||||
@@ -71,9 +73,8 @@ class CategoriesController extends Controller
|
||||
*/
|
||||
public function store(ImageUploadRequest $request)
|
||||
{
|
||||
// create a new model instance
|
||||
$this->authorize('create', Category::class);
|
||||
$category = new Category();
|
||||
// Update the category data
|
||||
$category->name = $request->input('name');
|
||||
$category->category_type = $request->input('category_type');
|
||||
$category->eula_text = $request->input('eula_text');
|
||||
@@ -112,6 +113,7 @@ class CategoriesController extends Controller
|
||||
*/
|
||||
public function edit($categoryId = null)
|
||||
{
|
||||
$this->authorize('edit', Category::class);
|
||||
if (is_null($item = Category::find($categoryId))) {
|
||||
return redirect()->route('categories.index')->with('error', trans('admin/categories/message.does_not_exist'));
|
||||
}
|
||||
@@ -134,7 +136,7 @@ class CategoriesController extends Controller
|
||||
*/
|
||||
public function update(ImageUploadRequest $request, $categoryId = null)
|
||||
{
|
||||
// Check if the blog post exists
|
||||
$this->authorize('edit', Category::class);
|
||||
if (is_null($category = Category::find($categoryId))) {
|
||||
// Redirect to the categories management page
|
||||
return redirect()->to('admin/categories')->with('error', trans('admin/categories/message.does_not_exist'));
|
||||
@@ -150,17 +152,35 @@ class CategoriesController extends Controller
|
||||
$category->require_acceptance = $request->input('require_acceptance', '0');
|
||||
$category->checkin_email = $request->input('checkin_email', '0');
|
||||
|
||||
$old_image = $category->image;
|
||||
|
||||
// Set the model's image property to null if the image is being deleted
|
||||
if ($request->input('image_delete') == 1) {
|
||||
$category->image = null;
|
||||
}
|
||||
|
||||
if ($request->file('image')) {
|
||||
$image = $request->file('image');
|
||||
$file_name = str_random(25).".".$image->getClientOriginalExtension();
|
||||
$path = public_path('uploads/categories/'.$file_name);
|
||||
Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save($path);
|
||||
$file_name = $category->id.'-'.str_slug($image->getClientOriginalName()) . "." . $image->getClientOriginalExtension();
|
||||
|
||||
if ($image->getClientOriginalExtension()!='svg') {
|
||||
Image::make($image->getRealPath())->resize(500, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save(app('categories_upload_path').$file_name);
|
||||
} else {
|
||||
$image->move(app('categories_upload_path'), $file_name);
|
||||
}
|
||||
$category->image = $file_name;
|
||||
} elseif ($request->input('image_delete')=='1') {
|
||||
$category->image = null;
|
||||
|
||||
}
|
||||
|
||||
if ((($request->file('image')) && (isset($old_image)) && ($old_image!='')) || ($request->input('image_delete') == 1)) {
|
||||
try {
|
||||
unlink(app('categories_upload_path').$old_image);
|
||||
} catch (\Exception $e) {
|
||||
\Log::error($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -182,6 +202,7 @@ class CategoriesController extends Controller
|
||||
*/
|
||||
public function destroy($categoryId)
|
||||
{
|
||||
$this->authorize('delete', Category::class);
|
||||
// Check if the category exists
|
||||
if (is_null($category = Category::find($categoryId))) {
|
||||
return redirect()->route('categories.index')->with('error', trans('admin/categories/message.not_found'));
|
||||
@@ -215,6 +236,7 @@ class CategoriesController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$this->authorize('view', Category::class);
|
||||
if ($category = Category::find($id)) {
|
||||
|
||||
if ($category->category_type=='asset') {
|
||||
|
||||
@@ -110,17 +110,35 @@ final class CompaniesController extends Controller
|
||||
|
||||
$company->name = $request->input('name');
|
||||
|
||||
$old_image = $company->image;
|
||||
|
||||
// Set the model's image property to null if the image is being deleted
|
||||
if ($request->input('image_delete') == 1) {
|
||||
$company->image = null;
|
||||
}
|
||||
|
||||
if ($request->file('image')) {
|
||||
$image = $request->file('image');
|
||||
$file_name = str_random(25).".".$image->getClientOriginalExtension();
|
||||
$path = public_path('uploads/companies/'.$file_name);
|
||||
Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save($path);
|
||||
$file_name = $company->id.'-'.str_slug($image->getClientOriginalName()) . "." . $image->getClientOriginalExtension();
|
||||
|
||||
if ($image->getClientOriginalExtension()!='svg') {
|
||||
Image::make($image->getRealPath())->resize(500, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save(app('companies_upload_path').$file_name);
|
||||
} else {
|
||||
$image->move(app('companies_upload_path'), $file_name);
|
||||
}
|
||||
$company->image = $file_name;
|
||||
} elseif ($request->input('image_delete')=='1') {
|
||||
$company->image = null;
|
||||
|
||||
}
|
||||
|
||||
if ((($request->file('image')) && (isset($old_image)) && ($old_image!='')) || ($request->input('image_delete') == 1)) {
|
||||
try {
|
||||
unlink(app('companies_upload_path').$old_image);
|
||||
} catch (\Exception $e) {
|
||||
\Log::error($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Requests\ImageUploadRequest;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Company;
|
||||
use App\Models\Component;
|
||||
use App\Models\CustomField;
|
||||
@@ -313,5 +314,97 @@ class ComponentsController extends Controller
|
||||
return redirect()->route('components.index')->with('success', trans('admin/components/message.checkout.success'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view that allows the checkin of a component from an asset.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ComponentsController::postCheckout() method that stores the data.
|
||||
* @since [v4.1.4]
|
||||
* @param int $componentId
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function getCheckin($component_asset_id)
|
||||
{
|
||||
|
||||
// This could probably be done more cleanly but I am very tired. - @snipe
|
||||
if ($component_assets = DB::table('components_assets')->find($component_asset_id)) {
|
||||
if (is_null($component = Component::find($component_assets->component_id))) {
|
||||
return redirect()->route('components.index')->with('error', trans('admin/components/messages.not_found'));
|
||||
}
|
||||
if (is_null($asset = Asset::find($component_assets->asset_id))) {
|
||||
return redirect()->route('components.index')->with('error',
|
||||
trans('admin/components/message.not_found'));
|
||||
}
|
||||
$this->authorize('checkin', $component);
|
||||
return view('components/checkin', compact('component_assets','component','asset'));
|
||||
}
|
||||
|
||||
return redirect()->route('components.index')->with('error', trans('admin/components/messages.not_found'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and store checkin data.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ComponentsController::getCheckout() method that returns the form.
|
||||
* @since [v4.1.4]
|
||||
* @param Request $request
|
||||
* @param int $componentId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function postCheckin(Request $request, $component_asset_id)
|
||||
{
|
||||
if ($component_assets = DB::table('components_assets')->find($component_asset_id)) {
|
||||
if (is_null($component = Component::find($component_assets->component_id))) {
|
||||
return redirect()->route('components.index')->with('error',
|
||||
trans('admin/components/message.not_found'));
|
||||
}
|
||||
|
||||
|
||||
$this->authorize('checkin', $component);
|
||||
|
||||
$max_to_checkin = $component_assets->assigned_qty;
|
||||
$validator = Validator::make($request->all(), [
|
||||
"checkin_qty" => "required|numeric|between:1,$max_to_checkin"
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()
|
||||
->withErrors($validator)
|
||||
->withInput();
|
||||
}
|
||||
|
||||
// Validation passed, so let's figure out what we have to do here.
|
||||
$qty_remaining_in_checkout = ($component_assets->assigned_qty - (int)$request->input('checkin_qty'));
|
||||
|
||||
// We have to modify the record to reflect the new qty that's
|
||||
// actually checked out.
|
||||
$component_assets->assigned_qty = $qty_remaining_in_checkout;
|
||||
DB::table('components_assets')->where('id',
|
||||
$component_asset_id)->update(['assigned_qty' => $qty_remaining_in_checkout]);
|
||||
|
||||
$log = new Actionlog();
|
||||
$log->user_id = Auth::user()->id;
|
||||
$log->action_type = 'checkin from';
|
||||
$log->target_type = Asset::class;
|
||||
$log->target_id = $component_assets->asset_id;
|
||||
$log->item_id = $component_assets->component_id;
|
||||
$log->item_type = Component::class;
|
||||
$log->note = $request->input('note');
|
||||
$log->save();
|
||||
|
||||
// If the checked-in qty is exactly the same as the assigned_qty,
|
||||
// we can simply delete the associated components_assets record
|
||||
if ($qty_remaining_in_checkout == 0) {
|
||||
DB::table('components_assets')->where('id', '=', $component_asset_id)->delete();
|
||||
}
|
||||
|
||||
return redirect()->route('components.index')->with('success',
|
||||
trans('admin/components/message.checkout.success'));
|
||||
}
|
||||
return redirect()->route('components.index')->with('error', trans('admin/components/message.not_found'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\CustomFieldRequest;
|
||||
use View;
|
||||
use App\Models\CustomFieldset;
|
||||
use App\Models\CustomField;
|
||||
@@ -69,7 +70,7 @@ class CustomFieldsController extends Controller
|
||||
* @since [v1.8]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function store(CustomFieldRequest $request)
|
||||
{
|
||||
$field = new CustomField([
|
||||
"name" => $request->get("name"),
|
||||
@@ -81,27 +82,19 @@ class CustomFieldsController extends Controller
|
||||
]);
|
||||
|
||||
|
||||
|
||||
if (!in_array(Input::get('format'), array_keys(CustomField::$PredefinedFormats))) {
|
||||
$field->format = e($request->get("custom_format"));
|
||||
} else {
|
||||
$field->format = e($request->get("format"));
|
||||
}
|
||||
|
||||
|
||||
$validator = Validator::make(Input::all(), $field->rules);
|
||||
|
||||
if ($validator->passes()) {
|
||||
$results = $field->save();
|
||||
if ($results) {
|
||||
return redirect()->route("fields.index")->with("success", trans('admin/custom_fields/message.field.create.success'));
|
||||
} else {
|
||||
dd($field);
|
||||
return redirect()->back()->withInput()->with('error', trans('admin/custom_fields/message.field.create.error'));
|
||||
}
|
||||
if ($field->save()) {
|
||||
return redirect()->route("fields.index")->with("success", trans('admin/custom_fields/message.field.create.success'));
|
||||
} else {
|
||||
return redirect()->back()->withInput()->withErrors($validator);
|
||||
// dd($field);
|
||||
return redirect()->back()->withInput()->with('error', trans('admin/custom_fields/message.field.create.error'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +162,7 @@ class CustomFieldsController extends Controller
|
||||
* @since [v4.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(CustomFieldRequest $request, $id)
|
||||
{
|
||||
$field = CustomField::find($id);
|
||||
|
||||
@@ -186,13 +179,12 @@ class CustomFieldsController extends Controller
|
||||
$field->format = e($request->get("format"));
|
||||
}
|
||||
|
||||
$validator = Validator::make(Input::all(), $field->rules);
|
||||
|
||||
if ($field->save()) {
|
||||
return redirect()->route("fields.index")->with("success", trans('admin/custom_fields/message.field.update.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($validator);
|
||||
return redirect()->back()->withInput()->with('error', trans('admin/custom_fields/message.field.update.error'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ class DepartmentsController extends Controller
|
||||
return view('departments/edit', compact('item'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id) {
|
||||
public function update(ImageUploadRequest $request, $id) {
|
||||
|
||||
$this->authorize('create', Department::class);
|
||||
if (is_null($department = Department::find($id))) {
|
||||
@@ -152,21 +152,38 @@ class DepartmentsController extends Controller
|
||||
}
|
||||
|
||||
$department->fill($request->all());
|
||||
$department->manager_id = ($request->has('manager_id' ) ? $request->input('manager_id') : null);
|
||||
|
||||
if ($request->file('image')) {
|
||||
$image = $request->file('image');
|
||||
$file_name = str_random(25).".".$image->getClientOriginalExtension();
|
||||
$path = public_path('uploads/departments/'.$file_name);
|
||||
Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save($path);
|
||||
$department->image = $file_name;
|
||||
} elseif ($request->input('image_delete')=='1') {
|
||||
$old_image = $department->image;
|
||||
|
||||
// Set the model's image property to null if the image is being deleted
|
||||
if ($request->input('image_delete') == 1) {
|
||||
$department->image = null;
|
||||
}
|
||||
|
||||
$department->manager_id = ($request->has('manager_id' ) ? $request->input('manager_id') : null);
|
||||
if ($request->file('image')) {
|
||||
$image = $request->file('image');
|
||||
$file_name = $department->id.'-'.str_slug($image->getClientOriginalName()) . "." . $image->getClientOriginalExtension();
|
||||
|
||||
if ($image->getClientOriginalExtension()!='svg') {
|
||||
Image::make($image->getRealPath())->resize(500, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save(app('departments_upload_path').$file_name);
|
||||
} else {
|
||||
$image->move(app('departments_upload_path'), $file_name);
|
||||
}
|
||||
$department->image = $file_name;
|
||||
|
||||
}
|
||||
|
||||
if ((($request->file('image')) && (isset($old_image)) && ($old_image!='')) || ($request->input('image_delete') == 1)) {
|
||||
try {
|
||||
unlink(app('departments_upload_path').$old_image);
|
||||
} catch (\Exception $e) {
|
||||
\Log::error($e);
|
||||
}
|
||||
}
|
||||
|
||||
if ($department->save()) {
|
||||
return redirect()->route("departments.index")->with('success', trans('admin/departments/message.update.success'));
|
||||
|
||||
@@ -47,7 +47,7 @@ class GroupsController extends Controller
|
||||
$group = new Group;
|
||||
// Get all the available permissions
|
||||
$permissions = config('permissions');
|
||||
$groupPermissions = array();
|
||||
$groupPermissions = Helper::selectedPermissionsArray($permissions, $permissions);
|
||||
$selectedPermissions = Input::old('permissions', $groupPermissions);
|
||||
|
||||
// Show the page
|
||||
@@ -84,7 +84,7 @@ class GroupsController extends Controller
|
||||
* @since [v1.0]
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit($id = null)
|
||||
public function edit($id)
|
||||
{
|
||||
$group = Group::find($id);
|
||||
|
||||
@@ -95,7 +95,7 @@ class GroupsController extends Controller
|
||||
return view('groups.edit', compact('group', 'permissions', 'selected_array', 'groupPermissions'));
|
||||
}
|
||||
|
||||
return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', compact('id')));
|
||||
return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -239,16 +239,19 @@ class LicensesController extends Controller
|
||||
* @param int $seatId
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function getCheckout($seatId)
|
||||
public function getCheckout($licenceId)
|
||||
{
|
||||
// Check if the license seat exists
|
||||
if (is_null($licenseSeat = LicenseSeat::find($seatId))) {
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.not_found'));
|
||||
// Check that the license is valid
|
||||
if ($license = License::where('id',$licenceId)->first()) {
|
||||
|
||||
// If the license is valid, check that there is an available seat
|
||||
if ($license->getAvailSeatsCountAttribute() < 1) {
|
||||
return redirect()->route('licenses.index')->with('error', 'There are no available seats for this license');
|
||||
}
|
||||
}
|
||||
|
||||
$this->authorize('checkout', $licenseSeat);
|
||||
return view('licenses/checkout', compact('licenseSeat'));
|
||||
$this->authorize('checkout', $license);
|
||||
return view('licenses/checkout', compact('license'));
|
||||
}
|
||||
|
||||
|
||||
@@ -262,78 +265,83 @@ class LicensesController extends Controller
|
||||
* @param int $seatId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function postCheckout(Request $request, $seatId)
|
||||
public function postCheckout(Request $request, $licenseId)
|
||||
{
|
||||
$licenseSeat = LicenseSeat::find($seatId);
|
||||
$assigned_to = e($request->input('assigned_to'));
|
||||
$asset_id = e($request->input('asset_id'));
|
||||
|
||||
$this->authorize('checkout', $licenseSeat);
|
||||
// Check that the license is valid
|
||||
if ($license = License::where('id',$licenseId)->first()) {
|
||||
|
||||
// Declare the rules for the form validation
|
||||
$rules = [
|
||||
'note' => 'string|nullable',
|
||||
'asset_id' => 'required_without:assigned_to',
|
||||
];
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails()) {
|
||||
// Ooops.. something went wrong
|
||||
return redirect()->back()->withInput()->withErrors($validator);
|
||||
}
|
||||
$target = null;
|
||||
if ($assigned_to!='') {
|
||||
// Check if the user exists
|
||||
if (is_null($target = User::find($assigned_to))) {
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.user_does_not_exist'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($asset_id!='') {
|
||||
if (is_null($target = Asset::find($asset_id))) {
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.asset_does_not_exist'));
|
||||
// If the license is valid, check that there is an available seat
|
||||
if ($license->getAvailSeatsCountAttribute() < 1) {
|
||||
return redirect()->route('licenses.index')->with('error', 'There are no available seats for this license');
|
||||
}
|
||||
|
||||
if (($request->has('assigned_to')) && ($request->has('asset_id'))) {
|
||||
return redirect()->back()->withInput()->with('error', trans('admin/licenses/message.select_asset_or_person'));
|
||||
// Get the next available seat for this license
|
||||
$next = $license->freeSeat();
|
||||
|
||||
if (!$next) {
|
||||
return redirect()->route('licenses.index')->with('error', 'There are no available seats for this license');
|
||||
}
|
||||
|
||||
if (!$licenseSeat = LicenseSeat::where('id', '=', $next->id)->first()) {
|
||||
return redirect()->route('licenses.index')->with('error', 'There are no available seats for this license');
|
||||
}
|
||||
|
||||
|
||||
$this->authorize('checkout', $license);
|
||||
|
||||
// Declare the rules for the form validation
|
||||
$rules = [
|
||||
'note' => 'string|nullable',
|
||||
'asset_id' => 'required_without:assigned_to',
|
||||
];
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails()) {
|
||||
// Ooops.. something went wrong
|
||||
return redirect()->back()->withInput()->withErrors($validator);
|
||||
}
|
||||
$target = null;
|
||||
|
||||
|
||||
// This item is checked out to a an asset
|
||||
if (request('checkout_to_type')=='asset') {
|
||||
if (is_null($target = Asset::find(request('asset_id')))) {
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.asset_does_not_exist'));
|
||||
}
|
||||
$licenseSeat->asset_id = $request->input('asset_id');
|
||||
|
||||
// Override asset's assigned user if available
|
||||
if ($target->checkedOutToUser()) {
|
||||
$licenseSeat->assigned_to = $target->assigned_to;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Fetch the target and set the license user
|
||||
if (is_null($target = User::find(request('assigned_to')))) {
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.user_does_not_exist'));
|
||||
}
|
||||
$licenseSeat->assigned_to = request('assigned_to');
|
||||
}
|
||||
|
||||
$licenseSeat->user_id = Auth::user()->id;
|
||||
|
||||
|
||||
if ($licenseSeat->save()) {
|
||||
$licenseSeat->logCheckout($request->input('note'), $target);
|
||||
return redirect()->route("licenses.index")->with('success', trans('admin/licenses/message.checkout.success'));
|
||||
}
|
||||
|
||||
}
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.not_found'));
|
||||
|
||||
// Check if the asset exists
|
||||
if (is_null($licenseSeat)) {
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.not_found'));
|
||||
}
|
||||
|
||||
if ($request->input('asset_id') == '') {
|
||||
$licenseSeat->asset_id = null;
|
||||
} else {
|
||||
$licenseSeat->asset_id = $request->input('asset_id');
|
||||
}
|
||||
|
||||
// Update the asset data
|
||||
if ($request->input('assigned_to') == '') {
|
||||
$licenseSeat->assigned_to = null;
|
||||
} else {
|
||||
$licenseSeat->assigned_to = $request->input('assigned_to');
|
||||
}
|
||||
|
||||
// Was the asset updated?
|
||||
if ($licenseSeat->save()) {
|
||||
$licenseSeat->logCheckout($request->input('note'), $target);
|
||||
|
||||
$data['license_id'] = $licenseSeat->license_id;
|
||||
$data['note'] = $request->input('note');
|
||||
|
||||
// Redirect to the new asset page
|
||||
return redirect()->route("licenses.index")->with('success', trans('admin/licenses/message.checkout.success'));
|
||||
}
|
||||
|
||||
return redirect()->route("licenses.index")->with('error', trans('admin/licenses/message.checkout.error'));
|
||||
}
|
||||
|
||||
@@ -354,7 +362,14 @@ class LicensesController extends Controller
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.not_found'));
|
||||
}
|
||||
$this->authorize('checkin', $licenseSeat);
|
||||
|
||||
if (is_null($license = License::find($licenseSeat->license_id))) {
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.not_found'));
|
||||
}
|
||||
|
||||
|
||||
$this->authorize('checkout', $license);
|
||||
return view('licenses/checkin', compact('licenseSeat'))->with('backto', $backTo);
|
||||
}
|
||||
|
||||
@@ -378,8 +393,7 @@ class LicensesController extends Controller
|
||||
}
|
||||
|
||||
$license = License::find($licenseSeat->license_id);
|
||||
|
||||
$this->authorize('checkin', $licenseSeat);
|
||||
$this->authorize('checkout', $license);
|
||||
|
||||
if (!$license->reassignable) {
|
||||
// Not allowed to checkin
|
||||
|
||||
@@ -40,6 +40,7 @@ class LocationsController extends Controller
|
||||
public function index()
|
||||
{
|
||||
// Grab all the locations
|
||||
$this->authorize('view', Location::class);
|
||||
$locations = Location::orderBy('created_at', 'DESC')->with('parent', 'assets', 'assignedassets')->get();
|
||||
|
||||
// Show the page
|
||||
@@ -57,6 +58,7 @@ class LocationsController extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$this->authorize('create', Location::class);
|
||||
$locations = Location::orderBy('name', 'ASC')->get();
|
||||
|
||||
$location_options_array = Location::getLocationHierarchy($locations);
|
||||
@@ -80,6 +82,7 @@ class LocationsController extends Controller
|
||||
*/
|
||||
public function store(ImageUploadRequest $request)
|
||||
{
|
||||
$this->authorize('create', Location::class);
|
||||
$location = new Location();
|
||||
$location->name = $request->input('name');
|
||||
$location->parent_id = $request->input('parent_id', null);
|
||||
@@ -98,7 +101,7 @@ class LocationsController extends Controller
|
||||
$image = $request->file('image');
|
||||
$file_name = str_random(25).".".$image->getClientOriginalExtension();
|
||||
$path = public_path('uploads/locations/'.$file_name);
|
||||
Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
|
||||
Image::make($image->getRealPath())->resize(600, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save($path);
|
||||
@@ -122,6 +125,7 @@ class LocationsController extends Controller
|
||||
*/
|
||||
public function apiStore(Request $request)
|
||||
{
|
||||
$this->authorize('create', Location::class);
|
||||
$new['currency']=Setting::first()->default_currency;
|
||||
|
||||
// create a new location instance
|
||||
@@ -158,6 +162,7 @@ class LocationsController extends Controller
|
||||
*/
|
||||
public function edit($locationId = null)
|
||||
{
|
||||
$this->authorize('edit', Location::class);
|
||||
// Check if the location exists
|
||||
if (is_null($item = Location::find($locationId))) {
|
||||
return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist'));
|
||||
@@ -186,6 +191,7 @@ class LocationsController extends Controller
|
||||
*/
|
||||
public function update(ImageUploadRequest $request, $locationId = null)
|
||||
{
|
||||
$this->authorize('edit', Location::class);
|
||||
// Check if the location exists
|
||||
if (is_null($location = Location::find($locationId))) {
|
||||
return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist'));
|
||||
@@ -204,17 +210,35 @@ class LocationsController extends Controller
|
||||
$location->ldap_ou = $request->input('ldap_ou');
|
||||
$location->manager_id = $request->input('manager_id');
|
||||
|
||||
$old_image = $location->image;
|
||||
|
||||
// Set the model's image property to null if the image is being deleted
|
||||
if ($request->input('image_delete') == 1) {
|
||||
$location->image = null;
|
||||
}
|
||||
|
||||
if ($request->file('image')) {
|
||||
$image = $request->file('image');
|
||||
$file_name = str_random(25).".".$image->getClientOriginalExtension();
|
||||
$path = public_path('uploads/locations/'.$file_name);
|
||||
Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save($path);
|
||||
$file_name = $location->id.'-'.str_slug($image->getClientOriginalName()) . "." . $image->getClientOriginalExtension();
|
||||
|
||||
if ($image->getClientOriginalExtension()!='svg') {
|
||||
Image::make($image->getRealPath())->resize(600, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save(app('locations_upload_path').$file_name);
|
||||
} else {
|
||||
$image->move(app('locations_upload_path'), $file_name);
|
||||
}
|
||||
$location->image = $file_name;
|
||||
} elseif ($request->input('image_delete')=='1') {
|
||||
$location->image = null;
|
||||
|
||||
}
|
||||
|
||||
if ((($request->file('image')) && (isset($old_image)) && ($old_image!='')) || ($request->input('image_delete') == 1)) {
|
||||
try {
|
||||
unlink(app('locations_upload_path').$old_image);
|
||||
} catch (\Exception $e) {
|
||||
\Log::error($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -234,6 +258,7 @@ class LocationsController extends Controller
|
||||
*/
|
||||
public function destroy($locationId)
|
||||
{
|
||||
$this->authorize('delete', Location::class);
|
||||
if (is_null($location = Location::find($locationId))) {
|
||||
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.not_found'));
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ class ManufacturersController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->authorize('index', Manufacturer::class);
|
||||
return view('manufacturers/index', compact('manufacturers'));
|
||||
}
|
||||
|
||||
@@ -49,6 +50,7 @@ class ManufacturersController extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$this->authorize('create', Manufacturer::class);
|
||||
return view('manufacturers/edit')->with('item', new Manufacturer);
|
||||
}
|
||||
|
||||
@@ -65,6 +67,7 @@ class ManufacturersController extends Controller
|
||||
public function store(ImageUploadRequest $request)
|
||||
{
|
||||
|
||||
$this->authorize('create', Manufacturer::class);
|
||||
$manufacturer = new Manufacturer;
|
||||
$manufacturer->name = $request->input('name');
|
||||
$manufacturer->user_id = Auth::user()->id;
|
||||
@@ -104,6 +107,7 @@ class ManufacturersController extends Controller
|
||||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
$this->authorize('edit', Manufacturer::class);
|
||||
// Check if the manufacturer exists
|
||||
if (is_null($item = Manufacturer::find($id))) {
|
||||
return redirect()->route('manufacturers.index')->with('error', trans('admin/manufacturers/message.does_not_exist'));
|
||||
@@ -123,8 +127,9 @@ class ManufacturersController extends Controller
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @since [v1.0]
|
||||
*/
|
||||
public function update(Request $request, $manufacturerId = null)
|
||||
public function update(ImageUploadRequest $request, $manufacturerId = null)
|
||||
{
|
||||
$this->authorize('edit', Manufacturer::class);
|
||||
// Check if the manufacturer exists
|
||||
if (is_null($manufacturer = Manufacturer::find($manufacturerId))) {
|
||||
// Redirect to the manufacturer page
|
||||
@@ -138,26 +143,35 @@ class ManufacturersController extends Controller
|
||||
$manufacturer->support_phone = $request->input('support_phone');
|
||||
$manufacturer->support_email = $request->input('support_email');
|
||||
|
||||
$old_image = $manufacturer->image;
|
||||
|
||||
// Set the model's image property to null if the image is being deleted
|
||||
if ($request->input('image_delete') == 1) {
|
||||
$manufacturer->image = null;
|
||||
}
|
||||
|
||||
if ($request->file('image')) {
|
||||
$image = $request->file('image');
|
||||
$file_name = str_slug($image->getClientOriginalName()).".".$image->getClientOriginalExtension();
|
||||
$path = public_path('uploads/manufacturers/'.$file_name);
|
||||
$old_image = $path.$manufacturer->image;
|
||||
$file_name = $manufacturer->id.'-'.str_slug($image->getClientOriginalName()) . "." . $image->getClientOriginalExtension();
|
||||
|
||||
if ($image->getClientOriginalExtension()!='svg') {
|
||||
Image::make($image->getRealPath())->resize(500, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save(app('manufacturers_upload_path').$file_name);
|
||||
} else {
|
||||
$image->move(app('manufacturers_upload_path'), $file_name);
|
||||
}
|
||||
$manufacturer->image = $file_name;
|
||||
|
||||
}
|
||||
|
||||
if ((($request->file('image')) && (isset($old_image)) && ($old_image!='')) || ($request->input('image_delete') == 1)) {
|
||||
try {
|
||||
unlink($old_image);
|
||||
unlink(app('manufacturers_upload_path').$old_image);
|
||||
} catch (\Exception $e) {
|
||||
\Log::error($e);
|
||||
}
|
||||
|
||||
|
||||
Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save($path);
|
||||
$manufacturer->image = $file_name;
|
||||
} elseif ($request->input('image_delete')=='1') {
|
||||
$manufacturer->image = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -177,6 +191,7 @@ class ManufacturersController extends Controller
|
||||
*/
|
||||
public function destroy($manufacturerId)
|
||||
{
|
||||
$this->authorize('delete', Manufacturer::class);
|
||||
// Check if the manufacturer exists
|
||||
if (is_null($manufacturer = Manufacturer::find($manufacturerId))) {
|
||||
// Redirect to the manufacturers page
|
||||
@@ -215,6 +230,7 @@ class ManufacturersController extends Controller
|
||||
*/
|
||||
public function show($manufacturerId = null)
|
||||
{
|
||||
$this->authorize('view', Manufacturer::class);
|
||||
$manufacturer = Manufacturer::find($manufacturerId);
|
||||
|
||||
if (isset($manufacturer->id)) {
|
||||
|
||||
@@ -29,4 +29,13 @@ class ModalController extends Controller
|
||||
function user() {
|
||||
return view('modals.user');
|
||||
}
|
||||
|
||||
function category() {
|
||||
return view('modals.category');
|
||||
}
|
||||
|
||||
function manufacturer() {
|
||||
return view('modals.manufacturer');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Models\Setting;
|
||||
use Gate;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Http\Requests\ImageUploadRequest;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to User Profiles for
|
||||
@@ -40,7 +41,7 @@ class ProfileController extends Controller
|
||||
* @since [v1.0]
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function postIndex()
|
||||
public function postIndex(ImageUploadRequest $request)
|
||||
{
|
||||
|
||||
$user = Auth::user();
|
||||
@@ -108,12 +109,12 @@ class ProfileController extends Controller
|
||||
{
|
||||
|
||||
if (config('app.lock_passwords')) {
|
||||
return redirect()->route('account.password.index')->with('error', Lang::get('admin/users/table.lock_passwords'));
|
||||
return redirect()->route('account.password.index')->with('error', trans('admin/users/table.lock_passwords'));
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
if ($user->ldap_import=='1') {
|
||||
return redirect()->route('account.password.index')->with('error', Lang::get('admin/users/message.error.password_ldap'));
|
||||
return redirect()->route('account.password.index')->with('error', trans('admin/users/message.error.password_ldap'));
|
||||
}
|
||||
|
||||
$rules = array(
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetMaintenance;
|
||||
use App\Models\CustomField;
|
||||
use App\Models\Depreciation;
|
||||
use App\Models\License;
|
||||
use App\Models\Setting;
|
||||
use Carbon\Carbon;
|
||||
@@ -141,48 +142,55 @@ class ReportsController extends Controller
|
||||
break;
|
||||
}
|
||||
|
||||
$headers=[
|
||||
trans('general.company'),
|
||||
trans('admin/hardware/table.asset_tag'),
|
||||
trans('admin/hardware/form.manufacturer'),
|
||||
trans('general.category'),
|
||||
trans('admin/hardware/form.model'),
|
||||
trans('general.model_no'),
|
||||
trans('general.name'),
|
||||
trans('admin/hardware/table.serial'),
|
||||
trans('general.status'),
|
||||
trans('admin/hardware/table.purchase_date'),
|
||||
trans('admin/hardware/table.purchase_cost'),
|
||||
trans('admin/hardware/form.order'),
|
||||
trans('general.supplier'),
|
||||
trans('admin/hardware/table.checkoutto'),
|
||||
trans('general.type'),
|
||||
trans('admin/hardware/table.checkout_date'),
|
||||
trans('admin/hardware/table.location'),
|
||||
trans('general.notes'),
|
||||
];
|
||||
foreach ($customfields as $field) {
|
||||
$headers[]=$field->name;
|
||||
}
|
||||
fputcsv($handle, $headers);
|
||||
|
||||
$assets->orderBy('created_at', 'DESC')->chunk(500, function($assets) use($handle, $customfields) {
|
||||
$headers=[
|
||||
trans('general.company'),
|
||||
trans('admin/hardware/table.asset_tag'),
|
||||
trans('admin/hardware/form.manufacturer'),
|
||||
trans('admin/hardware/form.model'),
|
||||
trans('general.model_no'),
|
||||
trans('general.name'),
|
||||
trans('admin/hardware/table.serial'),
|
||||
trans('general.status'),
|
||||
trans('admin/hardware/table.purchase_date'),
|
||||
trans('admin/hardware/table.purchase_cost'),
|
||||
trans('admin/hardware/form.order'),
|
||||
trans('general.supplier'),
|
||||
trans('admin/hardware/table.checkoutto'),
|
||||
trans('admin/hardware/table.checkout_date'),
|
||||
trans('admin/hardware/table.location'),
|
||||
trans('general.notes'),
|
||||
];
|
||||
foreach ($customfields as $field) {
|
||||
$headers[]=$field->name;
|
||||
}
|
||||
fputcsv($handle, $headers);
|
||||
|
||||
|
||||
foreach ($assets as $asset) {
|
||||
|
||||
// Add a new row with data
|
||||
$values=[
|
||||
($asset->company) ? $asset->company->name : '',
|
||||
$asset->asset_tag,
|
||||
($asset->model->manufacturer) ? $asset->model->manufacturer->name : '',
|
||||
($asset->model->category) ? $asset->model->category->name : '',
|
||||
($asset->model) ? $asset->model->name : '',
|
||||
($asset->model->model_number) ? $asset->model->model_number : '',
|
||||
($asset->name) ? $asset->name : '',
|
||||
($asset->serial) ? $asset->serial : '',
|
||||
($asset->assetstatus) ? e($asset->assetstatus->name) : '',
|
||||
($asset->assetstatus) ? e($asset->present()->statusText) : '',
|
||||
($asset->purchase_date) ? e($asset->purchase_date) : '',
|
||||
($asset->purchase_cost > 0) ? Helper::formatCurrencyOutput($asset->purchase_cost) : '',
|
||||
($asset->order_number) ? e($asset->order_number) : '',
|
||||
($asset->supplier) ? e($asset->supplier->name) : '',
|
||||
($asset->assignedTo) ? e($asset->assignedTo->present()->name()) : '',
|
||||
($asset->checkedOutToUser() && $asset->assigned) ? e($asset->assigned->getFullNameAttribute()) : ($asset->assigned ? e($asset->assigned->display_name) : ''),
|
||||
($asset->checkedOutToUser() && $asset->assigned) ? 'user' : e($asset->assignedType()),
|
||||
($asset->last_checkout!='') ? e($asset->last_checkout) : '',
|
||||
($asset->location) ? e($asset->location->present()->name()) : '',
|
||||
($asset->location) ? e($asset->location->name) : '',
|
||||
($asset->notes) ? e($asset->notes) : '',
|
||||
];
|
||||
foreach ($customfields as $field) {
|
||||
@@ -214,11 +222,12 @@ class ReportsController extends Controller
|
||||
public function getDeprecationReport()
|
||||
{
|
||||
|
||||
$depreciations = Depreciation::get();
|
||||
// Grab all the assets
|
||||
$assets = Asset::with( 'assignedTo', 'assetstatus', 'defaultLoc', 'location', 'assetlog', 'company', 'model.category', 'model.depreciation')
|
||||
->orderBy('created_at', 'DESC')->get();
|
||||
|
||||
return view('reports/depreciation', compact('assets'));
|
||||
return view('reports/depreciation', compact('assets'))->with('depreciations',$depreciations);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -417,251 +426,332 @@ class ReportsController extends Controller
|
||||
* @since [v1.0]
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function postCustom()
|
||||
public function postCustom(Request $request)
|
||||
{
|
||||
$assets = Asset::orderBy('created_at', 'DESC')->with('company', 'assignedTo', 'location', 'defaultLoc', 'model', 'supplier', 'assetstatus', 'model.manufacturer')->get();
|
||||
|
||||
\Debugbar::disable();
|
||||
$customfields = CustomField::get();
|
||||
$response = new StreamedResponse(function () use ($customfields, $request) {
|
||||
|
||||
$rows = [ ];
|
||||
$header = [ ];
|
||||
|
||||
if (e(Input::get('company')) == '1') {
|
||||
$header[] = 'Company Name';
|
||||
}
|
||||
|
||||
if (e(Input::get('asset_name')) == '1') {
|
||||
$header[] = 'Asset Name';
|
||||
}
|
||||
if (e(Input::get('asset_tag')) == '1') {
|
||||
$header[] = 'Asset Tag';
|
||||
}
|
||||
if (e(Input::get('manufacturer')) == '1') {
|
||||
$header[] = 'Manufacturer';
|
||||
}
|
||||
if (e(Input::get('model')) == '1') {
|
||||
$header[] = 'Model';
|
||||
$header[] = 'Model Number';
|
||||
}
|
||||
if (e(Input::get('category')) == '1') {
|
||||
$header[] = 'Category';
|
||||
}
|
||||
if (e(Input::get('serial')) == '1') {
|
||||
$header[] = 'Serial';
|
||||
}
|
||||
if (e(Input::get('purchase_date')) == '1') {
|
||||
$header[] = 'Purchase Date';
|
||||
}
|
||||
if (( e(Input::get('purchase_cost')) == '1' ) && ( e(Input::get('depreciation')) != '1' )) {
|
||||
$header[] = 'Purchase Cost';
|
||||
}
|
||||
if (e(Input::get('eol')) == '1') {
|
||||
$header[] = 'EOL';
|
||||
}
|
||||
if (e(Input::get('order')) == '1') {
|
||||
$header[] = 'Order Number';
|
||||
}
|
||||
if (e(Input::get('supplier')) == '1') {
|
||||
$header[] = 'Supplier';
|
||||
}
|
||||
if (e(Input::get('location')) == '1') {
|
||||
$header[] = 'Location';
|
||||
}
|
||||
if (e(Input::get('assigned_to')) == '1') {
|
||||
$header[] = 'Assigned To';
|
||||
}
|
||||
if (e(Input::get('username')) == '1') {
|
||||
$header[] = 'Username';
|
||||
}
|
||||
if (e(Input::get('employee_num')) == '1') {
|
||||
$header[] = 'Employee No.';
|
||||
}
|
||||
if (e(Input::get('status')) == '1') {
|
||||
$header[] = 'Status';
|
||||
}
|
||||
if (e(Input::get('warranty')) == '1') {
|
||||
$header[] = 'Warranty';
|
||||
$header[] = 'Warranty Expires';
|
||||
}
|
||||
if (e(Input::get('depreciation')) == '1') {
|
||||
$header[] = 'Purchase Cost';
|
||||
$header[] = 'Value';
|
||||
$header[] = 'Diff';
|
||||
}
|
||||
if (e(Input::get('expected_checkin')) == '1') {
|
||||
$header[] = trans('admin/hardware/form.expected_checkin');
|
||||
}
|
||||
|
||||
if (e(Input::get('notes')) == '1') {
|
||||
$header[] = trans('general.notes');
|
||||
}
|
||||
|
||||
|
||||
foreach ($customfields as $customfield) {
|
||||
if (e(Input::get($customfield->db_column_name())) == '1') {
|
||||
$header[] = $customfield->name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$header = array_map('trim', $header);
|
||||
$rows[] = implode($header, ',');
|
||||
|
||||
foreach ($assets as $asset) {
|
||||
$row = [ ];
|
||||
|
||||
if (e(Input::get('company')) == '1') {
|
||||
$row[] = is_null($asset->company) ? '' : '"'.$asset->company->name.'"';
|
||||
// Open output stream
|
||||
$handle = fopen('php://output', 'w');
|
||||
|
||||
if ($request->has('use_bom')) {
|
||||
fprintf($handle, chr(0xEF) . chr(0xBB) . chr(0xBF));
|
||||
}
|
||||
|
||||
if (e(Input::get('asset_name')) == '1') {
|
||||
$row[] = '"' .e($asset->name) . '"';
|
||||
}
|
||||
if (e(Input::get('asset_tag')) == '1') {
|
||||
$row[] = e($asset->asset_tag);
|
||||
}
|
||||
if (e(Input::get('manufacturer')) == '1') {
|
||||
if ($asset->model->manufacturer) {
|
||||
$row[] = '"' .e($asset->model->manufacturer->name) . '"';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
}
|
||||
if (e(Input::get('model')) == '1') {
|
||||
$row[] = '"' . e($asset->model->name) . '"';
|
||||
$row[] = '"' . e($asset->model->model_number) . '"';
|
||||
}
|
||||
if (e(Input::get('category')) == '1') {
|
||||
$row[] = '"' .e($asset->model->category->name) . '"';
|
||||
}
|
||||
|
||||
if (e(Input::get('serial')) == '1') {
|
||||
$row[] = e($asset->serial);
|
||||
}
|
||||
if (e(Input::get('purchase_date')) == '1') {
|
||||
$row[] = e($asset->purchase_date);
|
||||
}
|
||||
if (e(Input::get('purchase_cost')) == '1' && ( e(Input::get('depreciation')) != '1' )) {
|
||||
$row[] = '"' . Helper::formatCurrencyOutput($asset->purchase_cost) . '"';
|
||||
}
|
||||
if (e(Input::get('eol')) == '1') {
|
||||
$row[] = '"' .($asset->present()->eol_date()) ? $asset->present()->eol_date() : ''. '"';
|
||||
}
|
||||
if (e(Input::get('order')) == '1') {
|
||||
if ($asset->order_number) {
|
||||
$row[] = e($asset->order_number);
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
}
|
||||
if (e(Input::get('supplier')) == '1') {
|
||||
if ($asset->supplier) {
|
||||
$row[] = '"' .e($asset->supplier->name) . '"';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (e(Input::get('location')) == '1') {
|
||||
if($asset->location) {
|
||||
$show_loc = $asset->location->present()->name();
|
||||
} else {
|
||||
$show_loc = 'Default location '.$asset->rtd_location_id.' is invalid';
|
||||
}
|
||||
$row[] = $show_loc;
|
||||
}
|
||||
$header = [];
|
||||
|
||||
|
||||
if (e(Input::get('assigned_to')) == '1') {
|
||||
if ($asset->assignedto) {
|
||||
$row[] = '"' .e($asset->assignedto->present()->name()). '"';
|
||||
} else {
|
||||
$row[] = ''; // Empty string if unassigned
|
||||
}
|
||||
if ($request->has('company')) {
|
||||
$header[] = trans('general.company');
|
||||
}
|
||||
|
||||
if (e(Input::get('username')) == '1') {
|
||||
// Only works if we're checked out to a user, not anything else.
|
||||
if ($asset->checkedOutToUser()) {
|
||||
$row[] = '"' .e($asset->assignedto->username). '"';
|
||||
} else {
|
||||
$row[] = ''; // Empty string if unassigned
|
||||
}
|
||||
if ($request->has('asset_name')) {
|
||||
$header[] = trans('admin/hardware/form.name');
|
||||
}
|
||||
|
||||
if (e(Input::get('employee_num')) == '1') {
|
||||
// Only works if we're checked out to a user, not anything else.
|
||||
if ($asset->checkedOutToUser()) {
|
||||
$row[] = '"' .e($asset->assignedto->employee_num). '"';
|
||||
} else {
|
||||
$row[] = ''; // Empty string if unassigned
|
||||
}
|
||||
if ($request->has('asset_tag')) {
|
||||
$header[] = trans('admin/hardware/table.asset_tag');
|
||||
}
|
||||
|
||||
if (e(Input::get('status')) == '1') {
|
||||
if (( $asset->status_id == '0' ) && ( $asset->assigned_to == '0' )) {
|
||||
$row[] = trans('general.ready_to_deploy');
|
||||
} elseif (( $asset->status_id == '' ) && ( $asset->assigned_to == '0' )) {
|
||||
$row[] = trans('general.pending');
|
||||
} elseif ($asset->assetstatus) {
|
||||
$row[] = '"' .e($asset->assetstatus->name). '"';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
}
|
||||
if (e(Input::get('warranty')) == '1') {
|
||||
if ($asset->warranty_months) {
|
||||
$row[] = $asset->warranty_months;
|
||||
$row[] = $asset->present()->warrantee_expires();
|
||||
} else {
|
||||
$row[] = '';
|
||||
$row[] = '';
|
||||
}
|
||||
}
|
||||
if (e(Input::get('depreciation')) == '1') {
|
||||
$depreciation = $asset->getDepreciatedValue();
|
||||
$row[] = '"' . Helper::formatCurrencyOutput($asset->purchase_cost) . '"';
|
||||
$row[] = '"' . Helper::formatCurrencyOutput($depreciation) . '"';
|
||||
$row[] = '"' . Helper::formatCurrencyOutput($asset->purchase_cost) . '"';
|
||||
}
|
||||
if (e(Input::get('expected_checkin')) == '1') {
|
||||
if ($asset->expected_checkin) {
|
||||
$row[] = '"' .e($asset->expected_checkin). '"';
|
||||
} else {
|
||||
$row[] = ''; // Empty string if blankd
|
||||
}
|
||||
if ($request->has('model')) {
|
||||
$header[] = trans('admin/hardware/form.model');
|
||||
$header[] = trans('general.model_no');
|
||||
}
|
||||
|
||||
if (e(Input::get('notes')) == '1') {
|
||||
if ($asset->notes) {
|
||||
$row[] = '"' .$asset->notes . '"';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
if ($request->has('category')) {
|
||||
$header[] = trans('general.category');
|
||||
}
|
||||
|
||||
if ($request->has('manufacturer')) {
|
||||
$header[] = trans('admin/hardware/form.manufacturer');
|
||||
}
|
||||
|
||||
if ($request->has('serial')) {
|
||||
$header[] = trans('admin/hardware/table.serial');
|
||||
}
|
||||
if ($request->has('purchase_date')) {
|
||||
$header[] = trans('admin/hardware/table.purchase_date');
|
||||
}
|
||||
|
||||
if (($request->has('purchase_cost')) || ($request->has('depreciation'))) {
|
||||
$header[] = trans('admin/hardware/table.purchase_cost');
|
||||
}
|
||||
|
||||
if ($request->has('eol')) {
|
||||
$header[] = trans('admin/hardware/table.eol');
|
||||
}
|
||||
|
||||
if ($request->has('order')) {
|
||||
$header[] = trans('admin/hardware/form.order');
|
||||
}
|
||||
|
||||
if ($request->has('supplier')) {
|
||||
$header[] = trans('general.supplier');
|
||||
}
|
||||
|
||||
if ($request->has('location')) {
|
||||
$header[] = trans('admin/hardware/table.location');
|
||||
}
|
||||
|
||||
if ($request->has('assigned_to')) {
|
||||
$header[] = trans('admin/hardware/table.checkoutto');
|
||||
$header[] = trans('general.type');
|
||||
}
|
||||
|
||||
if ($request->has('username')) {
|
||||
$header[] = 'Username';
|
||||
}
|
||||
|
||||
if ($request->has('employee_num')) {
|
||||
$header[] = 'Employee No.';
|
||||
}
|
||||
|
||||
if ($request->has('status')) {
|
||||
$header[] = trans('general.status');
|
||||
}
|
||||
|
||||
if ($request->has('warranty')) {
|
||||
$header[] = 'Warranty';
|
||||
$header[] = 'Warranty Expires';
|
||||
}
|
||||
if ($request->has('depreciation')) {
|
||||
$header[] = 'Value';
|
||||
$header[] = 'Diff';
|
||||
}
|
||||
|
||||
if ($request->has('checkout_date')) {
|
||||
$header[] = trans('admin/hardware/table.checkout_date');
|
||||
}
|
||||
|
||||
if ($request->has('expected_checkin')) {
|
||||
$header[] = trans('admin/hardware/form.expected_checkin');
|
||||
}
|
||||
|
||||
if ($request->has('created_at')) {
|
||||
$header[] = trans('general.created_at');
|
||||
}
|
||||
|
||||
if ($request->has('updated_at')) {
|
||||
$header[] = trans('general.updated_at');
|
||||
}
|
||||
|
||||
if ($request->has('last_audit_date')) {
|
||||
$header[] = trans('general.last_audit');
|
||||
}
|
||||
|
||||
if ($request->has('next_audit_date')) {
|
||||
$header[] = trans('general.next_audit_date');
|
||||
}
|
||||
|
||||
if ($request->has('notes')) {
|
||||
$header[] = trans('general.notes');
|
||||
}
|
||||
|
||||
|
||||
foreach ($customfields as $customfield) {
|
||||
$column_name = $customfield->db_column_name();
|
||||
if (e(Input::get($customfield->db_column_name())) == '1') {
|
||||
$row[] = str_replace(",", "\,", $asset->$column_name);
|
||||
$header[] = $customfield->name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rows[] = implode($row, ',');
|
||||
}
|
||||
fputcsv($handle, $header);
|
||||
|
||||
$assets = \App\Models\Company::scopeCompanyables(Asset::select('assets.*'))->with(
|
||||
'location', 'assetstatus', 'assetlog', 'company', 'defaultLoc','assignedTo',
|
||||
'model.category', 'model.manufacturer','supplier');
|
||||
|
||||
if ($request->has('by_location_id')) {
|
||||
$assets->where('assets.location_id', $request->input('by_location_id'));
|
||||
}
|
||||
|
||||
if ($request->has('by_supplier_id')) {
|
||||
$assets->where('assets.supplier_id', $request->input('by_supplier_id'));
|
||||
}
|
||||
|
||||
if ($request->has('by_company_id')) {
|
||||
$assets->where('assets.company_id', $request->input('by_company_id'));
|
||||
}
|
||||
|
||||
if ($request->has('by_model_id')) {
|
||||
$assets->where('assets.model_id', $request->input('by_model_id'));
|
||||
}
|
||||
|
||||
if ($request->has('by_category_id')) {
|
||||
$assets->InCategory($request->input('by_category_id'));
|
||||
}
|
||||
|
||||
if ($request->has('by_manufacturer_id')) {
|
||||
$assets->ByManufacturer($request->input('by_manufacturer_id'));
|
||||
}
|
||||
|
||||
if ($request->has('by_order_number')) {
|
||||
$assets->where('assets.order_number', $request->input('by_order_number'));
|
||||
}
|
||||
|
||||
if ($request->has('by_status_id')) {
|
||||
$assets->where('assets.status_id', $request->input('by_status_id'));
|
||||
}
|
||||
|
||||
if (($request->has('purchase_start')) && ($request->has('purchase_end'))) {
|
||||
$assets->whereBetween('assets.purchase_date', [$request->input('purchase_start'), $request->input('purchase_end')]);
|
||||
}
|
||||
|
||||
if (($request->has('created_start')) && ($request->has('created_end'))) {
|
||||
$assets->whereBetween('assets.created_at', [$request->input('created_start'), $request->input('created_end')]);
|
||||
}
|
||||
|
||||
$assets->orderBy('assets.created_at', 'ASC')->chunk(500, function($assets) use($handle, $customfields, $request) {
|
||||
|
||||
foreach ($assets as $asset) {
|
||||
$row = [];
|
||||
|
||||
if ($request->has('company')) {
|
||||
$row[] = ($asset->company) ? $asset->company->name : '';
|
||||
}
|
||||
|
||||
if ($request->has('asset_name')) {
|
||||
$row[] = ($asset->name) ? $asset->name : '';
|
||||
}
|
||||
|
||||
if ($request->has('asset_tag')) {
|
||||
$row[] = ($asset->asset_tag) ? $asset->asset_tag : '';
|
||||
}
|
||||
|
||||
if ($request->has('model')) {
|
||||
$row[] = ($asset->model) ? $asset->model->name : '';
|
||||
$row[] = ($asset->model) ? $asset->model->model_number : '';
|
||||
}
|
||||
|
||||
if ($request->has('category')) {
|
||||
$row[] = (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : '';
|
||||
}
|
||||
|
||||
if ($request->has('manufacturer')) {
|
||||
$row[] = ($asset->model && $asset->model->manufacturer) ? $asset->model->manufacturer->name : '';
|
||||
}
|
||||
|
||||
if ($request->has('serial')) {
|
||||
$row[] = ($asset->serial) ? $asset->serial : '';
|
||||
}
|
||||
|
||||
if ($request->has('purchase_date')) {
|
||||
$row[] = ($asset->purchase_date) ? $asset->purchase_date : '';
|
||||
}
|
||||
|
||||
if ($request->has('purchase_cost')) {
|
||||
$row[] = ($asset->purchase_cost) ? Helper::formatCurrencyOutput($asset->purchase_cost) : '';
|
||||
}
|
||||
|
||||
if ($request->has('eol')) {
|
||||
$row[] = ($asset->purchase_date!='') ? $asset->present()->eol_date() : '';
|
||||
}
|
||||
|
||||
if ($request->has('order')) {
|
||||
$row[] = ($asset->order_number) ? $asset->order_number : '';
|
||||
}
|
||||
|
||||
if ($request->has('supplier')) {
|
||||
$row[] = ($asset->supplier) ? $asset->supplier->name : '';
|
||||
}
|
||||
|
||||
|
||||
if ($request->has('location')) {
|
||||
$row[] = ($asset->location) ? $asset->location->present()->name() : '';
|
||||
}
|
||||
|
||||
if ($request->has('assigned_to')) {
|
||||
$row[] = ($asset->checkedOutToUser() && $asset->assigned) ? e($asset->assigned->getFullNameAttribute()) : ($asset->assigned ? e($asset->assigned->display_name) : '');
|
||||
$row[] = ($asset->checkedOutToUser() && $asset->assigned) ? 'user' : e($asset->assignedType());
|
||||
}
|
||||
|
||||
if ($request->has('username')) {
|
||||
// Only works if we're checked out to a user, not anything else.
|
||||
if ($asset->checkedOutToUser()) {
|
||||
$row[] = ($asset->assignedto) ? $asset->assignedto->username : '';
|
||||
} else {
|
||||
$row[] = ''; // Empty string if unassigned
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->has('employee_num')) {
|
||||
// Only works if we're checked out to a user, not anything else.
|
||||
if ($asset->checkedOutToUser()) {
|
||||
$row[] = ($asset->assignedto) ? $asset->assignedto->employee_num : '';
|
||||
} else {
|
||||
$row[] = ''; // Empty string if unassigned
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->has('status')) {
|
||||
$row[] = ($asset->assetstatus) ? $asset->assetstatus->name.' ('.$asset->present()->statusMeta.')' : '';
|
||||
}
|
||||
|
||||
|
||||
if ($request->has('warranty')) {
|
||||
$row[] = ($asset->warranty_months) ? $asset->warranty_months : '';
|
||||
$row[] = $asset->present()->warrantee_expires();
|
||||
}
|
||||
|
||||
|
||||
if ($request->has('depreciation')) {
|
||||
$depreciation = $asset->getDepreciatedValue();
|
||||
$diff = ($asset->purchase_cost - $depreciation);
|
||||
$row[] = Helper::formatCurrencyOutput($depreciation);
|
||||
$row[] = Helper::formatCurrencyOutput($diff);
|
||||
}
|
||||
|
||||
if ($request->has('checkout_date')) {
|
||||
$row[] = ($asset->last_checkout) ? $asset->last_checkout : '';
|
||||
}
|
||||
|
||||
if ($request->has('expected_checkin')) {
|
||||
$row[] = ($asset->expected_checkin) ? $asset->expected_checkin : '';
|
||||
}
|
||||
|
||||
if ($request->has('created_at')) {
|
||||
$row[] = ($asset->created_at) ? $asset->created_at : '';
|
||||
}
|
||||
|
||||
if ($request->has('updated_at')) {
|
||||
$row[] = ($asset->updated_at) ? $asset->updated_at : '';
|
||||
}
|
||||
|
||||
if ($request->has('last_audit_date')) {
|
||||
$row[] = ($asset->last_audit_date) ? $asset->last_audit_date : '';
|
||||
}
|
||||
|
||||
if ($request->has('next_audit_date')) {
|
||||
$row[] = ($asset->next_audit_date) ? $asset->next_audit_date : '';
|
||||
}
|
||||
|
||||
if ($request->has('notes')) {
|
||||
$row[] = ($asset->notes) ? $asset->notes : '';
|
||||
}
|
||||
|
||||
foreach ($customfields as $customfield) {
|
||||
$column_name = $customfield->db_column_name();
|
||||
if ($request->has($customfield->db_column_name())) {
|
||||
$row[] = $asset->$column_name;
|
||||
}
|
||||
}
|
||||
fputcsv($handle, $row);
|
||||
}
|
||||
});
|
||||
|
||||
// Close the output stream
|
||||
fclose($handle);
|
||||
}, 200, [
|
||||
'Content-Type' => 'text/csv',
|
||||
'Content-Disposition'
|
||||
=> 'attachment; filename="custom-assets-report-'.date('Y-m-d-his').'.csv"',
|
||||
]);
|
||||
|
||||
return $response;
|
||||
|
||||
// spit out a csv
|
||||
if (array_filter($rows)) {
|
||||
$csv = implode($rows, "\n");
|
||||
$response = Response::make($csv, 200);
|
||||
$response->header('Content-Type', 'text/csv');
|
||||
$response->header('Content-disposition', 'attachment;filename='.date('Y-m-d-His').'-custom-asset-report.csv');
|
||||
|
||||
return $response;
|
||||
} else {
|
||||
return redirect()->to("reports/custom")
|
||||
->with('error', trans('admin/reports/message.error'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class SettingsController extends Controller
|
||||
|
||||
$start_settings['url_config'] = url('/');
|
||||
$start_settings['real_url'] = $pageURL;
|
||||
|
||||
|
||||
// Curl the .env file to make sure it's not accessible via a browser
|
||||
$ch = curl_init($protocol . $host.'/.env');
|
||||
curl_setopt($ch, CURLOPT_HEADER, true); // we want headers
|
||||
@@ -150,28 +150,31 @@ class SettingsController extends Controller
|
||||
|
||||
|
||||
$user = new User;
|
||||
$user->first_name = $data['first_name']= e(Input::get('first_name'));
|
||||
$user->last_name = e(Input::get('last_name'));
|
||||
$user->email = $data['email'] = e(Input::get('email'));
|
||||
$user->first_name = $data['first_name']= $request->input('first_name');
|
||||
$user->last_name = $request->input('last_name');
|
||||
$user->email = $data['email'] = $request->input('email');
|
||||
$user->activated = 1;
|
||||
$permissions = array('superuser' => 1);
|
||||
$user->permissions = json_encode($permissions);
|
||||
$user->username = $data['username'] = e(Input::get('username'));
|
||||
$user->password = bcrypt(Input::get('password'));
|
||||
$data['password'] = Input::get('password');
|
||||
$user->username = $data['username'] = $request->input('username');
|
||||
$user->password = bcrypt($request->input('password'));
|
||||
$data['password'] = $request->input('password');
|
||||
|
||||
$settings = new Setting;
|
||||
$settings->site_name = e(Input::get('site_name'));
|
||||
$settings->alert_email = e(Input::get('email'));
|
||||
$settings->full_multiple_companies_support = $request->input('full_multiple_companies_support', 0);
|
||||
$settings->site_name = $request->input('site_name');
|
||||
$settings->alert_email = $request->input('email');
|
||||
$settings->alerts_enabled = 1;
|
||||
$settings->pwd_secure_min = 10;
|
||||
$settings->brand = 1;
|
||||
$settings->locale = 'en';
|
||||
$settings->default_currency = 'USD';
|
||||
$settings->locale = $request->input('locale', 'en');
|
||||
$settings->default_currency = $request->input('default_currency', "USD");
|
||||
$settings->user_id = 1;
|
||||
$settings->email_domain = e(Input::get('email_domain'));
|
||||
$settings->email_format = e(Input::get('email_format'));
|
||||
$settings->email_domain = $request->input('email_domain');
|
||||
$settings->email_format = $request->input('email_format');
|
||||
$settings->next_auto_tag_base = 1;
|
||||
$settings->auto_increment_assets = $request->input('auto_increment_assets', 0);
|
||||
$settings->auto_increment_prefix = $request->input('auto_increment_prefix');
|
||||
|
||||
|
||||
if ((!$user->isValid()) || (!$settings->isValid())) {
|
||||
@@ -311,8 +314,18 @@ class SettingsController extends Controller
|
||||
return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error'));
|
||||
}
|
||||
|
||||
$setting->modellist_displays = '';
|
||||
|
||||
if (($request->has('show_in_model_list')) && (count($request->input('show_in_model_list')) > 0))
|
||||
{
|
||||
$setting->modellist_displays = implode(',', $request->input('show_in_model_list'));
|
||||
}
|
||||
|
||||
|
||||
$setting->full_multiple_companies_support = $request->input('full_multiple_companies_support', '0');
|
||||
$setting->load_remote = $request->input('load_remote', '0');
|
||||
$setting->show_archived_in_list = $request->input('show_archived_in_list', '0');
|
||||
$setting->dashboard_message = $request->input('dashboard_message');
|
||||
$setting->email_domain = $request->input('email_domain');
|
||||
$setting->email_format = $request->input('email_format');
|
||||
$setting->username_format = $request->input('username_format');
|
||||
@@ -370,6 +383,8 @@ class SettingsController extends Controller
|
||||
|
||||
$setting->brand = $request->input('brand', '1');
|
||||
$setting->header_color = $request->input('header_color');
|
||||
$setting->support_footer = $request->input('support_footer');
|
||||
$setting->footer_text = $request->input('footer_text');
|
||||
$setting->show_url_in_emails = $request->input('show_url_in_emails', '0');
|
||||
|
||||
|
||||
@@ -552,6 +567,7 @@ class SettingsController extends Controller
|
||||
$setting->alert_threshold = $request->input('alert_threshold');
|
||||
$setting->audit_interval = $request->input('audit_interval');
|
||||
$setting->audit_warning_days = $request->input('audit_warning_days');
|
||||
$setting->show_alerts_in_menu = $request->input('show_alerts_in_menu', '0');
|
||||
|
||||
if ($setting->save()) {
|
||||
return redirect()->route('settings.index')
|
||||
@@ -747,6 +763,7 @@ class SettingsController extends Controller
|
||||
$setting->labels_fontsize = $request->input('labels_fontsize');
|
||||
$setting->labels_pagewidth = $request->input('labels_pagewidth');
|
||||
$setting->labels_pageheight = $request->input('labels_pageheight');
|
||||
$setting->labels_display_company_name = $request->input('labels_display_company_name', '0');
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -32,12 +32,13 @@ class StatuslabelsController extends Controller
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->authorize('view', Statuslabel::class);
|
||||
return view('statuslabels.index', compact('statuslabels'));
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
$this->authorize('view', Statuslabel::class);
|
||||
if ($statuslabel = Statuslabel::find($id)) {
|
||||
return view('statuslabels.view')->with('statuslabel', $statuslabel);
|
||||
}
|
||||
@@ -55,6 +56,7 @@ class StatuslabelsController extends Controller
|
||||
public function create()
|
||||
{
|
||||
// Show the page
|
||||
$this->authorize('create', Statuslabel::class);
|
||||
$item = new Statuslabel;
|
||||
$use_statuslabel_type = $item->getStatuslabelType();
|
||||
$statuslabel_types = Helper::statusTypeList();
|
||||
@@ -72,6 +74,7 @@ class StatuslabelsController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
|
||||
$this->authorize('create', Statuslabel::class);
|
||||
// create a new model instance
|
||||
$statusLabel = new Statuslabel();
|
||||
|
||||
@@ -106,6 +109,7 @@ class StatuslabelsController extends Controller
|
||||
*/
|
||||
public function apiStore(Request $request)
|
||||
{
|
||||
$this->authorize('create', Statuslabel::class);
|
||||
$statuslabel = new Statuslabel();
|
||||
if (!$request->has('statuslabel_types')) {
|
||||
return JsonResponse::create(["error" => trans('validation.statuslabel_type')], 500);
|
||||
@@ -137,6 +141,7 @@ class StatuslabelsController extends Controller
|
||||
*/
|
||||
public function edit($statuslabelId = null)
|
||||
{
|
||||
$this->authorize('update', Statuslabel::class);
|
||||
// Check if the Statuslabel exists
|
||||
if (is_null($item = Statuslabel::find($statuslabelId))) {
|
||||
// Redirect to the blogs management page
|
||||
@@ -159,6 +164,7 @@ class StatuslabelsController extends Controller
|
||||
*/
|
||||
public function update(Request $request, $statuslabelId = null)
|
||||
{
|
||||
$this->authorize('update', Statuslabel::class);
|
||||
// Check if the Statuslabel exists
|
||||
if (is_null($statuslabel = Statuslabel::find($statuslabelId))) {
|
||||
// Redirect to the blogs management page
|
||||
@@ -197,6 +203,7 @@ class StatuslabelsController extends Controller
|
||||
*/
|
||||
public function destroy($statuslabelId)
|
||||
{
|
||||
$this->authorize('delete', Statuslabel::class);
|
||||
// Check if the Statuslabel exists
|
||||
if (is_null($statuslabel = Statuslabel::find($statuslabelId))) {
|
||||
return redirect()->route('statuslabels.index')->with('error', trans('admin/statuslabels/message.not_found'));
|
||||
|
||||
@@ -33,6 +33,7 @@ class SuppliersController extends Controller
|
||||
public function index()
|
||||
{
|
||||
// Grab all the suppliers
|
||||
$this->authorize('view', Supplier::class);
|
||||
$suppliers = Supplier::orderBy('created_at', 'DESC')->get();
|
||||
|
||||
// Show the page
|
||||
@@ -47,6 +48,7 @@ class SuppliersController extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$this->authorize('create', Supplier::class);
|
||||
return view('suppliers/edit')->with('item', new Supplier);
|
||||
}
|
||||
|
||||
@@ -59,6 +61,7 @@ class SuppliersController extends Controller
|
||||
*/
|
||||
public function store(ImageUploadRequest $request)
|
||||
{
|
||||
$this->authorize('create', Supplier::class);
|
||||
// Create a new supplier
|
||||
$supplier = new Supplier;
|
||||
// Save the location data
|
||||
@@ -100,6 +103,7 @@ class SuppliersController extends Controller
|
||||
*/
|
||||
public function apiStore(Request $request)
|
||||
{
|
||||
$this->authorize('create', Supplier::class);
|
||||
$supplier = new Supplier;
|
||||
$supplier->name = $request->input('name');
|
||||
$supplier->user_id = Auth::id();
|
||||
@@ -118,6 +122,7 @@ class SuppliersController extends Controller
|
||||
*/
|
||||
public function edit($supplierId = null)
|
||||
{
|
||||
$this->authorize('edit', Supplier::class);
|
||||
// Check if the supplier exists
|
||||
if (is_null($item = Supplier::find($supplierId))) {
|
||||
// Redirect to the supplier page
|
||||
@@ -137,6 +142,7 @@ class SuppliersController extends Controller
|
||||
*/
|
||||
public function update($supplierId = null, ImageUploadRequest $request)
|
||||
{
|
||||
$this->authorize('edit', Supplier::class);
|
||||
// Check if the supplier exists
|
||||
if (is_null($supplier = Supplier::find($supplierId))) {
|
||||
// Redirect to the supplier page
|
||||
@@ -159,19 +165,38 @@ class SuppliersController extends Controller
|
||||
$supplier->notes = request('notes');
|
||||
|
||||
|
||||
if ($request->file('image')) {
|
||||
$image = $request->file('image');
|
||||
$file_name = str_random(25).".".$image->getClientOriginalExtension();
|
||||
$path = public_path('uploads/suppliers/'.$file_name);
|
||||
Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save($path);
|
||||
$supplier->image = $file_name;
|
||||
} elseif ($request->input('image_delete')=='1') {
|
||||
$old_image = $supplier->image;
|
||||
|
||||
// Set the model's image property to null if the image is being deleted
|
||||
if ($request->input('image_delete') == 1) {
|
||||
$supplier->image = null;
|
||||
}
|
||||
|
||||
if ($request->file('image')) {
|
||||
$image = $request->file('image');
|
||||
$file_name = $supplier->id.'-'.str_slug($image->getClientOriginalName()) . "." . $image->getClientOriginalExtension();
|
||||
|
||||
if ($image->getClientOriginalExtension()!='svg') {
|
||||
Image::make($image->getRealPath())->resize(500, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save(app('suppliers_upload_path').$file_name);
|
||||
} else {
|
||||
$image->move(app('suppliers_upload_path'), $file_name);
|
||||
}
|
||||
$supplier->image = $file_name;
|
||||
|
||||
}
|
||||
|
||||
if ((($request->file('image')) && (isset($old_image)) && ($old_image!='')) || ($request->input('image_delete') == 1)) {
|
||||
try {
|
||||
unlink(app('suppliers_upload_path').$old_image);
|
||||
} catch (\Exception $e) {
|
||||
\Log::error($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($supplier->save()) {
|
||||
return redirect()->route('suppliers.index')->with('success', trans('admin/suppliers/message.update.success'));
|
||||
}
|
||||
@@ -188,6 +213,7 @@ class SuppliersController extends Controller
|
||||
*/
|
||||
public function destroy($supplierId)
|
||||
{
|
||||
$this->authorize('delete', Supplier::class);
|
||||
if (is_null($supplier = Supplier::with('asset_maintenances', 'assets', 'licenses')->withCount('asset_maintenances','assets','licenses')->find($supplierId))) {
|
||||
return redirect()->route('suppliers.index')->with('error', trans('admin/suppliers/message.not_found'));
|
||||
}
|
||||
@@ -232,7 +258,7 @@ class SuppliersController extends Controller
|
||||
$error = trans('admin/suppliers/message.does_not_exist', compact('id'));
|
||||
|
||||
// Redirect to the user management page
|
||||
return redirect()->route('suppliers')->with('error', $error);
|
||||
return redirect()->route('suppliers.index')->with('error', $error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -106,7 +106,6 @@ class UsersController extends Controller
|
||||
$user->password = bcrypt($request->input('password'));
|
||||
$data['password'] = $request->input('password');
|
||||
}
|
||||
// Update the user
|
||||
$user->first_name = $request->input('first_name');
|
||||
$user->last_name = $request->input('last_name');
|
||||
$user->locale = $request->input('locale');
|
||||
@@ -278,6 +277,10 @@ class UsersController extends Controller
|
||||
try {
|
||||
|
||||
$user = User::find($id);
|
||||
|
||||
if ($user->id == $request->input('manager_id')) {
|
||||
return redirect()->back()->withInput()->with('error', 'You cannot be your own manager.');
|
||||
}
|
||||
$this->authorize('update', $user);
|
||||
// Figure out of this user was an admin before this edit
|
||||
$orig_permissions_array = $user->decodePermissions();
|
||||
@@ -428,7 +431,7 @@ class UsersController extends Controller
|
||||
public function postBulkEdit(Request $request)
|
||||
{
|
||||
$this->authorize('update', User::class);
|
||||
if ((!Input::has('ids')) || (count(Input::has('ids')) == 0)) {
|
||||
if ((!Input::has('ids')) || (count(Input::input('ids')) == 0)) {
|
||||
return redirect()->back()->with('error', 'No users selected');
|
||||
} else {
|
||||
|
||||
@@ -458,7 +461,7 @@ class UsersController extends Controller
|
||||
public function postBulkEditSave(Request $request)
|
||||
{
|
||||
$this->authorize('update', User::class);
|
||||
if ((!Input::has('ids')) || (count(Input::has('ids')) == 0)) {
|
||||
if ((!Input::has('ids')) || (count(Input::input('ids')) == 0)) {
|
||||
return redirect()->back()->with('error', 'No users selected');
|
||||
} else {
|
||||
|
||||
@@ -477,6 +480,11 @@ class UsersController extends Controller
|
||||
if ($request->has('company_id')) {
|
||||
$update_array['company_id'] = $request->input('company_id');
|
||||
}
|
||||
if ($request->has('locale')) {
|
||||
$update_array['locale'] = $request->input('locale');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($request->has('manager_id')) {
|
||||
|
||||
@@ -1060,7 +1068,7 @@ class UsersController extends Controller
|
||||
// Open output stream
|
||||
$handle = fopen('php://output', 'w');
|
||||
|
||||
User::with('assets', 'accessories', 'consumables', 'licenses', 'manager', 'groups', 'userloc', 'company','throttle')->orderBy('created_at', 'DESC')->chunk(500, function($users) use($handle) {
|
||||
User::with('assets', 'accessories', 'consumables', 'department', 'licenses', 'manager', 'groups', 'userloc', 'company','throttle')->orderBy('created_at', 'DESC')->chunk(500, function($users) use($handle) {
|
||||
$headers=[
|
||||
// strtolower to prevent Excel from trying to open it as a SYLK file
|
||||
strtolower(trans('general.id')),
|
||||
@@ -1072,6 +1080,7 @@ class UsersController extends Controller
|
||||
trans('admin/users/table.email'),
|
||||
trans('admin/users/table.manager'),
|
||||
trans('admin/users/table.location'),
|
||||
trans('general.department'),
|
||||
trans('general.assets'),
|
||||
trans('general.licenses'),
|
||||
trans('general.accessories'),
|
||||
@@ -1102,6 +1111,7 @@ class UsersController extends Controller
|
||||
$user->email,
|
||||
($user->manager) ? $user->manager->present()->fullName() : '',
|
||||
($user->userloc) ? $user->userloc->name : '',
|
||||
($user->department) ? $user->department->name : '',
|
||||
$user->assets->count(),
|
||||
$user->licenses->count(),
|
||||
$user->accessories->count(),
|
||||
@@ -1144,4 +1154,24 @@ class UsersController extends Controller
|
||||
return response()->json(['message' => trans('admin/settings/general.two_factor_reset_error')], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* LDAP form processing.
|
||||
*
|
||||
* @author Aladin Alaily
|
||||
* @since [v1.8]
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function printInventory($id)
|
||||
{
|
||||
|
||||
$show_user = User::where('id',$id)->withTrashed()->first();
|
||||
$assets = Asset::where('assigned_to', $id)->where('assigned_type', User::class)->with('model', 'model.category')->get();
|
||||
$licenses = $show_user->licenses()->get();
|
||||
$accessories = $show_user->accessories()->get();
|
||||
$consumables = $show_user->consumables()->get();
|
||||
return view('users/print')->with('assets', $assets)->with('licenses',$licenses)->with('accessories', $accessories)->with('consumables', $consumables)->with('show_user', $show_user);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -284,9 +284,10 @@ class ViewAssetsController extends Controller
|
||||
public function getAcceptAsset($logID = null)
|
||||
{
|
||||
|
||||
if (!$findlog = Actionlog::where('id', $logID)->first()) {
|
||||
echo 'no record';
|
||||
//return redirect()->to('account')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||
$findlog = Actionlog::where('id', $logID)->first();
|
||||
|
||||
if (!$findlog) {
|
||||
return redirect()->to('account/view-assets')->with('error', 'No matching record.');
|
||||
}
|
||||
|
||||
if ($findlog->accepted_id!='') {
|
||||
|
||||
@@ -24,9 +24,10 @@ class AssetCheckoutRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
$rules = [
|
||||
"assigned_user" => 'required_without_all:assigned_asset,assigned_location',
|
||||
"assigned_asset" => 'required_without_all:assigned_user,assigned_location|different:'.$this->id,
|
||||
"assigned_location" => 'required_without_all:assigned_user,assigned_asset',
|
||||
"assigned_user" => 'required_without_all:assigned_asset,assigned_location',
|
||||
"assigned_asset" => 'required_without_all:assigned_user,assigned_location|different:'.$this->id,
|
||||
"assigned_location" => 'required_without_all:assigned_user,assigned_asset',
|
||||
"checkout_to_type" => 'required|in:asset,location,user'
|
||||
];
|
||||
|
||||
|
||||
|
||||
@@ -36,13 +36,16 @@ class AssetRequest extends Request
|
||||
'checkin_date' => 'date',
|
||||
'supplier_id' => 'integer|nullable',
|
||||
'status' => 'integer|nullable',
|
||||
'asset_tag' => 'required',
|
||||
'purchase_cost' => 'numeric|nullable',
|
||||
"assigned_user" => 'sometimes:required_without_all:assigned_asset,assigned_location',
|
||||
"assigned_asset" => 'sometimes:required_without_all:assigned_user,assigned_location',
|
||||
"assigned_location" => 'sometimes:required_without_all:assigned_user,assigned_asset',
|
||||
];
|
||||
|
||||
$settings = \App\Models\Setting::getSettings();
|
||||
|
||||
$rules['asset_tag'] = ($settings->auto_increment_assets == '1') ? 'max:255' : 'required';
|
||||
|
||||
$model = AssetModel::find($this->request->get('model_id'));
|
||||
|
||||
if (($model) && ($model->fieldset)) {
|
||||
|
||||
59
app/Http/Requests/CustomFieldRequest.php
Normal file
59
app/Http/Requests/CustomFieldRequest.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CustomFieldRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(Request $request)
|
||||
{
|
||||
|
||||
$rules = [];
|
||||
|
||||
switch($this->method())
|
||||
{
|
||||
|
||||
// Brand new
|
||||
case 'POST':
|
||||
{
|
||||
$rules['name'] = "required|unique:custom_fields";
|
||||
break;
|
||||
}
|
||||
|
||||
// Save all fields
|
||||
case 'PUT':
|
||||
$rules['name'] = "required";
|
||||
break;
|
||||
|
||||
// Save only what's passed
|
||||
case 'PATCH':
|
||||
{
|
||||
$rules['name'] = "required";
|
||||
break;
|
||||
}
|
||||
|
||||
default:break;
|
||||
}
|
||||
|
||||
$rules['custom_format'] = 'valid_regex';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,8 @@ class ImageUploadRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'image' => 'mimes:png,gif,jpg,jpeg,svg|max:2000'
|
||||
'image' => 'mimes:png,gif,jpg,jpeg,svg|max:2000',
|
||||
'avatar' => 'mimes:png,gif,jpg,jpeg,svg|max:2000',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class ItemImportRequest extends FormRequest
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
'import-type' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class ActionlogsTransformer
|
||||
] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($actionlog->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($actionlog->updated_at, 'datetime'),
|
||||
'next_audit_date' => ($actionlog->itemType()=='asset') ? Helper::getFormattedDateObject($actionlog->calcNextAuditDate(), 'date'): null,
|
||||
'next_audit_date' => ($actionlog->itemType()=='asset') ? Helper::getFormattedDateObject($actionlog->calcNextAuditDate(null, $actionlog->item), 'date'): null,
|
||||
'days_to_next_audit' => $actionlog->daysUntilNextAudit($settings->audit_interval, $actionlog->item),
|
||||
'action_type' => $actionlog->present()->actionType(),
|
||||
'admin' => ($actionlog->user) ? [
|
||||
@@ -54,6 +54,7 @@ class ActionlogsTransformer
|
||||
|
||||
'note' => ($actionlog->note) ? e($actionlog->note): null,
|
||||
'signature_file' => ($actionlog->accept_signature) ? route('log.signature.view', ['filename' => $actionlog->accept_signature ]) : null,
|
||||
'log_meta' => ($actionlog->log_meta) ? json_decode($actionlog->log_meta): null,
|
||||
|
||||
|
||||
];
|
||||
|
||||
@@ -28,7 +28,7 @@ class AssetModelsTransformer
|
||||
'id' => (int) $assetmodel->manufacturer->id,
|
||||
'name'=> e($assetmodel->manufacturer->name)
|
||||
] : null,
|
||||
'image' => ($assetmodel->image!='') ? url('/').'/uploads/models/'.e($assetmodel->image) : null,
|
||||
'image' => ($assetmodel->image!='') ? app('models_upload_url').e($assetmodel->image) : null,
|
||||
'model_number' => e($assetmodel->model_number),
|
||||
'depreciation' => ($assetmodel->depreciation) ? [
|
||||
'id' => (int) $assetmodel->depreciation->id,
|
||||
@@ -53,7 +53,7 @@ class AssetModelsTransformer
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
'update' => (Gate::allows('update', AssetModel::class) && ($assetmodel->deleted_at=='')) ? true : false,
|
||||
'delete' => (Gate::allows('delete', AssetModel::class) && ($assetmodel->deleted_at=='')) ? true : false,
|
||||
'delete' => (Gate::allows('delete', AssetModel::class) && ($assetmodel->assets_count==0) && ($assetmodel->deleted_at=='')) ? true : false,
|
||||
'clone' => (Gate::allows('create', AssetModel::class) && ($assetmodel->deleted_at=='')) ,
|
||||
'restore' => (Gate::allows('create', AssetModel::class) && ($assetmodel->deleted_at!='')) ? true : false,
|
||||
];
|
||||
|
||||
@@ -31,16 +31,18 @@ class AssetsTransformer
|
||||
'name'=> e($asset->model->name)
|
||||
] : null,
|
||||
'model_number' => (($asset->model) && ($asset->model->model_number)) ? e($asset->model->model_number) : null,
|
||||
'eol' => ($asset->purchase_date!='') ? Helper::getFormattedDateObject($asset->present()->eol_date(), 'date') : null ,
|
||||
'status_label' => ($asset->assetstatus) ? [
|
||||
'id' => (int) $asset->assetstatus->id,
|
||||
'name'=> e($asset->present()->statusText),
|
||||
'status_meta' => e($asset->present()->statusMeta),
|
||||
'name'=> e($asset->assetstatus->name),
|
||||
'status_type'=> e($asset->assetstatus->getStatuslabelType()),
|
||||
'status_meta' => e($asset->present()->statusMeta),
|
||||
] : null,
|
||||
'category' => ($asset->model->category) ? [
|
||||
'category' => (($asset->model) && ($asset->model->category)) ? [
|
||||
'id' => (int) $asset->model->category->id,
|
||||
'name'=> e($asset->model->category->name)
|
||||
] : null,
|
||||
'manufacturer' => ($asset->model->manufacturer) ? [
|
||||
'manufacturer' => (($asset->model) && ($asset->model->manufacturer)) ? [
|
||||
'id' => (int) $asset->model->manufacturer->id,
|
||||
'name'=> e($asset->model->manufacturer->name)
|
||||
] : null,
|
||||
@@ -68,6 +70,8 @@ class AssetsTransformer
|
||||
'warranty_expires' => ($asset->warranty_months > 0) ? Helper::getFormattedDateObject($asset->warranty_expires, 'date') : null,
|
||||
'created_at' => Helper::getFormattedDateObject($asset->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($asset->updated_at, 'datetime'),
|
||||
'last_audit_date' => Helper::getFormattedDateObject($asset->last_audit_date, 'datetime'),
|
||||
'next_audit_date' => Helper::getFormattedDateObject($asset->next_audit_date, 'date'),
|
||||
'deleted_at' => Helper::getFormattedDateObject($asset->deleted_at, 'datetime'),
|
||||
'purchase_date' => Helper::getFormattedDateObject($asset->purchase_date, 'date'),
|
||||
'last_checkout' => Helper::getFormattedDateObject($asset->last_checkout, 'datetime'),
|
||||
@@ -77,7 +81,7 @@ class AssetsTransformer
|
||||
];
|
||||
|
||||
|
||||
if (($asset->model->fieldset) && (count($asset->model->fieldset->fields)> 0)) {
|
||||
if (($asset->model) && ($asset->model->fieldset) && (count($asset->model->fieldset->fields)> 0)) {
|
||||
$fields_array = array();
|
||||
|
||||
foreach ($asset->model->fieldset->fields as $field) {
|
||||
@@ -86,24 +90,21 @@ class AssetsTransformer
|
||||
$decrypted = \App\Helpers\Helper::gracefulDecrypt($field,$asset->{$field->convertUnicodeDbSlug()});
|
||||
$value = (Gate::allows('superadmin')) ? $decrypted : strtoupper(trans('admin/custom_fields/general.encrypted'));
|
||||
|
||||
// $fields_array = [$field->convertUnicodeDbSlug() => $value];
|
||||
|
||||
|
||||
$fields_array[$field->name] = [
|
||||
'field' => $field->convertUnicodeDbSlug(),
|
||||
'value' => $value
|
||||
'value' => $value,
|
||||
'field_format' => $field->format,
|
||||
];
|
||||
|
||||
} else {
|
||||
$fields_array[$field->name] = [
|
||||
'field' => $field->convertUnicodeDbSlug(),
|
||||
'value' => $asset->{$field->convertUnicodeDbSlug()}
|
||||
'value' => $asset->{$field->convertUnicodeDbSlug()},
|
||||
'field_format' => $field->format,
|
||||
];
|
||||
//$fields_array = [$field->convertUnicodeDbSlug() => $asset->{$field->convertUnicodeDbSlug()}];
|
||||
|
||||
|
||||
}
|
||||
//array += $fields_array;
|
||||
$array['custom_fields'] = $fields_array;
|
||||
}
|
||||
} else {
|
||||
@@ -114,10 +115,23 @@ class AssetsTransformer
|
||||
'checkout' => (bool) Gate::allows('checkout', Asset::class),
|
||||
'checkin' => (bool) Gate::allows('checkin', Asset::class),
|
||||
'clone' => Gate::allows('create', Asset::class) ? true : false,
|
||||
'restore' => false,
|
||||
'update' => (bool) Gate::allows('update', Asset::class),
|
||||
'delete' => (bool) Gate::allows('delete', Asset::class),
|
||||
];
|
||||
|
||||
if ($asset->deleted_at!='') {
|
||||
$permissions_array['available_actions'] = [
|
||||
'checkout' => true,
|
||||
'checkin' => false,
|
||||
'clone' => Gate::allows('create', Asset::class) ? true : false,
|
||||
'restore' => Gate::allows('create', Asset::class) ? true : false,
|
||||
'update' => false,
|
||||
'delete' => false,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
$array += $permissions_array;
|
||||
return $array;
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ class CategoriesTransformer
|
||||
$array = [
|
||||
'id' => (int) $category->id,
|
||||
'name' => e($category->name),
|
||||
'image' => ($category->image) ? e(url('/').'/uploads/categories/'.e($category->image)) : null,
|
||||
'type' => e($category->category_type),
|
||||
'image' => ($category->image) ? app('categories_upload_url').e($category->image) : null,
|
||||
'category_type' => e($category->category_type),
|
||||
'eula' => ($category->getEula()) ? true : false,
|
||||
'checkin_email' => ($category->checkin_email =='1') ? true : false,
|
||||
'require_acceptance' => ($category->require_acceptance =='1') ? true : false,
|
||||
|
||||
@@ -25,7 +25,7 @@ class CompaniesTransformer
|
||||
$array = [
|
||||
'id' => (int) $company->id,
|
||||
'name' => e($company->name),
|
||||
'image' => ($company->image) ? e(url('/').'/uploads/companies/'.e($company->image)) : null,
|
||||
'image' => ($company->image) ? app('companies_upload_url').e($company->image) : null,
|
||||
"created_at" => Helper::getFormattedDateObject($company->created_at, 'datetime'),
|
||||
"updated_at" => Helper::getFormattedDateObject($company->updated_at, 'datetime'),
|
||||
"assets_count" => (int) $company->assets_count,
|
||||
@@ -38,7 +38,7 @@ class CompaniesTransformer
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
'update' => Gate::allows('update', Company::class) ? true : false,
|
||||
'delete' => Gate::allows('delete', Company::class) ? true : false,
|
||||
'delete' => (Gate::allows('delete', Company::class) && ($company->assets_count == 0) && ($company->accessories_count == 0) && ($company->consumables_count == 0) && ($company->components_count == 0) && ($company->users_count == 0)) ? true : false,
|
||||
];
|
||||
|
||||
$array += $permissions_array;
|
||||
|
||||
@@ -23,7 +23,7 @@ class ComponentsTransformer
|
||||
'id' => (int) $component->id,
|
||||
'name' => e($component->name),
|
||||
'image' => ($component->image) ? e(url('/').'/uploads/components/'.e($component->image)) : null,
|
||||
'serial_number' => ($component->serial) ? e($component->serial) : null,
|
||||
'serial' => ($component->serial) ? e($component->serial) : null,
|
||||
'location' => ($component->location) ? [
|
||||
'id' => (int) $component->location->id,
|
||||
'name' => e($component->location->name)
|
||||
@@ -34,6 +34,10 @@ class ComponentsTransformer
|
||||
'id' => (int) $component->category->id,
|
||||
'name' => e($component->category->name)
|
||||
] : null,
|
||||
'location' => ($component->location) ? [
|
||||
'id' => (int) $component->location->id,
|
||||
'name' => e($component->location->name)
|
||||
] : null,
|
||||
'order_number' => e($component->order_number),
|
||||
'purchase_date' => Helper::getFormattedDateObject($component->purchase_date, 'date'),
|
||||
'purchase_cost' => Helper::formatCurrencyOutput($component->purchase_cost),
|
||||
|
||||
@@ -30,7 +30,7 @@ class ConsumablesTransformer
|
||||
'location' => ($consumable->location) ? ['id' => (int) $consumable->location->id, 'name' => e($consumable->location->name)] : null,
|
||||
'manufacturer' => ($consumable->manufacturer) ? ['id' => (int) $consumable->manufacturer->id, 'name' => e($consumable->manufacturer->name)] : null,
|
||||
'min_amt' => (int) $consumable->min_amt,
|
||||
'model_number' => e($consumable->model_number),
|
||||
'model_number' => ($consumable->model_number!='') ? e($consumable->model_number) : null,
|
||||
'remaining' => $consumable->numRemaining(),
|
||||
'order_number' => e($consumable->order_number),
|
||||
'purchase_cost' => Helper::formatCurrencyOutput($consumable->purchase_cost),
|
||||
|
||||
@@ -22,6 +22,7 @@ class CustomFieldsTransformer
|
||||
{
|
||||
|
||||
$array = [
|
||||
'id' => $field->id,
|
||||
'name' => e($field->name),
|
||||
'db_column_name' => e($field->db_column_name()),
|
||||
'format' => e($field->format),
|
||||
|
||||
@@ -25,7 +25,7 @@ class DepartmentsTransformer
|
||||
$array = [
|
||||
'id' => (int) $department->id,
|
||||
'name' => e($department->name),
|
||||
'image' => ($department->image) ? e(url('/').'/uploads/departments/'.e($department->image)) : null,
|
||||
'image' => ($department->image) ? app('departments_upload_url').e($department->image) : null,
|
||||
'company' => ($department->company) ? [
|
||||
'id' => (int) $department->company->id,
|
||||
'name'=> e($department->company->name)
|
||||
@@ -47,7 +47,7 @@ class DepartmentsTransformer
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
'update' => Gate::allows('update', Department::class) ? true : false,
|
||||
'delete' => Gate::allows('delete', Department::class) ? true : false,
|
||||
'delete' => (Gate::allows('delete', Department::class) && ($department->users_count==0) && ($department->deleted_at=='')) ? true : false,
|
||||
];
|
||||
|
||||
$array += $permissions_array;
|
||||
|
||||
62
app/Http/Transformers/LicenseSeatsTransformer.php
Normal file
62
app/Http/Transformers/LicenseSeatsTransformer.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace App\Http\Transformers;
|
||||
|
||||
use App\Models\LicenseSeat;
|
||||
use Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use App\Helpers\Helper;
|
||||
|
||||
class LicenseSeatsTransformer
|
||||
{
|
||||
|
||||
public function transformLicenseSeats (Collection $seats, $total)
|
||||
{
|
||||
$array = array();
|
||||
$seat_count = 0;
|
||||
foreach ($seats as $seat) {
|
||||
$seat_count++;
|
||||
$array[] = self::transformLicenseSeat($seat, $seat_count);
|
||||
}
|
||||
return (new DatatablesTransformer)->transformDatatables($array, $total);
|
||||
}
|
||||
|
||||
public function transformLicenseSeat (LicenseSeat $seat, $seat_count)
|
||||
{
|
||||
$array = [
|
||||
'id' => (int) $seat->id,
|
||||
'license_id' => (int) $seat->license->id,
|
||||
'name' => 'Seat '.$seat_count,
|
||||
'assigned_user' => ($seat->user) ? [
|
||||
'id' => (int) $seat->user->id,
|
||||
'name'=> e($seat->user->present()->fullName)
|
||||
] : null,
|
||||
'assigned_asset' => ($seat->asset) ? [
|
||||
'id' => (int) $seat->asset->id,
|
||||
'name'=> e($seat->asset->present()->fullName)
|
||||
] : null,
|
||||
'location' => ($seat->location()) ? [
|
||||
'id' => (int) $seat->location()->id,
|
||||
'name'=> e($seat->location()->name)
|
||||
] : null,
|
||||
'reassignable' => (bool) $seat->license->reassignable,
|
||||
'user_can_checkout' => (($seat->assigned_to=='') && ($seat->asset_id=='')) ? true : false,
|
||||
];
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
'checkout' => Gate::allows('checkout', License::class) ? true : false,
|
||||
'checkin' => Gate::allows('checkin', License::class) ? true : false,
|
||||
'clone' => Gate::allows('create', License::class) ? true : false,
|
||||
'update' => Gate::allows('update', License::class) ? true : false,
|
||||
'delete' => Gate::allows('delete', License::class) ? true : false,
|
||||
];
|
||||
|
||||
$array += $permissions_array;
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -25,25 +25,22 @@ class LicensesTransformer
|
||||
'name' => e($license->name),
|
||||
'company' => ($license->company) ? ['id' => (int) $license->company->id,'name'=> e($license->company->name)] : null,
|
||||
'manufacturer' => ($license->manufacturer) ? ['id' => (int) $license->manufacturer->id,'name'=> e($license->manufacturer->name)] : null,
|
||||
'product_key' => e($license->serial),
|
||||
'product_key' => (Gate::allows('viewKeys', License::class)) ? e($license->serial) : '------------',
|
||||
'order_number' => e($license->order_number),
|
||||
'purchase_order' => e($license->purchase_order),
|
||||
'purchase_date' => Helper::getFormattedDateObject($license->purchase_date, 'date'),
|
||||
'purchase_cost' => e($license->purchase_cost),
|
||||
'depreciation' => ($license->depreciation) ? ['id' => (int) $license->depreciation->id,'name'=> e($license->depreciation->name)] : null,
|
||||
'notes' => e($license->notes),
|
||||
'expiration_date' => Helper::getFormattedDateObject($license->expiration_date, 'date'),
|
||||
'total_seats' => (int) $license->seats,
|
||||
'next_seat' => ($license->freeSeat()) ? (int) $license->freeSeat()->id : null,
|
||||
'remaining_qty' => (int) $license->remaincount(),
|
||||
'min_qty' => $license->remaincount(),
|
||||
'seats' => (int) $license->seats,
|
||||
'free_seats_count' => (int) $license->free_seats_count,
|
||||
'license_name' => e($license->license_name),
|
||||
'license_email' => e($license->license_email),
|
||||
'maintained' => ($license->maintained == 1) ? true : false,
|
||||
'supplier' => ($license->supplier) ? ['id' => (int) $license->supplier->id,'name'=> e($license->supplier->name)] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($license->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($license->updated_at, 'datetime'),
|
||||
'user_can_checkout' => (bool) ($license->remaincount() > 0),
|
||||
'user_can_checkout' => (bool) ($license->free_seats_count > 0),
|
||||
];
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
|
||||
@@ -33,16 +33,17 @@ class LocationsTransformer
|
||||
$array = [
|
||||
'id' => (int) $location->id,
|
||||
'name' => e($location->name),
|
||||
'image' => ($location->image) ? e(url('/').'/uploads/locations/'.e($location->image)) : null,
|
||||
'address' => e($location->address),
|
||||
'city' => e($location->city),
|
||||
'state' => e($location->state),
|
||||
'country' => e($location->country),
|
||||
'zip' => e($location->zip),
|
||||
'assets_count' => (int) $location->assets_count,
|
||||
'rtd_assets_count' => (int) $location->rtd_assets_count,
|
||||
'image' => ($location->image) ? app('locations_upload_url').e($location->image) : null,
|
||||
'address' => ($location->address) ? e($location->address) : null,
|
||||
'address2' => ($location->address2) ? e($location->address2) : null,
|
||||
'city' => ($location->city) ? e($location->city) : null,
|
||||
'state' => ($location->state) ? e($location->state) : null,
|
||||
'country' => ($location->country) ? e($location->country) : null,
|
||||
'zip' => ($location->zip) ? e($location->zip) : null,
|
||||
'assigned_assets_count' => (int) $location->assigned_assets_count,
|
||||
'assets_count' => (int) $location->assets_count,
|
||||
'users_count' => (int) $location->users_count,
|
||||
|
||||
'currency' => ($location->currency) ? e($location->currency) : null,
|
||||
'created_at' => Helper::getFormattedDateObject($location->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($location->updated_at, 'datetime'),
|
||||
'parent' => ($location->parent) ? [
|
||||
@@ -57,7 +58,7 @@ class LocationsTransformer
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
'update' => Gate::allows('update', Location::class) ? true : false,
|
||||
'delete' => Gate::allows('delete', Location::class) ? true : false,
|
||||
'delete' => (Gate::allows('delete', Location::class) && ($location->assigned_assets_count==0) && ($location->assets_count==0) && ($location->users_count==0) && ($location->deleted_at=='')) ? true : false,
|
||||
];
|
||||
|
||||
$array += $permissions_array;
|
||||
|
||||
@@ -26,7 +26,7 @@ class ManufacturersTransformer
|
||||
'id' => (int) $manufacturer->id,
|
||||
'name' => e($manufacturer->name),
|
||||
'url' => e($manufacturer->url),
|
||||
'image' => ($manufacturer->image) ? e(url('/').'/uploads/manufacturers/'.e($manufacturer->image)) : null,
|
||||
'image' => ($manufacturer->image) ? app('manufacturers_upload_url').e($manufacturer->image) : null,
|
||||
'support_url' => e($manufacturer->support_url),
|
||||
'support_phone' => e($manufacturer->support_phone),
|
||||
'support_email' => e($manufacturer->support_email),
|
||||
@@ -40,7 +40,7 @@ class ManufacturersTransformer
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
'update' => Gate::allows('update', Manufacturer::class) ? true : false,
|
||||
'delete' => Gate::allows('delete', Manufacturer::class) ? true : false,
|
||||
'delete' => (Gate::allows('delete', Manufacturer::class) && ($manufacturer->assets_count == 0) && ($manufacturer->licenses_count==0) && ($manufacturer->consumables_count==0) && ($manufacturer->accessories_count==0) && ($manufacturer->deleted_at=='')) ? true : false,
|
||||
];
|
||||
|
||||
$array += $permissions_array;
|
||||
|
||||
@@ -19,7 +19,7 @@ class SelectlistTransformer
|
||||
|
||||
public function transformSelectlist (LengthAwarePaginator $select_items)
|
||||
{
|
||||
$items_array = [];
|
||||
$items_array=[];
|
||||
|
||||
// Loop through the paginated collection to set the array values
|
||||
foreach ($select_items as $select_item) {
|
||||
@@ -32,6 +32,12 @@ class SelectlistTransformer
|
||||
|
||||
}
|
||||
|
||||
// This is weird and awful, but the only way I can find to allow the user to
|
||||
// clear the selection - @snipe
|
||||
if (count($items_array) > 0) {
|
||||
array_unshift($items_array, ['id' =>'', 'text'=> trans('general.clear_selection')]);
|
||||
}
|
||||
|
||||
$results = [
|
||||
'items' => $items_array,
|
||||
'pagination' =>
|
||||
|
||||
@@ -25,7 +25,7 @@ class SuppliersTransformer
|
||||
$array = [
|
||||
'id' => (int) $supplier->id,
|
||||
'name' => e($supplier->name),
|
||||
'image' => ($supplier->image) ? e(url('/').'/uploads/suppliers/'.e($supplier->image)) : null,
|
||||
'image' => ($supplier->image) ? app('suppliers_upload_url').e($supplier->image) : null,
|
||||
'address' => ($supplier->address) ? e($supplier->address) : null,
|
||||
'address2' => ($supplier->address2) ? e($supplier->address2) : null,
|
||||
'city' => ($supplier->city) ? e($supplier->city) : null,
|
||||
|
||||
@@ -25,8 +25,8 @@ class UsersTransformer
|
||||
'id' => (int) $user->id,
|
||||
'avatar' => e($user->present()->gravatar),
|
||||
'name' => e($user->first_name).' '.($user->last_name),
|
||||
'firstname' => e($user->first_name),
|
||||
'lastname' => e($user->last_name),
|
||||
'first_name' => e($user->first_name),
|
||||
'last_name' => e($user->last_name),
|
||||
'username' => e($user->username),
|
||||
'employee_num' => e($user->employee_num),
|
||||
'manager' => ($user->manager) ? [
|
||||
|
||||
@@ -41,6 +41,9 @@ class AccessoryImporter extends ItemImporter
|
||||
$this->log("No Matching Accessory, Creating a new one");
|
||||
$accessory = new Accessory();
|
||||
$accessory->fill($this->sanitizeItemForStoring($accessory));
|
||||
|
||||
//FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything.
|
||||
// $accessory->unsetEventDispatcher();
|
||||
if ($accessory->save()) {
|
||||
$accessory->logCreate('Imported using CSV Importer');
|
||||
$this->log('Accessory ' . $this->item["name"] . ' was created');
|
||||
|
||||
@@ -31,7 +31,9 @@ class AssetImporter extends ItemImporter
|
||||
$this->item['custom_fields'][$customField->db_column_name()] = $customFieldValue;
|
||||
$this->log('Custom Field '. $customField->name.': '.$customFieldValue);
|
||||
} else {
|
||||
$this->item['custom_fields'][$customField->db_column_name()] = '';
|
||||
// This removes custom fields when updating if the column doesn't exist in file.
|
||||
// Commented out becausee not sure if it's needed anywhere.
|
||||
// $this->item['custom_fields'][$customField->db_column_name()] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,25 +79,43 @@ class AssetImporter extends ItemImporter
|
||||
}
|
||||
|
||||
$this->item['asset_tag'] = $asset_tag;
|
||||
// By default we're set this to location_id in the item.
|
||||
|
||||
// We need to save the user if it exists so that we can checkout to user later.
|
||||
// Sanitizing the item will remove it.
|
||||
if(array_key_exists('user', $this->item)) {
|
||||
$user = $this->item['user'];
|
||||
}
|
||||
$item = $this->sanitizeItemForStoring($asset, $editingAsset);
|
||||
// The location id fetched by the csv reader is actually the rtd_location_id.
|
||||
// This will also set location_id, but then that will be overridden by the
|
||||
// checkout method if necessary below.
|
||||
if (isset($this->item["location_id"])) {
|
||||
$item['rtd_location_id'] = $this->item['location_id'];
|
||||
unset($item['location_id']);
|
||||
}
|
||||
|
||||
|
||||
if ($editingAsset) {
|
||||
$asset->update($item);
|
||||
} else {
|
||||
$asset->fill($item);
|
||||
}
|
||||
|
||||
// If we're updating, we don't want to overwrite old fields.
|
||||
if (array_key_exists('custom_fields', $this->item)) {
|
||||
foreach ($this->item['custom_fields'] as $custom_field => $val) {
|
||||
$asset->{$custom_field} = $val;
|
||||
}
|
||||
}
|
||||
//FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything.
|
||||
// $asset->unsetEventDispatcher();
|
||||
if ($asset->save()) {
|
||||
$asset->logCreate('Imported using csv importer');
|
||||
$this->log('Asset ' . $this->item["name"] . ' with serial number ' . $this->item['serial'] . ' was created');
|
||||
|
||||
// If we have a user to checkout to, lets do so.
|
||||
if(isset($user)) {
|
||||
$asset->fresh()->checkOut($user);
|
||||
}
|
||||
return;
|
||||
}
|
||||
$this->logError($asset, 'Asset "' . $this->item['name'].'"');
|
||||
|
||||
@@ -27,27 +27,27 @@ class ComponentImporter extends ItemImporter
|
||||
public function createComponentIfNotExists()
|
||||
{
|
||||
$component = null;
|
||||
$editingComponent = false;
|
||||
$this->log("Creating Component");
|
||||
$component = Component::where('name', $this->item['name']);
|
||||
$component = Component::where('name', $this->item['name'])
|
||||
->where('serial', $this->item['serial'])
|
||||
->first();
|
||||
|
||||
if ($component) {
|
||||
$editingComponent = true;
|
||||
$this->log('A matching Component ' . $this->item["name"] . ' already exists. ');
|
||||
$this->log('A matching Component ' . $this->item["name"] . ' with serial ' .$this->item['serial'].' already exists. ');
|
||||
if (!$this->updating) {
|
||||
$this->log("Skipping Component");
|
||||
return;
|
||||
}
|
||||
$this->log("Updating Component");
|
||||
$component = $this->components[$componentId];
|
||||
$component->update($this->sanitizeItemFor($component));
|
||||
$component->update($this->sanitizeItemForUpdating($component));
|
||||
$component->save();
|
||||
return;
|
||||
}
|
||||
$this->log("No matching component, creating one");
|
||||
$component = new Component;
|
||||
$component->fill($$this->sanitizeItemForStoring($component));
|
||||
|
||||
$component->fill($this->sanitizeItemForStoring($component));
|
||||
//FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything.
|
||||
$component->unsetEventDispatcher();
|
||||
if ($component->save()) {
|
||||
$component->logCreate('Imported using CSV Importer');
|
||||
$this->log("Component " . $this->item["name"] . ' was created');
|
||||
|
||||
@@ -40,6 +40,8 @@ class ConsumableImporter extends ItemImporter
|
||||
$this->log("No matching consumable, creating one");
|
||||
$consumable = new Consumable();
|
||||
$consumable->fill($this->sanitizeItemForStoring($consumable));
|
||||
//FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything.
|
||||
$consumable->unsetEventDispatcher();
|
||||
if ($consumable->save()) {
|
||||
$consumable->logCreate('Imported using CSV Importer');
|
||||
$this->log("Consumable " . $this->item["name"] . ' was created');
|
||||
|
||||
@@ -239,12 +239,15 @@ abstract class Importer
|
||||
// A number was given instead of a name
|
||||
if (is_numeric($user_name)) {
|
||||
$this->log('User '.$user_name.' is not a name - assume this user already exists');
|
||||
$user_username = '';
|
||||
// No name was given
|
||||
$user = User::find($user_name);
|
||||
if($user) {
|
||||
return $user;
|
||||
}
|
||||
$this->log('User with id'.$user_name.' does not exist. Continuing through our processes');
|
||||
} elseif (empty($user_name)) {
|
||||
|
||||
$this->log('No user data provided - skipping user creation, just adding asset');
|
||||
//$user_username = '';
|
||||
return false;
|
||||
} else {
|
||||
$user_email_array = User::generateFormattedNameFromFullName(Setting::getSettings()->email_format, $user_name);
|
||||
$first_name = $user_email_array['first_name'];
|
||||
|
||||
@@ -22,6 +22,9 @@ class ItemImporter extends Importer
|
||||
|
||||
protected function handle($row)
|
||||
{
|
||||
// Need to reset this between iterations or we'll have stale data.
|
||||
$this->item = [];
|
||||
|
||||
$item_category = $this->findCsvMatch($row, "category");
|
||||
if ($this->shouldUpdateField($item_category)) {
|
||||
$this->item["category_id"] = $this->createOrFetchCategory($item_category);
|
||||
@@ -63,14 +66,11 @@ class ItemImporter extends Importer
|
||||
$this->item["qty"] = $this->findCsvMatch($row, "quantity");
|
||||
$this->item["requestable"] = $this->findCsvMatch($row, "requestable");
|
||||
$this->item["user_id"] = $this->user_id;
|
||||
$this->item['serial'] = $this->findCsvMatch($row, "serial_number");
|
||||
$this->item['serial'] = $this->findCsvMatch($row, "serial");
|
||||
// NO need to call this method if we're running the user import.
|
||||
// TODO: Merge these methods.
|
||||
if(get_class($this) !== UserImporter::class) {
|
||||
if ($this->item["user"] = $this->createOrFetchUser($row)) {
|
||||
$this->item['assigned_to'] = $this->item['user']->id;
|
||||
$this->item['assigned_type'] = User::class;
|
||||
}
|
||||
$this->item["user"] = $this->createOrFetchUser($row);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ class ItemImporter extends Importer
|
||||
$item = collect($this->item);
|
||||
// First Filter the item down to the model's fillable fields
|
||||
$item = $item->only($model->getFillable());
|
||||
|
||||
// Then iterate through the item and, if we are updating, remove any blank values.
|
||||
if ($updating) {
|
||||
$item = $item->reject(function ($value) {
|
||||
|
||||
@@ -63,6 +63,8 @@ class LicenseImporter extends ItemImporter
|
||||
} else {
|
||||
$license->fill($this->sanitizeItemForStoring($license));
|
||||
}
|
||||
//FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything.
|
||||
// $license->unsetEventDispatcher();
|
||||
if ($license->save()) {
|
||||
$license->logCreate('Imported using csv importer');
|
||||
$this->log('License ' . $this->item["name"] . ' with serial number ' . $this->item['serial'] . ' was created');
|
||||
|
||||
@@ -33,7 +33,7 @@ class UserImporter extends ItemImporter
|
||||
$this->item['username'] = $this->findCsvMatch($row, 'username');
|
||||
$this->item['first_name'] = $this->findCsvMatch($row, 'first_name');
|
||||
$this->item['last_name'] = $this->findCsvMatch($row, 'last_name');
|
||||
$this->item['email'] = $this->findCsvMatch($row, 'user_email');
|
||||
$this->item['email'] = $this->findCsvMatch($row, 'email');
|
||||
$this->item['phone'] = $this->findCsvMatch($row, 'phone_number');
|
||||
$this->item['jobtitle'] = $this->findCsvMatch($row, 'jobtitle');
|
||||
$this->item['employee_num'] = $this->findCsvMatch($row, 'employee_num');
|
||||
|
||||
@@ -17,7 +17,7 @@ class Accessory extends SnipeModel
|
||||
use Loggable, Presentable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $dates = ['deleted_at', 'purchase_date'];
|
||||
protected $table = 'accessories';
|
||||
protected $casts = [
|
||||
'requestable' => 'boolean'
|
||||
@@ -181,8 +181,7 @@ class Accessory extends SnipeModel
|
||||
})->orWhere('accessories.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('accessories.model_number', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('accessories.order_number', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('accessories.purchase_cost', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('accessories.purchase_date', 'LIKE', '%'.$search.'%');
|
||||
->orWhere('accessories.purchase_cost', '=', $search);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -218,7 +218,8 @@ class Actionlog extends SnipeModel
|
||||
$query->where('companies.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere('action_type', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('note', 'LIKE', '%'.$search.'%');
|
||||
->orWhere('note', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('log_meta', 'LIKE', '%'.$search.'%');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -12,6 +12,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Log;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use DB;
|
||||
|
||||
/**
|
||||
* Model for Assets.
|
||||
@@ -42,13 +43,16 @@ class Asset extends Depreciable
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
|
||||
// We set these as protected dates so that they will be easily accessible via Carbon
|
||||
protected $dates = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'purchase_date',
|
||||
'last_checkout',
|
||||
'expected_checkin'
|
||||
'expected_checkin',
|
||||
'last_audit_date',
|
||||
'next_audit_date'
|
||||
];
|
||||
|
||||
|
||||
@@ -67,6 +71,7 @@ class Asset extends Depreciable
|
||||
'status' => 'integer',
|
||||
'purchase_cost' => 'numeric|nullable',
|
||||
'next_audit_date' => 'date|nullable',
|
||||
'last_audit_date' => 'date|nullable',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -127,7 +132,11 @@ class Asset extends Depreciable
|
||||
|
||||
public function availableForCheckout()
|
||||
{
|
||||
if ((empty($this->assigned_to)) && (empty($this->deleted_at)) && ($this->assetstatus->deployable == 1)) {
|
||||
if (
|
||||
(empty($this->assigned_to)) &&
|
||||
(empty($this->deleted_at)) &&
|
||||
(($this->assetstatus) && ($this->assetstatus->deployable == 1)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -138,13 +147,13 @@ class Asset extends Depreciable
|
||||
* @param User $user
|
||||
* @param User $admin
|
||||
* @param Carbon $checkout_at
|
||||
* @param null $expected_checkin
|
||||
* @param Carbon $expected_checkin
|
||||
* @param string $note
|
||||
* @param null $name
|
||||
* @return bool
|
||||
*/
|
||||
//FIXME: The admin parameter is never used. Can probably be removed.
|
||||
public function checkOut($target, $admin = null, $checkout_at = null, $expected_checkin = null, $note = null, $name = null)
|
||||
public function checkOut($target, $admin = null, $checkout_at = null, $expected_checkin = null, $note = null, $name = null, $location = null)
|
||||
{
|
||||
if (!$target) {
|
||||
return false;
|
||||
@@ -163,6 +172,14 @@ class Asset extends Depreciable
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
if ($location != null) {
|
||||
$this->location_id = $location;
|
||||
} else {
|
||||
if($target->location) {
|
||||
$this->location_id = $target->location->id;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->requireAcceptance()) {
|
||||
if(get_class($target) != User::class) {
|
||||
throw new CheckoutNotAllowed;
|
||||
@@ -206,7 +223,7 @@ class Asset extends Depreciable
|
||||
*/
|
||||
public function components()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\Component', 'components_assets', 'asset_id', 'component_id')->withPivot('id')->withTrashed();
|
||||
return $this->belongsToMany('\App\Models\Component', 'components_assets', 'asset_id', 'component_id')->withPivot('id', 'assigned_qty')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +231,9 @@ class Asset extends Depreciable
|
||||
*/
|
||||
public function get_depreciation()
|
||||
{
|
||||
return $this->model->depreciation;
|
||||
if (($this->model) && ($this->model->depreciation)) {
|
||||
return $this->model->depreciation;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,13 +271,10 @@ class Asset extends Depreciable
|
||||
/**
|
||||
* Get the asset's location based on the assigned user
|
||||
**/
|
||||
public function assetLoc()
|
||||
public function assetLoc($iterations = 1,$first_asset = null)
|
||||
{
|
||||
static $iterations=0;
|
||||
static $first_asset;
|
||||
if (!empty($this->assignedType())) {
|
||||
if ($this->assignedType() == self::ASSET) {
|
||||
$iterations++;
|
||||
if(!$first_asset) {
|
||||
$first_asset=$this;
|
||||
}
|
||||
@@ -267,7 +283,7 @@ class Asset extends Depreciable
|
||||
}
|
||||
$assigned_to=Asset::find($this->assigned_to); //have to do this this way because otherwise it errors
|
||||
if ($assigned_to) {
|
||||
return $assigned_to->assetLoc();
|
||||
return $assigned_to->assetLoc($iterations + 1, $first_asset);
|
||||
} // Recurse until we have a final location
|
||||
}
|
||||
if ($this->assignedType() == self::LOCATION) {
|
||||
@@ -690,7 +706,7 @@ class Asset extends Depreciable
|
||||
|
||||
public function scopeDeleted($query)
|
||||
{
|
||||
return $query->whereNotNull('deleted_at');
|
||||
return $query->whereNotNull('assets.deleted_at');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -706,7 +722,7 @@ class Asset extends Depreciable
|
||||
*/
|
||||
public function scopeInModelList($query, array $modelIdListing)
|
||||
{
|
||||
return $query->whereIn('model_id', $modelIdListing);
|
||||
return $query->whereIn('assets.model_id', $modelIdListing);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -760,11 +776,11 @@ class Asset extends Depreciable
|
||||
{
|
||||
$search = explode(' OR ', $search);
|
||||
|
||||
return $query->leftJoin('users',function ($leftJoin) {
|
||||
$leftJoin->on("users.id", "=", "assets.assigned_to")
|
||||
return $query->leftJoin('users as assets_users',function ($leftJoin) {
|
||||
$leftJoin->on("assets_users.id", "=", "assets.assigned_to")
|
||||
->where("assets.assigned_type", "=", User::class);
|
||||
})->leftJoin('locations',function ($leftJoin) {
|
||||
$leftJoin->on("locations.id","=","assets.assigned_to")
|
||||
})->leftJoin('locations as assets_locations',function ($leftJoin) {
|
||||
$leftJoin->on("assets_locations.id","=","assets.assigned_to")
|
||||
->where("assets.assigned_type","=",Location::class);
|
||||
})->leftJoin('assets as assigned_assets',function ($leftJoin) {
|
||||
$leftJoin->on('assigned_assets.id', '=', 'assets.assigned_to')
|
||||
@@ -796,18 +812,77 @@ class Asset extends Depreciable
|
||||
});
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('company', function ($query) use ($search) {
|
||||
$query->where('companies.name', 'LIKE', '%'.$search.'%');
|
||||
$query->where('companies.name', 'LIKE', '%' . $search . '%');
|
||||
});
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('defaultLoc', function ($query) use ($search) {
|
||||
$query->where('locations.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->where('users.first_name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('users.last_name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('users.username', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('locations.name', 'LIKE', '%'.$search.'%')
|
||||
$query->where('assets_users.first_name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets_users.last_name', 'LIKE', '%'.$search.'%')
|
||||
->orWhereRaw('CONCAT('.DB::getTablePrefix().'assets_users.first_name," ",'.DB::getTablePrefix().'assets_users.last_name) LIKE ?', ["%$search%", "%$search%"])
|
||||
->orWhere('assets_users.username', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets_locations.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assigned_assets.name', 'LIKE', '%'.$search.'%');
|
||||
})->orWhere('assets.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets.asset_tag', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets.serial', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets.order_number', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets.purchase_cost', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets.notes', 'LIKE', '%'.$search.'%');
|
||||
}
|
||||
foreach (CustomField::all() as $field) {
|
||||
$query->orWhere('assets.'.$field->db_column_name(), 'LIKE', "%$search%");
|
||||
}
|
||||
})->withTrashed()->whereNull("assets.deleted_at"); //workaround for laravel bug
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope to search on text for complex Bootstrap Tables API.
|
||||
*
|
||||
* @param \Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $search Search term
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeAssignedSearch($query, $search)
|
||||
{
|
||||
$search = explode(' OR ', $search);
|
||||
|
||||
return $query->leftJoin('users as assets_users',function ($leftJoin) {
|
||||
$leftJoin->on("assets_users.id", "=", "assets.assigned_to")
|
||||
->where("assets.assigned_type", "=", User::class);
|
||||
})->leftJoin('locations as assets_locations',function ($leftJoin) {
|
||||
$leftJoin->on("assets_locations.id","=","assets.assigned_to")
|
||||
->where("assets.assigned_type","=",Location::class);
|
||||
})->leftJoin('assets as assigned_assets',function ($leftJoin) {
|
||||
$leftJoin->on('assigned_assets.id', '=', 'assets.assigned_to')
|
||||
->where('assets.assigned_type', '=', Asset::class);
|
||||
})->where(function ($query) use ($search) {
|
||||
foreach ($search as $search) {
|
||||
$query->whereHas('model', function ($query) use ($search) {
|
||||
$query->whereHas('category', function ($query) use ($search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->where('categories.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('models.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('models.model_number', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
});
|
||||
})->orWhereHas('model', function ($query) use ($search) {
|
||||
$query->whereHas('manufacturer', function ($query) use ($search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->where('manufacturers.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
});
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->where('assets_users.first_name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets_users.last_name', 'LIKE', '%'.$search.'%')
|
||||
->orWhereRaw('CONCAT('.DB::getTablePrefix().'assets_users.first_name," ",'.DB::getTablePrefix().'assets_users.last_name) LIKE ?', ["%$search%", "%$search%"])
|
||||
->orWhere('assets_users.username', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets_locations.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assigned_assets.name', 'LIKE', '%'.$search.'%');
|
||||
})->orWhere('assets.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets.asset_tag', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets.serial', 'LIKE', '%'.$search.'%')
|
||||
@@ -935,8 +1010,9 @@ class Asset extends Depreciable
|
||||
}
|
||||
}
|
||||
|
||||
if (($fieldname!='category') && ($fieldname!='status_label')) {
|
||||
$query->orWhere('assets.'.$fieldname, 'LIKE', '%' . $search_val . '%');
|
||||
if (($fieldname!='category') && ($fieldname!='location')
|
||||
&& ($fieldname!='status_label') && ($fieldname!='model') && ($fieldname!='company') && ($fieldname!='manufacturer')) {
|
||||
$query->orWhere('assets.'.$fieldname, 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
||||
|
||||
@@ -957,7 +1033,7 @@ class Asset extends Depreciable
|
||||
*/
|
||||
public function scopeOrderModels($query, $order)
|
||||
{
|
||||
return $query->join('models', 'assets.model_id', '=', 'models.id')->orderBy('models.name', $order);
|
||||
return $query->join('models as asset_models', 'assets.model_id', '=', 'asset_models.id')->orderBy('asset_models.name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -984,7 +1060,7 @@ class Asset extends Depreciable
|
||||
*/
|
||||
public function scopeOrderAssigned($query, $order)
|
||||
{
|
||||
return $query->leftJoin('users', 'assets.assigned_to', '=', 'users.id')->select('assets.*')->orderBy('users.first_name', $order)->orderBy('users.last_name', $order);
|
||||
return $query->leftJoin('users as users_sort', 'assets.assigned_to', '=', 'users_sort.id')->select('assets.*')->orderBy('users_sort.first_name', $order)->orderBy('users_sort.last_name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -997,7 +1073,7 @@ class Asset extends Depreciable
|
||||
*/
|
||||
public function scopeOrderStatus($query, $order)
|
||||
{
|
||||
return $query->join('status_labels', 'assets.status_id', '=', 'status_labels.id')->orderBy('status_labels.name', $order);
|
||||
return $query->join('status_labels as status_sort', 'assets.status_id', '=', 'status_sort.id')->orderBy('status_sort.name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1010,7 +1086,7 @@ class Asset extends Depreciable
|
||||
*/
|
||||
public function scopeOrderCompany($query, $order)
|
||||
{
|
||||
return $query->leftJoin('companies', 'assets.company_id', '=', 'companies.id')->orderBy('companies.name', $order);
|
||||
return $query->leftJoin('companies as company_sort', 'assets.company_id', '=', 'company_sort.id')->orderBy('company_sort.name', $order);
|
||||
}
|
||||
|
||||
|
||||
@@ -1054,9 +1130,9 @@ class Asset extends Depreciable
|
||||
*/
|
||||
public function scopeOrderCategory($query, $order)
|
||||
{
|
||||
return $query->join('models', 'assets.model_id', '=', 'models.id')
|
||||
->join('categories', 'models.category_id', '=', 'categories.id')
|
||||
->orderBy('categories.name', $order);
|
||||
return $query->join('models as order_model_category', 'assets.model_id', '=', 'order_model_category.id')
|
||||
->join('categories as category_order', 'order_model_category.category_id', '=', 'category_order.id')
|
||||
->orderBy('category_order.name', $order);
|
||||
}
|
||||
|
||||
|
||||
@@ -1085,7 +1161,19 @@ class Asset extends Depreciable
|
||||
*/
|
||||
public function scopeOrderLocation($query, $order)
|
||||
{
|
||||
return $query->leftJoin('locations', 'locations.id', '=', 'assets.rtd_location_id')->orderBy('locations.name', $order);
|
||||
return $query->leftJoin('locations as asset_locations', 'asset_locations.id', '=', 'assets.location_id')->orderBy('asset_locations.name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on default
|
||||
* @param \Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderRtdLocation($query, $order)
|
||||
{
|
||||
return $query->leftJoin('locations as rtd_asset_locations', 'rtd_asset_locations.id', '=', 'assets.rtd_location_id')->orderBy('rtd_asset_locations.name', $order);
|
||||
}
|
||||
|
||||
|
||||
@@ -1099,7 +1187,7 @@ class Asset extends Depreciable
|
||||
*/
|
||||
public function scopeOrderSupplier($query, $order)
|
||||
{
|
||||
return $query->leftJoin('suppliers', 'assets.supplier_id', '=', 'suppliers.id')->orderBy('suppliers.name', $order);
|
||||
return $query->leftJoin('suppliers as suppliers_assets', 'assets.supplier_id', '=', 'suppliers_assets.id')->orderBy('suppliers_assets.name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1113,18 +1201,11 @@ class Asset extends Depreciable
|
||||
public function scopeByLocationId($query, $search)
|
||||
{
|
||||
return $query->where(function ($query) use ($search) {
|
||||
$query->whereHas('defaultLoc', function ($query) use ($search) {
|
||||
$query->whereHas('location', function ($query) use ($search) {
|
||||
$query->where('locations.id', '=', $search);
|
||||
});
|
||||
});
|
||||
// FIXME: This needs porting to checkout to non-user.
|
||||
// ->orWhere(function ($query) use ($search) {
|
||||
// $query->whereHas('assigneduser', function ($query) use ($search) {
|
||||
// $query->whereHas('userloc', function ($query) use ($search) {
|
||||
// $query->where('locations.id', '=', $search);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -169,6 +169,32 @@ class AssetModel extends SnipeModel
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to search on text, including catgeory and manufacturer name
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $search Search term
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeSearchByManufacturerOrCat($query, $search)
|
||||
{
|
||||
|
||||
return $query->where('models.name', 'LIKE', "%$search%")
|
||||
->orWhere('model_number', 'LIKE', "%$search%")
|
||||
->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('category', function ($query) use ($search) {
|
||||
$query->where('categories.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})
|
||||
->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('manufacturer', function ($query) use ($search) {
|
||||
$query->where('manufacturers.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on manufacturer
|
||||
*
|
||||
@@ -182,5 +208,18 @@ class AssetModel extends SnipeModel
|
||||
return $query->leftJoin('manufacturers', 'models.manufacturer_id', '=', 'manufacturers.id')->orderBy('manufacturers.name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on category name
|
||||
*
|
||||
* @param \Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderCategory($query, $order)
|
||||
{
|
||||
return $query->leftJoin('categories', 'models.category_id', '=', 'categories.id')->orderBy('categories.name', $order);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ final class Company extends SnipeModel
|
||||
}
|
||||
}
|
||||
|
||||
private static function scopeCompanyablesDirectly($query, $column = 'company_id')
|
||||
private static function scopeCompanyablesDirectly($query, $column = 'company_id', $table_name = null )
|
||||
{
|
||||
if (Auth::user()) {
|
||||
$company_id = Auth::user()->company_id;
|
||||
@@ -63,7 +63,8 @@ final class Company extends SnipeModel
|
||||
$company_id = null;
|
||||
}
|
||||
|
||||
return $query->where($column, '=', $company_id);
|
||||
$table = ($table_name) ? DB::getTablePrefix().$table_name."." : '';
|
||||
return $query->where($table.$column, '=', $company_id);
|
||||
}
|
||||
|
||||
public static function getIdFromInput($unescaped_input)
|
||||
@@ -131,13 +132,13 @@ final class Company extends SnipeModel
|
||||
}
|
||||
}
|
||||
|
||||
public static function scopeCompanyables($query, $column = 'company_id')
|
||||
public static function scopeCompanyables($query, $column = 'company_id', $table_name = null )
|
||||
{
|
||||
// If not logged in and hitting this, assume we are on the command line and don't scope?'
|
||||
if (!static::isFullMultipleCompanySupportEnabled() || (Auth::check() && Auth::user()->isSuperUser()) || (!Auth::check())) {
|
||||
return $query;
|
||||
} else {
|
||||
return static::scopeCompanyablesDirectly($query, $column);
|
||||
return static::scopeCompanyablesDirectly($query, $column, $table_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +150,6 @@ final class Company extends SnipeModel
|
||||
return $query;
|
||||
} else {
|
||||
$f = function ($q) {
|
||||
|
||||
static::scopeCompanyablesDirectly($q);
|
||||
};
|
||||
|
||||
@@ -166,31 +166,31 @@ final class Company extends SnipeModel
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
return $this->hasMany(User::class, 'company_id');
|
||||
}
|
||||
|
||||
public function assets()
|
||||
{
|
||||
return $this->hasMany(Asset::class);
|
||||
return $this->hasMany(Asset::class, 'company_id');
|
||||
}
|
||||
|
||||
public function licenses()
|
||||
{
|
||||
return $this->hasMany(License::class);
|
||||
return $this->hasMany(License::class, 'company_id');
|
||||
}
|
||||
public function accessories()
|
||||
{
|
||||
return $this->hasMany(Accessory::class);
|
||||
return $this->hasMany(Accessory::class, 'company_id');
|
||||
}
|
||||
|
||||
public function consumables()
|
||||
{
|
||||
return $this->hasMany(Consumable::class);
|
||||
return $this->hasMany(Consumable::class, 'company_id');
|
||||
}
|
||||
|
||||
public function components()
|
||||
{
|
||||
return $this->hasMany(Component::class);
|
||||
return $this->hasMany(Component::class, 'company_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ class Component extends SnipeModel
|
||||
use Loggable, Presentable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $dates = ['deleted_at', 'purchase_date'];
|
||||
protected $table = 'components';
|
||||
/**
|
||||
* Category validation rules
|
||||
@@ -55,6 +55,7 @@ class Component extends SnipeModel
|
||||
'purchase_date',
|
||||
'min_amt',
|
||||
'qty',
|
||||
'serial'
|
||||
];
|
||||
|
||||
public function location()
|
||||
@@ -143,8 +144,7 @@ class Component extends SnipeModel
|
||||
})->orWhere('components.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('components.order_number', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('components.serial', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('components.purchase_cost', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('components.purchase_date', 'LIKE', '%'.$search.'%');
|
||||
->orWhere('components.purchase_cost', 'LIKE', '%'.$search.'%');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,13 +12,14 @@ class Consumable extends SnipeModel
|
||||
use Loggable, Presentable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $dates = ['deleted_at', 'purchase_date'];
|
||||
protected $table = 'consumables';
|
||||
protected $casts = [
|
||||
'requestable' => 'boolean'
|
||||
];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Category validation rules
|
||||
*/
|
||||
@@ -185,8 +186,7 @@ class Consumable extends SnipeModel
|
||||
});
|
||||
})->orWhere('consumables.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('consumables.order_number', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('consumables.purchase_cost', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('consumables.purchase_date', 'LIKE', '%'.$search.'%');
|
||||
->orWhere('consumables.purchase_cost', 'LIKE', '%'.$search.'%');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Http\Traits\UniqueUndeletedTrait;
|
||||
use ForceUTF8\Encoding;
|
||||
use EasySlugger\Utf8Slugger;
|
||||
use Patchwork\Utf8;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CustomField extends Model
|
||||
{
|
||||
@@ -16,39 +17,83 @@ class CustomField extends Model
|
||||
public static $PredefinedFormats=[
|
||||
"ANY" => "",
|
||||
"ALPHA" => "alpha",
|
||||
"ALPHA-DASH" => "alpha_dash",
|
||||
"NUMERIC" => "numeric",
|
||||
"ALPHA-NUMERIC" => "alpha_num",
|
||||
"EMAIL" => "email",
|
||||
"DATE" => "date",
|
||||
"URL" => "url",
|
||||
"NUMERIC" => "numeric",
|
||||
"MAC" => "regex:/^[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}$/",
|
||||
"IP" => "ip",
|
||||
"IPV4" => "ipv4",
|
||||
"IPV6" => "ipv6",
|
||||
"MAC" => "regex:/^[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}$/",
|
||||
"BOOLEAN" => "boolean",
|
||||
];
|
||||
|
||||
public $rules = [
|
||||
"name" => "required|unique:custom_fields"
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'element',
|
||||
'format',
|
||||
'field_values',
|
||||
'field_encrypted',
|
||||
'help_text'
|
||||
];
|
||||
|
||||
public static $table_name="assets";
|
||||
// This is confusing, since it's actually the custom fields table that
|
||||
// we're usually modifying, but since we alter the assets table, we have to
|
||||
// say that here, otherwise the new fields get added onto the custom fields
|
||||
// table instead of the assets table.
|
||||
public static $table_name = "assets";
|
||||
|
||||
|
||||
/**
|
||||
* Convert the custom field's name property to a db-safe string.
|
||||
*
|
||||
* We could probably have used str_slug() here but not sure what it would
|
||||
* do with previously existing values. - @snipe
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.4]
|
||||
* @return String
|
||||
*/
|
||||
public static function name_to_db_name($name)
|
||||
{
|
||||
return "_snipeit_" . preg_replace("/[^a-zA-Z0-9]/", "_", strtolower($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set some boot methods for creating and updating.
|
||||
*
|
||||
* There is never ever a time when we wouldn't want to be updating those asset
|
||||
* column names and the values of the db column name in the custom fields table
|
||||
* if they have changed, so we handle that here so that we don't have to remember
|
||||
* to do it in the controllers.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.4]
|
||||
* @return Boolean
|
||||
*/
|
||||
public static function boot()
|
||||
{
|
||||
self::created(function ($custom_field) {
|
||||
|
||||
|
||||
// column exists - nothing to do here
|
||||
// Column already exists on the assets table - nothing to do here.
|
||||
// This *shouldn't* happen in the wild.
|
||||
if (Schema::hasColumn(CustomField::$table_name, $custom_field->convertUnicodeDbSlug())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update the column name in the assets table
|
||||
Schema::table(CustomField::$table_name, function ($table) use ($custom_field) {
|
||||
$table->text($custom_field->convertUnicodeDbSlug())->nullable();
|
||||
});
|
||||
|
||||
// Update the db_column property in the custom fields table
|
||||
$custom_field->db_column = $custom_field->convertUnicodeDbSlug();
|
||||
$custom_field->save();
|
||||
});
|
||||
@@ -56,20 +101,24 @@ class CustomField extends Model
|
||||
|
||||
self::updating(function ($custom_field) {
|
||||
|
||||
// Column already exists. Nothing to update.
|
||||
// Column already exists on the assets table - nothing to do here.
|
||||
if ($custom_field->isDirty("name")) {
|
||||
|
||||
if (Schema::hasColumn(CustomField::$table_name, $custom_field->convertUnicodeDbSlug())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// This is just a dumb thing we have to include because Laraval/Doctrine doesn't
|
||||
// play well with enums or a table that EVER had enums. :(
|
||||
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
|
||||
$platform->registerDoctrineTypeMapping('enum', 'string');
|
||||
|
||||
|
||||
// Rename the field if the name has changed
|
||||
Schema::table(CustomField::$table_name, function ($table) use ($custom_field) {
|
||||
$table->renameColumn($custom_field->convertUnicodeDbSlug($custom_field->getOriginal("name")), $custom_field->convertUnicodeDbSlug());
|
||||
});
|
||||
|
||||
|
||||
// Save the updated column name to the custom fields table
|
||||
$custom_field->db_column = $custom_field->convertUnicodeDbSlug();
|
||||
$custom_field->save();
|
||||
|
||||
@@ -78,6 +127,8 @@ class CustomField extends Model
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
// Drop the assets column if we've deleted it from custom fields
|
||||
self::deleting(function ($custom_field) {
|
||||
return Schema::table(CustomField::$table_name, function ($table) use ($custom_field) {
|
||||
$table->dropColumn($custom_field->convertUnicodeDbSlug());
|
||||
@@ -106,11 +157,21 @@ class CustomField extends Model
|
||||
return $this->db_column;
|
||||
}
|
||||
|
||||
// mutators for 'format' attribute
|
||||
/**
|
||||
* Mutator for the 'format' attribute.
|
||||
*
|
||||
* This is used by the dropdown to store the laravel-specific
|
||||
* validator strings in the database but still return the
|
||||
* user-friendly text in the dropdowns, and in the custom fields display.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.4]
|
||||
* @return Array
|
||||
*/
|
||||
public function getFormatAttribute($value)
|
||||
{
|
||||
foreach (self::$PredefinedFormats as $name => $pattern) {
|
||||
if ($pattern===$value) {
|
||||
if ($pattern === $value || $name === $value) {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
@@ -161,6 +222,13 @@ class CustomField extends Model
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the field is encrypted
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.4]
|
||||
* @return Boolean
|
||||
*/
|
||||
public function isFieldDecryptable($string)
|
||||
{
|
||||
if (($this->field_encrypted=='1') && ($string!='')) {
|
||||
@@ -170,6 +238,14 @@ class CustomField extends Model
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert non-UTF-8 or weirdly encoded text into something that
|
||||
* won't break the database.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.4]
|
||||
* @return Boolean
|
||||
*/
|
||||
public function convertUnicodeDbSlug($original = null)
|
||||
{
|
||||
$name = $original ? $original : $this->name;
|
||||
@@ -183,4 +259,26 @@ class CustomField extends Model
|
||||
|
||||
return substr($long_slug, 0, 50) . '_' . $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get validation rules for custom fields to use with Validator
|
||||
* @author [V. Cordes] [<volker@fdatek.de>]
|
||||
* @param int $id
|
||||
* @since [v4.1.10]
|
||||
* @return Array
|
||||
*/
|
||||
public function validationRules()
|
||||
{
|
||||
return [
|
||||
"name" => "required|unique:custom_fields",
|
||||
"element" => [
|
||||
"required",
|
||||
Rule::in(['text', 'listbox'])
|
||||
],
|
||||
'format' => [
|
||||
Rule::in(array_merge(array_keys(CustomField::$PredefinedFormats), CustomField::$PredefinedFormats))
|
||||
],
|
||||
'field_encrypted' => "nullable|boolean"
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,14 @@ class License extends Depreciable
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
// We set these as protected dates so that they will be easily accessible via Carbon
|
||||
protected $dates = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'purchase_date'
|
||||
];
|
||||
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -266,7 +273,9 @@ class License extends Depreciable
|
||||
public function availCount()
|
||||
{
|
||||
return $this->licenseSeatsRelation()
|
||||
->whereNull('asset_id');
|
||||
->whereNull('asset_id')
|
||||
->whereNull('assigned_to')
|
||||
->whereNull('deleted_at');
|
||||
}
|
||||
|
||||
public function getAvailSeatsCountAttribute()
|
||||
@@ -338,13 +347,25 @@ class License extends Depreciable
|
||||
*/
|
||||
public function freeSeat()
|
||||
{
|
||||
return $this->licenseseats()
|
||||
return $this->licenseseats()
|
||||
->whereNull('deleted_at')
|
||||
->whereNull('assigned_to')
|
||||
->whereNull('asset_id')
|
||||
->where(function ($query) {
|
||||
$query->whereNull('assigned_to')
|
||||
->whereNull('asset_id');
|
||||
})
|
||||
->orderBy('id', 'asc')
|
||||
->first();
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the next available free seat - used by
|
||||
* the API to populate next_seat
|
||||
*/
|
||||
public function freeSeats()
|
||||
{
|
||||
return $this->hasMany('\App\Models\LicenseSeat')->whereNull('assigned_to')->whereNull('deleted_at')->whereNull('asset_id');
|
||||
}
|
||||
|
||||
public static function getExpiringLicenses($days = 60)
|
||||
{
|
||||
|
||||
|
||||
@@ -34,4 +34,17 @@ class LicenseSeat extends Model implements ICompanyableChild
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Asset', 'asset_id')->withTrashed();
|
||||
}
|
||||
|
||||
public function location()
|
||||
{
|
||||
if (($this->user) && ($this->user->location)) {
|
||||
return $this->user->location;
|
||||
|
||||
} elseif (($this->asset) && ($this->asset->location)) {
|
||||
return $this->asset->location;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,12 @@ class Location extends SnipeModel
|
||||
|
||||
public function assets()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Asset', 'location_id');
|
||||
return $this->hasMany('\App\Models\Asset', 'location_id')
|
||||
->whereHas('assetstatus', function ($query) {
|
||||
$query->where('status_labels.deployable', '=', 1)
|
||||
->orWhere('status_labels.pending', '=', 1)
|
||||
->orWhere('status_labels.archived', '=', 0);
|
||||
});
|
||||
}
|
||||
|
||||
public function rtd_assets()
|
||||
@@ -92,7 +97,6 @@ class Location extends SnipeModel
|
||||
public function assignedAssets()
|
||||
{
|
||||
return $this->morphMany('App\Models\Asset', 'assigned', 'assigned_type', 'assigned_to')->withTrashed();
|
||||
// return $this->hasMany('\App\Models\Asset', 'assigned_to')->withTrashed();
|
||||
}
|
||||
|
||||
public function setLdapOuAttribute($ldap_ou)
|
||||
|
||||
@@ -182,7 +182,7 @@ trait Loggable
|
||||
$log->location_id = null;
|
||||
$log->note = $note;
|
||||
$log->user_id = $user_id;
|
||||
$log->logaction('created');
|
||||
$log->logaction('create');
|
||||
$log->save();
|
||||
return $log;
|
||||
}
|
||||
|
||||
@@ -79,16 +79,42 @@ class Setting extends Model
|
||||
|
||||
public static function getDefaultEula()
|
||||
{
|
||||
|
||||
$Parsedown = new \Parsedown();
|
||||
if (Setting::getSettings()->default_eula_text) {
|
||||
return $Parsedown->text(e(Setting::getSettings()->default_eula_text));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function modellistCheckedValue ($element) {
|
||||
|
||||
// If the value is blank for some reason
|
||||
if ($this->modellist_displays=='') {
|
||||
return false;
|
||||
}
|
||||
$values = explode(',', $this->modellist_displays);
|
||||
|
||||
foreach ($values as $value) {
|
||||
if ($value == $element) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes the custom CSS, and then un-escapes the greater-than symbol
|
||||
* so it can work with direct descendant characters for bootstrap
|
||||
* menu overrides like:
|
||||
*
|
||||
* .skin-blue .sidebar-menu>li.active>a, .skin-blue .sidebar-menu>li:hover>a
|
||||
*
|
||||
* Important: Do not remove the e() escaping here, as we output raw in the blade.
|
||||
*
|
||||
* @return string escaped CSS
|
||||
* @author A. Gianotto <snipe@snipe.net>
|
||||
*/
|
||||
public function show_custom_css()
|
||||
{
|
||||
$custom_css = Setting::getSettings()->custom_css;
|
||||
|
||||
@@ -24,6 +24,7 @@ class SnipeModel extends Model
|
||||
public function setPurchaseCostAttribute($value)
|
||||
{
|
||||
$value = Helper::ParseFloat($value);
|
||||
|
||||
if ($value == '0.0') {
|
||||
$value = null;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Http\Traits\UniqueUndeletedTrait;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Passport\HasApiTokens;
|
||||
use DB;
|
||||
|
||||
class User extends SnipeModel implements AuthenticatableContract, CanResetPasswordContract
|
||||
{
|
||||
@@ -35,7 +36,7 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
||||
'jobtitle',
|
||||
'location_id',
|
||||
'password',
|
||||
'phone_number',
|
||||
'phone',
|
||||
'username',
|
||||
'first_name',
|
||||
'address',
|
||||
@@ -43,6 +44,8 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
||||
'state',
|
||||
'country',
|
||||
'zip',
|
||||
'activated',
|
||||
'manager_id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@@ -61,7 +64,6 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
||||
'email' => 'email|nullable',
|
||||
'password' => 'required|min:6',
|
||||
'locale' => 'max:10|nullable',
|
||||
'manager_id' => 'nullable|different:id',
|
||||
];
|
||||
|
||||
|
||||
@@ -328,44 +330,24 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
||||
|
||||
public static function generateFormattedNameFromFullName($format = 'filastname', $users_name)
|
||||
{
|
||||
$name = explode(" ", $users_name);
|
||||
$name = str_replace("'", '', $name);
|
||||
$first_name = $name[0];
|
||||
$email_last_name = '';
|
||||
$email_prefix = $first_name;
|
||||
list($first_name, $last_name) = explode(" ", $users_name, 2);
|
||||
|
||||
// If there is no last name given
|
||||
if (!array_key_exists(1, $name)) {
|
||||
$last_name='';
|
||||
$email_last_name = $last_name;
|
||||
$user_username = $first_name;
|
||||
|
||||
// There is a last name given
|
||||
} else {
|
||||
|
||||
$last_name = str_replace($first_name . ' ', '', $users_name);
|
||||
|
||||
if ($format=='filastname') {
|
||||
$email_last_name.=str_replace(' ', '', $last_name);
|
||||
$email_prefix = $first_name[0].$email_last_name;
|
||||
|
||||
} elseif ($format=='firstname.lastname') {
|
||||
$email_last_name.=str_replace(' ', '', $last_name);
|
||||
$email_prefix = $first_name.'.'.$email_last_name;
|
||||
|
||||
} elseif ($format=='firstname') {
|
||||
$email_last_name.=str_replace(' ', '', $last_name);
|
||||
$email_prefix = $first_name;
|
||||
}
|
||||
// Assume filastname by default
|
||||
$username = str_slug(substr($first_name, 0, 1).$last_name);
|
||||
|
||||
if ($format=='firstname.lastname') {
|
||||
$username = str_slug($first_name).'.'.str_slug($last_name);
|
||||
|
||||
} elseif ($format=='firstname_lastname') {
|
||||
$username = str_slug($first_name).'_'.str_slug($last_name);
|
||||
|
||||
} elseif ($format=='firstname') {
|
||||
$username = str_slug($first_name);
|
||||
}
|
||||
|
||||
$user_username = $email_prefix;
|
||||
$user['first_name'] = $first_name;
|
||||
$user['last_name'] = $last_name;
|
||||
$user['username'] = strtolower($user_username);
|
||||
|
||||
$user['username'] = strtolower($username);
|
||||
return $user;
|
||||
|
||||
|
||||
@@ -424,6 +406,7 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
||||
->orWhere('users.phone', 'LIKE', "%$search%")
|
||||
->orWhere('users.jobtitle', 'LIKE', "%$search%")
|
||||
->orWhere('users.employee_num', 'LIKE', "%$search%")
|
||||
->orWhereRaw('CONCAT('.DB::getTablePrefix().'users.first_name," ",'.DB::getTablePrefix().'users.last_name) LIKE ?', ["%$search%", "%$search%"])
|
||||
->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('userloc', function ($query) use ($search) {
|
||||
$query->where('locations.name', 'LIKE', '%'.$search.'%');
|
||||
@@ -440,10 +423,12 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
||||
});
|
||||
})
|
||||
|
||||
// Ugly, ugly code because Laravel sucks at self-joins
|
||||
//Ugly, ugly code because Laravel sucks at self-joins
|
||||
->orWhere(function ($query) use ($search) {
|
||||
$query->whereRaw("users.manager_id IN (select id from users where first_name LIKE '%".$search."%' OR last_name LIKE '%".$search."%') ");
|
||||
$query->whereRaw(DB::getTablePrefix()."users.manager_id IN (select id from ".DB::getTablePrefix()."users where first_name LIKE ? OR last_name LIKE ?)", ["%$search%", "%$search%"]);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -474,7 +459,7 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
||||
public function scopeOrderManager($query, $order)
|
||||
{
|
||||
// Left join here, or it will only return results with parents
|
||||
return $query->leftJoin('users as manager', 'users.manager_id', '=', 'manager.id')->orderBy('manager.first_name', $order)->orderBy('manager.last_name', $order);
|
||||
return $query->leftJoin('users as users_manager', 'users.manager_id', '=', 'users_manager.id')->orderBy('users_manager.first_name', $order)->orderBy('users_manager.last_name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,7 +472,7 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
||||
*/
|
||||
public function scopeOrderLocation($query, $order)
|
||||
{
|
||||
return $query->leftJoin('locations', 'users.location_id', '=', 'locations.id')->orderBy('locations.name', $order);
|
||||
return $query->leftJoin('locations as locations_users', 'users.location_id', '=', 'locations_users.id')->orderBy('locations_users.name', $order);
|
||||
}
|
||||
|
||||
|
||||
@@ -501,6 +486,6 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
||||
*/
|
||||
public function scopeOrderDepartment($query, $order)
|
||||
{
|
||||
return $query->leftJoin('departments', 'users.department_id', '=', 'departments.id')->orderBy('departments.name', $order);
|
||||
return $query->leftJoin('departments as departments_users', 'users.department_id', '=', 'departments_users.id')->orderBy('departments_users.name', $order);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class CheckoutNotification extends Notification
|
||||
'first_name' => $target->present()->fullName(),
|
||||
'item_name' => $item->present()->name(),
|
||||
'checkout_date' => $item->last_checkout,
|
||||
'expected_checkin' => $item->expected_checkin,
|
||||
'expected_checkin' => ($item->expected_checkin) ? $item->expected_checkin->format('Y-m-d') : '',
|
||||
'item_tag' => $item->asset_tag,
|
||||
'note' => $this->params['note'],
|
||||
'item_serial' => $item->serial,
|
||||
|
||||
@@ -18,19 +18,31 @@ class AssetObserver
|
||||
public function updating(Asset $asset)
|
||||
{
|
||||
|
||||
|
||||
if ((isset($asset->getOriginal()['assigned_to'])) && ($asset->getAttributes()['assigned_to'] == $asset->getOriginal()['assigned_to'])
|
||||
// If the asset isn't being checked out or audited, log the update.
|
||||
// (Those other actions already create log entries.)
|
||||
if (($asset->getAttributes()['assigned_to'] == $asset->getOriginal()['assigned_to'])
|
||||
&& ($asset->getAttributes()['next_audit_date'] == $asset->getOriginal()['next_audit_date'])
|
||||
&& ($asset->getAttributes()['last_checkout'] == $asset->getOriginal()['last_checkout'])
|
||||
&& ($asset->getAttributes()['status_id'] == $asset->getOriginal()['status_id']))
|
||||
&& ($asset->getAttributes()['last_checkout'] == $asset->getOriginal()['last_checkout']))
|
||||
{
|
||||
$changed = [];
|
||||
|
||||
foreach ($asset->getOriginal() as $key => $value) {
|
||||
if ($asset->getOriginal()[$key] != $asset->getAttributes()[$key]) {
|
||||
$changed[$key]['old'] = $asset->getOriginal()[$key];
|
||||
$changed[$key]['new'] = $asset->getAttributes()[$key];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$logAction = new Actionlog();
|
||||
$logAction->item_type = Asset::class;
|
||||
$logAction->item_id = $asset->id;
|
||||
$logAction->created_at = date("Y-m-d H:i:s");
|
||||
$logAction->user_id = Auth::id();
|
||||
$logAction->log_meta = json_encode($changed);
|
||||
$logAction->logaction('update');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user