Compare commits
679 Commits
v3.0-alpha
...
v3.5.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe5e813970 | ||
|
|
d6f7e03431 | ||
|
|
87f50dfd10 | ||
|
|
85ddb9cfff | ||
|
|
c6338d6a8b | ||
|
|
b92d26f3c4 | ||
|
|
2a95a95e00 | ||
|
|
7ca7877740 | ||
|
|
1394424760 | ||
|
|
fc07753a5c | ||
|
|
7bbe85801e | ||
|
|
8774927b91 | ||
|
|
8cb4954f8a | ||
|
|
48b52a0ccc | ||
|
|
9ecb0e6ca1 | ||
|
|
9091385182 | ||
|
|
b90c0de822 | ||
|
|
ee2522571c | ||
|
|
d3a13bcd45 | ||
|
|
67f199b09d | ||
|
|
f1c458185d | ||
|
|
ed22ec4b36 | ||
|
|
fa72e64b98 | ||
|
|
2a8ab06ca3 | ||
|
|
61d07bdc7c | ||
|
|
3061ce2983 | ||
|
|
e9f3d622f5 | ||
|
|
1e3244b2b3 | ||
|
|
a92bfe8ade | ||
|
|
c42dfadd17 | ||
|
|
0a391de09f | ||
|
|
b6cc7e7c14 | ||
|
|
819ca2921b | ||
|
|
7d272e3c96 | ||
|
|
40f00665b3 | ||
|
|
03ee6b8f91 | ||
|
|
937192f7ce | ||
|
|
ce1f62b9be | ||
|
|
3208522dd1 | ||
|
|
c3cd329604 | ||
|
|
2ba4986396 | ||
|
|
8ba19632cf | ||
|
|
caf6a10227 | ||
|
|
580091269d | ||
|
|
bcc6ca5180 | ||
|
|
7fdd4fbe98 | ||
|
|
aecef2618f | ||
|
|
bd5e6d8551 | ||
|
|
1e4e9dd3d7 | ||
|
|
2ab91fed01 | ||
|
|
5b0220ac1e | ||
|
|
aa92b93bd1 | ||
|
|
998624ad68 | ||
|
|
d3d36315d3 | ||
|
|
6dc143d95d | ||
|
|
d8753a7d86 | ||
|
|
90af734f6b | ||
|
|
3aa7c60765 | ||
|
|
0962d770cf | ||
|
|
5d8c06bc30 | ||
|
|
2597a7b896 | ||
|
|
3741a93884 | ||
|
|
71be73781b | ||
|
|
7aea9341f8 | ||
|
|
e5098c3ba1 | ||
|
|
46507c929a | ||
|
|
8233d520c6 | ||
|
|
06f174adf9 | ||
|
|
08f320b76a | ||
|
|
04898c49b2 | ||
|
|
eeff305b02 | ||
|
|
2d8269ddcd | ||
|
|
b0a8a0427d | ||
|
|
f384593e19 | ||
|
|
5846f23d8b | ||
|
|
91a035ec5b | ||
|
|
d357326dc1 | ||
|
|
5e2dbaffc4 | ||
|
|
391c9a77ef | ||
|
|
7bde0f4f92 | ||
|
|
aa0ccf11fa | ||
|
|
a8f79369ee | ||
|
|
0a506120b7 | ||
|
|
0e28f36678 | ||
|
|
e86adccf19 | ||
|
|
e7fba08f92 | ||
|
|
35f3f1432f | ||
|
|
934b39268d | ||
|
|
67315d81d6 | ||
|
|
eee64d5509 | ||
|
|
b450ef3534 | ||
|
|
d4dc1830ec | ||
|
|
04e9ca0942 | ||
|
|
06021d79c1 | ||
|
|
7ecb8d7bc1 | ||
|
|
efe95d9ad0 | ||
|
|
6f89699f1a | ||
|
|
2c18bc24a7 | ||
|
|
f81b21208b | ||
|
|
ba70e5b053 | ||
|
|
5090468357 | ||
|
|
213cda8cf4 | ||
|
|
421cbf11fc | ||
|
|
8816c481af | ||
|
|
3ed0cf2be8 | ||
|
|
cd28b012b3 | ||
|
|
25902db659 | ||
|
|
35a67ab18a | ||
|
|
2cfb015b1a | ||
|
|
e4dcd47d6c | ||
|
|
64cd4fb1c9 | ||
|
|
276e0a7114 | ||
|
|
9bf3403f31 | ||
|
|
0d088f3031 | ||
|
|
a92ed97b4e | ||
|
|
fcdea4825e | ||
|
|
35439f9976 | ||
|
|
d473432436 | ||
|
|
4dff58ec26 | ||
|
|
537ad28a67 | ||
|
|
96eb832fd3 | ||
|
|
130c798c90 | ||
|
|
e1229bfb0f | ||
|
|
f185c2e0de | ||
|
|
122f0b9cba | ||
|
|
c49f10c9bb | ||
|
|
97a938f119 | ||
|
|
308fcf96de | ||
|
|
f1fab8b164 | ||
|
|
0e8502a323 | ||
|
|
3171d9230b | ||
|
|
11b9df4b48 | ||
|
|
0c2524954f | ||
|
|
b76ad5ea88 | ||
|
|
43fbd54a12 | ||
|
|
406d270c01 | ||
|
|
98eb26a2bd | ||
|
|
61aa9beddb | ||
|
|
e89fd9b3a2 | ||
|
|
d72443c335 | ||
|
|
f38593b530 | ||
|
|
4cf2d16c7a | ||
|
|
f38912a5cf | ||
|
|
ad22293f4b | ||
|
|
fb402e138d | ||
|
|
90d2d0c7e1 | ||
|
|
9d730af50f | ||
|
|
9407b4e28c | ||
|
|
ec19924bea | ||
|
|
7b8403cdb9 | ||
|
|
85f3e7e3d4 | ||
|
|
11dc20de61 | ||
|
|
14fa7ed965 | ||
|
|
5cf1c8dfa3 | ||
|
|
f04cfb3e7f | ||
|
|
d970daa666 | ||
|
|
0b0c81a110 | ||
|
|
b1324c2e64 | ||
|
|
3c28be33c5 | ||
|
|
e52a0f65bb | ||
|
|
b726d131a4 | ||
|
|
014167699d | ||
|
|
d9f2e7bf58 | ||
|
|
4c8c58d453 | ||
|
|
923352537c | ||
|
|
be8049b41a | ||
|
|
4419dc7434 | ||
|
|
ac63642224 | ||
|
|
5959f83de3 | ||
|
|
0c912bcf49 | ||
|
|
16014945b6 | ||
|
|
44821b9667 | ||
|
|
c5d7a1fdd6 | ||
|
|
29c4189419 | ||
|
|
7ef4f23d0f | ||
|
|
8232cefbba | ||
|
|
a852c624d3 | ||
|
|
7edf1db101 | ||
|
|
5e9740e0b4 | ||
|
|
41a20d8f66 | ||
|
|
7a0843e954 | ||
|
|
4a9f3fd6ff | ||
|
|
9ae1841fc4 | ||
|
|
ba5a2edd54 | ||
|
|
c73cbccffc | ||
|
|
24d2726c86 | ||
|
|
06fcf3e07d | ||
|
|
cc15a4f018 | ||
|
|
18e576e5fd | ||
|
|
4c787891e4 | ||
|
|
dbd96a4c10 | ||
|
|
d314f85b93 | ||
|
|
3a81b7e612 | ||
|
|
7992258b46 | ||
|
|
869da1da78 | ||
|
|
a6a6aa78b0 | ||
|
|
4ffea7ceaa | ||
|
|
1d3255a00b | ||
|
|
29eadb10ae | ||
|
|
1ca5f8bee5 | ||
|
|
8dbc098836 | ||
|
|
45ea44e172 | ||
|
|
fff2bce9e4 | ||
|
|
75e0c5565c | ||
|
|
098e7e4feb | ||
|
|
e4355292e4 | ||
|
|
ca8ca89955 | ||
|
|
30c45442f9 | ||
|
|
03c2c267bc | ||
|
|
a76fe98b2d | ||
|
|
9e43a44d20 | ||
|
|
6fe639f490 | ||
|
|
a5467ba25d | ||
|
|
1c09479d5f | ||
|
|
682c75e990 | ||
|
|
1612562f41 | ||
|
|
1b7f28598d | ||
|
|
17d5e40e02 | ||
|
|
099a85e26d | ||
|
|
0e5209e80f | ||
|
|
95328f0a6a | ||
|
|
cbc42f3e59 | ||
|
|
846356974d | ||
|
|
ef6fb69cee | ||
|
|
fb1eab0978 | ||
|
|
39929c7d89 | ||
|
|
d6ba0b67f0 | ||
|
|
66ad0f1d4c | ||
|
|
bfac25d445 | ||
|
|
3b247ba31f | ||
|
|
bc3482b281 | ||
|
|
23e23bab90 | ||
|
|
848e3837aa | ||
|
|
1747be4b29 | ||
|
|
565ea95803 | ||
|
|
e7e8c487c9 | ||
|
|
5a242433fb | ||
|
|
6204969639 | ||
|
|
cde5efd698 | ||
|
|
283bb4ae4b | ||
|
|
3d1d248bb5 | ||
|
|
9c31c0edce | ||
|
|
39450c1fe9 | ||
|
|
64ffd261fc | ||
|
|
de17da099f | ||
|
|
886a31190c | ||
|
|
8246a319a2 | ||
|
|
27adeb427e | ||
|
|
bfc18c758a | ||
|
|
735595be07 | ||
|
|
27dee1b793 | ||
|
|
cdeccb399f | ||
|
|
2f679ccc29 | ||
|
|
eac6abe60a | ||
|
|
c9d3cd724b | ||
|
|
1fa2fe3c24 | ||
|
|
b6986ad808 | ||
|
|
715c9aa780 | ||
|
|
139325d8ba | ||
|
|
d65a9091c8 | ||
|
|
1f30bdee99 | ||
|
|
4e4f338680 | ||
|
|
0f72989953 | ||
|
|
93e038006c | ||
|
|
b63a3abf70 | ||
|
|
46eca54b44 | ||
|
|
fcb1d6ac15 | ||
|
|
3f54c034dd | ||
|
|
a53346be1f | ||
|
|
fd94c76874 | ||
|
|
108a3c9dad | ||
|
|
85232c47da | ||
|
|
47f6635992 | ||
|
|
eef8d1609e | ||
|
|
8a9307f357 | ||
|
|
0a73297f24 | ||
|
|
1f0737cfb7 | ||
|
|
fae9755ffb | ||
|
|
c07ad03e74 | ||
|
|
011cb1120d | ||
|
|
68b7b8f932 | ||
|
|
f78a577210 | ||
|
|
c0f4e621ea | ||
|
|
c78dbfc21f | ||
|
|
f31637adb4 | ||
|
|
3e5d2b5385 | ||
|
|
fbd0059bbb | ||
|
|
f53c5706f6 | ||
|
|
214a7d548d | ||
|
|
0ee5dea1a1 | ||
|
|
29c60ee6b5 | ||
|
|
075f8fd021 | ||
|
|
14b0a6315f | ||
|
|
b99d300ab2 | ||
|
|
9dda0d02ea | ||
|
|
8e6c157e7e | ||
|
|
9fbe6c68ac | ||
|
|
eb508901c5 | ||
|
|
07b70a8cd0 | ||
|
|
e9eb5ad372 | ||
|
|
3fd5fb836f | ||
|
|
3514ae2c0d | ||
|
|
1493251794 | ||
|
|
b4e54225a2 | ||
|
|
4c9e75cec9 | ||
|
|
a401986ef5 | ||
|
|
288584cb60 | ||
|
|
399e70763b | ||
|
|
f145d6cc8c | ||
|
|
9e4ac018ea | ||
|
|
0bf5c6978e | ||
|
|
9a9b214c1d | ||
|
|
b76dc25ac0 | ||
|
|
b30369f7ce | ||
|
|
16fe53928c | ||
|
|
2e665e128f | ||
|
|
60560e4994 | ||
|
|
a44b90dfc9 | ||
|
|
987b969e88 | ||
|
|
ad531d6d59 | ||
|
|
261d2f133b | ||
|
|
e0938cf82d | ||
|
|
eec22c5aeb | ||
|
|
b03330aae0 | ||
|
|
7f5ea72dc7 | ||
|
|
ba25972b49 | ||
|
|
cc6b2a0081 | ||
|
|
a590cc3dd2 | ||
|
|
d4138f4364 | ||
|
|
128290bd82 | ||
|
|
114540d836 | ||
|
|
0b57f74e36 | ||
|
|
03d7d01e12 | ||
|
|
a1640d7fe3 | ||
|
|
1f85f4b337 | ||
|
|
b2d958724b | ||
|
|
297820d347 | ||
|
|
094c5ac8df | ||
|
|
78fda31379 | ||
|
|
3a04686ade | ||
|
|
ca5d3e3006 | ||
|
|
d427dcc8e2 | ||
|
|
f0c00897ca | ||
|
|
e256bdc9f7 | ||
|
|
2e6e0e8911 | ||
|
|
b0dc5b4183 | ||
|
|
9385c3e9cf | ||
|
|
61108102d7 | ||
|
|
8ba9399de7 | ||
|
|
f6a4d4aaab | ||
|
|
df664bdc9d | ||
|
|
c2f6e0cfd8 | ||
|
|
ba6f26cef9 | ||
|
|
68b0bbbec9 | ||
|
|
52425f62c5 | ||
|
|
54a0d0de0e | ||
|
|
099f5d4cfd | ||
|
|
5266bd4415 | ||
|
|
ebc74a6530 | ||
|
|
13d250f095 | ||
|
|
68d8e6a3a9 | ||
|
|
192b1582f5 | ||
|
|
27b8d326e3 | ||
|
|
7e56934484 | ||
|
|
698cb161d4 | ||
|
|
92175eb700 | ||
|
|
616f922306 | ||
|
|
c1d2be651a | ||
|
|
8729871353 | ||
|
|
99a42dfc38 | ||
|
|
0cf8ac1d95 | ||
|
|
8fd8e747d9 | ||
|
|
e6b872299d | ||
|
|
a00198abc7 | ||
|
|
40b56cfad7 | ||
|
|
5cd2c78d5e | ||
|
|
2ce1d8b985 | ||
|
|
f3e99113d2 | ||
|
|
ab6e2a7301 | ||
|
|
e7038cfdc8 | ||
|
|
4233c781ac | ||
|
|
b5d3843b7c | ||
|
|
026f099ba3 | ||
|
|
ff6c3cfa17 | ||
|
|
bf88cd8233 | ||
|
|
c8351ae01b | ||
|
|
7a4cbce460 | ||
|
|
3f835ba847 | ||
|
|
f87fbbdb1d | ||
|
|
caee42e843 | ||
|
|
4e38f96f97 | ||
|
|
814f8ea5fb | ||
|
|
ab3b9dcf5d | ||
|
|
f683c78a69 | ||
|
|
642be61007 | ||
|
|
8d71e6b268 | ||
|
|
6bdc88cfea | ||
|
|
7ff77981f6 | ||
|
|
a9f060e768 | ||
|
|
6de943b226 | ||
|
|
262fe62409 | ||
|
|
9f4e0491ed | ||
|
|
7ee135826f | ||
|
|
5e8d8d6df0 | ||
|
|
f2ddc7b0ae | ||
|
|
01b01c6479 | ||
|
|
3bb5479efd | ||
|
|
85606d830d | ||
|
|
8fe1b88947 | ||
|
|
9144605b57 | ||
|
|
a7a748385f | ||
|
|
d4628b5c0f | ||
|
|
0c65b6cad1 | ||
|
|
0c98390eef | ||
|
|
345a0da337 | ||
|
|
38a7bfecf6 | ||
|
|
6d5bc64b2b | ||
|
|
7c4b2caadf | ||
|
|
6633366b29 | ||
|
|
64dbcf7c92 | ||
|
|
483bf1b309 | ||
|
|
0e96a0aa3e | ||
|
|
e4275bd3d3 | ||
|
|
52c89ca889 | ||
|
|
d484636bba | ||
|
|
084db22cd5 | ||
|
|
081179a4fd | ||
|
|
82d19fc704 | ||
|
|
b1c28d7965 | ||
|
|
6ea74f9fc3 | ||
|
|
278be52f7b | ||
|
|
ee1f983114 | ||
|
|
e3fe80e2a5 | ||
|
|
d3b035cfe9 | ||
|
|
cf29a4a319 | ||
|
|
e9bb0e948b | ||
|
|
5bc52a9425 | ||
|
|
51a8fc1eee | ||
|
|
2867cd523d | ||
|
|
0cf563ae5b | ||
|
|
95beddf613 | ||
|
|
e5a5de6a0d | ||
|
|
0ca85f8a8a | ||
|
|
014e7ba9c4 | ||
|
|
2df3e95efc | ||
|
|
65dfd23021 | ||
|
|
25b916afeb | ||
|
|
6673a5afe1 | ||
|
|
fdd17a2088 | ||
|
|
424b854e29 | ||
|
|
f753783ca0 | ||
|
|
5daaa24a07 | ||
|
|
4ed8ff5576 | ||
|
|
70aefdc9c0 | ||
|
|
f6d47887c4 | ||
|
|
8942e085c3 | ||
|
|
3470fd57ef | ||
|
|
eba6574047 | ||
|
|
43e64a5f8c | ||
|
|
71b82fee03 | ||
|
|
b9f72a2afa | ||
|
|
560115e758 | ||
|
|
dd1241f964 | ||
|
|
dcdc1a6e7b | ||
|
|
50e38cb740 | ||
|
|
508e7acb54 | ||
|
|
e9227f77b6 | ||
|
|
3107b3679d | ||
|
|
49bf9f8b5b | ||
|
|
133d5e34a9 | ||
|
|
9c5965a8c5 | ||
|
|
afc3cfa16a | ||
|
|
c9bdc7da8e | ||
|
|
37d22d6d21 | ||
|
|
b152927dd0 | ||
|
|
f004facb06 | ||
|
|
d6dd449445 | ||
|
|
8c00bad6d0 | ||
|
|
4715cc6447 | ||
|
|
6165d804f9 | ||
|
|
161c6fe2e6 | ||
|
|
1c51db876c | ||
|
|
f26c24ea35 | ||
|
|
48595e3d76 | ||
|
|
bb3d88cce5 | ||
|
|
52084a2c24 | ||
|
|
5a45ec708b | ||
|
|
8d03668d78 | ||
|
|
4a148ac069 | ||
|
|
973513a078 | ||
|
|
412756b651 | ||
|
|
416cd96c94 | ||
|
|
87352470c0 | ||
|
|
27427dd26b | ||
|
|
e2789b2951 | ||
|
|
6a277a5391 | ||
|
|
464ecc7cc6 | ||
|
|
1efa69e51f | ||
|
|
6253d41231 | ||
|
|
b4d6842a7c | ||
|
|
f3e42384c5 | ||
|
|
c29984d0df | ||
|
|
77f6fe161e | ||
|
|
9b08d99fa4 | ||
|
|
0fd43c0a5d | ||
|
|
3ca81f4d73 | ||
|
|
bfe4bc6ee5 | ||
|
|
dec95c3e06 | ||
|
|
2df71be321 | ||
|
|
396446a34b | ||
|
|
2daed3c271 | ||
|
|
c1a3592059 | ||
|
|
57c9d506b8 | ||
|
|
5904de8718 | ||
|
|
ac15fb9be9 | ||
|
|
2159d77fc2 | ||
|
|
e9605891f3 | ||
|
|
9c4c91063f | ||
|
|
4e74c553bd | ||
|
|
9e8b76d348 | ||
|
|
6fa4d1252d | ||
|
|
7a9cfb1a8f | ||
|
|
a0901247a3 | ||
|
|
02a9394cd9 | ||
|
|
ec4bc6c2af | ||
|
|
4e1472f66d | ||
|
|
c6ca1748cb | ||
|
|
25c10c43dd | ||
|
|
044695cb02 | ||
|
|
f44d98924d | ||
|
|
66adffe6d9 | ||
|
|
c91c1f92cd | ||
|
|
bbb116f29c | ||
|
|
a04d6293d1 | ||
|
|
845b182fdf | ||
|
|
2b5fb04ba9 | ||
|
|
bb758d618b | ||
|
|
9b2c7d749b | ||
|
|
51742d66df | ||
|
|
3a101aa0c8 | ||
|
|
7f22d3f486 | ||
|
|
c9d6857c73 | ||
|
|
9648c6f1d3 | ||
|
|
75eb2bbe09 | ||
|
|
d4e231d5d4 | ||
|
|
75dfb87671 | ||
|
|
23936e465d | ||
|
|
13d11bfdcc | ||
|
|
21506f4101 | ||
|
|
51ab8ce41c | ||
|
|
ea3e11e011 | ||
|
|
6ba37a3a8d | ||
|
|
a89511674b | ||
|
|
cd9cca9c6b | ||
|
|
9f6eb02afc | ||
|
|
f8ac9a3f77 | ||
|
|
b28d966645 | ||
|
|
030b525535 | ||
|
|
093bcdfe4f | ||
|
|
5e0cc241a0 | ||
|
|
7d5c7991f4 | ||
|
|
9ced24b127 | ||
|
|
fd32f6d4d5 | ||
|
|
c5d96812f3 | ||
|
|
6de6052185 | ||
|
|
402c955f1c | ||
|
|
2f8cbe4ac2 | ||
|
|
95f94c1cfb | ||
|
|
485fb26393 | ||
|
|
9551c07528 | ||
|
|
2d5a0deb31 | ||
|
|
7d2ea36997 | ||
|
|
97691726f0 | ||
|
|
dce549cc5c | ||
|
|
049e13e365 | ||
|
|
dddb0f7267 | ||
|
|
5de6b8e016 | ||
|
|
a3e9b3df86 | ||
|
|
89e656e709 | ||
|
|
5f5fddb7a4 | ||
|
|
46d3a784a2 | ||
|
|
4998b5ab1b | ||
|
|
368bb77cf0 | ||
|
|
37b416d5c7 | ||
|
|
c7e695d3fe | ||
|
|
a152b0ae54 | ||
|
|
9c77de6473 | ||
|
|
71ca17649c | ||
|
|
41f3d5ccbc | ||
|
|
e32d5490d3 | ||
|
|
d85d3b14f7 | ||
|
|
1daa6abf48 | ||
|
|
5d206f2c20 | ||
|
|
2ff1ee4d33 | ||
|
|
04610e7864 | ||
|
|
da01591ab8 | ||
|
|
cffa76e627 | ||
|
|
9c4cd9c3ce | ||
|
|
eacf70ee3f | ||
|
|
33a35ec7f5 | ||
|
|
e0c07d8921 | ||
|
|
99f6207a69 | ||
|
|
d786be4fc0 | ||
|
|
8a7a659a87 | ||
|
|
f3c6275f8d | ||
|
|
0a2fb2ace7 | ||
|
|
1c1ef951e9 | ||
|
|
45d3d90c94 | ||
|
|
a9870db83f | ||
|
|
697ed0d53c | ||
|
|
3ddaa88694 | ||
|
|
b3454b1c24 | ||
|
|
fcc79456fd | ||
|
|
11c400f12b | ||
|
|
823273f565 | ||
|
|
a542b18a04 | ||
|
|
f2a5337ad2 | ||
|
|
4af5cdd64f | ||
|
|
0fa82743a1 | ||
|
|
45d93ffa8c | ||
|
|
4b98711e07 | ||
|
|
a729038ccd | ||
|
|
e5bd6a8a26 | ||
|
|
5e03fe40a7 | ||
|
|
dab2a50982 | ||
|
|
0e0b31bba6 | ||
|
|
c9d00b1f06 | ||
|
|
9bb258bb99 | ||
|
|
ac10a199ea | ||
|
|
5952181454 | ||
|
|
0da1e186d7 | ||
|
|
d92de14413 | ||
|
|
004c63cd5d | ||
|
|
715e385925 | ||
|
|
891c37b2ed | ||
|
|
e353df588f | ||
|
|
fd0d04eba4 | ||
|
|
22c6f32e92 | ||
|
|
04428d2d07 | ||
|
|
c89f357e4a | ||
|
|
8a968b4dfb | ||
|
|
9aff515c0a | ||
|
|
5f91329397 | ||
|
|
37be587c39 | ||
|
|
0c33575962 | ||
|
|
84edc9cf25 | ||
|
|
14dac9b371 | ||
|
|
8e18d02f7a | ||
|
|
d0ebdd03bd | ||
|
|
bfc3f69adb | ||
|
|
cde0d49e18 | ||
|
|
abf027059f | ||
|
|
4edc2a7a66 | ||
|
|
3b838ca867 | ||
|
|
8b023adba3 | ||
|
|
293b8c0dea | ||
|
|
d6dc57286f | ||
|
|
52b61c9d49 | ||
|
|
780c0e678d | ||
|
|
5bceb5ce52 | ||
|
|
de5e1ca86b | ||
|
|
6c6e65b8ca | ||
|
|
64d818e56e | ||
|
|
d6715914e1 | ||
|
|
f10b3b7cdb | ||
|
|
f844bf4b41 | ||
|
|
6e006a6873 | ||
|
|
cb91829729 | ||
|
|
fb35e40342 | ||
|
|
b796e72faf | ||
|
|
c56ceebb40 | ||
|
|
78fc6dec3c | ||
|
|
7fd6051514 | ||
|
|
072923826d | ||
|
|
c52e3b5f9c | ||
|
|
f6cdd90e41 | ||
|
|
975b266cb0 | ||
|
|
aad1ba4ab3 | ||
|
|
6b5d0a5abf |
10
.env.example
10
.env.example
@@ -5,7 +5,7 @@ APP_ENV=production
|
||||
APP_DEBUG=false
|
||||
APP_KEY=ChangeMe
|
||||
APP_URL=null
|
||||
APP_TIMEZONE='US/Pacific'
|
||||
APP_TIMEZONE='UTC'
|
||||
APP_LOCALE=en
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ DB_DATABASE=null
|
||||
DB_USERNAME=null
|
||||
DB_PASSWORD=null
|
||||
DB_PREFIX=null
|
||||
DB_DUMP_PATH='/usr/local/bin'
|
||||
DB_DUMP_PATH='/usr/bin'
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: OUTGOING MAIL SERVER SETTINGS
|
||||
@@ -30,7 +30,9 @@ MAIL_USERNAME=YOURUSERNAME
|
||||
MAIL_PASSWORD=YOURPASSWORD
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDR=you@example.com
|
||||
MAIL_FROM_NAME=Snipe-IT
|
||||
MAIL_FROM_NAME='Snipe-IT'
|
||||
MAIL_REPLYTO_ADDR=you@example.com
|
||||
MAIL_REPLYTO_NAME='Snipe-IT'
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
@@ -74,3 +76,5 @@ AWS_BUCKET=null
|
||||
APP_LOG=single
|
||||
APP_LOCKED=false
|
||||
FILESYSTEM_DISK=local
|
||||
APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1
|
||||
ALLOW_IFRAMING=false
|
||||
|
||||
68
.gitignore
vendored
68
.gitignore
vendored
@@ -1,49 +1,39 @@
|
||||
/vendor
|
||||
/node_modules
|
||||
Homestead.yaml
|
||||
Homestead.json
|
||||
.env
|
||||
|
||||
tests/_output/*
|
||||
.couscous
|
||||
.DS_Store
|
||||
public/uploads/models/*
|
||||
public/uploads/avatars/*
|
||||
public/uploads/suppliers/*
|
||||
public/uploads/assets/*
|
||||
public/uploads/users/*
|
||||
public/uploads/*.gif
|
||||
public/uploads/*.jpg
|
||||
public/uploads/*.png
|
||||
public/uploads/*.tif
|
||||
public/uploads/*.svg
|
||||
storage/app/private_uploads/users/*
|
||||
phpDocumentor.phar
|
||||
output
|
||||
tests/_support/_generated/*
|
||||
|
||||
|
||||
.env
|
||||
.idea
|
||||
/bin/
|
||||
/bootstrap/compiled.php
|
||||
composer.phar
|
||||
app/config/database.php
|
||||
app/config/mail.php
|
||||
/node_modules
|
||||
/vendor
|
||||
app/database/*.sqlite
|
||||
app/storage/meta/services.json
|
||||
app/config/*/mail.php
|
||||
app/config/*/session.php
|
||||
app/config/*/database.php
|
||||
app/config/*/app.php
|
||||
app/config/*/ldap.php
|
||||
public/packages/*
|
||||
storage/logs/*
|
||||
storage/debugbar/
|
||||
/bin/
|
||||
.idea
|
||||
composer.phar
|
||||
crowdin.yaml
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
output
|
||||
phpDocumentor.phar
|
||||
public/uploads/*.gif
|
||||
public/uploads/barcodes/*.png
|
||||
public/uploads/*.jpg
|
||||
public/uploads/*.png
|
||||
public/uploads/*.svg
|
||||
public/uploads/*.tif
|
||||
public/uploads/assets/*
|
||||
public/uploads/avatars/*
|
||||
public/uploads/logo.gif
|
||||
public/uploads/logo.svg
|
||||
public/uploads/logo.png
|
||||
.couscous
|
||||
public/uploads/logo.svg
|
||||
public/uploads/models/*
|
||||
public/uploads/suppliers/*
|
||||
public/uploads/users/*
|
||||
storage/app/private_uploads/users/*
|
||||
storage/debugbar/
|
||||
storage/dumps/*
|
||||
tests/_data/scenarios
|
||||
storage/laravel-backups
|
||||
storage/logs/*
|
||||
storage/private_uploads/users/*
|
||||
tests/_data/scenarios
|
||||
tests/_output/*
|
||||
tests/_support/_generated/*
|
||||
|
||||
@@ -59,7 +59,7 @@ RUN \
|
||||
rm -rf "/var/www/html/public/uploads/avatars" && ln -fs "/var/lib/snipeit/data/uploads/avatars" "/var/www/html/public/uploads/avatars" && \
|
||||
rm -rf "/var/www/html/public/uploads/models" && ln -fs "/var/lib/snipeit/data/uploads/models" "/var/www/html/public/uploads/models" && \
|
||||
rm -rf "/var/www/html/public/uploads/suppliers" && ln -fs "/var/lib/snipeit/data/uploads/suppliers" "/var/www/html/public/uploads/suppliers" && \
|
||||
rm -r "/var/www/html/storage/backups" && ln -fs "/var/lib/snipeit/dumps" "/var/www/html/storage/backups"
|
||||
rm -r "/var/www/html/storage/app/backups" && ln -fs "/var/lib/snipeit/dumps" "/var/www/html/storage/app/backups"
|
||||
|
||||
############## DEPENDENCIES via COMPOSER ###################
|
||||
|
||||
@@ -80,7 +80,7 @@ RUN cd /var/www/html;composer install
|
||||
|
||||
############### DATA VOLUME #################
|
||||
|
||||
VOLUME [/var/lib/snipeit]
|
||||
VOLUME ["/var/lib/snipeit"]
|
||||
|
||||
##### START SERVER
|
||||
|
||||
|
||||
32
README.md
32
README.md
@@ -1,43 +1,38 @@
|
||||
[](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://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)
|
||||
|
||||
|
||||
## Snipe-IT - Asset Management For the Rest of Us
|
||||
## Snipe-IT - Open Source Asset Management System
|
||||
|
||||
This is a FOSS project for asset management in IT Operations. Knowing who has which laptop, when it was purchased in order to depreciate it correctly, handling software licenses, etc.
|
||||
|
||||
It is built on [Laravel 5.2](http://laravel.com).
|
||||
|
||||
This project is being actively developed and we're [releasing quite frequently](https://github.com/snipe/snipe-it/releases). ([Check out the live demo here](https://snipeitapp.com/demo/).)
|
||||
Snipe-IT is actively developed and we're [releasing quite frequently](https://github.com/snipe/snipe-it/releases). ([Check out the live demo here](https://snipeitapp.com/demo/).)
|
||||
|
||||
__This is web-based software__. This means there there is no executable file (aka no .exe files), and it must be run on a web server and accessed through a web browser. It runs on any Mac OSX, flavor of Linux, as well as Windows.
|
||||
__This is web-based software__. This means there there is no executable file (aka no .exe files), and it must be run on a web server and accessed through a web browser. It runs on any Mac OSX, flavor of Linux, as well as Windows, and we have a [Docker image](https://snipe-it.readme.io/docs/docker) available if that's what you're into.
|
||||
|
||||
-----
|
||||
|
||||
### Installation
|
||||
|
||||
__Installation and configuration documentation for this project has been moved to http://docs.snipeitapp.com.__
|
||||
For instructions on installing and configuring Snipe-IT on your server, check out the [installation manual](https://snipe-it.readme.io/docs). (Please see the [requirements documentation](https://snipe-it.readme.io/docs/requirements) for full requirements.)
|
||||
|
||||
#### Server Requirements
|
||||
Please see the [requirements documentation](http://docs.snipeitapp.com/requirements.html) for full requirements.
|
||||
If you're having trouble with the installation, please check the [Common Issues](https://snipe-it.readme.io/docs/common-issues) and [Getting Help](https://snipe-it.readme.io/docs/getting-help) documentation, and search this repository's open *and* closed issues for help.
|
||||
|
||||
-----
|
||||
### User's Manual
|
||||
For help using Snipe-IT, check out the [user's manual](https://snipe-it-manual.readme.io/docs).
|
||||
|
||||
-----
|
||||
### Bug Reports & Feature Requests
|
||||
|
||||
Feel free to check out the [GitHub Issues for this project](https://github.com/snipe/snipe-it/issues) to open a bug report or see what open issues you can help with. Please search through existing issues (open and closed) to see if your question hasn't already been answered before opening a new issue.
|
||||
|
||||
We use Waffle.io to help better communicate our roadmap with users. Our [project page there](http://waffle.io/snipe/snipe-it) will show you the backlog, what's ready to be worked on, what's in progress, and what's completed.
|
||||
|
||||
If you're having trouble with the installation, please check the [Common Issues](http://docs.snipeitapp.com/common-issues.html) and [Getting Help](http://docs.snipeitapp.com/getting-help.html) documentation.
|
||||
|
||||
-----
|
||||
|
||||
### Upgrading
|
||||
|
||||
Please see the [upgrading documentation](http://docs.snipeitapp.com/upgrading.html) for instructions on upgrading Snipe-IT.
|
||||
Please see the [upgrading documentation](https://snipe-it.readme.io/docs/upgrading) for instructions on upgrading Snipe-IT.
|
||||
|
||||
------
|
||||
### Announcement List
|
||||
@@ -48,14 +43,13 @@ To be notified of important news (such as new releases, security advisories, etc
|
||||
|
||||
### Translations!
|
||||
|
||||
Please see the [translations documentation](http://docs.snipeitapp.com/translations.html) for information about available languages and how to add translations to Snipe-IT.
|
||||
Please see the [translations documentation](https://snipe-it.readme.io/docs/translations) for information about available languages and how to add translations to Snipe-IT.
|
||||
|
||||
-----
|
||||
|
||||
### Contributing
|
||||
|
||||
Please see the documentation on [contributing and developing for Snipe-IT](http://docs.snipeitapp.com/contributing.html).
|
||||
Please see the documentation on [contributing and developing for Snipe-IT](https://snipe-it.readme.io/docs/contributing).
|
||||
|
||||
[](http://waffle.io/snipe/snipe-it)
|
||||
|
||||
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Location;
|
||||
use App\Models\Category;
|
||||
@@ -13,456 +14,450 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||
use Illuminate\Console\Command;
|
||||
use League\Csv\Reader;
|
||||
|
||||
class AssetImportCommand extends Command {
|
||||
class AssetImportCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'snipeit:asset-import';
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'snipeit:asset-import';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Import Assets from CSV';
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Import Assets from CSV';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$filename = $this->argument('filename');
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$filename = $this->argument('filename');
|
||||
|
||||
|
||||
if (!$this->option('testrun')=='true') {
|
||||
$this->comment('======= Importing Assets from '.$filename.' =========');
|
||||
} else {
|
||||
$this->comment('====== TEST ONLY Asset Import for '.$filename.' ====');
|
||||
$this->comment('============== NO DATA WILL BE WRITTEN ==============');
|
||||
}
|
||||
|
||||
if (! ini_get("auto_detect_line_endings")) {
|
||||
ini_set("auto_detect_line_endings", '1');
|
||||
}
|
||||
|
||||
$csv = Reader::createFromPath($this->argument('filename'));
|
||||
$csv->setNewline("\r\n");
|
||||
$csv->setOffset(1);
|
||||
$duplicates = '';
|
||||
|
||||
// Loop through the records
|
||||
$nbInsert = $csv->each(function ($row) use ($duplicates) {
|
||||
$status_id = 1;
|
||||
|
||||
// Let's just map some of these entries to more user friendly words
|
||||
|
||||
// User's name
|
||||
if (array_key_exists('0',$row)) {
|
||||
$user_name = trim($row[0]);
|
||||
} else {
|
||||
$user_name = '';
|
||||
}
|
||||
|
||||
// User's email
|
||||
if (array_key_exists('1',$row)) {
|
||||
$user_email = trim($row[1]);
|
||||
} else {
|
||||
$user_email = '';
|
||||
}
|
||||
|
||||
// User's email
|
||||
if (array_key_exists('2',$row)) {
|
||||
$user_username = trim($row[2]);
|
||||
} else {
|
||||
$user_username = '';
|
||||
}
|
||||
|
||||
// Asset Name
|
||||
if (array_key_exists('3',$row)) {
|
||||
$user_asset_asset_name = trim($row[3]);
|
||||
} else {
|
||||
$user_asset_asset_name = '';
|
||||
}
|
||||
|
||||
// Asset Category
|
||||
if (array_key_exists('4',$row)) {
|
||||
$user_asset_category = trim($row[4]);
|
||||
} else {
|
||||
$user_asset_category = '';
|
||||
}
|
||||
|
||||
// Asset Name
|
||||
if (array_key_exists('5',$row)) {
|
||||
$user_asset_name = trim($row[5]);
|
||||
} else {
|
||||
$user_asset_name = '';
|
||||
}
|
||||
|
||||
// Asset Manufacturer
|
||||
if (array_key_exists('6',$row)) {
|
||||
$user_asset_mfgr = trim($row[6]);
|
||||
} else {
|
||||
$user_asset_mfgr = '';
|
||||
}
|
||||
|
||||
// Asset model number
|
||||
if (array_key_exists('7',$row)) {
|
||||
$user_asset_modelno = trim($row[7]);
|
||||
} else {
|
||||
$user_asset_modelno = '';
|
||||
}
|
||||
|
||||
// Asset serial number
|
||||
if (array_key_exists('8',$row)) {
|
||||
$user_asset_serial = trim($row[8]);
|
||||
} else {
|
||||
$user_asset_serial = '';
|
||||
}
|
||||
|
||||
// Asset tag
|
||||
if (array_key_exists('9',$row)) {
|
||||
$user_asset_tag = trim($row[9]);
|
||||
} else {
|
||||
$user_asset_tag = '';
|
||||
}
|
||||
|
||||
// Asset location
|
||||
if (array_key_exists('10',$row)) {
|
||||
$user_asset_location = trim($row[10]);
|
||||
} else {
|
||||
$user_asset_location = '';
|
||||
}
|
||||
|
||||
// Asset notes
|
||||
if (array_key_exists('11',$row)) {
|
||||
$user_asset_notes = trim($row[11]);
|
||||
} else {
|
||||
$user_asset_notes = '';
|
||||
}
|
||||
|
||||
// Asset purchase date
|
||||
if (array_key_exists('12',$row)) {
|
||||
if ($row[12]!='') {
|
||||
$user_asset_purchase_date = date("Y-m-d 00:00:01", strtotime($row[12]));
|
||||
} else {
|
||||
$user_asset_purchase_date = '';
|
||||
}
|
||||
} else {
|
||||
$user_asset_purchase_date = '';
|
||||
}
|
||||
|
||||
// Asset purchase cost
|
||||
if (array_key_exists('13',$row)) {
|
||||
if ($row[13]!='') {
|
||||
$user_asset_purchase_cost = trim($row[13]);
|
||||
} else {
|
||||
$user_asset_purchase_cost = '';
|
||||
}
|
||||
} else {
|
||||
$user_asset_purchase_cost = '';
|
||||
}
|
||||
|
||||
// Asset Company Name
|
||||
if (array_key_exists('14',$row)) {
|
||||
if ($row[14]!='') {
|
||||
$user_asset_company_name = trim($row[14]);
|
||||
} else {
|
||||
$user_asset_company_name= '';
|
||||
}
|
||||
} else {
|
||||
$user_asset_company_name = '';
|
||||
}
|
||||
|
||||
|
||||
// A number was given instead of a name
|
||||
if (is_numeric($user_name)) {
|
||||
$this->comment('User '.$user_name.' is not a name - assume this user already exists');
|
||||
$user_username = '';
|
||||
$first_name = '';
|
||||
$last_name = '';
|
||||
|
||||
// No name was given
|
||||
} elseif ($user_name=='') {
|
||||
$this->comment('No user data provided - skipping user creation, just adding asset');
|
||||
$first_name = '';
|
||||
$last_name = '';
|
||||
//$user_username = '';
|
||||
|
||||
} else {
|
||||
$user_email_array = User::generateFormattedNameFromFullName($this->option('email_format'), $user_name);
|
||||
$first_name = $user_email_array['first_name'];
|
||||
$last_name = $user_email_array['last_name'];
|
||||
|
||||
if ($user_email=='') {
|
||||
$user_email = $user_email_array['username'].'@'.config('app.domain');
|
||||
}
|
||||
|
||||
if ($user_username=='') {
|
||||
if ($this->option('username_format')=='email') {
|
||||
$user_username = $user_email;
|
||||
} else {
|
||||
$user_name_array = User::generateFormattedNameFromFullName($this->option('username_format'), $user_name);
|
||||
$user_username = $user_name_array['username'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->comment('Full Name: '.$user_name);
|
||||
$this->comment('First Name: '.$first_name);
|
||||
$this->comment('Last Name: '.$last_name);
|
||||
$this->comment('Username: '.$user_username);
|
||||
$this->comment('Email: '.$user_email);
|
||||
$this->comment('Category Name: '.$user_asset_category);
|
||||
$this->comment('Item: '.$user_asset_name);
|
||||
$this->comment('Manufacturer ID: '.$user_asset_mfgr);
|
||||
$this->comment('Model No: '.$user_asset_modelno);
|
||||
$this->comment('Serial No: '.$user_asset_serial);
|
||||
$this->comment('Asset Tag: '.$user_asset_tag);
|
||||
$this->comment('Location: '.$user_asset_location);
|
||||
$this->comment('Purchase Date: '.$user_asset_purchase_date);
|
||||
$this->comment('Purchase Cost: '.$user_asset_purchase_cost);
|
||||
$this->comment('Notes: '.$user_asset_notes);
|
||||
$this->comment('Company Name: '.$user_asset_company_name);
|
||||
|
||||
$this->comment('------------- Action Summary ----------------');
|
||||
|
||||
if ($user_username!='') {
|
||||
if ($user = User::MatchEmailOrUsername($user_username, $user_email)
|
||||
->whereNotNull('username')->first()) {
|
||||
$this->comment('User '.$user_username.' already exists');
|
||||
} else {
|
||||
$user = new \App\Models\User;
|
||||
$password = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
|
||||
|
||||
$user->first_name = $first_name;
|
||||
$user->last_name = $last_name;
|
||||
$user->username = $user_username;
|
||||
$user->email = $user_email;
|
||||
$user->permissions = '{user":1}';
|
||||
$user->password = bcrypt($password);
|
||||
$user->activated = 1;
|
||||
if ($user->save()) {
|
||||
$this->comment('User '.$first_name.' created');
|
||||
} else {
|
||||
$this->error('ERROR CREATING User '.$first_name.' '.$last_name);
|
||||
$this->error($user->getErrors());
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
$user = new User;
|
||||
}
|
||||
|
||||
// Check for the location match and create it if it doesn't exist
|
||||
if ($location = Location::where('name', e($user_asset_location))->first()) {
|
||||
$this->comment('Location '.$user_asset_location.' already exists');
|
||||
} else {
|
||||
|
||||
$location = new Location();
|
||||
|
||||
if ($user_asset_location!='')
|
||||
{
|
||||
$location->name = e($user_asset_location);
|
||||
$location->address = '';
|
||||
$location->city = '';
|
||||
$location->state = '';
|
||||
$location->country = '';
|
||||
$location->user_id = 1;
|
||||
|
||||
if (!$this->option('testrun')=='true') {
|
||||
|
||||
if ($location->save()) {
|
||||
$this->comment('Location '.$user_asset_location.' was created');
|
||||
} else {
|
||||
$this->error('Something went wrong! Location '.$user_asset_location.' was NOT created');
|
||||
$this->error($location->getErrors());
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->comment('Location '.$user_asset_location.' was (not) created - test run only');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->comment('No location given, so none created.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (e($user_asset_category)=='') {
|
||||
$category_name = 'Unnamed Category';
|
||||
if (!$this->option('testrun')=='true') {
|
||||
$this->comment('======= Importing Assets from '.$filename.' =========');
|
||||
} else {
|
||||
$category_name = e($user_asset_category);
|
||||
$this->comment('====== TEST ONLY Asset Import for '.$filename.' ====');
|
||||
$this->comment('============== NO DATA WILL BE WRITTEN ==============');
|
||||
}
|
||||
|
||||
// Check for the category match and create it if it doesn't exist
|
||||
if ($category = Category::where('name', e($category_name))->where('category_type', 'asset')->first()) {
|
||||
$this->comment('Category '.$category_name.' already exists');
|
||||
if (! ini_get("auto_detect_line_endings")) {
|
||||
ini_set("auto_detect_line_endings", '1');
|
||||
}
|
||||
|
||||
} else {
|
||||
$category = new Category();
|
||||
$category->name = e($category_name);
|
||||
$category->category_type = 'asset';
|
||||
$category->user_id = 1;
|
||||
$csv = Reader::createFromPath($this->argument('filename'));
|
||||
$csv->setNewline("\r\n");
|
||||
$csv->setOffset(1);
|
||||
$duplicates = '';
|
||||
|
||||
if ($category->save()) {
|
||||
$this->comment('Category '.$user_asset_category.' was created');
|
||||
// Loop through the records
|
||||
$nbInsert = $csv->each(function ($row) use ($duplicates) {
|
||||
$status_id = 1;
|
||||
|
||||
// Let's just map some of these entries to more user friendly words
|
||||
|
||||
// User's name
|
||||
if (array_key_exists('0', $row)) {
|
||||
$user_name = trim($row[0]);
|
||||
} else {
|
||||
$this->error('Something went wrong! Category '.$user_asset_category.' was NOT created');
|
||||
$this->error($category->getErrors());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check for the manufacturer match and create it if it doesn't exist
|
||||
if ($manufacturer = Manufacturer::where('name', e($user_asset_mfgr))->first()) {
|
||||
$this->comment('Manufacturer '.$user_asset_mfgr.' already exists');
|
||||
} else {
|
||||
$manufacturer = new Manufacturer();
|
||||
$manufacturer->name = e($user_asset_mfgr);
|
||||
$manufacturer->user_id = 1;
|
||||
|
||||
if ($manufacturer->save()) {
|
||||
$this->comment('Manufacturer '.$user_asset_mfgr.' was created');
|
||||
} else {
|
||||
$this->error('Something went wrong! Manufacturer '.$user_asset_mfgr.' was NOT created: '. $manufacturer->getErrors()->first());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check for the asset model match and create it if it doesn't exist
|
||||
if ($asset_model = AssetModel::where('name', e($user_asset_name))->where('modelno', e($user_asset_modelno))->where('category_id', $category->id)->where('manufacturer_id', $manufacturer->id)->first()) {
|
||||
$this->comment('The Asset Model '.$user_asset_name.' with model number '.$user_asset_modelno.' already exists');
|
||||
} else {
|
||||
$asset_model = new AssetModel();
|
||||
$asset_model->name = e($user_asset_name);
|
||||
$asset_model->manufacturer_id = $manufacturer->id;
|
||||
$asset_model->modelno = e($user_asset_modelno);
|
||||
$asset_model->category_id = $category->id;
|
||||
$asset_model->user_id = 1;
|
||||
|
||||
if ($asset_model->save()) {
|
||||
$this->comment('Asset Model '.$user_asset_name.' with model number '.$user_asset_modelno.' was created');
|
||||
} else {
|
||||
$this->error('Something went wrong! Asset Model '.$user_asset_name.' was NOT created: '.$asset_model->getErrors()->first());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check for the asset company match and create it if it doesn't exist
|
||||
if ($user_asset_company_name!='') {
|
||||
if ($company = Company::where('name', e($user_asset_company_name))->first()) {
|
||||
$this->comment('Company '.$user_asset_company_name.' already exists');
|
||||
} else {
|
||||
$company = new Company();
|
||||
$company->name = e($user_asset_company_name);
|
||||
|
||||
if ($company->save()) {
|
||||
$this->comment('Company '.$user_asset_company_name.' was created');
|
||||
} else {
|
||||
$this->error('Something went wrong! Company '.$user_asset_company_name.' was NOT created: '.$company->getErrors()->first());
|
||||
}
|
||||
$user_name = '';
|
||||
}
|
||||
|
||||
} else {
|
||||
$company = new Company();
|
||||
}
|
||||
// User's email
|
||||
if (array_key_exists('1', $row)) {
|
||||
$user_email = trim($row[1]);
|
||||
} else {
|
||||
$user_email = '';
|
||||
}
|
||||
|
||||
// Check for the asset match and create it if it doesn't exist
|
||||
if ($asset = Asset::where('asset_tag', e($user_asset_tag))->first()) {
|
||||
$this->comment('The Asset with asset tag '.$user_asset_tag.' already exists');
|
||||
} else {
|
||||
$asset = new Asset();
|
||||
$asset->name = e($user_asset_asset_name);
|
||||
if ($user_asset_purchase_date!='') {
|
||||
$asset->purchase_date = $user_asset_purchase_date;
|
||||
} else {
|
||||
$asset->purchase_date = NULL;
|
||||
}
|
||||
if ($user_asset_purchase_cost!='') {
|
||||
$asset->purchase_cost = ParseFloat(e($user_asset_purchase_cost));
|
||||
} else {
|
||||
$asset->purchase_cost = 0.00;
|
||||
}
|
||||
$asset->serial = e($user_asset_serial);
|
||||
$asset->asset_tag = e($user_asset_tag);
|
||||
$asset->model_id = $asset_model->id;
|
||||
$asset->assigned_to = $user->id;
|
||||
$asset->rtd_location_id = $location->id;
|
||||
$asset->user_id = 1;
|
||||
$asset->status_id = $status_id;
|
||||
$asset->company_id = $company->id;
|
||||
if ($user_asset_purchase_date!='') {
|
||||
$asset->purchase_date = $user_asset_purchase_date;
|
||||
} else {
|
||||
$asset->purchase_date = NULL;
|
||||
}
|
||||
$asset->notes = e($user_asset_notes);
|
||||
// User's email
|
||||
if (array_key_exists('2', $row)) {
|
||||
$user_username = trim($row[2]);
|
||||
} else {
|
||||
$user_username = '';
|
||||
}
|
||||
|
||||
if ($asset->save()) {
|
||||
$this->comment('Asset '.$user_asset_name.' with serial number '.$user_asset_serial.' was created');
|
||||
} else {
|
||||
$this->error('Something went wrong! Asset '.$user_asset_name.' was NOT created: '.$asset->getErrors()->first());
|
||||
}
|
||||
// Asset Name
|
||||
if (array_key_exists('3', $row)) {
|
||||
$user_asset_asset_name = trim($row[3]);
|
||||
} else {
|
||||
$user_asset_asset_name = '';
|
||||
}
|
||||
|
||||
}
|
||||
// Asset Category
|
||||
if (array_key_exists('4', $row)) {
|
||||
$user_asset_category = trim($row[4]);
|
||||
} else {
|
||||
$user_asset_category = '';
|
||||
}
|
||||
|
||||
// Asset Name
|
||||
if (array_key_exists('5', $row)) {
|
||||
$user_asset_name = trim($row[5]);
|
||||
} else {
|
||||
$user_asset_name = '';
|
||||
}
|
||||
|
||||
// Asset Manufacturer
|
||||
if (array_key_exists('6', $row)) {
|
||||
$user_asset_mfgr = trim($row[6]);
|
||||
} else {
|
||||
$user_asset_mfgr = '';
|
||||
}
|
||||
|
||||
// Asset model number
|
||||
if (array_key_exists('7', $row)) {
|
||||
$user_asset_modelno = trim($row[7]);
|
||||
} else {
|
||||
$user_asset_modelno = '';
|
||||
}
|
||||
|
||||
// Asset serial number
|
||||
if (array_key_exists('8', $row)) {
|
||||
$user_asset_serial = trim($row[8]);
|
||||
} else {
|
||||
$user_asset_serial = '';
|
||||
}
|
||||
|
||||
// Asset tag
|
||||
if (array_key_exists('9', $row)) {
|
||||
$user_asset_tag = trim($row[9]);
|
||||
} else {
|
||||
$user_asset_tag = '';
|
||||
}
|
||||
|
||||
// Asset location
|
||||
if (array_key_exists('10', $row)) {
|
||||
$user_asset_location = trim($row[10]);
|
||||
} else {
|
||||
$user_asset_location = '';
|
||||
}
|
||||
|
||||
// Asset notes
|
||||
if (array_key_exists('11', $row)) {
|
||||
$user_asset_notes = trim($row[11]);
|
||||
} else {
|
||||
$user_asset_notes = '';
|
||||
}
|
||||
|
||||
// Asset purchase date
|
||||
if (array_key_exists('12', $row)) {
|
||||
if ($row[12]!='') {
|
||||
$user_asset_purchase_date = date("Y-m-d 00:00:01", strtotime($row[12]));
|
||||
} else {
|
||||
$user_asset_purchase_date = '';
|
||||
}
|
||||
} else {
|
||||
$user_asset_purchase_date = '';
|
||||
}
|
||||
|
||||
// Asset purchase cost
|
||||
if (array_key_exists('13', $row)) {
|
||||
if ($row[13]!='') {
|
||||
$user_asset_purchase_cost = trim($row[13]);
|
||||
} else {
|
||||
$user_asset_purchase_cost = '';
|
||||
}
|
||||
} else {
|
||||
$user_asset_purchase_cost = '';
|
||||
}
|
||||
|
||||
// Asset Company Name
|
||||
if (array_key_exists('14', $row)) {
|
||||
if ($row[14]!='') {
|
||||
$user_asset_company_name = trim($row[14]);
|
||||
} else {
|
||||
$user_asset_company_name= '';
|
||||
}
|
||||
} else {
|
||||
$user_asset_company_name = '';
|
||||
}
|
||||
|
||||
|
||||
// A number was given instead of a name
|
||||
if (is_numeric($user_name)) {
|
||||
$this->comment('User '.$user_name.' is not a name - assume this user already exists');
|
||||
$user_username = '';
|
||||
$first_name = '';
|
||||
$last_name = '';
|
||||
|
||||
// No name was given
|
||||
} elseif ($user_name=='') {
|
||||
$this->comment('No user data provided - skipping user creation, just adding asset');
|
||||
$first_name = '';
|
||||
$last_name = '';
|
||||
//$user_username = '';
|
||||
|
||||
} else {
|
||||
$user_email_array = User::generateFormattedNameFromFullName($this->option('email_format'), $user_name);
|
||||
$first_name = $user_email_array['first_name'];
|
||||
$last_name = $user_email_array['last_name'];
|
||||
|
||||
if ($user_email=='') {
|
||||
$user_email = $user_email_array['username'].'@'.config('app.domain');
|
||||
}
|
||||
|
||||
if ($user_username=='') {
|
||||
if ($this->option('username_format')=='email') {
|
||||
$user_username = $user_email;
|
||||
} else {
|
||||
$user_name_array = User::generateFormattedNameFromFullName($this->option('username_format'), $user_name);
|
||||
$user_username = $user_name_array['username'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->comment('Full Name: '.$user_name);
|
||||
$this->comment('First Name: '.$first_name);
|
||||
$this->comment('Last Name: '.$last_name);
|
||||
$this->comment('Username: '.$user_username);
|
||||
$this->comment('Email: '.$user_email);
|
||||
$this->comment('Category Name: '.$user_asset_category);
|
||||
$this->comment('Item: '.$user_asset_name);
|
||||
$this->comment('Manufacturer ID: '.$user_asset_mfgr);
|
||||
$this->comment('Model No: '.$user_asset_modelno);
|
||||
$this->comment('Serial No: '.$user_asset_serial);
|
||||
$this->comment('Asset Tag: '.$user_asset_tag);
|
||||
$this->comment('Location: '.$user_asset_location);
|
||||
$this->comment('Purchase Date: '.$user_asset_purchase_date);
|
||||
$this->comment('Purchase Cost: '.$user_asset_purchase_cost);
|
||||
$this->comment('Notes: '.$user_asset_notes);
|
||||
$this->comment('Company Name: '.$user_asset_company_name);
|
||||
|
||||
$this->comment('------------- Action Summary ----------------');
|
||||
|
||||
if ($user_username!='') {
|
||||
if ($user = User::MatchEmailOrUsername($user_username, $user_email)
|
||||
->whereNotNull('username')->first()) {
|
||||
$this->comment('User '.$user_username.' already exists');
|
||||
} else {
|
||||
$user = new \App\Models\User;
|
||||
$password = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
|
||||
|
||||
$user->first_name = $first_name;
|
||||
$user->last_name = $last_name;
|
||||
$user->username = $user_username;
|
||||
$user->email = $user_email;
|
||||
$user->permissions = '{user":1}';
|
||||
$user->password = bcrypt($password);
|
||||
$user->activated = 1;
|
||||
if ($user->save()) {
|
||||
$this->comment('User '.$first_name.' created');
|
||||
} else {
|
||||
$this->error('ERROR CREATING User '.$first_name.' '.$last_name);
|
||||
$this->error($user->getErrors());
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
$user = new User;
|
||||
}
|
||||
|
||||
// Check for the location match and create it if it doesn't exist
|
||||
if ($location = Location::where('name', e($user_asset_location))->first()) {
|
||||
$this->comment('Location '.$user_asset_location.' already exists');
|
||||
} else {
|
||||
|
||||
$location = new Location();
|
||||
|
||||
if ($user_asset_location!='') {
|
||||
$location->name = e($user_asset_location);
|
||||
$location->address = '';
|
||||
$location->city = '';
|
||||
$location->state = '';
|
||||
$location->country = '';
|
||||
$location->user_id = 1;
|
||||
|
||||
if (!$this->option('testrun')=='true') {
|
||||
|
||||
if ($location->save()) {
|
||||
$this->comment('Location '.$user_asset_location.' was created');
|
||||
} else {
|
||||
$this->error('Something went wrong! Location '.$user_asset_location.' was NOT created');
|
||||
$this->error($location->getErrors());
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->comment('Location '.$user_asset_location.' was (not) created - test run only');
|
||||
}
|
||||
} else {
|
||||
$this->comment('No location given, so none created.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (e($user_asset_category)=='') {
|
||||
$category_name = 'Unnamed Category';
|
||||
} else {
|
||||
$category_name = e($user_asset_category);
|
||||
}
|
||||
|
||||
// Check for the category match and create it if it doesn't exist
|
||||
if ($category = Category::where('name', e($category_name))->where('category_type', 'asset')->first()) {
|
||||
$this->comment('Category '.$category_name.' already exists');
|
||||
|
||||
} else {
|
||||
$category = new Category();
|
||||
$category->name = e($category_name);
|
||||
$category->category_type = 'asset';
|
||||
$category->user_id = 1;
|
||||
|
||||
if ($category->save()) {
|
||||
$this->comment('Category '.$user_asset_category.' was created');
|
||||
} else {
|
||||
$this->error('Something went wrong! Category '.$user_asset_category.' was NOT created');
|
||||
$this->error($category->getErrors());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check for the manufacturer match and create it if it doesn't exist
|
||||
if ($manufacturer = Manufacturer::where('name', e($user_asset_mfgr))->first()) {
|
||||
$this->comment('Manufacturer '.$user_asset_mfgr.' already exists');
|
||||
} else {
|
||||
$manufacturer = new Manufacturer();
|
||||
$manufacturer->name = e($user_asset_mfgr);
|
||||
$manufacturer->user_id = 1;
|
||||
|
||||
if ($manufacturer->save()) {
|
||||
$this->comment('Manufacturer '.$user_asset_mfgr.' was created');
|
||||
} else {
|
||||
$this->error('Something went wrong! Manufacturer '.$user_asset_mfgr.' was NOT created: '. $manufacturer->getErrors()->first());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check for the asset model match and create it if it doesn't exist
|
||||
if ($asset_model = AssetModel::where('name', e($user_asset_name))->where('modelno', e($user_asset_modelno))->where('category_id', $category->id)->where('manufacturer_id', $manufacturer->id)->first()) {
|
||||
$this->comment('The Asset Model '.$user_asset_name.' with model number '.$user_asset_modelno.' already exists');
|
||||
} else {
|
||||
$asset_model = new AssetModel();
|
||||
$asset_model->name = e($user_asset_name);
|
||||
$asset_model->manufacturer_id = $manufacturer->id;
|
||||
$asset_model->modelno = e($user_asset_modelno);
|
||||
$asset_model->category_id = $category->id;
|
||||
$asset_model->user_id = 1;
|
||||
|
||||
if ($asset_model->save()) {
|
||||
$this->comment('Asset Model '.$user_asset_name.' with model number '.$user_asset_modelno.' was created');
|
||||
} else {
|
||||
$this->error('Something went wrong! Asset Model '.$user_asset_name.' was NOT created: '.$asset_model->getErrors()->first());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check for the asset company match and create it if it doesn't exist
|
||||
if ($user_asset_company_name!='') {
|
||||
if ($company = Company::where('name', e($user_asset_company_name))->first()) {
|
||||
$this->comment('Company '.$user_asset_company_name.' already exists');
|
||||
} else {
|
||||
$company = new Company();
|
||||
$company->name = e($user_asset_company_name);
|
||||
|
||||
if ($company->save()) {
|
||||
$this->comment('Company '.$user_asset_company_name.' was created');
|
||||
} else {
|
||||
$this->error('Something went wrong! Company '.$user_asset_company_name.' was NOT created: '.$company->getErrors()->first());
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$company = new Company();
|
||||
}
|
||||
|
||||
// Check for the asset match and create it if it doesn't exist
|
||||
if ($asset = Asset::where('asset_tag', e($user_asset_tag))->first()) {
|
||||
$this->comment('The Asset with asset tag '.$user_asset_tag.' already exists');
|
||||
} else {
|
||||
$asset = new Asset();
|
||||
$asset->name = e($user_asset_asset_name);
|
||||
if ($user_asset_purchase_date!='') {
|
||||
$asset->purchase_date = $user_asset_purchase_date;
|
||||
} else {
|
||||
$asset->purchase_date = null;
|
||||
}
|
||||
if ($user_asset_purchase_cost!='') {
|
||||
$asset->purchase_cost = ParseFloat(e($user_asset_purchase_cost));
|
||||
} else {
|
||||
$asset->purchase_cost = 0.00;
|
||||
}
|
||||
$asset->serial = e($user_asset_serial);
|
||||
$asset->asset_tag = e($user_asset_tag);
|
||||
$asset->model_id = $asset_model->id;
|
||||
$asset->assigned_to = $user->id;
|
||||
$asset->rtd_location_id = $location->id;
|
||||
$asset->user_id = 1;
|
||||
$asset->status_id = $status_id;
|
||||
$asset->company_id = $company->id;
|
||||
if ($user_asset_purchase_date!='') {
|
||||
$asset->purchase_date = $user_asset_purchase_date;
|
||||
} else {
|
||||
$asset->purchase_date = null;
|
||||
}
|
||||
$asset->notes = e($user_asset_notes);
|
||||
|
||||
if ($asset->save()) {
|
||||
$this->comment('Asset '.$user_asset_name.' with serial number '.$user_asset_serial.' was created');
|
||||
} else {
|
||||
$this->error('Something went wrong! Asset '.$user_asset_name.' was NOT created: '.$asset->getErrors()->first());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->comment('=====================================');
|
||||
$this->comment('=====================================');
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return array(
|
||||
array('filename', InputArgument::REQUIRED, 'File for the CSV import.'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
array('email_format', null, InputOption::VALUE_REQUIRED, 'The format of the email addresses that should be generated. Options are firstname.lastname, firstname, filastname', null),
|
||||
array('username_format', null, InputOption::VALUE_REQUIRED, 'The format of the username that should be generated. Options are firstname.lastname, firstname, filastname, email', null),
|
||||
array('testrun', null, InputOption::VALUE_REQUIRED, 'Test the output without writing to the database or not.', null),
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return array(
|
||||
array('filename', InputArgument::REQUIRED, 'File for the CSV import.'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
array('email_format', null, InputOption::VALUE_REQUIRED, 'The format of the email addresses that should be generated. Options are firstname.lastname, firstname, filastname', null),
|
||||
array('username_format', null, InputOption::VALUE_REQUIRED, 'The format of the username that should be generated. Options are firstname.lastname, firstname, filastname, email', null),
|
||||
array('testrun', null, InputOption::VALUE_REQUIRED, 'Test the output without writing to the database or not.', null),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,32 +46,32 @@ class CreateAdmin extends Command
|
||||
$show_in_list = $this->argument('show_in_list');
|
||||
|
||||
if (($first_name=='') || ($last_name=='') || ($username=='') || ($email=='') || ($password=='')) {
|
||||
$this->info('ERROR: All fields are required.');
|
||||
$this->info('ERROR: All fields are required.');
|
||||
} else {
|
||||
$user = new \App\Models\User;
|
||||
$user->first_name = $first_name;
|
||||
$user->last_name = $last_name;
|
||||
$user->username = $username;
|
||||
$user->email = $email;
|
||||
$user->permissions = '{"admin":1,"user":1,"superuser":1,"reports.view":1, "licenses.keys":1}';
|
||||
$user->password = bcrypt($password);
|
||||
$user->activated = 1;
|
||||
$user = new \App\Models\User;
|
||||
$user->first_name = $first_name;
|
||||
$user->last_name = $last_name;
|
||||
$user->username = $username;
|
||||
$user->email = $email;
|
||||
$user->permissions = '{"admin":1,"user":1,"superuser":1,"reports.view":1, "licenses.keys":1}';
|
||||
$user->password = bcrypt($password);
|
||||
$user->activated = 1;
|
||||
|
||||
if ($show_in_list == 'false') {
|
||||
$user->show_in_list = 0;
|
||||
}
|
||||
if ($user->save()) {
|
||||
$this->info('New user created');
|
||||
$user->groups()->attach(1);
|
||||
} else {
|
||||
$this->info('Admin user was not created');
|
||||
$errors = $user->getErrors();
|
||||
|
||||
foreach ($errors->all() as $error) {
|
||||
$this->info('ERROR:'. $error);
|
||||
if ($show_in_list == 'false') {
|
||||
$user->show_in_list = 0;
|
||||
}
|
||||
if ($user->save()) {
|
||||
$this->info('New user created');
|
||||
$user->groups()->attach(1);
|
||||
} else {
|
||||
$this->info('Admin user was not created');
|
||||
$errors = $user->getErrors();
|
||||
|
||||
}
|
||||
foreach ($errors->all() as $error) {
|
||||
$this->info('ERROR:'. $error);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -81,5 +81,5 @@ class CreateAdmin extends Command
|
||||
// return array(
|
||||
// array('username', InputArgument::REQUIRED, 'Username'),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Console\Commands;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Setting;
|
||||
|
||||
|
||||
class DisableLDAP extends Command
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -5,378 +5,379 @@ use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use League\Csv\Reader;
|
||||
use App\Models\User;
|
||||
use App\Models\Supplier;
|
||||
use App\Models\License;
|
||||
use App\Models\LicenseSeat;
|
||||
|
||||
class LicenseImportCommand extends Command {
|
||||
class LicenseImportCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'snipeit:license-import';
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'snipeit:license-import';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Import Licenses from CSV';
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Import Licenses from CSV';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$filename = $this->argument('filename');
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$filename = $this->argument('filename');
|
||||
|
||||
|
||||
if (!$this->option('testrun')=='true') {
|
||||
$this->comment('======= Importing Licenses from '.$filename.' =========');
|
||||
} else {
|
||||
$this->comment('====== TEST ONLY License Import for '.$filename.' ====');
|
||||
$this->comment('============== NO DATA WILL BE WRITTEN ==============');
|
||||
}
|
||||
if (!$this->option('testrun')=='true') {
|
||||
$this->comment('======= Importing Licenses from '.$filename.' =========');
|
||||
} else {
|
||||
$this->comment('====== TEST ONLY License Import for '.$filename.' ====');
|
||||
$this->comment('============== NO DATA WILL BE WRITTEN ==============');
|
||||
}
|
||||
|
||||
if (! ini_get("auto_detect_line_endings")) {
|
||||
ini_set("auto_detect_line_endings", '1');
|
||||
}
|
||||
if (! ini_get("auto_detect_line_endings")) {
|
||||
ini_set("auto_detect_line_endings", '1');
|
||||
}
|
||||
|
||||
$csv = Reader::createFromPath($this->argument('filename'));
|
||||
$csv->setNewline("\r\n");
|
||||
$csv->setOffset(1);
|
||||
$duplicates = '';
|
||||
$csv = Reader::createFromPath($this->argument('filename'));
|
||||
$csv->setNewline("\r\n");
|
||||
$csv->setOffset(1);
|
||||
$duplicates = '';
|
||||
|
||||
// Loop through the records
|
||||
$nbInsert = $csv->each(function ($row) use ($duplicates) {
|
||||
$status_id = 1;
|
||||
// Loop through the records
|
||||
$nbInsert = $csv->each(function ($row) use ($duplicates) {
|
||||
$status_id = 1;
|
||||
|
||||
// Let's just map some of these entries to more user friendly words
|
||||
// Let's just map some of these entries to more user friendly words
|
||||
|
||||
if (array_key_exists('0',$row)) {
|
||||
$user_name = trim($row[0]);
|
||||
} else {
|
||||
$user_name = '';
|
||||
}
|
||||
if (array_key_exists('0', $row)) {
|
||||
$user_name = trim($row[0]);
|
||||
} else {
|
||||
$user_name = '';
|
||||
}
|
||||
|
||||
if (array_key_exists('1',$row)) {
|
||||
$user_email = trim($row[1]);
|
||||
} else {
|
||||
$user_email = '';
|
||||
}
|
||||
if (array_key_exists('1', $row)) {
|
||||
$user_email = trim($row[1]);
|
||||
} else {
|
||||
$user_email = '';
|
||||
}
|
||||
|
||||
if (array_key_exists('2',$row)) {
|
||||
$user_username = trim($row[2]);
|
||||
} else {
|
||||
$user_username = '';
|
||||
}
|
||||
if (array_key_exists('2', $row)) {
|
||||
$user_username = trim($row[2]);
|
||||
} else {
|
||||
$user_username = '';
|
||||
}
|
||||
|
||||
if (array_key_exists('3',$row)) {
|
||||
$user_license_name = trim($row[3]);
|
||||
} else {
|
||||
$user_license_name = '';
|
||||
}
|
||||
if (array_key_exists('3', $row)) {
|
||||
$user_license_name = trim($row[3]);
|
||||
} else {
|
||||
$user_license_name = '';
|
||||
}
|
||||
|
||||
if (array_key_exists('4',$row)) {
|
||||
$user_license_serial = trim($row[4]);
|
||||
} else {
|
||||
$user_license_serial = '';
|
||||
}
|
||||
if (array_key_exists('4', $row)) {
|
||||
$user_license_serial = trim($row[4]);
|
||||
} else {
|
||||
$user_license_serial = '';
|
||||
}
|
||||
|
||||
if (array_key_exists('5',$row)) {
|
||||
$user_licensed_to_name = trim($row[5]);
|
||||
} else {
|
||||
$user_licensed_to_name = '';
|
||||
}
|
||||
if (array_key_exists('5', $row)) {
|
||||
$user_licensed_to_name = trim($row[5]);
|
||||
} else {
|
||||
$user_licensed_to_name = '';
|
||||
}
|
||||
|
||||
if (array_key_exists('6',$row)) {
|
||||
$user_licensed_to_email = trim($row[6]);
|
||||
} else {
|
||||
$user_licensed_to_email = '';
|
||||
}
|
||||
if (array_key_exists('6', $row)) {
|
||||
$user_licensed_to_email = trim($row[6]);
|
||||
} else {
|
||||
$user_licensed_to_email = '';
|
||||
}
|
||||
|
||||
if (array_key_exists('7',$row)) {
|
||||
$user_license_seats = trim($row[7]);
|
||||
} else {
|
||||
$user_license_seats = '';
|
||||
}
|
||||
if (array_key_exists('7', $row)) {
|
||||
$user_license_seats = trim($row[7]);
|
||||
} else {
|
||||
$user_license_seats = '';
|
||||
}
|
||||
|
||||
if (array_key_exists('8',$row)) {
|
||||
$user_license_reassignable = trim($row[8]);
|
||||
if ($user_license_reassignable!='') {
|
||||
if ((strtolower($user_license_reassignable)=='yes') || (strtolower($user_license_reassignable)=='true') || ($user_license_reassignable=='1')) {
|
||||
$user_license_reassignable = 1;
|
||||
}
|
||||
} else {
|
||||
$user_license_reassignable = 0;
|
||||
}
|
||||
} else {
|
||||
$user_license_reassignable = 0;
|
||||
}
|
||||
if (array_key_exists('8', $row)) {
|
||||
$user_license_reassignable = trim($row[8]);
|
||||
if ($user_license_reassignable!='') {
|
||||
if ((strtolower($user_license_reassignable)=='yes') || (strtolower($user_license_reassignable)=='true') || ($user_license_reassignable=='1')) {
|
||||
$user_license_reassignable = 1;
|
||||
}
|
||||
} else {
|
||||
$user_license_reassignable = 0;
|
||||
}
|
||||
} else {
|
||||
$user_license_reassignable = 0;
|
||||
}
|
||||
|
||||
if (array_key_exists('9',$row)) {
|
||||
$user_license_supplier = trim($row[9]);
|
||||
} else {
|
||||
$user_license_supplier = '';
|
||||
}
|
||||
if (array_key_exists('9', $row)) {
|
||||
$user_license_supplier = trim($row[9]);
|
||||
} else {
|
||||
$user_license_supplier = '';
|
||||
}
|
||||
|
||||
if (array_key_exists('10',$row)) {
|
||||
$user_license_maintained = trim($row[10]);
|
||||
if (array_key_exists('10', $row)) {
|
||||
$user_license_maintained = trim($row[10]);
|
||||
|
||||
if ($user_license_maintained!='') {
|
||||
if ((strtolower($user_license_maintained)=='yes') || (strtolower($user_license_maintained)=='true') || ($user_license_maintained=='1')) {
|
||||
$user_license_maintained = 1;
|
||||
}
|
||||
} else {
|
||||
$user_license_maintained = 0;
|
||||
}
|
||||
if ($user_license_maintained!='') {
|
||||
if ((strtolower($user_license_maintained)=='yes') || (strtolower($user_license_maintained)=='true') || ($user_license_maintained=='1')) {
|
||||
$user_license_maintained = 1;
|
||||
}
|
||||
} else {
|
||||
$user_license_maintained = 0;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$user_license_maintained = '';
|
||||
}
|
||||
} else {
|
||||
$user_license_maintained = '';
|
||||
}
|
||||
|
||||
if (array_key_exists('11',$row)) {
|
||||
$user_license_notes = trim($row[11]);
|
||||
} else {
|
||||
$user_license_notes = '';
|
||||
}
|
||||
if (array_key_exists('11', $row)) {
|
||||
$user_license_notes = trim($row[11]);
|
||||
} else {
|
||||
$user_license_notes = '';
|
||||
}
|
||||
|
||||
if (array_key_exists('12',$row)) {
|
||||
if ($row[12]!='') {
|
||||
$user_license_purchase_date = date("Y-m-d 00:00:01", strtotime($row[12]));
|
||||
} else {
|
||||
$user_license_purchase_date = '';
|
||||
}
|
||||
} else {
|
||||
$user_license_purchase_date = 0;
|
||||
}
|
||||
if (array_key_exists('12', $row)) {
|
||||
if ($row[12]!='') {
|
||||
$user_license_purchase_date = date("Y-m-d 00:00:01", strtotime($row[12]));
|
||||
} else {
|
||||
$user_license_purchase_date = '';
|
||||
}
|
||||
} else {
|
||||
$user_license_purchase_date = 0;
|
||||
}
|
||||
|
||||
// A number was given instead of a name
|
||||
if (is_numeric($user_name)) {
|
||||
$this->comment('User '.$user_name.' is not a name - assume this user already exists');
|
||||
$user_username = '';
|
||||
// No name was given
|
||||
// A number was given instead of a name
|
||||
if (is_numeric($user_name)) {
|
||||
$this->comment('User '.$user_name.' is not a name - assume this user already exists');
|
||||
$user_username = '';
|
||||
// No name was given
|
||||
|
||||
} elseif ($user_name=='') {
|
||||
$this->comment('No user data provided - skipping user creation, just adding license');
|
||||
$first_name = '';
|
||||
$last_name = '';
|
||||
$user_username = '';
|
||||
} elseif ($user_name=='') {
|
||||
$this->comment('No user data provided - skipping user creation, just adding license');
|
||||
$first_name = '';
|
||||
$last_name = '';
|
||||
$user_username = '';
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
$name = explode(" ", $user_name);
|
||||
$first_name = $name[0];
|
||||
$email_last_name = '';
|
||||
$email_prefix = $first_name;
|
||||
$name = explode(" ", $user_name);
|
||||
$first_name = $name[0];
|
||||
$email_last_name = '';
|
||||
$email_prefix = $first_name;
|
||||
|
||||
if (!array_key_exists(1, $name)) {
|
||||
$last_name='';
|
||||
$email_last_name = $last_name;
|
||||
$email_prefix = $first_name;
|
||||
} else {
|
||||
$last_name = str_replace($first_name,'',$user_name);
|
||||
if (!array_key_exists(1, $name)) {
|
||||
$last_name='';
|
||||
$email_last_name = $last_name;
|
||||
$email_prefix = $first_name;
|
||||
} else {
|
||||
$last_name = str_replace($first_name, '', $user_name);
|
||||
|
||||
if ($this->option('email_format')=='filastname') {
|
||||
$email_last_name.=str_replace(' ','',$last_name);
|
||||
$email_prefix = $first_name[0].$email_last_name;
|
||||
if ($this->option('email_format')=='filastname') {
|
||||
$email_last_name.=str_replace(' ', '', $last_name);
|
||||
$email_prefix = $first_name[0].$email_last_name;
|
||||
|
||||
} elseif ($this->option('email_format')=='firstname.lastname') {
|
||||
$email_last_name.=str_replace(' ','',$last_name);
|
||||
$email_prefix = $first_name.'.'.$email_last_name;
|
||||
} elseif ($this->option('email_format')=='firstname.lastname') {
|
||||
$email_last_name.=str_replace(' ', '', $last_name);
|
||||
$email_prefix = $first_name.'.'.$email_last_name;
|
||||
|
||||
} elseif ($this->option('email_format')=='firstname') {
|
||||
$email_last_name.=str_replace(' ','',$last_name);
|
||||
$email_prefix = $first_name;
|
||||
}
|
||||
} elseif ($this->option('email_format')=='firstname') {
|
||||
$email_last_name.=str_replace(' ', '', $last_name);
|
||||
$email_prefix = $first_name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$user_username = $email_prefix;
|
||||
$user_username = $email_prefix;
|
||||
|
||||
// Generate an email based on their name if no email address is given
|
||||
if ($user_email=='') {
|
||||
if ($first_name=='Unknown') {
|
||||
$status_id = 7;
|
||||
}
|
||||
$email = strtolower($email_prefix).'@'.$this->option('domain');
|
||||
$user_email = str_replace("'",'',$email);
|
||||
}
|
||||
}
|
||||
// Generate an email based on their name if no email address is given
|
||||
if ($user_email=='') {
|
||||
if ($first_name=='Unknown') {
|
||||
$status_id = 7;
|
||||
}
|
||||
$email = strtolower($email_prefix).'@'.$this->option('domain');
|
||||
$user_email = str_replace("'", '', $email);
|
||||
}
|
||||
}
|
||||
|
||||
$this->comment('Full Name: '.$user_name);
|
||||
$this->comment('First Name: '.$first_name);
|
||||
$this->comment('Last Name: '.$last_name);
|
||||
$this->comment('Username: '.$user_username);
|
||||
$this->comment('Email: '.$user_email);
|
||||
$this->comment('License Name: '.$user_license_name);
|
||||
$this->comment('Serial No: '.$user_license_serial);
|
||||
$this->comment('Licensed To Name: '.$user_licensed_to_name);
|
||||
$this->comment('Licensed To Email: '.$user_licensed_to_email);
|
||||
$this->comment('Seats: '.$user_license_seats);
|
||||
$this->comment('Reassignable: '.$user_license_reassignable);
|
||||
$this->comment('Supplier: '.$user_license_supplier);
|
||||
$this->comment('Maintained: '.$user_license_maintained);
|
||||
$this->comment('Notes: '.$user_license_notes);
|
||||
$this->comment('Purchase Date: '.$user_license_purchase_date);
|
||||
$this->comment('Full Name: '.$user_name);
|
||||
$this->comment('First Name: '.$first_name);
|
||||
$this->comment('Last Name: '.$last_name);
|
||||
$this->comment('Username: '.$user_username);
|
||||
$this->comment('Email: '.$user_email);
|
||||
$this->comment('License Name: '.$user_license_name);
|
||||
$this->comment('Serial No: '.$user_license_serial);
|
||||
$this->comment('Licensed To Name: '.$user_licensed_to_name);
|
||||
$this->comment('Licensed To Email: '.$user_licensed_to_email);
|
||||
$this->comment('Seats: '.$user_license_seats);
|
||||
$this->comment('Reassignable: '.$user_license_reassignable);
|
||||
$this->comment('Supplier: '.$user_license_supplier);
|
||||
$this->comment('Maintained: '.$user_license_maintained);
|
||||
$this->comment('Notes: '.$user_license_notes);
|
||||
$this->comment('Purchase Date: '.$user_license_purchase_date);
|
||||
|
||||
$this->comment('------------- Action Summary ----------------');
|
||||
$this->comment('------------- Action Summary ----------------');
|
||||
|
||||
if ($user_username!='') {
|
||||
if ($user = User::where('username', $user_username)->whereNotNull('username')->first()) {
|
||||
$this->comment('User '.$user_username.' already exists');
|
||||
} else {
|
||||
// Create the user
|
||||
$user = Sentry::createUser(array(
|
||||
'first_name' => $first_name,
|
||||
'last_name' => $last_name,
|
||||
'email' => $user_email,
|
||||
'username' => $user_username,
|
||||
'password' => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10),
|
||||
'activated' => true,
|
||||
'permissions' => array(
|
||||
'admin' => 0,
|
||||
'user' => 1,
|
||||
),
|
||||
'notes' => 'User importerd through license importer'
|
||||
));
|
||||
if ($user_username!='') {
|
||||
if ($user = User::where('username', $user_username)->whereNotNull('username')->first()) {
|
||||
$this->comment('User '.$user_username.' already exists');
|
||||
} else {
|
||||
|
||||
// Find the group using the group id
|
||||
$userGroup = Sentry::findGroupById(3);
|
||||
$user = new \App\Models\User;
|
||||
$password = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
|
||||
|
||||
// Assign the group to the user
|
||||
$user->addGroup($userGroup);
|
||||
$this->comment('User '.$first_name.' created');
|
||||
}
|
||||
} else {
|
||||
$user = new User;
|
||||
$user->user_id = NULL;
|
||||
}
|
||||
$user->first_name = $first_name;
|
||||
$user->last_name = $last_name;
|
||||
$user->username = $user_username;
|
||||
$user->email = $user_email;
|
||||
$user->permissions = '{user":1}';
|
||||
$user->password = bcrypt($password);
|
||||
$user->activated = 1;
|
||||
if ($user->save()) {
|
||||
$this->comment('User '.$first_name.' created');
|
||||
} else {
|
||||
$this->error('ERROR CREATING User '.$first_name.' '.$last_name);
|
||||
$this->error($user->getErrors());
|
||||
}
|
||||
|
||||
$this->comment('User '.$first_name.' created');
|
||||
}
|
||||
} else {
|
||||
$user = new User;
|
||||
$user->user_id = null;
|
||||
}
|
||||
|
||||
|
||||
// Check for the supplier match and create it if it doesn't exist
|
||||
if ($supplier = Supplier::where('name', $user_license_supplier)->first()) {
|
||||
$this->comment('Supplier '.$user_license_supplier.' already exists');
|
||||
} else {
|
||||
$supplier = new Supplier();
|
||||
$supplier->name = e($user_license_supplier);
|
||||
$supplier->user_id = 1;
|
||||
// Check for the supplier match and create it if it doesn't exist
|
||||
if ($supplier = Supplier::where('name', $user_license_supplier)->first()) {
|
||||
$this->comment('Supplier '.$user_license_supplier.' already exists');
|
||||
} else {
|
||||
$supplier = new Supplier();
|
||||
$supplier->name = e($user_license_supplier);
|
||||
$supplier->user_id = 1;
|
||||
|
||||
if ($supplier->save()) {
|
||||
$this->comment('Supplier '.$user_license_supplier.' was created');
|
||||
} else {
|
||||
$this->comment('Something went wrong! Supplier '.$user_license_supplier.' was NOT created');
|
||||
}
|
||||
if ($supplier->save()) {
|
||||
$this->comment('Supplier '.$user_license_supplier.' was created');
|
||||
} else {
|
||||
$this->comment('Something went wrong! Supplier '.$user_license_supplier.' was NOT created');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add the license
|
||||
$license = new License();
|
||||
$license->name = e($user_license_name);
|
||||
if ($user_license_purchase_date!='') {
|
||||
$license->purchase_date = $user_license_purchase_date;
|
||||
} else {
|
||||
$license->purchase_date = NULL;
|
||||
}
|
||||
$license->serial = e($user_license_serial);
|
||||
$license->seats = e($user_license_seats);
|
||||
$license->supplier_id = $supplier->id;
|
||||
$license->user_id = 1;
|
||||
if ($user_license_purchase_date!='') {
|
||||
$license->purchase_date = $user_license_purchase_date;
|
||||
} else {
|
||||
$license->purchase_date = NULL;
|
||||
}
|
||||
$license->license_name = $user_licensed_to_name;
|
||||
$license->license_email = $user_licensed_to_email;
|
||||
$license->notes = e($user_license_notes);
|
||||
// Add the license
|
||||
$license = new License();
|
||||
$license->name = e($user_license_name);
|
||||
if ($user_license_purchase_date!='') {
|
||||
$license->purchase_date = $user_license_purchase_date;
|
||||
} else {
|
||||
$license->purchase_date = null;
|
||||
}
|
||||
$license->serial = e($user_license_serial);
|
||||
$license->seats = e($user_license_seats);
|
||||
$license->supplier_id = $supplier->id;
|
||||
$license->user_id = 1;
|
||||
if ($user_license_purchase_date!='') {
|
||||
$license->purchase_date = $user_license_purchase_date;
|
||||
} else {
|
||||
$license->purchase_date = null;
|
||||
}
|
||||
$license->license_name = $user_licensed_to_name;
|
||||
$license->license_email = $user_licensed_to_email;
|
||||
$license->notes = e($user_license_notes);
|
||||
|
||||
if ($license->save()) {
|
||||
$this->comment('License '.$user_license_name.' with serial number '.$user_license_serial.' was created');
|
||||
if ($license->save()) {
|
||||
$this->comment('License '.$user_license_name.' with serial number '.$user_license_serial.' was created');
|
||||
|
||||
|
||||
$license_seat_created = 0;
|
||||
$license_seat_created = 0;
|
||||
|
||||
for ($x = 0; $x < $user_license_seats; $x++) {
|
||||
// Create the license seat entries
|
||||
$license_seat = new LicenseSeat();
|
||||
$license_seat->license_id = $license->id;
|
||||
for ($x = 0; $x < $user_license_seats; $x++) {
|
||||
// Create the license seat entries
|
||||
$license_seat = new LicenseSeat();
|
||||
$license_seat->license_id = $license->id;
|
||||
|
||||
// Only assign the first seat to the user
|
||||
if ($x==0) {
|
||||
$license_seat->assigned_to = $user->id;
|
||||
} else {
|
||||
$license_seat->assigned_to = NULL;
|
||||
}
|
||||
// Only assign the first seat to the user
|
||||
if ($x==0) {
|
||||
$license_seat->assigned_to = $user->id;
|
||||
} else {
|
||||
$license_seat->assigned_to = null;
|
||||
}
|
||||
|
||||
if ($license_seat->save()) {
|
||||
$license_seat_created++;
|
||||
}
|
||||
}
|
||||
if ($license_seat->save()) {
|
||||
$license_seat_created++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($license_seat_created > 0) {
|
||||
$this->comment($license_seat_created.' seats were created');
|
||||
} else {
|
||||
$this->comment('Something went wrong! NO seats for '.$user_license_name.' were created');
|
||||
}
|
||||
if ($license_seat_created > 0) {
|
||||
$this->comment($license_seat_created.' seats were created');
|
||||
} else {
|
||||
$this->comment('Something went wrong! NO seats for '.$user_license_name.' were created');
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
$this->comment('Something went wrong! License '.$user_license_name.' was NOT created');
|
||||
}
|
||||
$this->comment('Something went wrong! License '.$user_license_name.' was NOT created');
|
||||
}
|
||||
|
||||
|
||||
$this->comment('=====================================');
|
||||
$this->comment('=====================================');
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return array(
|
||||
array('filename', InputArgument::REQUIRED, 'File for the CSV import.'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
array('domain', null, InputOption::VALUE_REQUIRED, 'Email domain for generated email addresses.', null),
|
||||
array('email_format', null, InputOption::VALUE_REQUIRED, 'The format of the email addresses that should be generated. Options are firstname.lastname, firstname, filastname', null),
|
||||
array('testrun', null, InputOption::VALUE_REQUIRED, 'Test the output without writing to the database or not.', null),
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return array(
|
||||
array('filename', InputArgument::REQUIRED, 'File for the CSV import.'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
array('domain', null, InputOption::VALUE_REQUIRED, 'Email domain for generated email addresses.', null),
|
||||
array('email_format', null, InputOption::VALUE_REQUIRED, 'The format of the email addresses that should be generated. Options are firstname.lastname, firstname, filastname', null),
|
||||
array('testrun', null, InputOption::VALUE_REQUIRED, 'Test the output without writing to the database or not.', null),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,22 @@ namespace App\Console\Commands;
|
||||
use Illuminate\Console\Command;
|
||||
use DB;
|
||||
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\Component;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\Depreciation;
|
||||
use App\Models\Group;
|
||||
use App\Models\License;
|
||||
use App\Models\LicenseSeat;
|
||||
use App\Models\Location;
|
||||
use App\Models\Manufacturer;
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\Supplier;
|
||||
|
||||
class PaveIt extends Command
|
||||
{
|
||||
/**
|
||||
@@ -12,7 +28,8 @@ class PaveIt extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'snipeit:pave';
|
||||
protected $signature = 'snipeit:pave
|
||||
{--soft : Perform a "Soft" Delete, leaving all migrations, table structure, and the first user in place.}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -38,45 +55,78 @@ class PaveIt extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if ($this->confirm("\n****************************************************\nTHIS WILL DELETE ALL OF THE DATA IN YOUR DATABASE. \nThere is NO undo. This WILL destroy ALL of your data. \n****************************************************\n\nDo you wish to continue? No backsies! [y|N]")) {
|
||||
if ($this->option('soft')) {
|
||||
Accessory::getQuery()->delete();
|
||||
Asset::getQuery()->delete();
|
||||
Category::getQuery()->delete();
|
||||
Company::getQuery()->delete();
|
||||
Component::getQuery()->delete();
|
||||
Consumable::getQuery()->delete();
|
||||
Depreciation::getQuery()->delete();
|
||||
License::getQuery()->delete();
|
||||
LicenseSeat::getQuery()->delete();
|
||||
Location::getQuery()->delete();
|
||||
Manufacturer::getQuery()->delete();
|
||||
AssetModel::getQuery()->delete();
|
||||
Statuslabel::getQuery()->delete();
|
||||
Supplier::getQuery()->delete();
|
||||
Group::getQuery()->delete();
|
||||
|
||||
if ($this->confirm("\n****************************************************\nTHIS WILL DROP ALL OF THE TABLES IN YOUR DATABASE. \nThere is NO undo. This WILL destroy ALL of your data. \n****************************************************\n\nDo you wish to continue? No backsies! [y|N]")) {
|
||||
|
||||
\DB::statement('drop table IF EXISTS accessories_users');
|
||||
\DB::statement('drop table IF EXISTS accessories');
|
||||
\DB::statement('drop table IF EXISTS asset_logs');
|
||||
\DB::statement('drop table IF EXISTS asset_maintenances');
|
||||
\DB::statement('drop table IF EXISTS asset_uploads');
|
||||
\DB::statement('drop table IF EXISTS assets');
|
||||
\DB::statement('drop table IF EXISTS categories');
|
||||
\DB::statement('drop table IF EXISTS companies');
|
||||
\DB::statement('drop table IF EXISTS consumables_users');
|
||||
\DB::statement('drop table IF EXISTS consumables');
|
||||
\DB::statement('drop table IF EXISTS custom_field_custom_fieldset');
|
||||
\DB::statement('drop table IF EXISTS custom_fields');
|
||||
\DB::statement('drop table IF EXISTS custom_fieldsets');
|
||||
\DB::statement('drop table IF EXISTS depreciations');
|
||||
\DB::statement('drop table IF EXISTS groups');
|
||||
\DB::statement('drop table IF EXISTS history');
|
||||
\DB::statement('drop table IF EXISTS components');
|
||||
\DB::statement('drop table IF EXISTS components_assets');
|
||||
\DB::statement('drop table IF EXISTS license_seats');
|
||||
\DB::statement('drop table IF EXISTS licenses');
|
||||
\DB::statement('drop table IF EXISTS locations');
|
||||
\DB::statement('drop table IF EXISTS manufacturers');
|
||||
\DB::statement('drop table IF EXISTS models');
|
||||
\DB::statement('drop table IF EXISTS migrations');
|
||||
\DB::statement('drop table IF EXISTS password_resets');
|
||||
\DB::statement('drop table IF EXISTS requested_assets');
|
||||
\DB::statement('drop table IF EXISTS requests');
|
||||
\DB::statement('drop table IF EXISTS settings');
|
||||
\DB::statement('drop table IF EXISTS status_labels');
|
||||
\DB::statement('drop table IF EXISTS suppliers');
|
||||
\DB::statement('drop table IF EXISTS throttle');
|
||||
\DB::statement('drop table IF EXISTS users_groups');
|
||||
\DB::statement('drop table IF EXISTS users');
|
||||
|
||||
|
||||
DB::statement('delete from accessories_users');
|
||||
DB::statement('delete from asset_logs');
|
||||
DB::statement('delete from asset_maintenances');
|
||||
DB::statement('delete from asset_uploads');
|
||||
DB::statement('delete from action_logs');
|
||||
DB::statement('delete from checkout_requests');
|
||||
DB::statement('delete from consumables_users');
|
||||
DB::statement('delete from custom_field_custom_fieldset');
|
||||
DB::statement('delete from custom_fields');
|
||||
DB::statement('delete from custom_fieldsets');
|
||||
DB::statement('delete from components_assets');
|
||||
DB::statement('delete from password_resets');
|
||||
DB::statement('delete from requested_assets');
|
||||
DB::statement('delete from requests');
|
||||
DB::statement('delete from throttle');
|
||||
DB::statement('delete from users_groups');
|
||||
DB::statement('delete from users WHERE id!=1');
|
||||
} else {
|
||||
\DB::statement('drop table IF EXISTS accessories_users');
|
||||
\DB::statement('drop table IF EXISTS accessories');
|
||||
\DB::statement('drop table IF EXISTS asset_logs');
|
||||
\DB::statement('drop table IF EXISTS action_logs');
|
||||
\DB::statement('drop table IF EXISTS asset_maintenances');
|
||||
\DB::statement('drop table IF EXISTS asset_uploads');
|
||||
\DB::statement('drop table IF EXISTS assets');
|
||||
\DB::statement('drop table IF EXISTS categories');
|
||||
\DB::statement('drop table IF EXISTS checkout_requests');
|
||||
\DB::statement('drop table IF EXISTS companies');
|
||||
\DB::statement('drop table IF EXISTS consumables_users');
|
||||
\DB::statement('drop table IF EXISTS consumables');
|
||||
\DB::statement('drop table IF EXISTS custom_field_custom_fieldset');
|
||||
\DB::statement('drop table IF EXISTS custom_fields');
|
||||
\DB::statement('drop table IF EXISTS custom_fieldsets');
|
||||
\DB::statement('drop table IF EXISTS depreciations');
|
||||
\DB::statement('drop table IF EXISTS groups');
|
||||
\DB::statement('drop table IF EXISTS history');
|
||||
\DB::statement('drop table IF EXISTS components');
|
||||
\DB::statement('drop table IF EXISTS components_assets');
|
||||
\DB::statement('drop table IF EXISTS license_seats');
|
||||
\DB::statement('drop table IF EXISTS licenses');
|
||||
\DB::statement('drop table IF EXISTS locations');
|
||||
\DB::statement('drop table IF EXISTS manufacturers');
|
||||
\DB::statement('drop table IF EXISTS models');
|
||||
\DB::statement('drop table IF EXISTS migrations');
|
||||
\DB::statement('drop table IF EXISTS password_resets');
|
||||
\DB::statement('drop table IF EXISTS requested_assets');
|
||||
\DB::statement('drop table IF EXISTS requests');
|
||||
\DB::statement('drop table IF EXISTS settings');
|
||||
\DB::statement('drop table IF EXISTS status_labels');
|
||||
\DB::statement('drop table IF EXISTS suppliers');
|
||||
\DB::statement('drop table IF EXISTS throttle');
|
||||
\DB::statement('drop table IF EXISTS users_groups');
|
||||
\DB::statement('drop table IF EXISTS users');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class Purge extends Command
|
||||
public function handle()
|
||||
{
|
||||
$force = $this->option('force');
|
||||
if (($this->confirm("\n****************************************************\nTHIS WILL PURGE ALL SOFT-DELETED ITEMS IN YOUR SYSTEM. \nThere is NO undo. This WILL permanently destroy \nALL of your deleted data. \n****************************************************\n\nDo you wish to continue? No backsies! [y|N]")) || $force == 'true') {
|
||||
if (($this->confirm("\n****************************************************\nTHIS WILL PURGE ALL SOFT-DELETED ITEMS IN YOUR SYSTEM. \nThere is NO undo. This WILL permanently destroy \nALL of your deleted data. \n****************************************************\n\nDo you wish to continue? No backsies! [y|N]")) || $force == 'true') {
|
||||
|
||||
/**
|
||||
* Delete assets
|
||||
@@ -62,15 +62,19 @@ class Purge extends Command
|
||||
$assetcount = $assets->count();
|
||||
$this->info($assets->count().' assets purged.');
|
||||
$asset_assoc = 0;
|
||||
$asset_maintenances = 0;
|
||||
|
||||
foreach ($assets as $asset) {
|
||||
$this->info('- Asset "'.$asset->showAssetName().'" deleted.');
|
||||
$asset_assoc += $asset->assetlog()->count();
|
||||
$asset->assetlog()->forceDelete();
|
||||
$asset_maintenances += $asset->assetmaintenances()->count();
|
||||
$asset->assetmaintenances()->forceDelete();
|
||||
$asset->forceDelete();
|
||||
}
|
||||
|
||||
$this->info($asset_assoc.' corresponding log records purged.');
|
||||
$this->info($asset_maintenances.' corresponding maintenance records purged.');
|
||||
|
||||
$locations = Location::whereNotNull('deleted_at')->withTrashed()->get();
|
||||
$this->info($locations->count().' locations purged.');
|
||||
@@ -140,7 +144,7 @@ class Purge extends Command
|
||||
$supplier->forceDelete();
|
||||
}
|
||||
|
||||
$users = User::whereNotNull('deleted_at')->withTrashed()->get();
|
||||
$users = User::whereNotNull('deleted_at')->where('show_in_list', '!=', '0')->withTrashed()->get();
|
||||
$this->info($users->count().' users purged.');
|
||||
$user_assoc = 0;
|
||||
foreach ($users as $user) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Models\License;
|
||||
use App\Models\Setting;
|
||||
@@ -8,129 +9,129 @@ use DB;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendExpirationAlerts extends Command {
|
||||
class SendExpirationAlerts extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'snipeit:expiring-alerts';
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'snipeit:expiring-alerts';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check for expiring warrantees and service agreements, and sends out an alert email.';
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check for expiring warrantees and service agreements, and sends out an alert email.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
|
||||
// Expiring Assets
|
||||
$expiring_assets = Asset::getExpiringWarrantee(Setting::getSettings()->alert_interval);
|
||||
$this->info(count($expiring_assets).' expiring assets');
|
||||
// Expiring Assets
|
||||
$expiring_assets = Asset::getExpiringWarrantee(Setting::getSettings()->alert_interval);
|
||||
$this->info(count($expiring_assets).' expiring assets');
|
||||
|
||||
$asset_data['count'] = count($expiring_assets);
|
||||
$asset_data['email_content'] ='';
|
||||
$now = date("Y-m-d");
|
||||
$asset_data['count'] = count($expiring_assets);
|
||||
$asset_data['email_content'] ='';
|
||||
$now = date("Y-m-d");
|
||||
|
||||
|
||||
foreach ($expiring_assets as $asset) {
|
||||
foreach ($expiring_assets as $asset) {
|
||||
|
||||
$expires = $asset->warrantee_expires();
|
||||
$difference = round(abs(strtotime($expires) - strtotime($now))/86400);
|
||||
$expires = $asset->warrantee_expires();
|
||||
$difference = round(abs(strtotime($expires) - strtotime($now))/86400);
|
||||
|
||||
if ($difference > 30) {
|
||||
$asset_data['email_content'] .= '<tr style="background-color: #fcffa3;">';
|
||||
} else {
|
||||
$asset_data['email_content'] .= '<tr style="background-color:#d9534f;">';
|
||||
}
|
||||
$asset_data['email_content'] .= '<td><a href="'.config('app.url').'/hardware/'.e($asset->id).'/view">';
|
||||
$asset_data['email_content'] .= $asset->showAssetName().'</a></td><td>'.e($asset->asset_tag).'</td>';
|
||||
$asset_data['email_content'] .= '<td>'.e($asset->warrantee_expires()).'</td>';
|
||||
$asset_data['email_content'] .= '<td>'.$difference.' days</td>';
|
||||
if ($difference > 30) {
|
||||
$asset_data['email_content'] .= '<tr style="background-color: #fcffa3;">';
|
||||
} else {
|
||||
$asset_data['email_content'] .= '<tr style="background-color:#d9534f;">';
|
||||
}
|
||||
$asset_data['email_content'] .= '<td><a href="'.config('app.url').'/hardware/'.e($asset->id).'/view">';
|
||||
$asset_data['email_content'] .= $asset->showAssetName().'</a></td><td>'.e($asset->asset_tag).'</td>';
|
||||
$asset_data['email_content'] .= '<td>'.e($asset->warrantee_expires()).'</td>';
|
||||
$asset_data['email_content'] .= '<td>'.$difference.' '.trans('mail.days').'</td>';
|
||||
$asset_data['email_content'] .= '<td>'.($asset->supplier ? e($asset->supplier->name) : '').'</td>';
|
||||
$asset_data['email_content'] .= '<td>'.($asset->assigneduser ? e($asset->assigneduser->fullName()) : '').'</td>';
|
||||
$asset_data['email_content'] .= '</tr>';
|
||||
}
|
||||
$asset_data['email_content'] .= '</tr>';
|
||||
}
|
||||
|
||||
// Expiring licenses
|
||||
$expiring_licenses = License::getExpiringLicenses(Setting::getSettings()->alert_interval);
|
||||
$this->info(count($expiring_licenses).' expiring licenses');
|
||||
// Expiring licenses
|
||||
$expiring_licenses = License::getExpiringLicenses(Setting::getSettings()->alert_interval);
|
||||
$this->info(count($expiring_licenses).' expiring licenses');
|
||||
|
||||
|
||||
$license_data['count'] = count($expiring_licenses);
|
||||
$license_data['email_content'] = '';
|
||||
$license_data['count'] = count($expiring_licenses);
|
||||
$license_data['email_content'] = '';
|
||||
|
||||
foreach ($expiring_licenses as $license) {
|
||||
$expires = $license->expiration_date;
|
||||
$difference = round(abs(strtotime($expires) - strtotime($now))/86400);
|
||||
foreach ($expiring_licenses as $license) {
|
||||
$expires = $license->expiration_date;
|
||||
$difference = round(abs(strtotime($expires) - strtotime($now))/86400);
|
||||
|
||||
if ($difference > 30) {
|
||||
$license_data['email_content'] .= '<tr style="background-color: #fcffa3;">';
|
||||
} else {
|
||||
$license_data['email_content'] .= '<tr style="background-color:#d9534f;">';
|
||||
}
|
||||
$license_data['email_content'] .= '<td><a href="'.config('app.url').'/admin/licenses/'.$license->id.'/view">';
|
||||
$license_data['email_content'] .= $license->name.'</a></td>';
|
||||
$license_data['email_content'] .= '<td>'.$license->expiration_date.'</td>';
|
||||
$license_data['email_content'] .= '<td>'.$difference.' days</td>';
|
||||
$license_data['email_content'] .= '</tr>';
|
||||
}
|
||||
if ($difference > 30) {
|
||||
$license_data['email_content'] .= '<tr style="background-color: #fcffa3;">';
|
||||
} else {
|
||||
$license_data['email_content'] .= '<tr style="background-color:#d9534f;">';
|
||||
}
|
||||
$license_data['email_content'] .= '<td><a href="'.config('app.url').'/admin/licenses/'.$license->id.'/view">';
|
||||
$license_data['email_content'] .= $license->name.'</a></td>';
|
||||
$license_data['email_content'] .= '<td>'.$license->expiration_date.'</td>';
|
||||
$license_data['email_content'] .= '<td>'.$difference.' days</td>';
|
||||
$license_data['email_content'] .= '</tr>';
|
||||
}
|
||||
|
||||
if ((Setting::getSettings()->alert_email!='') && (Setting::getSettings()->alerts_enabled==1)) {
|
||||
if ((Setting::getSettings()->alert_email!='') && (Setting::getSettings()->alerts_enabled==1)) {
|
||||
|
||||
|
||||
if (count($expiring_assets) > 0) {
|
||||
\Mail::send('emails.expiring-assets-report', $asset_data, function ($m) {
|
||||
$m->to(explode(',',Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
|
||||
$m->subject('Expiring Assets Report');
|
||||
});
|
||||
if (count($expiring_assets) > 0) {
|
||||
$this->info('Report sent to '.Setting::getSettings()->alert_email);
|
||||
\Mail::send('emails.expiring-assets-report', $asset_data, function ($m) {
|
||||
$m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.Expiring_Assets_Report'));
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (count($expiring_licenses) > 0) {
|
||||
\Mail::send('emails.expiring-licenses-report', $license_data, function ($m) {
|
||||
$m->to(explode(',',Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
|
||||
$m->subject('Expiring Licenses Report');
|
||||
});
|
||||
if (count($expiring_licenses) > 0) {
|
||||
$this->info('Report sent to '.Setting::getSettings()->alert_email);
|
||||
\Mail::send('emails.expiring-licenses-report', $license_data, function ($m) {
|
||||
$m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.Expiring_Licenses_Report'));
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
if (Setting::getSettings()->alert_email=='') {
|
||||
echo "Could not send email. No alert email configured in settings. \n";
|
||||
} elseif (Setting::getSettings()->alerts_enabled!=1) {
|
||||
echo "Alerts are disabled in the settings. No mail will be sent. \n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
if (Setting::getSettings()->alert_email=='') {
|
||||
echo "Could not send email. No alert email configured in settings. \n";
|
||||
} elseif (Setting::getSettings()->alerts_enabled!=1) {
|
||||
echo "Alerts are disabled in the settings. No mail will be sent. \n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,22 +48,22 @@ class SendInventoryAlerts extends Command
|
||||
$data['count'] = count($data['data']);
|
||||
|
||||
if (count($data['data']) > 0) {
|
||||
\Mail::send('emails.low-inventory', $data, function ($m) {
|
||||
$m->to(explode(',',Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
|
||||
$m->subject('Low Inventory Report');
|
||||
});
|
||||
\Mail::send('emails.low-inventory', $data, function ($m) {
|
||||
$m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.Low_Inventory_Report'));
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (Setting::getSettings()->alert_email=='') {
|
||||
echo "Could not send email. No alert email configured in settings. \n";
|
||||
} elseif (Setting::getSettings()->alerts_enabled!=1) {
|
||||
echo "Alerts are disabled in the settings. No mail will be sent. \n";
|
||||
}
|
||||
echo "Could not send email. No alert email configured in settings. \n";
|
||||
} elseif (Setting::getSettings()->alerts_enabled!=1) {
|
||||
echo "Alerts are disabled in the settings. No mail will be sent. \n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,44 +4,42 @@ namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SystemBackup extends Command {
|
||||
class SystemBackup extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'snipeit:backup';
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'snipeit:backup';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'This command creates a database dump and zips up all of the uploaded files in the upload directories.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
//
|
||||
$this->call('backup:run');
|
||||
|
||||
}
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'This command creates a database dump and zips up all of the uploaded files in the upload directories.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
//
|
||||
$this->call('backup:run');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class Versioning extends Command {
|
||||
class Versioning extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
@@ -41,18 +42,18 @@ class Versioning extends Command {
|
||||
{
|
||||
// Path to the file containing your version
|
||||
// This will be overwritten everything you commit a message
|
||||
$versionFile = app_path().'/config/version.php';
|
||||
$versionFile = 'config/version.php';
|
||||
|
||||
// The git's output
|
||||
// get the argument passed in the git command
|
||||
$hash_version = $this->argument('app_version');
|
||||
$hash_version = $this->argument('app_version');
|
||||
|
||||
// discard the commit hash
|
||||
$version = explode('-', $hash_version);
|
||||
$realVersion = $version[0] . '-' . $version[1];
|
||||
// discard the commit hash
|
||||
$version = explode('-', $hash_version);
|
||||
$realVersion = $version[0];
|
||||
|
||||
// save the version array to a variable
|
||||
$array = var_export(array('app_version' => $realVersion,'hash_version' => $hash_version), true);
|
||||
// save the version array to a variable
|
||||
$array = var_export(array('app_version' => $realVersion,'hash_version' => $hash_version), true);
|
||||
|
||||
|
||||
// Construct our file content
|
||||
|
||||
@@ -17,7 +17,6 @@ class Kernel extends ConsoleKernel
|
||||
Commands\CreateAdmin::class,
|
||||
Commands\SendExpirationAlerts::class,
|
||||
Commands\SendInventoryAlerts::class,
|
||||
Commands\AssetImportCommand::class,
|
||||
Commands\LicenseImportCommand::class,
|
||||
Commands\ObjectImportCommand::class,
|
||||
Commands\Versioning::class,
|
||||
|
||||
@@ -17,6 +17,8 @@ use App\Models\Component;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\Asset;
|
||||
use Crypt;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
@@ -26,19 +28,78 @@ use App\Models\Asset;
|
||||
class Helper
|
||||
{
|
||||
|
||||
// This doesn't do anything yet
|
||||
|
||||
public static function parseEscapedMarkedown($str) {
|
||||
$Parsedown = new \Parsedown();
|
||||
|
||||
if ($str) {
|
||||
return $Parsedown->text(e($str));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This doesn't do anything yet
|
||||
public static function parseEmailList($emails)
|
||||
{
|
||||
$emails_array = explode(',', $emails);
|
||||
return array_walk($emails_array, 'trim_value');
|
||||
}
|
||||
|
||||
// This doesn't do anything yet
|
||||
public static function formatCurrencyOutput($cost)
|
||||
{
|
||||
// The importer has formatted number strings since v3, so the value might be a string, or an integer.
|
||||
// If it's a number, format it as a string
|
||||
if (is_numeric($cost)) {
|
||||
return number_format($cost, 2, '.', '');
|
||||
}
|
||||
// It's already been parsed.
|
||||
return $cost;
|
||||
}
|
||||
|
||||
// This doesn't do anything yet
|
||||
public static function trim_value(&$value)
|
||||
{
|
||||
return trim($value);
|
||||
}
|
||||
|
||||
// Static colors for pie charts
|
||||
public static function chartColors()
|
||||
{
|
||||
$colors = [
|
||||
'#f56954',
|
||||
'#00a65a',
|
||||
'#f39c12',
|
||||
'#00c0ef',
|
||||
'#3c8dbc',
|
||||
'#d2d6de',
|
||||
'#3c8dbc',
|
||||
'#3c8dbc',
|
||||
'#3c8dbc',
|
||||
|
||||
];
|
||||
return $colors;
|
||||
}
|
||||
|
||||
// Static background (highlight) colors for pie charts
|
||||
// This is not currently used, but might be in the near future.
|
||||
public static function chartBackgroundColors()
|
||||
{
|
||||
$colors = [
|
||||
'#f56954',
|
||||
'#00a65a',
|
||||
'#f39c12',
|
||||
'#00c0ef',
|
||||
'#3c8dbc',
|
||||
'#d2d6de',
|
||||
'#3c8dbc',
|
||||
'#3c8dbc',
|
||||
'#3c8dbc',
|
||||
|
||||
];
|
||||
return $colors;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function ParseFloat($floatString)
|
||||
{
|
||||
@@ -63,48 +124,50 @@ class Helper
|
||||
public static function companyList()
|
||||
{
|
||||
$company_list = array('0' => trans('general.select_company')) + DB::table('companies')
|
||||
->orderBy('name', 'asc')
|
||||
->pluck('name', 'id');
|
||||
->orderBy('name', 'asc')
|
||||
->pluck('name', 'id');
|
||||
return $company_list;
|
||||
}
|
||||
|
||||
|
||||
public static function categoryList()
|
||||
public static function categoryList($category_type = null)
|
||||
{
|
||||
$category_list = array('' => '') + Category::orderBy('name', 'asc')
|
||||
->whereNull('deleted_at')
|
||||
->orderBy('name', 'asc')
|
||||
->pluck('name', 'id')->toArray();
|
||||
$categories = Category::orderBy('name', 'asc')
|
||||
->whereNull('deleted_at')
|
||||
->orderBy('name', 'asc');
|
||||
if(!empty($category_type))
|
||||
$categories = $categories->where('category_type', '=', $category_type);
|
||||
$category_list = array('' => trans('general.select_category')) + $categories->pluck('name', 'id')->toArray();
|
||||
return $category_list;
|
||||
}
|
||||
|
||||
public static function suppliersList()
|
||||
{
|
||||
$supplier_list = array('' => trans('general.select_supplier')) + Supplier::orderBy('name', 'asc')
|
||||
->orderBy('name', 'asc')
|
||||
->pluck('name', 'id')->toArray();
|
||||
->orderBy('name', 'asc')
|
||||
->pluck('name', 'id')->toArray();
|
||||
return $supplier_list;
|
||||
}
|
||||
|
||||
public static function statusLabelList()
|
||||
{
|
||||
$statuslabel_list = array('' => trans('general.select_statuslabel')) + Statuslabel::orderBy('name', 'asc')
|
||||
->pluck('name', 'id')->toArray();
|
||||
->pluck('name', 'id')->toArray();
|
||||
return $statuslabel_list;
|
||||
}
|
||||
|
||||
public static function locationsList()
|
||||
{
|
||||
$location_list = array('' => trans('general.select_location')) + Location::orderBy('name', 'asc')
|
||||
->pluck('name', 'id')->toArray();
|
||||
->pluck('name', 'id')->toArray();
|
||||
return $location_list;
|
||||
}
|
||||
|
||||
public static function manufacturerList()
|
||||
{
|
||||
$manufacturer_list = array('' => 'Select One') +
|
||||
Manufacturer::orderBy('name', 'asc')
|
||||
->pluck('name', 'id')->toArray();
|
||||
$manufacturer_list = array('' => trans('general.select_manufacturer')) +
|
||||
Manufacturer::orderBy('name', 'asc')
|
||||
->pluck('name', 'id')->toArray();
|
||||
return $manufacturer_list;
|
||||
}
|
||||
|
||||
@@ -116,47 +179,55 @@ class Helper
|
||||
|
||||
public static function managerList()
|
||||
{
|
||||
$manager_list = array('' => '') + User::select(DB::raw('concat(last_name,", ",first_name," (",username,")") as full_name, id'))
|
||||
->whereNull('deleted_at', 'and')
|
||||
->orderBy('last_name', 'asc')
|
||||
->orderBy('first_name', 'asc')
|
||||
->pluck('full_name', 'id')->toArray();
|
||||
$manager_list = array('' => trans('general.select_user')) +
|
||||
User::where('deleted_at', '=', null)
|
||||
->orderBy('last_name', 'asc')
|
||||
->orderBy('first_name', 'asc')->get()
|
||||
->lists('complete_name', 'id')->toArray();
|
||||
|
||||
return $manager_list;
|
||||
}
|
||||
|
||||
public static function depreciationList()
|
||||
{
|
||||
$depreciation_list = ['' => 'Do Not Depreciate'] + Depreciation::orderBy('name', 'asc')
|
||||
->pluck('name', 'id')->toArray();
|
||||
->pluck('name', 'id')->toArray();
|
||||
return $depreciation_list;
|
||||
}
|
||||
|
||||
public static function categoryTypeList()
|
||||
{
|
||||
$category_types = array('' => '','accessory' => 'Accessory', 'asset' => 'Asset', 'consumable' => 'Consumable','component' => 'Component');
|
||||
return $category_types;
|
||||
$category_types = array('' => '','accessory' => 'Accessory', 'asset' => 'Asset', 'consumable' => 'Consumable','component' => 'Component');
|
||||
return $category_types;
|
||||
}
|
||||
|
||||
public static function usersList()
|
||||
{
|
||||
$users_list = array('' => trans('general.select_user')) + DB::table('users')
|
||||
->select(DB::raw('concat(last_name,", ",first_name," (",username,")") as full_name, id'))
|
||||
->whereNull('deleted_at')
|
||||
->where('show_in_list','=',1)
|
||||
->orderBy('last_name', 'asc')
|
||||
->orderBy('first_name', 'asc')
|
||||
->pluck('full_name', 'id');
|
||||
$users_list = array( '' => trans('general.select_user')) +
|
||||
Company::scopeCompanyables(User::where('deleted_at', '=', null))
|
||||
->where('show_in_list','=',1)
|
||||
->orderBy('last_name', 'asc')
|
||||
->orderBy('first_name', 'asc')->get()
|
||||
->lists('complete_name', 'id')->toArray();
|
||||
|
||||
return $users_list;
|
||||
}
|
||||
|
||||
public static function assetsList()
|
||||
{
|
||||
$assets_list = array('' => trans('general.select_asset')) + Asset::orderBy('name', 'asc')
|
||||
->whereNull('deleted_at')
|
||||
->pluck('name', 'id')->toArray();
|
||||
->whereNull('deleted_at')
|
||||
->pluck('name', 'id')->toArray();
|
||||
return $assets_list;
|
||||
}
|
||||
|
||||
public static function detailedAssetList()
|
||||
{
|
||||
|
||||
$assets = array('' => trans('general.select_asset')) + Company::scopeCompanyables(Asset::all(), 'assets.company_id')->lists('detailed_name', 'id')->toArray();
|
||||
return $assets;
|
||||
}
|
||||
|
||||
|
||||
public static function customFieldsetList()
|
||||
{
|
||||
@@ -168,7 +239,7 @@ class Helper
|
||||
{
|
||||
$keys=array_keys(CustomField::$PredefinedFormats);
|
||||
$stuff=array_combine($keys, $keys);
|
||||
return $stuff+["" => "Custom Format..."];
|
||||
return $stuff+["" => trans('admin/custom_fields/general.custom_format')];
|
||||
}
|
||||
|
||||
public static function barcodeDimensions($barcode_type = 'QRCODE')
|
||||
@@ -197,10 +268,10 @@ class Helper
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
/**
|
||||
* This nasty little method gets the low inventory info for the
|
||||
* alert dropdown
|
||||
**/
|
||||
/**
|
||||
* This nasty little method gets the low inventory info for the
|
||||
* alert dropdown
|
||||
**/
|
||||
public static function checkLowInventory()
|
||||
{
|
||||
$consumables = Consumable::with('users')->whereNotNull('min_amt')->get();
|
||||
@@ -214,7 +285,12 @@ class Helper
|
||||
foreach ($consumables as $consumable) {
|
||||
$avail = $consumable->numRemaining();
|
||||
if ($avail < ($consumable->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
|
||||
$percent = number_format((($consumable->numRemaining() / $consumable->qty) * 100), 0);
|
||||
if ($consumable->total_qty > 0) {
|
||||
$percent = number_format((($consumable->numRemaining() / $consumable->total_qty) * 100), 0);
|
||||
} else {
|
||||
$percent = 100;
|
||||
}
|
||||
|
||||
$items_array[$all_count]['id'] = $consumable->id;
|
||||
$items_array[$all_count]['name'] = $consumable->name;
|
||||
$items_array[$all_count]['type'] = 'consumables';
|
||||
@@ -230,7 +306,13 @@ class Helper
|
||||
foreach ($accessories as $accessory) {
|
||||
$avail = $accessory->numRemaining();
|
||||
if ($avail < ($accessory->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
|
||||
$percent = number_format((($accessory->numRemaining() / $accessory->qty) * 100), 0);
|
||||
|
||||
if ($accessory->total_qty > 0) {
|
||||
$percent = number_format((($accessory->numRemaining() / $accessory->total_qty) * 100), 0);
|
||||
} else {
|
||||
$percent = 100;
|
||||
}
|
||||
|
||||
$items_array[$all_count]['id'] = $accessory->id;
|
||||
$items_array[$all_count]['name'] = $accessory->name;
|
||||
$items_array[$all_count]['type'] = 'accessories';
|
||||
@@ -245,7 +327,12 @@ class Helper
|
||||
foreach ($components as $component) {
|
||||
$avail = $component->numRemaining();
|
||||
if ($avail < ($component->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
|
||||
$percent = number_format((($component->numRemaining() / $component->total_qty) * 100), 0);
|
||||
if ($component->total_qty > 0) {
|
||||
$percent = number_format((($component->numRemaining() / $component->total_qty) * 100), 0);
|
||||
} else {
|
||||
$percent = 100;
|
||||
}
|
||||
|
||||
$items_array[$all_count]['id'] = $component->id;
|
||||
$items_array[$all_count]['name'] = $component->name;
|
||||
$items_array[$all_count]['type'] = 'components';
|
||||
@@ -280,25 +367,26 @@ class Helper
|
||||
}
|
||||
|
||||
/**
|
||||
* Walks through the permissions in the permissions config file and determines if
|
||||
* permissions are granted based on a $selected_arr array.
|
||||
*
|
||||
* The $permissions array is a multidimensional array broke down by section.
|
||||
* (Licenses, Assets, etc)
|
||||
*
|
||||
* The $selected_arr should be a flattened array that contains just the
|
||||
* corresponding permission name and a true or false boolean to determine
|
||||
* if that group/user has been granted that permission.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net]
|
||||
* @param array $permissions
|
||||
* @param array $selected_arr
|
||||
* @since [v1.0]
|
||||
* @return Array
|
||||
*/
|
||||
* Walks through the permissions in the permissions config file and determines if
|
||||
* permissions are granted based on a $selected_arr array.
|
||||
*
|
||||
* The $permissions array is a multidimensional array broke down by section.
|
||||
* (Licenses, Assets, etc)
|
||||
*
|
||||
* The $selected_arr should be a flattened array that contains just the
|
||||
* corresponding permission name and a true or false boolean to determine
|
||||
* if that group/user has been granted that permission.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net]
|
||||
* @param array $permissions
|
||||
* @param array $selected_arr
|
||||
* @since [v1.0]
|
||||
* @return Array
|
||||
*/
|
||||
public static function selectedPermissionsArray($permissions, $selected_arr = array())
|
||||
{
|
||||
|
||||
|
||||
$permissions_arr = array();
|
||||
|
||||
foreach ($permissions as $permission) {
|
||||
@@ -310,7 +398,7 @@ class Helper
|
||||
|
||||
if ($selected_arr) {
|
||||
if (array_key_exists($permission_name,$selected_arr)) {
|
||||
$permissions_arr[$permission_name] = ($selected_arr[$permission_name] == 1) ? '1': '0';
|
||||
$permissions_arr[$permission_name] = $selected_arr[$permission_name];
|
||||
} else {
|
||||
$permissions_arr[$permission_name] = '0';
|
||||
}
|
||||
@@ -324,8 +412,99 @@ class Helper
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $permissions_arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Introspects into the model validation to see if the field passed is required.
|
||||
* This is used by the blades to add a required class onto the HTML element.
|
||||
* This isn't critical, but is helpful to keep form fields in sync with the actual
|
||||
* model level validation.
|
||||
*
|
||||
* This does not currently handle form request validation requiredness :(
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @return boolean
|
||||
*/
|
||||
public static function checkIfRequired($class, $field) {
|
||||
$rules = $class::rules();
|
||||
foreach ($rules as $rule_name => $rule) {
|
||||
if ($rule_name == $field) {
|
||||
if (strpos($rule, 'required') === false) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check to see if the given key exists in the array, and trim excess white space before returning it
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @param $array array
|
||||
* @param $key string
|
||||
* @param $default string
|
||||
* @return string
|
||||
*/
|
||||
public static function array_smart_fetch(array $array, $key, $default = '')
|
||||
{
|
||||
array_change_key_case($array, CASE_LOWER);
|
||||
return array_key_exists(strtolower($key), array_change_key_case($array)) ? e(trim($array[ $key ])) : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the given key exists in the array, and trim excess white space before returning it
|
||||
*
|
||||
* @author A. Gianotto
|
||||
* @since 3.2
|
||||
* @param $array array
|
||||
* @return string
|
||||
*/
|
||||
public static function getLastDateFromHistoryArray(array $array)
|
||||
{
|
||||
foreach ($array as $key => $value) {
|
||||
// echo '<pre>';
|
||||
// echo 'last:'.$key;
|
||||
// print_r($array);
|
||||
// echo '</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function gracefulDecrypt(CustomField $field, $string) {
|
||||
|
||||
if ($field->isFieldDecryptable($string)) {
|
||||
|
||||
try {
|
||||
Crypt::decrypt($string);
|
||||
return Crypt::decrypt($string);
|
||||
|
||||
} catch (DecryptException $e) {
|
||||
return 'Error Decrypting: '.$e->getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
return $string;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function stripTagsFromJSON(Array $array) {
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
$clean_value = strip_tags($value);
|
||||
$clean_array[$key] = $clean_value;
|
||||
}
|
||||
return $clean_array;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ use Str;
|
||||
use View;
|
||||
use Auth;
|
||||
use Request;
|
||||
use Gate;
|
||||
|
||||
/** This controller handles all actions related to Accessories for
|
||||
* the Snipe-IT Asset Management application.
|
||||
@@ -52,14 +53,12 @@ class AccessoriesController extends Controller
|
||||
public function getCreate(Request $request)
|
||||
{
|
||||
// Show the page
|
||||
$category_list = array('' => '') + DB::table('categories')->where('category_type', '=', 'accessory')->whereNull('deleted_at')->orderBy('name', 'ASC')->lists('name', 'id');
|
||||
$company_list = Helper::companyList();
|
||||
$location_list = Helper::locationsList();
|
||||
return View::make('accessories/edit')
|
||||
->with('accessory', new Accessory)
|
||||
->with('category_list', $category_list)
|
||||
->with('company_list', $company_list)
|
||||
->with('location_list', $location_list);
|
||||
->with('category_list', Helper::categoryList('accessory'))
|
||||
->with('company_list', Helper::companyList())
|
||||
->with('location_list', Helper::locationsList())
|
||||
->with('manufacturer_list', Helper::manufacturerList());
|
||||
}
|
||||
|
||||
|
||||
@@ -76,12 +75,13 @@ class AccessoriesController extends Controller
|
||||
$accessory = new Accessory();
|
||||
|
||||
// Update the accessory data
|
||||
$accessory->name = e(Input::get('name'));
|
||||
$accessory->category_id = e(Input::get('category_id'));
|
||||
$accessory->location_id = e(Input::get('location_id'));
|
||||
$accessory->min_amt = e(Input::get('min_amt'));
|
||||
$accessory->name = e(Input::get('name'));
|
||||
$accessory->category_id = e(Input::get('category_id'));
|
||||
$accessory->location_id = e(Input::get('location_id'));
|
||||
$accessory->min_amt = e(Input::get('min_amt'));
|
||||
$accessory->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
|
||||
$accessory->order_number = e(Input::get('order_number'));
|
||||
$accessory->manufacturer_id = e(Input::get('manufacturer_id'));
|
||||
|
||||
if (e(Input::get('purchase_date')) == '') {
|
||||
$accessory->purchase_date = null;
|
||||
@@ -92,11 +92,11 @@ class AccessoriesController extends Controller
|
||||
if (e(Input::get('purchase_cost')) == '0.00') {
|
||||
$accessory->purchase_cost = null;
|
||||
} else {
|
||||
$accessory->purchase_cost = e(Input::get('purchase_cost'));
|
||||
$accessory->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')));
|
||||
}
|
||||
|
||||
$accessory->qty = e(Input::get('qty'));
|
||||
$accessory->user_id = Auth::user()->id;
|
||||
$accessory->qty = e(Input::get('qty'));
|
||||
$accessory->user_id = Auth::user()->id;
|
||||
|
||||
// Was the accessory created?
|
||||
if ($accessory->save()) {
|
||||
@@ -125,14 +125,11 @@ class AccessoriesController extends Controller
|
||||
return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
$category_list = array('' => '') + DB::table('categories')->where('category_type', '=', 'accessory')->whereNull('deleted_at')->orderBy('name', 'ASC')->lists('name', 'id');
|
||||
$company_list = Helper::companyList();
|
||||
$location_list = Helper::locationsList();
|
||||
|
||||
return View::make('accessories/edit', compact('accessory'))
|
||||
->with('category_list', $category_list)
|
||||
->with('company_list', $company_list)
|
||||
->with('location_list', $location_list);
|
||||
->with('category_list', Helper::categoryList('accessory'))
|
||||
->with('company_list', Helper::companyList())
|
||||
->with('location_list', Helper::locationsList())
|
||||
->with('manufacturer_list', Helper::manufacturerList());
|
||||
}
|
||||
|
||||
|
||||
@@ -145,9 +142,9 @@ class AccessoriesController extends Controller
|
||||
*/
|
||||
public function postEdit(Request $request, $accessoryId = null)
|
||||
{
|
||||
// Check if the blog post exists
|
||||
// Check if the accessory exists
|
||||
if (is_null($accessory = Accessory::find($accessoryId))) {
|
||||
// Redirect to the blogs management page
|
||||
// Redirect to the accessory index page
|
||||
return redirect()->to('admin/accessories')->with('error', trans('admin/accessories/message.does_not_exist'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($accessory)) {
|
||||
return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
|
||||
@@ -159,11 +156,12 @@ class AccessoriesController extends Controller
|
||||
if (e(Input::get('location_id')) == '') {
|
||||
$accessory->location_id = null;
|
||||
} else {
|
||||
$accessory->location_id = e(Input::get('location_id'));
|
||||
$accessory->location_id = e(Input::get('location_id'));
|
||||
}
|
||||
$accessory->min_amt = e(Input::get('min_amt'));
|
||||
$accessory->min_amt = e(Input::get('min_amt'));
|
||||
$accessory->category_id = e(Input::get('category_id'));
|
||||
$accessory->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
|
||||
$accessory->manufacturer_id = e(Input::get('manufacturer_id'));
|
||||
$accessory->order_number = e(Input::get('order_number'));
|
||||
|
||||
if (e(Input::get('purchase_date')) == '') {
|
||||
@@ -180,9 +178,9 @@ class AccessoriesController extends Controller
|
||||
|
||||
$accessory->qty = e(Input::get('qty'));
|
||||
|
||||
// Was the accessory created?
|
||||
// Was the accessory updated?
|
||||
if ($accessory->save()) {
|
||||
// Redirect to the new accessory page
|
||||
// Redirect to the updated accessory page
|
||||
return redirect()->to("admin/accessories")->with('success', trans('admin/accessories/message.update.success'));
|
||||
}
|
||||
|
||||
@@ -311,16 +309,11 @@ class AccessoriesController extends Controller
|
||||
'user_id' => Auth::user()->id,
|
||||
'assigned_to' => e(Input::get('assigned_to'))));
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->accessory_id = $accessory->id;
|
||||
$logaction->checkedout_to = $accessory->assigned_to;
|
||||
$logaction->asset_type = 'accessory';
|
||||
$logaction->location_id = $user->location_id;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = e(Input::get('note'));
|
||||
$logaction = $accessory->logCheckout(e(Input::get('note')));
|
||||
|
||||
|
||||
|
||||
$admin_user = Auth::user();
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
if ($settings->slack_endpoint) {
|
||||
@@ -340,11 +333,11 @@ class AccessoriesController extends Controller
|
||||
'fields' => [
|
||||
[
|
||||
'title' => 'Checked Out:',
|
||||
'value' => strtoupper($logaction->asset_type).' <'.config('app.url').'/admin/accessories/'.$accessory->id.'/view'.'|'.$accessory->name.'> checked out to <'.config('app.url').'/admin/users/'.$user->id.'/view|'.$user->fullName().'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.'
|
||||
'value' => 'Accessory <'.config('app.url').'/admin/accessories/'.$accessory->id.'/view'.'|'.$accessory->name.'> checked out to <'.config('app.url').'/admin/users/'.$user->id.'/view|'.$user->fullName().'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
'value' => e($logaction->note)
|
||||
'value' => e(Input::get('note'))
|
||||
],
|
||||
]
|
||||
])->send('Accessory Checked Out');
|
||||
@@ -355,9 +348,6 @@ class AccessoriesController extends Controller
|
||||
}
|
||||
|
||||
|
||||
|
||||
$log = $logaction->logaction('checkout');
|
||||
|
||||
$accessory_user = DB::table('accessories_users')->where('assigned_to', '=', $accessory->assigned_to)->where('accessory_id', '=', $accessory->id)->first();
|
||||
|
||||
$data['log_id'] = $logaction->id;
|
||||
@@ -375,7 +365,8 @@ class AccessoriesController extends Controller
|
||||
|
||||
Mail::send('emails.accept-accessory', $data, function ($m) use ($user) {
|
||||
$m->to($user->email, $user->first_name . ' ' . $user->last_name);
|
||||
$m->subject('Confirm accessory delivery');
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.Confirm_accessory_delivery'));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -435,8 +426,7 @@ class AccessoriesController extends Controller
|
||||
return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->checkedout_to = e($accessory_user->assigned_to);
|
||||
$logaction = $accessory->logCheckin(e(Input::get('note')));
|
||||
$return_to = e($accessory_user->assigned_to);
|
||||
$admin_user = Auth::user();
|
||||
|
||||
@@ -444,12 +434,6 @@ class AccessoriesController extends Controller
|
||||
// Was the accessory updated?
|
||||
if (DB::table('accessories_users')->where('id', '=', $accessory_user->id)->delete()) {
|
||||
|
||||
$logaction->accessory_id = e($accessory->id);
|
||||
$logaction->location_id = null;
|
||||
$logaction->asset_type = 'accessory';
|
||||
$logaction->user_id = e($admin_user->id);
|
||||
$logaction->note = e(Input::get('note'));
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
if ($settings->slack_endpoint) {
|
||||
@@ -469,7 +453,7 @@ class AccessoriesController extends Controller
|
||||
'fields' => [
|
||||
[
|
||||
'title' => 'Checked In:',
|
||||
'value' => strtoupper($logaction->asset_type).' <'.config('app.url').'/admin/accessories/'.e($accessory->id).'/view'.'|'.e($accessory->name).'> checked in by <'.config('app.url').'/admin/users/'.e($admin_user->id).'/view'.'|'.e($admin_user->fullName()).'>.'
|
||||
'value' => class_basename(strtoupper($logaction->item_type)).' <'.config('app.url').'/admin/accessories/'.e($accessory->id).'/view'.'|'.e($accessory->name).'> checked in by <'.config('app.url').'/admin/users/'.e($admin_user->id).'/view'.'|'.e($admin_user->fullName()).'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
@@ -485,9 +469,6 @@ class AccessoriesController extends Controller
|
||||
|
||||
}
|
||||
|
||||
|
||||
$log = $logaction->logaction('checkin from');
|
||||
|
||||
if (!is_null($accessory_user->assigned_to)) {
|
||||
$user = User::find($accessory_user->assigned_to);
|
||||
}
|
||||
@@ -503,7 +484,8 @@ class AccessoriesController extends Controller
|
||||
|
||||
Mail::send('emails.checkin-asset', $data, function ($m) use ($user) {
|
||||
$m->to($user->email, $user->first_name . ' ' . $user->last_name);
|
||||
$m->subject('Confirm Accessory Checkin');
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.Confirm_Accessory_Checkin'));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -547,7 +529,7 @@ class AccessoriesController extends Controller
|
||||
**/
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
$accessories = Accessory::select('accessories.*')->with('category', 'company')
|
||||
$accessories = Company::scopeCompanyables(Accessory::select('accessories.*')->with('category', 'company'))
|
||||
->whereNull('accessories.deleted_at');
|
||||
|
||||
if (Input::has('search')) {
|
||||
@@ -589,7 +571,21 @@ class AccessoriesController extends Controller
|
||||
$rows = array();
|
||||
|
||||
foreach ($accessories as $accessory) {
|
||||
$actions = '<nobr><a href="'.route('checkout/accessory', $accessory->id).'" style="margin-right:5px;" class="btn btn-info btn-sm" '.(($accessory->numRemaining() > 0 ) ? '' : ' disabled').'>'.trans('general.checkout').'</a><a href="'.route('update/accessory', $accessory->id).'" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a><a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/accessory', $accessory->id).'" data-content="'.trans('admin/accessories/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($accessory->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></nobr>';
|
||||
|
||||
$actions = '<nobr>';
|
||||
if (Gate::allows('accessories.checkout')) {
|
||||
$actions .= '<a href="' . route('checkout/accessory',
|
||||
$accessory->id) . '" style="margin-right:5px;" class="btn btn-info btn-sm" ' . (($accessory->numRemaining() > 0) ? '' : ' disabled') . '>' . trans('general.checkout') . '</a>';
|
||||
}
|
||||
if (Gate::allows('accessories.edit')) {
|
||||
$actions .= '<a href="' . route('update/accessory',
|
||||
$accessory->id) . '" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a>';
|
||||
}
|
||||
if (Gate::allows('accessories.delete')) {
|
||||
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/accessory',
|
||||
$accessory->id) . '" data-content="' . trans('admin/accessories/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($accessory->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
|
||||
}
|
||||
$actions .= '</nobr>';
|
||||
$company = $accessory->company;
|
||||
|
||||
$rows[] = array(
|
||||
@@ -600,10 +596,12 @@ class AccessoriesController extends Controller
|
||||
'min_amt' => e($accessory->min_amt),
|
||||
'location' => ($accessory->location) ? e($accessory->location->name): '',
|
||||
'purchase_date' => e($accessory->purchase_date),
|
||||
'purchase_cost' => number_format($accessory->purchase_cost, 2),
|
||||
'purchase_cost' => Helper::formatCurrencyOutput($accessory->purchase_cost),
|
||||
'numRemaining' => $accessory->numRemaining(),
|
||||
'actions' => $actions,
|
||||
'companyName' => is_null($company) ? '' : e($company->name)
|
||||
'companyName' => is_null($company) ? '' : e($company->name),
|
||||
'manufacturer' => $accessory->manufacturer ? (string) link_to('/admin/settings/manufacturers/'.$accessory->manufacturer_id.'/view', $accessory->manufacturer->name) : ''
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
@@ -652,10 +650,20 @@ class AccessoriesController extends Controller
|
||||
$rows = array();
|
||||
|
||||
foreach ($accessory_users as $user) {
|
||||
$actions = '<a href="'.route('checkin/accessory', $user->pivot->id).'" class="btn btn-info btn-sm">Checkin</a>';
|
||||
$actions = '';
|
||||
if (Gate::allows('accessories.checkin')) {
|
||||
$actions .= '<a href="' . route('checkin/accessory',
|
||||
$user->pivot->id) . '" class="btn btn-info btn-sm">Checkin</a>';
|
||||
}
|
||||
|
||||
if (Gate::allows('users.view')) {
|
||||
$name = (string) link_to('/admin/users/'.$user->id.'/view', e($user->fullName()));
|
||||
} else {
|
||||
$name = e($user->fullName());
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
'name' =>(string) link_to('/admin/users/'.$user->id.'/view', e($user->fullName())),
|
||||
'name' => $name,
|
||||
'actions' => $actions
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ use View;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Asset;
|
||||
use App\Helpers\Helper;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Asset Maintenance for
|
||||
@@ -74,13 +75,16 @@ class AssetMaintenancesController extends Controller
|
||||
*/
|
||||
public function getDatatable()
|
||||
{
|
||||
$maintenances = AssetMaintenance::with('asset', 'supplier', 'asset.company')
|
||||
->whereNull('deleted_at');
|
||||
$maintenances = AssetMaintenance::with('asset', 'supplier', 'asset.company','admin')
|
||||
->withTrashed();
|
||||
|
||||
if (Input::has('search')) {
|
||||
$maintenances = $maintenances->TextSearch(e(Input::get('search')));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (Input::has('offset')) {
|
||||
$offset = e(Input::get('offset'));
|
||||
} else {
|
||||
@@ -93,11 +97,20 @@ class AssetMaintenancesController extends Controller
|
||||
$limit = 50;
|
||||
}
|
||||
|
||||
$allowed_columns = ['id','title','asset_maintenance_time','asset_maintenance_type','cost','start_date','completion_date','notes'];
|
||||
|
||||
|
||||
$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(Input::get('sort')) : 'created_at';
|
||||
|
||||
$maintenances->orderBy($sort, $order);
|
||||
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();
|
||||
@@ -109,27 +122,26 @@ class AssetMaintenancesController extends Controller
|
||||
|
||||
$actions = '<nobr><a href="'.route('update/asset_maintenance', $maintenance->id).'" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a><a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/asset_maintenance', $maintenance->id).'" data-content="'.trans('admin/asset_maintenances/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($maintenance->title).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></nobr>';
|
||||
|
||||
if (($maintenance->cost) && ($maintenance->asset->assetloc) && ($maintenance->asset->assetloc->currency!='')) {
|
||||
if (($maintenance->cost) && (isset($maintenance->asset)) && ($maintenance->asset->assetloc) && ($maintenance->asset->assetloc->currency!='')) {
|
||||
$maintenance_cost = $maintenance->asset->assetloc->currency.$maintenance->cost;
|
||||
} else {
|
||||
$maintenance_cost = $settings->default_currency.$maintenance->cost;
|
||||
}
|
||||
|
||||
$company = $maintenance->asset->company;
|
||||
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $maintenance->id,
|
||||
'asset_name' => (string)link_to('/hardware/'.$maintenance->asset->id.'/view', $maintenance->asset->showAssetName()) ,
|
||||
'asset_name' => ($maintenance->asset) ? (string)link_to('/hardware/'.$maintenance->asset->id.'/view', $maintenance->asset->showAssetName()) : 'Deleted Asset' ,
|
||||
'title' => $maintenance->title,
|
||||
'notes' => $maintenance->notes,
|
||||
'supplier' => $maintenance->supplier->name,
|
||||
'supplier' => ($maintenance->supplier) ? (string)link_to('/admin/settings/suppliers/'.$maintenance->supplier->id.'/view', $maintenance->supplier->name) : '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('/admin/users/'.$maintenance->admin->id.'/view', $maintenance->admin->fullName()) : '',
|
||||
'actions' => $actions,
|
||||
'companyName' => is_null($company) ? '' : $company->name
|
||||
'companyName' => ($maintenance->asset->company) ? $maintenance->asset->company->name : ''
|
||||
);
|
||||
}
|
||||
|
||||
@@ -155,41 +167,14 @@ class AssetMaintenancesController extends Controller
|
||||
] + AssetMaintenance::getImprovementOptions();
|
||||
// Mark the selected asset, if it came in
|
||||
$selectedAsset = $assetId;
|
||||
// Get the possible assets using a left join to get a list of assets and some other helpful info
|
||||
$asset = Company::scopeCompanyables(DB::table('assets'), 'assets.company_id')
|
||||
->leftJoin('users', 'users.id', '=', 'assets.assigned_to')
|
||||
->leftJoin('models', 'assets.model_id', '=', 'models.id')
|
||||
->select(
|
||||
'assets.id',
|
||||
'assets.name',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'asset_tag',
|
||||
DB::raw('concat(first_name," ",last_name) as full_name, assets.id as id, models.name as modelname')
|
||||
)
|
||||
->whereNull('assets.deleted_at')
|
||||
->get();
|
||||
$asset_array = json_decode(json_encode($asset), true);
|
||||
$asset_element[ '' ] = 'Please select an asset';
|
||||
|
||||
// Build a list out of the data results
|
||||
for ($x = 0; $x < count($asset_array); $x++) {
|
||||
$assets = Helper::detailedAssetList();
|
||||
|
||||
if ($asset_array[ $x ][ 'full_name' ] != '') {
|
||||
$full_name = ' (' . $asset_array[ $x ][ 'full_name' ] . ') ' . $asset_array[ $x ][ 'modelname' ];
|
||||
} else {
|
||||
$full_name = ' (Unassigned) ' . $asset_array[ $x ][ 'modelname' ];
|
||||
}
|
||||
$asset_element[ $asset_array[ $x ][ 'id' ] ] =
|
||||
$asset_array[ $x ][ 'asset_tag' ] . ' - ' . $asset_array[ $x ][ 'name' ] . $full_name;
|
||||
}
|
||||
|
||||
// Get Supplier List
|
||||
$supplier_list = Helper::suppliersList();
|
||||
|
||||
// Render the view
|
||||
return View::make('asset_maintenances/edit')
|
||||
->with('asset_list', $asset_element)
|
||||
->with('asset_list', $assets)
|
||||
->with('selectedAsset', $selectedAsset)
|
||||
->with('supplier_list', $supplier_list)
|
||||
->with('assetMaintenanceType', $assetMaintenanceType)
|
||||
@@ -230,7 +215,7 @@ class AssetMaintenancesController extends Controller
|
||||
if (e(Input::get('cost')) == '') {
|
||||
$assetMaintenance->cost = '';
|
||||
} else {
|
||||
$assetMaintenance->cost = e(Input::get('cost'));
|
||||
$assetMaintenance->cost = Helper::ParseFloat(e(Input::get('cost')));
|
||||
}
|
||||
|
||||
if (e(Input::get('notes')) == '') {
|
||||
@@ -251,6 +236,7 @@ class AssetMaintenancesController extends Controller
|
||||
$assetMaintenance->title = e(Input::get('title'));
|
||||
$assetMaintenance->start_date = e(Input::get('start_date'));
|
||||
$assetMaintenance->completion_date = e(Input::get('completion_date'));
|
||||
$assetMaintenance->user_id = Auth::user()->id;
|
||||
|
||||
if (( $assetMaintenance->completion_date == "" )
|
||||
|| ( $assetMaintenance->completion_date == "0000-00-00" )
|
||||
@@ -321,40 +307,13 @@ class AssetMaintenancesController extends Controller
|
||||
'' => 'Select an improvement type',
|
||||
] + AssetMaintenance::getImprovementOptions();
|
||||
|
||||
// Get the possible assets using a left join to get a list of assets and some other helpful info
|
||||
$asset = Company::scopeCompanyables(DB::table('assets'), 'assets.company_id')
|
||||
->leftJoin('users', 'users.id', '=', 'assets.assigned_to')
|
||||
->leftJoin('models', 'assets.model_id', '=', 'models.id')
|
||||
->select(
|
||||
'assets.id',
|
||||
'assets.name',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'asset_tag',
|
||||
DB::raw('concat(first_name," ",last_name) as full_name, assets.id as id, models.name as modelname')
|
||||
)
|
||||
->whereNull('assets.deleted_at')
|
||||
->get();
|
||||
$asset_array = json_decode(json_encode($asset), true);
|
||||
$asset_element[ '' ] = 'Please select an asset';
|
||||
|
||||
// Build a list out of the data results
|
||||
for ($x = 0; $x < count($asset_array); $x++) {
|
||||
|
||||
if ($asset_array[ $x ][ 'full_name' ] != '') {
|
||||
$full_name = ' (' . $asset_array[ $x ][ 'full_name' ] . ') ' . $asset_array[ $x ][ 'modelname' ];
|
||||
} else {
|
||||
$full_name = ' (Unassigned) ' . $asset_array[ $x ][ 'modelname' ];
|
||||
}
|
||||
$asset_element[ $asset_array[ $x ][ 'id' ] ] =
|
||||
$asset_array[ $x ][ 'asset_tag' ] . ' - ' . $asset_array[ $x ][ 'name' ] . $full_name;
|
||||
}
|
||||
$assets = Company::scopeCompanyables(Asset::with('model','assignedUser')->get(), 'assets.company_id')->lists('detailed_name', 'id');
|
||||
// Get Supplier List
|
||||
$supplier_list = Helper::suppliersList();
|
||||
|
||||
// Render the view
|
||||
return View::make('asset_maintenances/edit')
|
||||
->with('asset_list', $asset_element)
|
||||
->with('asset_list', $assets)
|
||||
->with('selectedAsset', null)
|
||||
->with('supplier_list', $supplier_list)
|
||||
->with('assetMaintenanceType', $assetMaintenanceType)
|
||||
@@ -404,7 +363,7 @@ class AssetMaintenancesController extends Controller
|
||||
if (e(Input::get('cost')) == '') {
|
||||
$assetMaintenance->cost = '';
|
||||
} else {
|
||||
$assetMaintenance->cost = e(Input::get('cost'));
|
||||
$assetMaintenance->cost = Helper::ParseFloat(e(Input::get('cost')));
|
||||
}
|
||||
|
||||
if (e(Input::get('notes')) == '') {
|
||||
|
||||
@@ -55,9 +55,9 @@ class AssetModelsController extends Controller
|
||||
public function getCreate()
|
||||
{
|
||||
// Show the page
|
||||
$depreciation_list = \App\Helpers\Helper::depreciationList();
|
||||
$manufacturer_list = \App\Helpers\Helper::manufacturerList();
|
||||
$category_list = \App\Helpers\Helper::categoryList();
|
||||
$depreciation_list = Helper::depreciationList();
|
||||
$manufacturer_list = Helper::manufacturerList();
|
||||
$category_list = Helper::categoryList('asset');
|
||||
return View::make('models/edit')
|
||||
->with('category_list', $category_list)
|
||||
->with('depreciation_list', $depreciation_list)
|
||||
@@ -92,28 +92,28 @@ class AssetModelsController extends Controller
|
||||
$model->eol = e(Input::get('eol'));
|
||||
}
|
||||
|
||||
// Save the model data
|
||||
$model->name = e(Input::get('name'));
|
||||
$model->modelno = e(Input::get('modelno'));
|
||||
$model->manufacturer_id = e(Input::get('manufacturer_id'));
|
||||
$model->category_id = e(Input::get('category_id'));
|
||||
$model->note = e(Input::get('note'));
|
||||
$model->user_id = Auth::user()->id;
|
||||
// Save the model data
|
||||
$model->name = e(Input::get('name'));
|
||||
$model->modelno = e(Input::get('modelno'));
|
||||
$model->manufacturer_id = e(Input::get('manufacturer_id'));
|
||||
$model->category_id = e(Input::get('category_id'));
|
||||
$model->note = e(Input::get('note'));
|
||||
$model->user_id = Auth::user()->id;
|
||||
$model->requestable = Input::has('requestable');
|
||||
|
||||
if (Input::get('custom_fieldset')!='') {
|
||||
$model->fieldset_id = e(Input::get('custom_fieldset'));
|
||||
}
|
||||
|
||||
//$model->show_mac_address = e(Input::get('show_mac_address', '0'));
|
||||
|
||||
|
||||
if (Input::file('image')) {
|
||||
$image = Input::file('image');
|
||||
$file_name = str_random(25).".".$image->getClientOriginalExtension();
|
||||
$path = public_path('uploads/models/'.$file_name);
|
||||
// Image::make($image->getRealPath())->resize(300, null, function ($constraint) {
|
||||
// $constraint->aspectRatio();
|
||||
// $constraint->upsize();
|
||||
// })->save($path);
|
||||
Image::make($image->getRealPath())->resize(500, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save($path);
|
||||
$model->image = $file_name;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ class AssetModelsController extends Controller
|
||||
$model = new AssetModel;
|
||||
|
||||
$settings=Input::all();
|
||||
$settings['eol']=0;
|
||||
$settings['eol']= null;
|
||||
|
||||
$model->name=e(Input::get('name'));
|
||||
$model->manufacturer_id = e(Input::get('manufacturer_id'));
|
||||
@@ -149,7 +149,7 @@ class AssetModelsController extends Controller
|
||||
$model->modelno = e(Input::get('modelno'));
|
||||
$model->user_id = Auth::user()->id;
|
||||
$model->note = e(Input::get('note'));
|
||||
$model->eol=0;
|
||||
$model->eol= null;
|
||||
|
||||
if (Input::get('fieldset_id')=='') {
|
||||
$model->fieldset_id = null;
|
||||
@@ -181,9 +181,9 @@ class AssetModelsController extends Controller
|
||||
return redirect()->to('assets/models')->with('error', trans('admin/models/message.does_not_exist'));
|
||||
}
|
||||
|
||||
$depreciation_list = \App\Helpers\Helper::depreciationList();
|
||||
$manufacturer_list = \App\Helpers\Helper::manufacturerList();
|
||||
$category_list = \App\Helpers\Helper::categoryList();
|
||||
$depreciation_list = Helper::depreciationList();
|
||||
$manufacturer_list = Helper::manufacturerList();
|
||||
$category_list = Helper::categoryList('asset');
|
||||
$view = View::make('models/edit', compact('model'));
|
||||
$view->with('category_list', $category_list);
|
||||
$view->with('depreciation_list', $depreciation_list);
|
||||
@@ -217,7 +217,7 @@ class AssetModelsController extends Controller
|
||||
}
|
||||
|
||||
if (e(Input::get('eol')) == '') {
|
||||
$model->eol = 0;
|
||||
$model->eol = null;
|
||||
} else {
|
||||
$model->eol = e(Input::get('eol'));
|
||||
}
|
||||
@@ -227,7 +227,10 @@ class AssetModelsController extends Controller
|
||||
$model->modelno = e(Input::get('modelno'));
|
||||
$model->manufacturer_id = e(Input::get('manufacturer_id'));
|
||||
$model->category_id = e(Input::get('category_id'));
|
||||
$model->note = e(Input::get('note'));
|
||||
$model->note = e(Input::get('note'));
|
||||
|
||||
$model->requestable = Input::has('requestable');
|
||||
|
||||
if (Input::get('custom_fieldset')=='') {
|
||||
$model->fieldset_id = null;
|
||||
} else {
|
||||
@@ -371,9 +374,9 @@ class AssetModelsController extends Controller
|
||||
$model->id = null;
|
||||
|
||||
// Show the page
|
||||
$depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id');
|
||||
$manufacturer_list = array('' => 'Select One') + Manufacturer::lists('name', 'id');
|
||||
$category_list = array('' => '') + DB::table('categories')->whereNull('deleted_at')->lists('name', 'id');
|
||||
$depreciation_list = Helper::depreciationList();
|
||||
$manufacturer_list = Helper::manufacturerList();
|
||||
$category_list = Helper::categoryList('asset');
|
||||
$view = View::make('models/edit');
|
||||
$view->with('category_list', $category_list);
|
||||
$view->with('depreciation_list', $depreciation_list);
|
||||
@@ -452,7 +455,7 @@ class AssetModelsController extends Controller
|
||||
|
||||
foreach ($models as $model) {
|
||||
if ($model->deleted_at == '') {
|
||||
$actions = '<div style=" white-space: nowrap;"><a href="'.route('update/model', $model->id).'" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a><a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/model', $model->id).'" data-content="'.trans('admin/models/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($model->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>';
|
||||
$actions = '<div style=" white-space: nowrap;"><a href="'.route('clone/model', $model->id).'" class="btn btn-info btn-sm" title="Clone Model" data-toggle="tooltip"><i class="fa fa-clone"></i></a> <a href="'.route('update/model', $model->id).'" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a><a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/model', $model->id).'" data-content="'.trans('admin/models/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($model->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>';
|
||||
} else {
|
||||
$actions = '<a href="'.route('restore/model', $model->id).'" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a>';
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@ use Validator;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ThrottlesLogins;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Ldap;
|
||||
use App\Models\User;
|
||||
use Auth;
|
||||
use Config;
|
||||
@@ -15,6 +16,8 @@ use Redirect;
|
||||
use Log;
|
||||
use View;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This controller handles authentication for the user, including local
|
||||
* database users and LDAP users.
|
||||
@@ -61,120 +64,13 @@ class AuthController extends Controller
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Authenticates a user to LDAP
|
||||
*
|
||||
* @param $username
|
||||
* @param $password
|
||||
* @param bool|false $returnUser
|
||||
* @return bool true if the username and/or password provided are valid
|
||||
* false if the username and/or password provided are invalid
|
||||
* array of ldap_attributes if $returnUser is true
|
||||
*/
|
||||
function ldap($username, $password, $returnUser = false)
|
||||
{
|
||||
|
||||
$ldaphost = Setting::getSettings()->ldap_server;
|
||||
$ldaprdn = Setting::getSettings()->ldap_uname;
|
||||
$ldappass = \Crypt::decrypt(Setting::getSettings()->ldap_pword);
|
||||
$baseDn = Setting::getSettings()->ldap_basedn;
|
||||
$filterQuery = Setting::getSettings()->ldap_auth_filter_query . $username;
|
||||
$ldapversion = Setting::getSettings()->ldap_version;
|
||||
$ldap_server_cert_ignore = Setting::getSettings()->ldap_server_cert_ignore;
|
||||
|
||||
// If we are ignoring the SSL cert we need to setup the environment variable
|
||||
// before we create the connection
|
||||
if ($ldap_server_cert_ignore) {
|
||||
putenv('LDAPTLS_REQCERT=never');
|
||||
}
|
||||
|
||||
// Connecting to LDAP
|
||||
$connection = ldap_connect($ldaphost) or die("Could not connect to {$ldaphost}");
|
||||
// Needed for AD
|
||||
ldap_set_option($connection, LDAP_OPT_REFERRALS, 0);
|
||||
ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, $ldapversion);
|
||||
|
||||
try {
|
||||
if ($connection) {
|
||||
// binding to ldap server
|
||||
$ldapbind = ldap_bind($connection, $ldaprdn, $ldappass);
|
||||
if (($results = @ldap_search($connection, $baseDn, $filterQuery)) != false) {
|
||||
$entry = ldap_first_entry($connection, $results);
|
||||
if (($userDn = @ldap_get_dn($connection, $entry)) != false) {
|
||||
if (($isBound = ldap_bind($connection, $userDn, $password)) == "true") {
|
||||
return $returnUser ?
|
||||
array_change_key_case(ldap_get_attributes($connection, $entry), CASE_LOWER)
|
||||
: true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
LOG::error($e->getMessage());
|
||||
}
|
||||
ldap_close($connection);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user from LDAP attributes
|
||||
*
|
||||
* @param $ldapatttibutes
|
||||
* @return array|bool
|
||||
*/
|
||||
function createUserFromLdap($ldapatttibutes)
|
||||
{
|
||||
//Get LDAP attribute config
|
||||
$ldap_result_username = Setting::getSettings()->ldap_username_field;
|
||||
$ldap_result_emp_num = Setting::getSettings()->ldap_emp_num;
|
||||
$ldap_result_last_name = Setting::getSettings()->ldap_lname_field;
|
||||
$ldap_result_first_name = Setting::getSettings()->ldap_fname_field;
|
||||
$ldap_result_email = Setting::getSettings()->ldap_email;
|
||||
|
||||
//Get LDAP user data
|
||||
$item = array();
|
||||
$item["username"] = isset($ldapatttibutes[$ldap_result_username][0]) ? $ldapatttibutes[$ldap_result_username][0] : "";
|
||||
$item["employee_number"] = isset($ldapatttibutes[$ldap_result_emp_num][0]) ? $ldapatttibutes[$ldap_result_emp_num][0] : "";
|
||||
$item["lastname"] = isset($ldapatttibutes[$ldap_result_last_name][0]) ? $ldapatttibutes[$ldap_result_last_name][0] : "";
|
||||
$item["firstname"] = isset($ldapatttibutes[$ldap_result_first_name][0]) ? $ldapatttibutes[$ldap_result_first_name][0] : "";
|
||||
$item["email"] = isset($ldapatttibutes[$ldap_result_email][0]) ? $ldapatttibutes[$ldap_result_email][0] : "" ;
|
||||
|
||||
//create user
|
||||
if (!empty($item["username"])) {
|
||||
//$pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10);
|
||||
|
||||
$newuser = array(
|
||||
'first_name' => $item["firstname"],
|
||||
'last_name' => $item["lastname"],
|
||||
'username' => $item["username"],
|
||||
'email' => $item["email"],
|
||||
'employee_num' => $item["employee_number"],
|
||||
'password' => bcrypt(Input::get("password")), //$pass,
|
||||
'activated' => 1,
|
||||
'permissions' => ["user" => 1], //'{"user":1}',
|
||||
'notes' => 'Imported from LDAP'
|
||||
);
|
||||
User::save($newuser);
|
||||
|
||||
} else {
|
||||
throw new Cartalyst\Sentry\Users\UserNotFoundException();
|
||||
}
|
||||
|
||||
//$item["note"] = "<strong>created</strong>";
|
||||
$credentials = array(
|
||||
'username' => $item["username"],
|
||||
'password' => Input::get("password")//$pass,
|
||||
);
|
||||
return $credentials;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Account sign in form processing.
|
||||
*
|
||||
* @return Redirect
|
||||
*/
|
||||
public function login()
|
||||
public function login(Request $request)
|
||||
{
|
||||
$validator = $this->validator(Input::all());
|
||||
|
||||
@@ -186,21 +82,43 @@ class AuthController extends Controller
|
||||
if (Setting::getSettings()->ldap_enabled=='1') {
|
||||
|
||||
LOG::debug("LDAP is enabled.");
|
||||
// Check if the user exists in the database
|
||||
// Check if the user exists in the database
|
||||
$user = User::where('username', '=', Input::get('username'))->whereNull('deleted_at')->first();
|
||||
LOG::debug("Auth lookup complete");
|
||||
LOG::debug("Local auth lookup complete");
|
||||
|
||||
try {
|
||||
Ldap::findAndBindUserLdap($request->input('username'), $request->input('password'));
|
||||
LOG::debug("Binding user to LDAP.");
|
||||
} catch (\Exception $e) {
|
||||
LOG::debug("User ".Input::get('username').' did not authenticate successfully against LDAP.');
|
||||
//$ldap_error = $e->getMessage();
|
||||
// return redirect()->back()->withInput()->with('error',$e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
// The user does not exist in the database. Try to get them from LDAP.
|
||||
// If user does not exist and authenticates sucessfully with LDAP we
|
||||
// will create it on the fly and sign in with default permissions
|
||||
// The user does not exist in the database. Try to get them from LDAP.
|
||||
// If user does not exist and authenticates sucessfully with LDAP we
|
||||
// will create it on the fly and sign in with default permissions
|
||||
if (!$user) {
|
||||
LOG::debug("Local user ".Input::get('username')." does not exist");
|
||||
if ($userattr = $this->ldap(Input::get('username'), Input::get('password'), true)) {
|
||||
LOG::debug("Creating local user from authenticated LDAP user.");
|
||||
$credentials = $this->createUserFromLdap($userattr);
|
||||
} else {
|
||||
LOG::debug("User did not authenticate correctly against LDAP. No local user was created.");
|
||||
|
||||
try {
|
||||
|
||||
if ($userattr = Ldap::findAndBindUserLdap($request->input('username'), $request->input('password'))) {
|
||||
LOG::debug("Creating local user ".Input::get('username'));
|
||||
|
||||
if ($newuser = Ldap::createUserFromLdap($userattr)) {
|
||||
LOG::debug("Local user created.");
|
||||
} else {
|
||||
LOG::debug("Could not create local user.");
|
||||
}
|
||||
|
||||
} else {
|
||||
LOG::debug("User did not authenticate correctly against LDAP. No local user was created.");
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->withInput()->with('error',$e->getMessage());
|
||||
}
|
||||
|
||||
// If the user exists and they were imported from LDAP already
|
||||
@@ -208,15 +126,28 @@ class AuthController extends Controller
|
||||
|
||||
LOG::debug("Local user ".Input::get('username')." exists in database. Authenticating existing user against LDAP.");
|
||||
|
||||
if ($this->ldap(Input::get('username'), Input::get('password'))) {
|
||||
if ($ldap_user = Ldap::findAndBindUserLdap($request->input('username'), $request->input('password'))) {
|
||||
$ldap_attr = Ldap::parseAndMapLdapAttributes($ldap_user);
|
||||
|
||||
LOG::debug("Valid LDAP login. Updating the local data.");
|
||||
$user = User::find($user->id); //need the Sentry object, not the Eloquent object, to access critical password hashing functions
|
||||
$user->password = bcrypt(Input::get('password'));
|
||||
$user->ldap_import = 1;
|
||||
|
||||
if (Setting::getSettings()->ldap_pw_sync=='1') {
|
||||
$user->password = bcrypt($request->input('password'));
|
||||
}
|
||||
|
||||
$user->email = $ldap_attr['email'];
|
||||
$user->first_name = $ldap_attr['firstname'];
|
||||
$user->last_name = $ldap_attr['lastname'];
|
||||
$user->save();
|
||||
|
||||
if (Setting::getSettings()->ldap_pw_sync!='1') {
|
||||
Auth::login($user, true);
|
||||
// Redirect to the users page
|
||||
return redirect()->to('/home')->with('success', trans('auth/message.signin.success'));
|
||||
}
|
||||
|
||||
} else {
|
||||
LOG::debug("User did not authenticate correctly against LDAP. Local user was not updated.");
|
||||
LOG::debug("User ".Input::get('username')." did not authenticate correctly against LDAP. Local user was not updated.");
|
||||
}// End LDAP auth
|
||||
|
||||
} // End if(!user)
|
||||
@@ -224,14 +155,17 @@ class AuthController extends Controller
|
||||
// NO LDAP enabled - just try to login the user normally
|
||||
}
|
||||
|
||||
|
||||
LOG::debug("Authenticating user against database.");
|
||||
// Try to log the user in
|
||||
if (!Auth::attempt(Input::only('username', 'password'), Input::get('remember-me', 0))) {
|
||||
LOG::debug("Local authentication failed.");
|
||||
// throw new Cartalyst\Sentry\Users\UserNotFoundException();
|
||||
// throw new Cartalyst\Sentry\Users\UserNotFoundException();
|
||||
return redirect()->back()->withInput()->with('error', trans('auth/message.account_not_found'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Get the page we were before
|
||||
$redirect = \Session::get('loginRedirect', 'home');
|
||||
|
||||
|
||||
@@ -37,4 +37,13 @@ class PasswordController extends Controller
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the e-mail subject line to be used for the reset link email.
|
||||
* Overriding method "getEmailSubject()" from trait "use ResetsPasswords"
|
||||
* @return string
|
||||
*/
|
||||
public function getEmailSubject(){
|
||||
return property_exists($this, 'subject') ? $this->subject : \Lang::get('mail.reset_link');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ use App\Models\Company;
|
||||
use App\Models\Setting;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Redirect;
|
||||
@@ -133,7 +135,7 @@ class CategoriesController extends Controller
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit($categoryId = null)
|
||||
public function postEdit(Request $request, $categoryId = null)
|
||||
{
|
||||
// Check if the blog post exists
|
||||
if (is_null($category = Category::find($categoryId))) {
|
||||
@@ -142,12 +144,14 @@ class CategoriesController extends Controller
|
||||
}
|
||||
|
||||
// Update the category data
|
||||
$category->name = e(Input::get('name'));
|
||||
$category->category_type = e(Input::get('category_type'));
|
||||
$category->eula_text = e(Input::get('eula_text'));
|
||||
$category->use_default_eula = e(Input::get('use_default_eula', '0'));
|
||||
$category->require_acceptance = e(Input::get('require_acceptance', '0'));
|
||||
$category->checkin_email = e(Input::get('checkin_email', '0'));
|
||||
$category->name = e($request->input('name'));
|
||||
// If the item count is > 0, we disable the category type in the edit. Disabled items
|
||||
// don't POST, so if the category_type is blank we just set it to the default.
|
||||
$category->category_type = e($request->input('category_type', $category->category_type));
|
||||
$category->eula_text = e($request->input('eula_text'));
|
||||
$category->use_default_eula = e($request->input('use_default_eula', '0'));
|
||||
$category->require_acceptance = e($request->input('require_acceptance', '0'));
|
||||
$category->checkin_email = e($request->input('checkin_email', '0'));
|
||||
|
||||
if ($category->save()) {
|
||||
// Redirect to the new category page
|
||||
@@ -244,7 +248,7 @@ class CategoriesController extends Controller
|
||||
public function getDatatable()
|
||||
{
|
||||
// Grab all the categories
|
||||
$categories = Category::with('assets', 'accessories', 'consumables','components');
|
||||
$categories = Category::with('assets', 'accessories', 'consumables', 'components');
|
||||
|
||||
if (Input::has('search')) {
|
||||
$categories = $categories->TextSearch(e(Input::get('search')));
|
||||
@@ -300,10 +304,11 @@ class CategoriesController extends Controller
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getDataViewAssets($categoryID) {
|
||||
public function getDataViewAssets($categoryID)
|
||||
{
|
||||
|
||||
$category = Category::with('assets.company')->find($categoryID);
|
||||
$category_assets = $category->assets;
|
||||
$category_assets = $category->assets();
|
||||
|
||||
if (Input::has('search')) {
|
||||
$category_assets = $category_assets->TextSearch(e(Input::get('search')));
|
||||
@@ -335,18 +340,18 @@ class CategoriesController extends Controller
|
||||
$inout='';
|
||||
|
||||
if ($asset->deleted_at=='') {
|
||||
$actions = '<div style=" white-space: nowrap;"><a href="'.route('clone/hardware', $asset->id).'" class="btn btn-info btn-sm" title="Clone asset"><i class="fa fa-files-o"></i></a> <a href="'.route('update/hardware', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> <a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/hardware', $asset->id).'" data-content="'.Lang::get('admin/hardware/message.delete.confirm').'" data-title="'.Lang::get('general.delete').' '.htmlspecialchars($asset->asset_tag).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>';
|
||||
$actions = '<div style=" white-space: nowrap;"><a href="'.route('clone/hardware', $asset->id).'" class="btn btn-info btn-sm" title="Clone asset"><i class="fa fa-files-o"></i></a> <a href="'.route('update/hardware', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> <a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/hardware', $asset->id).'" data-content="'.trans('admin/hardware/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($asset->asset_tag).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>';
|
||||
} elseif ($asset->deleted_at!='') {
|
||||
$actions = '<a href="'.route('restore/hardware', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a>';
|
||||
}
|
||||
|
||||
if ($asset->assetstatus) {
|
||||
if ($asset->assetstatus->deployable != 0) {
|
||||
if (($asset->assigned_to !='') && ($asset->assigned_to > 0)) {
|
||||
$inout = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.Lang::get('general.checkin').'</a>';
|
||||
} else {
|
||||
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.Lang::get('general.checkout').'</a>';
|
||||
}
|
||||
if ($asset->availableForCheckout()) {
|
||||
if (Gate::allows('assets.checkout')) {
|
||||
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.trans('general.checkout').'</a>';
|
||||
}
|
||||
} else {
|
||||
if (Gate::allows('assets.checkin')) {
|
||||
$inout = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.trans('general.checkin').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,7 +361,7 @@ class CategoriesController extends Controller
|
||||
'model' => $asset->model->name,
|
||||
'asset_tag' => $asset->asset_tag,
|
||||
'serial' => $asset->serial,
|
||||
'assigned_to' => ($asset->assigneduser) ? link_to('/admin/users/'.$asset->assigneduser->id.'/view', $asset->assigneduser->fullName()): '',
|
||||
'assigned_to' => ($asset->assigneduser) ? (string)link_to('/admin/users/'.$asset->assigneduser->id.'/view', $asset->assigneduser->fullName()): '',
|
||||
'change' => $inout,
|
||||
'actions' => $actions,
|
||||
'companyName' => Company::getName($asset),
|
||||
@@ -369,7 +374,8 @@ class CategoriesController extends Controller
|
||||
|
||||
|
||||
|
||||
public function getDataViewAccessories($categoryID) {
|
||||
public function getDataViewAccessories($categoryID)
|
||||
{
|
||||
|
||||
$category = Category::with('accessories.company')->find($categoryID);
|
||||
$category_assets = $category->accessories;
|
||||
@@ -404,7 +410,7 @@ class CategoriesController extends Controller
|
||||
$inout='';
|
||||
|
||||
if ($asset->deleted_at=='') {
|
||||
$actions = '<div style=" white-space: nowrap;"><a href="'.route('update/accessory', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> <a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/accessory', $asset->id).'" data-content="'.Lang::get('admin/hardware/message.delete.confirm').'" data-title="'.Lang::get('general.delete').' '.htmlspecialchars($asset->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>';
|
||||
$actions = '<div style=" white-space: nowrap;"><a href="'.route('update/accessory', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> <a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/accessory', $asset->id).'" data-content="'.trans('admin/hardware/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($asset->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>';
|
||||
}
|
||||
|
||||
|
||||
@@ -422,7 +428,8 @@ class CategoriesController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function getDataViewConsumables($categoryID) {
|
||||
public function getDataViewConsumables($categoryID)
|
||||
{
|
||||
|
||||
$category = Category::with('accessories.company')->find($categoryID);
|
||||
$category_assets = $category->consumables;
|
||||
@@ -457,7 +464,7 @@ class CategoriesController extends Controller
|
||||
$inout='';
|
||||
|
||||
if ($asset->deleted_at=='') {
|
||||
$actions = '<div style=" white-space: nowrap;"><a href="'.route('update/consumable', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> <a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/consumable', $asset->id).'" data-content="'.Lang::get('admin/hardware/message.delete.confirm').'" data-title="'.Lang::get('general.delete').' '.htmlspecialchars($asset->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>';
|
||||
$actions = '<div style=" white-space: nowrap;"><a href="'.route('update/consumable', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> <a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/consumable', $asset->id).'" data-content="'.trans('admin/hardware/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($asset->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>';
|
||||
}
|
||||
|
||||
|
||||
@@ -474,7 +481,8 @@ class CategoriesController extends Controller
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getDataViewComponent($categoryID) {
|
||||
public function getDataViewComponent($categoryID)
|
||||
{
|
||||
|
||||
$category = Category::with('accessories.company')->find($categoryID);
|
||||
$category_assets = $category->components;
|
||||
@@ -509,7 +517,7 @@ class CategoriesController extends Controller
|
||||
$inout='';
|
||||
|
||||
if ($asset->deleted_at=='') {
|
||||
$actions = '<div style=" white-space: nowrap;"><a href="'.route('update/component', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> <a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/component', $asset->id).'" data-content="'.Lang::get('admin/hardware/message.delete.confirm').'" data-title="'.Lang::get('general.delete').' '.htmlspecialchars($asset->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>';
|
||||
$actions = '<div style=" white-space: nowrap;"><a href="'.route('update/component', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> <a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/component', $asset->id).'" data-content="'.trans('admin/hardware/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($asset->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>';
|
||||
}
|
||||
|
||||
|
||||
@@ -525,7 +533,4 @@ class CategoriesController extends Controller
|
||||
$data = array('total' => $count, 'rows' => $rows);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ use App\Models\Component;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Models\Asset;
|
||||
use App\Http\Requests\ComponentCheckoutRequest;
|
||||
use Auth;
|
||||
use Config;
|
||||
use DB;
|
||||
@@ -19,6 +18,9 @@ use Redirect;
|
||||
use Slack;
|
||||
use Str;
|
||||
use View;
|
||||
use Validator;
|
||||
use Illuminate\Http\Request;
|
||||
use Gate;
|
||||
|
||||
/**
|
||||
* This class controls all actions related to Components for
|
||||
@@ -54,7 +56,7 @@ class ComponentsController extends Controller
|
||||
public function getCreate()
|
||||
{
|
||||
// Show the page
|
||||
$category_list = array('' => '') + DB::table('categories')->where('category_type', '=', 'component')->whereNull('deleted_at')->orderBy('name', 'ASC')->lists('name', 'id');
|
||||
$category_list = Helper::categoryList('component');
|
||||
$company_list = Helper::companyList();
|
||||
$location_list = Helper::locationsList();
|
||||
|
||||
@@ -97,7 +99,7 @@ class ComponentsController extends Controller
|
||||
if (e(Input::get('purchase_cost')) == '0.00') {
|
||||
$component->purchase_cost = null;
|
||||
} else {
|
||||
$component->purchase_cost = e(Input::get('purchase_cost'));
|
||||
$component->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')));
|
||||
}
|
||||
|
||||
$component->total_qty = e(Input::get('total_qty'));
|
||||
@@ -133,7 +135,7 @@ class ComponentsController extends Controller
|
||||
return redirect()->to('admin/components')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
$category_list = Helper::categoryList();
|
||||
$category_list = Helper::categoryList('component');
|
||||
$company_list = Helper::companyList();
|
||||
$location_list = Helper::locationsList();
|
||||
|
||||
@@ -181,7 +183,7 @@ class ComponentsController extends Controller
|
||||
if (e(Input::get('purchase_cost')) == '0.00') {
|
||||
$component->purchase_cost = null;
|
||||
} else {
|
||||
$component->purchase_cost = e(Input::get('purchase_cost'));
|
||||
$component->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')));
|
||||
}
|
||||
|
||||
$component->total_qty = e(Input::get('total_qty'));
|
||||
@@ -287,7 +289,7 @@ class ComponentsController extends Controller
|
||||
}
|
||||
|
||||
// Get the dropdown of assets and then pass it to the checkout view
|
||||
$assets_list = Helper::assetsList();
|
||||
$assets_list = Helper::detailedAssetList();
|
||||
|
||||
return View::make('components/checkout', compact('component'))->with('assets_list', $assets_list);
|
||||
|
||||
@@ -302,9 +304,12 @@ class ComponentsController extends Controller
|
||||
* @param int $componentId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCheckout(ComponentCheckoutRequest $request, $componentId)
|
||||
public function postCheckout(Request $request, $componentId)
|
||||
{
|
||||
// Check if the component exists
|
||||
|
||||
|
||||
|
||||
// Check if the component exists
|
||||
if (is_null($component = Component::find($componentId))) {
|
||||
// Redirect to the component management page with error
|
||||
return redirect()->to('components')->with('error', trans('admin/components/message.not_found'));
|
||||
@@ -312,6 +317,19 @@ class ComponentsController extends Controller
|
||||
return redirect()->to('admin/components')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
|
||||
$max_to_checkout = $component->numRemaining();
|
||||
$validator = Validator::make($request->all(),[
|
||||
"asset_id" => "required",
|
||||
"assigned_qty" => "required|numeric|between:1,$max_to_checkout"
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()
|
||||
->withErrors($validator)
|
||||
->withInput();
|
||||
}
|
||||
|
||||
$admin_user = Auth::user();
|
||||
$asset_id = e(Input::get('asset_id'));
|
||||
|
||||
@@ -320,24 +338,18 @@ class ComponentsController extends Controller
|
||||
// Redirect to the component management page with error
|
||||
return redirect()->to('admin/components')->with('error', trans('admin/components/message.asset_does_not_exist'));
|
||||
}
|
||||
|
||||
|
||||
// Update the component data
|
||||
$component->asset_id = $asset_id;
|
||||
|
||||
$component->assets()->attach($component->id, array(
|
||||
'component_id' => $component->id,
|
||||
'user_id' => $admin_user->id,
|
||||
'created_at' => date('Y-m-d h:i:s'),
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'assigned_qty' => e(Input::get('assigned_qty')),
|
||||
'asset_id' => $asset_id));
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->component_id = $component->id;
|
||||
$logaction->asset_id = $asset_id;
|
||||
$logaction->asset_type = 'component';
|
||||
$logaction->location_id = $asset->location_id;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = e(Input::get('note'));
|
||||
$logaction = $component->logCheckout(e(Input::get('note')), $asset_id);
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
@@ -357,7 +369,7 @@ class ComponentsController extends Controller
|
||||
'fields' => [
|
||||
[
|
||||
'title' => 'Checked Out:',
|
||||
'value' => strtoupper($logaction->asset_type).' <'.config('app.url').'/admin/components/'.$component->id.'/view'.'|'.$component->name.'> checked out to <'.config('app.url').'/hardware/'.$asset->id.'/view|'.$asset->name.'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.'
|
||||
'value' => class_basename(strtoupper($logaction->item_type)).' <'.config('app.url').'/admin/components/'.$component->id.'/view'.'|'.$component->name.'> checked out to <'.config('app.url').'/hardware/'.$asset->id.'/view|'.$asset->showAssetName().'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
@@ -371,9 +383,6 @@ class ComponentsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$log = $logaction->logaction('checkout');
|
||||
|
||||
// Redirect to the new component page
|
||||
return redirect()->to("admin/components")->with('success', trans('admin/components/message.checkout.success'));
|
||||
|
||||
@@ -393,8 +402,8 @@ class ComponentsController extends Controller
|
||||
**/
|
||||
public function getDatatable()
|
||||
{
|
||||
$components = Component::select('components.*')->whereNull('components.deleted_at')
|
||||
->with('company', 'location', 'category');
|
||||
$components = Company::scopeCompanyables(Component::select('components.*')->whereNull('components.deleted_at')
|
||||
->with('company', 'location', 'category'));
|
||||
|
||||
if (Input::has('search')) {
|
||||
$components = $components->TextSearch(Input::get('search'));
|
||||
@@ -437,7 +446,23 @@ class ComponentsController extends Controller
|
||||
$rows = array();
|
||||
|
||||
foreach ($components as $component) {
|
||||
$actions = '<nobr><a href="'.route('checkout/component', $component->id).'" style="margin-right:5px;" class="btn btn-info btn-sm" '.(($component->numRemaining() > 0 ) ? '' : ' disabled').'>'.trans('general.checkout').'</a><a href="'.route('update/component', $component->id).'" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a><a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/component', $component->id).'" data-content="'.trans('admin/components/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($component->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></nobr>';
|
||||
$actions = '<nobr>';
|
||||
if (Gate::allows('components.checkout')) {
|
||||
$actions .= '<a href="' . route('checkout/component',
|
||||
$component->id) . '" style="margin-right:5px;" class="btn btn-info btn-sm ' . (($component->numRemaining() > 0) ? '' : ' disabled') . '" ' . (($component->numRemaining() > 0) ? '' : ' disabled') . '>' . trans('general.checkout') . '</a>';
|
||||
}
|
||||
|
||||
if (Gate::allows('components.edit')) {
|
||||
$actions .= '<a href="' . route('update/component',
|
||||
$component->id) . '" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a>';
|
||||
}
|
||||
|
||||
if (Gate::allows('components.delete')) {
|
||||
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/component',
|
||||
$component->id) . '" data-content="' . trans('admin/components/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($component->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
|
||||
}
|
||||
|
||||
$actions .='</nobr>';
|
||||
$company = $component->company;
|
||||
|
||||
$rows[] = array(
|
||||
@@ -450,7 +475,7 @@ class ComponentsController extends Controller
|
||||
'category' => ($component->category) ? e($component->category->name) : 'Missing category',
|
||||
'order_number' => e($component->order_number),
|
||||
'purchase_date' => e($component->purchase_date),
|
||||
'purchase_cost' => ($component->purchase_cost!='') ? number_format($component->purchase_cost, 2): '' ,
|
||||
'purchase_cost' => Helper::formatCurrencyOutput($component->purchase_cost),
|
||||
'numRemaining' => $component->numRemaining(),
|
||||
'actions' => $actions,
|
||||
'companyName' => is_null($company) ? '' : e($company->name),
|
||||
@@ -486,7 +511,7 @@ class ComponentsController extends Controller
|
||||
|
||||
foreach ($component->assets as $component_assignment) {
|
||||
$rows[] = array(
|
||||
'name' => (string)link_to('/hardware/'.$component_assignment->id.'/view', e($component_assignment->name)),
|
||||
'name' => (string)link_to('/hardware/'.$component_assignment->id.'/view', e($component_assignment->showAssetName())),
|
||||
'qty' => e($component_assignment->pivot->assigned_qty),
|
||||
'created_at' => ($component_assignment->created_at->format('Y-m-d H:i:s')=='-0001-11-30 00:00:00') ? '' : $component_assignment->created_at->format('Y-m-d H:i:s'),
|
||||
);
|
||||
|
||||
@@ -18,6 +18,7 @@ use Redirect;
|
||||
use Slack;
|
||||
use Str;
|
||||
use View;
|
||||
use Gate;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Consumables for
|
||||
@@ -52,7 +53,7 @@ class ConsumablesController extends Controller
|
||||
public function getCreate()
|
||||
{
|
||||
// Show the page
|
||||
$category_list = array('' => '') + DB::table('categories')->where('category_type', '=', 'consumable')->whereNull('deleted_at')->orderBy('name', 'ASC')->lists('name', 'id');
|
||||
$category_list = Helper::categoryList('consumable');
|
||||
$company_list = Helper::companyList();
|
||||
$location_list = Helper::locationsList();
|
||||
$manufacturer_list = Helper::manufacturerList();
|
||||
@@ -96,7 +97,7 @@ class ConsumablesController extends Controller
|
||||
if (e(Input::get('purchase_cost')) == '0.00') {
|
||||
$consumable->purchase_cost = null;
|
||||
} else {
|
||||
$consumable->purchase_cost = e(Input::get('purchase_cost'));
|
||||
$consumable->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')));
|
||||
}
|
||||
|
||||
$consumable->qty = e(Input::get('qty'));
|
||||
@@ -132,7 +133,7 @@ class ConsumablesController extends Controller
|
||||
return redirect()->to('admin/consumables')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
$category_list = Helper::categoryList();
|
||||
$category_list = Helper::categoryList('consumable');
|
||||
$company_list = Helper::companyList();
|
||||
$location_list = Helper::locationsList();
|
||||
$manufacturer_list = Helper::manufacturerList();
|
||||
@@ -181,10 +182,10 @@ class ConsumablesController extends Controller
|
||||
if (e(Input::get('purchase_cost')) == '0.00') {
|
||||
$consumable->purchase_cost = null;
|
||||
} else {
|
||||
$consumable->purchase_cost = e(Input::get('purchase_cost'));
|
||||
$consumable->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')));
|
||||
}
|
||||
|
||||
$consumable->qty = e(Input::get('qty'));
|
||||
$consumable->qty = Helper::ParseFloat(e(Input::get('qty')));
|
||||
|
||||
if ($consumable->save()) {
|
||||
return redirect()->to("admin/consumables")->with('success', trans('admin/consumables/message.update.success'));
|
||||
@@ -315,13 +316,7 @@ class ConsumablesController extends Controller
|
||||
'user_id' => $admin_user->id,
|
||||
'assigned_to' => e(Input::get('assigned_to'))));
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->consumable_id = $consumable->id;
|
||||
$logaction->checkedout_to = $consumable->assigned_to;
|
||||
$logaction->asset_type = 'consumable';
|
||||
$logaction->location_id = $user->location_id;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = e(Input::get('note'));
|
||||
$logaction = $consumable->logCheckout(e(Input::get('note')));
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
@@ -341,7 +336,7 @@ class ConsumablesController extends Controller
|
||||
'fields' => [
|
||||
[
|
||||
'title' => 'Checked Out:',
|
||||
'value' => strtoupper($logaction->asset_type).' <'.config('app.url').'/admin/consumables/'.$consumable->id.'/view'.'|'.$consumable->name.'> checked out to <'.config('app.url').'/admin/users/'.$user->id.'/view|'.$user->fullName().'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.'
|
||||
'value' => 'Consumable <'.config('app.url').'/admin/consumables/'.$consumable->id.'/view'.'|'.$consumable->name.'> checked out to <'.config('app.url').'/admin/users/'.$user->id.'/view|'.$user->fullName().'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
@@ -355,9 +350,6 @@ class ConsumablesController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$log = $logaction->logaction('checkout');
|
||||
|
||||
$consumable_user = DB::table('consumables_users')->where('assigned_to', '=', $consumable->assigned_to)->where('consumable_id', '=', $consumable->id)->first();
|
||||
|
||||
$data['log_id'] = $logaction->id;
|
||||
@@ -365,8 +357,6 @@ class ConsumablesController extends Controller
|
||||
$data['first_name'] = $user->first_name;
|
||||
$data['item_name'] = $consumable->name;
|
||||
$data['checkout_date'] = $logaction->created_at;
|
||||
$data['item_tag'] = '';
|
||||
$data['expected_checkin'] = '';
|
||||
$data['note'] = $logaction->note;
|
||||
$data['require_acceptance'] = $consumable->requireAcceptance();
|
||||
|
||||
@@ -375,7 +365,8 @@ class ConsumablesController extends Controller
|
||||
|
||||
Mail::send('emails.accept-asset', $data, function ($m) use ($user) {
|
||||
$m->to($user->email, $user->first_name . ' ' . $user->last_name);
|
||||
$m->subject('Confirm consumable delivery');
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.Confirm_consumable_delivery'));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -398,8 +389,8 @@ class ConsumablesController extends Controller
|
||||
*/
|
||||
public function getDatatable()
|
||||
{
|
||||
$consumables = Consumable::select('consumables.*')->whereNull('consumables.deleted_at')
|
||||
->with('company', 'location', 'category', 'users');
|
||||
$consumables = Company::scopeCompanyables(Consumable::select('consumables.*')->whereNull('consumables.deleted_at')
|
||||
->with('company', 'location', 'category', 'users'));
|
||||
|
||||
if (Input::has('search')) {
|
||||
$consumables = $consumables->TextSearch(e(Input::get('search')));
|
||||
@@ -445,7 +436,23 @@ class ConsumablesController extends Controller
|
||||
$rows = array();
|
||||
|
||||
foreach ($consumables as $consumable) {
|
||||
$actions = '<nobr><a href="'.route('checkout/consumable', $consumable->id).'" style="margin-right:5px;" class="btn btn-info btn-sm" '.(($consumable->numRemaining() > 0 ) ? '' : ' disabled').'>'.trans('general.checkout').'</a><a href="'.route('update/consumable', $consumable->id).'" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a><a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/consumable', $consumable->id).'" data-content="'.trans('admin/consumables/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($consumable->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></nobr>';
|
||||
$actions = '<nobr>';
|
||||
if (Gate::allows('consumables.checkout')) {
|
||||
$actions .= '<a href="' . route('checkout/consumable',
|
||||
$consumable->id) . '" style="margin-right:5px;" class="btn btn-info btn-sm" ' . (($consumable->numRemaining() > 0) ? '' : ' disabled') . '>' . trans('general.checkout') . '</a>';
|
||||
}
|
||||
|
||||
if (Gate::allows('consumables.edit')) {
|
||||
$actions .= '<a href="' . route('update/consumable',
|
||||
$consumable->id) . '" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a>';
|
||||
}
|
||||
if (Gate::allows('consumables.delete')) {
|
||||
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/consumable',
|
||||
$consumable->id) . '" data-content="' . trans('admin/consumables/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($consumable->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
|
||||
}
|
||||
|
||||
$actions .='</nobr>';
|
||||
|
||||
$company = $consumable->company;
|
||||
|
||||
$rows[] = array(
|
||||
@@ -454,13 +461,13 @@ class ConsumablesController extends Controller
|
||||
'location' => ($consumable->location) ? e($consumable->location->name) : '',
|
||||
'min_amt' => e($consumable->min_amt),
|
||||
'qty' => e($consumable->qty),
|
||||
'manufacturer' => ($consumable->manufacturer) ? e($consumable->manufacturer->name) : '',
|
||||
'model_no' => e($consumable->model_no),
|
||||
'item_no' => e($consumable->item_no),
|
||||
'category' => ($consumable->category) ? e($consumable->category->name) : 'Missing category',
|
||||
'manufacturer' => ($consumable->manufacturer) ? (string) link_to('/admin/settings/manufacturers/'.$consumable->manufacturer_id.'/view', $consumable->manufacturer->name): '',
|
||||
'model_no' => e($consumable->model_no),
|
||||
'item_no' => e($consumable->item_no),
|
||||
'category' => ($consumable->category) ? (string) link_to('/admin/settings/categories/'.$consumable->category_id.'/view', $consumable->category->name) : 'Missing category',
|
||||
'order_number' => e($consumable->order_number),
|
||||
'purchase_date' => e($consumable->purchase_date),
|
||||
'purchase_cost' => ($consumable->purchase_cost!='') ? number_format($consumable->purchase_cost, 2): '' ,
|
||||
'purchase_cost' => Helper::formatCurrencyOutput($consumable->purchase_cost),
|
||||
'numRemaining' => $consumable->numRemaining(),
|
||||
'actions' => $actions,
|
||||
'companyName' => is_null($company) ? '' : e($company->name),
|
||||
|
||||
@@ -10,6 +10,7 @@ use Redirect;
|
||||
use App\Models\AssetModel;
|
||||
use Lang;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Custom Asset Fields for
|
||||
@@ -63,10 +64,15 @@ class CustomFieldsController extends Controller
|
||||
* @since [v1.8]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function store()
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
$cfset=new CustomFieldset(["name" => Input::get("name"),"user_id" => Auth::user()->id]);
|
||||
$cfset = new CustomFieldset(
|
||||
[
|
||||
"name" => e($request->get("name")),
|
||||
"user_id" => Auth::user()->id]
|
||||
);
|
||||
|
||||
$validator=Validator::make(Input::all(), $cfset->rules);
|
||||
if ($validator->passes()) {
|
||||
$cfset->save();
|
||||
@@ -122,24 +128,33 @@ class CustomFieldsController extends Controller
|
||||
* @since [v1.8]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function storeField()
|
||||
public function storeField(Request $request)
|
||||
{
|
||||
$field=new CustomField(["name" => Input::get("name"),"element" => Input::get("element"),"user_id" => Auth::user()->id]);
|
||||
$field = new CustomField([
|
||||
"name" => e($request->get("name")),
|
||||
"element" => e($request->get("element")),
|
||||
"field_values" => e($request->get("field_values")),
|
||||
"field_encrypted" => e($request->get("field_encrypted", 0)),
|
||||
"user_id" => Auth::user()->id
|
||||
]);
|
||||
|
||||
|
||||
|
||||
if (!in_array(Input::get('format'), array_keys(CustomField::$PredefinedFormats))) {
|
||||
$field->format=Input::get("custom_format");
|
||||
$field->format = e($request->get("custom_format"));
|
||||
} else {
|
||||
$field->format=Input::get('format');
|
||||
$field->format = e($request->get("format"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
$validator=Validator::make(Input::all(), $field->rules);
|
||||
if ($validator->passes()) {
|
||||
$results=$field->save();
|
||||
//return "postCreateField: $results";
|
||||
$results = $field->save();
|
||||
if ($results) {
|
||||
return redirect()->route("admin.custom_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'));
|
||||
}
|
||||
} else {
|
||||
@@ -147,6 +162,25 @@ class CustomFieldsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Detach a custom field from a fieldset.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function deleteFieldFromFieldset($field_id, $fieldset_id)
|
||||
{
|
||||
$field = CustomField::find($field_id);
|
||||
|
||||
if ($field->fieldset()->detach($fieldset_id)) {
|
||||
return redirect()->route("admin.custom_fields.index")->with("success", trans('admin/custom_fields/message.field.delete.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withErrors(['message' => "Field is in-use"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a custom field.
|
||||
*
|
||||
@@ -156,7 +190,7 @@ class CustomFieldsController extends Controller
|
||||
*/
|
||||
public function deleteField($field_id)
|
||||
{
|
||||
$field=CustomField::find($field_id);
|
||||
$field = CustomField::find($field_id);
|
||||
|
||||
if ($field->fieldset->count()>0) {
|
||||
return redirect()->back()->withErrors(['message' => "Field is in-use"]);
|
||||
@@ -260,7 +294,8 @@ class CustomFieldsController extends Controller
|
||||
* @since [v3.0]
|
||||
* @return Array
|
||||
*/
|
||||
public function postReorder($id) {
|
||||
public function postReorder($id)
|
||||
{
|
||||
$fieldset=CustomFieldset::find($id);
|
||||
$fields = array();
|
||||
|
||||
|
||||
@@ -30,12 +30,6 @@ class DashboardController extends Controller
|
||||
// Show the page
|
||||
if (Auth::user()->hasAccess('admin')) {
|
||||
|
||||
$recent_activity = Actionlog::orderBy('created_at', 'DESC')
|
||||
->with('accessorylog', 'consumablelog', 'licenselog', 'assetlog', 'adminlog', 'userlog', 'componentlog')
|
||||
->take(30)
|
||||
->get();
|
||||
|
||||
|
||||
$asset_stats['total'] = Asset::Hardware()->count();
|
||||
|
||||
$asset_stats['rtd']['total'] = Asset::Hardware()->RTD()->count();
|
||||
@@ -82,7 +76,7 @@ class DashboardController extends Controller
|
||||
}
|
||||
|
||||
|
||||
return View::make('dashboard')->with('asset_stats', $asset_stats)->with('recent_activity', $recent_activity);
|
||||
return View::make('dashboard')->with('asset_stats', $asset_stats);
|
||||
} else {
|
||||
// Redirect to the profile page
|
||||
return redirect()->route('view-assets');
|
||||
|
||||
@@ -11,7 +11,6 @@ use Str;
|
||||
use View;
|
||||
use Auth;
|
||||
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Depreciations for
|
||||
* the Snipe-IT Asset Management application.
|
||||
|
||||
@@ -47,11 +47,11 @@ class GroupsController extends Controller
|
||||
$group = new Group;
|
||||
// Get all the available permissions
|
||||
$permissions = config('permissions');
|
||||
|
||||
$selectedPermissions = Input::old('permissions', array());
|
||||
$groupPermissions = array();
|
||||
$selectedPermissions = Input::old('permissions', $groupPermissions);
|
||||
|
||||
// Show the page
|
||||
return View::make('groups/edit', compact('permissions', 'selectedPermissions'))->with('group', $group);
|
||||
return View::make('groups/edit', compact('permissions', 'selectedPermissions', 'groupPermissions'))->with('group', $group);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,7 +70,7 @@ class GroupsController extends Controller
|
||||
$group->permissions = json_encode(Input::get('permission'));
|
||||
|
||||
if ($group->save()) {
|
||||
return redirect()->to("admin/groups")->with('success', trans('admin/groups/message.create.success'));
|
||||
return redirect()->to("admin/groups")->with('success', trans('admin/groups/message.success.create'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($group->getErrors());
|
||||
@@ -91,9 +91,9 @@ class GroupsController extends Controller
|
||||
{
|
||||
$group = Group::find($id);
|
||||
$permissions = config('permissions');
|
||||
$group->permissions = $group->decodePermissions();
|
||||
$selected_array = Helper::selectedPermissionsArray($permissions, $group->permissions);
|
||||
return View::make('groups/edit', compact('group', 'permissions','selected_array'));
|
||||
$groupPermissions = $group->decodePermissions();
|
||||
$selected_array = Helper::selectedPermissionsArray($permissions, $groupPermissions);
|
||||
return View::make('groups/edit', compact('group', 'permissions', 'selected_array', 'groupPermissions'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +119,7 @@ class GroupsController extends Controller
|
||||
if (!config('app.lock_passwords')) {
|
||||
|
||||
if ($group->save()) {
|
||||
return redirect()->to("admin/groups")->with('success', trans('admin/groups/message.create.success'));
|
||||
return redirect()->to("admin/groups")->with('success', trans('admin/groups/message.success.update'));
|
||||
}
|
||||
return redirect()->back()->withInput()->withErrors($group->getErrors());
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ use Config;
|
||||
use Session;
|
||||
use App\Helpers\Helper;
|
||||
use Auth;
|
||||
use Gate;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Licenses for
|
||||
@@ -60,18 +61,17 @@ class LicensesController extends Controller
|
||||
public function getCreate()
|
||||
{
|
||||
|
||||
$depreciation_list = Helper::depreciationList();
|
||||
$supplier_list = Helper::suppliersList();
|
||||
$maintained_list = array('' => 'Maintained', '1' => 'Yes', '0' => 'No');
|
||||
$company_list = Helper::companyList();
|
||||
|
||||
return View::make('licenses/edit')
|
||||
//->with('license_options',$license_options)
|
||||
->with('depreciation_list', $depreciation_list)
|
||||
->with('supplier_list', $supplier_list)
|
||||
->with('depreciation_list', Helper::depreciationList())
|
||||
->with('supplier_list', Helper::suppliersList())
|
||||
->with('maintained_list', $maintained_list)
|
||||
->with('company_list', $company_list)
|
||||
->with('company_list', Helper::companyList())
|
||||
->with('manufacturer_list', Helper::manufacturerList())
|
||||
->with('license', new License);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -87,17 +87,13 @@ class LicensesController extends Controller
|
||||
public function postCreate()
|
||||
{
|
||||
|
||||
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// create a new model instance
|
||||
$license = new License();
|
||||
|
||||
if (e(Input::get('purchase_cost')) == '') {
|
||||
$license->purchase_cost = null;
|
||||
} else {
|
||||
$license->purchase_cost = e(Input::get('purchase_cost'));
|
||||
$license->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')));
|
||||
}
|
||||
|
||||
if (e(Input::get('supplier_id')) == '') {
|
||||
@@ -124,6 +120,12 @@ class LicensesController extends Controller
|
||||
$license->purchase_order = e(Input::get('purchase_order'));
|
||||
}
|
||||
|
||||
if (empty(e(Input::get('manufacturer_id')))) {
|
||||
$license->manufacturer_id = null;
|
||||
} else {
|
||||
$license->manufacturer_id = e(Input::get('manufacturer_id'));
|
||||
}
|
||||
|
||||
// Save the license data
|
||||
$license->name = e(Input::get('name'));
|
||||
$license->serial = e(Input::get('serial'));
|
||||
@@ -156,14 +158,16 @@ class LicensesController extends Controller
|
||||
|
||||
$insertedId = $license->id;
|
||||
// Save the license seat data
|
||||
for ($x=0; $x<$license->seats; $x++) {
|
||||
$license_seat = new LicenseSeat();
|
||||
$license_seat->license_id = $insertedId;
|
||||
$license_seat->user_id = Auth::user()->id;
|
||||
$license_seat->assigned_to = null;
|
||||
$license_seat->notes = null;
|
||||
$license_seat->save();
|
||||
}
|
||||
DB::transaction(function () use (&$insertedId, &$license) {
|
||||
for ($x=0; $x<$license->seats; $x++) {
|
||||
$license_seat = new LicenseSeat();
|
||||
$license_seat->license_id = $insertedId;
|
||||
$license_seat->user_id = Auth::user()->id;
|
||||
$license_seat->assigned_to = null;
|
||||
$license_seat->notes = null;
|
||||
$license_seat->save();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Redirect to the new license page
|
||||
@@ -203,17 +207,15 @@ class LicensesController extends Controller
|
||||
|
||||
// Show the page
|
||||
$license_options = array('' => 'Top Level') + DB::table('assets')->where('id', '!=', $licenseId)->pluck('name', 'id');
|
||||
$depreciation_list = array('0' => trans('admin/licenses/form.no_depreciation')) + Depreciation::pluck('name', 'id')->toArray();
|
||||
$supplier_list = array('' => 'Select Supplier') + Supplier::orderBy('name', 'asc')->pluck('name', 'id')->toArray();
|
||||
$maintained_list = array('' => 'Maintained', '1' => 'Yes', '0' => 'No');
|
||||
$company_list = Helper::companyList();
|
||||
|
||||
return View::make('licenses/edit', compact('license'))
|
||||
->with('license_options', $license_options)
|
||||
->with('depreciation_list', $depreciation_list)
|
||||
->with('supplier_list', $supplier_list)
|
||||
->with('company_list', $company_list)
|
||||
->with('maintained_list', $maintained_list);
|
||||
->with('depreciation_list', Helper::depreciationList())
|
||||
->with('supplier_list', Helper::suppliersList())
|
||||
->with('company_list', Helper::companyList())
|
||||
->with('maintained_list', $maintained_list)
|
||||
->with('manufacturer_list', Helper::manufacturerList());
|
||||
}
|
||||
|
||||
|
||||
@@ -250,6 +252,13 @@ class LicensesController extends Controller
|
||||
$license->maintained = e(Input::get('maintained'));
|
||||
$license->reassignable = e(Input::get('reassignable'));
|
||||
|
||||
if (empty(e(Input::get('manufacturer_id')))) {
|
||||
$license->manufacturer_id = null;
|
||||
} else {
|
||||
$license->manufacturer_id = e(Input::get('manufacturer_id'));
|
||||
}
|
||||
|
||||
|
||||
if (e(Input::get('supplier_id')) == '') {
|
||||
$license->supplier_id = null;
|
||||
} else {
|
||||
@@ -276,10 +285,9 @@ class LicensesController extends Controller
|
||||
}
|
||||
|
||||
if (e(Input::get('purchase_cost')) == '') {
|
||||
$license->purchase_cost = null;
|
||||
$license->purchase_cost = null;
|
||||
} else {
|
||||
$license->purchase_cost = e(Input::get('purchase_cost'));
|
||||
//$license->purchase_cost = e(Input::get('purchase_cost'));
|
||||
$license->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')));
|
||||
}
|
||||
|
||||
if (e(Input::get('maintained')) == '') {
|
||||
@@ -321,11 +329,11 @@ class LicensesController extends Controller
|
||||
|
||||
//Log the deletion of seats to the log
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $license->id;
|
||||
$logaction->asset_type = 'software';
|
||||
$logaction->item_type = License::class;
|
||||
$logaction->item_id = $license->id;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = abs($difference)." seats";
|
||||
$logaction->checkedout_to = null;
|
||||
$logaction->note = '-'.abs($difference)." seats";
|
||||
$logaction->target_id = null;
|
||||
$log = $logaction->logaction('delete seats');
|
||||
|
||||
} else {
|
||||
@@ -346,10 +354,11 @@ class LicensesController extends Controller
|
||||
|
||||
//Log the addition of license to the log.
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $license->id;
|
||||
$logaction->asset_type = 'software';
|
||||
$logaction->item_type = License::class;
|
||||
$logaction->item_id = $license->id;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = abs($difference)." seats";
|
||||
$logaction->note = '+'.abs($difference)." seats";
|
||||
$logaction->target_id = null;
|
||||
$log = $logaction->logaction('add seats');
|
||||
}
|
||||
$license->seats = e(Input::get('seats'));
|
||||
@@ -435,40 +444,12 @@ class LicensesController extends Controller
|
||||
}
|
||||
|
||||
// Get the dropdown of users and then pass it to the checkout view
|
||||
$users_list = array('' => 'Select a User') + DB::table('users')->select(DB::raw('concat(last_name,", ",first_name," (",username,")") as full_name, id'))->whereNull('deleted_at')->orderBy('last_name', 'asc')->orderBy('first_name', 'asc')->lists('full_name', 'id');
|
||||
$users_list = Helper::usersList();
|
||||
|
||||
|
||||
// Left join to get a list of assets and some other helpful info
|
||||
$asset = DB::table('assets')
|
||||
->leftJoin('users', 'users.id', '=', 'assets.assigned_to')
|
||||
->leftJoin('models', 'assets.model_id', '=', 'models.id')
|
||||
->select(
|
||||
'assets.id',
|
||||
'assets.name',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'asset_tag',
|
||||
DB::raw('concat(first_name," ",last_name) as full_name, assets.id as id, models.name as modelname')
|
||||
)
|
||||
->whereNull('assets.deleted_at')
|
||||
->get();
|
||||
|
||||
$asset_array = json_decode(json_encode($asset), true);
|
||||
$asset_element[''] = 'Please select an asset';
|
||||
|
||||
// Build a list out of the data results
|
||||
for ($x=0; $x<count($asset_array); $x++) {
|
||||
|
||||
if ($asset_array[$x]['full_name']!='') {
|
||||
$full_name = ' ('.$asset_array[$x]['full_name'].') '.$asset_array[$x]['modelname'];
|
||||
} else {
|
||||
$full_name = ' (Unassigned) '.$asset_array[$x]['modelname'];
|
||||
}
|
||||
$asset_element[$asset_array[$x]['id']] = $asset_array[$x]['asset_tag'].' - '.$asset_array[$x]['name'].$full_name;
|
||||
|
||||
}
|
||||
|
||||
return View::make('licenses/checkout', compact('licenseseat'))->with('users_list', $users_list)->with('asset_list', $asset_element);
|
||||
$assets = Helper::detailedAssetList();
|
||||
return View::make('licenses/checkout', compact('licenseseat'))
|
||||
->with('users_list', $users_list)
|
||||
->with('asset_list', $assets);
|
||||
|
||||
}
|
||||
|
||||
@@ -521,13 +502,13 @@ class LicensesController extends Controller
|
||||
|
||||
if ($asset_id!='') {
|
||||
|
||||
if (is_null($is_asset_id = Asset::find($asset_id))) {
|
||||
if (is_null($asset = Asset::find($asset_id))) {
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->to('admin/licenses')->with('error', trans('admin/licenses/message.asset_does_not_exist'));
|
||||
}
|
||||
|
||||
if (($is_asset_id->assigned_to!=$assigned_to) && ($assigned_to!='')) {
|
||||
//echo 'asset assigned to: '.$is_asset_id->assigned_to.'<br>license assigned to: '.$assigned_to;
|
||||
|
||||
if (($asset->assigned_to!='') && (($asset->assigned_to!=$assigned_to)) && ($assigned_to!='')) {
|
||||
return redirect()->to('admin/licenses')->with('error', trans('admin/licenses/message.owner_doesnt_match_asset'));
|
||||
}
|
||||
|
||||
@@ -558,14 +539,10 @@ class LicensesController extends Controller
|
||||
// Was the asset updated?
|
||||
if ($licenseseat->save()) {
|
||||
|
||||
$logaction = new Actionlog();
|
||||
|
||||
//$logaction->location_id = $assigned_to->location_id;
|
||||
$logaction->asset_type = 'software';
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = e(Input::get('note'));
|
||||
$logaction->asset_id = $licenseseat->license_id;
|
||||
$licenseseat->logCheckout(e(Input::get('note')));
|
||||
|
||||
$data['license_id'] =$licenseseat->license_id;
|
||||
$data['note'] = e(Input::get('note'));
|
||||
|
||||
$license = License::find($licenseseat->license_id);
|
||||
$settings = Setting::getSettings();
|
||||
@@ -573,11 +550,9 @@ class LicensesController extends Controller
|
||||
|
||||
// Update the asset data
|
||||
if (e(Input::get('assigned_to')) == '') {
|
||||
$logaction->checkedout_to = null;
|
||||
$slack_msg = strtoupper($logaction->asset_type).' license <'.config('app.url').'/admin/licenses/'.$license->id.'/view'.'|'.$license->name.'> checked out to <'.config('app.url').'/hardware/'.$is_asset_id->id.'/view|'.$is_asset_id->showAssetName().'> by <'.config('app.url').'/admin/users/'.$user->id.'/view'.'|'.$user->fullName().'>.';
|
||||
$slack_msg = 'License <'.config('app.url').'/admin/licenses/'.$license->id.'/view'.'|'.$license->name.'> checked out to <'.config('app.url').'/hardware/'.$asset->id.'/view|'.$asset->showAssetName().'> by <'.config('app.url').'/admin/users/'.$user->id.'/view'.'|'.$user->fullName().'>.';
|
||||
} else {
|
||||
$logaction->checkedout_to = e(Input::get('assigned_to'));
|
||||
$slack_msg = strtoupper($logaction->asset_type).' license <'.config('app.url').'/admin/licenses/'.$license->id.'/view'.'|'.$license->name.'> checked out to <'.config('app.url').'/admin/users/'.$is_assigned_to->id.'/view|'.$is_assigned_to->fullName().'> by <'.config('app.url').'/admin/users/'.$user->id.'/view'.'|'.$user->fullName().'>.';
|
||||
$slack_msg = 'License <'.config('app.url').'/admin/licenses/'.$license->id.'/view'.'|'.$license->name.'> checked out to <'.config('app.url').'/admin/users/'.$user->id.'/view|'.$is_assigned_to->fullName().'> by <'.config('app.url').'/admin/users/'.$user->id.'/view'.'|'.$user->fullName().'>.';
|
||||
}
|
||||
|
||||
|
||||
@@ -603,7 +578,7 @@ class LicensesController extends Controller
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
'value' => e($logaction->note)
|
||||
'value' => e(Input::get('note'))
|
||||
],
|
||||
|
||||
|
||||
@@ -617,9 +592,6 @@ class LicensesController extends Controller
|
||||
|
||||
}
|
||||
|
||||
$log = $logaction->logaction('checkout');
|
||||
|
||||
|
||||
// Redirect to the new asset page
|
||||
return redirect()->to("admin/licenses")->with('success', trans('admin/licenses/message.checkout.success'));
|
||||
}
|
||||
@@ -698,8 +670,6 @@ class LicensesController extends Controller
|
||||
return redirect()->back()->withInput()->withErrors($validator);
|
||||
}
|
||||
$return_to = $licenseseat->assigned_to;
|
||||
$logaction = new Actionlog();
|
||||
$logaction->checkedout_to = $licenseseat->assigned_to;
|
||||
|
||||
// Update the asset data
|
||||
$licenseseat->assigned_to = null;
|
||||
@@ -709,11 +679,7 @@ class LicensesController extends Controller
|
||||
|
||||
// Was the asset updated?
|
||||
if ($licenseseat->save()) {
|
||||
$logaction->asset_id = $licenseseat->license_id;
|
||||
$logaction->location_id = null;
|
||||
$logaction->asset_type = 'software';
|
||||
$logaction->note = e(Input::get('note'));
|
||||
$logaction->user_id = $user->id;
|
||||
$licenseseat->logCheckin(e(Input::get('note')));
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
@@ -734,11 +700,11 @@ class LicensesController extends Controller
|
||||
'fields' => [
|
||||
[
|
||||
'title' => 'Checked In:',
|
||||
'value' => strtoupper($logaction->asset_type).' <'.config('app.url').'/admin/licenses/'.$license->id.'/view'.'|'.$license->name.'> checked in by <'.config('app.url').'/admin/users/'.$user->id.'/view'.'|'.$user->fullName().'>.'
|
||||
'value' => 'License: <'.config('app.url').'/admin/licenses/'.$license->id.'/view'.'|'.$license->name.'> checked in by <'.config('app.url').'/admin/users/'.$user->id.'/view'.'|'.$user->fullName().'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
'value' => e($logaction->note)
|
||||
'value' => e(Input::get('note'))
|
||||
],
|
||||
|
||||
]
|
||||
@@ -751,9 +717,6 @@ class LicensesController extends Controller
|
||||
}
|
||||
|
||||
|
||||
$log = $logaction->logaction('checkin from');
|
||||
|
||||
|
||||
|
||||
if ($backto=='user') {
|
||||
return redirect()->to("admin/users/".$return_to.'/view')->with('success', trans('admin/licenses/message.checkin.success'));
|
||||
@@ -824,7 +787,8 @@ class LicensesController extends Controller
|
||||
->with('supplier_list', $supplier_list)
|
||||
->with('license', $license)
|
||||
->with('maintained_list', $maintained_list)
|
||||
->with('company_list', $company_list);
|
||||
->with('company_list', $company_list)
|
||||
->with('manufacturer_list', Helper::manufacturerList());
|
||||
|
||||
}
|
||||
|
||||
@@ -857,7 +821,7 @@ class LicensesController extends Controller
|
||||
foreach (Input::file('licensefile') as $file) {
|
||||
|
||||
$rules = array(
|
||||
'licensefile' => 'required|mimes:png,gif,jpg,jpeg,doc,docx,pdf,txt,zip,rar|max:2000'
|
||||
'licensefile' => 'required|mimes:png,gif,jpg,jpeg,doc,docx,pdf,txt,zip,rar,rtf|max:2000'
|
||||
);
|
||||
$validator = Validator::make(array('licensefile'=> $file), $rules);
|
||||
|
||||
@@ -868,16 +832,8 @@ class LicensesController extends Controller
|
||||
$filename .= '-'.str_slug($file->getClientOriginalName()).'.'.$extension;
|
||||
$upload_success = $file->move($destinationPath, $filename);
|
||||
|
||||
//Log the deletion of seats to the log
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $license->id;
|
||||
$logaction->asset_type = 'software';
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = e(Input::get('notes'));
|
||||
$logaction->checkedout_to = null;
|
||||
$logaction->created_at = date("Y-m-d h:i:s");
|
||||
$logaction->filename = $filename;
|
||||
$log = $logaction->logaction('uploaded');
|
||||
//Log the upload to the log
|
||||
$license->logUpload($filename, e(Input::get('notes')));
|
||||
} else {
|
||||
return redirect()->back()->with('error', trans('admin/licenses/message.upload.invalidfiles'));
|
||||
}
|
||||
@@ -991,7 +947,7 @@ class LicensesController extends Controller
|
||||
*/
|
||||
public function getDatatable()
|
||||
{
|
||||
$licenses = License::with('company');
|
||||
$licenses = Company::scopeCompanyables(License::with('company'));
|
||||
|
||||
if (Input::has('search')) {
|
||||
$licenses = $licenses->TextSearch(Input::get('search'));
|
||||
@@ -1009,7 +965,27 @@ class LicensesController extends Controller
|
||||
$rows = array();
|
||||
|
||||
foreach ($licenses as $license) {
|
||||
$actions = '<span style="white-space: nowrap;"><a href="'.route('freecheckout/license', $license->id).'" class="btn btn-primary btn-sm" style="margin-right:5px;" '.(($license->remaincount() > 0) ? '' : 'disabled').'>'.trans('general.checkout').'</a> <a href="'.route('clone/license', $license->id).'" class="btn btn-info btn-sm" style="margin-right:5px;" title="Clone asset"><i class="fa fa-files-o"></i></a><a href="'.route('update/license', $license->id).'" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a><a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/license', $license->id).'" data-content="'.trans('admin/licenses/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($license->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></span>';
|
||||
$actions = '<span style="white-space: nowrap;">';
|
||||
|
||||
if (Gate::allows('licenses.checkout')) {
|
||||
$actions .= '<a href="' . route('freecheckout/license', $license->id)
|
||||
. '" class="btn btn-primary btn-sm' . (($license->remaincount() > 0) ? '' : ' disabled') . '" style="margin-right:5px;">' . trans('general.checkout') . '</a> ';
|
||||
}
|
||||
|
||||
if (Gate::allows('licenses.create')) {
|
||||
$actions .= '<a href="' . route('clone/license', $license->id)
|
||||
. '" class="btn btn-info btn-sm" style="margin-right:5px;" title="Clone license"><i class="fa fa-files-o"></i></a>';
|
||||
}
|
||||
if (Gate::allows('licenses.edit')) {
|
||||
$actions .= '<a href="' . route('update/license', $license->id)
|
||||
. '" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a>';
|
||||
}
|
||||
if (Gate::allows('licenses.delete')) {
|
||||
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'
|
||||
. route('delete/license', $license->id)
|
||||
. '" data-content="' . trans('admin/licenses/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($license->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
|
||||
}
|
||||
$actions .='</span>';
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $license->id,
|
||||
@@ -1018,15 +994,16 @@ class LicensesController extends Controller
|
||||
'totalSeats' => $license->totalSeatsByLicenseID(),
|
||||
'remaining' => $license->remaincount(),
|
||||
'license_name' => e($license->license_name),
|
||||
'license_email' => e($license->license_email),
|
||||
'license_email' => e($license->license_email),
|
||||
'purchase_date' => ($license->purchase_date) ? $license->purchase_date : '',
|
||||
'expiration_date' => ($license->expiration_date) ? $license->expiration_date : '',
|
||||
'purchase_cost' => ($license->purchase_cost) ? number_format($license->purchase_cost, 2) : '',
|
||||
'purchase_cost' => Helper::formatCurrencyOutput($license->purchase_cost),
|
||||
'purchase_order' => ($license->purchase_order) ? e($license->purchase_order) : '',
|
||||
'order_number' => ($license->order_number) ? e($license->order_number) : '',
|
||||
'notes' => ($license->notes) ? e($license->notes) : '',
|
||||
'actions' => $actions,
|
||||
'companyName' => is_null($license->company) ? '' : e($license->company->name)
|
||||
'companyName' => is_null($license->company) ? '' : e($license->company->name),
|
||||
'manufacturer' => $license->manufacturer ? (string) link_to('/admin/settings/manufacturers/'.$license->manufacturer_id.'/view', $license->manufacturer->name) : ''
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -370,7 +370,7 @@ class LocationsController extends Controller
|
||||
public function getDataViewUsers($locationID)
|
||||
{
|
||||
$location = Location::find($locationID);
|
||||
$users = User::where('location_id','=',$location->id);
|
||||
$users = User::where('location_id', '=', $location->id);
|
||||
|
||||
if (Input::has('search')) {
|
||||
$users = $users->TextSearch(e(Input::get('search')));
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\Manufacturer;
|
||||
use App\Models\Setting;
|
||||
use Auth;
|
||||
use Gate;
|
||||
use Input;
|
||||
use Lang;
|
||||
use App\Models\Manufacturer;
|
||||
use Redirect;
|
||||
use App\Models\Setting;
|
||||
use Str;
|
||||
use View;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Manufacturers for
|
||||
@@ -254,10 +255,27 @@ class ManufacturersController extends Controller
|
||||
* @since [v1.0]
|
||||
* @return String JSON
|
||||
*/
|
||||
public function getDataView($manufacturerId)
|
||||
public function getDataView($manufacturerId, $itemtype = null)
|
||||
{
|
||||
|
||||
$manufacturer = Manufacturer::with('assets.company')->find($manufacturerId);
|
||||
|
||||
switch ($itemtype) {
|
||||
case "assets":
|
||||
return $this->getDataAssetsView($manufacturer);
|
||||
case "licenses":
|
||||
return $this->getDataLicensesView($manufacturer);
|
||||
case "accessories":
|
||||
return $this->getDataAccessoriesView($manufacturer);
|
||||
case "consumables":
|
||||
return $this->getDataConsumablesView($manufacturer);
|
||||
}
|
||||
|
||||
throw new Exception("We shouldn't be here");
|
||||
|
||||
}
|
||||
|
||||
protected function getDataAssetsView(Manufacturer $manufacturer)
|
||||
{
|
||||
$manufacturer_assets = $manufacturer->assets;
|
||||
|
||||
if (Input::has('search')) {
|
||||
@@ -293,35 +311,213 @@ class ManufacturersController extends Controller
|
||||
$actions = '<a href="'.route('restore/hardware', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a>';
|
||||
}
|
||||
|
||||
if ($asset->assetstatus) {
|
||||
if ($asset->assetstatus->deployable != 0) {
|
||||
if (($asset->assigned_to !='') && ($asset->assigned_to > 0)) {
|
||||
$inout = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.trans('general.checkin').'</a>';
|
||||
} else {
|
||||
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.trans('general.checkout').'</a>';
|
||||
}
|
||||
if ($asset->availableForCheckout()) {
|
||||
if (Gate::allows('assets.checkout')) {
|
||||
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.trans('general.checkout').'</a>';
|
||||
}
|
||||
} else {
|
||||
if (Gate::allows('assets.checkin')) {
|
||||
$inout = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.trans('general.checkin').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$row = array(
|
||||
'id' => $asset->id,
|
||||
'name' => (string)link_to('/hardware/'.$asset->id.'/view', e($asset->showAssetName())),
|
||||
'model' => e($asset->model->name),
|
||||
'asset_tag' => e($asset->asset_tag),
|
||||
'serial' => e($asset->serial),
|
||||
'assigned_to' => ($asset->assigneduser) ? (string)link_to('/admin/users/'.$asset->assigneduser->id.'/view', e($asset->assigneduser->fullName())): '',
|
||||
'actions' => $actions,
|
||||
'companyName' => e(Company::getName($asset)),
|
||||
);
|
||||
$rows[] = array(
|
||||
'id' => $asset->id,
|
||||
'name' => (string)link_to('/hardware/'.$asset->id.'/view', e($asset->showAssetName())),
|
||||
'model' => e($asset->model->name),
|
||||
'asset_tag' => e($asset->asset_tag),
|
||||
'serial' => e($asset->serial),
|
||||
'assigned_to' => ($asset->assigneduser) ? (string)link_to('/admin/users/'.$asset->assigneduser->id.'/view', e($asset->assigneduser->fullName())): '',
|
||||
'actions' => $actions,
|
||||
'companyName' => e(Company::getName($asset)),
|
||||
);
|
||||
|
||||
if (isset($inout)) {
|
||||
$row['change'] = $inout;
|
||||
if (isset($inout)) {
|
||||
$row['change'] = $inout;
|
||||
}
|
||||
}
|
||||
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
|
||||
$data = array('total' => $count, 'rows' => $rows);
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getDataLicensesView(Manufacturer $manufacturer)
|
||||
{
|
||||
$licenses = $manufacturer->licenses;
|
||||
|
||||
if (Input::has('search')) {
|
||||
$licenses = $licenses->TextSearch(Input::get('search'));
|
||||
}
|
||||
|
||||
$licenseCount = $licenses->count();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($licenses as $license) {
|
||||
$actions = '<span style="white-space: nowrap;">';
|
||||
|
||||
if (Gate::allows('licenses.checkout')) {
|
||||
$actions .= '<a href="' . route('freecheckout/license', $license->id)
|
||||
. '" class="btn btn-primary btn-sm' . (($license->remaincount() > 0) ? '' : ' disabled') . '" style="margin-right:5px;">' . trans('general.checkout') . '</a> ';
|
||||
}
|
||||
|
||||
if (Gate::allows('licenses.create')) {
|
||||
$actions .= '<a href="' . route('clone/license', $license->id)
|
||||
. '" class="btn btn-info btn-sm" style="margin-right:5px;" title="Clone asset"><i class="fa fa-files-o"></i></a>';
|
||||
}
|
||||
if (Gate::allows('licenses.edit')) {
|
||||
$actions .= '<a href="' . route('update/license', $license->id)
|
||||
. '" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a>';
|
||||
}
|
||||
if (Gate::allows('licenses.delete')) {
|
||||
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'
|
||||
. route('delete/license', $license->id)
|
||||
. '" data-content="' . trans('admin/licenses/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($license->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
|
||||
}
|
||||
$actions .='</span>';
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $license->id,
|
||||
'name' => (string) link_to('/admin/licenses/'.$license->id.'/view', $license->name),
|
||||
'serial' => (string) link_to('/admin/licenses/'.$license->id.'/view', mb_strimwidth($license->serial, 0, 50, "...")),
|
||||
'totalSeats' => $license->totalSeatsByLicenseID(),
|
||||
'remaining' => $license->remaincount(),
|
||||
'license_name' => e($license->license_name),
|
||||
'license_email' => e($license->license_email),
|
||||
'purchase_date' => ($license->purchase_date) ? $license->purchase_date : '',
|
||||
'expiration_date' => ($license->expiration_date) ? $license->expiration_date : '',
|
||||
'purchase_cost' => ($license->purchase_cost) ? number_format($license->purchase_cost, 2) : '',
|
||||
'purchase_order' => ($license->purchase_order) ? e($license->purchase_order) : '',
|
||||
'order_number' => ($license->order_number) ? e($license->order_number) : '',
|
||||
'notes' => ($license->notes) ? e($license->notes) : '',
|
||||
'actions' => $actions,
|
||||
'companyName' => is_null($license->company) ? '' : e($license->company->name),
|
||||
'manufacturer' => $license->manufacturer ? (string) link_to('/admin/settings/manufacturers/'.$license->manufacturer_id.'/view', $license->manufacturer->name) : ''
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $licenseCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getDataAccessoriesView(Manufacturer $manufacturer)
|
||||
{
|
||||
$accessories = $manufacturer->accessories;
|
||||
|
||||
if (Input::has('search')) {
|
||||
$accessories = $accessories->TextSearch(e(Input::get('search')));
|
||||
}
|
||||
|
||||
if (Input::has('limit')) {
|
||||
$limit = e(Input::get('limit'));
|
||||
} else {
|
||||
$limit = 50;
|
||||
}
|
||||
|
||||
$accessCount = $accessories->count();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($accessories as $accessory) {
|
||||
|
||||
$actions = '<nobr>';
|
||||
if (Gate::allows('accessories.checkout')) {
|
||||
$actions .= '<a href="' . route('checkout/accessory',
|
||||
$accessory->id) . '" style="margin-right:5px;" class="btn btn-info btn-sm" ' . (($accessory->numRemaining() > 0) ? '' : ' disabled') . '>' . trans('general.checkout') . '</a>';
|
||||
}
|
||||
if (Gate::allows('accessories.edit')) {
|
||||
$actions .= '<a href="' . route('update/accessory',
|
||||
$accessory->id) . '" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a>';
|
||||
}
|
||||
if (Gate::allows('accessories.delete')) {
|
||||
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/accessory',
|
||||
$accessory->id) . '" data-content="' . trans('admin/accessories/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($accessory->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
|
||||
}
|
||||
$actions .= '</nobr>';
|
||||
$company = $accessory->company;
|
||||
|
||||
$rows[] = array(
|
||||
'name' => '<a href="'.url('admin/accessories/'.$accessory->id).'/view">'. $accessory->name.'</a>',
|
||||
'category' => ($accessory->category) ? (string)link_to('admin/settings/categories/'.$accessory->category->id.'/view', $accessory->category->name) : '',
|
||||
'qty' => e($accessory->qty),
|
||||
'order_number' => e($accessory->order_number),
|
||||
'min_amt' => e($accessory->min_amt),
|
||||
'location' => ($accessory->location) ? e($accessory->location->name): '',
|
||||
'purchase_date' => e($accessory->purchase_date),
|
||||
'purchase_cost' => number_format($accessory->purchase_cost, 2),
|
||||
'numRemaining' => $accessory->numRemaining(),
|
||||
'actions' => $actions,
|
||||
'companyName' => is_null($company) ? '' : e($company->name),
|
||||
'manufacturer' => $accessory->manufacturer ? (string) link_to('/admin/settings/manufacturers/'.$accessory->manufacturer_id.'/view', $accessory->manufacturer->name) : ''
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total'=>$accessCount, 'rows'=>$rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getDataConsumablesView($manufacturer)
|
||||
{
|
||||
$consumables = $manufacturer->consumables;
|
||||
|
||||
if (Input::has('search')) {
|
||||
$consumables = $consumables->TextSearch(e(Input::get('search')));
|
||||
}
|
||||
|
||||
if (Input::has('limit')) {
|
||||
$limit = e(Input::get('limit'));
|
||||
} else {
|
||||
$limit = 50;
|
||||
}
|
||||
|
||||
$consumCount = $consumables->count();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($consumables as $consumable) {
|
||||
$actions = '<nobr>';
|
||||
if (Gate::allows('consumables.checkout')) {
|
||||
$actions .= '<a href="' . route('checkout/consumable',
|
||||
$consumable->id) . '" style="margin-right:5px;" class="btn btn-info btn-sm" ' . (($consumable->numRemaining() > 0) ? '' : ' disabled') . '>' . trans('general.checkout') . '</a>';
|
||||
}
|
||||
|
||||
if (Gate::allows('consumables.edit')) {
|
||||
$actions .= '<a href="' . route('update/consumable',
|
||||
$consumable->id) . '" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a>';
|
||||
}
|
||||
if (Gate::allows('consumables.delete')) {
|
||||
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/consumable',
|
||||
$consumable->id) . '" data-content="' . trans('admin/consumables/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($consumable->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
|
||||
}
|
||||
|
||||
$actions .='</nobr>';
|
||||
|
||||
$company = $consumable->company;
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $consumable->id,
|
||||
'name' => (string)link_to('admin/consumables/'.$consumable->id.'/view', e($consumable->name)),
|
||||
'location' => ($consumable->location) ? e($consumable->location->name) : '',
|
||||
'min_amt' => e($consumable->min_amt),
|
||||
'qty' => e($consumable->qty),
|
||||
'manufacturer' => ($consumable->manufacturer) ? (string) link_to('/admin/settings/manufacturers/'.$consumable->manufacturer_id.'/view', $consumable->manufacturer->name): '',
|
||||
'model_no' => e($consumable->model_no),
|
||||
'item_no' => e($consumable->item_no),
|
||||
'category' => ($consumable->category) ? (string) link_to('/admin/settings/categories/'.$consumable->category_id.'/view', $consumable->category->name) : 'Missing category',
|
||||
'order_number' => e($consumable->order_number),
|
||||
'purchase_date' => e($consumable->purchase_date),
|
||||
'purchase_cost' => ($consumable->purchase_cost!='') ? number_format($consumable->purchase_cost, 2): '' ,
|
||||
'numRemaining' => $consumable->numRemaining(),
|
||||
'actions' => $actions,
|
||||
'companyName' => is_null($company) ? '' : e($company->name),
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $consumCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class ProfileController extends Controller
|
||||
|
||||
if (Input::file('avatar')) {
|
||||
$image = Input::file('avatar');
|
||||
$file_name = $user->first_name."-".$user->last_name.".".$image->getClientOriginalExtension();
|
||||
$file_name = str_slug($user->first_name."-".$user->last_name).".".$image->getClientOriginalExtension();
|
||||
$path = public_path('uploads/avatars/'.$file_name);
|
||||
Image::make($image->getRealPath())->resize(84, 84)->save($path);
|
||||
$user->avatar = $file_name;
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetMaintenance;
|
||||
use Carbon\Carbon;
|
||||
use Category;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Company;
|
||||
use App\Models\CustomField;
|
||||
use App\Models\License;
|
||||
use App\Models\Location;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Input;
|
||||
use League\Csv\Reader;
|
||||
use App\Models\License;
|
||||
use App\Models\Location;
|
||||
use App\Models\AssetModel;
|
||||
use Redirect;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Reports for
|
||||
@@ -31,7 +33,7 @@ class ReportsController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns a view that displaysthe accessories report.
|
||||
* Returns a view that displays the accessories report.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
@@ -87,7 +89,7 @@ class ReportsController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Display asset report.
|
||||
* Display asset report view.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
@@ -96,23 +98,11 @@ class ReportsController extends Controller
|
||||
public function getAssetsReport()
|
||||
{
|
||||
$settings = \App\Models\Setting::first();
|
||||
// Grab all the assets
|
||||
$assets = Asset::with(
|
||||
'model',
|
||||
'assigneduser.userLoc',
|
||||
'assetstatus',
|
||||
'defaultLoc',
|
||||
'assetlog',
|
||||
'supplier',
|
||||
'model.manufacturer',
|
||||
'company'
|
||||
)
|
||||
->orderBy('created_at', 'DESC')
|
||||
->get();
|
||||
|
||||
return View::make('reports/asset', compact('assets'))->with('settings',$settings);
|
||||
return View::make('reports/asset', compact('assets'))->with('settings', $settings);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Exports the assets to CSV
|
||||
*
|
||||
@@ -122,103 +112,76 @@ class ReportsController extends Controller
|
||||
*/
|
||||
public function exportAssetReport()
|
||||
{
|
||||
// Grab all the assets
|
||||
$assets = Asset::orderBy('created_at', 'DESC')->get();
|
||||
|
||||
$rows = [ ];
|
||||
\Debugbar::disable();
|
||||
|
||||
// Create the header row
|
||||
$header = [
|
||||
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('admin/hardware/form.supplier'),
|
||||
trans('admin/hardware/table.checkoutto'),
|
||||
trans('admin/hardware/table.location'),
|
||||
trans('general.notes'),
|
||||
];
|
||||
$header = array_map('trim', $header);
|
||||
$rows[] = implode($header, ',');
|
||||
$customfields = CustomField::get();
|
||||
|
||||
// Create a row per asset
|
||||
foreach ($assets as $asset) {
|
||||
$row = [ ];
|
||||
$row[] = e($asset->asset_tag);
|
||||
if ($asset->model->manufacturer) {
|
||||
$row[] = e($asset->model->manufacturer->name);
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
$row[] = '"' . e($asset->model->name) . '"';
|
||||
$row[] = '"' . e($asset->model->modelno) . '"';
|
||||
$row[] = e($asset->name);
|
||||
$row[] = e($asset->serial);
|
||||
if ($asset->assetstatus) {
|
||||
$row[] = e($asset->assetstatus->name);
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
$row[] = $asset->purchase_date;
|
||||
$row[] = '"' . number_format($asset->purchase_cost, 2) . '"';
|
||||
if ($asset->order_number) {
|
||||
$row[] = e($asset->order_number);
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
if ($asset->supplier_id) {
|
||||
$row[] = e($asset->supplier->name);
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
$response = new StreamedResponse(function() use ($customfields) {
|
||||
// Open output stream
|
||||
$handle = fopen('php://output', 'w');
|
||||
|
||||
if ($asset->assigned_to > 0) {
|
||||
$user = User::find($asset->assigned_to);
|
||||
$row[] = e($user->fullName());
|
||||
} else {
|
||||
$row[] = ''; // Empty string if unassigned
|
||||
}
|
||||
|
||||
if (( $asset->assigned_to > 0 ) && ( $asset->assigneduser->location_id > 0 )) {
|
||||
$location = Location::find($asset->assigneduser->location_id);
|
||||
if ($location) {
|
||||
$row[] = e($location->name);
|
||||
} else {
|
||||
$row[] = '';
|
||||
Asset::with('assigneduser', 'assetloc','defaultLoc','assigneduser.userloc','model','supplier','assetstatus','model.manufacturer')->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('admin/hardware/form.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;
|
||||
}
|
||||
} elseif ($asset->rtd_location_id) {
|
||||
$location = Location::find($asset->rtd_location_id);
|
||||
if ($location->name) {
|
||||
$row[] = e($location->name);
|
||||
} else {
|
||||
$row[] = '';
|
||||
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) ? $asset->model->name : '',
|
||||
($asset->model->modelno) ? $asset->model->modelno : '',
|
||||
($asset->name) ? $asset->name : '',
|
||||
($asset->serial) ? $asset->serial : '',
|
||||
($asset->assetstatus) ? e($asset->assetstatus->name) : '',
|
||||
($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->assigneduser) ? e($asset->assigneduser->fullName()) : '',
|
||||
($asset->last_checkout!='') ? e($asset->last_checkout) : '',
|
||||
($asset->assigneduser && $asset->assigneduser->userloc!='') ?
|
||||
e($asset->assigneduser->userloc->name) : ( ($asset->defaultLoc!='') ? e($asset->defaultLoc->name) : ''),
|
||||
($asset->notes) ? e($asset->notes) : '',
|
||||
];
|
||||
foreach($customfields as $field) {
|
||||
$values[]=$asset->{$field->db_column_name()};
|
||||
}
|
||||
fputcsv($handle, $values);
|
||||
}
|
||||
} else {
|
||||
$row[] = ''; // Empty string if location is not set
|
||||
}
|
||||
});
|
||||
|
||||
if ($asset->notes) {
|
||||
$row[] = '"' . e($asset->notes) . '"';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
$rows[] = implode($row, ',');
|
||||
}
|
||||
|
||||
// spit out a csv
|
||||
$csv = implode($rows, "\n");
|
||||
$response = Response::make($csv, 200);
|
||||
$response->header('Content-Type', 'text/csv');
|
||||
$response->header('Content-disposition', 'attachment;filename=report.csv');
|
||||
// Close the output stream
|
||||
fclose($handle);
|
||||
}, 200, [
|
||||
'Content-Type' => 'text/csv',
|
||||
'Content-Disposition' => 'attachment; filename="assets-'.date('Y-m-d-his').'.csv"',
|
||||
]);
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,9 +271,9 @@ class ReportsController extends Controller
|
||||
}
|
||||
|
||||
$row[] = $asset->purchase_date;
|
||||
$row[] = $currency . number_format($asset->purchase_cost, 2);
|
||||
$row[] = $currency . number_format($asset->getDepreciatedValue(), 2);
|
||||
$row[] = $currency . number_format(( $asset->purchase_cost - $asset->getDepreciatedValue() ), 2);
|
||||
$row[] = $currency . Helper::formatCurrencyOutput($asset->purchase_cost);
|
||||
$row[] = $currency . Helper::formatCurrencyOutput($asset->getDepreciatedValue());
|
||||
$row[] = $currency . Helper::formatCurrencyOutput(( $asset->purchase_cost - $asset->getDepreciatedValue() ));
|
||||
$csv->insertOne($row);
|
||||
}
|
||||
|
||||
@@ -329,11 +292,7 @@ class ReportsController extends Controller
|
||||
public function getActivityReport()
|
||||
{
|
||||
$log_actions = Actionlog::orderBy('created_at', 'DESC')
|
||||
->with('adminlog')
|
||||
->with('accessorylog')
|
||||
->with('assetlog')
|
||||
->with('licenselog')
|
||||
->with('userlog')
|
||||
->with('item')
|
||||
->orderBy('created_at', 'DESC')
|
||||
->get();
|
||||
|
||||
@@ -341,16 +300,114 @@ class ReportsController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays license report
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
* Returns Activity Report JSON.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getActivityReportDataTable()
|
||||
{
|
||||
$activitylogs = Company::scopeCompanyables(Actionlog::with('item', 'user', 'target'))->orderBy('created_at', 'DESC');
|
||||
|
||||
if (Input::has('search')) {
|
||||
$activity = $activity->TextSearch(e(Input::get('search')));
|
||||
}
|
||||
|
||||
if (Input::has('offset')) {
|
||||
$offset = e(Input::get('offset'));
|
||||
} else {
|
||||
$offset = 0;
|
||||
}
|
||||
|
||||
if (Input::has('limit')) {
|
||||
$limit = e(Input::get('limit'));
|
||||
} else {
|
||||
$limit = 50;
|
||||
}
|
||||
|
||||
|
||||
$allowed_columns = ['created_at'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? e(Input::get('sort')) : 'created_at';
|
||||
|
||||
|
||||
$activityCount = $activitylogs->count();
|
||||
// dd("Offset:" . $offset . " Limit " . $limit);
|
||||
$activitylogs = $activitylogs->offset($offset)->limit($limit)->get();
|
||||
|
||||
$rows = array();
|
||||
foreach ($activitylogs as $activity) {
|
||||
|
||||
if ($activity->itemType() == "asset") {
|
||||
$activity_icons = '<i class="fa fa-barcode"></i>';
|
||||
} elseif ($activity->itemType() == "accessory") {
|
||||
$activity_icons = '<i class="fa fa-keyboard-o"></i>';
|
||||
} elseif ($activity->itemType()=="consumable") {
|
||||
$activity_icons = '<i class="fa fa-tint"></i>';
|
||||
} elseif ($activity->itemType()=="license"){
|
||||
$activity_icons = '<i class="fa fa-floppy-o"></i>';
|
||||
} elseif ($activity->itemType()=="component") {
|
||||
$activity_icons = '<i class="fa fa-hdd-o"></i>';
|
||||
} else {
|
||||
$activity_icons = '<i class="fa fa-paperclip"></i>';
|
||||
}
|
||||
|
||||
if (($activity->item) && ($activity->itemType()=="asset")) {
|
||||
$activity_item = '<a href="'.route('view/hardware', $activity->item_id).'">'.e($activity->item->asset_tag).' - '. e($activity->item->showAssetName()).'</a>';
|
||||
$item_type = 'asset';
|
||||
} elseif ($activity->item()) {
|
||||
$activity_item = '<a href="'.route('view/'. $activity->itemType(), $activity->item_id).'">'.e($activity->item->name).'</a>';
|
||||
$item_type = $activity->itemType();
|
||||
} else {
|
||||
$activity_item = "unkonwn";
|
||||
$item_type = "null";
|
||||
}
|
||||
|
||||
|
||||
if (($activity->user) && ($activity->action_type=="uploaded") && ($activity->itemType()=="user")) {
|
||||
$activity_target = '<a href="'.route('view/user', $activity->target_id).'">'.$activity->user->fullName().'</a>';
|
||||
} elseif (($activity->item) && ($activity->target_type === "App\Models\Asset")) {
|
||||
$activity_target = '<a href="'.route('view/hardware', $activity->target_id).'">'.$activity->target->showAssetName().'</a>';
|
||||
} elseif ( $activity->target_type === "App\Models\User") {
|
||||
$activity_target = '<a href="'.route('view/user', $activity->target_id).'">'.$activity->target->fullName().'</a>';
|
||||
} elseif ($activity->action_type=='requested') {
|
||||
$activity_target = '<a href="'.route('view/user', $activity->user_id).'">'.$activity->user->fullName().'</a>';
|
||||
} else {
|
||||
$activity_target = $activity->target->id;
|
||||
}
|
||||
|
||||
|
||||
$rows[] = array(
|
||||
'icon' => $activity_icons,
|
||||
'created_at' => date("M d, Y g:iA", strtotime($activity->created_at)),
|
||||
'action_type' => strtolower(trans('general.'.str_replace(' ','_',$activity->action_type))),
|
||||
'admin' => $activity->user ? (string) link_to('/admin/users/'.$activity->user_id.'/view', $activity->user->fullName()) : '',
|
||||
'target' => $activity_target,
|
||||
'item' => $activity_item,
|
||||
'item_type' => $item_type,
|
||||
'note' => e($activity->note),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total'=>$activityCount, 'rows'=>$rows);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays license report
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getLicenseReport()
|
||||
{
|
||||
|
||||
$licenses = License::orderBy('created_at', 'DESC')
|
||||
$licenses = License::with('depreciation')->orderBy('created_at', 'DESC')
|
||||
->with('company')
|
||||
->get();
|
||||
|
||||
@@ -377,6 +434,7 @@ class ReportsController extends Controller
|
||||
trans('admin/licenses/form.remaining_seats'),
|
||||
trans('admin/licenses/form.expiration'),
|
||||
trans('admin/licenses/form.date'),
|
||||
trans('admin/licenses/form.depreciation'),
|
||||
trans('admin/licenses/form.cost')
|
||||
];
|
||||
|
||||
@@ -392,7 +450,8 @@ class ReportsController extends Controller
|
||||
$row[] = $license->remaincount();
|
||||
$row[] = $license->expiration_date;
|
||||
$row[] = $license->purchase_date;
|
||||
$row[] = '"' . number_format($license->purchase_cost, 2) . '"';
|
||||
$row[] = ($license->depreciation!='') ? '' : e($license->depreciation->name);
|
||||
$row[] = '"' . Helper::formatCurrencyOutput($license->purchase_cost) . '"';
|
||||
|
||||
$rows[] = implode($row, ',');
|
||||
}
|
||||
@@ -415,25 +474,30 @@ class ReportsController extends Controller
|
||||
*/
|
||||
public function getCustomReport()
|
||||
{
|
||||
|
||||
return View::make('reports/custom');
|
||||
$customfields = CustomField::get();
|
||||
return View::make('reports/custom')->with('customfields', $customfields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the custom report to CSV
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ReportsController::getCustomReport() method that generates form view
|
||||
* @since [v1.0]
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
* Exports the custom report to CSV
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ReportsController::getCustomReport() method that generates form view
|
||||
* @since [v1.0]
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function postCustom()
|
||||
{
|
||||
$assets = Asset::orderBy('created_at', 'DESC')->get();
|
||||
$assets = Asset::orderBy('created_at', 'DESC')->with('company','assigneduser', 'assetloc','defaultLoc','assigneduser.userloc','model','supplier','assetstatus','model.manufacturer')->get();
|
||||
$customfields = CustomField::get();
|
||||
|
||||
$rows = [ ];
|
||||
$header = [ ];
|
||||
|
||||
if (e(Input::get('company')) == '1') {
|
||||
$header[] = 'Company Name';
|
||||
}
|
||||
|
||||
if (e(Input::get('asset_name')) == '1') {
|
||||
$header[] = 'Asset Name';
|
||||
}
|
||||
@@ -471,6 +535,9 @@ class ReportsController extends Controller
|
||||
if (e(Input::get('assigned_to')) == '1') {
|
||||
$header[] = 'Assigned To';
|
||||
}
|
||||
if (e(Input::get('username')) == '1') {
|
||||
$header[] = 'Username';
|
||||
}
|
||||
if (e(Input::get('status')) == '1') {
|
||||
$header[] = 'Status';
|
||||
}
|
||||
@@ -484,11 +551,23 @@ class ReportsController extends Controller
|
||||
$header[] = 'Diff';
|
||||
}
|
||||
|
||||
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.'"';
|
||||
}
|
||||
|
||||
if (e(Input::get('asset_name')) == '1') {
|
||||
$row[] = '"' .e($asset->name) . '"';
|
||||
}
|
||||
@@ -517,7 +596,7 @@ class ReportsController extends Controller
|
||||
$row[] = e($asset->purchase_date);
|
||||
}
|
||||
if (e(Input::get('purchase_cost')) == '1' && ( e(Input::get('depreciation')) != '1' )) {
|
||||
$row[] = '"' . number_format($asset->purchase_cost, 2) . '"';
|
||||
$row[] = '"' . Helper::formatCurrencyOutput($asset->purchase_cost) . '"';
|
||||
}
|
||||
if (e(Input::get('order')) == '1') {
|
||||
if ($asset->order_number) {
|
||||
@@ -562,6 +641,16 @@ class ReportsController extends Controller
|
||||
$row[] = ''; // Empty string if unassigned
|
||||
}
|
||||
}
|
||||
|
||||
if (e(Input::get('username')) == '1') {
|
||||
if ($asset->assigned_to > 0) {
|
||||
$user = User::find($asset->assigned_to);
|
||||
$row[] = '"' .e($user->username). '"';
|
||||
} else {
|
||||
$row[] = ''; // Empty string if unassigned
|
||||
}
|
||||
}
|
||||
|
||||
if (e(Input::get('status')) == '1') {
|
||||
if (( $asset->status_id == '0' ) && ( $asset->assigned_to == '0' )) {
|
||||
$row[] = trans('general.ready_to_deploy');
|
||||
@@ -584,10 +673,19 @@ class ReportsController extends Controller
|
||||
}
|
||||
if (e(Input::get('depreciation')) == '1') {
|
||||
$depreciation = $asset->getDepreciatedValue();
|
||||
$row[] = '"' . number_format($asset->purchase_cost, 2) . '"';
|
||||
$row[] = '"' . number_format($depreciation, 2) . '"';
|
||||
$row[] = '"' . number_format($asset->purchase_cost - $depreciation, 2) . '"';
|
||||
$row[] = '"' . Helper::formatCurrencyOutput($asset->purchase_cost) . '"';
|
||||
$row[] = '"' . Helper::formatCurrencyOutput($depreciation) . '"';
|
||||
$row[] = '"' . Helper::formatCurrencyOutput($asset->purchase_cost) . '"';
|
||||
}
|
||||
|
||||
foreach ($customfields as $customfield) {
|
||||
$column_name = $customfield->db_column_name();
|
||||
if (e(Input::get($customfield->db_column_name())) == '1') {
|
||||
$row[] = $asset->$column_name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rows[] = implode($row, ',');
|
||||
}
|
||||
|
||||
@@ -596,14 +694,15 @@ class ReportsController extends Controller
|
||||
$csv = implode($rows, "\n");
|
||||
$response = Response::make($csv, 200);
|
||||
$response->header('Content-Type', 'text/csv');
|
||||
$response->header('Content-disposition', 'attachment;filename=report.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'));
|
||||
->with('error', trans('admin/reports/message.error'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getImprovementsReport
|
||||
@@ -668,7 +767,7 @@ class ReportsController extends Controller
|
||||
$improvementTime = intval($assetMaintenance->asset_maintenance_time);
|
||||
}
|
||||
$row[] = $improvementTime;
|
||||
$row[] = trans('general.currency') . number_format($assetMaintenance->cost, 2);
|
||||
$row[] = trans('general.currency') . Helper::formatCurrencyOutput($assetMaintenance->cost);
|
||||
$rows[] = implode($row, ',');
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
use Input;
|
||||
use Lang;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Ldap;
|
||||
use Redirect;
|
||||
use DB;
|
||||
use Str;
|
||||
@@ -16,7 +17,6 @@ use Crypt;
|
||||
use Mail;
|
||||
use App\Models\User;
|
||||
use App\Http\Requests\SetupUserRequest;
|
||||
use App\Http\Requests\SettingRequest;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Settings for
|
||||
@@ -50,31 +50,20 @@ class SettingsController extends Controller
|
||||
$start_settings['db_error'] = $e->getMessage();
|
||||
}
|
||||
|
||||
$protocol = array_key_exists('HTTPS',$_SERVER) && ( $_SERVER['HTTPS'] == "on") ? 'https://' : 'http://';
|
||||
$protocol = array_key_exists('HTTPS', $_SERVER) && ( $_SERVER['HTTPS'] == "on") ? 'https://' : 'http://';
|
||||
|
||||
|
||||
$pageURL = $protocol;
|
||||
if ($_SERVER["SERVER_PORT"] != "80") {
|
||||
$main_page = $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"];
|
||||
$pageURL .= $main_page.$_SERVER["REQUEST_URI"];
|
||||
} else {
|
||||
$main_page = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
|
||||
$pageURL .= $main_page;
|
||||
$host = $_SERVER['SERVER_NAME'];
|
||||
if (($protocol === 'http://' && $_SERVER['SERVER_PORT'] != '80') || ($protocol === 'https://' && $_SERVER['SERVER_PORT'] != '443')) {
|
||||
$host .= ':' . $_SERVER['SERVER_PORT'];
|
||||
}
|
||||
$pageURL = $protocol . $host . $_SERVER['REQUEST_URI'];
|
||||
|
||||
$start_settings['env_location'] = $pageURL.'../.env';
|
||||
$start_settings['url_valid'] = (config('app.url').'/setup' === $pageURL);
|
||||
|
||||
$start_settings['url_config'] = config('app.url');
|
||||
$start_settings['real_url'] = $pageURL;
|
||||
|
||||
if (config('app.url').'/setup'!=$pageURL) {
|
||||
$start_settings['url_valid']= false;
|
||||
} else {
|
||||
$start_settings['url_valid']= true;
|
||||
}
|
||||
|
||||
$start_settings['url_config']= config('app.url');
|
||||
$start_settings['real_url']= $pageURL;
|
||||
|
||||
$exposed_env = @file_get_contents($main_page.'/.env');
|
||||
$exposed_env = @file_get_contents($protocol . $host.'/.env');
|
||||
|
||||
if ($exposed_env) {
|
||||
$start_settings['env_exposed'] = true;
|
||||
@@ -98,10 +87,17 @@ class SettingsController extends Controller
|
||||
|
||||
}
|
||||
|
||||
$owner = posix_getpwuid(fileowner($_SERVER["SCRIPT_FILENAME"]));
|
||||
$start_settings['owner'] = $owner['name'];
|
||||
if (function_exists('posix_getpwuid')) { // Probably Linux
|
||||
$owner = posix_getpwuid(fileowner($_SERVER["SCRIPT_FILENAME"]));
|
||||
$start_settings['owner'] = $owner['name'];
|
||||
} else { // Windows
|
||||
// TODO: Is there a way of knowing if a windows user has elevated permissions
|
||||
// This just gets the user name, which likely isn't 'root'
|
||||
// $start_settings['owner'] = getenv('USERNAME');
|
||||
$start_settings['owner'] = '';
|
||||
}
|
||||
|
||||
if (($start_settings['owner']=='root') || ($start_settings['owner']=='0') || ($start_settings['owner']=='root')) {
|
||||
if (($start_settings['owner']==='root') || ($start_settings['owner']==='0')) {
|
||||
$start_settings['owner_is_admin'] = true;
|
||||
} else {
|
||||
$start_settings['owner_is_admin'] = false;
|
||||
@@ -140,7 +136,8 @@ class SettingsController extends Controller
|
||||
try {
|
||||
Mail::send('emails.test', [], function ($m) {
|
||||
$m->to(config('mail.from.address'), config('mail.from.name'));
|
||||
$m->subject('Test Email from Snipe-IT');
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.test_email'));
|
||||
});
|
||||
return 'success';
|
||||
} catch (Exception $e) {
|
||||
@@ -176,10 +173,14 @@ class SettingsController extends Controller
|
||||
$settings->alert_email = e(Input::get('email'));
|
||||
$settings->alerts_enabled = 1;
|
||||
$settings->brand = 1;
|
||||
$settings->locale = 'en';
|
||||
$settings->default_currency = 'USD';
|
||||
$settings->user_id = 1;
|
||||
$settings->email_domain = e(Input::get('email_domain'));
|
||||
$settings->email_format = e(Input::get('email_format'));
|
||||
|
||||
if ((!$user->isValid('initial')) && (!$settings->isValid('initial'))) {
|
||||
|
||||
if ((!$user->isValid()) || (!$settings->isValid())) {
|
||||
return redirect()->back()->withInput()->withErrors($user->getErrors())->withErrors($settings->getErrors());
|
||||
} else {
|
||||
$user->save();
|
||||
@@ -188,10 +189,12 @@ class SettingsController extends Controller
|
||||
if (Input::get('email_creds')=='1') {
|
||||
Mail::send(['text' => 'emails.firstadmin'], $data, function ($m) use ($data) {
|
||||
$m->to($data['email'], $data['first_name']);
|
||||
$m->subject('Your Snipe-IT credentials');
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.your_credentials'));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return redirect()->route('setup.done');
|
||||
}
|
||||
|
||||
@@ -288,11 +291,11 @@ class SettingsController extends Controller
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit(SettingRequest $request)
|
||||
public function postEdit()
|
||||
{
|
||||
|
||||
// Check if the asset exists
|
||||
if (is_null($setting = Setting::find(1))) {
|
||||
if (is_null($setting = Setting::first())) {
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error'));
|
||||
}
|
||||
@@ -312,7 +315,6 @@ class SettingsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$setting->id = '1';
|
||||
|
||||
if (config('app.lock_passwords')==false) {
|
||||
$setting->site_name = e(Input::get('site_name'));
|
||||
@@ -328,6 +330,7 @@ class SettingsController extends Controller
|
||||
|
||||
$setting->locale = e(Input::get('locale', 'en'));
|
||||
$setting->qr_code = e(Input::get('qr_code', '0'));
|
||||
$setting->full_multiple_companies_support = e(Input::get('full_multiple_companies_support', '0'));
|
||||
$setting->alt_barcode = e(Input::get('alt_barcode'));
|
||||
$setting->alt_barcode_enabled = e(Input::get('alt_barcode_enabled', '0'));
|
||||
$setting->barcode_type = e(Input::get('barcode_type'));
|
||||
@@ -336,8 +339,12 @@ class SettingsController extends Controller
|
||||
$setting->qr_text = e(Input::get('qr_text'));
|
||||
$setting->auto_increment_prefix = e(Input::get('auto_increment_prefix'));
|
||||
$setting->auto_increment_assets = e(Input::get('auto_increment_assets', '0'));
|
||||
$setting->zerofill_count = e(Input::get('zerofill_count'));
|
||||
$setting->alert_interval = e(Input::get('alert_interval'));
|
||||
$setting->alert_threshold = e(Input::get('alert_threshold'));
|
||||
$setting->email_domain = e(Input::get('email_domain'));
|
||||
$setting->email_format = e(Input::get('email_format'));
|
||||
$setting->username_format = e(Input::get('username_format'));
|
||||
|
||||
|
||||
$setting->labels_per_page = e(Input::get('labels_per_page'));
|
||||
@@ -398,6 +405,10 @@ class SettingsController extends Controller
|
||||
$setting->ldap_active_flag = e(Input::get('ldap_active_flag'));
|
||||
$setting->ldap_emp_num = e(Input::get('ldap_emp_num'));
|
||||
$setting->ldap_email = e(Input::get('ldap_email'));
|
||||
$setting->ad_domain = e(Input::get('ad_domain'));
|
||||
$setting->is_ad = e(Input::get('is_ad', '0'));
|
||||
$setting->ldap_tls = e(Input::get('ldap_tls', '0'));
|
||||
$setting->ldap_pw_sync = e(Input::get('ldap_pw_sync', '0'));
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($setting->save()) {
|
||||
@@ -414,6 +425,25 @@ class SettingsController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function getLdapTest() {
|
||||
|
||||
try {
|
||||
$connection = Ldap::connectToLdap();
|
||||
try {
|
||||
Ldap::bindAdminToLdap($connection);
|
||||
return response()->json(['message' => 'It worked!'], 200);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 500);
|
||||
}
|
||||
return response()->json(['message' => 'It worked!'], 200);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the listing of backups
|
||||
*
|
||||
@@ -443,7 +473,7 @@ class SettingsController extends Controller
|
||||
|
||||
}
|
||||
closedir($handle);
|
||||
$files = array_reverse($files);
|
||||
rsort($files);
|
||||
}
|
||||
|
||||
|
||||
@@ -538,7 +568,7 @@ class SettingsController extends Controller
|
||||
{
|
||||
if (!config('app.lock_passwords')) {
|
||||
if (Input::get('confirm_purge')=='DELETE') {
|
||||
Artisan::call('snipeit:purge',['--force'=>'true','--no-interaction'=>true]);
|
||||
Artisan::call('snipeit:purge', ['--force'=>'true','--no-interaction'=>true]);
|
||||
$output = Artisan::output();
|
||||
return View::make('settings/purge')
|
||||
->with('output', $output)->with('success', trans('admin/settings/message.purge.success'));
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
use Input;
|
||||
use Lang;
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\Asset;
|
||||
use Redirect;
|
||||
use DB;
|
||||
use App\Models\Setting;
|
||||
@@ -11,6 +12,7 @@ use Str;
|
||||
use View;
|
||||
use App\Helpers\Helper;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
@@ -35,6 +37,48 @@ class StatuslabelsController extends Controller
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show a count of assets by status label
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
|
||||
public function getAssetCountByStatuslabel()
|
||||
{
|
||||
$colors = [];
|
||||
|
||||
$statuslabels = Statuslabel::with('assets')->get();
|
||||
$labels=[];
|
||||
$points=[];
|
||||
$colors=[];
|
||||
foreach ($statuslabels as $statuslabel) {
|
||||
if ($statuslabel->assets->count() > 0) {
|
||||
$labels[]=$statuslabel->name;
|
||||
$points[]=$statuslabel->assets()->whereNull('assigned_to')->count();
|
||||
if ($statuslabel->color!='') {
|
||||
$colors[]=$statuslabel->color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$labels[]='Deployed';
|
||||
$points[]=Asset::whereNotNull('assigned_to')->count();
|
||||
|
||||
$colors_array = array_merge($colors, Helper::chartColors());
|
||||
|
||||
$result= [
|
||||
"labels" => $labels,
|
||||
"datasets" => [ [
|
||||
"data" => $points,
|
||||
"backgroundColor" => $colors_array,
|
||||
"hoverBackgroundColor" => $colors_array
|
||||
]]
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Statuslabel create.
|
||||
*
|
||||
@@ -56,12 +100,17 @@ class StatuslabelsController extends Controller
|
||||
*
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate()
|
||||
public function postCreate(Request $request)
|
||||
{
|
||||
|
||||
// create a new model instance
|
||||
$statuslabel = new Statuslabel();
|
||||
$statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types'));
|
||||
|
||||
if (!$request->has('statuslabel_types')) {
|
||||
return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]);
|
||||
}
|
||||
|
||||
$statustype = Statuslabel::getStatuslabelTypesForDB($request->input('statuslabel_types'));
|
||||
|
||||
// Save the Statuslabel data
|
||||
$statuslabel->name = e(Input::get('name'));
|
||||
@@ -70,6 +119,8 @@ class StatuslabelsController extends Controller
|
||||
$statuslabel->deployable = $statustype['deployable'];
|
||||
$statuslabel->pending = $statustype['pending'];
|
||||
$statuslabel->archived = $statustype['archived'];
|
||||
$statuslabel->color = e(Input::get('color'));
|
||||
$statuslabel->show_in_nav = e(Input::get('show_in_nav'),0);
|
||||
|
||||
|
||||
// Was the asset created?
|
||||
@@ -82,36 +133,30 @@ class StatuslabelsController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function store()
|
||||
public function store(Request $request)
|
||||
{
|
||||
|
||||
// create a new model instance
|
||||
$statuslabel = new Statuslabel();
|
||||
$statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('modal-statuslabel_types'));
|
||||
|
||||
// attempt validation
|
||||
if ($statuslabel->validate($new)) {
|
||||
|
||||
// Save the Statuslabel data
|
||||
$statuslabel->name = e(Input::get('name'));
|
||||
$statuslabel->user_id = Auth::user()->id;
|
||||
$statuslabel->notes = '';
|
||||
$statuslabel->deployable = $statustype['deployable'];
|
||||
$statuslabel->pending = $statustype['pending'];
|
||||
$statuslabel->archived = $statustype['archived'];
|
||||
|
||||
// Was the asset created?
|
||||
if ($statuslabel->save()) {
|
||||
// Redirect to the new Statuslabel page
|
||||
return JsonResponse::create($statuslabel);
|
||||
} else {
|
||||
return JsonResponse::create(["error" => "Couldn't save Statuslabel"], 500);
|
||||
}
|
||||
} else {
|
||||
// failure
|
||||
$errors = $statuslabel->getErrors();
|
||||
return JsonResponse::create(["error" => "Failed validation: ".print_r($errors->all('<li>:message</li>'), true)], 500);
|
||||
if (!$request->has('statuslabel_types')) {
|
||||
return JsonResponse::create(["error" => trans('validation.statuslabel_type')], 500);
|
||||
}
|
||||
|
||||
$statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types'));
|
||||
$statuslabel->name = e(Input::get('name'));
|
||||
$statuslabel->user_id = Auth::user()->id;
|
||||
$statuslabel->notes = '';
|
||||
$statuslabel->deployable = $statustype['deployable'];
|
||||
$statuslabel->pending = $statustype['pending'];
|
||||
$statuslabel->archived = $statustype['archived'];
|
||||
|
||||
|
||||
if ($statuslabel->isValid()) {
|
||||
$statuslabel->save();
|
||||
// Redirect to the new Statuslabel page
|
||||
return JsonResponse::create($statuslabel);
|
||||
}
|
||||
return JsonResponse::create(["error" => $statuslabel->getErrors()->first()], 500);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +188,7 @@ class StatuslabelsController extends Controller
|
||||
* @param int $statuslabelId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit($statuslabelId = null)
|
||||
public function postEdit(Request $request, $statuslabelId = null)
|
||||
{
|
||||
// Check if the Statuslabel exists
|
||||
if (is_null($statuslabel = Statuslabel::find($statuslabelId))) {
|
||||
@@ -151,6 +196,10 @@ class StatuslabelsController extends Controller
|
||||
return redirect()->to('admin/settings/statuslabels')->with('error', trans('admin/statuslabels/message.does_not_exist'));
|
||||
}
|
||||
|
||||
if (!$request->has('statuslabel_types')) {
|
||||
return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]);
|
||||
}
|
||||
|
||||
|
||||
// Update the Statuslabel data
|
||||
$statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types'));
|
||||
@@ -159,6 +208,8 @@ class StatuslabelsController extends Controller
|
||||
$statuslabel->deployable = $statustype['deployable'];
|
||||
$statuslabel->pending = $statustype['pending'];
|
||||
$statuslabel->archived = $statustype['archived'];
|
||||
$statuslabel->color = e(Input::get('color'));
|
||||
$statuslabel->show_in_nav = e(Input::get('show_in_nav'),0);
|
||||
|
||||
|
||||
// Was the asset created?
|
||||
@@ -193,7 +244,7 @@ class StatuslabelsController extends Controller
|
||||
if ($statuslabel->has_assets() > 0) {
|
||||
|
||||
// Redirect to the asset management page
|
||||
return redirect()->to('admin/settings/statuslabels')->with('error', trans('admin/statuslabels/message.assoc_users'));
|
||||
return redirect()->to('admin/settings/statuslabels')->with('error', trans('admin/statuslabels/message.assoc_assets'));
|
||||
} else {
|
||||
|
||||
$statuslabel->delete();
|
||||
@@ -209,7 +260,7 @@ class StatuslabelsController extends Controller
|
||||
|
||||
public function getDatatable()
|
||||
{
|
||||
$statuslabels = Statuslabel::select(array('id','name','deployable','pending','archived'))
|
||||
$statuslabels = Statuslabel::select(array('id','name','deployable','pending','archived','color','show_in_nav'))
|
||||
->whereNull('deleted_at');
|
||||
|
||||
if (Input::has('search')) {
|
||||
@@ -253,10 +304,19 @@ class StatuslabelsController extends Controller
|
||||
|
||||
$actions = '<a href="'.route('update/statuslabel', $statuslabel->id).'" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a><a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/statuslabel', $statuslabel->id).'" data-content="'.trans('admin/statuslabels/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($statuslabel->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
|
||||
|
||||
if ($statuslabel->color!='') {
|
||||
$color = '<div class="pull-left" style="margin-right: 5px; height: 20px; width: 20px; background-color: '.e($statuslabel->color).'"></div>'.e($statuslabel->color);
|
||||
} else {
|
||||
$color = '';
|
||||
}
|
||||
|
||||
|
||||
$rows[] = array(
|
||||
'id' => e($statuslabel->id),
|
||||
'type' => e($label_type),
|
||||
'name' => e($statuslabel->name),
|
||||
'color' => $color,
|
||||
'show_in_nav' => ($statuslabel->show_in_nav=='1') ? trans('general.yes') : trans('general.no'),
|
||||
'actions' => $actions
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Models\Setting;
|
||||
use Str;
|
||||
use View;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
@@ -102,10 +103,10 @@ class SuppliersController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function store()
|
||||
public function store(Request $request)
|
||||
{
|
||||
$supplier=new Supplier;
|
||||
$supplier->name=$new['name'];
|
||||
$supplier = new Supplier;
|
||||
$supplier->name = e($request->input('name'));
|
||||
$supplier->user_id = Auth::user()->id;
|
||||
|
||||
if ($supplier->save()) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\SetupUserRequest;
|
||||
use App\Http\Requests\AssetFileRequest;
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Accessory;
|
||||
@@ -13,7 +12,10 @@ use App\Models\Company;
|
||||
use App\Models\Location;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Statuslabel;
|
||||
use App\Http\Requests\SaveUserRequest;
|
||||
use App\Http\Requests\UpdateUserRequest;
|
||||
use App\Models\User;
|
||||
use App\Models\Ldap;
|
||||
use Auth;
|
||||
use Config;
|
||||
use Crypt;
|
||||
@@ -30,7 +32,8 @@ use Str;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use URL;
|
||||
use View;
|
||||
use Request;
|
||||
use Illuminate\Http\Request;
|
||||
use Gate;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Users for
|
||||
@@ -38,6 +41,8 @@ use Request;
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
|
||||
|
||||
class UsersController extends Controller
|
||||
{
|
||||
|
||||
@@ -65,7 +70,6 @@ class UsersController extends Controller
|
||||
*/
|
||||
public function getCreate()
|
||||
{
|
||||
$user = new User;
|
||||
|
||||
$groups = Group::pluck('name', 'id');
|
||||
|
||||
@@ -74,7 +78,7 @@ class UsersController extends Controller
|
||||
} else {
|
||||
$userGroups = collect();
|
||||
}
|
||||
|
||||
|
||||
$permissions = config('permissions');
|
||||
$userPermissions = Helper::selectedPermissionsArray($permissions, Input::old('permissions', array()));
|
||||
|
||||
@@ -96,59 +100,103 @@ class UsersController extends Controller
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate(SetupUserRequest $request)
|
||||
public function postCreate(SaveUserRequest $request)
|
||||
{
|
||||
|
||||
$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->activated = 1;
|
||||
$user->locale = e(Input::get('locale'));
|
||||
$user->username = $data['username'] = e(Input::get('username'));
|
||||
$user->password = bcrypt(Input::get('password'));
|
||||
$data['password'] = Input::get('password');
|
||||
//Username, email, and password need to be handled specially because the need to respect config values on an edit.
|
||||
$user->email = $data['email'] = e($request->input('email'));
|
||||
$user->username = $data['username'] = e($request->input('username'));
|
||||
if ($request->has('password')) {
|
||||
$user->password = bcrypt($request->input('password'));
|
||||
$data['password'] = $request->input('password');
|
||||
}
|
||||
// Update the user
|
||||
$user->first_name = e($request->input('first_name'));
|
||||
$user->last_name = e($request->input('last_name'));
|
||||
$user->locale = e($request->input('locale'));
|
||||
$user->employee_num = e($request->input('employee_num'));
|
||||
$user->activated = e($request->input('activated', $user->activated));
|
||||
$user->jobtitle = e($request->input('jobtitle'));
|
||||
$user->phone = e($request->input('phone'));
|
||||
$user->location_id = e($request->input('location_id'));
|
||||
$user->company_id = e(Company::getIdForUser($request->input('company_id')));
|
||||
$user->manager_id = e($request->input('manager_id'));
|
||||
$user->notes = e($request->input('notes'));
|
||||
$user->permissions = json_encode($request->input('permission'));
|
||||
|
||||
|
||||
if ($user->manager_id == "") {
|
||||
$user->manager_id = null;
|
||||
}
|
||||
|
||||
if ($user->location_id == "") {
|
||||
$user->location_id = null;
|
||||
}
|
||||
|
||||
if ($user->company_id == "") {
|
||||
$user->company_id = null;
|
||||
}
|
||||
|
||||
|
||||
if ($user->save()) {
|
||||
if (Input::has('groups')) {
|
||||
$user->groups()->sync(Input::get('groups'));
|
||||
|
||||
if ($request->has('groups')) {
|
||||
$user->groups()->sync($request->input('groups'));
|
||||
} else {
|
||||
$user->groups()->sync(array());
|
||||
}
|
||||
|
||||
if ((Input::get('email_user') == 1) && (Input::has('email'))) {
|
||||
if (($request->input('email_user') == 1) && ($request->has('email'))) {
|
||||
// Send the credentials through email
|
||||
$data = array();
|
||||
$data['email'] = e(Input::get('email'));
|
||||
$data['username'] = e(Input::get('username'));
|
||||
$data['first_name'] = e(Input::get('first_name'));
|
||||
$data['password'] = e(Input::get('password'));
|
||||
$data['email'] = e($request->input('email'));
|
||||
$data['username'] = e($request->input('username'));
|
||||
$data['first_name'] = e($request->input('first_name'));
|
||||
$data['password'] = e($request->input('password'));
|
||||
|
||||
Mail::send('emails.send-login', $data, function ($m) use ($user) {
|
||||
$m->to($user->email, $user->first_name . ' ' . $user->last_name);
|
||||
$m->subject('Welcome ' . $user->first_name);
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.welcome', ['name' => $user->first_name]));
|
||||
});
|
||||
}
|
||||
return redirect::route('users')->with('success', trans('admin/users/message.success.create'));
|
||||
} else {
|
||||
redirect()->back()->withInput()->withInput()->withErrors($user->getErrors())->withErrors($settings->getErrors());
|
||||
}
|
||||
|
||||
return redirect()->route('create/user')->withInput()->with('error', $error);
|
||||
return redirect()->back()->withInput()->withErrors($user->getErrors());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON handler for creating a user through a modal popup
|
||||
*
|
||||
* @todo Handle validation more graciously
|
||||
* @author [B. Wetherington] [<uberbrady@gmail.com>]
|
||||
* @since [v1.8]
|
||||
* @return string JSON
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
$user = new User;
|
||||
|
||||
$user = new User;
|
||||
$inputs = Input::except('csrf_token', 'password_confirm', 'groups', 'email_user');
|
||||
$inputs['activated'] = true;
|
||||
|
||||
$user->first_name = e(Input::get('first_name'));
|
||||
$user->last_name = e(Input::get('last_name'));
|
||||
$user->username = e(Input::get('username'));
|
||||
$user->email = e(Input::get('email'));
|
||||
if (Input::has('password')) {
|
||||
$user->password = bcrypt(Input::get('password'));
|
||||
}
|
||||
|
||||
$user->activated = true;
|
||||
|
||||
|
||||
|
||||
// Was the user created?
|
||||
if ($user->save()) {
|
||||
|
||||
@@ -157,11 +205,13 @@ class UsersController extends Controller
|
||||
$data = array();
|
||||
$data['email'] = e(Input::get('email'));
|
||||
$data['first_name'] = e(Input::get('first_name'));
|
||||
$data['last_name'] = e(Input::get('last_name'));
|
||||
$data['password'] = e(Input::get('password'));
|
||||
|
||||
Mail::send('emails.send-login', $data, function ($m) use ($user) {
|
||||
$m->to($user->email, $user->first_name . ' ' . $user->last_name);
|
||||
$m->subject('Welcome ' . $user->first_name);
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.welcome', ['name' => $user->first_name]));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -170,7 +220,6 @@ class UsersController extends Controller
|
||||
} else {
|
||||
return JsonResponse::create(["error" => "Failed validation: " . print_r($user->getErrors(), true)], 500);
|
||||
}
|
||||
return JsonResponse::create(["error" => "Couldn't save User"], 500);
|
||||
|
||||
|
||||
|
||||
@@ -227,12 +276,11 @@ class UsersController extends Controller
|
||||
* @param int $id
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit($id = null)
|
||||
public function postEdit(UpdateUserRequest $request, $id = null)
|
||||
{
|
||||
// We need to reverse the UI specific logic for our
|
||||
// permissions here before we update the user.
|
||||
$permissions = Input::get('permissions', array());
|
||||
//$this->decodePermissions($permissions);
|
||||
$permissions = $request->input('permissions', array());
|
||||
app('request')->request->set('permissions', $permissions);
|
||||
|
||||
// Only update the email address if locking is set to false
|
||||
@@ -255,26 +303,36 @@ class UsersController extends Controller
|
||||
return redirect()->route('users')->with('error', $error);
|
||||
}
|
||||
|
||||
// First handle anything exclusive to editing.
|
||||
if ($request->has('groups')) {
|
||||
$user->groups()->sync($request->input('groups'));
|
||||
} else {
|
||||
$user->groups()->sync(array());
|
||||
}
|
||||
// Do we want to update the user password?
|
||||
if ($request->has('password')) {
|
||||
$user->password = bcrypt($request->input('password'));
|
||||
}
|
||||
if ( $request->has('username')) {
|
||||
$user->username = e($request->input('username'));
|
||||
}
|
||||
$user->email = e($request->input('email'));
|
||||
|
||||
// Update the user
|
||||
$user->first_name = e(Input::get('first_name'));
|
||||
$user->last_name = e(Input::get('last_name'));
|
||||
$user->locale = e(Input::get('locale'));
|
||||
if (Input::has('username')) {
|
||||
$user->username = e(Input::get('username'));
|
||||
}
|
||||
|
||||
$user->email = e(Input::get('email'));
|
||||
$user->employee_num = e(Input::get('employee_num'));
|
||||
$user->activated = e(Input::get('activated', $user->activated));
|
||||
$user->jobtitle = e(Input::get('jobtitle'));
|
||||
$user->phone = e(Input::get('phone'));
|
||||
$user->location_id = e(Input::get('location_id'));
|
||||
$user->company_id = e(Company::getIdForUser(Input::get('company_id')));
|
||||
$user->manager_id = e(Input::get('manager_id'));
|
||||
$user->notes = e(Input::get('notes'));
|
||||
$user->permissions = json_encode(Input::get('permission'));
|
||||
$user->groups()->sync(Input::get('groups'));
|
||||
// Update the user
|
||||
$user->first_name = e($request->input('first_name'));
|
||||
$user->last_name = e($request->input('last_name'));
|
||||
$user->locale = e($request->input('locale'));
|
||||
$user->employee_num = e($request->input('employee_num'));
|
||||
$user->activated = e($request->input('activated', $user->activated));
|
||||
$user->jobtitle = e($request->input('jobtitle'));
|
||||
$user->phone = e($request->input('phone'));
|
||||
$user->location_id = e($request->input('location_id'));
|
||||
$user->company_id = e(Company::getIdForUser($request->input('company_id')));
|
||||
$user->manager_id = e($request->input('manager_id'));
|
||||
$user->notes = e($request->input('notes'));
|
||||
$user->permissions = json_encode($request->input('permission'));
|
||||
|
||||
|
||||
if ($user->manager_id == "") {
|
||||
$user->manager_id = null;
|
||||
@@ -284,24 +342,15 @@ class UsersController extends Controller
|
||||
$user->location_id = null;
|
||||
}
|
||||
|
||||
|
||||
// Do we want to update the user password?
|
||||
if ((Input::has('password')) && (!config('app.lock_passwords'))) {
|
||||
$user->password = bcrypt(Input::get('password'));
|
||||
if ($user->company_id == "") {
|
||||
$user->company_id = null;
|
||||
}
|
||||
|
||||
// Do we want to update the user email?
|
||||
if (!config('app.lock_passwords')) {
|
||||
$user->email = Input::get('email');
|
||||
}
|
||||
|
||||
|
||||
if (!config('app.lock_passwords')) {
|
||||
|
||||
}
|
||||
|
||||
// Was the user updated?
|
||||
if ($user->save()) {
|
||||
|
||||
|
||||
// Prepare the success message
|
||||
$success = trans('admin/users/message.success.update');
|
||||
|
||||
@@ -397,7 +446,7 @@ class UsersController extends Controller
|
||||
|
||||
//print_r($licenses);
|
||||
|
||||
$users = User::whereIn('id', $user_raw_array)->with('groups', 'assets', 'licenses','accessories')->get();
|
||||
$users = User::whereIn('id', $user_raw_array)->with('groups', 'assets', 'licenses', 'accessories')->get();
|
||||
// $users = Company::scopeCompanyables($users)->get();
|
||||
|
||||
return View::make('users/confirm-bulk-delete', compact('users', 'statuslabel_list'));
|
||||
@@ -448,9 +497,10 @@ class UsersController extends Controller
|
||||
|
||||
// Update the asset log
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $asset->id;
|
||||
$logaction->checkedout_to = $asset->assigned_to;
|
||||
$logaction->asset_type = 'hardware';
|
||||
$logaction->item_id = $asset->id;
|
||||
$logaction->item_type = Asset::class;
|
||||
$logaction->target_id = $asset->assigned_to;
|
||||
$logaction->target_type = User::class;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = 'Bulk checkin asset and delete user';
|
||||
$logaction->logaction('checkin from');
|
||||
@@ -467,9 +517,10 @@ class UsersController extends Controller
|
||||
$accessory_array[] = $accessory->accessory_id;
|
||||
// Update the asset log
|
||||
$logaction = new Actionlog();
|
||||
$logaction->accessory_id = $accessory->id;
|
||||
$logaction->checkedout_to = $accessory->assigned_to;
|
||||
$logaction->asset_type = 'accessory';
|
||||
$logaction->item_id = $accessory->id;
|
||||
$logaction->item_type = Accessory::class;
|
||||
$logaction->target_id = $accessory->assigned_to;
|
||||
$logaction->target_type = User::class;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = 'Bulk checkin accessory and delete user';
|
||||
$logaction->logaction('checkin from');
|
||||
@@ -481,15 +532,16 @@ class UsersController extends Controller
|
||||
$license_array[] = $license->id;
|
||||
// Update the asset log
|
||||
$logaction = new Actionlog();
|
||||
$logaction->accessory_id = $license->id;
|
||||
$logaction->checkedout_to = $license->assigned_to;
|
||||
$logaction->asset_type = 'software';
|
||||
$logaction->item_id = $license->id;
|
||||
$logaction->item_type = License::class;
|
||||
$logaction->target_id = $license->assigned_to;
|
||||
$logaction->target_type = User::class;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = 'Bulk checkin license and delete user';
|
||||
$logaction->logaction('checkin from');
|
||||
}
|
||||
|
||||
LicenseSeat::whereIn('id', $license_array)->update(['assigned_to' => NULL]);
|
||||
|
||||
LicenseSeat::whereIn('id', $license_array)->update(['assigned_to' => null]);
|
||||
|
||||
foreach ($users as $user) {
|
||||
$user->accessories()->sync(array());
|
||||
@@ -519,22 +571,22 @@ class UsersController extends Controller
|
||||
{
|
||||
|
||||
// Get user information
|
||||
if (!$user = User::onlyTrashed()->find($id)) {
|
||||
return redirect()->route('users')->with('error', trans('admin/users/messages.user_not_found'));
|
||||
}
|
||||
if (!$user = User::onlyTrashed()->find($id)) {
|
||||
return redirect()->route('users')->with('error', trans('admin/users/messages.user_not_found'));
|
||||
}
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($user)) {
|
||||
return redirect()->route('users')->with('error', trans('general.insufficient_permissions'));
|
||||
if (!Company::isCurrentUserHasAccess($user)) {
|
||||
return redirect()->route('users')->with('error', trans('general.insufficient_permissions'));
|
||||
} else {
|
||||
|
||||
// Restore the user
|
||||
if (User::withTrashed()->where('id', $id)->restore()) {
|
||||
return redirect()->route('users')->with('success', trans('admin/users/message.success.restored'));
|
||||
} else {
|
||||
|
||||
// Restore the user
|
||||
if (User::withTrashed()->where('id',$id)->restore()) {
|
||||
return redirect()->route('users')->with('success', trans('admin/users/message.success.restored'));
|
||||
} else {
|
||||
return redirect()->route('users')->with('error','User could not be restored.');
|
||||
}
|
||||
|
||||
return redirect()->route('users')->with('error', 'User could not be restored.');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -551,7 +603,7 @@ class UsersController extends Controller
|
||||
|
||||
$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find($userId);
|
||||
|
||||
$userlog = $user->userlog->load('assetlog', 'consumablelog', 'assetlog.model', 'licenselog', 'accessorylog', 'userlog', 'adminlog');
|
||||
$userlog = $user->userlog->load('item');
|
||||
|
||||
if (isset($user->id)) {
|
||||
|
||||
@@ -593,7 +645,7 @@ class UsersController extends Controller
|
||||
}
|
||||
|
||||
// Do we have permission to unsuspend this user?
|
||||
if ($user->isSuperUser() and ! Auth::user()->isSuperUser()) {
|
||||
if ($user->isSuperUser() && !Auth::user()->isSuperUser()) {
|
||||
// Redirect to the user management page
|
||||
return redirect()->route('users')->with('error', 'Insufficient permissions!');
|
||||
}
|
||||
@@ -642,28 +694,21 @@ class UsersController extends Controller
|
||||
$user->id = null;
|
||||
|
||||
// Get this user groups
|
||||
$userGroups = $user_to_clone->groups()->lists('group_id', 'name');
|
||||
|
||||
// Get this user permissions
|
||||
$userPermissions = null;
|
||||
//$this->encodePermissions($userPermissions);
|
||||
$userGroups = $user_to_clone->groups()->lists('name', 'id');
|
||||
|
||||
// Get a list of all the available groups
|
||||
//$groups = Sentry::getGroupProvider()->findAll();
|
||||
$groups = Group::pluck('name', 'id');
|
||||
|
||||
// Get all the available permissions
|
||||
$permissions = config('permissions');
|
||||
$clonedPermissions = $user_to_clone->decodePermissions();
|
||||
|
||||
$userPermissions =Helper::selectedPermissionsArray($permissions, $clonedPermissions);
|
||||
//$this->encodeAllPermissions($permissions);
|
||||
|
||||
$location_list = Helper::locationsList();
|
||||
$company_list = Helper::companyList();
|
||||
$manager_list = array('' => 'Select a User') + DB::table('users')
|
||||
->select(DB::raw('concat(last_name,", ",first_name," (",email,")") as full_name, id'))
|
||||
->whereNull('deleted_at')
|
||||
->where('id', '!=', $id)
|
||||
->orderBy('last_name', 'asc')
|
||||
->orderBy('first_name', 'asc')
|
||||
->lists('full_name', 'id');
|
||||
$manager_list = Helper::managerList();
|
||||
|
||||
// Show the page
|
||||
return View::make('users/edit', compact('groups', 'userGroups', 'permissions', 'userPermissions'))
|
||||
@@ -671,6 +716,8 @@ class UsersController extends Controller
|
||||
->with('company_list', $company_list)
|
||||
->with('manager_list', $manager_list)
|
||||
->with('user', $user)
|
||||
->with('groups', $groups)
|
||||
->with('userGroups', $userGroups)
|
||||
->with('clone_user', $user_to_clone);
|
||||
} catch (UserNotFoundException $e) {
|
||||
// Prepare the error message
|
||||
@@ -761,7 +808,7 @@ class UsersController extends Controller
|
||||
'last_name' => trim(e($row[1])),
|
||||
'username' => trim(e($row[2])),
|
||||
'email' => trim(e($row[3])),
|
||||
'password' => $pass,
|
||||
'password' => bcrypt($pass),
|
||||
'activated' => $activated,
|
||||
'location_id' => trim(e($user_location_id)),
|
||||
'phone' => trim(e($row[5])),
|
||||
@@ -771,17 +818,10 @@ class UsersController extends Controller
|
||||
'permissions' => '{"user":1}',
|
||||
'notes' => 'Imported user'
|
||||
);
|
||||
//dd($newuser);
|
||||
|
||||
DB::table('users')->insert($newuser);
|
||||
|
||||
$updateuser = User::find($row[2]);
|
||||
|
||||
// Update the user details
|
||||
$updateuser->password = $pass;
|
||||
|
||||
// Update the user
|
||||
$updateuser->save();
|
||||
|
||||
|
||||
if (((Input::get('email_user') == 1) && !config('app.lock_passwords'))) {
|
||||
// Send the credentials through email
|
||||
@@ -794,7 +834,8 @@ class UsersController extends Controller
|
||||
if ($newuser['email']) {
|
||||
Mail::send('emails.send-login', $data, function ($m) use ($newuser) {
|
||||
$m->to($newuser['email'], $newuser['first_name'] . ' ' . $newuser['last_name']);
|
||||
$m->subject('Welcome ' . $newuser['first_name']);
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.welcome', ['name' => $newuser['first_name']]));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -819,7 +860,7 @@ class UsersController extends Controller
|
||||
* @see UsersController::getIndex() method that consumed this JSON response
|
||||
* @return string JSON
|
||||
*/
|
||||
public function getDatatable($status = null)
|
||||
public function getDatatable(Request $request, $status = null)
|
||||
{
|
||||
|
||||
if (Input::has('offset')) {
|
||||
@@ -841,7 +882,7 @@ class UsersController extends Controller
|
||||
}
|
||||
|
||||
$users = User::select(array('users.id','users.employee_num','users.email','users.username','users.location_id','users.manager_id','users.first_name','users.last_name','users.created_at','users.notes','users.company_id', 'users.deleted_at','users.activated'))
|
||||
->with('assets', 'accessories', 'consumables', 'licenses', 'manager', 'groups', 'userloc', 'company');
|
||||
->with('assets', 'accessories', 'consumables', 'licenses', 'manager', 'groups', 'userloc', 'company','throttle');
|
||||
$users = Company::scopeCompanyables($users);
|
||||
|
||||
switch ($status) {
|
||||
@@ -867,7 +908,7 @@ class UsersController extends Controller
|
||||
$allowed_columns =
|
||||
[
|
||||
'last_name','first_name','email','username','employee_num',
|
||||
'assets','accessories', 'consumables','licenses','groups','activated'
|
||||
'assets','accessories', 'consumables','licenses','groups','activated','created_at'
|
||||
];
|
||||
|
||||
$sort = in_array($sort, $allowed_columns) ? $sort : 'first_name';
|
||||
@@ -889,23 +930,38 @@ class UsersController extends Controller
|
||||
}
|
||||
|
||||
|
||||
if (!is_null($user->deleted_at)) {
|
||||
|
||||
$actions .= '<a href="' . route('restore/user', $user->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-share icon-white"></i></a> ';
|
||||
} else {
|
||||
|
||||
if ($user->accountStatus() == 'suspended') {
|
||||
$actions .= '<a href="' . route('unsuspend/user', $user->id) . '" class="btn btn-default btn-sm"><span class="fa fa-clock-o"></span></a> ';
|
||||
}
|
||||
|
||||
$actions .= '<a href="' . route('update/user', $user->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> ';
|
||||
|
||||
if ((Auth::user()->id !== $user->id) && (!config('app.lock_passwords'))) {
|
||||
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/user', $user->id) . '" data-content="Are you sure you wish to delete this user?" data-title="Delete ' . htmlspecialchars($user->first_name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a> ';
|
||||
if (!is_null($user->deleted_at)) {
|
||||
if (Gate::allows('users.delete')) {
|
||||
$actions .= '<a href="' . route('restore/user',
|
||||
$user->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-share icon-white"></i></a> ';
|
||||
}
|
||||
} else {
|
||||
$actions .= ' <span class="btn delete-asset btn-danger btn-sm disabled"><i class="fa fa-trash icon-white"></i></span>';
|
||||
|
||||
if (Gate::allows('users.delete')) {
|
||||
if ($user->accountStatus() == 'suspended') {
|
||||
$actions .= '<a href="' . route('unsuspend/user',
|
||||
$user->id) . '" class="btn btn-default btn-sm"><span class="fa fa-clock-o"></span></a> ';
|
||||
}
|
||||
}
|
||||
if (Gate::allows('users.edit')) {
|
||||
$actions .= '<a href="' . route('update/user',
|
||||
$user->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> ';
|
||||
|
||||
$actions .= '<a href="' . route('clone/user',
|
||||
$user->id) . '" class="btn btn-info btn-sm"><i class="fa fa-clone"></i></a>';
|
||||
}
|
||||
if (Gate::allows('users.delete')) {
|
||||
if ((Auth::user()->id !== $user->id) && (!config('app.lock_passwords'))) {
|
||||
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/user',
|
||||
$user->id) . '" data-content="Are you sure you wish to delete this user?" data-title="Delete ' . htmlspecialchars($user->first_name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a> ';
|
||||
} else {
|
||||
$actions .= ' <span class="btn delete-asset btn-danger btn-sm disabled"><i class="fa fa-trash icon-white"></i></span>';
|
||||
}
|
||||
} else {
|
||||
$actions.='foo';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$actions .= '</nobr>';
|
||||
|
||||
$rows[] = array(
|
||||
@@ -926,6 +982,7 @@ class UsersController extends Controller
|
||||
'consumables' => $user->consumables->count(),
|
||||
'groups' => $group_names,
|
||||
'notes' => e($user->notes),
|
||||
'created_at' => ($user->created_at!='') ? e($user->created_at->format('F j, Y h:iA')) : '',
|
||||
'activated' => ($user->activated=='1') ? '<i class="fa fa-check"></i>' : '<i class="fa fa-times"></i>',
|
||||
'actions' => ($actions) ? $actions : '',
|
||||
'companyName' => is_null($user->company) ? '' : e($user->company->name)
|
||||
@@ -966,12 +1023,12 @@ class UsersController extends Controller
|
||||
|
||||
//Log the deletion of seats to the log
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $user->id;
|
||||
$logaction->asset_type = 'user';
|
||||
$logaction->item_id = $user->id;
|
||||
$logaction->item_type = User::class;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = e(Input::get('notes'));
|
||||
$logaction->checkedout_to = null;
|
||||
$logaction->created_at = date("Y-m-d h:i:s");
|
||||
$logaction->target_id = null;
|
||||
$logaction->created_at = date("Y-m-d H:i:s");
|
||||
$logaction->filename = $filename;
|
||||
$logaction->action_type = 'uploaded';
|
||||
$logaction->save();
|
||||
@@ -1042,7 +1099,7 @@ class UsersController extends Controller
|
||||
return redirect()->route('users')->with('error', trans('general.insufficient_permissions'));
|
||||
} else {
|
||||
$log = Actionlog::find($fileId);
|
||||
$file = $log->get_src();
|
||||
$file = $log->get_src('users');
|
||||
return Response::download($file);
|
||||
}
|
||||
} else {
|
||||
@@ -1063,22 +1120,24 @@ class UsersController extends Controller
|
||||
*/
|
||||
public function getLDAP()
|
||||
{
|
||||
// Get all the available groups
|
||||
//s$groups = Sentry::getGroupProvider()->findAll();
|
||||
// Selected groups
|
||||
$selectedGroups = Input::old('groups', array());
|
||||
// Get all the available permissions
|
||||
$permissions = config('permissions');
|
||||
//$this->encodeAllPermissions($permissions);
|
||||
// Selected permissions
|
||||
$selectedPermissions = Input::old('permissions', array('superuser' => -1));
|
||||
//$this->encodePermissions($selectedPermissions);
|
||||
|
||||
$location_list = Helper::locationsList();
|
||||
|
||||
// Show the page
|
||||
return View::make('users/ldap', compact('groups', 'selectedGroups', 'permissions', 'selectedPermissions'))
|
||||
->with('location_list', $location_list);
|
||||
try {
|
||||
$ldapconn = Ldap::connectToLdap();
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->route('users')->with('error',$e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Ldap::bindAdminToLdap($ldapconn);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->route('users')->with('error',$e->getMessage());
|
||||
}
|
||||
|
||||
return View::make('users/ldap')
|
||||
->with('location_list', $location_list);
|
||||
|
||||
}
|
||||
|
||||
@@ -1096,7 +1155,6 @@ class UsersController extends Controller
|
||||
|
||||
protected $ldapValidationRules = array(
|
||||
'firstname' => 'required|string|min:2',
|
||||
'lastname' => 'required|string|min:2',
|
||||
'employee_number' => 'string',
|
||||
'username' => 'required|min:2|unique:users,username',
|
||||
'email' => 'email|unique:users,email',
|
||||
@@ -1109,17 +1167,10 @@ class UsersController extends Controller
|
||||
* @since [v1.8]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postLDAP()
|
||||
public function postLDAP(Request $request)
|
||||
{
|
||||
|
||||
$location_id = e(Input::get('location_id'));
|
||||
|
||||
$ldap_version = Setting::getSettings()->ldap_version;
|
||||
$url = Setting::getSettings()->ldap_server;
|
||||
$username = Setting::getSettings()->ldap_uname;
|
||||
$password = Crypt::decrypt(Setting::getSettings()->ldap_pword);
|
||||
$base_dn = Setting::getSettings()->ldap_basedn;
|
||||
$filter = Setting::getSettings()->ldap_filter;
|
||||
ini_set('max_execution_time', 600); //600 seconds = 10 minutes
|
||||
ini_set('memory_limit', '500M');
|
||||
|
||||
$ldap_result_username = Setting::getSettings()->ldap_username_field;
|
||||
$ldap_result_last_name = Setting::getSettings()->ldap_lname_field;
|
||||
@@ -1128,78 +1179,27 @@ class UsersController extends Controller
|
||||
$ldap_result_active_flag = Setting::getSettings()->ldap_active_flag_field;
|
||||
$ldap_result_emp_num = Setting::getSettings()->ldap_emp_num;
|
||||
$ldap_result_email = Setting::getSettings()->ldap_email;
|
||||
$ldap_server_cert_ignore = Setting::getSettings()->ldap_server_cert_ignore;
|
||||
|
||||
// If we are ignoring the SSL cert we need to setup the environment variable
|
||||
// before we create the connection
|
||||
if ($ldap_server_cert_ignore) {
|
||||
putenv('LDAPTLS_REQCERT=never');
|
||||
try {
|
||||
$ldapconn = Ldap::connectToLdap();
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->withInput()->with('error',$e->getMessage());
|
||||
}
|
||||
|
||||
// Connect to LDAP server
|
||||
$ldapconn = @ldap_connect($url);
|
||||
|
||||
// Needed for AD
|
||||
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
|
||||
|
||||
if (!$ldapconn) {
|
||||
return redirect()->route('users')->with('error', trans('admin/users/message.error.ldap_could_not_connect'));
|
||||
try {
|
||||
Ldap::bindAdminToLdap($ldapconn);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->withInput()->with('error',$e->getMessage());
|
||||
}
|
||||
|
||||
// Set options
|
||||
$ldapopt = @ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, $ldap_version);
|
||||
if (!$ldapopt) {
|
||||
return redirect()->route('users')->with('error', trans('admin/users/message.error.ldap_could_not_connect'));
|
||||
}
|
||||
|
||||
// Binding to ldap server
|
||||
$ldapbind = @ldap_bind($ldapconn, $username, $password);
|
||||
|
||||
Log::error(ldap_errno($ldapconn));
|
||||
if (!$ldapbind) {
|
||||
return redirect()->route('users')->with('error', trans('admin/users/message.error.ldap_could_not_bind').ldap_error($ldapconn));
|
||||
}
|
||||
|
||||
// Set up LDAP pagination for very large databases
|
||||
// @author Richard Hofman
|
||||
$page_size = 500;
|
||||
$cookie = '';
|
||||
$result_set = array();
|
||||
$global_count = 0;
|
||||
|
||||
// Perform the search
|
||||
do {
|
||||
// Paginate (non-critical, if not supported by server)
|
||||
ldap_control_paged_result($ldapconn, $page_size, false, $cookie);
|
||||
|
||||
$search_results = ldap_search($ldapconn, $base_dn, '('.$filter.')');
|
||||
|
||||
if (!$search_results) {
|
||||
return redirect()->route('users')->with('error', trans('admin/users/message.error.ldap_could_not_search').ldap_error($ldapconn));
|
||||
}
|
||||
|
||||
// Get results from page
|
||||
$results = ldap_get_entries($ldapconn, $search_results);
|
||||
if (!$results) {
|
||||
return redirect()->route('users')->with('error', trans('admin/users/message.error.ldap_could_not_get_entries').ldap_error($ldapconn));
|
||||
}
|
||||
|
||||
// Add results to result set
|
||||
$global_count += $results['count'];
|
||||
$result_set = array_merge($result_set, $results);
|
||||
|
||||
ldap_control_paged_result_response($ldapconn, $search_results, $cookie);
|
||||
|
||||
} while ($cookie !== null && $cookie != '');
|
||||
|
||||
|
||||
// Clean up after search
|
||||
$result_set['count'] = $global_count;
|
||||
$results = $result_set;
|
||||
ldap_control_paged_result($ldapconn, 0);
|
||||
|
||||
$summary = array();
|
||||
|
||||
$results = Ldap::findLdapUsers();
|
||||
|
||||
$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") {
|
||||
|
||||
@@ -1214,22 +1214,22 @@ class UsersController extends Controller
|
||||
$item["createorupdate"] = 'updated';
|
||||
if (!$user = User::where('username', $item["username"])->first()) {
|
||||
$user = new User;
|
||||
$user->password = $pass;
|
||||
$item["createorupdate"] = 'created';
|
||||
}
|
||||
|
||||
|
||||
// Create the user if they don't exist.
|
||||
$pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
|
||||
|
||||
|
||||
$user->first_name = e($item["firstname"]);
|
||||
$user->last_name = e($item["lastname"]);
|
||||
$user->username = e($item["username"]);
|
||||
$user->email = e($item["email"]);
|
||||
$user->employee_num = e($item["employee_number"]);
|
||||
$user->password = bcrypt($pass);
|
||||
$user->activated = 1;
|
||||
$user->location_id = e($location_id);
|
||||
$user->permissions = '{"user":1}';
|
||||
if ($request->input('location_id')!='') {
|
||||
$user->location_id = e($request->input('location_id'));
|
||||
}
|
||||
$user->notes = 'Imported from LDAP';
|
||||
$user->ldap_import = 1;
|
||||
|
||||
@@ -1239,9 +1239,7 @@ class UsersController extends Controller
|
||||
$item["note"] = $item["createorupdate"];
|
||||
$item["status"]='success';
|
||||
} else {
|
||||
//$errors_array = array($user->getErrors());
|
||||
foreach ($user->getErrors()->getMessages() as $key => $err) {
|
||||
//echo $user->getErrors();
|
||||
$errors .='<li>'.$err[0];
|
||||
}
|
||||
$item["note"] = $errors;
|
||||
@@ -1255,7 +1253,7 @@ class UsersController extends Controller
|
||||
|
||||
|
||||
|
||||
return redirect()->route('ldap/user')->with('success', "OK")->with('summary', $summary);
|
||||
return redirect()->route('ldap/user')->with('success', "LDAP Import successful.")->with('summary', $summary);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1267,9 +1265,7 @@ class UsersController extends Controller
|
||||
*/
|
||||
public function getAssetList($userId)
|
||||
{
|
||||
$assets = Asset::where('assigned_to', '=', $userId)->get();
|
||||
$assets = Asset::where('assigned_to', '=', $userId)->with('model')->get();
|
||||
return response()->json($assets);
|
||||
//$foo = Asset::where('assigned_to','=',$userId)->get();
|
||||
//print_r($foo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,12 @@ namespace App\Http\Controllers;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\CheckoutRequest;
|
||||
use App\Models\Company;
|
||||
use App\Models\Component;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\Location;
|
||||
use App\Models\License;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Auth;
|
||||
@@ -36,11 +39,18 @@ class ViewAssetsController extends Controller
|
||||
public function getIndex()
|
||||
{
|
||||
|
||||
$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find(Auth::user()->id);
|
||||
|
||||
$userlog = $user->userlog->load('assetlog', 'consumablelog', 'assetlog.model', 'licenselog', 'accessorylog', 'userlog', 'adminlog');
|
||||
$user = User::with(
|
||||
'assets',
|
||||
'assets.model',
|
||||
'consumables',
|
||||
'accessories',
|
||||
'licenses',
|
||||
'userloc',
|
||||
'userlog'
|
||||
)->withTrashed()->find(Auth::user()->id);
|
||||
|
||||
|
||||
$userlog = $user->userlog->load('item', 'user', 'target');
|
||||
|
||||
if (isset($user->id)) {
|
||||
return View::make('account/view-assets', compact('user', 'userlog'));
|
||||
@@ -58,12 +68,133 @@ class ViewAssetsController extends Controller
|
||||
public function getRequestableIndex()
|
||||
{
|
||||
|
||||
$assets = Asset::with('model', 'defaultLoc')->Hardware()->RequestableAssets()->get();
|
||||
$assets = Asset::with('model', 'defaultLoc', 'assetloc', 'assigneduser')->Hardware()->RequestableAssets()->get();
|
||||
$models = AssetModel::with('category')->RequestableModels()->get();
|
||||
|
||||
return View::make('account/requestable-assets', compact('user', 'assets'));
|
||||
return View::make('account/requestable-assets', compact('user', 'assets', 'models'));
|
||||
}
|
||||
|
||||
public function getRequestedIndex()
|
||||
{
|
||||
$requestedItems = CheckoutRequest::with('user', 'requestedItem')->get();
|
||||
return View::make('admin/requested-assets', compact('requestedItems'));
|
||||
}
|
||||
|
||||
|
||||
public function getRequestItem($itemType, $itemId = null)
|
||||
{
|
||||
$item = null;
|
||||
$fullItemType = 'App\\Models\\' . studly_case($itemType);
|
||||
if ($itemType == "asset_model") {
|
||||
$itemType = "model";
|
||||
}
|
||||
$item = call_user_func(array($fullItemType, 'find'), $itemId);
|
||||
$user = Auth::user();
|
||||
$quantity = $data['item_quantity'] = Input::has('request-quantity') ? e(Input::get('request-quantity')) : 1;
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->item_id = $data['asset_id'] = $item->id;
|
||||
$logaction->item_type = $fullItemType;
|
||||
$logaction->created_at = $data['requested_date'] = date("Y-m-d H:i:s");
|
||||
if ($user->location_id) {
|
||||
$logaction->location_id = $user->location_id;
|
||||
}
|
||||
$logaction->target_id = $data['user_id'] = Auth::user()->id;
|
||||
$logaction->target_type = User::class;
|
||||
|
||||
$data['requested_by'] = $user->fullName();
|
||||
$data['item_name'] = $item->name;
|
||||
$data['item_type'] = $itemType;
|
||||
|
||||
if ($fullItemType == Asset::class) {
|
||||
$data['item_url'] = route('view/hardware', $item->id);
|
||||
$slackMessage = ' Asset <'.config('app.url').'/hardware/'.$item->id.'/view'.'|'.$item->showAssetName().'> requested by <'.config('app.url').'/users/'.$item->user_id.'/view'.'|'.$user->fullName().'>.';
|
||||
} else {
|
||||
$data['item_url'] = route("view/${itemType}", $item->id);
|
||||
$slackMessage = $quantity. ' ' . class_basename(strtoupper($logaction->item_type)).' <'.$data['item_url'].'|'.$item->name.'> requested by <'.config('app.url').'/user/'.$item->id.'/view'.'|'.$user->fullName().'>.';
|
||||
}
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
if ($settings->slack_endpoint) {
|
||||
|
||||
$slack_settings = [
|
||||
'username' => $settings->botname,
|
||||
'channel' => $settings->slack_channel,
|
||||
'link_names' => true
|
||||
];
|
||||
|
||||
$slackClient = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);
|
||||
}
|
||||
|
||||
if ($item->isRequestedBy($user)) {
|
||||
|
||||
$item->cancelRequest();
|
||||
$log = $logaction->logaction('request_canceled');
|
||||
|
||||
if (($settings->alert_email!='') && ($settings->alerts_enabled=='1') && (!config('app.lock_passwords'))) {
|
||||
Mail::send('emails.asset-canceled', $data, function ($m) use ($user, $settings) {
|
||||
$m->to(explode(',', $settings->alert_email), $settings->site_name);
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.Item_Request_Canceled'));
|
||||
});
|
||||
}
|
||||
|
||||
if ($settings->slack_endpoint) {
|
||||
try {
|
||||
$slackClient->attach([
|
||||
'color' => 'good',
|
||||
'fields' => [
|
||||
[
|
||||
'title' => 'CANCELED:',
|
||||
'value' => $slackMessage
|
||||
]
|
||||
|
||||
]
|
||||
])->send('Item Request Canceled');
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('requestable-assets')->with('success')->with('success', trans('admin/hardware/message.requests.canceled'));
|
||||
|
||||
} else {
|
||||
$item->request();
|
||||
|
||||
$log = $logaction->logaction('requested');
|
||||
|
||||
|
||||
if (($settings->alert_email!='') && ($settings->alerts_enabled=='1') && (!config('app.lock_passwords'))) {
|
||||
Mail::send('emails.asset-requested', $data, function ($m) use ($user, $settings) {
|
||||
$m->to(explode(',', $settings->alert_email), $settings->site_name);
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.Item_Requested'));
|
||||
});
|
||||
}
|
||||
|
||||
if ($settings->slack_endpoint) {
|
||||
try {
|
||||
$slackClient->attach([
|
||||
'color' => 'good',
|
||||
'fields' => [
|
||||
[
|
||||
'title' => 'REQUESTED:',
|
||||
'value' => $slackMessage
|
||||
]
|
||||
|
||||
]
|
||||
])->send('Item Requested');
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('requestable-assets')->with('success')->with('success', trans('admin/hardware/message.requests.success'));
|
||||
}
|
||||
}
|
||||
public function getRequestAsset($assetId = null)
|
||||
{
|
||||
|
||||
@@ -75,17 +206,23 @@ class ViewAssetsController extends Controller
|
||||
return redirect()->route('requestable-assets')->with('error', trans('admin/hardware/message.does_not_exist_or_not_requestable'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($asset)) {
|
||||
return redirect()->route('requestable-assets')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
// If it's requested, cancel the request.
|
||||
if ($asset->isRequestedBy(Auth::user())) {
|
||||
$asset->cancelRequest();
|
||||
return redirect()->route('requestable-assets')->with('success')->with('success', trans('admin/hardware/message.requests.success'));
|
||||
} else {
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $data['asset_id'] = $asset->id;
|
||||
$logaction->asset_type = $data['asset_type'] = 'hardware';
|
||||
$logaction->created_at = $data['requested_date'] = date("Y-m-d h:i:s");
|
||||
|
||||
$logaction->item_id = $data['asset_id'] = $asset->id;
|
||||
$logaction->item_type = Asset::class;
|
||||
$logaction->created_at = $data['requested_date'] = date("Y-m-d H:i:s");
|
||||
$data['asset_type'] = 'hardware';
|
||||
if ($user->location_id) {
|
||||
$logaction->location_id = $user->location_id;
|
||||
}
|
||||
$logaction->user_id = $data['user_id'] = Auth::user()->id;
|
||||
$logaction->target_id = $data['user_id'] = Auth::user()->id;
|
||||
$logaction->target_type = User::class;
|
||||
$log = $logaction->logaction('requested');
|
||||
|
||||
$data['requested_by'] = $user->fullName();
|
||||
@@ -96,10 +233,13 @@ class ViewAssetsController extends Controller
|
||||
if (($settings->alert_email!='') && ($settings->alerts_enabled=='1') && (!config('app.lock_passwords'))) {
|
||||
Mail::send('emails.asset-requested', $data, function ($m) use ($user, $settings) {
|
||||
$m->to(explode(',', $settings->alert_email), $settings->site_name);
|
||||
$m->subject('Asset Requested');
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.asset_requested'));
|
||||
});
|
||||
}
|
||||
|
||||
$asset->request();
|
||||
|
||||
|
||||
if ($settings->slack_endpoint) {
|
||||
|
||||
@@ -118,7 +258,7 @@ class ViewAssetsController extends Controller
|
||||
'fields' => [
|
||||
[
|
||||
'title' => 'REQUESTED:',
|
||||
'value' => strtoupper($logaction->asset_type).' asset <'.config('app.url').'/hardware/'.$asset->id.'/view'.'|'.$asset->showAssetName().'> requested by <'.config('app.url').'/hardware/'.$asset->id.'/view'.'|'.Auth::user()->fullName().'>.'
|
||||
'value' => class_basename(strtoupper($logaction->item_type)).' asset <'.config('app.url').'/hardware/'.$asset->id.'/view'.'|'.$asset->showAssetName().'> requested by <'.config('app.url').'/hardware/'.$asset->id.'/view'.'|'.Auth::user()->fullName().'>.'
|
||||
]
|
||||
|
||||
]
|
||||
@@ -136,34 +276,32 @@ class ViewAssetsController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function getRequestedAssets()
|
||||
{
|
||||
$checkoutrequests = CheckoutRequest::all();
|
||||
|
||||
return View::make('account/requested-items', compact($checkoutrequests));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Get the acceptance screen
|
||||
public function getAcceptAsset($logID = null)
|
||||
{
|
||||
|
||||
if (is_null($findlog = Actionlog::find($logID))) {
|
||||
// Redirect to the asset management page
|
||||
return redirect()->to('account')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||
if (!$findlog = Actionlog::where('id', $logID)->first()) {
|
||||
echo 'no record';
|
||||
//return redirect()->to('account')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||
}
|
||||
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
if ($user->id != $findlog->checkedout_to) {
|
||||
return redirect()->to('account/view-assets')->with('error', trans('admin/users/message.error.incorrect_user_accepted'));
|
||||
}
|
||||
|
||||
// Asset
|
||||
if (($findlog->asset_id!='') && ($findlog->asset_type=='hardware')) {
|
||||
$item = Asset::find($findlog->asset_id);
|
||||
|
||||
// software
|
||||
} elseif (($findlog->asset_id!='') && ($findlog->asset_type=='software')) {
|
||||
$item = License::find($findlog->asset_id);
|
||||
// accessories
|
||||
} elseif ($findlog->accessory_id!='') {
|
||||
$item = Accessory::find($findlog->accessory_id);
|
||||
}
|
||||
$item = $findlog->item;
|
||||
|
||||
// Check if the asset exists
|
||||
if (is_null($item)) {
|
||||
@@ -181,16 +319,11 @@ class ViewAssetsController extends Controller
|
||||
{
|
||||
|
||||
// Check if the asset exists
|
||||
if (is_null($findlog = Actionlog::find($logID))) {
|
||||
if (is_null($findlog = Actionlog::where('id', $logID)->first())) {
|
||||
// Redirect to the asset management page
|
||||
return redirect()->to('account/view-assets')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// NOTE: make sure the global scope is applied
|
||||
$is_unauthorized = is_null(Actionlog::where('id', '=', $logID)->first());
|
||||
if ($is_unauthorized) {
|
||||
return redirect()->route('requestable-assets')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
if ($findlog->accepted_id!='') {
|
||||
// Redirect to the asset management page
|
||||
@@ -218,41 +351,24 @@ class ViewAssetsController extends Controller
|
||||
$accepted="rejected";
|
||||
$return_msg = trans('admin/users/message.declined');
|
||||
}
|
||||
|
||||
$logaction->item_id = $findlog->item_id;
|
||||
$logaction->item_type = $findlog->item_type;
|
||||
// Asset
|
||||
if (($findlog->asset_id!='') && ($findlog->asset_type=='hardware')) {
|
||||
$logaction->asset_id = $findlog->asset_id;
|
||||
$logaction->accessory_id = null;
|
||||
$logaction->asset_type = 'hardware';
|
||||
|
||||
if (($findlog->item_id!='') && ($findlog->item_type==Asset::class)) {
|
||||
if (Input::get('asset_acceptance')!='accepted') {
|
||||
DB::table('assets')
|
||||
->where('id', $findlog->asset_id)
|
||||
->where('id', $findlog->item_id)
|
||||
->update(array('assigned_to' => null));
|
||||
}
|
||||
|
||||
|
||||
// software
|
||||
} elseif (($findlog->asset_id!='') && ($findlog->asset_type=='software')) {
|
||||
$logaction->asset_id = $findlog->asset_id;
|
||||
$logaction->accessory_id = null;
|
||||
$logaction->asset_type = 'software';
|
||||
|
||||
// accessories
|
||||
} elseif ($findlog->accessory_id!='') {
|
||||
$logaction->asset_id = null;
|
||||
$logaction->accessory_id = $findlog->accessory_id;
|
||||
$logaction->asset_type = 'accessory';
|
||||
}
|
||||
|
||||
$logaction->checkedout_to = $findlog->checkedout_to;
|
||||
$logaction->target_id = $findlog->target_id;
|
||||
|
||||
$logaction->note = e(Input::get('note'));
|
||||
$logaction->user_id = $user->id;
|
||||
$logaction->accepted_at = date("Y-m-d h:i:s");
|
||||
$logaction->accepted_at = date("Y-m-d H:i:s");
|
||||
$log = $logaction->logaction($logaction_msg);
|
||||
|
||||
$update_checkout = DB::table('asset_logs')
|
||||
$update_checkout = DB::table('action_logs')
|
||||
->where('id', $findlog->id)
|
||||
->update(array('accepted_id' => $logaction->id));
|
||||
|
||||
|
||||
@@ -14,13 +14,14 @@ class Kernel extends HttpKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\MisterPhilip\MaintenanceMode\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\FrameGuard::class,
|
||||
\App\Http\Middleware\XssProtectHeader::class,
|
||||
\App\Http\Middleware\NosniffGuard::class,
|
||||
\App\Http\Middleware\CheckForSetup::class,
|
||||
\Fideloper\Proxy\TrustProxies::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,23 +14,23 @@ class CheckForSetup
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
|
||||
if (Setting::setupCompleted()) {
|
||||
|
||||
if ($request->is('setup*')) {
|
||||
return redirect(config('app.url'));
|
||||
} else {
|
||||
return $next($request);
|
||||
}
|
||||
if (Setting::setupCompleted()) {
|
||||
|
||||
if ($request->is('setup*')) {
|
||||
return redirect(config('app.url'));
|
||||
} else {
|
||||
if (!$request->is('setup*')) {
|
||||
return redirect(config('app.url').'/setup')->with('Request',$request);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!$request->is('setup*')) {
|
||||
return redirect(config('app.url').'/setup')->with('Request', $request);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,27 +5,34 @@ namespace App\Http\Middleware;
|
||||
use Closure;
|
||||
use Config;
|
||||
use Route;
|
||||
use Gate;
|
||||
|
||||
class CheckPermissions
|
||||
{
|
||||
/**
|
||||
* Handle the ACLs for permissions.
|
||||
*
|
||||
* The $section variable is passed via the route middleware,
|
||||
* 'middleware' => [authorize:superadmin']
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @param string|null $section
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $section = null, $guard = null)
|
||||
public function handle($request, Closure $next, $section = null)
|
||||
{
|
||||
|
||||
if (($request->user()->hasAccess($section)) || ($request->user()->isSuperUser())) {
|
||||
|
||||
if (Gate::allows($section)) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
return response()->view('layouts/basic', [
|
||||
'content' => view('errors/403')
|
||||
'content' => view('errors/403')
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,10 @@ class FrameGuard
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
$response->headers->set('X-Frame-Options', 'SAMEORIGIN', false);
|
||||
if (config('app.allow_iframing') == false) {
|
||||
$response->headers->set('X-Frame-Options', 'SAMEORIGIN', false);
|
||||
}
|
||||
return $response;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\AssetModel;
|
||||
use Session;
|
||||
|
||||
class AssetRequest extends Request
|
||||
{
|
||||
@@ -30,29 +31,32 @@ class AssetRequest extends Request
|
||||
'status_id' => 'required|integer',
|
||||
'company_id' => 'integer',
|
||||
'warranty_months' => 'integer|min:0|max:240',
|
||||
'physical' => 'integer',
|
||||
'checkout_date' => 'date|max:10|min:10',
|
||||
'checkin_date' => 'date|max:10|min:10',
|
||||
'physical' => 'integer',
|
||||
'checkout_date' => 'date',
|
||||
'checkin_date' => 'date',
|
||||
'supplier_id' => 'integer',
|
||||
'asset_tag' => 'required|min:2|max:255|unique:assets,asset_tag,NULL,deleted_at',
|
||||
'status' => 'integer',
|
||||
'asset_tag' => 'required',
|
||||
'purchase_cost' => 'numeric',
|
||||
|
||||
];
|
||||
|
||||
$model = AssetModel::find($this->request->get('model_id'));
|
||||
|
||||
if (($model) && ($model->fieldset))
|
||||
{
|
||||
if (($model) && ($model->fieldset)) {
|
||||
$rules += $model->fieldset->validation_rules();
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $rules;
|
||||
|
||||
}
|
||||
|
||||
public function response(array $errors)
|
||||
{
|
||||
return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);
|
||||
$this->session()->flash('errors', Session::get('errors', new \Illuminate\Support\ViewErrorBag)
|
||||
->put('default', new \Illuminate\Support\MessageBag($errors)));
|
||||
\Input::flash();
|
||||
return parent::response($errors);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ abstract class Request extends FormRequest
|
||||
return $this->rules;
|
||||
}
|
||||
|
||||
public function response(array $errors)
|
||||
{
|
||||
$this->session->flash('errorMessages', $errors);
|
||||
return $this->redirector->back()->withErrors($errors)->withInput();
|
||||
}
|
||||
// public function response(array $errors)
|
||||
// {
|
||||
// $this->session->flash('errorMessages', $errors);
|
||||
// return $this->redirector->back()->withErrors($errors)->withInput();
|
||||
// }
|
||||
}
|
||||
|
||||
34
app/Http/Requests/SaveUserRequest.php
Normal file
34
app/Http/Requests/SaveUserRequest.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class SaveUserRequest extends Request
|
||||
{
|
||||
/**
|
||||
* 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()
|
||||
{
|
||||
return [
|
||||
'first_name' => 'required|string|min:1',
|
||||
'email' => 'email',
|
||||
'password' => 'required|min:6',
|
||||
'password_confirm' => 'sometimes|required_with:password',
|
||||
'username' => 'required|string|min:2|unique:users,username,NULL,deleted_at',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class SettingRequest extends Request
|
||||
{
|
||||
/**
|
||||
* 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()
|
||||
{
|
||||
return [
|
||||
"brand" => 'required|min:1|numeric',
|
||||
"qr_text" => 'min:1|max:31',
|
||||
"logo_img" => 'mimes:jpeg,bmp,png,gif',
|
||||
"custom_css" => 'string',
|
||||
"alert_email" => 'email_array',
|
||||
"slack_endpoint" => 'url',
|
||||
"default_currency" => 'required',
|
||||
"locale" => 'required',
|
||||
"slack_channel" => 'regex:/(?<!\w)#\w+/',
|
||||
"slack_botname" => 'string',
|
||||
'labels_per_page' => 'numeric',
|
||||
'labels_width' => 'numeric',
|
||||
'labels_height' => 'numeric',
|
||||
'labels_pmargin_left' => 'numeric',
|
||||
'labels_pmargin_right' => 'numeric',
|
||||
'labels_pmargin_top' => 'numeric',
|
||||
'labels_pmargin_bottom' => 'numeric',
|
||||
'labels_display_bgutter' => 'numeric',
|
||||
'labels_display_sgutter' => 'numeric',
|
||||
'labels_fontsize' => 'numeric|min:5',
|
||||
'labels_pagewidth' => 'numeric',
|
||||
'labels_pageheight' => 'numeric',
|
||||
"ldap_server" => 'sometimes|required_if:ldap_enabled,1|url',
|
||||
"ldap_uname" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_basedn" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_filter" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_username_field" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_lname_field" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_auth_filter_query" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_version" => 'sometimes|required_if:ldap_enabled,1',
|
||||
];
|
||||
}
|
||||
|
||||
public function response(array $errors)
|
||||
{
|
||||
return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);
|
||||
}
|
||||
}
|
||||
@@ -24,14 +24,14 @@ class SetupUserRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'site_name' => 'required|string|min:1',
|
||||
'first_name' => 'required|string|min:1',
|
||||
'last_name' => 'required|string|min:1',
|
||||
'location_id' => 'numeric',
|
||||
'username' => 'required|string|min:2|unique:users,username,NULL,deleted_at',
|
||||
'email' => 'email|unique:users,email',
|
||||
'password' => 'required|min:6',
|
||||
'password_confirm' => 'required|min:6|same:password',
|
||||
'company_id' => 'integer',
|
||||
'email_domain' => 'required|min:4',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class ComponentCheckoutRequest extends Request
|
||||
class UpdateUserRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
@@ -24,8 +24,9 @@ class ComponentCheckoutRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
"asset_id" => 'required',
|
||||
"assigned_qty" => 'required|numeric|min:1',
|
||||
'first_name' => 'required|string|min:1',
|
||||
'email' => 'email',
|
||||
'password_confirm' => 'sometimes|required_with:password',
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Traits/UniqueUndeletedTrait.php
Normal file
23
app/Http/Traits/UniqueUndeletedTrait.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace App\Http\Traits;
|
||||
|
||||
trait UniqueUndeletedTrait
|
||||
{
|
||||
|
||||
/**
|
||||
* Prepare a unique_ids rule, adding a model identifier if required.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param string $field
|
||||
* @return string
|
||||
*/
|
||||
protected function prepareUniqueUndeletedRule($parameters, $field)
|
||||
{
|
||||
// Only perform a replacement if the model has been persisted.
|
||||
if ($this->exists) {
|
||||
return 'unique_undeleted:'.$this->table.','. $this->getKey();
|
||||
}
|
||||
|
||||
return 'unique_undeleted:'.$this->table.',0';
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\CheckoutRequest;
|
||||
use App\Models\Location;
|
||||
use App\Models\Statuslabel;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -10,7 +11,7 @@ use App\Models\Location;
|
||||
Route::group([ 'prefix' => 'api', 'middleware' => 'auth' ], function () {
|
||||
|
||||
/*---Hardware API---*/
|
||||
Route::group([ 'prefix' => 'hardware','middleware' => ['web','auth','authorize:hardware']], function () {
|
||||
Route::group([ 'prefix' => 'hardware','middleware' => ['web','auth','authorize:assets.view']], function () {
|
||||
|
||||
Route::get('list/{status?}', [ 'as' => 'api.hardware.list', 'uses' => 'AssetsController@getDatatable' ]);
|
||||
|
||||
@@ -35,6 +36,7 @@ Route::group([ 'prefix' => 'api', 'middleware' => 'auth' ], function () {
|
||||
});
|
||||
|
||||
Route::get('list', [ 'as' => 'api.statuslabels.list', 'uses' => 'StatuslabelsController@getDatatable' ]);
|
||||
Route::get('assets', [ 'as' => 'api.statuslabels.assets', 'uses' => 'StatuslabelsController@getAssetCountByStatuslabel' ]);
|
||||
|
||||
});
|
||||
|
||||
@@ -77,7 +79,7 @@ Route::group([ 'prefix' => 'api', 'middleware' => 'auth' ], function () {
|
||||
/*---Manufacturers API---*/
|
||||
Route::group(array('prefix'=>'manufacturers'), function () {
|
||||
Route::get('list', array('as'=>'api.manufacturers.list', 'uses'=>'ManufacturersController@getDatatable'));
|
||||
Route::get('{manufacturerID}/view', array('as'=>'api.manufacturers.view', 'uses'=>'ManufacturersController@getDataView'));
|
||||
Route::get('{manufacturerID}/view/{itemtype}', array('as'=>'api.manufacturers.view', 'uses'=>'ManufacturersController@getDataView'));
|
||||
});
|
||||
|
||||
/*---Suppliers API---*/
|
||||
@@ -137,14 +139,22 @@ Route::group([ 'prefix' => 'api', 'middleware' => 'auth' ], function () {
|
||||
Route::group([ 'prefix' => 'categories' ], function () {
|
||||
|
||||
Route::get('list', [ 'as' => 'api.categories.list', 'uses' => 'CategoriesController@getDatatable' ]);
|
||||
Route::get( '{categoryID}/asset/view',
|
||||
[ 'as' => 'api.categories.asset.view', 'uses' => 'CategoriesController@getDataViewAssets' ] );
|
||||
Route::get( '{categoryID}/accessory/view',
|
||||
[ 'as' => 'api.categories.accessory.view', 'uses' => 'CategoriesController@getDataViewAccessories' ] );
|
||||
Route::get( '{categoryID}/consumable/view',
|
||||
[ 'as' => 'api.categories.consumable.view', 'uses' => 'CategoriesController@getDataViewConsumables' ] );
|
||||
Route::get( '{categoryID}/component/view',
|
||||
[ 'as' => 'api.categories.component.view', 'uses' => 'CategoriesController@getDataViewComponent' ] );
|
||||
Route::get(
|
||||
'{categoryID}/asset/view',
|
||||
[ 'as' => 'api.categories.asset.view', 'uses' => 'CategoriesController@getDataViewAssets' ]
|
||||
);
|
||||
Route::get(
|
||||
'{categoryID}/accessory/view',
|
||||
[ 'as' => 'api.categories.accessory.view', 'uses' => 'CategoriesController@getDataViewAccessories' ]
|
||||
);
|
||||
Route::get(
|
||||
'{categoryID}/consumable/view',
|
||||
[ 'as' => 'api.categories.consumable.view', 'uses' => 'CategoriesController@getDataViewConsumables' ]
|
||||
);
|
||||
Route::get(
|
||||
'{categoryID}/component/view',
|
||||
[ 'as' => 'api.categories.component.view', 'uses' => 'CategoriesController@getDataViewComponent' ]
|
||||
);
|
||||
});
|
||||
|
||||
/*-- Suppliers API (mostly for creating new ones in-line while creating an asset) --*/
|
||||
@@ -161,7 +171,6 @@ Route::group([ 'prefix' => 'api', 'middleware' => 'auth' ], function () {
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
@@ -176,75 +185,142 @@ Route::group([ 'prefix' => 'api', 'middleware' => 'auth' ], function () {
|
||||
Route::group(
|
||||
[ 'prefix' => 'hardware',
|
||||
'middleware' => ['web',
|
||||
'auth',
|
||||
'authorize:hardware']],
|
||||
'auth']],
|
||||
function () {
|
||||
|
||||
Route::get('history', [
|
||||
'as' => 'asset.import-history',
|
||||
'middleware' => 'authorize:assets.checkout',
|
||||
'uses' => 'AssetsController@getImportHistory'
|
||||
]);
|
||||
|
||||
Route::post('history', [
|
||||
'as' => 'asset.process-import-history',
|
||||
'middleware' => 'authorize:assets.checkout',
|
||||
'uses' => 'AssetsController@postImportHistory'
|
||||
]);
|
||||
|
||||
|
||||
Route::get('create/{model?}', [
|
||||
'as' => 'create/hardware',
|
||||
'middleware' => 'authorize:assets.create',
|
||||
'uses' => 'AssetsController@getCreate'
|
||||
]);
|
||||
|
||||
Route::post('create', [
|
||||
'as' => 'savenew/hardware',
|
||||
'middleware' => 'authorize:assets.create',
|
||||
'uses' => 'AssetsController@postCreate'
|
||||
]);
|
||||
|
||||
Route::get('{assetId}/edit', [
|
||||
'as' => 'update/hardware',
|
||||
'middleware' => 'authorize:assets.edit',
|
||||
'uses' => 'AssetsController@getEdit'
|
||||
]);
|
||||
Route::get('/bytag', [
|
||||
'as' => 'findbytag/hardware',
|
||||
'middleware' => 'authorize:assets.view',
|
||||
'uses' => 'AssetsController@getAssetByTag'
|
||||
]);
|
||||
|
||||
Route::get('{assetId}/clone', [
|
||||
'as' => 'clone/hardware',
|
||||
'middleware' => 'authorize:assets.create',
|
||||
'uses' => 'AssetsController@getClone'
|
||||
]);
|
||||
|
||||
Route::get('{assetId}/clone', [ 'as' => 'clone/hardware', 'uses' => 'AssetsController@getClone' ]);
|
||||
Route::post('{assetId}/clone', 'AssetsController@postCreate');
|
||||
Route::get('{assetId}/delete', [ 'as' => 'delete/hardware', 'uses' => 'AssetsController@getDelete' ]);
|
||||
Route::get(
|
||||
'{assetId}/checkout',
|
||||
[ 'as' => 'checkout/hardware', 'uses' => 'AssetsController@getCheckout' ]
|
||||
);
|
||||
Route::post('{assetId}/checkout', 'AssetsController@postCheckout');
|
||||
Route::get(
|
||||
'{assetId}/checkin/{backto?}',
|
||||
[ 'as' => 'checkin/hardware', 'uses' => 'AssetsController@getCheckin' ]
|
||||
);
|
||||
Route::post('{assetId}/checkin/{backto?}', 'AssetsController@postCheckin');
|
||||
Route::get('{assetId}/view', [ 'as' => 'view/hardware', 'uses' => 'AssetsController@getView' ]);
|
||||
Route::get('{assetId}/delete', [
|
||||
'as' => 'delete/hardware',
|
||||
'middleware' => 'authorize:assets.delete',
|
||||
'uses' => 'AssetsController@getDelete'
|
||||
]);
|
||||
Route::get('{assetId}/checkout', [
|
||||
'as' => 'checkout/hardware',
|
||||
'middleware' => 'authorize:assets.checkout',
|
||||
'uses' => 'AssetsController@getCheckout'
|
||||
]);
|
||||
Route::post('{assetId}/checkout', [
|
||||
'as' => 'checkout/hardware',
|
||||
'middleware' => 'authorize:assets.checkout',
|
||||
'uses' => 'AssetsController@postCheckout'
|
||||
]);
|
||||
Route::get('{assetId}/checkin/{backto?}', [
|
||||
'as' => 'checkin/hardware',
|
||||
'middleware' => 'authorize:assets.checkin',
|
||||
'uses' => 'AssetsController@getCheckin'
|
||||
]);
|
||||
|
||||
Route::post('{assetId}/checkin/{backto?}', [
|
||||
'as' => 'checkin/hardware',
|
||||
'middleware' => 'authorize:assets.checkin',
|
||||
'uses' => 'AssetsController@postCheckin'
|
||||
]);
|
||||
Route::get('{assetId}/view', [
|
||||
'as' => 'view/hardware',
|
||||
'middleware' => ['authorize:assets.view'],
|
||||
'uses' => 'AssetsController@getView'
|
||||
]);
|
||||
Route::get('{assetId}/qr-view', [ 'as' => 'qr-view/hardware', 'uses' => 'AssetsController@getView' ]);
|
||||
Route::get('{assetId}/qr_code', [ 'as' => 'qr_code/hardware', 'uses' => 'AssetsController@getQrCode' ]);
|
||||
Route::get('{assetId}/barcode', [ 'as' => 'barcode/hardware', 'uses' => 'AssetsController@getBarCode' ]);
|
||||
Route::get('{assetId}/restore', [ 'as' => 'restore/hardware', 'uses' => 'AssetsController@getRestore' ]);
|
||||
Route::post('{assetId}/upload', [ 'as' => 'upload/asset', 'uses' => 'AssetsController@postUpload' ]);
|
||||
Route::get(
|
||||
'{assetId}/deletefile/{fileId}',
|
||||
[ 'as' => 'delete/assetfile', 'uses' => 'AssetsController@getDeleteFile' ]
|
||||
);
|
||||
Route::get(
|
||||
'{assetId}/showfile/{fileId}',
|
||||
[ 'as' => 'show/assetfile', 'uses' => 'AssetsController@displayFile' ]
|
||||
);
|
||||
Route::get('{assetId}/restore', [
|
||||
'as' => 'restore/hardware',
|
||||
'middleware' => 'authorize:assets.delete',
|
||||
'uses' => 'AssetsController@getRestore'
|
||||
]);
|
||||
Route::post('{assetId}/upload', [
|
||||
'as' => 'upload/asset',
|
||||
'middleware' => 'authorize:assets.edit',
|
||||
'uses' => 'AssetsController@postUpload'
|
||||
]);
|
||||
|
||||
Route::get(
|
||||
'import/delete-import/{filename}',
|
||||
[ 'as' => 'assets/import/delete-file', 'uses' => 'AssetsController@getDeleteImportFile' ]
|
||||
);
|
||||
Route::get('{assetId}/deletefile/{fileId}', [
|
||||
'as' => 'delete/assetfile',
|
||||
'middleware' => 'authorize:assets.edit',
|
||||
'uses' => 'AssetsController@getDeleteFile'
|
||||
]);
|
||||
|
||||
Route::get(
|
||||
'import/process/{filename}',
|
||||
[ 'as' => 'assets/import/process-file', 'uses' => 'AssetsController@getProcessImportFile' ]
|
||||
);
|
||||
Route::get('{assetId}/showfile/{fileId}', [
|
||||
'as' => 'show/assetfile',
|
||||
'middleware' => 'authorize:assets.view',
|
||||
'uses' => 'AssetsController@displayFile'
|
||||
]);
|
||||
|
||||
Route::get(
|
||||
'import',
|
||||
[ 'as' => 'assets/import', 'uses' => 'AssetsController@getImportUpload' ]
|
||||
);
|
||||
Route::get('import/delete-import/{filename}', [
|
||||
'as' => 'assets/import/delete-file',
|
||||
'middleware' => 'authorize:assets.create',
|
||||
'uses' => 'AssetsController@getDeleteImportFile'
|
||||
]);
|
||||
|
||||
Route::post( 'import/process/', [ 'as' => 'assets/import/process-file',
|
||||
'middleware' => 'authorize:assets.create',
|
||||
'uses' => 'AssetsController@postProcessImportFile'
|
||||
]);
|
||||
Route::get( 'import/delete/{filename}', [ 'as' => 'assets/import/delete-file',
|
||||
'middleware' => 'authorize:assets.create', // TODO What permissions should this require?
|
||||
'uses' => 'AssetsController@getDeleteImportFile'
|
||||
]);
|
||||
|
||||
Route::get('import',[
|
||||
'as' => 'assets/import',
|
||||
'middleware' => 'authorize:assets.create',
|
||||
'uses' => 'AssetsController@getImportUpload'
|
||||
]);
|
||||
|
||||
|
||||
Route::post('{assetId}/edit', 'AssetsController@postEdit');
|
||||
Route::post('{assetId}/edit',[
|
||||
'as' => 'assets/import',
|
||||
'middleware' => 'authorize:assets.edit',
|
||||
'uses' => 'AssetsController@postEdit'
|
||||
]);
|
||||
|
||||
Route::post(
|
||||
'bulkedit',
|
||||
[
|
||||
'as' => 'hardware/bulkedit',
|
||||
'middleware' => 'authorize:assets.edit',
|
||||
'uses' => 'AssetsController@postBulkEdit'
|
||||
]
|
||||
);
|
||||
@@ -252,6 +328,7 @@ Route::group(
|
||||
'bulkdelete',
|
||||
[
|
||||
'as' => 'hardware/bulkdelete',
|
||||
'middleware' => 'authorize:assets.delete',
|
||||
'uses' => 'AssetsController@postBulkDelete'
|
||||
]
|
||||
);
|
||||
@@ -259,10 +336,23 @@ Route::group(
|
||||
'bulksave',
|
||||
[
|
||||
'as' => 'hardware/bulksave',
|
||||
'middleware' => 'authorize:assets.edit',
|
||||
'uses' => 'AssetsController@postBulkSave'
|
||||
]
|
||||
);
|
||||
|
||||
# Bulk checkout / checkin
|
||||
Route::get( 'bulkcheckout', [
|
||||
'as' => 'hardware/bulkcheckout',
|
||||
'middleware' => 'authorize:assets.checkout',
|
||||
'uses' => 'AssetsController@getBulkCheckout'
|
||||
]);
|
||||
Route::post( 'bulkcheckout', [
|
||||
'as' => 'hardware/bulkcheckout',
|
||||
'middleware' => 'authorize:assets.checkout',
|
||||
'uses' => 'AssetsController@postBulkCheckout'
|
||||
]);
|
||||
|
||||
# Asset Model Management
|
||||
Route::group([ 'prefix' => 'models', 'middleware' => 'auth' ], function () {
|
||||
|
||||
@@ -281,6 +371,7 @@ Route::group(
|
||||
|
||||
Route::get('/', [
|
||||
'as' => 'hardware',
|
||||
'middleware' => 'authorize:assets.view',
|
||||
'uses' => 'AssetsController@getIndex'
|
||||
]);
|
||||
|
||||
@@ -296,50 +387,74 @@ Route::group(
|
||||
|
|
||||
*/
|
||||
|
||||
Route::group([ 'prefix' => 'admin','middleware' => ['web','auth','authorize:admin']], function () {
|
||||
Route::group([ 'prefix' => 'admin','middleware' => ['web','auth']], function () {
|
||||
|
||||
Route::get('requests',
|
||||
// foreach( CheckoutRequest::with('user')->get() as $requestedItem) {
|
||||
// echo $requestedItem->user->username . ' requested ' . $requestedItem->requestedItem->name;
|
||||
[
|
||||
'as' => 'requests',
|
||||
'middleware' => 'authorize:admin',
|
||||
'uses' => 'ViewAssetsController@getRequestedIndex'
|
||||
]);
|
||||
# Licenses
|
||||
Route::group([ 'prefix' => 'licenses' ], function () {
|
||||
Route::group([ 'prefix' => 'licenses', 'middleware'=>'authorize:licenses.view' ], function () {
|
||||
|
||||
Route::get('create', [ 'as' => 'create/licenses', 'uses' => 'LicensesController@getCreate' ]);
|
||||
Route::post('create', 'LicensesController@postCreate');
|
||||
Route::get('{licenseId}/edit', [ 'as' => 'update/license', 'uses' => 'LicensesController@getEdit' ]);
|
||||
Route::post('{licenseId}/edit', 'LicensesController@postEdit');
|
||||
Route::get('{licenseId}/clone', [ 'as' => 'clone/license', 'uses' => 'LicensesController@getClone' ]);
|
||||
Route::post('{licenseId}/clone', 'LicensesController@postCreate');
|
||||
Route::get('{licenseId}/delete', [ 'as' => 'delete/license', 'uses' => 'LicensesController@getDelete' ]);
|
||||
Route::get(
|
||||
'{licenseId}/freecheckout',
|
||||
[ 'as' => 'freecheckout/license', 'uses' => 'LicensesController@getFreeLicense' ]
|
||||
);
|
||||
Route::get('create', [ 'as' => 'create/licenses', 'middleware' => 'authorize:licenses.create','uses' => 'LicensesController@getCreate' ]);
|
||||
Route::post('create', [ 'as' => 'create/licenses', 'middleware' => 'authorize:licenses.create','uses' => 'LicensesController@postCreate' ]);
|
||||
Route::get('{licenseId}/edit', [ 'as' => 'update/license', 'middleware' => 'authorize:licenses.edit', 'uses' => 'LicensesController@getEdit' ]);
|
||||
Route::post('{licenseId}/edit', [ 'as' => 'update/license', 'middleware' => 'authorize:licenses.edit', 'uses' => 'LicensesController@postEdit' ]);
|
||||
Route::get('{licenseId}/clone', [ 'as' => 'clone/license', 'middleware' => 'authorize:licenses.create', 'uses' => 'LicensesController@getClone' ]);
|
||||
Route::post('{licenseId}/clone', [ 'as' => 'clone/license', 'middleware' => 'authorize:licenses.create', 'uses' => 'LicensesController@postCreate' ]);
|
||||
Route::get('{licenseId}/delete', [ 'as' => 'delete/license', 'middleware' => 'authorize:licenses.delete', 'uses' => 'LicensesController@getDelete' ]);
|
||||
Route::get('{licenseId}/freecheckout', [
|
||||
'as' => 'freecheckout/license',
|
||||
'middleware' => 'authorize:licenses.checkout',
|
||||
'uses' => 'LicensesController@getFreeLicense'
|
||||
]);
|
||||
Route::get(
|
||||
'{licenseId}/checkout',
|
||||
[ 'as' => 'checkout/license', 'uses' => 'LicensesController@getCheckout' ]
|
||||
[ 'as' => 'checkout/license', 'middleware' => 'authorize:licenses.checkout','uses' => 'LicensesController@getCheckout' ]
|
||||
);
|
||||
Route::post('{licenseId}/checkout', 'LicensesController@postCheckout');
|
||||
Route::get(
|
||||
'{licenseId}/checkin/{backto?}',
|
||||
[ 'as' => 'checkin/license', 'uses' => 'LicensesController@getCheckin' ]
|
||||
Route::post(
|
||||
'{licenseId}/checkout',
|
||||
[ 'as' => 'checkout/license', 'middleware' => 'authorize:licenses.checkout','uses' => 'LicensesController@postCheckout' ]
|
||||
);
|
||||
Route::post('{licenseId}/checkin/{backto?}', 'LicensesController@postCheckin');
|
||||
Route::get('{licenseId}/view', [ 'as' => 'view/license', 'uses' => 'LicensesController@getView' ]);
|
||||
Route::get('{licenseId}/checkin/{backto?}', [
|
||||
'as' => 'checkin/license',
|
||||
'middleware' => 'authorize:licenses.checkin',
|
||||
'uses' => 'LicensesController@getCheckin'
|
||||
]);
|
||||
|
||||
Route::post('{licenseId}/checkin/{backto?}', [
|
||||
'as' => 'checkin/license',
|
||||
'middleware' => 'authorize:licenses.checkin',
|
||||
'uses' => 'LicensesController@postCheckin'
|
||||
]);
|
||||
|
||||
Route::get('{licenseId}/view', [
|
||||
'as' => 'view/license',
|
||||
'middleware' => 'authorize:licenses.view',
|
||||
'uses' => 'LicensesController@getView'
|
||||
]);
|
||||
|
||||
Route::post(
|
||||
'{licenseId}/upload',
|
||||
[ 'as' => 'upload/license', 'uses' => 'LicensesController@postUpload' ]
|
||||
[ 'as' => 'upload/license', 'middleware' => 'authorize:licenses.edit','uses' => 'LicensesController@postUpload' ]
|
||||
);
|
||||
Route::get(
|
||||
'{licenseId}/deletefile/{fileId}',
|
||||
[ 'as' => 'delete/licensefile', 'uses' => 'LicensesController@getDeleteFile' ]
|
||||
[ 'as' => 'delete/licensefile', 'middleware' => 'authorize:licenses.edit', 'uses' => 'LicensesController@getDeleteFile' ]
|
||||
);
|
||||
Route::get(
|
||||
'{licenseId}/showfile/{fileId}',
|
||||
[ 'as' => 'show/licensefile', 'uses' => 'LicensesController@displayFile' ]
|
||||
[ 'as' => 'show/licensefile', 'middleware' => 'authorize:licenses.view','uses' => 'LicensesController@displayFile' ]
|
||||
);
|
||||
Route::get('/', [ 'as' => 'licenses', 'uses' => 'LicensesController@getIndex' ]);
|
||||
Route::get('/', [ 'as' => 'licenses', 'middleware' => 'authorize:licenses.view','uses' => 'LicensesController@getIndex' ]);
|
||||
});
|
||||
|
||||
# Asset Maintenances
|
||||
Route::group([ 'prefix' => 'asset_maintenances' ], function () {
|
||||
Route::group([ 'prefix' => 'asset_maintenances', 'middleware'=>'authorize:assets.view' ], function () {
|
||||
|
||||
Route::get(
|
||||
'create/{assetId?}',
|
||||
@@ -363,90 +478,109 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth','authorize:admi
|
||||
});
|
||||
|
||||
# Accessories
|
||||
Route::group([ 'prefix' => 'accessories' ], function () {
|
||||
Route::group([ 'prefix' => 'accessories', 'middleware'=>'authorize:accessories.view' ], function () {
|
||||
|
||||
Route::get('create', [ 'as' => 'create/accessory', 'uses' => 'AccessoriesController@getCreate' ]);
|
||||
Route::get('create', [ 'as' => 'create/accessory', 'middleware' => 'authorize:accessories.create','uses' => 'AccessoriesController@getCreate' ]);
|
||||
Route::post('create', 'AccessoriesController@postCreate');
|
||||
Route::get(
|
||||
'{accessoryID}/edit',
|
||||
[ 'as' => 'update/accessory', 'uses' => 'AccessoriesController@getEdit' ]
|
||||
[ 'as' => 'update/accessory', 'middleware' => 'authorize:accessories.edit','uses' => 'AccessoriesController@getEdit' ]
|
||||
);
|
||||
Route::post('{accessoryID}/edit', 'AccessoriesController@postEdit');
|
||||
Route::get(
|
||||
'{accessoryID}/delete',
|
||||
[ 'as' => 'delete/accessory', 'uses' => 'AccessoriesController@getDelete' ]
|
||||
[ 'as' => 'delete/accessory', 'middleware' => 'authorize:accessories.delete','uses' => 'AccessoriesController@getDelete' ]
|
||||
);
|
||||
Route::get('{accessoryID}/view', [ 'as' => 'view/accessory', 'uses' => 'AccessoriesController@getView' ]);
|
||||
Route::get('{accessoryID}/view', [ 'as' => 'view/accessory', 'middleware' => 'authorize:accessories.view','uses' => 'AccessoriesController@getView' ]);
|
||||
Route::get(
|
||||
'{accessoryID}/checkout',
|
||||
[ 'as' => 'checkout/accessory', 'uses' => 'AccessoriesController@getCheckout' ]
|
||||
[ 'as' => 'checkout/accessory', 'middleware' => 'authorize:accessories.checkout','uses' => 'AccessoriesController@getCheckout' ]
|
||||
);
|
||||
Route::post('{accessoryID}/checkout', 'AccessoriesController@postCheckout');
|
||||
Route::post(
|
||||
'{accessoryID}/checkout',
|
||||
[ 'as' => 'checkout/accessory', 'middleware' => 'authorize:accessories.checkout','uses' => 'AccessoriesController@postCheckout' ]
|
||||
);
|
||||
|
||||
Route::get(
|
||||
'{accessoryID}/checkin/{backto?}',
|
||||
[ 'as' => 'checkin/accessory', 'uses' => 'AccessoriesController@getCheckin' ]
|
||||
[ 'as' => 'checkin/accessory', 'middleware' => 'authorize:accessories.checkin','uses' => 'AccessoriesController@getCheckin' ]
|
||||
);
|
||||
Route::post(
|
||||
'{accessoryID}/checkin/{backto?}',
|
||||
[ 'as' => 'checkin/accessory', 'middleware' => 'authorize:accessories.checkin','uses' => 'AccessoriesController@postCheckin' ]
|
||||
);
|
||||
Route::post('{accessoryID}/checkin/{backto?}', 'AccessoriesController@postCheckin');
|
||||
|
||||
Route::get('/', [ 'as' => 'accessories', 'uses' => 'AccessoriesController@getIndex' ]);
|
||||
Route::get('/', [ 'as' => 'accessories', 'middleware'=>'authorize:accessories.view', 'uses' => 'AccessoriesController@getIndex' ]);
|
||||
});
|
||||
|
||||
# Consumables
|
||||
Route::group([ 'prefix' => 'consumables' ], function () {
|
||||
Route::group([ 'prefix' => 'consumables', 'middleware'=>'authorize:consumables.view' ], function () {
|
||||
|
||||
Route::get('create', [ 'as' => 'create/consumable', 'uses' => 'ConsumablesController@getCreate' ]);
|
||||
Route::post('create', 'ConsumablesController@postCreate');
|
||||
Route::get('create', [ 'as' => 'create/consumable','middleware'=>'authorize:consumables.create', 'uses' => 'ConsumablesController@getCreate' ]);
|
||||
Route::post('create', [ 'as' => 'create/consumable','middleware'=>'authorize:consumables.create', 'uses' => 'ConsumablesController@postCreate' ]);
|
||||
Route::get(
|
||||
'{consumableID}/edit',
|
||||
[ 'as' => 'update/consumable', 'uses' => 'ConsumablesController@getEdit' ]
|
||||
[ 'as' => 'update/consumable', 'middleware'=>'authorize:consumables.edit', 'uses' => 'ConsumablesController@getEdit' ]
|
||||
);
|
||||
Route::post(
|
||||
'{consumableID}/edit',
|
||||
[ 'as' => 'update/consumable', 'middleware'=>'authorize:consumables.edit', 'uses' => 'ConsumablesController@postEdit' ]
|
||||
);
|
||||
Route::post('{consumableID}/edit', 'ConsumablesController@postEdit');
|
||||
Route::get(
|
||||
'{consumableID}/delete',
|
||||
[ 'as' => 'delete/consumable', 'uses' => 'ConsumablesController@getDelete' ]
|
||||
[ 'as' => 'delete/consumable', 'middleware'=>'authorize:consumables.delete','uses' => 'ConsumablesController@getDelete' ]
|
||||
);
|
||||
Route::get(
|
||||
'{consumableID}/view',
|
||||
[ 'as' => 'view/consumable', 'uses' => 'ConsumablesController@getView' ]
|
||||
[ 'as' => 'view/consumable', 'middleware'=>'authorize:consumables.view','uses' => 'ConsumablesController@getView' ]
|
||||
);
|
||||
Route::get(
|
||||
'{consumableID}/checkout',
|
||||
[ 'as' => 'checkout/consumable', 'uses' => 'ConsumablesController@getCheckout' ]
|
||||
[ 'as' => 'checkout/consumable', 'middleware'=>'authorize:consumables.checkout','uses' => 'ConsumablesController@getCheckout' ]
|
||||
);
|
||||
Route::post('{consumableID}/checkout', 'ConsumablesController@postCheckout');
|
||||
Route::get('/', [ 'as' => 'consumables', 'uses' => 'ConsumablesController@getIndex' ]);
|
||||
Route::post(
|
||||
'{consumableID}/checkout',
|
||||
[ 'as' => 'checkout/consumable', 'middleware'=>'authorize:consumables.checkout','uses' => 'ConsumablesController@postCheckout' ]
|
||||
);
|
||||
Route::get('/', [ 'as' => 'consumables', 'middleware'=>'authorize:consumables.view','uses' => 'ConsumablesController@getIndex' ]);
|
||||
});
|
||||
|
||||
# Components
|
||||
Route::group([ 'prefix' => 'components' ], function () {
|
||||
Route::group([ 'prefix' => 'components', 'middleware'=>'authorize:components.view' ], function () {
|
||||
|
||||
Route::get('create', [ 'as' => 'create/component', 'uses' => 'ComponentsController@getCreate' ]);
|
||||
Route::post('create', 'ComponentsController@postCreate');
|
||||
Route::get('create', [ 'as' => 'create/component', 'middleware'=>'authorize:components.create','uses' => 'ComponentsController@getCreate' ]);
|
||||
Route::post('create', [ 'as' => 'create/component', 'middleware'=>'authorize:components.create','uses' => 'ComponentsController@postCreate' ]);
|
||||
Route::get(
|
||||
'{componentID}/edit',
|
||||
[ 'as' => 'update/component', 'uses' => 'ComponentsController@getEdit' ]
|
||||
[ 'as' => 'update/component', 'middleware'=>'authorize:components.edit','uses' => 'ComponentsController@getEdit' ]
|
||||
);
|
||||
Route::post(
|
||||
'{componentID}/edit',
|
||||
[ 'as' => 'update/component', 'middleware'=>'authorize:components.edit','uses' => 'ComponentsController@postEdit' ]
|
||||
);
|
||||
Route::post('{componentID}/edit', 'ComponentsController@postEdit');
|
||||
Route::get(
|
||||
'{componentID}/delete',
|
||||
[ 'as' => 'delete/component', 'uses' => 'ComponentsController@getDelete' ]
|
||||
[ 'as' => 'delete/component', 'middleware'=>'authorize:components.delete','uses' => 'ComponentsController@getDelete' ]
|
||||
);
|
||||
Route::get(
|
||||
'{componentID}/view',
|
||||
[ 'as' => 'view/component', 'uses' => 'ComponentsController@getView' ]
|
||||
[ 'as' => 'view/component', 'middleware'=>'authorize:components.view','uses' => 'ComponentsController@getView' ]
|
||||
);
|
||||
Route::get(
|
||||
'{componentID}/checkout',
|
||||
[ 'as' => 'checkout/component', 'uses' => 'ComponentsController@getCheckout' ]
|
||||
[ 'as' => 'checkout/component', 'middleware'=>'authorize:components.checkout','uses' => 'ComponentsController@getCheckout' ]
|
||||
);
|
||||
Route::post('{componentID}/checkout', 'ComponentsController@postCheckout');
|
||||
Route::post('bulk', [ 'as' => 'component/bulk-form', 'uses' => 'ComponentsController@postBulk' ]);
|
||||
Route::post('bulksave', [ 'as' => 'component/bulk-save', 'uses' => 'ComponentsController@postBulkSave' ]);
|
||||
Route::get('/', [ 'as' => 'components', 'uses' => 'ComponentsController@getIndex' ]);
|
||||
Route::post(
|
||||
'{componentID}/checkout',
|
||||
[ 'as' => 'checkout/component', 'middleware'=>'authorize:components.checkout','uses' => 'ComponentsController@postCheckout' ]
|
||||
);
|
||||
Route::post('bulk', [ 'as' => 'component/bulk-form', 'middleware'=>'authorize:components.checkout','uses' => 'ComponentsController@postBulk' ]);
|
||||
Route::post('bulksave', [ 'as' => 'component/bulk-save', 'middleware'=>'authorize:components.edit','uses' => 'ComponentsController@postBulkSave' ]);
|
||||
Route::get('/', [ 'as' => 'components', 'middleware'=>'authorize:components.view','uses' => 'ComponentsController@getIndex' ]);
|
||||
});
|
||||
|
||||
# Admin Settings Routes (for categories, maufactureres, etc)
|
||||
Route::group([ 'prefix' => 'settings'], function () {
|
||||
Route::group([ 'prefix' => 'settings', 'middleware'=>'authorize:superuser'], function () {
|
||||
|
||||
|
||||
|
||||
@@ -454,12 +588,19 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth','authorize:admi
|
||||
Route::group([ 'prefix' => 'app' ], function () {
|
||||
|
||||
Route::post('purge', ['as' => 'purge', 'uses' => 'SettingsController@postPurge']);
|
||||
|
||||
Route::get('/', [ 'as' => 'app', 'uses' => 'SettingsController@getIndex' ]);
|
||||
Route::get('edit', [ 'as' => 'edit/settings', 'uses' => 'SettingsController@getEdit' ]);
|
||||
Route::post('edit', 'SettingsController@postEdit');
|
||||
|
||||
Route::get('ldaptest', [
|
||||
'as' => 'settings/ldaptest',
|
||||
'uses' => 'SettingsController@getLdapTest'
|
||||
]);
|
||||
|
||||
Route::get('/', [ 'as' => 'app', 'uses' => 'SettingsController@getIndex' ]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
# Settings
|
||||
Route::group([ 'prefix' => 'backups', 'middleware' => 'auth' ], function () {
|
||||
|
||||
@@ -476,6 +617,8 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth','authorize:admi
|
||||
'as' => 'settings/backups',
|
||||
'uses' => 'SettingsController@postBackups'
|
||||
]);
|
||||
|
||||
|
||||
Route::get('/', [ 'as' => 'settings/backups', 'uses' => 'SettingsController@getBackups' ]);
|
||||
});
|
||||
|
||||
@@ -617,27 +760,28 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth','authorize:admi
|
||||
Route::get('custom_fields/create-field', ['uses' =>'CustomFieldsController@createField','as' => 'admin.custom_fields.create-field']);
|
||||
Route::post('custom_fields/create-field', ['uses' => 'CustomFieldsController@storeField','as' => 'admin.custom_fields.store-field']);
|
||||
Route::post('custom_fields/{id}/associate', ['uses' => 'CustomFieldsController@associate','as' => 'admin.custom_fields.associate']);
|
||||
Route::get('custom_fields/{field_id}/{fieldset_id}/disassociate', ['uses' => 'CustomFieldsController@deleteFieldFromFieldset','as' => 'admin.custom_fields.disassociate']);
|
||||
Route::match(['DELETE'], 'custom_fields/delete-field/{id}', ['uses' => 'CustomFieldsController@deleteField','as' => 'admin.custom_fields.delete-field']);
|
||||
Route::resource('custom_fields', 'CustomFieldsController');
|
||||
|
||||
# User Management
|
||||
Route::group([ 'prefix' => 'users' ], function () {
|
||||
Route::group([ 'prefix' => 'users', 'middleware' => ['web','auth','authorize:users.view']], function () {
|
||||
|
||||
Route::get('ldap', ['as' => 'ldap/user', 'uses' => 'UsersController@getLDAP' ]);
|
||||
Route::get('ldap', ['as' => 'ldap/user', 'uses' => 'UsersController@getLDAP', 'middleware' => ['authorize:users.edit'] ]);
|
||||
Route::post('ldap', 'UsersController@postLDAP');
|
||||
|
||||
Route::get('create', [ 'as' => 'create/user', 'uses' => 'UsersController@getCreate' ]);
|
||||
Route::post('create', 'UsersController@postCreate');
|
||||
Route::get('import', [ 'as' => 'import/user', 'uses' => 'UsersController@getImport' ]);
|
||||
Route::post('import', 'UsersController@postImport');
|
||||
Route::get('{userId}/edit', [ 'as' => 'update/user', 'uses' => 'UsersController@getEdit' ]);
|
||||
Route::post('{userId}/edit', 'UsersController@postEdit');
|
||||
Route::get('{userId}/clone', [ 'as' => 'clone/user', 'uses' => 'UsersController@getClone' ]);
|
||||
Route::post('{userId}/clone', 'UsersController@postCreate');
|
||||
Route::get('{userId}/delete', [ 'as' => 'delete/user', 'uses' => 'UsersController@getDelete' ]);
|
||||
Route::get('{userId}/restore', [ 'as' => 'restore/user', 'uses' => 'UsersController@getRestore' ]);
|
||||
Route::get('{userId}/view', [ 'as' => 'view/user', 'uses' => 'UsersController@getView' ]);
|
||||
Route::get('{userId}/unsuspend', [ 'as' => 'unsuspend/user', 'uses' => 'UsersController@getUnsuspend' ]);
|
||||
Route::get('create', [ 'as' => 'create/user', 'uses' => 'UsersController@getCreate', 'middleware' => ['authorize:users.edit'] ]);
|
||||
Route::post('create', [ 'uses' => 'UsersController@postCreate', 'middleware' => ['authorize:users.edit'] ]);
|
||||
Route::get('import', [ 'as' => 'import/user', 'uses' => 'UsersController@getImport', 'middleware' => ['authorize:users.edit'] ]);
|
||||
Route::post('import', [ 'uses' => 'UsersController@postImport', 'middleware' => ['authorize:users.edit'] ]);
|
||||
Route::get('{userId}/edit', [ 'as' => 'update/user', 'uses' => 'UsersController@getEdit', 'middleware' => ['authorize:users.edit'] ]);
|
||||
Route::post('{userId}/edit', [ 'uses' => 'UsersController@postEdit', 'middleware' => ['authorize:users.edit'] ]);
|
||||
Route::get('{userId}/clone', [ 'as' => 'clone/user', 'uses' => 'UsersController@getClone', 'middleware' => ['authorize:users.edit'] ]);
|
||||
Route::post('{userId}/clone', [ 'uses' => 'UsersController@postCreate', 'middleware' => ['authorize:users.edit'] ]);
|
||||
Route::get('{userId}/delete', [ 'as' => 'delete/user', 'uses' => 'UsersController@getDelete', 'middleware' => ['authorize:users.edit'] ]);
|
||||
Route::get('{userId}/restore', [ 'as' => 'restore/user', 'uses' => 'UsersController@getRestore', 'middleware' => ['authorize:users.edit'] ]);
|
||||
Route::get('{userId}/view', [ 'as' => 'view/user', 'uses' => 'UsersController@getView' , 'middleware' => ['authorize:users.view'] ]);
|
||||
Route::get('{userId}/unsuspend', [ 'as' => 'unsuspend/user', 'uses' => 'UsersController@getUnsuspend', 'middleware' => ['authorize:users.edit'] ]);
|
||||
Route::get(
|
||||
'{userId}/deletefile/{fileId}',
|
||||
[ 'as' => 'delete/userfile', 'uses' => 'UsersController@getDeleteFile' ]
|
||||
@@ -651,14 +795,16 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth','authorize:admi
|
||||
'bulkedit',
|
||||
[
|
||||
'as' => 'users/bulkedit',
|
||||
'uses' => 'UsersController@postBulkEdit'
|
||||
'uses' => 'UsersController@postBulkEdit',
|
||||
'middleware' => ['authorize:users.edit'],
|
||||
]
|
||||
);
|
||||
Route::post(
|
||||
'bulksave',
|
||||
[
|
||||
'as' => 'users/bulksave',
|
||||
'uses' => 'UsersController@postBulkSave'
|
||||
'uses' => 'UsersController@postBulkSave',
|
||||
'middleware' => ['authorize:users.edit'],
|
||||
]
|
||||
);
|
||||
|
||||
@@ -667,7 +813,7 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth','authorize:admi
|
||||
});
|
||||
|
||||
# Group Management
|
||||
Route::group([ 'prefix' => 'groups' ], function () {
|
||||
Route::group([ 'prefix' => 'groups', 'middleware' => ['web','auth','authorize:superadmin'] ], function () {
|
||||
|
||||
Route::get('/', [ 'as' => 'groups', 'uses' => 'GroupsController@getIndex' ]);
|
||||
Route::get('create', [ 'as' => 'create/group', 'uses' => 'GroupsController@getCreate' ]);
|
||||
@@ -721,13 +867,18 @@ Route::group([ 'prefix' => 'account', 'middleware' => ['web', 'auth']], function
|
||||
[ 'as' => 'account/request-asset', 'uses' => 'ViewAssetsController@getRequestAsset' ]
|
||||
);
|
||||
|
||||
Route::post(
|
||||
'request/{itemType}/{itemId}',
|
||||
[ 'as' => 'account/request-item', 'uses' => 'ViewAssetsController@getRequestItem']
|
||||
);
|
||||
|
||||
# Account Dashboard
|
||||
Route::get('/', [ 'as' => 'account', 'uses' => 'ProfileController@getDashboard' ]);
|
||||
Route::get('/', [ 'as' => 'account', 'uses' => 'ViewAssetsController@getIndex' ]);
|
||||
|
||||
});
|
||||
|
||||
|
||||
Route::group(['middleware' => ['web','auth','authorize:reports']], function () {
|
||||
Route::group(['middleware' => ['web','auth','authorize:reports.view']], function () {
|
||||
|
||||
Route::get(
|
||||
'reports/depreciation',
|
||||
@@ -773,6 +924,12 @@ Route::group(['middleware' => ['web','auth','authorize:reports']], function () {
|
||||
'reports/activity',
|
||||
[ 'as' => 'reports/activity', 'uses' => 'ReportsController@getActivityReport' ]
|
||||
);
|
||||
|
||||
Route::get(
|
||||
'reports/activity/json',
|
||||
[ 'as' => 'api.activity.list', 'uses' => 'ReportsController@getActivityReportDataTable' ]
|
||||
);
|
||||
|
||||
Route::get(
|
||||
'reports/unaccepted_assets',
|
||||
[ 'as' => 'reports/unaccepted_assets', 'uses' => 'ReportsController@getAssetAcceptanceReport' ]
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Loggable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Model for Accessories.
|
||||
*
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class Accessory extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableTrait;
|
||||
use Loggable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'accessories';
|
||||
@@ -22,11 +24,12 @@ class Accessory extends Model
|
||||
* Accessory validation rules
|
||||
*/
|
||||
public $rules = array(
|
||||
'name' => 'required|min:3|max:255',
|
||||
'qty' => 'required|integer|min:1',
|
||||
'category_id' => 'required|integer',
|
||||
'company_id' => 'integer',
|
||||
'min_amt' => 'integer|min:1',
|
||||
'name' => 'required|min:3|max:255',
|
||||
'qty' => 'required|integer|min:1',
|
||||
'category_id' => 'required|integer',
|
||||
'company_id' => 'integer',
|
||||
'min_amt' => 'integer|min:1',
|
||||
'purchase_cost' => 'numeric',
|
||||
);
|
||||
|
||||
|
||||
@@ -67,7 +70,7 @@ class Accessory extends Model
|
||||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'accessory_id')->where('asset_type', '=', 'accessory')->orderBy('created_at', 'desc')->withTrashed();
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')->where('item_type', Accessory::class)->orderBy('created_at', 'desc')->withTrashed();
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +84,11 @@ class Accessory extends Model
|
||||
return $this->belongsToMany('\App\Models\User', 'accessories_users', 'accessory_id', 'assigned_to')->count();
|
||||
}
|
||||
|
||||
public function manufacturer()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Manufacturer', 'manufacturer_id');
|
||||
}
|
||||
|
||||
public function checkin_email()
|
||||
{
|
||||
return $this->category->checkin_email;
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Model for the Actionlog (the table that keeps a historical log of
|
||||
@@ -12,88 +13,74 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class Actionlog extends Model implements ICompanyableChild
|
||||
class Actionlog extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableChildTrait;
|
||||
|
||||
protected $dates = [ 'deleted_at' ];
|
||||
|
||||
protected $table = 'asset_logs';
|
||||
protected $table = 'action_logs';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [ 'created_at', 'asset_type' ];
|
||||
protected $fillable = [ 'created_at', 'item_type','user_id','item_id','action_type','note','target_id', 'target_type' ];
|
||||
|
||||
public function getCompanyableParents()
|
||||
// Overridden from Builder to automatically add the company
|
||||
public static function boot()
|
||||
{
|
||||
return [ 'accessorylog', 'assetlog', 'licenselog', 'consumablelog' ];
|
||||
parent::boot();
|
||||
static::creating( function (Actionlog $actionlog) {
|
||||
// If the admin is a superadmin, let's see if the target instead has a company.
|
||||
if (Auth::user() && Auth::user()->isSuperUser()) {
|
||||
$actionlog->company_id = $actionlog->target->company_id;
|
||||
} else if (Auth::user() && Auth::user()->company) {
|
||||
$actionlog->company_id = Auth::user()->company_id;
|
||||
}
|
||||
});
|
||||
}
|
||||
// Eloquent Relationships below
|
||||
public function item()
|
||||
{
|
||||
return $this->morphTo('item')->withTrashed();
|
||||
}
|
||||
|
||||
public function assetlog()
|
||||
public function itemType()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\Asset', 'asset_id')
|
||||
->withTrashed();
|
||||
if($this->item_type == AssetModel::class) {
|
||||
return "model";
|
||||
}
|
||||
return camel_case(class_basename($this->item_type));
|
||||
}
|
||||
|
||||
public function uploads()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\Asset', 'asset_id')
|
||||
return $this->morphTo('item')
|
||||
->where('action_type', '=', 'uploaded')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function licenselog()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\License', 'asset_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function componentlog()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\Component', 'component_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function accessorylog()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\Accessory', 'accessory_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function consumablelog()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\Consumable', 'consumable_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function adminlog()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\User', 'user_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function userlog()
|
||||
{
|
||||
return $this->target();
|
||||
}
|
||||
|
||||
return $this->belongsTo('\App\Models\User', 'checkedout_to')
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function target()
|
||||
{
|
||||
return $this->morphTo('target');
|
||||
}
|
||||
|
||||
public function childlogs()
|
||||
{
|
||||
|
||||
return $this->hasMany('\App\Models\ActionLog', 'thread_id');
|
||||
}
|
||||
|
||||
public function parentlog()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\ActionLog', 'thread_id');
|
||||
}
|
||||
|
||||
@@ -134,44 +121,10 @@ class Actionlog extends Model implements ICompanyableChild
|
||||
public function getListingOfActionLogsChronologicalOrder()
|
||||
{
|
||||
|
||||
return DB::table('asset_logs')
|
||||
->select('*')
|
||||
return $this->all()
|
||||
->where('action_type', '!=', 'uploaded')
|
||||
->orderBy('asset_id', 'asc')
|
||||
->orderBy('item_id', 'asc')
|
||||
->orderBy('created_at', 'asc')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* getLatestCheckoutActionForAssets
|
||||
*
|
||||
* @return mixed
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public function getLatestCheckoutActionForAssets()
|
||||
{
|
||||
|
||||
return DB::table('asset_logs')
|
||||
->select(DB::raw('asset_id, MAX(created_at) as last_created'))
|
||||
->where('action_type', '=', 'checkout')
|
||||
->groupBy('asset_id')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* scopeCheckoutWithoutAcceptance
|
||||
*
|
||||
* @param $query
|
||||
*
|
||||
* @return mixed
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public function scopeCheckoutWithoutAcceptance($query)
|
||||
{
|
||||
|
||||
return $query->where('action_type', '=', 'checkout')
|
||||
->where('accepted_id', '=', null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Traits\UniqueUndeletedTrait;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Company;
|
||||
use App\Models\Location;
|
||||
use App\Models\Loggable;
|
||||
use App\Models\Requestable;
|
||||
use App\Models\Setting;
|
||||
use Auth;
|
||||
use Config;
|
||||
use DateTime;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Log;
|
||||
use Parsedown;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use DateTime;
|
||||
use App\Models\Setting;
|
||||
use App\Helpers\Helper;
|
||||
|
||||
/**
|
||||
* Model for Assets.
|
||||
@@ -21,7 +25,9 @@ use App\Helpers\Helper;
|
||||
*/
|
||||
class Asset extends Depreciable
|
||||
{
|
||||
use Loggable;
|
||||
use SoftDeletes;
|
||||
use Requestable;
|
||||
|
||||
/**
|
||||
* The database table used by the model.
|
||||
@@ -39,6 +45,7 @@ class Asset extends Depreciable
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
use UniqueUndeletedTrait;
|
||||
|
||||
protected $rules = [
|
||||
'name' => 'min:2|max:255',
|
||||
@@ -50,8 +57,9 @@ class Asset extends Depreciable
|
||||
'checkout_date' => 'date|max:10|min:10',
|
||||
'checkin_date' => 'date|max:10|min:10',
|
||||
'supplier_id' => 'integer',
|
||||
'asset_tag' => 'required|min:2|max:255|unique:assets,asset_tag,NULL,deleted_at',
|
||||
'asset_tag' => 'required|min:1|max:255|unique_undeleted',
|
||||
'status' => 'integer',
|
||||
'purchase_cost' => 'numeric',
|
||||
];
|
||||
|
||||
|
||||
@@ -69,20 +77,36 @@ class Asset extends Depreciable
|
||||
}
|
||||
|
||||
|
||||
public function availableForCheckout()
|
||||
{
|
||||
return (
|
||||
empty($this->assigned_to) &&
|
||||
$this->assetstatus->deployable == 1 &&
|
||||
empty($this->deleted_at)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkout asset
|
||||
*/
|
||||
public function checkOutToUser($user, $admin, $checkout_at = null, $expected_checkin = null, $note = null, $name = null)
|
||||
{
|
||||
if (!$user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($expected_checkin) {
|
||||
$this->expected_checkin = $expected_checkin ;
|
||||
$this->expected_checkin = $expected_checkin;
|
||||
}
|
||||
|
||||
$this->last_checkout = $checkout_at;
|
||||
|
||||
$this->assigneduser()->associate($user);
|
||||
$this->name = $name;
|
||||
|
||||
if($name != null)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
@@ -90,17 +114,15 @@ class Asset extends Depreciable
|
||||
$this->accepted="pending";
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ($this->save()) {
|
||||
|
||||
// $action, $admin, $user, $expected_checkin = null, $note = null, $checkout_at = null
|
||||
$log_id = $this->createLogRecord('checkout', $this, $admin, $user, $expected_checkin, $note, $checkout_at);
|
||||
$log = $this->createLogRecord('checkout', $this, $admin, $user, $expected_checkin, $note, $checkout_at);
|
||||
|
||||
if ((($this->requireAcceptance()=='1') || ($this->getEula())) && ($user->email!='')) {
|
||||
$this->checkOutNotifyMail($log_id, $user, $checkout_at, $expected_checkin, $note);
|
||||
$this->checkOutNotifyMail($log->id, $user, $checkout_at, $expected_checkin, $note);
|
||||
}
|
||||
|
||||
if ($settings->slack_endpoint) {
|
||||
@@ -130,7 +152,8 @@ class Asset extends Depreciable
|
||||
|
||||
\Mail::send('emails.accept-asset', $data, function ($m) use ($user) {
|
||||
$m->to($user->email, $user->first_name . ' ' . $user->last_name);
|
||||
$m->subject('Confirm asset delivery');
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.Confirm_asset_delivery'));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -155,7 +178,7 @@ class Asset extends Depreciable
|
||||
'fields' => [
|
||||
[
|
||||
'title' => 'Checked Out:',
|
||||
'value' => 'HARDWARE asset <'.config('app.url').'/hardware/'.$this->id.'/view'.'|'.$this->showAssetName().'> checked out to <'.config('app.url').'/admin/users/'.$this->assigned_to.'/view|'.$this->assigneduser->fullName().'> by <'.config('app.url').'/hardware/'.$this->id.'/view'.'|'.$admin->fullName().'>.'
|
||||
'value' => 'HARDWARE asset <'.config('app.url').'/hardware/'.$this->id.'/view'.'|'.$this->showAssetName().'> checked out to <'.config('app.url').'/admin/users/'.$this->assigned_to.'/view|'.$this->assigneduser->fullName().'> by <'.config('app.url').'/admin/users/'.Auth::user()->id.'/view'.'|'.$admin->fullName().'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
@@ -165,13 +188,22 @@ class Asset extends Depreciable
|
||||
])->send('Asset Checked Out');
|
||||
|
||||
} catch (Exception $e) {
|
||||
print_r($e);
|
||||
LOG::error($e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getDetailedNameAttribute()
|
||||
{
|
||||
if ($this->assignedUser) {
|
||||
$user_name = $this->assignedUser->fullName();
|
||||
} else {
|
||||
$user_name = "Unassigned";
|
||||
}
|
||||
return $this->asset_tag . ' - ' . $this->name . ' (' . $user_name . ') ' . $this->model->name;
|
||||
}
|
||||
public function validationRules($id = '0')
|
||||
{
|
||||
return $this->rules;
|
||||
@@ -182,10 +214,12 @@ class Asset extends Depreciable
|
||||
{
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $this->id;
|
||||
$logaction->checkedout_to = $this->assigned_to;
|
||||
$logaction->asset_type = 'hardware';
|
||||
$logaction->item_type = Asset::class;
|
||||
$logaction->item_id = $this->id;
|
||||
$logaction->target_type = User::class;
|
||||
$logaction->target_id = $this->assigned_to;
|
||||
$logaction->note = $note;
|
||||
$logaction->user_id = $admin->id;
|
||||
if ($checkout_at!='') {
|
||||
$logaction->created_at = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', date('Y-m-d H:i:s', strtotime($checkout_at)));
|
||||
} else {
|
||||
@@ -198,15 +232,10 @@ class Asset extends Depreciable
|
||||
}
|
||||
} else {
|
||||
// Update the asset data to null, since it's being checked in
|
||||
$logaction->checkedout_to = $asset->assigned_to;
|
||||
$logaction->checkedout_to = '';
|
||||
$logaction->asset_id = $asset->id;
|
||||
$logaction->target_id = '';
|
||||
$logaction->location_id = null;
|
||||
$logaction->asset_type = 'hardware';
|
||||
$logaction->note = $note;
|
||||
$logaction->user_id = $admin->id;
|
||||
}
|
||||
$logaction->adminlog()->associate($admin);
|
||||
$logaction->user()->associate($admin);
|
||||
$log = $logaction->logaction($action);
|
||||
|
||||
return $logaction;
|
||||
@@ -243,8 +272,8 @@ class Asset extends Depreciable
|
||||
public function uploads()
|
||||
{
|
||||
|
||||
return $this->hasMany('\App\Models\Actionlog', 'asset_id')
|
||||
->where('asset_type', '=', 'hardware')
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')
|
||||
->where('item_type', '=', Asset::class)
|
||||
->where('action_type', '=', 'uploaded')
|
||||
->whereNotNull('filename')
|
||||
->orderBy('created_at', 'desc');
|
||||
@@ -281,8 +310,8 @@ class Asset extends Depreciable
|
||||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'asset_id')
|
||||
->where('asset_type', '=', 'hardware')
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')
|
||||
->where('item_type', '=', Asset::class)
|
||||
->orderBy('created_at', 'desc')
|
||||
->withTrashed();
|
||||
}
|
||||
@@ -318,7 +347,7 @@ class Asset extends Depreciable
|
||||
public static function assetcount()
|
||||
{
|
||||
|
||||
return Asset::where('physical', '=', '1')
|
||||
return Company::scopeCompanyables(Asset::where('physical', '=', '1'))
|
||||
->whereNull('deleted_at', 'and')
|
||||
->count();
|
||||
}
|
||||
@@ -348,7 +377,7 @@ class Asset extends Depreciable
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total assets
|
||||
* Get asset status
|
||||
*/
|
||||
public function assetstatus()
|
||||
{
|
||||
@@ -362,7 +391,10 @@ class Asset extends Depreciable
|
||||
{
|
||||
|
||||
if ($this->name == '') {
|
||||
return $this->model->name;
|
||||
if ($this->model) {
|
||||
return $this->model->name.' ('.$this->asset_tag.')';
|
||||
}
|
||||
return $this->asset_tag;
|
||||
} else {
|
||||
return $this->name;
|
||||
}
|
||||
@@ -452,13 +484,24 @@ class Asset extends Depreciable
|
||||
$asset_tag = \DB::table('assets')
|
||||
->where('physical', '=', '1')
|
||||
->max('id');
|
||||
|
||||
if ($settings->zerofill_count > 0) {
|
||||
return $settings->auto_increment_prefix.Asset::zerofill(($asset_tag + 1),$settings->zerofill_count);
|
||||
}
|
||||
return $settings->auto_increment_prefix.($asset_tag + 1);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkin_email()
|
||||
|
||||
public static function zerofill ($num, $zerofill = 3)
|
||||
{
|
||||
return str_pad($num, $zerofill, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
|
||||
public function checkin_email()
|
||||
{
|
||||
return $this->model->category->checkin_email;
|
||||
}
|
||||
@@ -534,13 +577,13 @@ class Asset extends Depreciable
|
||||
|
||||
public function scopeAssetsByLocation($query, $location)
|
||||
{
|
||||
return $query->where(function ($query) use ($location)
|
||||
{
|
||||
$query->whereHas('assigneduser', function ($query) use ($location)
|
||||
{
|
||||
return $query->where(function ($query) use ($location) {
|
||||
|
||||
$query->whereHas('assigneduser', function ($query) use ($location) {
|
||||
|
||||
$query->where('users.location_id', '=', $location->id);
|
||||
})->orWhere(function ($query) use ($location)
|
||||
{
|
||||
})->orWhere(function ($query) use ($location) {
|
||||
|
||||
$query->where('assets.rtd_location_id', '=', $location->id);
|
||||
$query->whereNull('assets.assigned_to');
|
||||
});
|
||||
@@ -587,6 +630,23 @@ class Asset extends Depreciable
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope for non-Archived assets
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
|
||||
public function scopeNotArchived($query)
|
||||
{
|
||||
|
||||
return $query->whereHas('assetstatus', function ($query) {
|
||||
|
||||
$query->where('archived', '=', 0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope for Archived assets
|
||||
*
|
||||
@@ -631,10 +691,10 @@ class Asset extends Depreciable
|
||||
public function scopeRequestableAssets($query)
|
||||
{
|
||||
|
||||
return $query->where('requestable', '=', 1)
|
||||
return Company::scopeCompanyables($query->where('requestable', '=', 1))
|
||||
->whereHas('assetstatus', function ($query) {
|
||||
|
||||
$query->where('deployable', '=', 1)
|
||||
$query->where('deployable', '=', 1)
|
||||
->where('pending', '=', 0)
|
||||
->where('archived', '=', 0);
|
||||
});
|
||||
@@ -704,7 +764,7 @@ class Asset extends Depreciable
|
||||
*/
|
||||
public function scopeAccepted($query)
|
||||
{
|
||||
return $uery->where("accepted", "=", "accepted");
|
||||
return $query->where("accepted", "=", "accepted");
|
||||
}
|
||||
|
||||
|
||||
@@ -727,7 +787,8 @@ class Asset extends Depreciable
|
||||
$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.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('models.modelno', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
});
|
||||
})->orWhereHas('model', function ($query) use ($search) {
|
||||
@@ -785,6 +846,19 @@ class Asset extends Depreciable
|
||||
return $query->join('models', 'assets.model_id', '=', 'models.id')->orderBy('models.name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on model number
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderModelNumber($query, $order)
|
||||
{
|
||||
return $query->join('models', 'assets.model_id', '=', 'models.id')->orderBy('models.modelno', $order);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope to order on assigned user
|
||||
@@ -857,7 +931,7 @@ class Asset extends Depreciable
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on model
|
||||
* Query builder scope to order on location
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
|
||||
@@ -15,6 +15,7 @@ class AssetMaintenance extends Model implements ICompanyableChild
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableChildTrait;
|
||||
use ValidatingTrait;
|
||||
|
||||
|
||||
protected $dates = [ 'deleted_at' ];
|
||||
@@ -49,9 +50,9 @@ class AssetMaintenance extends Model implements ICompanyableChild
|
||||
{
|
||||
|
||||
return [
|
||||
Lang::get('admin/asset_maintenances/general.maintenance') => Lang::get('admin/asset_maintenances/general.maintenance'),
|
||||
Lang::get('admin/asset_maintenances/general.repair') => Lang::get('admin/asset_maintenances/general.repair'),
|
||||
Lang::get('admin/asset_maintenances/general.upgrade') => Lang::get('admin/asset_maintenances/general.upgrade')
|
||||
trans('admin/asset_maintenances/general.maintenance') => trans('admin/asset_maintenances/general.maintenance'),
|
||||
trans('admin/asset_maintenances/general.repair') => trans('admin/asset_maintenances/general.repair'),
|
||||
trans('admin/asset_maintenances/general.upgrade') => trans('admin/asset_maintenances/general.upgrade')
|
||||
];
|
||||
}
|
||||
|
||||
@@ -70,6 +71,20 @@ class AssetMaintenance extends Model implements ICompanyableChild
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the admin who created the maintenance
|
||||
*
|
||||
* @return mixed
|
||||
* @author A. Gianotto <snipe@snipe.net>
|
||||
* @version v3.0
|
||||
*/
|
||||
public function admin()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\User', 'user_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function supplier()
|
||||
{
|
||||
|
||||
@@ -78,24 +93,11 @@ class AssetMaintenance extends Model implements ICompanyableChild
|
||||
}
|
||||
|
||||
/**
|
||||
* -----------------------------------------------
|
||||
* BEGIN QUERY SCOPES
|
||||
* -----------------------------------------------
|
||||
**/
|
||||
|
||||
/**
|
||||
* Query builder scope for Deleted assets
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
|
||||
public function scopeDeleted($query)
|
||||
{
|
||||
|
||||
return $query->whereNotNull('deleted_at');
|
||||
}
|
||||
* -----------------------------------------------
|
||||
* BEGIN QUERY SCOPES
|
||||
* -----------------------------------------------
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope to search on text
|
||||
@@ -118,4 +120,19 @@ class AssetMaintenance extends Model implements ICompanyableChild
|
||||
->orWhere('completion_date', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on admin user
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderAdmin($query, $order)
|
||||
{
|
||||
return $query->leftJoin('users', 'asset_maintenances.user_id', '=', 'users.id')
|
||||
->orderBy('users.first_name', $order)
|
||||
->orderBy('users.last_name', $order);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Requestable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
@@ -14,12 +15,13 @@ use Watson\Validating\ValidatingTrait;
|
||||
class AssetModel extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use Requestable;
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'models';
|
||||
|
||||
// Declare the rules for the model validation
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:2|max:255',
|
||||
'name' => 'required|min:1|max:255',
|
||||
'modelno' => 'min:1|max:255',
|
||||
'category_id' => 'required|integer',
|
||||
'manufacturer_id' => 'required|integer',
|
||||
@@ -131,6 +133,22 @@ class AssetModel extends Model
|
||||
return $query->whereIn('category_id', $categoryIdListing);
|
||||
}
|
||||
|
||||
/**
|
||||
* scopeRequestable
|
||||
* Get all models that are requestable by a user.
|
||||
*
|
||||
* @param $query
|
||||
*
|
||||
* @return $query
|
||||
* @author Daniel Meltzer <parallelgrapefruit@gmail.com
|
||||
* @version v3.5
|
||||
*/
|
||||
public function scopeRequestableModels($query)
|
||||
{
|
||||
|
||||
return $query->where('requestable', '1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to search on text
|
||||
*
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use App\Http\Traits\UniqueUndeletedTrait;
|
||||
|
||||
/**
|
||||
* Model for Categories. Categories are a higher-level group
|
||||
@@ -25,7 +26,7 @@ class Category extends Model
|
||||
*/
|
||||
public $rules = array(
|
||||
'user_id' => 'numeric',
|
||||
'name' => 'required|min:3|max:255|unique:categories,name,NULL,deleted_at',
|
||||
'name' => 'required|min:1|max:255|unique_undeleted',
|
||||
'category_type' => 'required',
|
||||
);
|
||||
|
||||
@@ -38,6 +39,7 @@ class Category extends Model
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
use UniqueUndeletedTrait;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
59
app/Models/CheckoutRequest.php
Normal file
59
app/Models/CheckoutRequest.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CheckoutRequest extends Model
|
||||
{
|
||||
//
|
||||
protected $fillable = ['user_id'];
|
||||
protected $table = 'checkout_requests';
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function requestingUser()
|
||||
{
|
||||
return $this->user()->first();
|
||||
}
|
||||
|
||||
public function requestedItem()
|
||||
{
|
||||
return $this->morphTo('requestable');
|
||||
}
|
||||
|
||||
public function itemRequested() // Workaround for laravel polymorphic issue that's not being solved :(
|
||||
{
|
||||
return $this->requestedItem()->first();
|
||||
}
|
||||
|
||||
public function itemType()
|
||||
{
|
||||
return snake_case(class_basename($this->requestable_type));
|
||||
}
|
||||
|
||||
public function location()
|
||||
{
|
||||
if ($this->itemType() == "asset") {
|
||||
$asset = $this->itemRequested();
|
||||
if ($asset->assigneduser && $asset->assetloc) {
|
||||
return $asset->assetloc;
|
||||
} elseif ($asset->defaultLoc) {
|
||||
return $asset->defaultLoc;
|
||||
}
|
||||
}
|
||||
return $this->itemRequested()->location;
|
||||
}
|
||||
|
||||
public function name()
|
||||
{
|
||||
if ($this->itemType() == "asset") {
|
||||
return $this->itemRequested()->showAssetName();
|
||||
}
|
||||
return $this->itemRequested()->name;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use Auth;
|
||||
use DB;
|
||||
|
||||
/**
|
||||
* Model for Companies.
|
||||
@@ -14,7 +16,10 @@ final class Company extends Model
|
||||
protected $table = 'companies';
|
||||
|
||||
// Declare the rules for the model validation
|
||||
protected $rules = ['name' => 'required|min:2|max:255|unique:companies,name'];
|
||||
protected $rules = [
|
||||
'name' => 'required|min:1|max:255|unique:companies,name'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
@@ -54,16 +59,12 @@ final class Company extends Model
|
||||
$company_id = null;
|
||||
}
|
||||
|
||||
if ($company_id == null) {
|
||||
return $query;
|
||||
} else {
|
||||
return $query->where($column, '=', $company_id);
|
||||
}
|
||||
return $query->where($column, '=', $company_id);
|
||||
}
|
||||
|
||||
public static function getSelectList()
|
||||
{
|
||||
$select_company = Lang::get('general.select_company');
|
||||
$select_company = trans('general.select_company');
|
||||
return ['0' => $select_company] + DB::table('companies')->orderBy('name', 'ASC')->lists('name', 'id');
|
||||
}
|
||||
|
||||
@@ -85,11 +86,17 @@ final class Company extends Model
|
||||
} else {
|
||||
$current_user = Auth::user();
|
||||
|
||||
if ($current_user->company_id != null) {
|
||||
return $current_user->company_id;
|
||||
} else {
|
||||
// Super users should be able to set a company to whatever they need
|
||||
if ($current_user->isSuperUser()) {
|
||||
return static::getIdFromInput($unescaped_input);
|
||||
} else {
|
||||
if ($current_user->company_id != null) {
|
||||
return $current_user->company_id;
|
||||
} else {
|
||||
return static::getIdFromInput($unescaped_input);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,14 +109,14 @@ final class Company extends Model
|
||||
} else {
|
||||
$current_user_company_id = Auth::user()->company_id;
|
||||
$companyable_company_id = $companyable->company_id;
|
||||
|
||||
return ($current_user_company_id == null || $current_user_company_id == $companyable_company_id);
|
||||
return ($current_user_company_id == null || $current_user_company_id == $companyable_company_id || Auth::user()->isSuperUser());
|
||||
}
|
||||
}
|
||||
|
||||
public static function isCurrentUserAuthorized()
|
||||
{
|
||||
return (!static::isFullMultipleCompanySupportEnabled() || Auth::user()->company_id == null);
|
||||
|
||||
return ((!static::isFullMultipleCompanySupportEnabled()) || (Auth::user()->isSuperUser()));
|
||||
}
|
||||
|
||||
public static function canManageUsersCompanies()
|
||||
@@ -129,7 +136,8 @@ final class Company extends Model
|
||||
|
||||
public static function scopeCompanyables($query, $column = 'company_id')
|
||||
{
|
||||
if (!static::isFullMultipleCompanySupportEnabled()) {
|
||||
// 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);
|
||||
@@ -140,7 +148,7 @@ final class Company extends Model
|
||||
{
|
||||
if (count($companyable_names) == 0) {
|
||||
throw new Exception('No Companyable Children to scope');
|
||||
} elseif (!static::isFullMultipleCompanySupportEnabled()) {
|
||||
} elseif (!static::isFullMultipleCompanySupportEnabled() || (Auth::check() && Auth::user()->isSuperUser())) {
|
||||
return $query;
|
||||
} else {
|
||||
$f = function ($q) {
|
||||
@@ -169,4 +177,27 @@ final class Company extends Model
|
||||
return e($company->name);
|
||||
}
|
||||
}
|
||||
|
||||
public function users() {
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
|
||||
public function assets() {
|
||||
return $this->hasMany(Asset::class);
|
||||
}
|
||||
|
||||
public function licenses() {
|
||||
return $this->hasMany(License::class);
|
||||
}
|
||||
public function accessories() {
|
||||
return $this->hasMany(Accessory::class);
|
||||
}
|
||||
|
||||
public function consumables() {
|
||||
return $this->hasMany(Consumable::class);
|
||||
}
|
||||
|
||||
public function components() {
|
||||
return $this->hasMany(Component::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\ConsumableAssignment;
|
||||
use App\Models\Company;
|
||||
use App\Models\Location;
|
||||
use App\Models\Category;
|
||||
use App\Models\ActionLog;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\ConsumableAssignment;
|
||||
use App\Models\Location;
|
||||
use App\Models\Loggable;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
@@ -18,8 +19,9 @@ use Watson\Validating\ValidatingTrait;
|
||||
*/
|
||||
class Component extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableTrait;
|
||||
use Loggable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'components';
|
||||
@@ -30,7 +32,11 @@ class Component extends Model
|
||||
*/
|
||||
public $rules = array(
|
||||
'name' => 'required|min:3|max:255',
|
||||
'min_amt' => 'integer|min:1',
|
||||
'total_qty' => 'required|integer|min:1',
|
||||
'category_id' => 'required|integer',
|
||||
'company_id' => 'integer',
|
||||
'purchase_date' => 'date',
|
||||
'purchase_cost' => 'numeric',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -81,7 +87,7 @@ class Component extends Model
|
||||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'component_id')->where('asset_type', '=', 'component')->orderBy('created_at', 'desc')->withTrashed();
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')->where('item_type', Component::class)->orderBy('created_at', 'desc')->withTrashed();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\ConsumableAssignment;
|
||||
use App\Models\Company;
|
||||
use App\Models\Location;
|
||||
use App\Models\Category;
|
||||
use App\Models\ActionLog;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\ConsumableAssignment;
|
||||
use App\Models\Location;
|
||||
use App\Models\Loggable;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Consumable extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableTrait;
|
||||
use Loggable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'consumables';
|
||||
@@ -29,6 +31,7 @@ class Consumable extends Model
|
||||
'category_id' => 'required|integer',
|
||||
'company_id' => 'integer',
|
||||
'min_amt' => 'integer|min:1',
|
||||
'purchase_cost' => 'numeric',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -84,7 +87,7 @@ class Consumable extends Model
|
||||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'consumable_id')->where('asset_type', '=', 'consumable')->orderBy('created_at', 'desc')->withTrashed();
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')->where('item_type', Consumable::class)->orderBy('created_at', 'desc')->withTrashed();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,14 +11,14 @@ class CustomField extends Model
|
||||
|
||||
*/
|
||||
public static $PredefinedFormats=[
|
||||
"ANY" => "",
|
||||
"ALPHA" => "alpha",
|
||||
"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"
|
||||
"ANY" => "",
|
||||
"ALPHA" => "alpha",
|
||||
"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",
|
||||
];
|
||||
|
||||
public $rules=[
|
||||
@@ -109,4 +109,43 @@ class CustomField extends Model
|
||||
$this->attributes['format']=$value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a value string as an array for select boxes and checkboxes.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.4]
|
||||
* @return Array
|
||||
*/
|
||||
public function formatFieldValuesAsArray() {
|
||||
$arr = preg_split("/\\r\\n|\\r|\\n/", $this->field_values);
|
||||
|
||||
$result[''] = 'Select '.strtolower($this->format);
|
||||
|
||||
for ($x = 0; $x < count($arr); $x++) {
|
||||
$arr_parts = explode('|', $arr[$x]);
|
||||
if ($arr_parts[0]!='') {
|
||||
if (key_exists('1',$arr_parts)) {
|
||||
$result[$arr_parts[0]] = $arr_parts[1];
|
||||
} else {
|
||||
$result[$arr_parts[0]] = $arr_parts[0];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function isFieldDecryptable($string) {
|
||||
if (($this->field_encrypted=='1') && ($string!='')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Gate;
|
||||
|
||||
class CustomFieldset extends Model
|
||||
{
|
||||
@@ -30,16 +31,21 @@ class CustomFieldset extends Model
|
||||
{
|
||||
$rules=[];
|
||||
foreach ($this->fields as $field) {
|
||||
$rule=[];
|
||||
if ($field->pivot->required) {
|
||||
$rule[]="required";
|
||||
$rule = [];
|
||||
|
||||
if (($field->field_encrypted!='1') ||
|
||||
(($field->field_encrypted =='1') && (Gate::allows('admin')) ))
|
||||
{
|
||||
|
||||
if ($field->pivot->required) {
|
||||
$rule[]="required";
|
||||
}
|
||||
}
|
||||
|
||||
array_push($rule, $field->attributes['format']);
|
||||
$rules[$field->db_column_name()]=$rule;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
//requiredness goes *here*
|
||||
//sequence goes here?
|
||||
}
|
||||
|
||||
@@ -37,7 +37,4 @@ class Group extends Model
|
||||
{
|
||||
return json_decode($this->permissions, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
298
app/Models/Ldap.php
Normal file
298
app/Models/Ldap.php
Normal file
@@ -0,0 +1,298 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\User;
|
||||
use App\Models\Setting;
|
||||
use Exception;
|
||||
use Input;
|
||||
use Log;
|
||||
|
||||
|
||||
class Ldap extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Makes a connection to LDAP using the settings in Admin > Settings.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @return connection
|
||||
*/
|
||||
|
||||
public static function connectToLdap()
|
||||
{
|
||||
|
||||
$ldap_host = Setting::getSettings()->ldap_server;
|
||||
$ldap_version = Setting::getSettings()->ldap_version;
|
||||
$ldap_server_cert_ignore = Setting::getSettings()->ldap_server_cert_ignore;
|
||||
$ldap_use_tls = Setting::getSettings()->ldap_tls;
|
||||
|
||||
|
||||
// If we are ignoring the SSL cert we need to setup the environment variable
|
||||
// before we create the connection
|
||||
if ($ldap_server_cert_ignore=='1') {
|
||||
putenv('LDAPTLS_REQCERT=never');
|
||||
}
|
||||
|
||||
// If the user specifies where CA Certs are, make sure to use them
|
||||
if(env("LDAPTLS_CACERT")) {
|
||||
putenv("LDAPTLS_CACERT=".env("LDAPTLS_CACERT"));
|
||||
}
|
||||
|
||||
$connection = @ldap_connect($ldap_host);
|
||||
|
||||
if (!$connection) {
|
||||
throw new Exception('Could not connect to LDAP server at '.$ldap_host.'. Please check your LDAP server name and port number in your settings.');
|
||||
}
|
||||
|
||||
// Needed for AD
|
||||
ldap_set_option($connection, LDAP_OPT_REFERRALS, 0);
|
||||
ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, $ldap_version);
|
||||
|
||||
if ($ldap_use_tls=='1') {
|
||||
ldap_start_tls($connection);
|
||||
}
|
||||
|
||||
return $connection;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Binds/authenticates the user to LDAP, and returns their attributes.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @param $username
|
||||
* @param $password
|
||||
* @param bool|false $user
|
||||
* @return bool true if the username and/or password provided are valid
|
||||
* false if the username and/or password provided are invalid
|
||||
* array of ldap_attributes if $user is true
|
||||
*
|
||||
*/
|
||||
static function findAndBindUserLdap($username, $password)
|
||||
{
|
||||
$settings = Setting::getSettings();
|
||||
$connection = Ldap::connectToLdap();
|
||||
$ldap_username_field = $settings->ldap_username_field;
|
||||
$baseDn = $settings->ldap_basedn;
|
||||
|
||||
if ($settings->is_ad =='1')
|
||||
{
|
||||
|
||||
// Check if they are using the userprincipalname for the username field.
|
||||
// If they are, we can skip building the UPN to authenticate against AD
|
||||
if ($ldap_username_field=='userprincipalname')
|
||||
{
|
||||
$userDn = $username;
|
||||
} else {
|
||||
// In case they haven't added an AD domain
|
||||
if ($settings->ad_domain == '') {
|
||||
$userDn = $username.'@'.$settings->email_domain;
|
||||
} else {
|
||||
$userDn = $username.'@'.$settings->ad_domain;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$userDn = $ldap_username_field.'='.$username.','.$settings->ldap_basedn;
|
||||
}
|
||||
|
||||
|
||||
$filterQuery = $settings->ldap_auth_filter_query . $username;
|
||||
|
||||
if (!$ldapbind = @ldap_bind($connection, $userDn, $password)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$results = ldap_search($connection, $baseDn, $filterQuery)) {
|
||||
throw new Exception('Could not search LDAP: ');
|
||||
}
|
||||
|
||||
if (!$entry = ldap_first_entry($connection, $results)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$user = array_change_key_case(ldap_get_attributes($connection, $entry), CASE_LOWER)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $user;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Binds/authenticates an admin to LDAP for LDAP searching/syncing.
|
||||
* Here we also return a better error if the app key is donked.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @param bool|false $user
|
||||
* @return bool true if the username and/or password provided are valid
|
||||
* false if the username and/or password provided are invalid
|
||||
*
|
||||
*/
|
||||
static function bindAdminToLdap($connection)
|
||||
{
|
||||
|
||||
$ldap_username = Setting::getSettings()->ldap_uname;
|
||||
|
||||
// Lets return some nicer messages for users who donked their app key, and disable LDAP
|
||||
try {
|
||||
$ldap_pass = \Crypt::decrypt(Setting::getSettings()->ldap_pword);
|
||||
} catch (Exception $e) {
|
||||
|
||||
throw new Exception('Your app key has changed! Could not decrypt LDAP password using your current app key, so LDAP authentication has been disabled. Login with a local account, update the LDAP password and re-enable it in Admin > Settings.');
|
||||
}
|
||||
|
||||
|
||||
if (!$ldapbind = @ldap_bind($connection, $ldap_username, $ldap_pass)) {
|
||||
throw new Exception('Could not bind to LDAP: '.ldap_error($connection));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse and map LDAP attributes based on settings
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
*
|
||||
* @param $ldapatttibutes
|
||||
* @return array|bool
|
||||
*/
|
||||
static function parseAndMapLdapAttributes($ldapatttibutes)
|
||||
{
|
||||
//Get LDAP attribute config
|
||||
$ldap_result_username = Setting::getSettings()->ldap_username_field;
|
||||
$ldap_result_emp_num = Setting::getSettings()->ldap_emp_num;
|
||||
$ldap_result_last_name = Setting::getSettings()->ldap_lname_field;
|
||||
$ldap_result_first_name = Setting::getSettings()->ldap_fname_field;
|
||||
$ldap_result_email = Setting::getSettings()->ldap_email;
|
||||
|
||||
// Get LDAP user data
|
||||
$item = array();
|
||||
$item["username"] = isset($ldapatttibutes[$ldap_result_username][0]) ? $ldapatttibutes[$ldap_result_username][0] : "";
|
||||
$item["employee_number"] = isset($ldapatttibutes[$ldap_result_emp_num][0]) ? $ldapatttibutes[$ldap_result_emp_num][0] : "";
|
||||
$item["lastname"] = isset($ldapatttibutes[$ldap_result_last_name][0]) ? $ldapatttibutes[$ldap_result_last_name][0] : "";
|
||||
$item["firstname"] = isset($ldapatttibutes[$ldap_result_first_name][0]) ? $ldapatttibutes[$ldap_result_first_name][0] : "";
|
||||
$item["email"] = isset($ldapatttibutes[$ldap_result_email][0]) ? $ldapatttibutes[$ldap_result_email][0] : "" ;
|
||||
|
||||
return $item;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user from LDAP attributes
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @param $ldapatttibutes
|
||||
* @return array|bool
|
||||
*/
|
||||
static function createUserFromLdap($ldapatttibutes)
|
||||
{
|
||||
$item = Ldap::parseAndMapLdapAttributes($ldapatttibutes);
|
||||
|
||||
|
||||
// Create user from LDAP data
|
||||
if (!empty($item["username"])) {
|
||||
$user = new User;
|
||||
$user->first_name = $item["firstname"];
|
||||
$user->last_name = $item["lastname"];
|
||||
$user->username = $item["username"];
|
||||
$user->email = $item["email"];
|
||||
|
||||
if (Setting::getSettings()->ldap_pw_sync=='1') {
|
||||
$user->password = bcrypt(Input::get("password"));
|
||||
} else {
|
||||
$pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 25);
|
||||
$user->password = bcrypt($pass);
|
||||
}
|
||||
|
||||
$user->activated = 1;
|
||||
$user->ldap_import = 1;
|
||||
$user->notes = 'Imported on first login from LDAP';
|
||||
|
||||
if ($user->save()) {
|
||||
return true;
|
||||
} else {
|
||||
LOG::debug('Could not create user.'.$user->getErrors());
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches LDAP
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @param $ldapatttibutes
|
||||
* @return array|bool
|
||||
*/
|
||||
static function findLdapUsers() {
|
||||
|
||||
$ldapconn = Ldap::connectToLdap();
|
||||
$ldap_bind = Ldap::bindAdminToLdap($ldapconn);
|
||||
$base_dn = Setting::getSettings()->ldap_basedn;
|
||||
$filter = Setting::getSettings()->ldap_filter;
|
||||
|
||||
// Set up LDAP pagination for very large databases
|
||||
// @author Richard Hofman
|
||||
$page_size = 500;
|
||||
$cookie = '';
|
||||
$result_set = array();
|
||||
$global_count = 0;
|
||||
|
||||
// Perform the search
|
||||
do {
|
||||
|
||||
// Paginate (non-critical, if not supported by server)
|
||||
if (!$ldap_paging = @ldap_control_paged_result($ldapconn, $page_size, false, $cookie)) {
|
||||
throw new Exception('Problem with your LDAP connection. Try checking the Use TLS setting in Admin > Settings. ');
|
||||
}
|
||||
|
||||
|
||||
$search_results = ldap_search($ldapconn, $base_dn, '('.$filter.')');
|
||||
|
||||
if (!$search_results) {
|
||||
return redirect()->route('users')->with('error', trans('admin/users/message.error.ldap_could_not_search').ldap_error($ldapconn));
|
||||
}
|
||||
|
||||
// Get results from page
|
||||
$results = ldap_get_entries($ldapconn, $search_results);
|
||||
if (!$results) {
|
||||
return redirect()->route('users')->with('error', trans('admin/users/message.error.ldap_could_not_get_entries').ldap_error($ldapconn));
|
||||
}
|
||||
|
||||
// Add results to result set
|
||||
$global_count += $results['count'];
|
||||
$result_set = array_merge($result_set, $results);
|
||||
|
||||
ldap_control_paged_result_response($ldapconn, $search_results, $cookie);
|
||||
|
||||
} while ($cookie !== null && $cookie != '');
|
||||
|
||||
|
||||
// Clean up after search
|
||||
$result_set['count'] = $global_count;
|
||||
$results = $result_set;
|
||||
ldap_control_paged_result($ldapconn, 0);
|
||||
|
||||
return $results;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -2,15 +2,16 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\Loggable;
|
||||
use DB;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class License extends Depreciable
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableTrait;
|
||||
use Loggable;
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
@@ -36,6 +37,11 @@ class License extends Depreciable
|
||||
return $this->belongsTo('\App\Models\Company', 'company_id');
|
||||
}
|
||||
|
||||
public function manufacturer()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Manufacturer', 'manufacturer_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the assigned user
|
||||
*/
|
||||
@@ -49,8 +55,8 @@ class License extends Depreciable
|
||||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'asset_id')
|
||||
->where('asset_type', '=', 'software')
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')
|
||||
->where('item_type', '=', License::class)
|
||||
->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
@@ -59,8 +65,8 @@ class License extends Depreciable
|
||||
*/
|
||||
public function uploads()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'asset_id')
|
||||
->where('asset_type', '=', 'software')
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')
|
||||
->where('item_type', '=', License::class)
|
||||
->where('action_type', '=', 'uploaded')
|
||||
->whereNotNull('filename')
|
||||
->orderBy('created_at', 'desc');
|
||||
@@ -208,6 +214,7 @@ class License extends Depreciable
|
||||
->orWhere('serial', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('notes', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('order_number', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('purchase_order', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('purchase_date', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('purchase_cost', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Loggable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
@@ -8,6 +9,7 @@ class LicenseSeat extends Model implements ICompanyableChild
|
||||
{
|
||||
use CompanyableChildTrait;
|
||||
use SoftDeletes;
|
||||
use Loggable;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $guarded = 'id';
|
||||
|
||||
@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Models\User;
|
||||
use App\Models\Asset;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use App\Http\Traits\UniqueUndeletedTrait;
|
||||
|
||||
class Location extends Model
|
||||
{
|
||||
@@ -13,7 +14,7 @@ class Location extends Model
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'locations';
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:3|max:255|unique:locations,name,NULL,deleted_at',
|
||||
'name' => 'required|min:3|max:255|unique_undeleted',
|
||||
'city' => 'min:3|max:255',
|
||||
'state' => 'min:2|max:32',
|
||||
'country' => 'min:2|max:2|max:2',
|
||||
@@ -31,6 +32,7 @@ class Location extends Model
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
use UniqueUndeletedTrait;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
108
app/Models/Loggable.php
Normal file
108
app/Models/Loggable.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\CheckoutRequest;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
trait Loggable
|
||||
{
|
||||
|
||||
/**
|
||||
* @author Daniel Meltzer <parallelgrapefruit@gmail.com
|
||||
* @since [v3.4]
|
||||
* @return \App\Models\Actionlog
|
||||
*/
|
||||
|
||||
public function log()
|
||||
{
|
||||
return $this->morphMany(Actionlog::class, 'item');
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Daniel Meltzer <parallelgrapefruit@gmail.com
|
||||
* @since [v3.4]
|
||||
* @return \App\Models\Actionlog
|
||||
*/
|
||||
public function logCheckout($note, $target = null /*target is overridable for components*/)
|
||||
{
|
||||
$log = new Actionlog;
|
||||
|
||||
// We need to special case licenses because of license_seat vs license. So much for clean polymorphism :)
|
||||
if (static::class == LicenseSeat::class) {
|
||||
$log->item_type = License::class;
|
||||
$log->item_id = $this->license_id;
|
||||
} else {
|
||||
$log->item_type = static::class;
|
||||
$log->item_id = $this->id;
|
||||
}
|
||||
|
||||
$log->user_id = Auth::user()->id;
|
||||
|
||||
if (!is_null($this->asset_id) || isset($target)) {
|
||||
$log->target_type = Asset::class;
|
||||
$log->target_id = $this->asset_id;
|
||||
} else if (!is_null($this->assigned_to)) {
|
||||
$log->target_type = User::class;
|
||||
$log->target_id = $this->assigned_to;
|
||||
}
|
||||
|
||||
$item = call_user_func(array($log->target_type, 'find'), $log->target_id);
|
||||
$log->location_id = $item->location_id;
|
||||
$log->note = $note;
|
||||
$log->logaction('checkout');
|
||||
|
||||
return $log;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Daniel Meltzer <parallelgrapefruit@gmail.com
|
||||
* @since [v3.4]
|
||||
* @return \App\Models\Actionlog
|
||||
*/
|
||||
public function logCheckin($note)
|
||||
{
|
||||
$log = new Actionlog;
|
||||
if (static::class == LicenseSeat::class) {
|
||||
$log->item_type = License::class;
|
||||
$log->item_id = $this->license_id;
|
||||
} else {
|
||||
$log->item_type = static::class;
|
||||
$log->item_id = $this->id;
|
||||
}
|
||||
$log->location_id = null;
|
||||
$log->note = $note;
|
||||
$log->user_id = Auth::user()->id;
|
||||
$log->logaction('checkin from');
|
||||
|
||||
return $log;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Daniel Meltzer <parallelgrapefruit@gmail.com
|
||||
* @since [v3.4]
|
||||
* @return \App\Models\Actionlog
|
||||
*/
|
||||
public function logUpload($filename, $note)
|
||||
{
|
||||
$log = new Actionlog;
|
||||
if (static::class == LicenseSeat::class) {
|
||||
$log->item_type = License::class;
|
||||
$log->item_id = $this->license_id;
|
||||
} else {
|
||||
$log->item_type = static::class;
|
||||
$log->item_id = $this->id;
|
||||
}
|
||||
$log->user_id = Auth::user()->id;
|
||||
$log->note = $note;
|
||||
$log->target_id = null;
|
||||
$log->created_at = date("Y-m-d h:i:s");
|
||||
$log->filename = $filename;
|
||||
$log->logaction('uploaded');
|
||||
|
||||
return $log;
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,21 @@ class Manufacturer extends Model
|
||||
return $this->hasManyThrough('\App\Models\Asset', '\App\Models\AssetModel', 'manufacturer_id', 'model_id');
|
||||
}
|
||||
|
||||
public function licenses()
|
||||
{
|
||||
return $this->hasMany('\App\Models\License', 'manufacturer_id');
|
||||
}
|
||||
|
||||
public function accessories()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Accessory', 'manufacturer_id');
|
||||
}
|
||||
|
||||
public function consumables()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Consumable', 'manufacturer_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to search on text
|
||||
*
|
||||
|
||||
45
app/Models/Requestable.php
Normal file
45
app/Models/Requestable.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\CheckoutRequest;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
// $asset->requests
|
||||
// $asset->isRequestedBy($user)
|
||||
// $asset->whereRequestedBy($user)
|
||||
trait Requestable
|
||||
{
|
||||
|
||||
public function requests()
|
||||
{
|
||||
return $this->morphMany(CheckoutRequest::class, 'requestable');
|
||||
}
|
||||
|
||||
public function isRequestedBy(User $user)
|
||||
{
|
||||
return $this->requests()
|
||||
->where('user_id', $user->id)
|
||||
->exists();
|
||||
}
|
||||
|
||||
public function scopeRequestedBy($query, User $user)
|
||||
{
|
||||
return $query->whereHas('requests', function ($query) use ($user) {
|
||||
$query->where('user_id', $user->id);
|
||||
});
|
||||
}
|
||||
|
||||
public function request()
|
||||
{
|
||||
$this->requests()->save(
|
||||
new CheckoutRequest(['user_id' => Auth::id()])
|
||||
);
|
||||
}
|
||||
|
||||
public function cancelRequest()
|
||||
{
|
||||
$this->requests()->where('user_id', Auth::id())->delete();
|
||||
}
|
||||
}
|
||||
@@ -11,28 +11,39 @@ class Setting extends Model
|
||||
use ValidatingTrait;
|
||||
|
||||
protected $rules = [
|
||||
"site_name" => 'required|min:1',
|
||||
"brand" => 'required|min:1|numeric',
|
||||
"alert_threshold" => 'numeric',
|
||||
"alert_interval" => 'numeric',
|
||||
"qr_text" => 'min:1|max:31',
|
||||
"custom_css" => 'string',
|
||||
"slack_endpoint" => 'url',
|
||||
"default_currency" => 'required',
|
||||
"slack_channel" => 'regex:/(?<!\w)#\w+/',
|
||||
"slack_botname" => 'string',
|
||||
"ldap_server" => 'sometimes|required_if:ldap_enabled,1|url',
|
||||
"ldap_uname" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_pword" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_basedn" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_filter" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_username_field" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_lname_field" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_auth_filter_query" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_version" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"brand" => 'required|min:1|numeric',
|
||||
"qr_text" => 'min:1|max:31',
|
||||
"logo_img" => 'mimes:jpeg,bmp,png,gif',
|
||||
"custom_css" => 'string',
|
||||
"alert_email" => 'email_array',
|
||||
"slack_endpoint" => 'url',
|
||||
"default_currency" => 'required',
|
||||
"locale" => 'required',
|
||||
"slack_channel" => 'regex:/(?<!\w)#\w+/',
|
||||
"slack_botname" => 'string',
|
||||
'labels_per_page' => 'numeric',
|
||||
'labels_width' => 'numeric',
|
||||
'labels_height' => 'numeric',
|
||||
'labels_pmargin_left' => 'numeric',
|
||||
'labels_pmargin_right' => 'numeric',
|
||||
'labels_pmargin_top' => 'numeric',
|
||||
'labels_pmargin_bottom' => 'numeric',
|
||||
'labels_display_bgutter' => 'numeric',
|
||||
'labels_display_sgutter' => 'numeric',
|
||||
'labels_fontsize' => 'numeric|min:5',
|
||||
'labels_pagewidth' => 'numeric',
|
||||
'labels_pageheight' => 'numeric',
|
||||
"ldap_server" => 'sometimes|required_if:ldap_enabled,1|url',
|
||||
"ldap_uname" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_basedn" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_filter" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_username_field" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_lname_field" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_auth_filter_query" => 'sometimes|required_if:ldap_enabled,1',
|
||||
"ldap_version" => 'sometimes|required_if:ldap_enabled,1',
|
||||
];
|
||||
|
||||
protected $fillable = ['site_name'];
|
||||
protected $fillable = ['site_name','email_domain','email_format','username_format'];
|
||||
|
||||
public static function getSettings()
|
||||
{
|
||||
@@ -44,22 +55,22 @@ class Setting extends Model
|
||||
return $static_cache;
|
||||
}
|
||||
|
||||
public static function setupCompleted() {
|
||||
public static function setupCompleted()
|
||||
{
|
||||
|
||||
$users_table_exists = Schema::hasTable('users');
|
||||
$settings_table_exists = Schema::hasTable('settings');
|
||||
$users_table_exists = Schema::hasTable('users');
|
||||
$settings_table_exists = Schema::hasTable('settings');
|
||||
|
||||
if ($users_table_exists && $settings_table_exists) {
|
||||
$usercount = User::withTrashed()->count();
|
||||
|
||||
|
||||
if ($users_table_exists && $settings_table_exists) {
|
||||
$usercount = User::withTrashed()->count();
|
||||
|
||||
if ($usercount > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
if ($usercount > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use App\Http\Traits\UniqueUndeletedTrait;
|
||||
|
||||
class Statuslabel extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use ValidatingTrait;
|
||||
use UniqueUndeletedTrait;
|
||||
|
||||
protected $injectUniqueIdentifier = true;
|
||||
protected $dates = ['deleted_at'];
|
||||
@@ -16,26 +18,44 @@ class Statuslabel extends Model
|
||||
|
||||
|
||||
protected $rules = array(
|
||||
'name' => 'required|string|unique:status_labels,name,NULL,deleted_at',
|
||||
//'statuslabel_types' => 'required|in:deployable,pending,archived,undeployable',
|
||||
'notes' => 'string',
|
||||
'name' => 'required|string|unique_undeleted',
|
||||
'notes' => 'string',
|
||||
'deployable' => 'required',
|
||||
'pending' => 'required',
|
||||
'archived' => 'required',
|
||||
);
|
||||
|
||||
protected $fillable = ['name'];
|
||||
protected $fillable = ['name', 'deployable', 'pending', 'archived'];
|
||||
|
||||
/**
|
||||
* Show count of assets with status label
|
||||
*
|
||||
* @todo Remove this. It's dumb.
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function has_assets()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Asset', 'status_id')->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get assets with associated status label
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function assets()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Asset', 'status_id');
|
||||
}
|
||||
|
||||
public function getStatuslabelType()
|
||||
{
|
||||
|
||||
if ($this->pending == 1) {
|
||||
if (($this->pending == '1') && ($this->archived == '0') && ($this->deployable == '0')) {
|
||||
return 'pending';
|
||||
} elseif ($this->archived == 1) {
|
||||
} elseif (($this->pending == '0') && ($this->archived == '1') && ($this->deployable == '0')) {
|
||||
return 'archived';
|
||||
} elseif (($this->archived == 0) && ($this->deployable == 0) && ($this->deployable == 0)) {
|
||||
} elseif (($this->pending == '0') && ($this->archived == '0') && ($this->deployable == '0')) {
|
||||
return 'undeployable';
|
||||
} else {
|
||||
return 'deployable';
|
||||
@@ -58,11 +78,12 @@ class Statuslabel extends Model
|
||||
$statustype['pending'] = 0;
|
||||
$statustype['deployable'] = 0;
|
||||
$statustype['archived'] = 1;
|
||||
|
||||
} elseif ($type == 'undeployable') {
|
||||
|
||||
} else {
|
||||
$statustype['pending'] = 0;
|
||||
$statustype['deployable'] = 0;
|
||||
$statustype['archived'] = 0;
|
||||
|
||||
}
|
||||
|
||||
return $statustype;
|
||||
|
||||
@@ -4,14 +4,16 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use App\Http\Traits\UniqueUndeletedTrait;
|
||||
|
||||
class Supplier extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'suppliers';
|
||||
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:3|max:255|unique:suppliers,name,NULL,deleted_at',
|
||||
'name' => 'required|min:3|max:255|unique_undeleted',
|
||||
'address' => 'min:3|max:255',
|
||||
'address2' => 'min:2|max:255',
|
||||
'city' => 'min:3|max:255',
|
||||
@@ -35,6 +37,7 @@ class Supplier extends Model
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
use UniqueUndeletedTrait;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
||||
@@ -7,8 +7,9 @@ use Illuminate\Auth\Passwords\CanResetPassword;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use App\Models\Company;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Http\Traits\UniqueUndeletedTrait;
|
||||
use App\Models\Setting;
|
||||
|
||||
class User extends Model implements AuthenticatableContract, CanResetPasswordContract
|
||||
{
|
||||
@@ -17,6 +18,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
use ValidatingTrait;
|
||||
use Authenticatable;
|
||||
use CanResetPassword;
|
||||
use UniqueUndeletedTrait;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'users';
|
||||
@@ -24,43 +26,50 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
protected $fillable = ['first_name', 'last_name', 'email','password','username'];
|
||||
|
||||
|
||||
/**
|
||||
* Model validation rules
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/**
|
||||
* Model validation rules
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
||||
protected $rules = [
|
||||
'first_name' => 'required|string|min:1',
|
||||
'last_name' => 'required|string|min:1',
|
||||
'username' => 'required|string|min:2|unique:users,username,NULL,deleted_at',
|
||||
'email' => 'email',
|
||||
'password' => 'required|min:6',
|
||||
'first_name' => 'required|string|min:1',
|
||||
'username' => 'required|string|min:2|unique_undeleted',
|
||||
'email' => 'email',
|
||||
'password' => 'required|min:6',
|
||||
];
|
||||
|
||||
|
||||
// This is very coarse and should be changed
|
||||
public function hasAccess($section)
|
||||
{
|
||||
|
||||
if ($this->isSuperUser()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->permissions=='') {
|
||||
$user_groups = $this->groups;
|
||||
|
||||
|
||||
if (($this->permissions=='') && (count($user_groups) == 0)) {
|
||||
return false;
|
||||
}
|
||||
$user_permissions = json_decode($this->permissions, true);
|
||||
$user_groups = $this->groups();
|
||||
|
||||
if (((array_key_exists($section, $user_permissions)) && ($user_permissions[$section]=='1')) ||
|
||||
((array_key_exists('admin', $user_permissions)) && ($user_permissions['admin']=='1'))) {
|
||||
$user_permissions = json_decode($this->permissions, true);
|
||||
|
||||
//If the user is explicitly granted, return true
|
||||
if (($user_permissions!='') && ((array_key_exists($section, $user_permissions)) && ($user_permissions[$section]=='1'))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the user is explicitly denied, return false
|
||||
if (($user_permissions=='') || array_key_exists($section, $user_permissions) && ($user_permissions[$section]=='-1')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Loop through the groups to see if any of them grant this permission
|
||||
foreach ($user_groups as $user_group) {
|
||||
$group_permissions = json_decode($user_group->permissions, true);
|
||||
if (((array_key_exists($section, $group_permissions)) && ($group_permissions[$section]=='1')) ||
|
||||
((array_key_exists('admin', $group_permissions)) && ($group_permissions['admin']=='1'))) {
|
||||
$group_permissions = (array) json_decode($user_group->permissions, true);
|
||||
if (((array_key_exists($section, $group_permissions)) && ($group_permissions[$section]=='1'))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -68,27 +77,25 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isSuperUser() {
|
||||
public function isSuperUser()
|
||||
{
|
||||
if (!$user_permissions = json_decode($this->permissions, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$group_array = array();
|
||||
foreach ($this->groups() as $user_group) {
|
||||
foreach ($this->groups as $user_group) {
|
||||
$group_permissions = json_decode($user_group->permissions, true);
|
||||
$group_array[] = $group_permissions;
|
||||
$group_array = (array)$group_permissions;
|
||||
if ((array_key_exists('superuser', $group_array)) && ($group_permissions['superuser']=='1')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((array_key_exists('superuser', $user_permissions)) && ($user_permissions['superuser']=='1')) {
|
||||
return true;
|
||||
} else {
|
||||
if ((array_key_exists('superuser', $group_array)) && ($group_array['superuser']=='1')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,23 +114,32 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the user full name, it simply concatenates
|
||||
* the user first and last name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
/**
|
||||
* Returns the user full name, it simply concatenates
|
||||
* the user first and last name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fullName()
|
||||
{
|
||||
return "{$this->first_name} {$this->last_name}";
|
||||
}
|
||||
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
return $this->first_name . " " . $this->last_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user Gravatar image url.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCompleteNameAttribute()
|
||||
{
|
||||
return $this->last_name . ", " . $this->first_name . " (" . $this->username . ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user Gravatar image url.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function gravatar()
|
||||
{
|
||||
|
||||
@@ -131,10 +147,8 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
return config('app.url').'/uploads/avatars/'.$this->avatar;
|
||||
}
|
||||
|
||||
if ($this->email) {
|
||||
// Generate the Gravatar hash
|
||||
if ((Setting::getSettings()->load_remote=='1') && ($this->email!='')) {
|
||||
$gravatar = md5(strtolower(trim($this->email)));
|
||||
// Return the Gravatar url
|
||||
return "//gravatar.com/avatar/".$gravatar;
|
||||
}
|
||||
|
||||
@@ -142,65 +156,73 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get assets assigned to this user
|
||||
*/
|
||||
/**
|
||||
* Get assets assigned to this user
|
||||
*/
|
||||
public function assets()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Asset', 'assigned_to')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get accessories assigned to this user
|
||||
*/
|
||||
/**
|
||||
* Get assets assigned to this user
|
||||
*/
|
||||
public function assetmaintenances()
|
||||
{
|
||||
return $this->hasMany('\App\Models\AssetMaintenance', 'user_id')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get accessories assigned to this user
|
||||
*/
|
||||
public function accessories()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\Accessory', 'accessories_users', 'assigned_to', 'accessory_id')->withPivot('id')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get consumables assigned to this user
|
||||
*/
|
||||
/**
|
||||
* Get consumables assigned to this user
|
||||
*/
|
||||
public function consumables()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\Consumable', 'consumables_users', 'assigned_to', 'consumable_id')->withPivot('id')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get licenses assigned to this user
|
||||
*/
|
||||
/**
|
||||
* Get licenses assigned to this user
|
||||
*/
|
||||
public function licenses()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\License', 'license_seats', 'assigned_to', 'license_id')->withPivot('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action logs for this user
|
||||
*/
|
||||
/**
|
||||
* Get action logs for this user
|
||||
*/
|
||||
public function userlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'checkedout_to')->orderBy('created_at', 'DESC')->withTrashed();
|
||||
return $this->hasMany('\App\Models\Actionlog', 'target_id')->orderBy('created_at', 'DESC')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the asset's location based on the assigned user
|
||||
**/
|
||||
/**
|
||||
* Get the asset's location based on the assigned user
|
||||
**/
|
||||
public function userloc()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Location', 'location_id')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user's manager based on the assigned user
|
||||
**/
|
||||
/**
|
||||
* Get the user's manager based on the assigned user
|
||||
**/
|
||||
public function manager()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\User', 'manager_id')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user groups
|
||||
*/
|
||||
/**
|
||||
* Get user groups
|
||||
*/
|
||||
public function groups()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\Group', 'users_groups');
|
||||
@@ -209,10 +231,10 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
|
||||
public function accountStatus()
|
||||
{
|
||||
if ($this->sentryThrottle) {
|
||||
if ($this->sentryThrottle->suspended==1) {
|
||||
if ($this->throttle) {
|
||||
if ($this->throttle->suspended==1) {
|
||||
return 'suspended';
|
||||
} elseif ($this->sentryThrottle->banned==1) {
|
||||
} elseif ($this->throttle->banned==1) {
|
||||
return 'banned';
|
||||
} else {
|
||||
return false;
|
||||
@@ -227,19 +249,27 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
return $this->hasMany('\App\Models\Asset', 'id')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get uploads for this asset
|
||||
*/
|
||||
/**
|
||||
* Get uploads for this asset
|
||||
*/
|
||||
public function uploads()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'asset_id')
|
||||
->where('asset_type', '=', 'user')
|
||||
->where('action_type', '=', 'uploaded')
|
||||
->whereNotNull('filename')
|
||||
->orderBy('created_at', 'desc');
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')
|
||||
->where('item_type', User::class)
|
||||
->where('action_type', '=', 'uploaded')
|
||||
->whereNotNull('filename')
|
||||
->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
public function sentryThrottle()
|
||||
/**
|
||||
* Fetch Items User has requested
|
||||
*/
|
||||
public function checkoutRequests()
|
||||
{
|
||||
return $this->belongsToMany(Asset::class, 'checkout_requests');
|
||||
}
|
||||
|
||||
public function throttle()
|
||||
{
|
||||
return $this->hasOne('\App\Models\Throttle');
|
||||
}
|
||||
@@ -254,10 +284,10 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
return $query->whereNull('deleted_at');
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the SentryUser getPersistCode method for
|
||||
* multiple logins at one time
|
||||
**/
|
||||
/**
|
||||
* Override the SentryUser getPersistCode method for
|
||||
* multiple logins at one time
|
||||
**/
|
||||
public function getPersistCode()
|
||||
{
|
||||
|
||||
@@ -275,10 +305,14 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
public function scopeMatchEmailOrUsername($query, $user_username, $user_email)
|
||||
{
|
||||
return $query->where('email', '=', $user_email)
|
||||
->orWhere('username', '=', $user_username)
|
||||
->orWhere('username', '=', $user_email);
|
||||
->orWhere('username', '=', $user_username)
|
||||
->orWhere('username', '=', $user_email);
|
||||
}
|
||||
|
||||
public static function generateEmailFromFullName($name) {
|
||||
$username = User::generateFormattedNameFromFullName(Setting::getSettings()->email_format, $name);
|
||||
return $username['username'].'@'.Setting::getSettings()->email_domain;
|
||||
}
|
||||
|
||||
public static function generateFormattedNameFromFullName($format = 'filastname', $users_name)
|
||||
{
|
||||
@@ -294,7 +328,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
$email_last_name = $last_name;
|
||||
$user_username = $first_name;
|
||||
|
||||
// There is a last name given
|
||||
// There is a last name given
|
||||
} else {
|
||||
|
||||
$last_name = str_replace($first_name, '', $users_name);
|
||||
@@ -310,8 +344,9 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
} elseif ($format=='firstname') {
|
||||
$email_last_name.=str_replace(' ', '', $last_name);
|
||||
$email_prefix = $first_name;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$user_username = $email_prefix;
|
||||
@@ -330,46 +365,46 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
return json_decode($this->permissions, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to search on text
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $search Search term
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
/**
|
||||
* Query builder scope to search on text
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $search Search term
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeTextsearch($query, $search)
|
||||
{
|
||||
|
||||
return $query->where(function ($query) use ($search) {
|
||||
$query->where('users.first_name', 'LIKE', "%$search%")
|
||||
->orWhere('users.last_name', 'LIKE', "%$search%")
|
||||
->orWhere('users.email', 'LIKE', "%$search%")
|
||||
->orWhere('users.username', 'LIKE', "%$search%")
|
||||
->orWhere('users.notes', 'LIKE', "%$search%")
|
||||
->orWhere('users.employee_num', 'LIKE', "%$search%")
|
||||
->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('userloc', function ($query) use ($search) {
|
||||
$query->where('locations.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})
|
||||
->orWhere('users.last_name', 'LIKE', "%$search%")
|
||||
->orWhere('users.email', 'LIKE', "%$search%")
|
||||
->orWhere('users.username', 'LIKE', "%$search%")
|
||||
->orWhere('users.notes', 'LIKE', "%$search%")
|
||||
->orWhere('users.employee_num', 'LIKE', "%$search%")
|
||||
->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('userloc', function ($query) use ($search) {
|
||||
$query->where('locations.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})
|
||||
|
||||
// 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."%') ");
|
||||
});
|
||||
// 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 builder scope for Deleted users
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
/**
|
||||
* Query builder scope for Deleted users
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
|
||||
public function scopeDeleted($query)
|
||||
{
|
||||
@@ -377,28 +412,28 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope to order on manager
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
/**
|
||||
* Query builder scope to order on manager
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderManager($query, $order)
|
||||
{
|
||||
// Left join here, or it will only return results with parents
|
||||
// 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on company
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
/**
|
||||
* Query builder scope to order on company
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderLocation($query, $order)
|
||||
{
|
||||
return $query->leftJoin('locations', 'users.location_id', '=', 'locations.id')->orderBy('locations.name', $order);
|
||||
|
||||
@@ -3,6 +3,8 @@ namespace App\Providers;
|
||||
|
||||
use Validator;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use DB;
|
||||
|
||||
|
||||
/**
|
||||
* This service provider handles a few custom validation rules.
|
||||
@@ -47,6 +49,21 @@ class AppServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Unique only if undeleted
|
||||
// This works around the use case where multiple deleted items have the same unique attribute.
|
||||
// (I think this is a bug in Laravel's validator?)
|
||||
Validator::extend('unique_undeleted', function($attribute, $value, $parameters, $validator) {
|
||||
|
||||
$count = DB::table($parameters[0])->select('id')->where($attribute,'=',$value)->whereNull('deleted_at')->where('id','!=',$parameters[1])->count();
|
||||
|
||||
if ($count < 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,6 @@ class AuthServiceProvider extends ServiceProvider
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
'App\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -26,6 +25,308 @@ class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
$this->registerPolicies($gate);
|
||||
|
||||
//
|
||||
|
||||
// --------------------------------
|
||||
// BEFORE ANYTHING ELSE
|
||||
// --------------------------------
|
||||
// If this condition is true, ANYTHING else below will be asssumed
|
||||
// to be true. This can cause weird blade behavior.
|
||||
$gate->before(function ($user) {
|
||||
if ($user->isSuperUser()) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// --------------------------------
|
||||
// GENERAL GATES
|
||||
// These control general sections of the admin
|
||||
// --------------------------------
|
||||
$gate->define('admin', function ($user) {
|
||||
if ($user->hasAccess('admin')) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
# -----------------------------------------
|
||||
# Reports
|
||||
# -----------------------------------------
|
||||
$gate->define('reports.view', function ($user) {
|
||||
if ($user->hasAccess('reports.view')) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
# -----------------------------------------
|
||||
# Assets
|
||||
# -----------------------------------------
|
||||
$gate->define('assets.view', function ($user) {
|
||||
if (($user->hasAccess('assets.view')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('assets.view.requestable', function ($user) {
|
||||
if (($user->hasAccess('assets.view.requestable')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('assets.create', function ($user) {
|
||||
if (($user->hasAccess('assets.create')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('assets.checkout', function ($user) {
|
||||
if (($user->hasAccess('assets.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('assets.checkin', function ($user) {
|
||||
if (($user->hasAccess('assets.checkin')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('assets.edit', function ($user) {
|
||||
if (($user->hasAccess('assets.edit')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Checks for some level of management
|
||||
$gate->define('assets.manage', function ($user) {
|
||||
if (($user->hasAccess('assets.checkin')) || ($user->hasAccess('assets.edit')) || ($user->hasAccess('assets.delete')) || ($user->hasAccess('assets.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
# -----------------------------------------
|
||||
# Accessories
|
||||
# -----------------------------------------
|
||||
$gate->define('accessories.view', function ($user) {
|
||||
if (($user->hasAccess('accessories.view')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('accessories.create', function ($user) {
|
||||
if (($user->hasAccess('accessories.create')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('accessories.edit', function ($user) {
|
||||
if (($user->hasAccess('accessories.edit')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('accessories.delete', function ($user) {
|
||||
if (($user->hasAccess('accessories.delete')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('accessories.checkout', function ($user) {
|
||||
if (($user->hasAccess('accessories.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('accessories.checkin', function ($user) {
|
||||
if (($user->hasAccess('accessories.checkin')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Checks for some level of management
|
||||
$gate->define('accessories.manage', function ($user) {
|
||||
if (($user->hasAccess('accessories.checkin')) || ($user->hasAccess('accessories.edit')) || ($user->hasAccess('accessories.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
# -----------------------------------------
|
||||
# Consumables
|
||||
# -----------------------------------------
|
||||
$gate->define('consumables.view', function ($user) {
|
||||
if (($user->hasAccess('consumables.view')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('consumables.create', function ($user) {
|
||||
if (($user->hasAccess('consumables.create')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('consumables.edit', function ($user) {
|
||||
if (($user->hasAccess('consumables.edit')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('consumables.delete', function ($user) {
|
||||
if (($user->hasAccess('consumables.delete')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('consumables.checkout', function ($user) {
|
||||
if (($user->hasAccess('consumables.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('consumables.checkin', function ($user) {
|
||||
if (($user->hasAccess('consumables.checkin')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Checks for some level of management
|
||||
$gate->define('consumables.manage', function ($user) {
|
||||
if (($user->hasAccess('consumables.checkin')) || ($user->hasAccess('consumables.edit')) || ($user->hasAccess('consumables.delete')) || ($user->hasAccess('consumables.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
# -----------------------------------------
|
||||
# Users
|
||||
# -----------------------------------------
|
||||
|
||||
$gate->define('users.view', function ($user) {
|
||||
if (($user->hasAccess('users.view')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('users.create', function ($user) {
|
||||
if (($user->hasAccess('users.create')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('users.edit', function ($user) {
|
||||
if (($user->hasAccess('users.edit')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('users.delete', function ($user) {
|
||||
if (($user->hasAccess('users.delete')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
# -----------------------------------------
|
||||
# Components
|
||||
# -----------------------------------------
|
||||
$gate->define('components.view', function ($user) {
|
||||
if (($user->hasAccess('components.view')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('components.create', function ($user) {
|
||||
if (($user->hasAccess('components.create')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('components.edit', function ($user) {
|
||||
if (($user->hasAccess('components.edit')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('components.delete', function ($user) {
|
||||
if (($user->hasAccess('components.delete')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('components.checkout', function ($user) {
|
||||
if (($user->hasAccess('components.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('components.checkout', function ($user) {
|
||||
if (($user->hasAccess('components.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Checks for some level of management
|
||||
$gate->define('components.manage', function ($user) {
|
||||
if (($user->hasAccess('components.edit')) || ($user->hasAccess('components.delete')) || ($user->hasAccess('components.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
# -----------------------------------------
|
||||
# Licenses
|
||||
# -----------------------------------------
|
||||
$gate->define('licenses.view', function ($user) {
|
||||
if (($user->hasAccess('licenses.view')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('licenses.create', function ($user) {
|
||||
if (($user->hasAccess('licenses.create')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('licenses.edit', function ($user) {
|
||||
if (($user->hasAccess('licenses.edit')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('licenses.delete', function ($user) {
|
||||
if (($user->hasAccess('licenses.delete')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('licenses.checkout', function ($user) {
|
||||
if (($user->hasAccess('licenses.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('licenses.checkin', function ($user) {
|
||||
if (($user->hasAccess('licenses.checkin')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('licenses.keys', function ($user) {
|
||||
if (($user->hasAccess('licenses.keys')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Checks for some level of management
|
||||
$gate->define('licenses.manage', function ($user) {
|
||||
if (($user->hasAccess('licenses.checkin')) || ($user->hasAccess('licenses.edit')) || ($user->hasAccess('licenses.delete')) || ($user->hasAccess('licenses.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
10
c3.php
10
c3.php
@@ -48,6 +48,16 @@ if (!function_exists('__c3_error')) {
|
||||
}
|
||||
}
|
||||
|
||||
// phpunit codecoverage shimming
|
||||
if (class_exists('SebastianBergmann\CodeCoverage\CodeCoverage')) {
|
||||
class_alias('SebastianBergmann\CodeCoverage\CodeCoverage', 'PHP_CodeCoverage');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Report\Text', 'PHP_CodeCoverage_Report_Text');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Report\PHP', 'PHP_CodeCoverage_Report_PHP');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Report\Clover', 'PHP_CodeCoverage_Report_Clover');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Report\Html\Facade', 'PHP_CodeCoverage_Report_HTML');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Exception', 'PHP_CodeCoverage_Exception');
|
||||
}
|
||||
|
||||
// Autoload Codeception classes
|
||||
if (!class_exists('\\Codeception\\Codecept')) {
|
||||
if (file_exists(__DIR__ . '/codecept.phar')) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "Snipe-IT Laravel 5.2",
|
||||
"description": "The Laravel Framework.",
|
||||
"keywords": ["framework", "laravel"],
|
||||
"license": "MIT",
|
||||
"name": "snipe/snipe-it",
|
||||
"description": "Open source asset management system built on Laravel.",
|
||||
"keywords": ["assets", "asset-management", "laravel"],
|
||||
"license": "AGPL-3",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
@@ -11,8 +11,8 @@
|
||||
"league/csv": "~7.0",
|
||||
"maknz/slack": "dev-master",
|
||||
"erusev/parsedown": "dev-master",
|
||||
"fideloper/proxy": "2.1.1",
|
||||
"guzzlehttp/guzzle": "5.3.0",
|
||||
"fideloper/proxy": "^3.1",
|
||||
"guzzlehttp/guzzle": "6.2.1",
|
||||
"aws/aws-sdk-php-laravel": "~3.0",
|
||||
"tecnickcom/tc-lib-barcode": "dev-master",
|
||||
"laravelcollective/html" : "~5.0",
|
||||
@@ -21,12 +21,15 @@
|
||||
"doctrine/common": "v2.5.3",
|
||||
"doctrine/dbal": "v2.4.2",
|
||||
"barryvdh/laravel-debugbar": "^2.1",
|
||||
"spatie/laravel-backup": "^3.7"
|
||||
"spatie/laravel-backup": "3.8.1",
|
||||
"misterphilip/maintenance-mode": "1.0.*",
|
||||
"neitanod/forceutf8": "dev-master"
|
||||
},
|
||||
"require-dev": {
|
||||
"fzaninotto/faker": "~1.4",
|
||||
"mockery/mockery": "0.9.*",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"squizlabs/php_codesniffer": "2.*",
|
||||
"phpspec/phpspec": "~2.1",
|
||||
"codeception/codeception": "2.1.*",
|
||||
"symfony/dom-crawler": "~3.0",
|
||||
|
||||
1107
composer.lock
generated
1107
composer.lock
generated
File diff suppressed because it is too large
Load Diff
20
config/app.php
Normal file → Executable file
20
config/app.php
Normal file → Executable file
@@ -117,7 +117,7 @@ return [
|
||||
|--------------------------------------------------------------------------
|
||||
| This is the path for any uploaded files that have to be run through the
|
||||
| auth system to ensure they are not visible to the public. These should be
|
||||
| stored somewhere outside of the web root so that an unautenticated user
|
||||
| stored somewhere outside of the web root so that an unauthenticated user
|
||||
| cannot access them.
|
||||
|
|
||||
| For example: license keys, contracts, etc.
|
||||
@@ -127,6 +127,20 @@ return [
|
||||
'private_uploads' => storage_path().'/private_uploads',
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ALLOW I-FRAMING
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Normal users will never need to edit this. This option lets you run
|
||||
| Snipe-IT within an I-Frame, which is normally disabled by default for
|
||||
| security reasons, to prevent clickjacking. It should normally be set to false.
|
||||
|
|
||||
*/
|
||||
|
||||
'allow_iframing' => env('ALLOW_IFRAMING', false),
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Demo Mode Lockdown
|
||||
@@ -140,7 +154,6 @@ return [
|
||||
'lock_passwords' => env('APP_LOCKED', false),
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autoloaded Service Providers
|
||||
@@ -196,6 +209,9 @@ return [
|
||||
Intervention\Image\ImageServiceProvider::class,
|
||||
Collective\Html\HtmlServiceProvider::class,
|
||||
Spatie\Backup\BackupServiceProvider::class,
|
||||
Fideloper\Proxy\TrustedProxyServiceProvider::class,
|
||||
MisterPhilip\MaintenanceMode\MaintenanceModeServiceProvider::class,
|
||||
MisterPhilip\MaintenanceMode\MaintenanceCommandServiceProvider::class,
|
||||
|
||||
/*
|
||||
* Custom service provider
|
||||
|
||||
1
config/database.php
Normal file → Executable file
1
config/database.php
Normal file → Executable file
@@ -69,6 +69,7 @@ return [
|
||||
'prefix' => env('DB_PREFIX', null),
|
||||
'strict' => false,
|
||||
'engine' => null,
|
||||
'unix_socket' => env('DB_SOCKET',''),
|
||||
'dump_command_path' => env('DB_DUMP_PATH', '/usr/local/bin'), // only the path, so without 'mysqldump'
|
||||
'dump_command_timeout' => 60 * 5, // 5 minute timeout
|
||||
'dump_using_single_transaction' => true, // perform dump using a single transaction
|
||||
|
||||
@@ -99,8 +99,8 @@ return array(
|
||||
'logs' => false, // Add the latest log messages
|
||||
'files' => false, // Show the included files
|
||||
'config' => false, // Display config settings
|
||||
'auth' => false, // Display Laravel authentication status
|
||||
'gate' => false, // Display Laravel Gate checks
|
||||
'auth' => true, // Display Laravel authentication status
|
||||
'gate' => true, // Display Laravel Gate checks
|
||||
'session' => true, // Display session data
|
||||
),
|
||||
|
||||
@@ -119,8 +119,8 @@ return array(
|
||||
),
|
||||
'db' => array(
|
||||
'with_params' => true, // Render SQL with the parameters substituted
|
||||
'timeline' => false, // Add the queries to the timeline
|
||||
'backtrace' => false, // EXPERIMENTAL: Use a backtrace to find the origin of the query in your files.
|
||||
'timeline' => true, // Add the queries to the timeline
|
||||
'backtrace' => true, // EXPERIMENTAL: Use a backtrace to find the origin of the query in your files.
|
||||
'explain' => array( // EXPERIMENTAL: Show EXPLAIN output on queries
|
||||
'enabled' => false,
|
||||
'types' => array('SELECT'), // array('SELECT', 'INSERT', 'UPDATE', 'DELETE'); for MySQL 5.6.3+
|
||||
|
||||
@@ -142,9 +142,9 @@ return [
|
||||
'whenBackupWasSuccessful' => ['log'],
|
||||
'whenCleanupWasSuccessful' => ['log'],
|
||||
'whenHealthyBackupWasFound' => ['log'],
|
||||
'whenBackupHasFailed' => ['log', 'mail'],
|
||||
'whenCleanupHasFailed' => ['log', 'mail'],
|
||||
'whenUnhealthyBackupWasFound' => ['log', 'mail'],
|
||||
'whenBackupHasFailed' => ['log'],
|
||||
'whenCleanupHasFailed' => ['log'],
|
||||
'whenUnhealthyBackupWasFound' => ['log'],
|
||||
],
|
||||
|
||||
/*
|
||||
|
||||
24
config/mail.php
Normal file → Executable file
24
config/mail.php
Normal file → Executable file
@@ -3,6 +3,12 @@
|
||||
return [
|
||||
|
||||
/*
|
||||
| ***************************************************************************
|
||||
| DO NOT MAKE CHANGES DIRECTLY TO THIS FILE.
|
||||
|
|
||||
| Instead use your .env file to set your application configuration settings.
|
||||
| See https://snipe-it.readme.io/docs/configuration for more info.
|
||||
|
|
||||
|--------------------------------------------------------------------------
|
||||
| Mail Driver
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -11,6 +17,7 @@ return [
|
||||
| sending of e-mail. You may specify which one you're using throughout
|
||||
| your application here. By default, Laravel is setup for SMTP mail.
|
||||
|
|
||||
|
|
||||
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "ses", "log"
|
||||
|
|
||||
*/
|
||||
@@ -56,6 +63,23 @@ return [
|
||||
|
||||
'from' => ['address' => env('MAIL_FROM_ADDR', null), 'name' => env('MAIL_FROM_NAME', null)],
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global "Reply-To" Address
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may wish for all e-mails sent by your application to have a different "Reply-to"
|
||||
| address than the "From" address. If this is left blank, the application will use
|
||||
| your MAIL_FROM information.
|
||||
|
|
||||
*/
|
||||
|
||||
'reply_to' => [
|
||||
'address' => env('MAIL_REPLYTO_ADDR', env('MAIL_FROM_ADDR', null)),
|
||||
'name' => env('MAIL_REPLYTO_NAME', env('MAIL_FROM_NAME', null))
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| E-Mail Encryption Protocol
|
||||
|
||||
@@ -6,7 +6,7 @@ return array(
|
||||
array(
|
||||
'permission' => 'superuser',
|
||||
'label' => 'Super User',
|
||||
'note' => 'Determines whether the user has full access to all aspects of the admin. ',
|
||||
'note' => 'Determines whether the user has full access to all aspects of the admin. This setting overrides any more specific permissions throughout the system. ',
|
||||
'display' => true,
|
||||
),
|
||||
),
|
||||
@@ -15,16 +15,22 @@ return array(
|
||||
array(
|
||||
'permission' => 'admin',
|
||||
'label' => '',
|
||||
'note' => 'Determines whether the user has access to most aspects of the admin.',
|
||||
'note' => 'Determines whether the user has access to most aspects of the admin. ',
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'admin.api_key',
|
||||
'label' => 'Create API Key',
|
||||
'note' => 'Determines whether the user can access the API via API key.',
|
||||
'display' => false,
|
||||
),
|
||||
),
|
||||
|
||||
'Reports' => array(
|
||||
array(
|
||||
'permission' => 'reports.view',
|
||||
'label' => '',
|
||||
'note' => 'Determines whether the user has the abiity to view reports.',
|
||||
'label' => 'View',
|
||||
'note' => 'Determines whether the user has the ability to view reports.',
|
||||
'display' => true,
|
||||
),
|
||||
),
|
||||
@@ -32,99 +38,135 @@ return array(
|
||||
'Assets' => array(
|
||||
array(
|
||||
'permission' => 'assets.view',
|
||||
'label' => '',
|
||||
'label' => 'View ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'assets.create',
|
||||
'label' => 'Create Assets',
|
||||
'label' => 'Create ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'assets.edit',
|
||||
'label' => 'Edit Assets',
|
||||
'label' => 'Edit ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'assets.delete',
|
||||
'label' => 'Delete Assets',
|
||||
'label' => 'Delete ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'assets.checkout',
|
||||
'label' => 'View Assets',
|
||||
'label' => 'Checkout ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'permission' => 'assets.checkin',
|
||||
'label' => 'Checkin ',
|
||||
'note' => '',
|
||||
'display' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'permission' => 'assets.checkout',
|
||||
'label' => 'Checkout ',
|
||||
'note' => '',
|
||||
'display' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'permission' => 'assets.audit',
|
||||
'label' => 'Audit ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
),
|
||||
|
||||
|
||||
array(
|
||||
'permission' => 'assets.view.requestable',
|
||||
'label' => 'View Requestable Assets',
|
||||
'note' => '',
|
||||
'display' => true,
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
'Accessories' => array(
|
||||
array(
|
||||
'permission' => 'accessories.view',
|
||||
'label' => '',
|
||||
'label' => 'View ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'accessory.create',
|
||||
'label' => 'Create Assets',
|
||||
'label' => 'Create ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'accessories.edit',
|
||||
'label' => 'Edit Assets',
|
||||
'label' => 'Edit ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'accessories.delete',
|
||||
'label' => 'Delete Assets',
|
||||
'label' => 'Delete ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'accessories.checkout',
|
||||
'label' => 'View Assets',
|
||||
'label' => 'Checkout ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'accessories.checkin',
|
||||
'label' => 'Checkin ',
|
||||
'note' => '',
|
||||
'display' => true,
|
||||
),
|
||||
),
|
||||
|
||||
'Consumables' => array(
|
||||
array(
|
||||
'permission' => 'consumables.view',
|
||||
'label' => '',
|
||||
'label' => 'View',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'consumables.create',
|
||||
'label' => 'Create Consumables',
|
||||
'label' => 'Create ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'consumables.edit',
|
||||
'label' => 'Edit Consumables',
|
||||
'label' => 'Edit ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'consumables.delete',
|
||||
'label' => 'Delete Consumables',
|
||||
'label' => 'Delete ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'consumables.checkout',
|
||||
'label' => 'Checkout Consumables',
|
||||
'label' => 'Checkout ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -132,33 +174,33 @@ return array(
|
||||
'Licenses' => array(
|
||||
array(
|
||||
'permission' => 'licenses.view',
|
||||
'label' => '',
|
||||
'label' => 'View',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'licenses.create',
|
||||
'label' => 'Create Licenses',
|
||||
'label' => 'Create ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'licenses.edit',
|
||||
'label' => 'Edit Licenses',
|
||||
'label' => 'Edit ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'licenses.delete',
|
||||
'label' => 'Delete Licenses',
|
||||
'label' => 'Delete ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'licenses.checkout',
|
||||
'label' => 'Checkout Licenses',
|
||||
'label' => 'Checkout ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'licenses.keys',
|
||||
@@ -172,33 +214,39 @@ return array(
|
||||
'Components' => array(
|
||||
array(
|
||||
'permission' => 'components.view',
|
||||
'label' => '',
|
||||
'label' => 'View',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'components.create',
|
||||
'label' => 'Create Components',
|
||||
'label' => 'Create ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'components.edit',
|
||||
'label' => 'Edit Components',
|
||||
'label' => 'Edit ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'components.delete',
|
||||
'label' => 'Delete Components',
|
||||
'label' => 'Delete ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'components.checkout',
|
||||
'label' => 'Checkout Components',
|
||||
'label' => 'Checkout ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'components.checkin',
|
||||
'label' => 'Checkin ',
|
||||
'note' => '',
|
||||
'display' => true,
|
||||
),
|
||||
|
||||
),
|
||||
@@ -206,27 +254,27 @@ return array(
|
||||
'Users' => array(
|
||||
array(
|
||||
'permission' => 'users.view',
|
||||
'label' => 'View Users',
|
||||
'label' => 'View ',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'users.create',
|
||||
'label' => 'Create Users',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'users.edit',
|
||||
'label' => 'Edit Users',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
array(
|
||||
'permission' => 'users.delete',
|
||||
'label' => 'Delete Users',
|
||||
'note' => '',
|
||||
'display' => false,
|
||||
'display' => true,
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
23
config/trustedproxy.php
Normal file
23
config/trustedproxy.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
* Set trusted proxy IP addresses.
|
||||
*
|
||||
* Both IPv4 and IPv6 addresses are
|
||||
* supported, along with CIDR notation.
|
||||
*
|
||||
* The "*" character is syntactic sugar
|
||||
* within TrustedProxy to trust any proxy;
|
||||
* a requirement when you cannot know the address
|
||||
* of your proxy (e.g. if using Rackspace balancers).
|
||||
*/
|
||||
'proxies' => env('APP_TRUSTED_PROXIES') !== null ? explode(env('APP_TRUSTED_PROXIES'), ',') : '*',
|
||||
|
||||
/*
|
||||
* Or, to trust all proxies, uncomment this:
|
||||
*/
|
||||
# 'proxies' => '*',
|
||||
|
||||
];
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
return array (
|
||||
'app_version' => 'v3.0.0-dev',
|
||||
'hash_version' => 'v3.0.0-dev-g6d810a9',
|
||||
'app_version' => 'v3.5.0-beta2',
|
||||
'hash_version' => 'v3.5.0-beta2-53-g87f50df',
|
||||
);
|
||||
|
||||
@@ -25,6 +25,7 @@ $factory->defineAs(App\Models\Asset::class, 'asset', function (Faker\Generator $
|
||||
'order_number' => $faker->numberBetween(1000000,50000000),
|
||||
'supplier_id' => $faker->numberBetween(1,5),
|
||||
'requestable' => $faker->numberBetween(0,1),
|
||||
'company_id' => \App\Models\Company::inRandomOrder()->first()->id
|
||||
];
|
||||
});
|
||||
|
||||
@@ -96,6 +97,7 @@ $factory->defineAs(App\Models\Component::class, 'component', function (Faker\Gen
|
||||
'category_id' => $faker->numberBetween(21,25),
|
||||
'total_qty' => $faker->numberBetween(3, 10),
|
||||
'min_amt' => $faker->numberBetween($min = 1, $max = 2),
|
||||
'company_id' => \App\Models\Company::inRandomOrder()->first()->id
|
||||
];
|
||||
});
|
||||
|
||||
@@ -113,6 +115,7 @@ $factory->defineAs(App\Models\Accessory::class, 'accessory', function (Faker\Gen
|
||||
'qty' => $faker->numberBetween(5, 10),
|
||||
'location_id' => $faker->numberBetween(1,5),
|
||||
'min_amt' => $faker->numberBetween($min = 1, $max = 2),
|
||||
'company_id' => \App\Models\Company::inRandomOrder()->first()->id
|
||||
];
|
||||
});
|
||||
|
||||
@@ -138,6 +141,7 @@ $factory->defineAs(App\Models\Consumable::class, 'consumable', function (Faker\G
|
||||
'company_id' => $faker->numberBetween(1, 10),
|
||||
'qty' => $faker->numberBetween(5, 10),
|
||||
'min_amt' => $faker->numberBetween($min = 1, $max = 2),
|
||||
'company_id' => \App\Models\Company::inRandomOrder()->first()->id
|
||||
|
||||
];
|
||||
});
|
||||
@@ -251,6 +255,7 @@ $factory->defineAs(App\Models\License::class, 'license', function (Faker\Generat
|
||||
'purchase_date' => $faker->dateTime(),
|
||||
'purchase_cost' => $faker->randomFloat(2),
|
||||
'notes' => $faker->sentence,
|
||||
'company_id' => \App\Models\Company::inRandomOrder()->first()->id
|
||||
];
|
||||
});
|
||||
|
||||
@@ -265,18 +270,82 @@ $factory->defineAs(App\Models\LicenseSeat::class, 'license-seat', function (Fake
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Actionlog::class, 'asset-checkout', function (Faker\Generator $faker) {
|
||||
$company = \App\Models\Company::has('users')->has('assets')->inRandomOrder()->first();
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'user_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'action_type' => 'checkout',
|
||||
'asset_id' => $faker->numberBetween(1, 10),
|
||||
'checkedout_to' => 1,
|
||||
'item_id' => $company->assets()->inRandomOrder()->first()->id,
|
||||
'target_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'target_type' => 'App\\Models\\User',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'asset_type' => 'hardware',
|
||||
'item_type' => 'App\\Models\\Asset',
|
||||
'note' => $faker->sentence,
|
||||
'user_id' => '1',
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Actionlog::class, 'license-checkout-asset', function (Faker\Generator $faker) {
|
||||
$company = \App\Models\Company::has('users')->has('licenses')->inRandomOrder()->first();
|
||||
|
||||
return [
|
||||
'user_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $company->licenses()->whereNotNull('company_id')->inRandomOrder()->first()->id,
|
||||
'target_id' => $company->assets()->inRandomOrder()->first()->id,
|
||||
'target_type' => 'App\\Models\\Asset',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'item_type' => 'App\\Models\\License',
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Actionlog::class, 'accessory-checkout', function (Faker\Generator $faker) {
|
||||
$company = \App\Models\Company::has('users')->has('accessories')->inRandomOrder()->first();
|
||||
return [
|
||||
'user_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $company->accessories()->whereNotNull('company_id')->inRandomOrder()->first()->id,
|
||||
'target_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'target_type' => 'App\\Models\\User',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'item_type' => 'App\\Models\\Accessory',
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Actionlog::class, 'consumable-checkout', function (Faker\Generator $faker) {
|
||||
$company = \App\Models\Company::has('users')->has('consumables')->inRandomOrder()->first();
|
||||
|
||||
return [
|
||||
'user_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $company->consumables()->whereNotNull('company_id')->inRandomOrder()->first()->id,
|
||||
'target_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'target_type' => 'App\\Models\\User',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'item_type' => 'App\\Models\\Consumable',
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Actionlog::class, 'component-checkout', function (Faker\Generator $faker) {
|
||||
$company = \App\Models\Company::has('users')->has('components')->inRandomOrder()->first();
|
||||
|
||||
return [
|
||||
'user_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $company->components()->whereNotNull('company_id')->inRandomOrder()->first()->id,
|
||||
'target_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'target_type' => 'App\\Models\\User',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'item_type' => 'App\\Models\\Component',
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\CustomField::class, 'customfield-ip', function (Faker\Generator $faker) {
|
||||
return [
|
||||
@@ -294,5 +363,6 @@ $factory->defineAs(App\Models\User::class, 'valid-user', function (Faker\Generat
|
||||
'email' => $faker->safeEmail,
|
||||
'password' => $faker->password,
|
||||
'username' => $faker->username,
|
||||
'company_id' => \App\Models\Company::inRandomOrder()->first()->id
|
||||
];
|
||||
});
|
||||
|
||||
@@ -18,9 +18,9 @@ class UpdateGroupFieldForReporting extends Migration {
|
||||
// //
|
||||
// });
|
||||
|
||||
DB::update('update groups set permissions = ? where id = ?', ['{"admin":1,"users":1,"reports":1}', 1]);
|
||||
DB::update('update '.DB::getTablePrefix().'groups set permissions = ? where id = ?', ['{"admin":1,"users":1,"reports":1}', 1]);
|
||||
|
||||
DB::update('update groups set permissions = ? where id = ?', ['{"users":1,"reports":1}', 2]);
|
||||
DB::update('update '.DB::getTablePrefix().'groups set permissions = ? where id = ?', ['{"users":1,"reports":1}', 2]);
|
||||
|
||||
// DB::statement('UPDATE '.$prefix.'groups SET permissions="{\"admin\":1,\"users\":1,\"reports\":1}" where id=1');
|
||||
// DB::statement('UPDATE '.$prefix.'groups SET permissions="{\"users\":1,\"reports\":1}" where id=2');
|
||||
|
||||
@@ -44,9 +44,9 @@
|
||||
{
|
||||
|
||||
return [
|
||||
Lang::get( 'admin/asset_maintenances/general.maintenance' ),
|
||||
Lang::get( 'admin/asset_maintenances/general.repair' ),
|
||||
Lang::get( 'admin/asset_maintenances/general.upgrade' )
|
||||
trans( 'admin/asset_maintenances/general.maintenance' ),
|
||||
trans( 'admin/asset_maintenances/general.repair' ),
|
||||
trans( 'admin/asset_maintenances/general.upgrade' )
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@ class AddCurrencyToSettingsAndLocations extends Migration {
|
||||
$table->string('default_currency',10)->nullable()->default(NULL);
|
||||
});
|
||||
|
||||
DB::update('UPDATE `'.DB::getTablePrefix().'settings` SET `default_currency`="'. Lang::get('general.currency').'"');
|
||||
DB::update('UPDATE `'.DB::getTablePrefix().'settings` SET `default_currency`="'. trans('general.currency').'"');
|
||||
|
||||
Schema::table('locations', function(Blueprint $table)
|
||||
{
|
||||
$table->string('currency',10)->nullable()->default(NULL);
|
||||
});
|
||||
|
||||
DB::update('UPDATE `'.DB::getTablePrefix().'locations` SET `currency`="'. Lang::get('general.currency').'"');
|
||||
DB::update('UPDATE `'.DB::getTablePrefix().'locations` SET `currency`="'. trans('general.currency').'"');
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use App\Models\Actionlog;
|
||||
|
||||
class AddThreadIdToAssetLogsTable extends Migration
|
||||
{
|
||||
@@ -63,39 +64,39 @@
|
||||
public function up()
|
||||
{
|
||||
|
||||
if (!Schema::hasColumn('asset_logs', 'thread_id')) {
|
||||
// if (!Schema::hasColumn('asset_logs', 'thread_id')) {
|
||||
|
||||
Schema::table( 'asset_logs', function ( Blueprint $table ) {
|
||||
// Schema::table( 'asset_logs', function ( Blueprint $table ) {
|
||||
|
||||
$table->integer( 'thread_id' )
|
||||
->nullable()
|
||||
->default( null );
|
||||
$table->index( 'thread_id' );
|
||||
} );
|
||||
}
|
||||
// $table->integer( 'thread_id' )
|
||||
// ->nullable()
|
||||
// ->default( null );
|
||||
// $table->index( 'thread_id' );
|
||||
// } );
|
||||
// }
|
||||
|
||||
$this->actionlog = new App\Models\Actionlog();
|
||||
$this->assetLogs = $this->actionlog->getListingOfActionLogsChronologicalOrder();
|
||||
// $this->actionlog = new App\Models\Actionlog();
|
||||
// $this->assetLogs = $this->actionlog->getListingOfActionLogsChronologicalOrder();
|
||||
|
||||
foreach ($this->assetLogs as $assetLog) {
|
||||
// foreach ($this->assetLogs as $assetLog) {
|
||||
|
||||
if ($this->hasAssetChanged( $assetLog )) {
|
||||
$this->resetCurrentAssetInformation( $assetLog );
|
||||
}
|
||||
// if ($this->hasAssetChanged( $assetLog )) {
|
||||
// $this->resetCurrentAssetInformation( $assetLog );
|
||||
// }
|
||||
|
||||
if ($this->hasBegunNewChain( $assetLog )) {
|
||||
$this->startOfCurrentThread = false;
|
||||
continue;
|
||||
}
|
||||
// if ($this->hasBegunNewChain( $assetLog )) {
|
||||
// $this->startOfCurrentThread = false;
|
||||
// continue;
|
||||
// }
|
||||
|
||||
$this->updateAssetLogWithThreadInformation( $assetLog );
|
||||
// $this->updateAssetLogWithThreadInformation( $assetLog );
|
||||
|
||||
if ($this->hasReachedEndOfChain( $assetLog )
|
||||
) {
|
||||
$this->clearCurrentAssetInformation();
|
||||
}
|
||||
// if ($this->hasReachedEndOfChain( $assetLog )
|
||||
// ) {
|
||||
// $this->clearCurrentAssetInformation();
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ class RemoveOptionKeysFromSettingsTable extends Migration
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
//
|
||||
$table->dropColumn('option_name');
|
||||
$table->dropColumn('option_value');
|
||||
if(Schema::hasColumn('settings', 'option_name'))
|
||||
$table->dropColumn('option_name');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ class RemoveOptionKeysFromSettingsTable extends Migration
|
||||
{
|
||||
Schema::table('Settings', function (Blueprint $table) {
|
||||
//
|
||||
$table->string('option_name')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class RemoveOptionValueFromSettingsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
//
|
||||
if(Schema::hasColumn('settings', 'option_value'))
|
||||
$table->dropColumn('option_value');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->string('option_value')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddEmailDomainAndFormatToSettings extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->string('email_domain')->nullable()->default(NULL);
|
||||
$table->string('email_format')->nullable()->default('filastname');
|
||||
$table->string('username_format')->nullable()->default('filastname');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('settings', function ($table) {
|
||||
$table->dropColumn(
|
||||
'email_domain',
|
||||
'email_format',
|
||||
'username_format'
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddUserIdToMaintenances extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('asset_maintenances', function (Blueprint $table) {
|
||||
$table->integer('user_id')->nullable()->default(NULL);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('asset_maintenances', function ($table) {
|
||||
$table->dropColumn('user_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddIsAdToSettings extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->boolean('is_ad')->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('settings', function ($table) {
|
||||
$table->dropColumn('is_ad');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddAdDomainToSettings extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->string('ad_domain')->nullable()->default(NULL);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('settings', function ($table) {
|
||||
$table->dropColumn('ad_domain');
|
||||
});
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user