Compare commits
1339 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 43cdace9de | |||
| a04af4aead | |||
| e7eec42ab8 | |||
| 063e5c407c | |||
| 3ba02b65fb | |||
| 88dc0700f0 | |||
| 899e2bc9b6 | |||
| 1e4071b51d | |||
| 38961298ed | |||
| ea6a6d098a | |||
| 1f0f9c2441 | |||
| d4fbea3571 | |||
| b32d74de57 | |||
| 4e4144ea74 | |||
| 7b331b26d3 | |||
| e02bea4275 | |||
| 24f5cdc743 | |||
| 08ee02d0cd | |||
| ec1ab6913e | |||
| f40bb7b8b3 | |||
| 17258b73a1 | |||
| 4a5007264e | |||
| bd01b11f4f | |||
| 064c0211db | |||
| 4cb931a93b | |||
| 3df8243d80 | |||
| f57c61dd4d | |||
| 7a4f115cb3 | |||
| 58ff929d71 | |||
| 49f25a23a9 | |||
| bcf75073ec | |||
| 6908456d09 | |||
| c26369f8cc | |||
| 56e090f3e7 | |||
| 00f7717142 | |||
| 823e0c8562 | |||
| 95be7908f8 | |||
| c660c71556 | |||
| fbf03b225d | |||
| a5f4c51ab2 | |||
| 89dce89035 | |||
| 8cdd215614 | |||
| 342a8b81af | |||
| cd5a352961 | |||
| a451fa1fa6 | |||
| e343c157c5 | |||
| 37fc216c5a | |||
| 96feb84fd4 | |||
| 80e10c4c98 | |||
| 35a133bbf9 | |||
| 0adbce77f9 | |||
| c89be34503 | |||
| 9c3873e712 | |||
| 4f6eeda368 | |||
| f690cd6305 | |||
| 447ed3518e | |||
| d9d99b2223 | |||
| 2b99adba5f | |||
| 11aa98d389 | |||
| 591f97f149 | |||
| ef696f8207 | |||
| ab1c921443 | |||
| 7b165a12e0 | |||
| 6f2f7cc214 | |||
| 89729bfa51 | |||
| 34032c73ce | |||
| f72b385790 | |||
| d541ded862 | |||
| 8cc95a3b9b | |||
| bf9a825095 | |||
| 5c92be5190 | |||
| fa9cf35ff5 | |||
| f36029a34a | |||
| c2e532e32e | |||
| 9bcc9a7ed1 | |||
| 7715731c4a | |||
| a2178392e6 | |||
| 0aa4d2a3db | |||
| 5867c60410 | |||
| 268fb98dbb | |||
| 5f1227d0fa | |||
| 1b93c5538a | |||
| 3645f85731 | |||
| 0b02b1631b | |||
| 31f4ba88f6 | |||
| c06a4d4118 | |||
| dbc93de6b3 | |||
| 2277b6ee69 | |||
| b36d73a4bb | |||
| 283d2855d7 | |||
| f175f52530 | |||
| e29da5521d | |||
| 1db1819a56 | |||
| aef3a734a3 | |||
| d2438f9fdb | |||
| 53d000e2d0 | |||
| addfcd4bc5 | |||
| b360736b77 | |||
| 2bae77b3af | |||
| c1600a33db | |||
| 5d3b84e01a | |||
| 7ed098de67 | |||
| 22af5561b2 | |||
| 7009b24748 | |||
| 389c27b2e6 | |||
| a61e913824 | |||
| 95ae26eb2a | |||
| cfebe11755 | |||
| d86b5aa613 | |||
| c255de7fc0 | |||
| 42d5d8db80 | |||
| 91bf9763d2 | |||
| 9c66dd5431 | |||
| 614396a15b | |||
| cfe0472ea2 | |||
| d20b5136b8 | |||
| 29f5b7c5e3 | |||
| 140bd137a4 | |||
| 3a9cb9ba7a | |||
| 6d0828bfe5 | |||
| 51a7752771 | |||
| a8681225f5 | |||
| 26a59afa44 | |||
| e22ce0d377 | |||
| 2fbef7f561 | |||
| 2678611c79 | |||
| 416cd236d2 | |||
| 4936a5914f | |||
| 36fce27297 | |||
| 4b2e45c5f2 | |||
| 11f46474ab | |||
| b0d52a4158 | |||
| 7b4845c255 | |||
| 223ba349ea | |||
| feeef4b66c | |||
| 42f8a35078 | |||
| 0128505213 | |||
| 06bee68cd2 | |||
| c255edaf61 | |||
| 7f0e21d50c | |||
| 1aeb4de0fa | |||
| bff33cb7f5 | |||
| 5695815360 | |||
| e67ba8a743 | |||
| 3669ab2ae8 | |||
| e2ee954592 | |||
| b4750f016d | |||
| 7069d9c6b1 | |||
| 8e0d774023 | |||
| 394836821c | |||
| a1ac7f8676 | |||
| cd338d2a70 | |||
| 4dc81ce65f | |||
| f5efc368a5 | |||
| 1db806f8b2 | |||
| b3af102d22 | |||
| 2b86f14e30 | |||
| 3f0e494276 | |||
| a4bac03692 | |||
| 950567e9d6 | |||
| dede09e9c5 | |||
| 3787a3f4ba | |||
| 95141d49ba | |||
| d85e524680 | |||
| 4a77dee79c | |||
| 6fba41e026 | |||
| f39922f51f | |||
| 53085983f8 | |||
| 4a2ac03ace | |||
| 548de1a1a2 | |||
| 82560b1098 | |||
| 3c141e8f50 | |||
| 5e496672c6 | |||
| 4887c53f25 | |||
| 2b79a61d65 | |||
| 5268c579e2 | |||
| 21448ea8e6 | |||
| 778a7bb18c | |||
| 685881cf27 | |||
| cf4b80bbd5 | |||
| 5c98dae57d | |||
| e434616db8 | |||
| 8a7b7418db | |||
| 533be7f942 | |||
| 094ec50a68 | |||
| 98a29e460d | |||
| 27fabfd110 | |||
| dce1d47228 | |||
| 9bbec53635 | |||
| 82232a34ee | |||
| 3d1795e312 | |||
| d858861d0f | |||
| eec36cb13a | |||
| cee966e76e | |||
| dcf2b428da | |||
| 80d8432c35 | |||
| 8ec5934af5 | |||
| 31f77dcb4b | |||
| 0663ccb99f | |||
| 19189f688f | |||
| 7849320db0 | |||
| cc8ca54b3f | |||
| ecb4d0d948 | |||
| f20566f222 | |||
| 73dd339772 | |||
| 5a6139fb64 | |||
| 0fb2728e3f | |||
| 5e6c4a250a | |||
| bf96aae9d9 | |||
| daefc86e58 | |||
| 64c16a0bac | |||
| 89a2b87e42 | |||
| 1b41c974cf | |||
| d6a0249c60 | |||
| 6a6676b1e7 | |||
| 1024816313 | |||
| 6905d82fc4 | |||
| 22746db8b7 | |||
| b826673d0d | |||
| 637009054c | |||
| 5f5be6aa2a | |||
| a863cf1615 | |||
| 05d8ff0252 | |||
| b73ae3147a | |||
| 81b2ce33c2 | |||
| 501e1749b3 | |||
| 53f279f55f | |||
| f5fb2525de | |||
| 53951c8bbc | |||
| 00755eadf0 | |||
| 13b173409f | |||
| 7ddc6d497a | |||
| 2829eeca7c | |||
| e39227633f | |||
| 89c7159c56 | |||
| 6854453bc5 | |||
| ce9c616843 | |||
| 40b0ced8da | |||
| 57ec8aa3c2 | |||
| 02feb69d5d | |||
| fc2d472ed3 | |||
| b622d977d9 | |||
| 6d2a073d04 | |||
| 564cf90e58 | |||
| c60e40096a | |||
| 74ae2fceea | |||
| 02605bdf69 | |||
| 432e348e56 | |||
| d91a7c7aa8 | |||
| f2ae05786b | |||
| 3d3e2dc985 | |||
| 3c3617d641 | |||
| b518162c50 | |||
| b2d5dc9ec5 | |||
| cff24309a1 | |||
| b25c94e429 | |||
| 53a47743e8 | |||
| 8a10386737 | |||
| 7e95d36245 | |||
| f90327ee9c | |||
| 3b5670965c | |||
| 8699a90093 | |||
| 562e5cd700 | |||
| 3f7486e1a9 | |||
| 0eb6183711 | |||
| cdf5ecc084 | |||
| 0eda46da0c | |||
| 1047c5c8bb | |||
| 5f6f3de25e | |||
| 7833d10006 | |||
| 122b3d89d9 | |||
| 14801eca79 | |||
| 4a4b974f41 | |||
| ab7b828e33 | |||
| b0e87d967a | |||
| a0001fe1ed | |||
| ac5fa1641e | |||
| 7c16dd8c92 | |||
| 294b02127b | |||
| e04cc806d9 | |||
| 2bee522a7c | |||
| 5441dd41f0 | |||
| 7858252fca | |||
| 6c6d31f15a | |||
| 6b2d3efe3e | |||
| 1078dbf5c5 | |||
| 300c262739 | |||
| 25a7b05de6 | |||
| 70d7748229 | |||
| 6315db7fd8 | |||
| 343798d241 | |||
| 5050862979 | |||
| 90baf2eeba | |||
| 0022389463 | |||
| 04123b3fe8 | |||
| 491de30374 | |||
| 0d402f52c8 | |||
| 55cd7c0f81 | |||
| 63656762b0 | |||
| 87a9399b6b | |||
| ed5ff9a01b | |||
| 68bf40a7ea | |||
| 0cf24bdde1 | |||
| 05502cf29d | |||
| 1305ea9597 | |||
| 94e1fcb01b | |||
| 9c01ab334f | |||
| b685ea666c | |||
| ee35948980 | |||
| 569714315c | |||
| f09455117b | |||
| af70559754 | |||
| 07e6d49dce | |||
| 86597bb863 | |||
| 6d057846a1 | |||
| ba9f8c61f1 | |||
| d3266dd4e8 | |||
| 9143ac461f | |||
| 7199d6fd22 | |||
| 2b21b26950 | |||
| c122cc2647 | |||
| ced8610833 | |||
| af63d34412 | |||
| 9e85dcb9fc | |||
| 687c629953 | |||
| 13b3e2c4d4 | |||
| 4d8e663bd1 | |||
| 3e11ea70da | |||
| 86b7b6946f | |||
| 3184c3e03b | |||
| 55eb4325bc | |||
| d4ef8a75b8 | |||
| cf4804a994 | |||
| 22590e2a43 | |||
| d9f86df05f | |||
| 636eb29421 | |||
| 5dea4c7691 | |||
| 672e2e5fd4 | |||
| 42ad3da3d3 | |||
| bb3aa99b9c | |||
| 676155eacb | |||
| 54071d1837 | |||
| 5abc4467df | |||
| ffe095d64b | |||
| ce566509ce | |||
| 84cb51b4c3 | |||
| 9b0d930a21 | |||
| 1680d45163 | |||
| 5e1f61ea2a | |||
| 75d0136d7f | |||
| 30428cb858 | |||
| 26ab53c02c | |||
| d8815b5ef5 | |||
| e8737b156a | |||
| f200e81334 | |||
| 03f3294873 | |||
| da70d5042c | |||
| 239370058c | |||
| 0b4c1b8d83 | |||
| 736c9a1ad7 | |||
| fb46a04d78 | |||
| e9e332e19e | |||
| 16420dafa9 | |||
| 22f81912e4 | |||
| e61f93deb8 | |||
| 8d2b09a647 | |||
| b11a0cb436 | |||
| dd923984ef | |||
| d36c73550b | |||
| bbfc87dddf | |||
| 90497bb6a4 | |||
| 35ce00f6ab | |||
| 3cbd8c9b5d | |||
| 599520dff6 | |||
| 309772e67d | |||
| 139a0a2e2a | |||
| 88459b755f | |||
| e17de3d34f | |||
| a6cd7c0bab | |||
| 062d16b2c0 | |||
| 7f44d6dd47 | |||
| 9125def119 | |||
| 024972e239 | |||
| b0e1ef6024 | |||
| d74bddb51f | |||
| 189523a943 | |||
| 98b96d372d | |||
| 14a9500c6f | |||
| 0e9e659dc4 | |||
| 7bea50feca | |||
| 8f582f29e2 | |||
| cbf23fc455 | |||
| fafd03f00f | |||
| 05fb2a434c | |||
| e43a94586b | |||
| 0d12428140 | |||
| 692c861594 | |||
| c68d76870e | |||
| 255b618559 | |||
| bf1e075551 | |||
| 7c97477a53 | |||
| ee7d9bec70 | |||
| 58a99a2219 | |||
| a829fcf52f | |||
| af450c9bcc | |||
| 5575567726 | |||
| 97724a95e3 | |||
| 2bf57febd8 | |||
| a82a35d921 | |||
| 94ead64386 | |||
| e978038cc0 | |||
| 96e40d72b9 | |||
| 284154a2d7 | |||
| e0da7ffe9b | |||
| 35479bfa40 | |||
| 582a9bf78b | |||
| e8c197c6a5 | |||
| ec658b0cf5 | |||
| 68d44e65d3 | |||
| 6fd0cbe044 | |||
| 4629875bdf | |||
| 297f986c4b | |||
| ccb49f4b23 | |||
| 49c5607e1c | |||
| 13f61e1e8a | |||
| cd4e994ef5 | |||
| 974fb6b9ae | |||
| 4365659a2c | |||
| 363d084bd6 | |||
| 69cd6404f5 | |||
| 229291999f | |||
| 2cb61ab1c5 | |||
| 652f1c746c | |||
| caaa96ec67 | |||
| db49e570fd | |||
| e242f8da0d | |||
| 8d3d8c86b1 | |||
| 144c9eb7f8 | |||
| 9ccc7d756f | |||
| b1fafa7ca4 | |||
| 62a3ed671b | |||
| 7ac06fa004 | |||
| 54c3dfbcce | |||
| 0dfc9660ca | |||
| d6404dc734 | |||
| d482b1ea69 | |||
| 8c7be8fbb3 | |||
| 3944ebddf3 | |||
| 6cfb4ab5d8 | |||
| 64abdddccb | |||
| 23a64cfe26 | |||
| 448b54d8e2 | |||
| 72671d3e1d | |||
| efbe7b0fee | |||
| af083570a0 | |||
| 87c2a4c9c0 | |||
| cb8369e9de | |||
| 6c5bbec44e | |||
| d71a02982d | |||
| b8a4c7e4d6 | |||
| 8197e6174e | |||
| 3de929bb28 | |||
| f2036e0951 | |||
| 213e313e45 | |||
| a695d8513c | |||
| 69fca5d1ed | |||
| 94daba9bab | |||
| 56d619b218 | |||
| dc1033025a | |||
| a4b220d6c3 | |||
| a8c2955218 | |||
| 03cd9f893c | |||
| 4f04b96a13 | |||
| d2d85436ad | |||
| 85cd343bb6 | |||
| 6f6b98186e | |||
| f855be45aa | |||
| ddf946ad5e | |||
| 4a13cded60 | |||
| 27e43eebcb | |||
| 196dbb856e | |||
| 3d91a43554 | |||
| 9df9371ffe | |||
| ca24ef1cd8 | |||
| ac4c905c42 | |||
| 7f48ca04b0 | |||
| 39fff92bdb | |||
| 43b98eff92 | |||
| e203fc516f | |||
| ff61705a8f | |||
| aa8bbb88e9 | |||
| 7d04ded02a | |||
| 04ea0528a8 | |||
| 89000440f3 | |||
| 73b469621f | |||
| e94087d62b | |||
| 21251b4623 | |||
| 381f99543f | |||
| 6f2b78ad9f | |||
| 6043321bed | |||
| 03dffa3541 | |||
| 99003e126a | |||
| 82a84310ed | |||
| 9dc40a3a9c | |||
| 784f7e8dec | |||
| deb9f42ec8 | |||
| beb4d6500a | |||
| 45fa66b41e | |||
| 8eb2523293 | |||
| 2b9494ed82 | |||
| 66c9264fcb | |||
| f22f23f21d | |||
| 90eb883b67 | |||
| 300358bc46 | |||
| 3cffff3415 | |||
| 4253744d9d | |||
| 6b5a552d95 | |||
| 43485e1a51 | |||
| 5cdceb1db1 | |||
| 0c285d64bc | |||
| 38cdbf8804 | |||
| 9606834e14 | |||
| 276b1553c1 | |||
| 182f2bfa62 | |||
| 5266d9a30a | |||
| 6068a940bd | |||
| fc032c95b4 | |||
| 2265b9321e | |||
| a7b809cb91 | |||
| af269b536e | |||
| 89a8f3c277 | |||
| 57b3f6c44f | |||
| 380ff9917d | |||
| 6532f1aba5 | |||
| 49dfd259b4 | |||
| fad2ec66fa | |||
| e455de65f9 | |||
| 7a0c1cc6ff | |||
| 2517359f3a | |||
| c782f29f5a | |||
| 2825bcb431 | |||
| 1117c2958a | |||
| 4464c221b7 | |||
| 21e6f2c249 | |||
| ec9eab81bf | |||
| b863bd2c53 | |||
| 09ca2be28d | |||
| a170efae27 | |||
| 919119c5b9 | |||
| 7cb0db5b83 | |||
| d24c4ed7eb | |||
| a0f7083e9c | |||
| 8b914102b7 | |||
| 77f4848d6e | |||
| afabd28142 | |||
| 67d23bdb45 | |||
| 124acc89c4 | |||
| 5c0e912080 | |||
| 47a8363f1d | |||
| b09aec67f1 | |||
| 86400f435b | |||
| 82f0c6f00c | |||
| 9fe76a21f6 | |||
| 264a6e304d | |||
| ad62ec7540 | |||
| 3b9f96419b | |||
| 6b8ed1a1ad | |||
| 164ca5f77b | |||
| a142afe177 | |||
| 15d48c903e | |||
| cbd3420327 | |||
| 380417953b | |||
| 6f42b3045e | |||
| b717a3ee34 | |||
| 945cb3253f | |||
| 3e7a9e45d1 | |||
| 0c9d94deb1 | |||
| 19de7425e6 | |||
| 3cc038208f | |||
| a48efb8855 | |||
| 7ddf84adf7 | |||
| 57628d725e | |||
| 45f353e575 | |||
| bef5170b7c | |||
| e7e75631c5 | |||
| a4c931e4fd | |||
| d1499deecd | |||
| b365ada0ce | |||
| 185ffd3df1 | |||
| 5fdb61589f | |||
| b3292c3a35 | |||
| 4ce1c94bc3 | |||
| 08d05b481f | |||
| 7742bb30c1 | |||
| bf3062f4ef | |||
| 8f744e02fd | |||
| ba3e56df9a | |||
| 8aebaaf502 | |||
| c937796224 | |||
| 74653d3480 | |||
| 65d298a557 | |||
| 04f23ef792 | |||
| 507b6e5128 | |||
| 4271f5265d | |||
| d9a8ede623 | |||
| 117ed3294b | |||
| cd0f42c508 | |||
| 2fe66c1bdc | |||
| dae3220f2b | |||
| 7448db6334 | |||
| 2f90069792 | |||
| ffab309940 | |||
| 34b4615f4e | |||
| 75590b6852 | |||
| 610c405aa5 | |||
| 94016678f8 | |||
| dc256583d4 | |||
| cbc945299e | |||
| 607484b294 | |||
| 9714178ce1 | |||
| 46afc0cc73 | |||
| dfa5d1c642 | |||
| e463b28b37 | |||
| 9db6605085 | |||
| d57955c7e7 | |||
| ad9b1fc446 | |||
| 3518ab9f55 | |||
| cd8ebbd7b6 | |||
| c2ed0f6b21 | |||
| f4c5da57d0 | |||
| 8a7f71ec56 | |||
| b627c5cfbf | |||
| c21c3a4a9e | |||
| d29e30bcf6 | |||
| 1cf42932fb | |||
| fee5fcf608 | |||
| e512b8f7ef | |||
| 5e1fedda45 | |||
| d0789da472 | |||
| fc21fc1aab | |||
| 24ae1b948f | |||
| f1cc547151 | |||
| 594212db6b | |||
| ca0f5df63a | |||
| 57e903a926 | |||
| 06067fc19c | |||
| 67aba76d3f | |||
| 96e47612fa | |||
| 97af71d592 | |||
| 71c0c01430 | |||
| 78f4615d01 | |||
| d93639d480 | |||
| 70fb2d98a0 | |||
| 34960e26cc | |||
| 3473ef5fa6 | |||
| 2fc197623a | |||
| 7bc681dfef | |||
| af603f0380 | |||
| 1d10425d19 | |||
| 5690e9ce1f | |||
| 792e45bd12 | |||
| 5a798110ad | |||
| ad8b95f07c | |||
| 729f94331f | |||
| faa9b95a6f | |||
| 0e633efca2 | |||
| b2015e7e08 | |||
| efad5db082 | |||
| 9423c9e9d3 | |||
| 366e7d01a3 | |||
| 869cd3ea14 | |||
| a2f068eb8f | |||
| 580590b4c0 | |||
| 5ec87e81b1 | |||
| 60d94eea04 | |||
| 78e3171fa6 | |||
| d03d692868 | |||
| 4b4eefb4cc | |||
| 940cf7b227 | |||
| 3e47e47add | |||
| 8b3f409703 | |||
| d497a84245 | |||
| 01612652b5 | |||
| 5cb0a1465e | |||
| 55b54e0a42 | |||
| a3eb61b307 | |||
| 9e5e9ee96b | |||
| 92347c6707 | |||
| dc5ea81d34 | |||
| 9c369d72e1 | |||
| ea0560e1ce | |||
| cd62be0de0 | |||
| e186bb115d | |||
| 7a3f6fb714 | |||
| 1ed761c97f | |||
| a193e3118d | |||
| e9a675a9a4 | |||
| 439a139d7c | |||
| 40d6ad09ae | |||
| 3acd88d451 | |||
| 8806208e83 | |||
| 5ba487d74e | |||
| 7c12d5fed0 | |||
| f6717d9f49 | |||
| 3ec6df492d | |||
| cdddbcf695 | |||
| 483f9b1289 | |||
| b2912195ac | |||
| 19b524e113 | |||
| 1cec46f997 | |||
| 4468cbd096 | |||
| 4c3e2a9a68 | |||
| da9f28fbe7 | |||
| 8ac394bd3f | |||
| ff22ee8292 | |||
| d36409d037 | |||
| 7e9be9b935 | |||
| dd701d253c | |||
| 78b3a0e1f9 | |||
| 1e9a81f59d | |||
| 432f44118f | |||
| b697c77cd8 | |||
| 23ce0a9e67 | |||
| 0cd6c60fd9 | |||
| 82de635a75 | |||
| 299393aa26 | |||
| 7bc9a53b13 | |||
| c1bf27fcba | |||
| d72daf14ff | |||
| c5678414ae | |||
| 329980c6c6 | |||
| 5fb649b59e | |||
| 900a441908 | |||
| 19de8a15cf | |||
| ab99e6a64f | |||
| 5dc9c30bca | |||
| 9308059230 | |||
| ac9dfe2edc | |||
| ae26b683fb | |||
| cf9cd1a7a0 | |||
| 194150bbf0 | |||
| b97f5fc043 | |||
| aaebaa8d36 | |||
| ef4743ed49 | |||
| 6737a9a91a | |||
| 965d329ae5 | |||
| e4fd2373fb | |||
| e784854e05 | |||
| c4c4db201f | |||
| 33df88d434 | |||
| f02f4341ca | |||
| 211a527ae1 | |||
| cc275367bf | |||
| 65e0e4d749 | |||
| 1dc7fd1bdf | |||
| e49420f62d | |||
| 9fe8ace39b | |||
| d591c1ea04 | |||
| ae05f27015 | |||
| b8ebcf769a | |||
| 9c718dce59 | |||
| efb3ed4932 | |||
| e09d250dd6 | |||
| 4d27008c5d | |||
| cfd6c4301c | |||
| dddba1198d | |||
| a0267db832 | |||
| 0d46eba76e | |||
| c8e47ad00e | |||
| 47b065208e | |||
| edf71a7692 | |||
| 775ec10114 | |||
| d19721d17a | |||
| c11510fdca | |||
| 1f2b3f8505 | |||
| fba853a6a7 | |||
| 1af24827bd | |||
| 392cc8eb44 | |||
| c21a1ef16b | |||
| 46281dd39b | |||
| db2c751480 | |||
| c08d672e49 | |||
| 70c446cb35 | |||
| 2de48f2b91 | |||
| 391334ee13 | |||
| a678ec4171 | |||
| ea42a18930 | |||
| 36a714b154 | |||
| bee260b1f0 | |||
| 45f46466d7 | |||
| 8f235881c5 | |||
| 8bf6a34c58 | |||
| ca591ccb5d | |||
| 9d22ce5ac7 | |||
| 067ddb9aac | |||
| 66bddba6fe | |||
| fbe3ace0dd | |||
| b352817407 | |||
| e2dc24d926 | |||
| baab758377 | |||
| d91d75abe4 | |||
| 12d3d10dec | |||
| 7693e83d7f | |||
| 3bc35208af | |||
| 78d1c0345e | |||
| ca39b34b8c | |||
| 3d1a533bf2 | |||
| 71eaeb2783 | |||
| f9d8cb1b93 | |||
| d535adcc5e | |||
| f62ce4039d | |||
| 8f9a82e400 | |||
| 2be6c6f5da | |||
| 35155dfc4c | |||
| 2e82794ab4 | |||
| 7142e37372 | |||
| dca7a7f2eb | |||
| a7ca9f0c9f | |||
| 7c3a9faf53 | |||
| 2fe58f8d6d | |||
| bc16276a38 | |||
| 3420f3ed8b | |||
| 11c657ffa4 | |||
| 80afa7cbc7 | |||
| 75fc552637 | |||
| 56adc67e67 | |||
| 02f1977d30 | |||
| b68e39472d | |||
| 10df2bc950 | |||
| f6aecd8af9 | |||
| 567f395afa | |||
| 7003eff42c | |||
| d54eb94497 | |||
| 295cef61df | |||
| 8ed5584565 | |||
| e305099b45 | |||
| 091de54bab | |||
| 112d5d5994 | |||
| 428998c6fb | |||
| 56b52392e8 | |||
| ddf0997a93 | |||
| e1207e0e27 | |||
| 3544be0960 | |||
| 2e916d0246 | |||
| 809e176908 | |||
| c2bf033fb8 | |||
| d67c01e652 | |||
| 8d82338e1e | |||
| 89e6f52142 | |||
| 030db6e267 | |||
| aae590adc4 | |||
| 06cbd0723e | |||
| ddabdaca02 | |||
| 839d01a3af | |||
| 4d421c9a50 | |||
| 9fa826b2e7 | |||
| 7718e8d928 | |||
| 23374b7fc6 | |||
| f0f07b578b | |||
| e23f1f10b7 | |||
| 1b56c31a22 | |||
| 9f7cbc8a4f | |||
| f504175578 | |||
| 103faca6ef | |||
| 2fce4884d7 | |||
| 4142629665 | |||
| 03821838eb | |||
| d2959e82a1 | |||
| 6a5ccc89df | |||
| 5858bfb99b | |||
| 3cce78c087 | |||
| 0d0d42f86a | |||
| d9a37f3822 | |||
| 4fcdf72ab6 | |||
| 8680d98bc3 | |||
| b3bb2d4f11 | |||
| 5c28089f2b | |||
| c3769adf80 | |||
| 9e189aa309 | |||
| 7a3d92522e | |||
| 54013cfd42 | |||
| ccb7a5ddba | |||
| 54d9d72549 | |||
| 819a606204 | |||
| 33f81abcd3 | |||
| fbb0b22522 | |||
| 6b017d12c0 | |||
| 6691447624 | |||
| 39cc0c6ad7 | |||
| cb87b16e28 | |||
| 5be13d5eb5 | |||
| eb015b1e22 | |||
| 012a889444 | |||
| e79d27c984 | |||
| 6552401fd8 | |||
| da96126445 | |||
| 301ef3fddb | |||
| d6ba98252d | |||
| 9aa6b519c9 | |||
| 9f19792985 | |||
| e4d56dba92 | |||
| e49cb9eb85 | |||
| b7579a1420 | |||
| 6f59617546 | |||
| 996458dde3 | |||
| c2d889de12 | |||
| b5a0da03a8 | |||
| 8d3d337820 | |||
| 1314a1ffea | |||
| bed78dd935 | |||
| 02e5333101 | |||
| 0aa3c676c2 | |||
| acd9505597 | |||
| 65cd28aad3 | |||
| 12684b214a | |||
| 5c72aabdea | |||
| a2b353fb6d | |||
| aa38d83ba6 | |||
| af69467bea | |||
| 432600ab7b | |||
| b1aa67ddb7 | |||
| c16382e9d4 | |||
| 9f9bb96076 | |||
| f1e280ccde | |||
| cfe28ad903 | |||
| bda827c590 | |||
| ebc40857e4 | |||
| 69ede7f82c | |||
| 0e3bcfecd0 | |||
| 96368444ac | |||
| ec4172d41a | |||
| 8eeae70313 | |||
| a33435ee12 | |||
| eb7801abf9 | |||
| 42450d9cd6 | |||
| 4c0af1eae1 | |||
| 35e5df8bdc | |||
| dfd374b875 | |||
| 7722c50312 | |||
| 1527b88fd6 | |||
| 7f82a6e9fa | |||
| 196710dac8 | |||
| 194c0b6c7b | |||
| b3b67abaa0 | |||
| 0f0059342c | |||
| d7a8cac1dc | |||
| c8288b430e | |||
| dc5ad87686 | |||
| 1ff93f65b3 | |||
| 4ccb93665b | |||
| 32a63cdd56 | |||
| 635cd71ef7 | |||
| 116af7e809 | |||
| ee3fb2785e | |||
| 2b1ddd9a45 | |||
| 1fe925ad5f | |||
| c220c0a427 | |||
| 52fa847769 | |||
| 9854752036 | |||
| 37fd854003 | |||
| e6fc1956fc | |||
| 5bf38b1d02 | |||
| 5b8adda5da | |||
| d0cbb9f3a7 | |||
| 1295855302 | |||
| 4d1dd1c446 | |||
| e77b47717e | |||
| 3f4ce4025f | |||
| 680b377bd1 | |||
| 45c04b1cde | |||
| e13578d97d | |||
| 1d50724c91 | |||
| d469a9601b | |||
| fa246aade1 | |||
| a27be4e053 | |||
| 7e6013b125 | |||
| e310d16fb7 | |||
| 6b224ea8aa | |||
| 7a5b133c58 | |||
| 4e25a9e815 | |||
| 084ec064cb | |||
| 0eb86ccd1d | |||
| e87e5b9cae | |||
| 20cce33273 | |||
| e235a4565c | |||
| a345cbd907 | |||
| 5959e1f9fc | |||
| 3ea0ad87c8 | |||
| cf438d0207 | |||
| 1624dbffa4 | |||
| e2a1cda50e | |||
| 6fee1067bc | |||
| 3ba2880a35 | |||
| 5a2c6391bf | |||
| 447a74928b | |||
| 62e03e0910 | |||
| 1a970716cc | |||
| 57d0f36435 | |||
| a8d01550dc | |||
| f071fe5867 | |||
| acfda8dc82 | |||
| 3cc0ed8743 | |||
| ffcfc853b3 | |||
| 051ef0a218 | |||
| 5fcbc9ba78 | |||
| 9dbb147ada | |||
| 718236b2d4 | |||
| efb5269a0c | |||
| 74034ae69e | |||
| 9284164e96 | |||
| dc26a901d4 | |||
| ad680a337e | |||
| dab7ec3457 | |||
| 46714172ba | |||
| 4844cd0b38 | |||
| 79f93ab475 | |||
| 2b088a3fb2 | |||
| 2353eda611 | |||
| 343eb31c56 | |||
| 56586b7e83 | |||
| 1b152396ad | |||
| 69badc7fda | |||
| 2727ec13c6 | |||
| e457aaee6a | |||
| 03edbc008c | |||
| 2203789f4c | |||
| 74607c0534 | |||
| 0d9184870c | |||
| faae6a21d3 | |||
| 1b01074b9e | |||
| 54894227f0 | |||
| c72e98a193 | |||
| 295c2e35eb | |||
| 75c48c351c | |||
| 37e1ae7f5a | |||
| e9bd8397d8 | |||
| 9b5274fdcd | |||
| d5bbf38915 | |||
| c32d45e901 | |||
| 2774b07bce | |||
| a356dbd73d | |||
| 9249786a25 | |||
| 135d21e27d | |||
| 95fb2f6efd | |||
| 6434db2a8e | |||
| d0d94bac44 | |||
| b7251d9992 | |||
| 1b1efec858 | |||
| 52020d09f0 | |||
| 8dd5704697 | |||
| 7b2cf64d7f | |||
| 60b577166a | |||
| da93fb18b8 | |||
| a3db6ba99c | |||
| 08db7fbb38 | |||
| 7b9eebe51c | |||
| 8a348ead33 | |||
| fc8c3c086c | |||
| 5fae91d4e9 | |||
| f7cdc8d5c0 | |||
| de98f20b9c | |||
| 904a024636 | |||
| 261690986a | |||
| 7ada2cc021 | |||
| 1b5f0e1dd1 | |||
| 595f151ff9 | |||
| aa34c4a4dd | |||
| 1d04235520 | |||
| ed3fd129bf | |||
| 53e6d22f83 | |||
| f3114dec7a | |||
| d46556a83d | |||
| 7f77f1e0b1 | |||
| 11a6ee5e8d | |||
| 549c0a9fd6 | |||
| 84dbb64caf | |||
| c93469c465 | |||
| 781deb2551 | |||
| 44c5817992 | |||
| c25122273d | |||
| 4e9aa99e42 | |||
| fb9f0d837e | |||
| 080f38a899 | |||
| b00f3430cb | |||
| 97a69625ba | |||
| 34bbf460ee | |||
| 171346b5ea | |||
| 61cceb5f0b | |||
| f7032f0eaa | |||
| e3160957e6 | |||
| 57f5f5705f | |||
| 4e8c3517a7 | |||
| 0ee08e47e9 | |||
| 9c08d6fcf7 | |||
| d6a718e997 | |||
| 8daffa82fe | |||
| 7352eaec2e | |||
| 67aaeaf7f8 | |||
| 76da83cbe1 | |||
| 4929f803cc | |||
| 24972a330a | |||
| 1b160d251e | |||
| fa175feb45 | |||
| f0f0019d3b | |||
| 8cc367f9e6 | |||
| 55aa41dc32 | |||
| 08f6d7e17d | |||
| 961baffa4f | |||
| 9e235b6825 | |||
| db80b36d0f | |||
| 02829cb138 | |||
| 123b6f2a37 | |||
| 1567a8bde1 | |||
| 30a8a96113 | |||
| cab75ed7d6 | |||
| e2c1671d21 | |||
| 5b27a34f05 | |||
| ea312fc161 | |||
| b8908bf246 | |||
| f7f79681f3 | |||
| e22d381a20 | |||
| 9ebe62f044 | |||
| 719c36d482 | |||
| 8c1f6ada67 | |||
| 5bcfca18c7 | |||
| a28775b9b7 | |||
| bbaed47e90 | |||
| 8bf1640721 | |||
| 6265f530ed | |||
| 015c09f560 | |||
| 0023b04396 | |||
| 98cf8767f2 | |||
| 3bbd98f1c7 | |||
| 532c03a73d | |||
| 44ba90f9f0 | |||
| 981ff2b6e5 | |||
| e819c642db | |||
| 8268edae81 | |||
| edbf195034 | |||
| 1590c1a300 | |||
| 6dd320171f | |||
| 5c43caf057 | |||
| ddfd69e510 | |||
| 0e11b29cf9 | |||
| 3401fee672 | |||
| ffdb4b1aa8 | |||
| f409ade3a5 | |||
| 064d7da38e | |||
| 4854228851 | |||
| 88599fad7f | |||
| d0a5afbf02 | |||
| c2f5b48635 | |||
| 5172954aef | |||
| 14de269474 | |||
| ad914b73b0 | |||
| c679d446fd | |||
| 889b66d578 | |||
| b966bb2889 | |||
| abac6489c4 | |||
| 4ef506cde7 | |||
| c7c072b07c | |||
| 7b59f42fb0 | |||
| 50387874bf | |||
| 02ed943ffa | |||
| 8f665e82ae | |||
| 897bc63621 | |||
| 673f5accf9 | |||
| 6214c7b706 | |||
| 7c37f91dd5 | |||
| ca90300d2f | |||
| d2427bdea2 | |||
| 57107dceee | |||
| 48e180c691 | |||
| b554a9f9db | |||
| e3fa628bac | |||
| c29b3c93f7 | |||
| 524d3d233d | |||
| 2fd8b1760c | |||
| 7bc7ffb728 | |||
| 7d38a7db61 | |||
| 785b32c8ff | |||
| 2d9f56c02a | |||
| 36bef5bfa5 | |||
| ec4239693d | |||
| 17cb895633 | |||
| a8372dc998 | |||
| d9f434ca12 | |||
| 3a5300e805 | |||
| b22621ab55 | |||
| 4da2bccbf7 | |||
| eae1c29262 | |||
| 127c378b36 | |||
| 284645fa7c | |||
| 03959b4783 | |||
| 90c4dfecdf | |||
| 8f86ec9dae | |||
| 3d5dcf7c0e | |||
| 31d323fb71 | |||
| 940281dd4d | |||
| 238e933f00 | |||
| 03e95743e2 | |||
| 2f67ee659f | |||
| ea571535b0 | |||
| 7bdd5505fd | |||
| 3aea00841a | |||
| 76ac391153 | |||
| 7d1a2b2bec | |||
| ca842ee447 | |||
| 16afe9eb02 | |||
| 343e13efee | |||
| a7281ef5b5 | |||
| cfb37dcec0 | |||
| cb5b365631 | |||
| 23c35522c8 | |||
| 92eab82328 | |||
| 774b182e9f | |||
| 51c1bf4b63 | |||
| c9a78b319a | |||
| f62fdd9aeb | |||
| 89ede0f8cf | |||
| 939648e9de | |||
| 66c9b81118 | |||
| 4143fa6a25 | |||
| 961a4068b4 | |||
| 38d85afc2b | |||
| 5adb65b4cb | |||
| 17be6b3efe | |||
| a3837eb641 | |||
| 90ac04eac7 | |||
| eddbb7d973 | |||
| eee22a9f2b | |||
| 98990d852d | |||
| 33a0d2e191 | |||
| cf59ec8c67 | |||
| 24c3a153e5 | |||
| ffe786f659 | |||
| 173a7d120f | |||
| 4756e950ef | |||
| 9e96e4b60a | |||
| c1e1323e68 | |||
| ea7b0c1c0c | |||
| 27514f85c3 | |||
| 5dc449a99e | |||
| 7def599141 | |||
| e4443b8988 | |||
| bb167aac59 | |||
| 4742c5e906 | |||
| a62ffa96cf | |||
| 0894832e60 | |||
| 2e132331e7 | |||
| 4f0a1789db | |||
| 23a6e867e6 | |||
| 9720ff9fd5 | |||
| 32eb9d1d30 | |||
| 31b90cf2a3 | |||
| e475846fb6 | |||
| 95750cb3a9 | |||
| 86087b2c4f | |||
| 9c3be972f0 | |||
| 6a70acbe5f | |||
| f60cba1a4a | |||
| 38154c0df8 | |||
| 3af94b4e7e | |||
| 4cd458cc7a | |||
| ccf59fb79d | |||
| 7e840ec273 | |||
| 8b57cd8ab9 | |||
| 0839510807 | |||
| b0eb5e5bdd | |||
| f12e6b0837 | |||
| 16143c4ff7 | |||
| 40713d04f9 | |||
| 2a08e00a16 | |||
| 5e6a22d973 | |||
| f27fa40f1c | |||
| abd060679e | |||
| 34cb25296f | |||
| 9bbc25fc76 | |||
| e9fe59444f | |||
| 9364c46c2d | |||
| 50dfa27689 | |||
| d7dedf84ad | |||
| fd0e5959b5 | |||
| ba8cf36691 | |||
| 5a46c85533 | |||
| 9159d5f771 | |||
| c9293897fb | |||
| 0e4e26206b | |||
| 884131f729 | |||
| 1f2badfc39 | |||
| 79da13dff7 | |||
| b8d4823cae | |||
| 0789108e74 | |||
| c591a71141 | |||
| 2b930ff1e7 | |||
| af03d60d28 | |||
| 51cd0b0208 | |||
| e5aa5f1a5b | |||
| 1bd87cca05 | |||
| 0fcd64c386 | |||
| 590dbb2bd5 | |||
| 54cd3d04b1 | |||
| 6218e1912f | |||
| 14972f894b | |||
| cf1134db37 | |||
| 963d3a764a | |||
| 07e71a547c | |||
| 98afb39ef0 | |||
| 5d3d1eb319 | |||
| a1f9296700 | |||
| a8d192d263 | |||
| 7785743d85 | |||
| 4ac4b2fde0 | |||
| f387f7e005 | |||
| 721a858aa3 | |||
| b3c85cd554 | |||
| 760c41896e | |||
| b18f69330f | |||
| e08741b104 | |||
| dd8d23bcf7 | |||
| 1ff564ad9f | |||
| f7466a335d | |||
| 261049e848 | |||
| 9747815960 | |||
| 4c9b66150d | |||
| 41efea5929 | |||
| 52acfafc42 | |||
| 5721636b71 | |||
| 01dadedc78 | |||
| 6bca4fa187 | |||
| 92f80f979f | |||
| fc6e41e464 | |||
| 574822f278 | |||
| 91b85de6cf | |||
| dd20f519b5 | |||
| 6f80a2dedd | |||
| 53ca5e9c5d | |||
| feda21a6e3 | |||
| 87e90f12ea |
Executable
+37
@@ -0,0 +1,37 @@
|
||||
ls
|
||||
pwd
|
||||
cd app
|
||||
ls
|
||||
cd views/
|
||||
cd backend/
|
||||
ls
|
||||
cd users/
|
||||
ls
|
||||
vi view.blade.php
|
||||
ls -alF
|
||||
cd
|
||||
pwd
|
||||
ls -alF
|
||||
pwd
|
||||
cd app
|
||||
ls
|
||||
cd views/
|
||||
cd backend/
|
||||
cd users/
|
||||
ls
|
||||
ls -alF
|
||||
chown snipeitftp view.blade.php
|
||||
sudo chown snipeitftp view.blade.php
|
||||
pwd
|
||||
ls
|
||||
vi view.blade.php
|
||||
set noswapfile
|
||||
set nobackup
|
||||
vi view.blade.php
|
||||
touch delete.me
|
||||
vi delete.me
|
||||
ls
|
||||
ls -alF
|
||||
touch view.blade.php
|
||||
touch index.blade.php
|
||||
vi view.blade.php
|
||||
@@ -1,5 +0,0 @@
|
||||
.git
|
||||
.dockerignore
|
||||
app/storage/logs/*
|
||||
app/storage/views/*
|
||||
vendor/*
|
||||
@@ -1,77 +0,0 @@
|
||||
# --------------------------------------------
|
||||
# REQUIRED: BASIC APP SETTINGS
|
||||
# --------------------------------------------
|
||||
APP_ENV=production
|
||||
APP_DEBUG=false
|
||||
APP_KEY=ChangeMe
|
||||
APP_URL=null
|
||||
APP_TIMEZONE='UTC'
|
||||
APP_LOCALE=en
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: DATABASE SETTINGS
|
||||
# --------------------------------------------
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=null
|
||||
DB_USERNAME=null
|
||||
DB_PASSWORD=null
|
||||
DB_PREFIX=null
|
||||
DB_DUMP_PATH='/usr/bin'
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: OUTGOING MAIL SERVER SETTINGS
|
||||
# --------------------------------------------
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_HOST=email-smtp.us-west-2.amazonaws.com
|
||||
MAIL_PORT=587
|
||||
MAIL_USERNAME=YOURUSERNAME
|
||||
MAIL_PASSWORD=YOURPASSWORD
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDR=you@example.com
|
||||
MAIL_FROM_NAME=Snipe-IT
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: IMAGE LIBRARY
|
||||
# This should be gd or imagick
|
||||
# --------------------------------------------
|
||||
IMAGE_LIB=gd
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: SESSION SETTINGS
|
||||
# --------------------------------------------
|
||||
SESSION_LIFETIME=12000
|
||||
EXPIRE_ON_CLOSE=false
|
||||
ENCRYPT=false
|
||||
COOKIE_NAME=snipeit_session
|
||||
COOKIE_DOMAIN=null
|
||||
SECURE_COOKIES=false
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: CACHE SETTINGS
|
||||
# --------------------------------------------
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: AWS S3 SETTINGS
|
||||
# --------------------------------------------
|
||||
AWS_SECRET=null
|
||||
AWS_KEY=null
|
||||
AWS_REGION=null
|
||||
AWS_BUCKET=null
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: MISC
|
||||
# --------------------------------------------
|
||||
APP_LOG=single
|
||||
APP_LOCKED=false
|
||||
FILESYSTEM_DISK=local
|
||||
APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1
|
||||
@@ -1,71 +0,0 @@
|
||||
# --------------------------------------------
|
||||
# REQUIRED: BASIC APP SETTINGS
|
||||
# --------------------------------------------
|
||||
APP_ENV=testing
|
||||
APP_DEBUG=true
|
||||
APP_KEY=ChangeMe
|
||||
APP_URL=http://localhost:8000
|
||||
APP_TIMEZONE='US/Pacific'
|
||||
APP_LOCALE=en
|
||||
FILESYSTEM_DISK=local
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: DATABASE SETTINGS
|
||||
# --------------------------------------------
|
||||
DB_CONNECTION=sqlite_testing
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=testing.sqlite
|
||||
DB_USERNAME=null
|
||||
DB_PASSWORD=null
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: OUTGOING MAIL SERVER SETTINGS
|
||||
# --------------------------------------------
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_HOST=email-smtp.us-west-2.amazonaws.com
|
||||
MAIL_PORT=587
|
||||
MAIL_USERNAME=YOURUSERNAME
|
||||
MAIL_PASSWORD=YOURPASSWORD
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDR=you@example.com
|
||||
MAIL_FROM_NAME=Snipe-IT
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: IMAGE LIBRARY
|
||||
# This should be gd or imagick
|
||||
# --------------------------------------------
|
||||
IMAGE_LIB=gd
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: AWS S3 SETTINGS
|
||||
# --------------------------------------------
|
||||
AWS_SECRET=null
|
||||
AWS_KEY=null
|
||||
AWS_REGION=null
|
||||
AWS_BUCKET=null
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: CACHE SETTINGS
|
||||
# --------------------------------------------
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: SESSION SETTINGS
|
||||
# --------------------------------------------
|
||||
SESSION_LIFETIME=12000
|
||||
EXPIRE_ON_CLOSE=false
|
||||
ENCRYPT=false
|
||||
COOKIE_NAME=snipeittest_session
|
||||
COOKIE_DOMAIN=null
|
||||
SECURE_COOKIES=false
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: APP LOG FORMAT
|
||||
# --------------------------------------------
|
||||
APP_LOG=single
|
||||
@@ -1,71 +0,0 @@
|
||||
# --------------------------------------------
|
||||
# REQUIRED: BASIC APP SETTINGS
|
||||
# --------------------------------------------
|
||||
APP_ENV=testing-ci
|
||||
APP_DEBUG=true
|
||||
APP_KEY=ChangeMe
|
||||
APP_URL=http://localhost:8000
|
||||
APP_TIMEZONE='US/Pacific'
|
||||
APP_LOCALE=en
|
||||
FILESYSTEM_DISK=local
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: DATABASE SETTINGS
|
||||
# --------------------------------------------
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=snipeit_unit
|
||||
DB_USERNAME=travis
|
||||
DB_PASSWORD=null
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: OUTGOING MAIL SERVER SETTINGS
|
||||
# --------------------------------------------
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_HOST=email-smtp.us-west-2.amazonaws.com
|
||||
MAIL_PORT=587
|
||||
MAIL_USERNAME=YOURUSERNAME
|
||||
MAIL_PASSWORD=YOURPASSWORD
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDR=you@example.com
|
||||
MAIL_FROM_NAME=Snipe-IT
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: IMAGE LIBRARY
|
||||
# This should be gd or imagick
|
||||
# --------------------------------------------
|
||||
IMAGE_LIB=gd
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: AWS S3 SETTINGS
|
||||
# --------------------------------------------
|
||||
AWS_SECRET=null
|
||||
AWS_KEY=null
|
||||
AWS_REGION=null
|
||||
AWS_BUCKET=null
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: CACHE SETTINGS
|
||||
# --------------------------------------------
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: SESSION SETTINGS
|
||||
# --------------------------------------------
|
||||
SESSION_LIFETIME=12000
|
||||
EXPIRE_ON_CLOSE=false
|
||||
ENCRYPT=false
|
||||
COOKIE_NAME=snipeittest_session
|
||||
COOKIE_DOMAIN=null
|
||||
SECURE_COOKIES=false
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: APP LOG FORMAT
|
||||
# --------------------------------------------
|
||||
APP_LOG=single
|
||||
@@ -1,31 +0,0 @@
|
||||
#### Expected Behavior (or desired behavior if a feature request)
|
||||
|
||||
(what you expect to happen goes here)
|
||||
|
||||
-----
|
||||
|
||||
#### Actual Behavior
|
||||
|
||||
(what actually happens goes here)
|
||||
|
||||
-----
|
||||
|
||||
#### Please confirm you have done the following before posting your bug report:
|
||||
|
||||
- [ ] I have enabled debug mode
|
||||
- [ ] I have read [checked the Common Issues page](http://docs.snipeitapp.com/common-issues.html)
|
||||
|
||||
-----
|
||||
#### Please provide answers to these questions before posting your bug report:
|
||||
|
||||
- Version of Snipe-IT you're running
|
||||
- What OS and web server you're running Snipe-IT on
|
||||
- What method you used to install Snipe-IT (install.sh, manual installation, docker, etc)
|
||||
- If you're getting an error in your browser, include that error
|
||||
- What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error
|
||||
- If a stacktrace is provided in the error, include that too.
|
||||
- Any errors that appear in your browser's error console.
|
||||
- Confirm whether the error is [reproduceable on the demo](https://snipeitapp.com/demo).
|
||||
- Include any additional information you can find in `app/storage/logs` and your webserver's logs.
|
||||
- Include what you've done so far in the installation, and if you got any error messages along the way.
|
||||
- Indicate whether or not you've manually edited any data directly in the database
|
||||
+14
-43
@@ -1,49 +1,20 @@
|
||||
/bootstrap/compiled.php
|
||||
/vendor
|
||||
/node_modules
|
||||
Homestead.yaml
|
||||
Homestead.json
|
||||
.env
|
||||
|
||||
tests/_output/*
|
||||
composer.phar
|
||||
.DS_Store
|
||||
/app/config/database.php
|
||||
/app/config/mail.php
|
||||
/app/database/*.sqlite
|
||||
/app/storage/meta/services.json
|
||||
/app/config/*/mail.php
|
||||
/app/config/*/database.php
|
||||
/app/config/*/app.php
|
||||
public/packages/*
|
||||
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/*
|
||||
|
||||
|
||||
/bootstrap/compiled.php
|
||||
composer.phar
|
||||
app/config/database.php
|
||||
app/config/mail.php
|
||||
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/
|
||||
/app/storage/views/*
|
||||
/app/storage/logs/*
|
||||
/app/storage/debugbar/
|
||||
/bin/
|
||||
.idea
|
||||
crowdin.yaml
|
||||
public/uploads/logo.gif
|
||||
public/uploads/logo.svg
|
||||
public/uploads/logo.png
|
||||
.couscous
|
||||
storage/dumps/*
|
||||
tests/_data/scenarios
|
||||
storage/laravel-backups
|
||||
storage/private_uploads/users/*
|
||||
crowdin.yaml
|
||||
@@ -1,11 +0,0 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
<IfModule mod_negotiation.c>
|
||||
Options -MultiViews
|
||||
</IfModule>
|
||||
|
||||
# Make sure .env files not not browseable if in a sub-directory.
|
||||
<FilesMatch "\.env$">
|
||||
Deny from all
|
||||
</FilesMatch>
|
||||
|
||||
</IfModule>
|
||||
Regular → Executable
+20
-38
@@ -1,58 +1,40 @@
|
||||
addons:
|
||||
hosts:
|
||||
- localhost
|
||||
sudo: false
|
||||
hosts:
|
||||
- AlisonMBP
|
||||
|
||||
# see http://about.travis-ci.org/docs/user/languages/php/ for more hints
|
||||
language: php
|
||||
|
||||
# list any PHP version you want to test against
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
|
||||
# optionally specify a list of environments, for example to test different RDBMS
|
||||
env:
|
||||
- DB=mysql
|
||||
|
||||
# execute any number of scripts before the test run, custom env's are available as variables
|
||||
before_script:
|
||||
- phantomjs --webdriver=4444 &
|
||||
- sleep 10
|
||||
- mysql -e "create database IF NOT EXISTS snipeit_unit;" -utravis
|
||||
- if [[ "$DB" == "mysql" ]]; then mysql -e "create database IF NOT EXISTS snipeit_laravel;" -utravis; fi
|
||||
- curl -s http://getcomposer.org/installer | php
|
||||
- cp app/config/testing/app.example.php app/config/testing/app.php
|
||||
- cp app/config/testing/database.example.php app/config/testing/database.php
|
||||
- cp app/config/testing/mail.example.php app/config/testing/mail.php
|
||||
- composer self-update
|
||||
- composer install -n --prefer-source
|
||||
- cp .env.testing-ci .env
|
||||
- chmod -R 777 storage
|
||||
- php artisan migrate --database=mysql --force
|
||||
- ./vendor/bin/codecept build
|
||||
- php artisan key:generate
|
||||
- php artisan db:seed --database=mysql --force
|
||||
- php artisan snipeit:create-admin --first_name=Alison --last_name=Foobar --email=me@example.com --username=snipe --password=password
|
||||
- php artisan serve --port=8000 --host=localhost &
|
||||
- sleep 5
|
||||
- pip install --user codecov
|
||||
- sleep 5
|
||||
|
||||
|
||||
- composer install --prefer-source --no-interaction
|
||||
- php artisan key:generate --env=testing
|
||||
- php artisan migrate:install --env=testing --no-interaction -vvv
|
||||
- php artisan migrate --package cartalyst/sentry --env=testing --no-interaction -vvv
|
||||
- php artisan migrate --env=testing --no-interaction -vvv
|
||||
- php artisan db:seed --env=testing --no-interaction -vvv
|
||||
|
||||
# omitting "script:" will default to phpunit
|
||||
# use the $DB env variable to determine the phpunit.xml to use
|
||||
# script: ./vendor/bin/codecept run --env testing-ci - broken :(
|
||||
script: ./vendor/bin/codecept run unit --env testing-ci
|
||||
#script: ./vendor/bin/codecept run
|
||||
|
||||
after_success:
|
||||
- codecov
|
||||
|
||||
after_failure:
|
||||
- cat tests/_output/AccessoriesCept.fail.html
|
||||
- curl http://localhost:8000/login
|
||||
script: phpunit
|
||||
|
||||
# configure notifications (email, IRC, campfire etc)
|
||||
notifications:
|
||||
email: false
|
||||
slack:
|
||||
secure: vv9we1RxB9RsrMbomSdq6D7vz/okobw87pEkgIZjB+hj1QpQ2by90gsPsOa+NgsJEFaEP7e4KlT6SH8kK+zhbmuKaUd3d1//XdcancE22LZXi6tkiB5yuR/Jhhb1LLDqyGJTB4D92hMnnCPiUjpxNA3r437ttNeYRdYIEEP3drA=
|
||||
webhooks:
|
||||
urls:
|
||||
- https://webhooks.gitter.im/e/5e136eb0c1965f3918d0
|
||||
on_success: change # options: [always|never|change] default: always
|
||||
on_failure: change # options: [always|never|change] default: always
|
||||
on_start: false # default: false
|
||||
|
||||
Executable
+236
@@ -0,0 +1,236 @@
|
||||
|
||||
|
||||
### v1.1 - Released Nov 06, 2014 02:16:26
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/fafd03f00f49cb9ffe81d50aa9ca3d1f1fa1d043">view</a> • Added DB Prefix to Migrations
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/309772e67d62989f1f60141a4a10d724a44c6baa">view</a> • Fixed operator for setting bool display
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/22f81912e416cfe1227a08b5d8b6323e32e1ef36">view</a> • Fixes #299
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/86b7b6946f1e1bd404127e228c615e4abe0b20fb">view</a> • Fixes #316 - added model name back to view
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/9e85dcb9fcb4cc932ecddd23caa6b51e83110543">view</a> • Fixes #315 - add EOL as display option in settings (run migrations)
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/ee35948980c22f9256241c02d7febd90275f6229">view</a> • fix div issues
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/0022389463e251e73402450cfbc280cb05633bd1">view</a> • Fix dropdown menu position
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/343798d241172707145ef365445062db9bb6b99a">view</a> • Merge pull request #322 from madd15/fix-js-delete-asset
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/1078dbf5c5f6a5bec1a2ef864cebfcc7883d31e6">view</a> • Fixes #324
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/6b2d3efe3e76429c9c2f5de78f04c4f7e2748a3d">view</a> • Fixes #237 - reporting-only group
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/e04cc806d9209b54a1833172ebb66ab55b5f0c06">view</a> • Fixes #327
|
||||
|
||||
|
||||
### v1.0 - Released Oct 16, 2014 09:46:47
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/a4b220d6c31c97f6504023f0b52527825a4cd897">view</a> • Fixed #191 - allow admins to assign a user during asset creation
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/dc1033025a0bc1b2d657e06c89058c3ab95f2c59">view</a> • Fixed #151 - more complete translations
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/56d619b218794b43d8c6b182c89c75f83af9dcd9">view</a> • Fixed missing language string
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/69fca5d1eda0e5f26d2085f7eebc08fafd84a3ae">view</a> • Fixed #58
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/8197e6174e9f12bcfddd94c6bf606ee36e6801bf">view</a> • Fixes #200
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/cb8369e9de96aaf1cf9108e22f4038fa6486b881">view</a> • Initial QA Patch to fix errors Add License Add Asset Show Deleted Users License Assign
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/62a3ed671bbd957075563933f49e8a5445042737">view</a> • DB migration, layout and clone fixes
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/9ccc7d756f9361757eafc1dce9684ee9f5ecc1c3">view</a> • A0.4.2: Added asset, license, user, model cloning and fixed some bugs.
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/652f1c746c4757dce9d33d7bd90a9357822c4656">view</a> • Fixes Travis CI build
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/363d084bd623f778cd72ca7d385a4fb2f67ef474">view</a> • Fixed DB name in travis CI
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/49c5607e1c8a82a3111123ad84b537644546ebb3">view</a> • Fixes #222
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/96e40d72b9ac3f74b94b0e39b6f296f0f0b2a1f4">view</a> • fix typo: artisand -> artisan
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/e978038cc044f60c2eca71b6319063009a57886f">view</a> • Merge pull request #234 from burlito/typo-fix
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/a829fcf52f933d087c3776993b42311ec9a8988e">view</a> • fix: Use the old asset tag when cloning
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/ee7d9bec7082dc2e60a4797dea84a0b7443c8090">view</a> • Fixes #279 - QR checkbox not staying checked
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/bf1e07555160ede517d41f649d6b1d0911f89dd2">view</a> • Fixes #87 - made datatables responsive
|
||||
|
||||
|
||||
### v0.3.11-alpha - Released Jul 19, 2014 05:16:53
|
||||
#### This is a pre-release
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/ac4c905c42d920d2cf8455d644f4c65332a81d0d">view</a> • Fixed #140
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/4a13cded607415d749151cef495332c48c58cf86">view</a> • Fixed path for Travis composer
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/ddf946ad5eb6dd8480eeaa709f82af75e0c61444">view</a> • Tried to fix failing build caused by travis composer
|
||||
|
||||
|
||||
### v0.3.10-alpha - Released Jul 17, 2014 05:54:10
|
||||
#### This is a pre-release
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/89a8f3c277d2482b2cd04c4c5c582c9e507770f8">view</a> • Fixes #183 - added employee number to users
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/a7b809cb91f49fb2c8eaecc67822fa155a0f20ce">view</a> • Updated title/header for users, additional fixes for #151
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/5266d9a30a9663fa80ff764b25ff71726e5c4f4c">view</a> • Fixed title tag for user list view
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/43485e1a51330ef585a65b469d7eb85ae7bde13a">view</a> • Fixed language definition
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/6b5a552d95ff6f6d5567275b50fcd487fb793820">view</a> • Fixed #186 - Bug with select box not retaining selections on edit screen
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/90eb883b671919ea360122c2bf44433995a12144">view</a> • Fixed #187 - replaced dummy site name with site name from admin panel preferences
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/f22f23f21dc11d393854849580f0c1229cec9827">view</a> • Fixed button label on forgotten password page
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/2b9494ed8271254f8f84e016f238d518e6109842">view</a> • Fixed inconsistent password requirements across admin user creation, user profile and forgotten password
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/9dc40a3a9c161267fd8c88aacc1fbf536c1ec2de">view</a> • Fixed a few CSS quirks
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/99003e126a8fd0ad9aaea5a550e0af5e306fc1bb">view</a> • Fixed bug with edit (supplier_id), added requestable field for assets
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/21251b462308f2d783b83be1a331a0faf0813d16">view</a> • Fixed #190, where depreciation on licenses would not be saved
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/89000440f344f766a31adc69718d7f66df235abf">view</a> • Added admin ability to unsuspend locked accounts #changelog
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/e203fc516fadf6218f5ce87c070d0cdba9fca188">view</a> • Fixes #194
|
||||
|
||||
|
||||
### v0.3.9-alpha - Released Jul 03, 2014 02:08:38
|
||||
#### This is a pre-release
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/2825bcb4310899e89ccbc73dfa8b59ade28018da">view</a> • Fixed #179 - account page to show assets checked out to the logged in user
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/c782f29f5aae752a6246be9778d418df172dd4f6">view</a> • Pulled account sub-nav into top menu to free up UI space. #changelog
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/fad2ec66fa9abe0b34baf16cce453a7e9fc9e4d4">view</a> • More README fixes and refinement
|
||||
|
||||
|
||||
### v0.3.8-alpha - Released Jun 27, 2014 09:28:22
|
||||
#### This is a pre-release
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/3e7a9e45d1954531bbc3b73f2ed59dd16d59c657">view</a> • Fixes PR #168 and #167
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/945cb3253f1349e30aafa4e7cb57bb507a2ea0cc">view</a> • Fix #117
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/6f42b3045e2a65cdf98ec1038284cc2ecf01fa5d">view</a> • Resolves #155
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/380417953b6b67a506f0cc395fd2dfb744cf26cd">view</a> • Fixed missing string
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/b09aec67f1ab76ff0435a2e1e49b179c3d73bc12">view</a> • Fixes #155
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/124acc89c4027e346daf54c62cb38b85586de870">view</a> • Resolves #174
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/afabd2814205fdcd83b7bf9ce9095aa367b08311">view</a> • Additional fixes for #167
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/a170efae2796314896d548d86b79d89d859c37d2">view</a> • fix for #167
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/ec9eab81bfb3b35bfe7ad06008b26f19009e6638">view</a> • Closes #177 - change log file added, needs refining
|
||||
|
||||
|
||||
### v.0.3.5-alpha - Released Jun 20, 2014 02:23:09
|
||||
#### This is a pre-release
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/d1499deecdff3c7a4235ffdfad5adbddc1a5098f">view</a> • Provisions for strict mode, fixed license deletion bug
|
||||
|
||||
|
||||
### v.0.3.4-alpha - Released Jun 19, 2014 10:27:59
|
||||
#### This is a pre-release
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/08d05b481f6366ad48fcdce72a8df53755f5dee8">view</a> • Fixes #158
|
||||
|
||||
|
||||
### v.0.3.3-alpha - Released Jun 18, 2014 08:04:46
|
||||
#### This is a pre-release
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/3518ab9f55f7992d6d4f886389d67b062a02f2d8">view</a> • Fixes #139
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/ad9b1fc446ab15157502fe7c52ddbda455e3ea8f">view</a> • Fixes #139
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/dfa5d1c64205b23c4c3d16190d1478da8aa0edbb">view</a> • Fixes #136
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/9714178ce1fa1e2814389e4b6b82eb596a650084">view</a> • Fixes #141
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/607484b29407718238571eb5269c9c27830338f7">view</a> • Fixes #141 for mysql with strict mode enabled
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/cbc945299e7f67f5f10dfdc6a875e5c53ac8440a">view</a> • Fixes #148
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/dc256583d410cb09253e30b075149c79fb4864e5">view</a> • Fixes #144
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/610c405aa50118163ad5d26d43e4bf6c2456f624">view</a> • More fixes for #151
|
||||
|
||||
|
||||
### v.0.3.2-alpha - Released May 06, 2014 08:26:21
|
||||
#### This is a pre-release
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/f4c5da57d0397877d90aa398267e59fcffee7b47">view</a> • Fixed auth error when user isn't logged in
|
||||
|
||||
|
||||
### v.0.3.1-alpha - Released May 06, 2014 04:48:09
|
||||
#### This is a pre-release
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/efad5db082d1461ea26556fad2f1671a49dc1480">view</a> • Fix for broken datatables in upgrading to v2.2
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/5690e9ce1f178486179ce6cdfb00ca417acd87dd">view</a> • Fixed code indentation for Apache virtualhost example
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/67aba76d3f83c5f374c05fe07d52eebd81d13278">view</a> • Fixing this change from #109 that somehow got reverted
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/06067fc19c0127fdcbb78541e7cdc8e77f5444ac">view</a> • Fixed CSV rexport
|
||||
|
||||
|
||||
### v0.3.0-alpha - Released Jan 29, 2014 01:28:31
|
||||
#### This is a pre-release
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/d91d75abe4df19dd6cd54705ba9967295973ced0">view</a> • Fixing JSON parse errors from #97
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/baab758377e117a86c3273dd1d6e03e66b02dc8b">view</a> • Fixed language support
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/a678ec41714f5d7f77418b5933bc112aa67eae9c">view</a> • Fixed Gravatar Hash
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/c08d672e4923b12972eae76d0699e6a301f911cd">view</a> • Fixes mail config documentation
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/fba853a6a7a2f8166265cac2e99a526fd9b88c7b">view</a> • Fixes composer formatting issues
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/c11510fdcac2b2de09ae9e241c846426bdf0b187">view</a> • Removes sorting from actions column. Fixes #56
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/ae05f2701559a841cb8d9bc8767e6d7a56dcd93c">view</a> • Fixed depreciation bug
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/d591c1ea0495de091eb0f71daa8572929096c897">view</a> • Fixed bug where RTD = 1 instead of 0
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/e49420f62d26405b2fa0385f0ae7b3009b3beeaf">view</a> • Fixed bug in depreciation display
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/1dc7fd1bdf8852fed6d886938f632c8ea69d4798">view</a> • Fixed depreciation display on asset view
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/211a527ae176df667f6f8fbc95901c53a368d8e2">view</a> • Fixed FK
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/aaebaa8d36158aafc61988a6370239e85f2e75e5">view</a> • Bugfix to put custom title in the page title
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/194150bbf0493512018390d011e8d88d144e9763">view</a> • Hacky shit to fix pagination weirdness - will come back to this
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/5fb649b59e76aa9db6e433ad8c9fc75b4b8d5fc2">view</a> • Fixed error message layout
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/7bc9a53b133895206a3df230baca50d3879abbe5">view</a> • Fixed error when user is invalid
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/82de635a75aba376209b741ce1ed4497b91e65e0">view</a> • Fixed invalid seed data
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/b697c77cd85416ca502ec3bb28c990099c7faae3">view</a> • Fixing error when no depreciation
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/432f44118f46381bdaa44daf61dfa35677aba0ee">view</a> • Fixed FK in licenses model
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/4468cbd096e9990300240205baf7139eafbc423c">view</a> • Fixes #112
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/cd62be0de03da071f344c8f66730cbc9e1475fb7">view</a> • Minor div fix
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/9c369d72e1e7e29f3c205586c916b2f42b250047">view</a> • Fixed typo
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/60d94eea04d1ebb93704e6a0d20621ff18708272">view</a> • Changes serial to text area, allow new lines. Fixes #118
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/580590b4c0b4a2f76ef8edfe02de986267fc7395">view</a> • Fixed === to == (PHP is loosely typed)
|
||||
|
||||
|
||||
### v0.2.0-alpha - Released Nov 29, 2013 10:09:07
|
||||
#### This is a pre-release
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/06cbd0723e415d81ea12aa48f2c37188741b2dbc">view</a> • Fixes #93
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/e305099b45401c871f16fec23c200080830fcd5d">view</a> • Fixed model view
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/7003eff42ca0e0ea2b9070187c0afd8ba1a8d8b0">view</a> • More fixes for #88
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/567f395afaa19335671f366ce889630426f33273">view</a> • More fixes for #88
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/02f1977d301cd449aa806e02e8a829516d436ef7">view</a> • Fixed error message
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/11c657ffa4c3bdd01cd04b81d01980b2d795107c">view</a> • Fixes #36
|
||||
|
||||
|
||||
### v0.1.2-alpha - Released Nov 29, 2013 01:59:05
|
||||
#### This is a pre-release
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/b1aa67ddb72158513f0a706996c8c1f5b3609aa5">view</a> • Fixes #69
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/aa38d83ba6369215451d905e599492214e9f4b8b">view</a> • Fixes #63 and #70
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/65cd28aad3903e11879e01faba382454dec7e75c">view</a> • Fixes #14
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/6552401fd869fd285aef5e217438f4f055b53ab6">view</a> • Fixes #77
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/012a889444fa25b174a5fb2c67e89c8c5fcf09aa">view</a> • Corrected license seat count associated with license. Fixes #75
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/9e189aa309750c221c27352f35e2ca1f5fab9173">view</a> • Fixes #80, also prevents the user from checking out an asset that is undeployable, etc
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/8680d98bc36bffa08f87020300b315d26be09928">view</a> • Fixed status display bug
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/4fcdf72ab6505625f244a6e6ee8683204fb81ccd">view</a> • Responsive design bug fixes, placeholder code for #64 (commented out)
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/d9a37f38228d55bb6265efc626e3ab7919013362">view</a> • Fixes #88
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/5858bfb99b2144fbc805ec62cc90e6aaaf019f77">view</a> • Fixed language file paths caused by #88
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/9f7cbc8a4f01ddf2596e831f658c9a8c321b2f46">view</a> • Another fix related to #88, also accounts for users with invalid location_ids
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/1b56c31a22afd39a875677714b9c07e96876b8df">view</a> • Fixed relationship between users/locations because fuck you ORM
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/f0f07b578b2439a627e5e946df0849d88d8526cf">view</a> • Fixing pivot for users
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/9fa826b2e77ce22d25a8b3094bc825802d25be85">view</a> • Fixed assigned to id
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/839d01a3af08d780be4152bc02b33bff1a7d7f20">view</a> • Fixed relationship method because fuck you ORM
|
||||
|
||||
|
||||
### v0.1.1-alpha - Released Nov 26, 2013 11:11:00
|
||||
#### This is a pre-release
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/1527b88fd671a20c879c9b2061ae95f3b386ba27">view</a> • Fixes #61
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/4c0af1eae1031c2630f6e29cc73f8a9dfac1081c">view</a> • Fixed typo causing failure with mysql strict
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/0e3bcfecd05a39bfea6fc7ba11cb24d9d49e6d86">view</a> • Should be final fixes for mysql strict mode
|
||||
|
||||
|
||||
### Initial alpha - Released Nov 26, 2013 09:01:13
|
||||
#### This is a pre-release
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/14972f894bb0e761e2d0170a2c93c9aac4edfca6">view</a> • fixed typo
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/79da13dff767d57f6f4fbb12f195e25f409ee5ec">view</a> • Fixed layout for category view
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/0e4e26206bdcc164e5df586368ed45edd45b9a74">view</a> • fixed broken redirect route
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/9364c46c2df79c0de07dc5dbb724a3c44485b739">view</a> • Fixed licensed link
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/4f0a1789db01f12ebc4bd47e7e0594bf67b64daf">view</a> • Fixed license blades
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/27514f85c3ba9056c4609774a482a58605f4d8cf">view</a> • Fixed typo in variable name
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/ffe786f659e3e8c5b91c27cd33cb77b6d24d3545">view</a> • Fixed routes.
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/cf59ec8c67e142c0612fb7797448057b19af5cfa">view</a> • Fixed pagination bug
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/76ac39115347dabac8ada21d981494a3edf7a29c">view</a> • Fixed edit bug where new Category was invoked twice
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/940281dd4dd0a69b900a052c0bb84e24dde89666">view</a> • Fixed bug on validation display
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/31d323fb71fcbe94f17f0a2b38183709e8c77151">view</a> • Cosmetic fix on form
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/8f86ec9dae58cef27387b028f70c8116d649b425">view</a> • Change depreciation to be by month; formatting fixes.
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/4da2bccbf78a0b630267c6ed75f3a1bd8100e20d">view</a> • Merge pull request #27 from snipe/depreciation_fix
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/7bc7ffb72813cd176658d536bbdd6be0faa9a45c">view</a> • Fixed some error reporting/required fields around checkout/checkin
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/48e180c6910d30732559b0cc077fce679344f56e">view</a> • Fixed asset bug caused by unique validation in assets model
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/57107dceeee81e8618198da33af79fe66bde0d9e">view</a> • Fixed checkin text
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/7b59f42fb03ee5017c11cf32abc8a23c3f5d2141">view</a> • Fixed pagination bug, styled buttons
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/ffdb4b1aa8dde9942f7c3b110e9a68006779998b">view</a> • Fixed wonky layout issue
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/3401fee672d796f4aca8dafced6917c7caf87866">view</a> • Another table fix
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/ddfd69e5100b19bb05d6b76cb9fad3dbadad1921">view</a> • More table fixes
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/5c43caf0579a26c1604fc81f5cbdf8f0d43c157d">view</a> • More table fixes
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/44ba90f9f0a968999a743c35dd2bf153c2edbf1d">view</a> • Fixed icon set to white in main nav
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/719c36d482cc67f1513351672eda057519f7f735">view</a> • migration to fix a few fields in the log table
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/5b27a34f050646467a178ff780efc80036aadf1b">view</a> • Fixed fieldname in userlog
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/76da83cbe1c4334380bb996a40cc374ab4ec12e9">view</a> • Fixed links to edit/checkout
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/d6a718e99766829e700760c2266b62ad37cdb66b">view</a> • Fixed bug in views for created_at date
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/0ee08e47e9f2b144084703142ae5eb099090476d">view</a> • Fixed fatal error if admin who created the asset was deleted. (This should never happen, but...)
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/61cceb5f0b44e7f2a82ccca44be2bc42e8825156">view</a> • Fixed open tag in CSS
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/c93469c465c0ce8a291d595ac8ccbafbfc68c71a">view</a> • Fixed query for asset/license header boxes
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/d46556a83d5335913b8b7fe8558f416540290343">view</a> • Fixed phone display if no value set
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/fc8c3c086ca70a513cd3fff39275fcf035cead5a">view</a> • fixed #37
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/52020d09f034c9de78b798725c0f3700d0253beb">view</a> • Fixed bomb when asset is unassigned
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/1b1efec858e8e0cfc5cfafc63bfb537e45191cd1">view</a> • Fixed foreign key in assets
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/b7251d9992401c04a5da1771af0fcddad2754362">view</a> • Fixed potential bug in blade
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/9249786a25bc166bf5341f59a11d644cf4f6425c">view</a> • Fixed status display
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/c32d45e90142b41b567a350af6d399af67994a02">view</a> • Fixed ID
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/2203789f4c5310599a94799bb3ead9ff9c1ce802">view</a> • Fixes #41
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/03edbc008c671c868fced94a7761683309d9ab8b">view</a> • Fixes #43
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/2b088a3fb2ea7711f66e4a887882b17f401ba4bc">view</a> • Fixes #17
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/ad680a337e50638b4b9865e42e4ea7e453c4151b">view</a> • Fixed column name spelling in DB
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/718236b2d4bedeaaad80cc601e3e91a3229e81fa">view</a> • Fixed #9
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/3cc0ed87438b632679ce8b61a7ea0fae48999438">view</a> • Fixed sorting weirdness
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/57d0f3643518190f0b4a6fe33ac6d83eda647119">view</a> • Fixes #4
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/3ea0ad87c8733ce1bac0e9c10c2cdaf3254743d5">view</a> • Fixes #22
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/e87e5b9cae19bfd06b815cf01be309d665409828">view</a> • Fixes #46
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/7a5b133c5875959c5d7bebf16ea82bac7ceb3989">view</a> • Fixed bug linking to assets when they should be pointing to licenses
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/e13578d97d6b1ef1990f171beda9b35868fda47c">view</a> • Fixed error when no category is given
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/45c04b1cdebc0b19243a519d2580af921c82b47b">view</a> • Fixed display bug
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/4d1dd1c446f76e5530d6fb7f932a77a8da2d0b73">view</a> • Fixed #50 - MOAR VALIDATION!
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/12958553022d4b7b2184ebf837d4113b23f5cf27">view</a> • Fixes #51
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/d0cbb9f3a7e4a1fc05ddcabd19e201434c14370b">view</a> • Fixes #52
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/5bf38b1d02e743af22a51393f1e477100b1f76b7">view</a> • Fixes #50
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/e6fc1956fc93132d04bf5ac4c0d108c1ae9eee0b">view</a> • Fixes #55
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/ee3fb2785e719c938b6036f6ea74527c1217aba8">view</a> • Fixed XSS on modal
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/dc5ad876863a1e17babce06adfb365f38c30ca59">view</a> • Fixes #59
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/d7a8cac1dc6158983673688c2e48e9a48217b6f2">view</a> • Fixed validation
|
||||
* <a href="http://github.com/snipe/snipe-it/commit/196710dac807d48f6c73b02c2444a5b8d301b8a6">view</a> • Fixed bug in error validation display
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
# Contribution Guidelines
|
||||
|
||||
Please submit all issues and pull requests to the [snipe/snipe-it](http://github.com/snipe/snipe-it) repository in the `develop` branch!
|
||||
|
||||
**As you're working on bug-fixes or features, please break them out into their own feature branches and open the pull request against your feature branch**. It makes it _much_ easier to decipher down the road, as you open multiple pull requests over time, and makes it much easier for me to approve pull requests quickly.
|
||||
|
||||
If you don't have a feature in mind, but would like to contribute back to the project, check out the [open issues](https://github.com/snipe/snipe-it/issues?state=open) and see if there are any you can tackle.
|
||||
|
||||
-----
|
||||
|
||||
[](http://waffle.io/snipe/snipe-it)
|
||||
|
||||
The labels we use in GitHub Issues and Waffle.io indicate whether we've confirmed an issue as a bug, whether we're considering the issue as a potential feature, and whether it's ready for someone to work on it. We also provide labels such as "n00b", "intermediate" and "advanced" for the experience level we think it requires for contributors who want to help.
|
||||
|
||||
|
||||
## Translations!
|
||||
|
||||
If you're not a coder but want to give back to the project and you're fluent in other languages, that's okay too. We use [CrowdIn](https://crowdin.com) to manage translations, and it makes it super-simple for you to add translations (or validate proposed translations) to the project without messing with code. __Check out [the Snipe-IT CrowdIn translation project here](https://crowdin.com/project/snipe-it/)__.
|
||||
|
||||
Thanks!
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
FROM ubuntu:trusty
|
||||
MAINTAINER Brady Wetherington <uberbrady@gmail.com>
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
apache2-bin \
|
||||
libapache2-mod-php5 \
|
||||
php5-curl \
|
||||
php5-ldap \
|
||||
php5-mysql \
|
||||
php5-mcrypt \
|
||||
php5-gd \
|
||||
patch \
|
||||
curl \
|
||||
vim \
|
||||
git \
|
||||
mysql-client
|
||||
|
||||
RUN php5enmod mcrypt
|
||||
RUN php5enmod gd
|
||||
|
||||
RUN sed -i 's/variables_order = .*/variables_order = "EGPCS"/' /etc/php5/apache2/php.ini
|
||||
RUN sed -i 's/variables_order = .*/variables_order = "EGPCS"/' /etc/php5/cli/php.ini
|
||||
|
||||
RUN useradd --uid 1000 --gid 50 docker
|
||||
|
||||
RUN echo export APACHE_RUN_USER=docker >> /etc/apache2/envvars
|
||||
RUN echo export APACHE_RUN_GROUP=staff >> /etc/apache2/envvars
|
||||
|
||||
COPY docker/000-default.conf /etc/apache2/sites-enabled/000-default.conf
|
||||
|
||||
#SSL
|
||||
RUN mkdir -p /var/lib/snipeit/ssl
|
||||
COPY docker/001-default-ssl.conf /etc/apache2/sites-enabled/001-default-ssl.conf
|
||||
#COPY docker/001-default-ssl.conf /etc/apache2/sites-available/001-default-ssl.conf
|
||||
|
||||
RUN a2enmod ssl
|
||||
#RUN a2ensite 001-default-ssl.conf
|
||||
|
||||
COPY . /var/www/html
|
||||
|
||||
RUN a2enmod rewrite
|
||||
|
||||
############ INITIAL APPLICATION SETUP #####################
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
#Append to bootstrap file (less brittle than 'patch')
|
||||
# RUN sed -i 's/return $app;/$env="production";\nreturn $app;/' bootstrap/start.php
|
||||
|
||||
#copy all configuration files
|
||||
# COPY docker/*.php /var/www/html/app/config/production/
|
||||
COPY docker/docker.env /var/www/html/.env
|
||||
|
||||
RUN chown -R docker /var/www/html
|
||||
|
||||
RUN \
|
||||
rm -r "/var/www/html/storage/private_uploads" && ln -fs "/var/lib/snipeit/data/private_uploads" "/var/www/html/storage/private_uploads" && \
|
||||
mkdir -p "/var/www/html/public/uploads" && \
|
||||
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/app/backups" && ln -fs "/var/lib/snipeit/dumps" "/var/www/html/storage/app/backups"
|
||||
|
||||
############## DEPENDENCIES via COMPOSER ###################
|
||||
|
||||
#global install of composer
|
||||
RUN cd /tmp;curl -sS https://getcomposer.org/installer | php;mv /tmp/composer.phar /usr/local/bin/composer
|
||||
|
||||
# Get dependencies
|
||||
RUN cd /var/www/html;composer install
|
||||
|
||||
############### APPLICATION INSTALL/INIT #################
|
||||
|
||||
#RUN php artisan app:install
|
||||
# too interactive! Try something else
|
||||
|
||||
#COPY docker/app_install.exp /tmp/app_install.exp
|
||||
#RUN chmod +x /tmp/app_install.exp
|
||||
#RUN /tmp/app_install.exp
|
||||
|
||||
############### DATA VOLUME #################
|
||||
|
||||
VOLUME [/var/lib/snipeit]
|
||||
|
||||
##### START SERVER
|
||||
|
||||
COPY docker/entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
EXPOSE 80
|
||||
EXPOSE 443
|
||||
@@ -1,55 +1,71 @@
|
||||
[](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)
|
||||
[](https://pledgie.com/campaigns/22899) [](https://travis-ci.org/snipe/snipe-it) [](http://waffle.io/snipe/snipe-it) [](http://stillmaintained.com/snipe/snipe-it) [](https://crowdin.com/project/snipe-it)
|
||||
|
||||
|
||||
## Snipe-IT - Open Source Asset Management System
|
||||
## Snipe-IT - Asset Management For the Rest of Us
|
||||
|
||||
[](https://gitter.im/snipe/snipe-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
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).
|
||||
It is built on [Laravel 4.2](http://laravel.com) and uses the [Sentry 2](https://github.com/cartalyst/sentry) package.
|
||||
|
||||
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 project is being actively developed and we're [releasing quite frequently](https://github.com/snipe/snipe-it/releases). ([Check out the live demo here](http://snipeitapp.com/demo.php).)
|
||||
|
||||
__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.
|
||||
__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.
|
||||
|
||||
-----
|
||||
### Documentation & Installation
|
||||
|
||||
### Installation
|
||||
__Installation and configuration documentation for this project has been moved to http://snipeitapp.com/documentation/.__
|
||||
|
||||
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.)
|
||||
We'll be adding a long-overdue user's manual soon as well.
|
||||
|
||||
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).
|
||||
__To deploy on Ubuntu using Ansible and Vagrant, be sure to check out the [Snipe-IT Installation scripts](https://github.com/GR360RY/snipeit-ansible) created by [@GR360RY](https://github.com/GR360RY/).__
|
||||
|
||||
-----
|
||||
### 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.
|
||||
|
||||
[](http://waffle.io/snipe/snipe-it)
|
||||
|
||||
-----
|
||||
|
||||
### Upgrading
|
||||
|
||||
Please see the [upgrading documentation](https://snipe-it.readme.io/docs/upgrading) for instructions on upgrading Snipe-IT.
|
||||
|
||||
------
|
||||
### Announcement List
|
||||
|
||||
To be notified of important news (such as new releases, security advisories, etc), [sign up for our list](http://eepurl.com/XyZKz). We'll never sell or give away your info, and we'll only email you when it's important.
|
||||
|
||||
------
|
||||
|
||||
### Translations!
|
||||
|
||||
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.
|
||||
If you're not a coder but want to give back to the project and you're fluent in other languages, consider helping out with the translations. We use [CrowdIn](https://crowdin.com) to manage translations, and it makes it super-simple for you to add translations to the project without messing with code. Check out [the Snipe-IT CrowdIn translation project here](https://crowdin.com/project/snipe-it/).
|
||||
|
||||
We currently have English, Chinese, Finnish, Malay, Romanian and Spanish completed, and are looking for lots more!
|
||||
|
||||
-----
|
||||
## Requirements
|
||||
|
||||
- PHP 5.4 or later
|
||||
- MCrypt PHP Extension
|
||||
- Fileinfo Extension
|
||||
|
||||
And _one_ of the following image libraries (for QR codes, asset model image and user avatar image uploads).
|
||||
|
||||
- GD Library (>=2.0) … or …
|
||||
- Imagick PHP extension (>=6.3.8)
|
||||
|
||||
-----
|
||||
|
||||
### Contributing
|
||||
## Important Notes on Updating
|
||||
|
||||
Please see the documentation on [contributing and developing for Snipe-IT](https://snipe-it.readme.io/docs/contributing).
|
||||
Whenever you pull down a new version from master or develop, when you grab the [latest official release](https://github.com/snipe/snipe-it/releases), make sure to run the following commands via command line:
|
||||
|
||||
php composer.phar dump-autoload
|
||||
php artisan migrate
|
||||
|
||||
Forgetting to do this can mean your DB might end up out of sync with the new files you just pulled, or you may have some funky cached autoloader values. It's a good idea to get into the habit of running these every time you pull anything new down. If there are no database changes to migrate, it won't hurt anything to run migrations anyway.
|
||||
|
||||
|
||||
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.
|
||||
[](https://bitdeli.com/free "Bitdeli Badge")
|
||||
|
||||
|
||||
@@ -1,463 +0,0 @@
|
||||
<?php
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Location;
|
||||
use App\Models\Category;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Company;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Manufacturer;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use League\Csv\Reader;
|
||||
|
||||
class AssetImportCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'snipeit:asset-import';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Import Assets from CSV';
|
||||
|
||||
/**
|
||||
* 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');
|
||||
|
||||
|
||||
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';
|
||||
} 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('=====================================');
|
||||
|
||||
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),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CreateAdmin extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'snipeit:create-admin {--first_name=} {--last_name=} {--email=} {--username=} {--password=} {show_in_list?}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create an admin user via command line.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$first_name = $this->option('first_name');
|
||||
$last_name = $this->option('last_name');
|
||||
$username = $this->option('username');
|
||||
$email = $this->option('email');
|
||||
$password = $this->option('password');
|
||||
$show_in_list = $this->argument('show_in_list');
|
||||
|
||||
if (($first_name=='') || ($last_name=='') || ($username=='') || ($email=='') || ($password=='')) {
|
||||
$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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// protected function getArguments()
|
||||
// {
|
||||
// return array(
|
||||
// array('username', InputArgument::REQUIRED, 'Username'),
|
||||
// );
|
||||
// }
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Setting;
|
||||
|
||||
class DisableLDAP extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'snipeit:ldap-disable';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'This is a rescue command that can be used to turn off LDAP settings in the event that you managed to lock yourself out using bad LDAP settings.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
if ($this->confirm("\n****************************************************\nThis will disable LDAP support. You will not be able \nto login with an account that does not exist \nlocally in the Snipe-IT local database. \n****************************************************\n\nDo you wish to continue? [y|N]")) {
|
||||
|
||||
$setting = Setting::first();
|
||||
$setting->ldap_enabled = 0;
|
||||
if ($setting->save()) {
|
||||
$this->info('LDAP has been set to disabled.');
|
||||
} else {
|
||||
$this->info('Unable to disable LDAP.');
|
||||
}
|
||||
} else {
|
||||
$this->info('Canceled. No actions taken.');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,383 +0,0 @@
|
||||
<?php
|
||||
namespace App\Console\Commands;
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'snipeit:license-import';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Import Licenses from CSV';
|
||||
|
||||
/**
|
||||
* 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');
|
||||
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
$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
|
||||
|
||||
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('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('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('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('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('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;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$user_license_maintained = '';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// 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 = '';
|
||||
|
||||
} else {
|
||||
|
||||
$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 ($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') {
|
||||
$email_last_name.=str_replace(' ', '', $last_name);
|
||||
$email_prefix = $first_name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
$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 ----------------');
|
||||
|
||||
if ($user_username!='') {
|
||||
if ($user = User::where('username', $user_username)->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());
|
||||
}
|
||||
|
||||
$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;
|
||||
|
||||
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);
|
||||
|
||||
if ($license->save()) {
|
||||
$this->comment('License '.$user_license_name.' with serial number '.$user_license_serial.' was created');
|
||||
|
||||
|
||||
$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;
|
||||
|
||||
// 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_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('=====================================');
|
||||
|
||||
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),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,981 +0,0 @@
|
||||
<?php
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use League\Csv\Reader;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\Location;
|
||||
use App\Models\Manufacturer;
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\Supplier;
|
||||
use App\Models\User;
|
||||
use App\Models\CustomField;
|
||||
use DB;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
ini_set('max_execution_time', 600); //600 seconds = 10 minutes
|
||||
ini_set('memory_limit', '500M');
|
||||
|
||||
/**
|
||||
* Class ObjectImportCommand
|
||||
*/
|
||||
class ObjectImportCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'snipeit:import';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Import Items from CSV';
|
||||
|
||||
/**
|
||||
* 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');
|
||||
|
||||
|
||||
if (!$this->option('web-importer')) {
|
||||
$logFile = $this->option('logfile');
|
||||
\Log::useFiles($logFile);
|
||||
if ($this->option('testrun')) {
|
||||
$this->comment('====== TEST ONLY Asset Import for '.$filename.' ====');
|
||||
$this->comment('============== NO DATA WILL BE WRITTEN ==============');
|
||||
} else {
|
||||
|
||||
$this->comment('======= Importing Assets from '.$filename.' =========');
|
||||
}
|
||||
}
|
||||
|
||||
if (! ini_get("auto_detect_line_endings")) {
|
||||
ini_set("auto_detect_line_endings", '1');
|
||||
}
|
||||
|
||||
$csv = Reader::createFromPath($this->argument('filename'));
|
||||
$csv->setNewline("\r\n");
|
||||
$results = $csv->fetchAssoc();
|
||||
$newarray = null;
|
||||
|
||||
foreach ($results as $index => $arraytoNormalize) {
|
||||
$internalnewarray = array_change_key_case($arraytoNormalize);
|
||||
$newarray[$index] = $internalnewarray;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->locations = Location::All(['name', 'id']);
|
||||
$this->categories = Category::All(['name', 'category_type', 'id']);
|
||||
$this->manufacturers = Manufacturer::All(['name', 'id']);
|
||||
$this->asset_models = AssetModel::All(['name','modelno','category_id','manufacturer_id', 'id']);
|
||||
$this->companies = Company::All(['name', 'id']);
|
||||
$this->status_labels = Statuslabel::All(['name', 'id']);
|
||||
$this->suppliers = Supplier::All(['name', 'id']);
|
||||
$this->assets = Asset::all(['asset_tag']);
|
||||
$this->accessories = Accessory::All(['name']);
|
||||
$this->consumables = Consumable::All(['name']);
|
||||
$this->customfields = CustomField::All(['name']);
|
||||
$bar = null;
|
||||
|
||||
if (!$this->option('web-importer')) {
|
||||
$bar = $this->output->createProgressBar(count($newarray));
|
||||
}
|
||||
// Loop through the records
|
||||
DB::transaction(function () use (&$newarray, $bar) {
|
||||
Model::unguard();
|
||||
$item_type = strtolower($this->option('item-type'));
|
||||
|
||||
|
||||
|
||||
foreach ($newarray as $row) {
|
||||
|
||||
// Let's just map some of these entries to more user friendly words
|
||||
|
||||
// Fetch general items here, fetch item type specific items in respective methods
|
||||
/** @var Asset, License, Accessory, or Consumable $item_type */
|
||||
|
||||
$item_category = $this->array_smart_fetch($row, "category");
|
||||
$item_company_name = $this->array_smart_fetch($row, "company");
|
||||
$item_location = $this->array_smart_fetch($row, "location");
|
||||
|
||||
$item_status_name = $this->array_smart_fetch($row, "status");
|
||||
|
||||
$item["item_name"] = $this->array_smart_fetch($row, "item name");
|
||||
if ($this->array_smart_fetch($row, "purchase date")!='') {
|
||||
$item["purchase_date"] = date("Y-m-d 00:00:01", strtotime($this->array_smart_fetch($row, "purchase date")));
|
||||
} else {
|
||||
$item["purchase_date"] = null;
|
||||
}
|
||||
|
||||
$item["purchase_cost"] = $this->array_smart_fetch($row, "purchase cost");
|
||||
$item["order_number"] = $this->array_smart_fetch($row, "order number");
|
||||
$item["notes"] = $this->array_smart_fetch($row, "notes");
|
||||
$item["quantity"] = $this->array_smart_fetch($row, "quantity");
|
||||
$item["requestable"] = $this->array_smart_fetch($row, "requestable");
|
||||
$item["asset_tag"] = $this->array_smart_fetch($row, "asset tag");
|
||||
|
||||
|
||||
$this->current_assetId = $item["item_name"];
|
||||
if ($item["asset_tag"] != '') {
|
||||
$this->current_assetId = $item["asset_tag"];
|
||||
}
|
||||
$this->log('Category: ' . $item_category);
|
||||
$this->log('Location: ' . $item_location);
|
||||
$this->log('Purchase Date: ' . $item["purchase_date"]);
|
||||
$this->log('Purchase Cost: ' . $item["purchase_cost"]);
|
||||
$this->log('Company Name: ' . $item_company_name);
|
||||
$this->log('Status: ' . $item_status_name);
|
||||
|
||||
$item["user"] = $this->createOrFetchUser($row);
|
||||
|
||||
$item["location"] = $this->createOrFetchLocation($item_location);
|
||||
$item["category"] = $this->createOrFetchCategory($item_category, $item_type);
|
||||
$item["manufacturer"] = $this->createOrFetchManufacturer($row);
|
||||
$item["company"] = $this->createOrFetchCompany($item_company_name);
|
||||
|
||||
$item["status_label"] = $this->createOrFetchStatusLabel($item_status_name);
|
||||
|
||||
switch ($item_type) {
|
||||
case "asset":
|
||||
// -----------------------------
|
||||
// CUSTOM FIELDS
|
||||
// -----------------------------
|
||||
// Loop through custom fields in the database and see if we have any matches in the CSV
|
||||
foreach ($this->customfields as $customfield) {
|
||||
if ($item['custom_fields'][$customfield->db_column_name()] = $this->array_smart_custom_field_fetch($row, $customfield)) {
|
||||
$this->log('Custom Field '. $customfield->name.': '.$this->array_smart_custom_field_fetch($row, $customfield));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->createAssetIfNotExists($row, $item);
|
||||
break;
|
||||
case "accessory":
|
||||
$this->createAccessoryIfNotExists($item);
|
||||
break;
|
||||
case 'consumable':
|
||||
$this->createConsumableIfNotExists($item);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$this->option('web-importer')) {
|
||||
$bar->advance();
|
||||
}
|
||||
$this->log('------------- Action Summary ----------------');
|
||||
|
||||
}
|
||||
});
|
||||
if (!$this->option('web-importer')) {
|
||||
$bar->finish();
|
||||
}
|
||||
|
||||
|
||||
$this->log('=====================================');
|
||||
if (!$this->option('web-importer')) {
|
||||
if (!empty($this->errors)) {
|
||||
$this->comment("The following Errors were encountered.");
|
||||
foreach ($this->errors as $asset => $error) {
|
||||
$this->comment('Error: Item: ' . $asset . 'failed validation: ' . json_encode($error));
|
||||
}
|
||||
} else {
|
||||
$this->comment("All Items imported successfully!");
|
||||
}
|
||||
} else {
|
||||
if (empty($this->errors)) {
|
||||
return 0;
|
||||
} else {
|
||||
$this->comment(json_encode($this->errors)); //Send a big string to the
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
$this->comment("");
|
||||
|
||||
return 2;
|
||||
}
|
||||
// Tracks the current item for error messages
|
||||
private $current_assetId;
|
||||
|
||||
// An array of errors encountered while parsing
|
||||
private $errors;
|
||||
|
||||
public function jsonError($field, $errorString)
|
||||
{
|
||||
$this->errors[$this->current_assetId][$field] = $errorString;
|
||||
if ($this->option('verbose')) {
|
||||
parent::error($field . $errorString);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a message to file, configurable by the --log-file parameter.
|
||||
* If a warning message is passed, we'll spit it to the console as well.
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @param string $string
|
||||
* @param string $level
|
||||
*/
|
||||
private function log($string, $level = 'info')
|
||||
{
|
||||
if ($this->option('web-importer')) {
|
||||
return;
|
||||
}
|
||||
if ($level === 'warning') {
|
||||
\Log::warning($string);
|
||||
$this->comment($string);
|
||||
} else {
|
||||
\Log::Info($string);
|
||||
if ($this->option('verbose')) {
|
||||
$this->comment($string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 function array_smart_fetch(array $array, $key, $default = '')
|
||||
{
|
||||
return array_key_exists($key, $array) ? e(trim($array[ $key ])) : $default;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Figure out the fieldname of the custom field
|
||||
*
|
||||
* @author A. Gianotto <snipe@snipe.net>
|
||||
* @since 3.0
|
||||
* @param $array array
|
||||
* @return string
|
||||
*/
|
||||
public function array_smart_custom_field_fetch(array $array, $key)
|
||||
{
|
||||
$index_name = strtolower($key->name);
|
||||
return array_key_exists($index_name, $array) ? e(trim($array[$index_name])) : '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
private $asset_models;
|
||||
/**
|
||||
* Select the asset model if it exists, otherwise create it.
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @param array
|
||||
* @param $category Category
|
||||
* @param $manufacturer Manufacturer
|
||||
* @return Model
|
||||
* @internal param $asset_modelno string
|
||||
*/
|
||||
public function createOrFetchAssetModel(array $row, $category, $manufacturer)
|
||||
{
|
||||
|
||||
$asset_model_name = $this->array_smart_fetch($row, "model name");
|
||||
$asset_modelno = $this->array_smart_fetch($row, "model number");
|
||||
if (empty($asset_model_name)) {
|
||||
$asset_model_name='Unknown';
|
||||
}
|
||||
if (empty($asset_modelno)) {
|
||||
$asset_modelno='';
|
||||
}
|
||||
$this->log('Model Name: ' . $asset_model_name);
|
||||
$this->log('Model No: ' . $asset_modelno);
|
||||
|
||||
|
||||
foreach ($this->asset_models as $tempmodel) {
|
||||
if ((strcasecmp($tempmodel->name, $asset_model_name) == 0)
|
||||
&& $tempmodel->modelno == $asset_modelno
|
||||
&& $tempmodel->category_id == $category->id
|
||||
&& $tempmodel->manufacturer_id == $manufacturer->id ) {
|
||||
$this->log('A matching model ' . $asset_model_name . ' with model number ' . $asset_modelno . ' already exists');
|
||||
return $tempmodel;
|
||||
}
|
||||
}
|
||||
$asset_model = new AssetModel();
|
||||
$asset_model->name = $asset_model_name;
|
||||
$asset_model->manufacturer_id = $manufacturer->id;
|
||||
$asset_model->modelno = $asset_modelno;
|
||||
$asset_model->category_id = $category->id;
|
||||
$asset_model->user_id = $this->option('user_id');
|
||||
|
||||
|
||||
if (!$this->option('testrun')) {
|
||||
if ($asset_model->save()) {
|
||||
$this->asset_models->add($asset_model);
|
||||
$this->log('Asset Model ' . $asset_model_name . ' with model number ' . $asset_modelno . ' was created');
|
||||
return $asset_model;
|
||||
} else {
|
||||
$this->jsonError('Asset Model "' . $asset_model_name . '"', $asset_model->getErrors());
|
||||
return $asset_model;
|
||||
}
|
||||
} else {
|
||||
$this->asset_models->add($asset_model);
|
||||
return $asset_model;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private $categories;
|
||||
|
||||
/**
|
||||
* Finds a category with the same name and item type in the database, otherwise creates it
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @param $asset_category string
|
||||
* @param $item_type string
|
||||
* @return Category
|
||||
*/
|
||||
public function createOrFetchCategory($asset_category, $item_type)
|
||||
{
|
||||
if (empty($asset_category)) {
|
||||
$asset_category = 'Unnamed Category';
|
||||
}
|
||||
|
||||
foreach ($this->categories as $tempcategory) {
|
||||
if ((strcasecmp($tempcategory->name, $asset_category) == 0) && $tempcategory->category_type === $item_type) {
|
||||
$this->log('Category ' . $asset_category . ' already exists');
|
||||
return $tempcategory;
|
||||
}
|
||||
}
|
||||
|
||||
$category = new Category();
|
||||
|
||||
$category->name = $asset_category;
|
||||
$category->category_type = $item_type;
|
||||
$category->user_id = $this->option('user_id');
|
||||
|
||||
|
||||
if (!$this->option('testrun')) {
|
||||
if ($category->save()) {
|
||||
$this->categories->add($category);
|
||||
$this->log('Category ' . $asset_category . ' was created');
|
||||
return $category;
|
||||
} else {
|
||||
$this->jsonError('Category "'. $asset_category. '"', $category->getErrors());
|
||||
return $category;
|
||||
}
|
||||
} else {
|
||||
$this->categories->add($category);
|
||||
return $category;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private $companies;
|
||||
|
||||
/**
|
||||
* Fetch an existing company, or create new if it doesn't exist
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @param $asset_company_name string
|
||||
* @return Company
|
||||
*/
|
||||
public function createOrFetchCompany($asset_company_name)
|
||||
{
|
||||
foreach ($this->companies as $tempcompany) {
|
||||
if (strcasecmp($tempcompany->name, $asset_company_name) == 0) {
|
||||
$this->log('A matching Company ' . $asset_company_name . ' already exists');
|
||||
return $tempcompany;
|
||||
}
|
||||
}
|
||||
|
||||
$company = new Company();
|
||||
$company->name = $asset_company_name;
|
||||
|
||||
if (!$this->option('testrun')) {
|
||||
if ($company->save()) {
|
||||
$this->companies->add($company);
|
||||
$this->log('Company ' . $asset_company_name . ' was created');
|
||||
return $company;
|
||||
} else {
|
||||
$this->log('Company', $company->getErrors());
|
||||
}
|
||||
} else {
|
||||
$this->companies->add($company);
|
||||
return $company;
|
||||
}
|
||||
}
|
||||
private $status_labels;
|
||||
/**
|
||||
* Fetch the existing status label or create new if it doesn't exist.
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @param string $asset_statuslabel_name
|
||||
* @return Company
|
||||
*/
|
||||
public function createOrFetchStatusLabel($asset_statuslabel_name)
|
||||
{
|
||||
if (empty($asset_statuslabel_name)) {
|
||||
return;
|
||||
}
|
||||
foreach ($this->status_labels as $tempstatus) {
|
||||
if (strcasecmp($tempstatus->name, $asset_statuslabel_name) == 0) {
|
||||
$this->log('A matching Status ' . $asset_statuslabel_name . ' already exists');
|
||||
return $tempstatus;
|
||||
}
|
||||
}
|
||||
$status = new Statuslabel();
|
||||
$status->name = $asset_statuslabel_name;
|
||||
|
||||
|
||||
if (!$this->option('testrun')) {
|
||||
if ($status->save()) {
|
||||
$this->status_labels->add($status);
|
||||
$this->log('Status ' . $asset_statuslabel_name . ' was created');
|
||||
return $status;
|
||||
} else {
|
||||
$this->jsonError('Status "'. $asset_statuslabel_name . '"', $status->getErrors());
|
||||
return $status;
|
||||
}
|
||||
} else {
|
||||
$this->status_labels->add($status);
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
private $manufacturers;
|
||||
|
||||
/**
|
||||
* Finds a manufacturer with matching name, otherwise create it.
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @param $row array
|
||||
* @return Manufacturer
|
||||
* @internal param $asset_mfgr string
|
||||
*/
|
||||
|
||||
public function createOrFetchManufacturer(array $row)
|
||||
{
|
||||
$asset_mfgr = $this->array_smart_fetch($row, "manufacturer");
|
||||
|
||||
if (empty($asset_mfgr)) {
|
||||
$asset_mfgr='Unknown';
|
||||
}
|
||||
$this->log('Manufacturer ID: ' . $asset_mfgr);
|
||||
|
||||
foreach ($this->manufacturers as $tempmanufacturer) {
|
||||
if (strcasecmp($tempmanufacturer->name, $asset_mfgr) == 0) {
|
||||
$this->log('Manufacturer ' . $asset_mfgr . ' already exists') ;
|
||||
return $tempmanufacturer;
|
||||
}
|
||||
}
|
||||
|
||||
//Otherwise create a manufacturer.
|
||||
|
||||
$manufacturer = new Manufacturer();
|
||||
$manufacturer->name = $asset_mfgr;
|
||||
$manufacturer->user_id = $this->option('user_id');
|
||||
|
||||
if (!$this->option('testrun')) {
|
||||
if ($manufacturer->save()) {
|
||||
$this->manufacturers->add($manufacturer);
|
||||
$this->log('Manufacturer ' . $manufacturer->name . ' was created');
|
||||
return $manufacturer;
|
||||
} else {
|
||||
$this->jsonError('Manufacturer "'. $manufacturer->name . '"', $manufacturer->getErrors());
|
||||
return $manufacturer;
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->manufacturers->add($manufacturer);
|
||||
return $manufacturer;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
private $locations;
|
||||
/**
|
||||
* Checks the DB to see if a location with the same name exists, otherwise create it
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @param $asset_location string
|
||||
* @return Location
|
||||
*/
|
||||
public function createOrFetchLocation($asset_location)
|
||||
{
|
||||
foreach ($this->locations as $templocation) {
|
||||
if (strcasecmp($templocation->name, $asset_location) == 0) {
|
||||
$this->log('Location ' . $asset_location . ' already exists');
|
||||
return $templocation;
|
||||
}
|
||||
}
|
||||
// No matching locations in the collection, create a new one.
|
||||
$location = new Location();
|
||||
|
||||
if (!empty($asset_location)) {
|
||||
$location->name = $asset_location;
|
||||
$location->address = '';
|
||||
$location->city = '';
|
||||
$location->state = '';
|
||||
$location->country = '';
|
||||
$location->user_id = $this->option('user_id');
|
||||
|
||||
if (!$this->option('testrun')) {
|
||||
if ($location->save()) {
|
||||
$this->locations->add($location);
|
||||
$this->log('Location ' . $asset_location . ' was created');
|
||||
return $location;
|
||||
} else {
|
||||
$this->log('Location', $location->getErrors()) ;
|
||||
return $location;
|
||||
}
|
||||
} else {
|
||||
$this->locations->add($location);
|
||||
return $location;
|
||||
}
|
||||
} else {
|
||||
$this->log('No location given, so none created.');
|
||||
return $location;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private $suppliers;
|
||||
|
||||
/**
|
||||
* Fetch an existing supplier or create new if it doesn't exist
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @param $row array
|
||||
* @return Supplier
|
||||
*/
|
||||
public function createOrFetchSupplier(array $row)
|
||||
{
|
||||
$supplier_name = $this->array_smart_fetch($row, "supplier");
|
||||
if (empty($supplier_name)) {
|
||||
$supplier_name='Unknown';
|
||||
}
|
||||
foreach ($this->suppliers as $tempsupplier) {
|
||||
if (strcasecmp($tempsupplier->name, $supplier_name) == 0) {
|
||||
$this->log('A matching Company ' . $supplier_name . ' already exists');
|
||||
return $tempsupplier;
|
||||
}
|
||||
}
|
||||
|
||||
$supplier = new Supplier();
|
||||
$supplier->name = $supplier_name;
|
||||
$supplier->user_id = $this->option('user_id');
|
||||
|
||||
if (!$this->option('testrun')) {
|
||||
if ($supplier->save()) {
|
||||
$this->suppliers->add($supplier);
|
||||
$this->log('Supplier ' . $supplier_name . ' was created');
|
||||
return $supplier;
|
||||
} else {
|
||||
$this->log('Supplier', $supplier->getErrors());
|
||||
return $supplier;
|
||||
}
|
||||
} else {
|
||||
$this->suppliers->add($supplier);
|
||||
return $supplier;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the user matching given data, or creates a new one if there is no match
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @param $row array
|
||||
* @return User Model w/ matching name
|
||||
* @internal param string $user_username Username extracted from CSV
|
||||
* @internal param string $user_email Email extracted from CSV
|
||||
* @internal param string $first_name
|
||||
* @internal param string $last_name
|
||||
*/
|
||||
public function createOrFetchUser($row)
|
||||
{
|
||||
$user_name = $this->array_smart_fetch($row, "name");
|
||||
$user_email = $this->array_smart_fetch($row, "email");
|
||||
$user_username = $this->array_smart_fetch($row, "username");
|
||||
|
||||
// A number was given instead of a name
|
||||
if (is_numeric($user_name)) {
|
||||
$this->log('User '.$user_name.' is not a name - assume this user already exists');
|
||||
$user_username = '';
|
||||
$first_name = '';
|
||||
$last_name = '';
|
||||
|
||||
// No name was given
|
||||
} elseif (empty($user_name)) {
|
||||
$this->log('No user data provided - skipping user creation, just adding asset');
|
||||
$first_name = '';
|
||||
$last_name = '';
|
||||
//$user_username = '';
|
||||
} else {
|
||||
$user_email_array = User::generateFormattedNameFromFullName(Setting::getSettings()->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'].'@'.Setting::getSettings()->email_domain;
|
||||
}
|
||||
|
||||
if ($user_username=='') {
|
||||
if ($this->option('username_format')=='email') {
|
||||
$user_username = $user_email;
|
||||
} else {
|
||||
$user_name_array = User::generateFormattedNameFromFullName(Setting::getSettings()->username_format, $user_name);
|
||||
$user_username = $user_name_array['username'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$this->log("--- User Data ---");
|
||||
$this->log('Full Name: ' . $user_name);
|
||||
$this->log('First Name: ' . $first_name);
|
||||
$this->log('Last Name: ' . $last_name);
|
||||
$this->log('Username: ' . $user_username);
|
||||
$this->log('Email: ' . $user_email);
|
||||
$this->log('--- End User Data ---');
|
||||
|
||||
if ($this->option('testrun')) {
|
||||
return new User;
|
||||
}
|
||||
|
||||
if (!empty($user_username)) {
|
||||
if ($user = User::MatchEmailOrUsername($user_username, $user_email)
|
||||
->whereNotNull('username')->first()) {
|
||||
|
||||
$this->log('User '.$user_username.' already exists');
|
||||
} elseif (( $first_name != '') && ($last_name != '') && ($user_username != '')) {
|
||||
$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->password = bcrypt($password);
|
||||
$user->activated = 1;
|
||||
if ($user->save()) {
|
||||
$this->log('User '.$first_name.' created');
|
||||
} else {
|
||||
$this->jsonError('User "' . $first_name . '"', $user->getErrors());
|
||||
}
|
||||
|
||||
} else {
|
||||
$user = new User;
|
||||
}
|
||||
} else {
|
||||
$user = new User;
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
|
||||
private $assets;
|
||||
|
||||
/**
|
||||
* Create the asset if it doesn't exist.
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @param array $row
|
||||
* @param array $item
|
||||
*/
|
||||
public function createAssetIfNotExists(array $row, array $item)
|
||||
{
|
||||
$asset_serial = $this->array_smart_fetch($row, "serial number");
|
||||
$asset_image = $this->array_smart_fetch($row, "image");
|
||||
$asset_warranty_months = intval($this->array_smart_fetch($row, "warranty months"));
|
||||
if (empty($asset_warranty_months)) {
|
||||
$asset_warranty_months = null;
|
||||
}
|
||||
// Check for the asset model match and create it if it doesn't exist
|
||||
$asset_model = $this->createOrFetchAssetModel($row, $item["category"], $item["manufacturer"]);
|
||||
$supplier = $this->createOrFetchSupplier($row);
|
||||
|
||||
$this->log('Serial No: '.$asset_serial);
|
||||
$this->log('Asset Tag: '.$item['asset_tag']);
|
||||
$this->log('Notes: '.$item["notes"]);
|
||||
$this->log('Warranty Months: ' . $asset_warranty_months);
|
||||
|
||||
foreach ($this->assets as $tempasset) {
|
||||
if (strcasecmp($tempasset->asset_tag, $item['asset_tag']) == 0) {
|
||||
$this->log('A matching Asset ' . $item['asset_tag'] . ' already exists');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($item["status_label"]) {
|
||||
$status_id = $item["status_label"]->id;
|
||||
|
||||
} else {
|
||||
// FIXME: We're already grabbing the list of statuses, we should probably not hardcode here
|
||||
$this->log("No status field found, defaulting to id 1.");
|
||||
$status_id = 1;
|
||||
}
|
||||
|
||||
$asset = new Asset();
|
||||
$asset->name = $item["item_name"];
|
||||
if ($item["purchase_date"] != '') {
|
||||
$asset->purchase_date = $item["purchase_date"];
|
||||
} else {
|
||||
$asset->purchase_date = null;
|
||||
}
|
||||
|
||||
if (array_key_exists('custom_fields', $item)) {
|
||||
foreach ($item['custom_fields'] as $custom_field => $val) {
|
||||
$asset->{$custom_field} = $val;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($item["purchase_cost"])) {
|
||||
//TODO How to generalize this for not USD?
|
||||
$purchase_cost = substr($item["purchase_cost"], 0, 1) === '$' ? substr($item["purchase_cost"], 1) : $item["purchase_cost"];
|
||||
$asset->purchase_cost = number_format($purchase_cost, 2);
|
||||
$this->log("Asset cost parsed: " . $asset->purchase_cost);
|
||||
} else {
|
||||
$asset->purchase_cost = 0.00;
|
||||
}
|
||||
$asset->serial = $asset_serial;
|
||||
$asset->asset_tag = $item['asset_tag'];
|
||||
$asset->warranty_months = $asset_warranty_months;
|
||||
|
||||
if ($asset_model) {
|
||||
$asset->model_id = $asset_model->id;
|
||||
}
|
||||
if ($item["user"]) {
|
||||
$asset->assigned_to = $item["user"]->id;
|
||||
}
|
||||
if ($item["location"]) {
|
||||
$asset->rtd_location_id = $item["location"]->id;
|
||||
}
|
||||
$asset->user_id = $this->option('user_id');
|
||||
$this->log("status_id: " . $status_id);
|
||||
$asset->status_id = $status_id;
|
||||
if ($item["company"]) {
|
||||
$asset->company_id = $item["company"]->id;
|
||||
}
|
||||
$asset->order_number = $item["order_number"];
|
||||
if ($supplier) {
|
||||
$asset->supplier_id = $supplier->id;
|
||||
}
|
||||
$asset->notes = $item["notes"];
|
||||
$asset->image = $asset_image;
|
||||
$this->assets->add($asset);
|
||||
if (!$this->option('testrun')) {
|
||||
|
||||
if ($asset->save()) {
|
||||
$this->log('Asset ' . $item["item_name"] . ' with serial number ' . $asset_serial . ' was created');
|
||||
} else {
|
||||
$this->jsonError('Asset', $asset->getErrors());
|
||||
}
|
||||
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private $accessories;
|
||||
|
||||
/**
|
||||
* Create an accessory if a duplicate does not exist
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @param $item array
|
||||
*/
|
||||
public function createAccessoryIfNotExists(array $item)
|
||||
{
|
||||
$this->log("Creating Accessory");
|
||||
foreach ($this->accessories as $tempaccessory) {
|
||||
if (strcasecmp($tempaccessory->name, $item["item_name"]) == 0) {
|
||||
$this->log('A matching Accessory ' . $item["item_name"] . ' already exists. ');
|
||||
// FUTURE: Adjust quantity on import maybe?
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$accessory = new Accessory();
|
||||
$accessory->name = $item["item_name"];
|
||||
|
||||
if (!empty($item["purchase_date"])) {
|
||||
$accessory->purchase_date = $item["purchase_date"];
|
||||
} else {
|
||||
$accessory->purchase_date = null;
|
||||
}
|
||||
if (!empty($item["purchase_cost"])) {
|
||||
$accessory->purchase_cost = number_format(e($item["purchase_cost"]), 2);
|
||||
} else {
|
||||
$accessory->purchase_cost = 0.00;
|
||||
}
|
||||
if ($item["location"]) {
|
||||
$accessory->location_id = $item["location"]->id;
|
||||
}
|
||||
$accessory->user_id = $this->option('user_id');
|
||||
if ($item["company"]) {
|
||||
$accessory->company_id = $item["company"]->id;
|
||||
}
|
||||
$accessory->order_number = $item["order_number"];
|
||||
if ($item["category"]) {
|
||||
$accessory->category_id = $item["category"]->id;
|
||||
}
|
||||
|
||||
//TODO: Implement
|
||||
// $accessory->notes = e($item_notes);
|
||||
$accessory->requestable = filter_var($item["requestable"], FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
//Must have at least zero of the item if we import it.
|
||||
if ($item["quantity"] > -1) {
|
||||
$accessory->qty = $item["quantity"];
|
||||
} else {
|
||||
$accessory->qty = 1;
|
||||
}
|
||||
|
||||
if (!$this->option('testrun')) {
|
||||
if ($accessory->save()) {
|
||||
$this->log('Accessory ' . $item["item_name"] . ' was created');
|
||||
// $this->comment('Accessory ' . $item["item_name"] . ' was created');
|
||||
|
||||
} else {
|
||||
$this->jsonError('Accessory', $accessory->getErrors()) ;
|
||||
}
|
||||
} else {
|
||||
$this->log('TEST RUN - Accessory ' . $item["item_name"] . ' not created');
|
||||
}
|
||||
}
|
||||
|
||||
private $consumables;
|
||||
|
||||
/**
|
||||
* Create a consumable if a duplicate does not exist
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @param $item array
|
||||
*/
|
||||
public function createConsumableIfNotExists(array $item)
|
||||
{
|
||||
$this->log("Creating Consumable");
|
||||
foreach ($this->consumables as $tempconsumable) {
|
||||
if (strcasecmp($tempconsumable->name, $item["item_name"]) == 0) {
|
||||
$this->log("A matching consumable " . $item["item_name"] . " already exists");
|
||||
//TODO: Adjust quantity if different maybe?
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$consumable = new Consumable();
|
||||
$consumable->name = $item["item_name"];
|
||||
|
||||
if (!empty($item["purchase_date"])) {
|
||||
$consumable->purchase_date = $item["purchase_date"];
|
||||
} else {
|
||||
$consumable->purchase_date = null;
|
||||
}
|
||||
|
||||
if (!empty($item["purchase_cost"])) {
|
||||
$consumable->purchase_cost = number_format(e($item["purchase_cost"]), 2);
|
||||
} else {
|
||||
$consumable->purchase_cost = 0.00;
|
||||
}
|
||||
$consumable->location_id = $item["location"]->id;
|
||||
$consumable->user_id = $this->option('user_id');
|
||||
$consumable->company_id = $item["company"]->id;
|
||||
$consumable->order_number = $item["order_number"];
|
||||
$consumable->category_id = $item["category"]->id;
|
||||
// TODO:Implement
|
||||
//$consumable->notes= e($item_notes);
|
||||
$consumable->requestable = filter_var($item["requestable"], FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
if ($item["quantity"] > -1) {
|
||||
$consumable->qty = $item["quantity"];
|
||||
} else {
|
||||
$consumable->qty = 1;
|
||||
}
|
||||
|
||||
if (!$this->option("testrun")) {
|
||||
if ($consumable->save()) {
|
||||
$this->log("Consumable " . $item["item_name"] . ' was created');
|
||||
// $this->comment("Consumable " . $item["item_name"] . ' was created');
|
||||
|
||||
} else {
|
||||
$this->jsonError('Consumable', $consumable->getErrors());
|
||||
}
|
||||
} else {
|
||||
$this->log('TEST RUN - Consumable ' . $item['item_name'] . ' not created');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return array(
|
||||
array('filename', InputArgument::REQUIRED, 'File for the CSV import.'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
* @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_NONE, 'If set, will parse and output data without adding to database', null),
|
||||
array('logfile', null, InputOption::VALUE_REQUIRED, 'The path to log output to. storage/logs/importer.log by default', storage_path('logs/importer.log') ),
|
||||
array('item-type', null, InputOption::VALUE_REQUIRED, 'Item Type To import. Valid Options are Asset, Consumable, Or Accessory', 'Asset'),
|
||||
array('web-importer', null, InputOption::VALUE_NONE, 'Internal: packages output for use with the web importer'),
|
||||
array('user_id', null, InputOption::VALUE_REQUIRED, 'ID of user creating items', 1)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
<?php
|
||||
|
||||
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
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'snipeit:pave
|
||||
{--soft : Perform a "Soft" Delete, leaving all migrations, table structure, and the first user in place.}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Pave the database to start over. This should ALMOST NEVER BE USED. (It is primarily a quick tool for developers.)';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
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();
|
||||
|
||||
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 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 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');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use DB;
|
||||
use \App\Models\Asset;
|
||||
use \App\Models\AssetModel;
|
||||
use \App\Models\Location;
|
||||
use \App\Models\Company;
|
||||
use \App\Models\License;
|
||||
use \App\Models\Accessory;
|
||||
use \App\Models\Component;
|
||||
use \App\Models\Consumable;
|
||||
use \App\Models\Category;
|
||||
use \App\Models\User;
|
||||
use \App\Models\Supplier;
|
||||
use \App\Models\Manufacturer;
|
||||
use \App\Models\Depreciation;
|
||||
use \App\Models\Statuslabel;
|
||||
|
||||
class Purge extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'snipeit:purge {--force=false}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Purge all soft-deleted deleted records in the database. This will rewrite history for items that have been edited, or checked in or out. It will also reqrite history for users associated with deleted items.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
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') {
|
||||
|
||||
/**
|
||||
* Delete assets
|
||||
*/
|
||||
$assets = Asset::whereNotNull('deleted_at')->withTrashed()->get();
|
||||
$assetcount = $assets->count();
|
||||
$this->info($assets->count().' assets purged.');
|
||||
$asset_assoc = 0;
|
||||
|
||||
foreach ($assets as $asset) {
|
||||
$this->info('- Asset "'.$asset->showAssetName().'" deleted.');
|
||||
$asset_assoc += $asset->assetlog()->count();
|
||||
$asset->assetlog()->forceDelete();
|
||||
$asset->forceDelete();
|
||||
}
|
||||
|
||||
$this->info($asset_assoc.' corresponding log records purged.');
|
||||
|
||||
$locations = Location::whereNotNull('deleted_at')->withTrashed()->get();
|
||||
$this->info($locations->count().' locations purged.');
|
||||
foreach ($locations as $location) {
|
||||
$this->info('- Location "'.$location->name.'" deleted.');
|
||||
$location->forceDelete();
|
||||
}
|
||||
|
||||
|
||||
$accessories = Accessory::whereNotNull('deleted_at')->withTrashed()->get();
|
||||
$accessory_assoc=0;
|
||||
$this->info($accessories->count().' accessories purged.');
|
||||
foreach ($accessories as $accessory) {
|
||||
$this->info('- Accessory "'.$accessory->name.'" deleted.');
|
||||
$accessory_assoc += $accessory->assetlog()->count();
|
||||
$accessory->assetlog()->forceDelete();
|
||||
$accessory->forceDelete();
|
||||
}
|
||||
$this->info($accessory_assoc.' corresponding log records purged.');
|
||||
|
||||
|
||||
$consumables = Consumable::whereNotNull('deleted_at')->withTrashed()->get();
|
||||
$this->info($consumables->count().' consumables purged.');
|
||||
foreach ($consumables as $consumable) {
|
||||
$this->info('- Consumable "'.$consumable->name.'" deleted.');
|
||||
$consumable->assetlog()->forceDelete();
|
||||
$consumable->forceDelete();
|
||||
}
|
||||
|
||||
|
||||
$components = Component::whereNotNull('deleted_at')->withTrashed()->get();
|
||||
$this->info($components->count().' components purged.');
|
||||
foreach ($components as $component) {
|
||||
$this->info('- Component "'.$component->name.'" deleted.');
|
||||
$component->assetlog()->forceDelete();
|
||||
$component->forceDelete();
|
||||
}
|
||||
|
||||
$licenses = License::whereNotNull('deleted_at')->withTrashed()->get();
|
||||
$this->info($licenses->count().' licenses purged.');
|
||||
foreach ($licenses as $license) {
|
||||
$this->info('- License "'.$license->name.'" deleted.');
|
||||
$license->assetlog()->forceDelete();
|
||||
$license->licenseseats()->forceDelete();
|
||||
$license->forceDelete();
|
||||
}
|
||||
|
||||
$models = AssetModel::whereNotNull('deleted_at')->withTrashed()->get();
|
||||
$this->info($models->count().' asset models purged.');
|
||||
foreach ($models as $model) {
|
||||
$this->info('- Asset Model "'.$model->name.'" deleted.');
|
||||
$model->forceDelete();
|
||||
}
|
||||
|
||||
|
||||
$categories = Category::whereNotNull('deleted_at')->withTrashed()->get();
|
||||
$this->info($categories->count().' categories purged.');
|
||||
foreach ($categories as $category) {
|
||||
$this->info('- Category "'.$category->name.'" deleted.');
|
||||
$category->forceDelete();
|
||||
}
|
||||
|
||||
$suppliers = Supplier::whereNotNull('deleted_at')->withTrashed()->get();
|
||||
$this->info($suppliers->count().' suppliers purged.');
|
||||
foreach ($suppliers as $supplier) {
|
||||
$this->info('- Supplier "'.$supplier->name.'" deleted.');
|
||||
$supplier->forceDelete();
|
||||
}
|
||||
|
||||
$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) {
|
||||
$this->info('- User "'.$user->username.'" deleted.');
|
||||
$user_assoc += $user->userlog()->count();
|
||||
$user->userlog()->forceDelete();
|
||||
$user->forceDelete();
|
||||
}
|
||||
$this->info($user_assoc.' corresponding user log records purged.');
|
||||
|
||||
$manufacturers = Manufacturer::whereNotNull('deleted_at')->withTrashed()->get();
|
||||
$this->info($manufacturers->count().' manufacturers purged.');
|
||||
foreach ($manufacturers as $manufacturer) {
|
||||
$this->info('- Manufacturer "'.$manufacturer->name.'" deleted.');
|
||||
$manufacturer->forceDelete();
|
||||
}
|
||||
|
||||
$status_labels = Statuslabel::whereNotNull('deleted_at')->withTrashed()->get();
|
||||
$this->info($status_labels->count().' status labels purged.');
|
||||
foreach ($status_labels as $status_label) {
|
||||
$this->info('- Status Label "'.$status_label->name.'" deleted.');
|
||||
$status_label->forceDelete();
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$this->info('Action canceled. Nothing was purged.');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Models\License;
|
||||
use App\Models\Setting;
|
||||
use DB;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendExpirationAlerts extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* 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.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
|
||||
$asset_data['count'] = count($expiring_assets);
|
||||
$asset_data['email_content'] ='';
|
||||
$now = date("Y-m-d");
|
||||
|
||||
|
||||
foreach ($expiring_assets as $asset) {
|
||||
|
||||
$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>';
|
||||
$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>';
|
||||
}
|
||||
|
||||
// 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'] = '';
|
||||
|
||||
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 ((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_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');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
} 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";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Setting;
|
||||
use DB;
|
||||
use Mail;
|
||||
use App\Helpers\Helper;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendInventoryAlerts extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'snipeit:inventory-alerts';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'This command checks for low inventory, and sends out an alert email.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if ((Setting::getSettings()->alert_email!='') && (Setting::getSettings()->alerts_enabled==1)) {
|
||||
|
||||
$data['data'] = Helper::checkLowInventory();
|
||||
$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');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
} 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";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SystemBackup extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* 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');
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class Versioning extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'versioning:update';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Generate and update app\'s version via git.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
// Path to the file containing your version
|
||||
// This will be overwritten everything you commit a message
|
||||
$versionFile = app_path().'/config/version.php';
|
||||
|
||||
// The git's output
|
||||
// get the argument passed in the git command
|
||||
$hash_version = $this->argument('app_version');
|
||||
|
||||
// discard the commit hash
|
||||
$version = explode('-', $hash_version);
|
||||
$realVersion = $version[0] . '-' . $version[1];
|
||||
|
||||
// save the version array to a variable
|
||||
$array = var_export(array('app_version' => $realVersion,'hash_version' => $hash_version), true);
|
||||
|
||||
|
||||
// Construct our file content
|
||||
$content = <<<CON
|
||||
<?php
|
||||
return $array;
|
||||
CON;
|
||||
|
||||
// And finally write the file and output the current version
|
||||
\File::put($versionFile, $content);
|
||||
$this->line('Setting version: '. \config('version.latest'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return array(
|
||||
array('app_version', InputArgument::REQUIRED, 'version number is required.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
Commands\PaveIt::class,
|
||||
Commands\CreateAdmin::class,
|
||||
Commands\SendExpirationAlerts::class,
|
||||
Commands\SendInventoryAlerts::class,
|
||||
Commands\LicenseImportCommand::class,
|
||||
Commands\ObjectImportCommand::class,
|
||||
Commands\Versioning::class,
|
||||
Commands\SystemBackup::class,
|
||||
Commands\DisableLDAP::class,
|
||||
Commands\Purge::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
|
||||
$schedule->command('snipeit:inventory-alerts')->daily();
|
||||
$schedule->command('snipeit:expiring-alerts')->daily();
|
||||
$schedule->command('snipeit:backup')->weekly();
|
||||
$schedule->command('backup:clean')->daily();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
abstract class Event
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
AuthorizationException::class,
|
||||
HttpException::class,
|
||||
ModelNotFoundException::class,
|
||||
ValidationException::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $e)
|
||||
{
|
||||
parent::report($e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
{
|
||||
if ($e instanceof \Illuminate\Session\TokenMismatchException) {
|
||||
return redirect()->back()->with('error', trans('general.token_expired'));
|
||||
}
|
||||
|
||||
if ($this->isHttpException($e)) {
|
||||
|
||||
$statusCode = $e->getStatusCode();
|
||||
|
||||
switch ($statusCode) {
|
||||
|
||||
case '404':
|
||||
return response()->view('layouts/basic', [
|
||||
'content' => view('errors/404')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
}
|
||||
@@ -1,406 +0,0 @@
|
||||
<?php
|
||||
namespace App\Helpers;
|
||||
|
||||
use DB;
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\Location;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Company;
|
||||
use App\Models\User;
|
||||
use App\Models\Manufacturer;
|
||||
use App\Models\Supplier;
|
||||
use App\Models\Category;
|
||||
use App\Models\Depreciation;
|
||||
use App\Models\CustomFieldset;
|
||||
use App\Models\CustomField;
|
||||
use App\Models\Component;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\Asset;
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
class Helper
|
||||
{
|
||||
|
||||
|
||||
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 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)
|
||||
{
|
||||
// use comma for thousands until local info is property used
|
||||
$LocaleInfo = localeconv();
|
||||
$floatString = str_replace(",", "", $floatString);
|
||||
$floatString = str_replace($LocaleInfo["decimal_point"], ".", $floatString);
|
||||
return floatval($floatString);
|
||||
}
|
||||
|
||||
|
||||
public static function modelList()
|
||||
{
|
||||
$models = AssetModel::with('manufacturer')->get();
|
||||
$model_array[''] = trans('general.select_model');
|
||||
foreach ($models as $model) {
|
||||
$model_array[$model->id] = $model->displayModelName();
|
||||
}
|
||||
return $model_array;
|
||||
}
|
||||
|
||||
public static function companyList()
|
||||
{
|
||||
$company_list = array('0' => trans('general.select_company')) + DB::table('companies')
|
||||
->orderBy('name', 'asc')
|
||||
->pluck('name', 'id');
|
||||
return $company_list;
|
||||
}
|
||||
|
||||
|
||||
public static function categoryList($category_type = null)
|
||||
{
|
||||
$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();
|
||||
return $supplier_list;
|
||||
}
|
||||
|
||||
public static function statusLabelList()
|
||||
{
|
||||
$statuslabel_list = array('' => trans('general.select_statuslabel')) + Statuslabel::orderBy('name', 'asc')
|
||||
->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();
|
||||
return $location_list;
|
||||
}
|
||||
|
||||
public static function manufacturerList()
|
||||
{
|
||||
$manufacturer_list = array('' => trans('general.select_manufacturer')) +
|
||||
Manufacturer::orderBy('name', 'asc')
|
||||
->pluck('name', 'id')->toArray();
|
||||
return $manufacturer_list;
|
||||
}
|
||||
|
||||
public static function statusTypeList()
|
||||
{
|
||||
$statuslabel_types = array('' => trans('admin/hardware/form.select_statustype')) + array('undeployable' => trans('admin/hardware/general.undeployable')) + array('pending' => trans('admin/hardware/general.pending')) + array('archived' => trans('admin/hardware/general.archived')) + array('deployable' => trans('admin/hardware/general.deployable'));
|
||||
return $statuslabel_types;
|
||||
}
|
||||
|
||||
public static function managerList()
|
||||
{
|
||||
$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();
|
||||
return $depreciation_list;
|
||||
}
|
||||
|
||||
public static function categoryTypeList()
|
||||
{
|
||||
$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')) +
|
||||
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();
|
||||
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()
|
||||
{
|
||||
$customfields = array('' => trans('admin/models/general.no_custom_field')) + CustomFieldset::pluck('name', 'id')->toArray();
|
||||
return $customfields;
|
||||
}
|
||||
|
||||
public static function predefined_formats()
|
||||
{
|
||||
$keys=array_keys(CustomField::$PredefinedFormats);
|
||||
$stuff=array_combine($keys, $keys);
|
||||
return $stuff+["" => "Custom Format..."];
|
||||
}
|
||||
|
||||
public static function barcodeDimensions($barcode_type = 'QRCODE')
|
||||
{
|
||||
if ($barcode_type == 'C128') {
|
||||
$size['height'] = '-1';
|
||||
$size['width'] = '-10';
|
||||
} elseif ($barcode_type == 'PDF417') {
|
||||
$size['height'] = '-3';
|
||||
$size['width'] = '-10';
|
||||
} else {
|
||||
$size['height'] = '-3';
|
||||
$size['width'] = '-3';
|
||||
}
|
||||
return $size;
|
||||
}
|
||||
|
||||
public static function generateRandomString($length = 10)
|
||||
{
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
$accessories = Accessory::with('users')->whereNotNull('min_amt')->get();
|
||||
$components = Component::with('assets')->whereNotNull('min_amt')->get();
|
||||
|
||||
$avail_consumables = 0;
|
||||
$items_array = array();
|
||||
$all_count = 0;
|
||||
|
||||
foreach ($consumables as $consumable) {
|
||||
$avail = $consumable->numRemaining();
|
||||
if ($avail < ($consumable->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
|
||||
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';
|
||||
$items_array[$all_count]['percent'] = $percent;
|
||||
$items_array[$all_count]['remaining']=$consumable->numRemaining();
|
||||
$items_array[$all_count]['min_amt']=$consumable->min_amt;
|
||||
$all_count++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
foreach ($accessories as $accessory) {
|
||||
$avail = $accessory->numRemaining();
|
||||
if ($avail < ($accessory->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
|
||||
|
||||
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';
|
||||
$items_array[$all_count]['percent'] = $percent;
|
||||
$items_array[$all_count]['remaining']=$accessory->numRemaining();
|
||||
$items_array[$all_count]['min_amt']=$accessory->min_amt;
|
||||
$all_count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($components as $component) {
|
||||
$avail = $component->numRemaining();
|
||||
if ($avail < ($component->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
|
||||
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';
|
||||
$items_array[$all_count]['percent'] = $percent;
|
||||
$items_array[$all_count]['remaining']=$component->numRemaining();
|
||||
$items_array[$all_count]['min_amt']=$component->min_amt;
|
||||
$all_count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $items_array;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function checkUploadIsImage($file)
|
||||
{
|
||||
// Check if the file is an image, so we can show a preview
|
||||
$finfo = @finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
|
||||
$filetype = @finfo_file($finfo, $file);
|
||||
finfo_close($finfo);
|
||||
|
||||
if (($filetype=="image/jpeg") || ($filetype=="image/jpg") || ($filetype=="image/png") || ($filetype=="image/bmp") || ($filetype=="image/gif")) {
|
||||
return $filetype;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
|
||||
for ($x = 0; $x < count($permission); $x++) {
|
||||
$permission_name = $permission[$x]['permission'];
|
||||
|
||||
if ($permission[$x]['display'] === true) {
|
||||
|
||||
if ($selected_arr) {
|
||||
if (array_key_exists($permission_name,$selected_arr)) {
|
||||
$permissions_arr[$permission_name] = $selected_arr[$permission_name];
|
||||
} else {
|
||||
$permissions_arr[$permission_name] = '0';
|
||||
}
|
||||
} else {
|
||||
$permissions_arr[$permission_name] = '0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $permissions_arr;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,669 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Company;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Config;
|
||||
use DB;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Mail;
|
||||
use Redirect;
|
||||
use Slack;
|
||||
use Str;
|
||||
use View;
|
||||
use Auth;
|
||||
use Request;
|
||||
|
||||
/** This controller handles all actions related to Accessories for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class AccessoriesController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the accessories listing, which is generated in getDatatable.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see AccessoriesController::getDatatable() method that generates the JSON response
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex(Request $request)
|
||||
{
|
||||
return View::make('accessories/index');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a view with a form to create a new Accessory.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @return View
|
||||
*/
|
||||
public function getCreate(Request $request)
|
||||
{
|
||||
// Show the page
|
||||
$category_list = Helper::categoryList('accessory');
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate and save new Accessory from form post
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate(Request $request)
|
||||
{
|
||||
|
||||
// create a new model instance
|
||||
$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->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
|
||||
$accessory->order_number = e(Input::get('order_number'));
|
||||
|
||||
if (e(Input::get('purchase_date')) == '') {
|
||||
$accessory->purchase_date = null;
|
||||
} else {
|
||||
$accessory->purchase_date = e(Input::get('purchase_date'));
|
||||
}
|
||||
|
||||
if (e(Input::get('purchase_cost')) == '0.00') {
|
||||
$accessory->purchase_cost = null;
|
||||
} else {
|
||||
$accessory->purchase_cost = e(Input::get('purchase_cost'));
|
||||
}
|
||||
|
||||
$accessory->qty = e(Input::get('qty'));
|
||||
$accessory->user_id = Auth::user()->id;
|
||||
|
||||
// Was the accessory created?
|
||||
if ($accessory->save()) {
|
||||
// Redirect to the new accessory page
|
||||
return redirect()->to("admin/accessories")->with('success', trans('admin/accessories/message.create.success'));
|
||||
}
|
||||
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($accessory->getErrors());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return view for the Accessory update form, prepopulated with existing data
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $accessoryId
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit(Request $request, $accessoryId = null)
|
||||
{
|
||||
// Check if the accessory exists
|
||||
if (is_null($accessory = Accessory::find($accessoryId))) {
|
||||
// Redirect to the blogs management 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'));
|
||||
}
|
||||
|
||||
$category_list = Helper::categoryList('accessory');
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save edited Accessory from form post
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $accessoryId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit(Request $request, $accessoryId = null)
|
||||
{
|
||||
// Check if the blog post exists
|
||||
if (is_null($accessory = Accessory::find($accessoryId))) {
|
||||
// Redirect to the blogs management 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'));
|
||||
}
|
||||
|
||||
// Update the accessory data
|
||||
$accessory->name = e(Input::get('name'));
|
||||
|
||||
if (e(Input::get('location_id')) == '') {
|
||||
$accessory->location_id = null;
|
||||
} else {
|
||||
$accessory->location_id = e(Input::get('location_id'));
|
||||
}
|
||||
$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->order_number = e(Input::get('order_number'));
|
||||
|
||||
if (e(Input::get('purchase_date')) == '') {
|
||||
$accessory->purchase_date = null;
|
||||
} else {
|
||||
$accessory->purchase_date = e(Input::get('purchase_date'));
|
||||
}
|
||||
|
||||
if (e(Input::get('purchase_cost')) == '0.00') {
|
||||
$accessory->purchase_cost = null;
|
||||
} else {
|
||||
$accessory->purchase_cost = e(Input::get('purchase_cost'));
|
||||
}
|
||||
|
||||
$accessory->qty = e(Input::get('qty'));
|
||||
|
||||
// Was the accessory created?
|
||||
if ($accessory->save()) {
|
||||
// Redirect to the new accessory page
|
||||
return redirect()->to("admin/accessories")->with('success', trans('admin/accessories/message.update.success'));
|
||||
}
|
||||
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($accessory->getErrors());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the given accessory.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $accessoryId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getDelete(Request $request, $accessoryId)
|
||||
{
|
||||
// Check if the blog post exists
|
||||
if (is_null($accessory = Accessory::find($accessoryId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/accessories')->with('error', trans('admin/accessories/message.not_found'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($accessory)) {
|
||||
return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
|
||||
if ($accessory->hasUsers() > 0) {
|
||||
return redirect()->to('admin/accessories')->with('error', trans('admin/accessories/message.assoc_users', array('count'=> $accessory->hasUsers())));
|
||||
} else {
|
||||
$accessory->delete();
|
||||
|
||||
// Redirect to the locations management page
|
||||
return redirect()->to('admin/accessories')->with('success', trans('admin/accessories/message.delete.success'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a view that invokes the ajax table which contains
|
||||
* the content for the accessory detail view, which is generated in getDataView.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $accessoryId
|
||||
* @see AccessoriesController::getDataView() method that generates the JSON response
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getView(Request $request, $accessoryID = null)
|
||||
{
|
||||
$accessory = Accessory::find($accessoryID);
|
||||
|
||||
if (isset($accessory->id)) {
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($accessory)) {
|
||||
return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
|
||||
} else {
|
||||
return View::make('accessories/view', compact('accessory'));
|
||||
}
|
||||
} else {
|
||||
// Prepare the error message
|
||||
$error = trans('admin/accessories/message.does_not_exist', compact('id'));
|
||||
|
||||
// Redirect to the user management page
|
||||
return redirect()->route('accessories')->with('error', $error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the form to checkout an Accessory to a user.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $accessoryId
|
||||
* @return View
|
||||
*/
|
||||
public function getCheckout(Request $request, $accessoryId)
|
||||
{
|
||||
// Check if the accessory exists
|
||||
if (is_null($accessory = Accessory::find($accessoryId))) {
|
||||
// Redirect to the accessory management page with error
|
||||
return redirect()->to('accessories')->with('error', trans('admin/accessories/message.not_found'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($accessory)) {
|
||||
return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
// Get the dropdown of users and then pass it to the checkout view
|
||||
$users_list = Helper::usersList();
|
||||
|
||||
return View::make('accessories/checkout', compact('accessory'))->with('users_list', $users_list);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the Accessory checkout information.
|
||||
*
|
||||
* If Slack is enabled and/or asset acceptance is enabled, it will also
|
||||
* trigger a Slack message and send an email.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $accessoryId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCheckout(Request $request, $accessoryId)
|
||||
{
|
||||
// Check if the accessory exists
|
||||
if (is_null($accessory = Accessory::find($accessoryId))) {
|
||||
// Redirect to the accessory management page with error
|
||||
return redirect()->to('accessories')->with('error', trans('admin/accessories/message.user_not_found'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($accessory)) {
|
||||
return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
if (!$user = User::find(Input::get('assigned_to'))) {
|
||||
return redirect()->to('admin/accessories')->with('error', trans('admin/accessories/message.not_found'));
|
||||
}
|
||||
|
||||
// Update the accessory data
|
||||
$accessory->assigned_to = e(Input::get('assigned_to'));
|
||||
|
||||
$accessory->users()->attach($accessory->id, array(
|
||||
'accessory_id' => $accessory->id,
|
||||
'created_at' => Carbon::now(),
|
||||
'user_id' => Auth::user()->id,
|
||||
'assigned_to' => e(Input::get('assigned_to'))));
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->accessory_id = $accessory->id;
|
||||
$logaction->asset_id = 0;
|
||||
$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'));
|
||||
|
||||
|
||||
|
||||
$admin_user = Auth::user();
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
if ($settings->slack_endpoint) {
|
||||
|
||||
|
||||
$slack_settings = [
|
||||
'username' => $settings->botname,
|
||||
'channel' => $settings->slack_channel,
|
||||
'link_names' => true
|
||||
];
|
||||
|
||||
$client = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);
|
||||
|
||||
try {
|
||||
$client->attach([
|
||||
'color' => 'good',
|
||||
'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().'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
'value' => e($logaction->note)
|
||||
],
|
||||
]
|
||||
])->send('Accessory Checked Out');
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$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;
|
||||
$data['eula'] = $accessory->getEula();
|
||||
$data['first_name'] = $user->first_name;
|
||||
$data['item_name'] = $accessory->name;
|
||||
$data['checkout_date'] = $logaction->created_at;
|
||||
$data['item_tag'] = '';
|
||||
$data['expected_checkin'] = '';
|
||||
$data['note'] = $logaction->note;
|
||||
$data['require_acceptance'] = $accessory->requireAcceptance();
|
||||
|
||||
|
||||
if (($accessory->requireAcceptance()=='1') || ($accessory->getEula())) {
|
||||
|
||||
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');
|
||||
});
|
||||
}
|
||||
|
||||
// Redirect to the new accessory page
|
||||
return redirect()->to("admin/accessories")->with('success', trans('admin/accessories/message.checkout.success'));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check the accessory back into inventory
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $accessoryId
|
||||
* @return View
|
||||
**/
|
||||
public function getCheckin(Request $request, $accessoryUserId = null, $backto = null)
|
||||
{
|
||||
// Check if the accessory exists
|
||||
if (is_null($accessory_user = DB::table('accessories_users')->find($accessoryUserId))) {
|
||||
// Redirect to the accessory management page with error
|
||||
return redirect()->to('admin/accessories')->with('error', trans('admin/accessories/message.not_found'));
|
||||
}
|
||||
|
||||
$accessory = Accessory::find($accessory_user->accessory_id);
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($accessory)) {
|
||||
return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
|
||||
} else {
|
||||
return View::make('accessories/checkin', compact('accessory'))->with('backto', $backto);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check in the item so that it can be checked out again to someone else
|
||||
*
|
||||
* @uses Accessory::checkin_email() to determine if an email can and should be sent
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $accessoryId
|
||||
* @return Redirect
|
||||
**/
|
||||
public function postCheckin(Request $request, $accessoryUserId = null, $backto = null)
|
||||
{
|
||||
// Check if the accessory exists
|
||||
if (is_null($accessory_user = DB::table('accessories_users')->find($accessoryUserId))) {
|
||||
// Redirect to the accessory management page with error
|
||||
return redirect()->to('admin/accessories')->with('error', trans('admin/accessories/message.not_found'));
|
||||
}
|
||||
|
||||
|
||||
$accessory = Accessory::find($accessory_user->accessory_id);
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($accessory)) {
|
||||
return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->checkedout_to = e($accessory_user->assigned_to);
|
||||
$return_to = e($accessory_user->assigned_to);
|
||||
$admin_user = Auth::user();
|
||||
|
||||
|
||||
// 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) {
|
||||
|
||||
|
||||
$slack_settings = [
|
||||
'username' => e($settings->botname),
|
||||
'channel' => e($settings->slack_channel),
|
||||
'link_names' => true
|
||||
];
|
||||
|
||||
$client = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);
|
||||
|
||||
try {
|
||||
$client->attach([
|
||||
'color' => 'good',
|
||||
'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()).'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
'value' => e($logaction->note)
|
||||
],
|
||||
|
||||
]
|
||||
])->send('Accessory Checked In');
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$log = $logaction->logaction('checkin from');
|
||||
|
||||
if (!is_null($accessory_user->assigned_to)) {
|
||||
$user = User::find($accessory_user->assigned_to);
|
||||
}
|
||||
|
||||
$data['log_id'] = $logaction->id;
|
||||
$data['first_name'] = e($user->first_name);
|
||||
$data['item_name'] = e($accessory->name);
|
||||
$data['checkin_date'] = e($logaction->created_at);
|
||||
$data['item_tag'] = '';
|
||||
$data['note'] = e($logaction->note);
|
||||
|
||||
if (($accessory->checkin_email()=='1')) {
|
||||
|
||||
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');
|
||||
});
|
||||
}
|
||||
|
||||
if ($backto=='user') {
|
||||
return redirect()->to("admin/users/".$return_to.'/view')->with('success', trans('admin/accessories/message.checkin.success'));
|
||||
} else {
|
||||
return redirect()->to("admin/accessories/".$accessory->id."/view")->with('success', trans('admin/accessories/message.checkin.success'));
|
||||
}
|
||||
}
|
||||
|
||||
// Redirect to the accessory management page with error
|
||||
return redirect()->to("admin/accessories")->with('error', trans('admin/accessories/message.checkin.error'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the JSON response for accessories listing view.
|
||||
*
|
||||
* Example:
|
||||
* {
|
||||
* "actions": "(links to available actions)",
|
||||
* "category": "(link to category)",
|
||||
* "companyName": "My Company",
|
||||
* "location": "My Location",
|
||||
* "min_amt": 2,
|
||||
* "name": "(link to accessory),
|
||||
* "numRemaining": 6,
|
||||
* "order_number": null,
|
||||
* "purchase_cost": "0.00",
|
||||
* "purchase_date": null,
|
||||
* "qty": 7
|
||||
* },
|
||||
*
|
||||
* The names of the fields in the returns JSON correspond directly to the the
|
||||
* names of the fields in the bootstrap-tables in the view.
|
||||
*
|
||||
* For debugging, see at /api/accessories/list
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $accessoryId
|
||||
* @return string JSON containing accessories and their associated atrributes.
|
||||
**/
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
$accessories = Accessory::select('accessories.*')->with('category', 'company')
|
||||
->whereNull('accessories.deleted_at');
|
||||
|
||||
if (Input::has('search')) {
|
||||
$accessories = $accessories->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 = ['name','min_amt','order_number','purchase_date','purchase_cost','companyName','category'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? e(Input::get('sort')) : 'created_at';
|
||||
|
||||
switch ($sort) {
|
||||
case 'category':
|
||||
$accessories = $accessories->OrderCategory($order);
|
||||
break;
|
||||
case 'companyName':
|
||||
$accessories = $accessories->OrderCompany($order);
|
||||
break;
|
||||
default:
|
||||
$accessories = $accessories->orderBy($sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
$accessCount = $accessories->count();
|
||||
$accessories = $accessories->skip($offset)->take($limit)->get();
|
||||
|
||||
$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>';
|
||||
$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)
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total'=>$accessCount, 'rows'=>$rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates the JSON response for accessory detail view.
|
||||
*
|
||||
* Example:
|
||||
* <code>
|
||||
* {
|
||||
* "rows": [
|
||||
* {
|
||||
* "actions": "(link to available actions)",
|
||||
* "name": "(link to user)"
|
||||
* }
|
||||
* ],
|
||||
* "total": 1
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* The names of the fields in the returns JSON correspond directly to the the
|
||||
* names of the fields in the bootstrap-tables in the view.
|
||||
*
|
||||
* For debugging, see at /api/accessories/$accessoryID/view
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $accessoryId
|
||||
* @return string JSON containing accessories and their associated atrributes.
|
||||
**/
|
||||
public function getDataView(Request $request, $accessoryID)
|
||||
{
|
||||
$accessory = Accessory::find($accessoryID);
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($accessory)) {
|
||||
return ['total' => 0, 'rows' => []];
|
||||
}
|
||||
|
||||
$accessory_users = $accessory->users;
|
||||
$count = $accessory_users->count();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($accessory_users as $user) {
|
||||
$actions = '<a href="'.route('checkin/accessory', $user->pivot->id).'" class="btn btn-info btn-sm">Checkin</a>';
|
||||
|
||||
$rows[] = array(
|
||||
'name' =>(string) link_to('/admin/users/'.$user->id.'/view', e($user->fullName())),
|
||||
'actions' => $actions
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total'=>$count, 'rows'=>$rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -1,473 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\AssetMaintenance;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Company;
|
||||
use DB;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Log;
|
||||
use Mail;
|
||||
use Redirect;
|
||||
use Response;
|
||||
use Slack;
|
||||
use Str;
|
||||
use App\Models\Supplier;
|
||||
use TCPDF;
|
||||
use Validator;
|
||||
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
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v2.0
|
||||
*/
|
||||
class AssetMaintenancesController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Checks for permissions for this action.
|
||||
*
|
||||
* @todo This should be replaced with middleware and/or policies
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
private static function getInsufficientPermissionsRedirect()
|
||||
{
|
||||
return redirect()->route('asset_maintenances')
|
||||
->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the asset maintenances listing, which is generated in getDatatable.
|
||||
*
|
||||
* @todo This should be replaced with middleware and/or policies
|
||||
* @see AssetMaintenancesController::getDatatable() method that generates the JSON response
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
|
||||
return View::make('asset_maintenances/index');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates the JSON response for asset maintenances listing view.
|
||||
*
|
||||
* @see AssetMaintenancesController::getIndex() method that generates view
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
* @since [v1.8]
|
||||
* @return String JSON
|
||||
*/
|
||||
public function getDatatable()
|
||||
{
|
||||
$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 {
|
||||
$offset = 0;
|
||||
}
|
||||
|
||||
if (Input::has('limit')) {
|
||||
$limit = e(Input::get('limit'));
|
||||
} else {
|
||||
$limit = 50;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$allowed_columns = ['id','title','asset_maintenance_time','asset_maintenance_type','cost','start_date','completion_date','notes','user_id'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? e(Input::get('sort')) : 'created_at';
|
||||
|
||||
switch ($sort) {
|
||||
case 'user_id':
|
||||
$maintenances = $maintenances->OrderAdmin($order);
|
||||
break;
|
||||
default:
|
||||
$maintenances = $maintenances->orderBy($sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
$maintenancesCount = $maintenances->count();
|
||||
$maintenances = $maintenances->skip($offset)->take($limit)->get();
|
||||
|
||||
$rows = array();
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
foreach ($maintenances as $maintenance) {
|
||||
|
||||
$actions = '<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!='')) {
|
||||
$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()) ,
|
||||
'title' => $maintenance->title,
|
||||
'notes' => $maintenance->notes,
|
||||
'supplier' => $maintenance->supplier->name,
|
||||
'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
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $maintenancesCount, 'rows' => $rows);
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a form view to create a new asset maintenance.
|
||||
*
|
||||
* @see AssetMaintenancesController::postCreate() method that stores the data
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
* @since [v1.8]
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCreate($assetId = null)
|
||||
{
|
||||
// Prepare Asset Maintenance Type List
|
||||
$assetMaintenanceType = [
|
||||
'' => 'Select an asset maintenance type',
|
||||
] + AssetMaintenance::getImprovementOptions();
|
||||
// Mark the selected asset, if it came in
|
||||
$selectedAsset = $assetId;
|
||||
|
||||
$assets = Helper::detailedAssetList();
|
||||
|
||||
$supplier_list = Helper::suppliersList();
|
||||
|
||||
// Render the view
|
||||
return View::make('asset_maintenances/edit')
|
||||
->with('asset_list', $assets)
|
||||
->with('selectedAsset', $selectedAsset)
|
||||
->with('supplier_list', $supplier_list)
|
||||
->with('assetMaintenanceType', $assetMaintenanceType)
|
||||
->with('assetMaintenance', new AssetMaintenance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and stores the new asset maintenance
|
||||
*
|
||||
* @see AssetMaintenancesController::getCreate() method for the form
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
* @since [v1.8]
|
||||
* @return mixed
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// create a new model instance
|
||||
$assetMaintenance = new AssetMaintenance();
|
||||
|
||||
|
||||
if (e(Input::get('supplier_id')) == '') {
|
||||
$assetMaintenance->supplier_id = null;
|
||||
} else {
|
||||
$assetMaintenance->supplier_id = e(Input::get('supplier_id'));
|
||||
}
|
||||
|
||||
if (e(Input::get('is_warranty')) == '') {
|
||||
$assetMaintenance->is_warranty = 0;
|
||||
} else {
|
||||
$assetMaintenance->is_warranty = e(Input::get('is_warranty'));
|
||||
}
|
||||
|
||||
if (e(Input::get('cost')) == '') {
|
||||
$assetMaintenance->cost = '';
|
||||
} else {
|
||||
$assetMaintenance->cost = e(Input::get('cost'));
|
||||
}
|
||||
|
||||
if (e(Input::get('notes')) == '') {
|
||||
$assetMaintenance->notes = null;
|
||||
} else {
|
||||
$assetMaintenance->notes = e(Input::get('notes'));
|
||||
}
|
||||
|
||||
$asset = Asset::find(e(Input::get('asset_id')));
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($asset)) {
|
||||
return static::getInsufficientPermissionsRedirect();
|
||||
}
|
||||
|
||||
// Save the asset maintenance data
|
||||
$assetMaintenance->asset_id = e(Input::get('asset_id'));
|
||||
$assetMaintenance->asset_maintenance_type = e(Input::get('asset_maintenance_type'));
|
||||
$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" )
|
||||
) {
|
||||
$assetMaintenance->completion_date = null;
|
||||
}
|
||||
|
||||
if (( $assetMaintenance->completion_date !== "" )
|
||||
&& ( $assetMaintenance->completion_date !== "0000-00-00" )
|
||||
&& ( $assetMaintenance->start_date !== "" )
|
||||
&& ( $assetMaintenance->start_date !== "0000-00-00" )
|
||||
) {
|
||||
$startDate = Carbon::parse($assetMaintenance->start_date);
|
||||
$completionDate = Carbon::parse($assetMaintenance->completion_date);
|
||||
$assetMaintenance->asset_maintenance_time = $completionDate->diffInDays($startDate);
|
||||
}
|
||||
|
||||
// Was the asset maintenance created?
|
||||
if ($assetMaintenance->save()) {
|
||||
|
||||
// Redirect to the new asset maintenance page
|
||||
return redirect()->to("admin/asset_maintenances")
|
||||
->with('success', trans('admin/asset_maintenances/message.create.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($assetMaintenance->getErrors());
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a form view to edit a selected asset maintenance.
|
||||
*
|
||||
* @see AssetMaintenancesController::postEdit() method that stores the data
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @param int $assetMaintenanceId
|
||||
* @version v1.0
|
||||
* @since [v1.8]
|
||||
* @return mixed
|
||||
*/
|
||||
public function getEdit($assetMaintenanceId = null)
|
||||
{
|
||||
// Check if the asset maintenance exists
|
||||
if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
|
||||
// Redirect to the improvement management page
|
||||
return redirect()->to('admin/asset_maintenances')
|
||||
->with('error', trans('admin/asset_maintenances/message.not_found'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
|
||||
return static::getInsufficientPermissionsRedirect();
|
||||
}
|
||||
|
||||
if ($assetMaintenance->completion_date == '0000-00-00') {
|
||||
$assetMaintenance->completion_date = null;
|
||||
}
|
||||
|
||||
if ($assetMaintenance->start_date == '0000-00-00') {
|
||||
$assetMaintenance->start_date = null;
|
||||
}
|
||||
|
||||
if ($assetMaintenance->cost == '0.00') {
|
||||
$assetMaintenance->cost = null;
|
||||
}
|
||||
|
||||
// Prepare Improvement Type List
|
||||
$assetMaintenanceType = [
|
||||
'' => 'Select an improvement type',
|
||||
] + AssetMaintenance::getImprovementOptions();
|
||||
|
||||
$assets = Company::scopeCompanyables(Asset::all(), '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', $assets)
|
||||
->with('selectedAsset', null)
|
||||
->with('supplier_list', $supplier_list)
|
||||
->with('assetMaintenanceType', $assetMaintenanceType)
|
||||
->with('assetMaintenance', $assetMaintenance);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and stores an update to an asset maintenance
|
||||
*
|
||||
* @see AssetMaintenancesController::postEdit() method that stores the data
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @param int $assetMaintenanceId
|
||||
* @version v1.0
|
||||
* @since [v1.8]
|
||||
* @return mixed
|
||||
*/
|
||||
public function postEdit($assetMaintenanceId = null)
|
||||
{
|
||||
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// Check if the asset maintenance exists
|
||||
if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
|
||||
// Redirect to the asset maintenance management page
|
||||
return redirect()->to('admin/asset_maintenances')
|
||||
->with('error', trans('admin/asset_maintenances/message.not_found'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
|
||||
return static::getInsufficientPermissionsRedirect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (e(Input::get('supplier_id')) == '') {
|
||||
$assetMaintenance->supplier_id = null;
|
||||
} else {
|
||||
$assetMaintenance->supplier_id = e(Input::get('supplier_id'));
|
||||
}
|
||||
|
||||
if (e(Input::get('is_warranty')) == '') {
|
||||
$assetMaintenance->is_warranty = 0;
|
||||
} else {
|
||||
$assetMaintenance->is_warranty = e(Input::get('is_warranty'));
|
||||
}
|
||||
|
||||
if (e(Input::get('cost')) == '') {
|
||||
$assetMaintenance->cost = '';
|
||||
} else {
|
||||
$assetMaintenance->cost = e(Input::get('cost'));
|
||||
}
|
||||
|
||||
if (e(Input::get('notes')) == '') {
|
||||
$assetMaintenance->notes = null;
|
||||
} else {
|
||||
$assetMaintenance->notes = e(Input::get('notes'));
|
||||
}
|
||||
|
||||
$asset = Asset::find(e(Input::get('asset_id')));
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($asset)) {
|
||||
return static::getInsufficientPermissionsRedirect();
|
||||
}
|
||||
|
||||
// Save the asset maintenance data
|
||||
$assetMaintenance->asset_id = e(Input::get('asset_id'));
|
||||
$assetMaintenance->asset_maintenance_type = e(Input::get('asset_maintenance_type'));
|
||||
$assetMaintenance->title = e(Input::get('title'));
|
||||
$assetMaintenance->start_date = e(Input::get('start_date'));
|
||||
$assetMaintenance->completion_date = e(Input::get('completion_date'));
|
||||
|
||||
if (( $assetMaintenance->completion_date == "" )
|
||||
|| ( $assetMaintenance->completion_date == "0000-00-00" )
|
||||
) {
|
||||
$assetMaintenance->completion_date = null;
|
||||
if (( $assetMaintenance->asset_maintenance_time !== 0 )
|
||||
|| ( !is_null($assetMaintenance->asset_maintenance_time) )
|
||||
) {
|
||||
$assetMaintenance->asset_maintenance_time = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (( $assetMaintenance->completion_date !== "" )
|
||||
&& ( $assetMaintenance->completion_date !== "0000-00-00" )
|
||||
&& ( $assetMaintenance->start_date !== "" )
|
||||
&& ( $assetMaintenance->start_date !== "0000-00-00" )
|
||||
) {
|
||||
$startDate = Carbon::parse($assetMaintenance->start_date);
|
||||
$completionDate = Carbon::parse($assetMaintenance->completion_date);
|
||||
$assetMaintenance->asset_maintenance_time = $completionDate->diffInDays($startDate);
|
||||
}
|
||||
|
||||
// Was the asset maintenance created?
|
||||
if ($assetMaintenance->save()) {
|
||||
|
||||
// Redirect to the new asset maintenance page
|
||||
return redirect()->to("admin/asset_maintenances")
|
||||
->with('success', trans('admin/asset_maintenances/message.create.success'));
|
||||
}
|
||||
return redirect()->back() ->withInput()->withErrors($assetMaintenance->getErrors());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an asset maintenance
|
||||
*
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @param int $assetMaintenanceId
|
||||
* @version v1.0
|
||||
* @since [v1.8]
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDelete($assetMaintenanceId)
|
||||
{
|
||||
// Check if the asset maintenance exists
|
||||
if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
|
||||
// Redirect to the asset maintenance management page
|
||||
return redirect()->to('admin/asset_maintenances')
|
||||
->with('error', trans('admin/asset_maintenances/message.not_found'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
|
||||
return static::getInsufficientPermissionsRedirect();
|
||||
}
|
||||
|
||||
// Delete the asset maintenance
|
||||
$assetMaintenance->delete();
|
||||
|
||||
// Redirect to the asset_maintenance management page
|
||||
return redirect()->to('admin/asset_maintenances')
|
||||
->with('success', trans('admin/asset_maintenances/message.delete.success'));
|
||||
}
|
||||
|
||||
/**
|
||||
* View an asset maintenance
|
||||
*
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @param int $assetMaintenanceId
|
||||
* @version v1.0
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function getView($assetMaintenanceId)
|
||||
{
|
||||
// Check if the asset maintenance exists
|
||||
if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
|
||||
// Redirect to the asset maintenance management page
|
||||
return redirect()->to('admin/asset_maintenances')
|
||||
->with('error', trans('admin/asset_maintenances/message.not_found'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
|
||||
return static::getInsufficientPermissionsRedirect();
|
||||
}
|
||||
|
||||
return View::make('asset_maintenances/view')->with('assetMaintenance', $assetMaintenance);
|
||||
}
|
||||
}
|
||||
@@ -1,550 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Image;
|
||||
use Input;
|
||||
use Lang;
|
||||
use App\Models\AssetModel;
|
||||
use Redirect;
|
||||
use App\Models\Setting;
|
||||
use Auth;
|
||||
use DB;
|
||||
use App\Models\Depreciation;
|
||||
use App\Models\Manufacturer;
|
||||
use Str;
|
||||
use Validator;
|
||||
use View;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Company;
|
||||
use Config;
|
||||
use App\Helpers\Helper;
|
||||
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
/**
|
||||
* This class controls all actions related to asset models for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
*/
|
||||
class AssetModelsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the accessories listing, which is generated in getDatatable.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see AssetModelsController::getDatatable() method that generates the JSON response
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
// Show the page
|
||||
return View::make('models/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view containing the asset model creation form.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getCreate()
|
||||
{
|
||||
// Show the page
|
||||
$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)
|
||||
->with('manufacturer_list', $manufacturer_list)
|
||||
->with('model', new AssetModel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate and process the new Asset Model data.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
|
||||
// Create a new asset model
|
||||
$model = new AssetModel;
|
||||
|
||||
|
||||
if (e(Input::get('depreciation_id')) == '') {
|
||||
$model->depreciation_id = 0;
|
||||
} else {
|
||||
$model->depreciation_id = e(Input::get('depreciation_id'));
|
||||
}
|
||||
|
||||
if (e(Input::get('eol')) == '') {
|
||||
$model->eol = 0;
|
||||
} else {
|
||||
$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;
|
||||
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(500, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save($path);
|
||||
$model->image = $file_name;
|
||||
}
|
||||
|
||||
// Was it created?
|
||||
if ($model->save()) {
|
||||
// Redirect to the new model page
|
||||
return redirect()->to("hardware/models")->with('success', trans('admin/models/message.create.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($model->getErrors());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and stores new Asset Model data created from the
|
||||
* modal form on the Asset Creation view.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v2.0]
|
||||
* @return String JSON
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
//COPYPASTA!!!! FIXME
|
||||
$model = new AssetModel;
|
||||
|
||||
$settings=Input::all();
|
||||
$settings['eol']=0;
|
||||
|
||||
$model->name=e(Input::get('name'));
|
||||
$model->manufacturer_id = e(Input::get('manufacturer_id'));
|
||||
$model->category_id = e(Input::get('category_id'));
|
||||
$model->modelno = e(Input::get('modelno'));
|
||||
$model->user_id = Auth::user()->id;
|
||||
$model->note = e(Input::get('note'));
|
||||
$model->eol=0;
|
||||
|
||||
if (Input::get('fieldset_id')=='') {
|
||||
$model->fieldset_id = null;
|
||||
} else {
|
||||
$model->fieldset_id = e(Input::get('fieldset_id'));
|
||||
}
|
||||
|
||||
if ($model->save()) {
|
||||
return JsonResponse::create($model);
|
||||
} else {
|
||||
return JsonResponse::create(["error" => "Failed validation: ".print_r($model->getErrors()->all('<li>:message</li>'), true)], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a view containing the asset model edit form.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $modelId
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit($modelId = null)
|
||||
{
|
||||
// Check if the model exists
|
||||
if (is_null($model = AssetModel::find($modelId))) {
|
||||
// Redirect to the model management page
|
||||
return redirect()->to('assets/models')->with('error', trans('admin/models/message.does_not_exist'));
|
||||
}
|
||||
|
||||
$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);
|
||||
$view->with('manufacturer_list', $manufacturer_list);
|
||||
return $view;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates and processes form data from the edit
|
||||
* Asset Model form based on the model ID passed.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $modelId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit($modelId = null)
|
||||
{
|
||||
// Check if the model exists
|
||||
if (is_null($model = AssetModel::find($modelId))) {
|
||||
// Redirect to the models management page
|
||||
return redirect()->to('admin/models')->with('error', trans('admin/models/message.does_not_exist'));
|
||||
}
|
||||
|
||||
|
||||
if (e(Input::get('depreciation_id')) == '') {
|
||||
$model->depreciation_id = 0;
|
||||
} else {
|
||||
$model->depreciation_id = e(Input::get('depreciation_id'));
|
||||
}
|
||||
|
||||
if (e(Input::get('eol')) == '') {
|
||||
$model->eol = 0;
|
||||
} else {
|
||||
$model->eol = e(Input::get('eol'));
|
||||
}
|
||||
|
||||
// Update 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'));
|
||||
if (Input::get('custom_fieldset')=='') {
|
||||
$model->fieldset_id = null;
|
||||
} else {
|
||||
$model->fieldset_id = e(Input::get('custom_fieldset'));
|
||||
}
|
||||
|
||||
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);
|
||||
$model->image = $file_name;
|
||||
}
|
||||
|
||||
if (Input::get('image_delete') == 1 && Input::file('image') == "") {
|
||||
$model->image = null;
|
||||
}
|
||||
|
||||
// Was it created?
|
||||
if ($model->save()) {
|
||||
// Redirect to the new model page
|
||||
return redirect()->to("hardware/models")->with('success', trans('admin/models/message.update.success'));
|
||||
} else {
|
||||
return redirect()->back()->withInput()->withErrors($model->getErrors());
|
||||
}
|
||||
|
||||
|
||||
// Redirect to the model create page
|
||||
return redirect()->to("hardware/models/$modelId/edit")->with('error', trans('admin/models/message.update.error'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and delete the given Asset Model. An Asset Model
|
||||
* cannot be deleted if there are associated assets.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $modelId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getDelete($modelId)
|
||||
{
|
||||
// Check if the model exists
|
||||
if (is_null($model = AssetModel::find($modelId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('hardware/models')->with('error', trans('admin/models/message.not_found'));
|
||||
}
|
||||
|
||||
if ($model->assets->count() > 0) {
|
||||
// Throw an error that this model is associated with assets
|
||||
return redirect()->to('hardware/models')->with('error', trans('admin/models/message.assoc_users'));
|
||||
|
||||
} else {
|
||||
// Delete the model
|
||||
$model->delete();
|
||||
|
||||
// Redirect to the models management page
|
||||
return redirect()->to('hardware/models')->with('success', trans('admin/models/message.delete.success'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restore a given Asset Model (mark as un-deleted)
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $modelId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getRestore($modelId = null)
|
||||
{
|
||||
|
||||
// Get user information
|
||||
$model = AssetModel::withTrashed()->find($modelId);
|
||||
|
||||
if (isset($model->id)) {
|
||||
|
||||
// Restore the model
|
||||
$model->restore();
|
||||
|
||||
// Prepare the success message
|
||||
$success = trans('admin/models/message.restore.success');
|
||||
|
||||
// Redirect back
|
||||
return redirect()->back()->with('success', $success);
|
||||
|
||||
} else {
|
||||
return redirect()->back()->with('error', trans('admin/models/message.not_found'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the model information to present to the model view page
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $modelId
|
||||
* @return View
|
||||
*/
|
||||
public function getView($modelId = null)
|
||||
{
|
||||
$model = AssetModel::withTrashed()->find($modelId);
|
||||
|
||||
if (isset($model->id)) {
|
||||
return View::make('models/view', compact('model'));
|
||||
} else {
|
||||
// Prepare the error message
|
||||
$error = trans('admin/models/message.does_not_exist', compact('id'));
|
||||
|
||||
// Redirect to the user management page
|
||||
return redirect()->route('models')->with('error', $error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the clone page to clone a model
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $modelId
|
||||
* @return View
|
||||
*/
|
||||
public function getClone($modelId = null)
|
||||
{
|
||||
// Check if the model exists
|
||||
if (is_null($model_to_clone = AssetModel::find($modelId))) {
|
||||
// Redirect to the model management page
|
||||
return redirect()->to('assets/models')->with('error', trans('admin/models/message.does_not_exist'));
|
||||
}
|
||||
|
||||
$model = clone $model_to_clone;
|
||||
$model->id = null;
|
||||
|
||||
// Show the page
|
||||
$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);
|
||||
$view->with('manufacturer_list', $manufacturer_list);
|
||||
$view->with('model', $model);
|
||||
$view->with('clone_model', $model_to_clone);
|
||||
return $view;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the custom fields form
|
||||
*
|
||||
* @author [B. Wetherington] [<uberbrady@gmail.com>]
|
||||
* @since [v2.0]
|
||||
* @param int $modelId
|
||||
* @return View
|
||||
*/
|
||||
public function getCustomFields($modelId)
|
||||
{
|
||||
$model=AssetModel::find($modelId);
|
||||
return View::make("models.custom_fields_form")->with("model", $model);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the JSON response to populate the data tables on the
|
||||
* Asset Model listing page.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v2.0]
|
||||
* @param string $status
|
||||
* @return String JSON
|
||||
*/
|
||||
|
||||
public function getDatatable($status = null)
|
||||
{
|
||||
$models = AssetModel::with('category', 'assets', 'depreciation');
|
||||
|
||||
switch ($status) {
|
||||
case 'Deleted':
|
||||
$models->withTrashed()->Deleted();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (Input::has('search')) {
|
||||
$models = $models->TextSearch(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 = ['id','name','modelno'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? e(Input::get('sort')) : 'created_at';
|
||||
|
||||
$models = $models->orderBy($sort, $order);
|
||||
|
||||
$modelCount = $models->count();
|
||||
$models = $models->skip($offset)->take($limit)->get();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($models as $model) {
|
||||
if ($model->deleted_at == '') {
|
||||
$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>';
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $model->id,
|
||||
'manufacturer' => (string)link_to('/admin/settings/manufacturers/'.$model->manufacturer->id.'/view', $model->manufacturer->name),
|
||||
'name' => (string)link_to('/hardware/models/'.$model->id.'/view', $model->name),
|
||||
'image' => ($model->image!='') ? '<img src="'.config('app.url').'/uploads/models/'.$model->image.'" height=50 width=50>' : '',
|
||||
'modelnumber' => $model->modelno,
|
||||
'numassets' => $model->assets->count(),
|
||||
'depreciation' => (($model->depreciation)&&($model->depreciation->id > 0)) ? $model->depreciation->name.' ('.$model->depreciation->months.')' : trans('general.no_depreciation'),
|
||||
'category' => ($model->category) ? $model->category->name : '',
|
||||
'eol' => ($model->eol) ? $model->eol.' '.trans('general.months') : '',
|
||||
'note' => $model->getNote(),
|
||||
'actions' => $actions
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $modelCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the asset information to present to the model view detail page
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v2.0]
|
||||
* @param int $modelId
|
||||
* @return String JSON
|
||||
*/
|
||||
public function getDataView($modelID)
|
||||
{
|
||||
$assets = Asset::where('model_id', '=', $modelID)->with('company');
|
||||
|
||||
if (Input::has('search')) {
|
||||
$assets = $assets->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 = ['name', 'serial','asset_tag'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? e(Input::get('sort')) : 'created_at';
|
||||
|
||||
$assets = $assets->orderBy($sort, $order);
|
||||
|
||||
$assetsCount = $assets->count();
|
||||
$assets = $assets->skip($offset)->take($limit)->get();
|
||||
|
||||
$rows = array();
|
||||
|
||||
|
||||
foreach ($assets as $asset) {
|
||||
$actions = '';
|
||||
|
||||
if ($asset->assetstatus) {
|
||||
if ($asset->assetstatus->deployable != 0) {
|
||||
if (($asset->assigned_to !='') && ($asset->assigned_to > 0)) {
|
||||
$actions = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.trans('general.checkin').'</a>';
|
||||
} else {
|
||||
$actions = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.trans('general.checkout').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $asset->id,
|
||||
'name' => (string)link_to('/hardware/'.$asset->id.'/view', $asset->showAssetName()),
|
||||
'asset_tag' => (string)link_to('hardware/'.$asset->id.'/view', $asset->asset_tag),
|
||||
'serial' => $asset->serial,
|
||||
'assigned_to' => ($asset->assigned_to) ? (string)link_to('/admin/users/'.$asset->assigned_to.'/view', $asset->assigneduser->fullName()) : '',
|
||||
'actions' => $actions,
|
||||
'companyName' => Company::getName($asset)
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $assetsCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,198 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
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;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Log;
|
||||
use View;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This controller handles authentication for the user, including local
|
||||
* database users and LDAP users.
|
||||
*
|
||||
* @todo Move LDAP methods into user model for better separation of concerns.
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @version v1.0
|
||||
*/
|
||||
class AuthController extends Controller
|
||||
{
|
||||
|
||||
use ThrottlesLogins;
|
||||
|
||||
// This tells the auth controller to use username instead of email address
|
||||
protected $username = 'username';
|
||||
|
||||
/**
|
||||
* Where to redirect users after login / registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Create a new authentication controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest', ['except' => 'logout']);
|
||||
}
|
||||
|
||||
|
||||
function showLoginForm()
|
||||
{
|
||||
// Is the user logged in?
|
||||
if (Auth::check()) {
|
||||
return redirect()->intended('dashboard');
|
||||
}
|
||||
|
||||
// Show the page
|
||||
return View::make('auth.login');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Account sign in form processing.
|
||||
*
|
||||
* @return Redirect
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
$validator = $this->validator(Input::all());
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withInput()->withErrors($validator);
|
||||
}
|
||||
|
||||
// Should we even check for LDAP users?
|
||||
if (Setting::getSettings()->ldap_enabled=='1') {
|
||||
|
||||
LOG::debug("LDAP is enabled.");
|
||||
// Check if the user exists in the database
|
||||
$user = User::where('username', '=', Input::get('username'))->whereNull('deleted_at')->first();
|
||||
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
|
||||
if (!$user) {
|
||||
LOG::debug("Local user ".Input::get('username')." does not exist");
|
||||
|
||||
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
|
||||
} else {
|
||||
|
||||
LOG::debug("Local user ".Input::get('username')." exists in database. Authenticating existing user against LDAP.");
|
||||
|
||||
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->password = bcrypt($request->input('password'));
|
||||
$user->email = $ldap_attr['email'];
|
||||
$user->first_name = $ldap_attr['firstname'];
|
||||
$user->last_name = $ldap_attr['lastname'];
|
||||
$user->save();
|
||||
|
||||
} else {
|
||||
LOG::debug("User ".Input::get('username')." did not authenticate correctly against LDAP. Local user was not updated.");
|
||||
}// End LDAP auth
|
||||
|
||||
} // End if(!user)
|
||||
|
||||
// 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();
|
||||
return redirect()->back()->withInput()->with('error', trans('auth/message.account_not_found'));
|
||||
}
|
||||
|
||||
// Get the page we were before
|
||||
$redirect = \Session::get('loginRedirect', 'home');
|
||||
|
||||
// Unset the page we were before from the session
|
||||
\Session::forget('loginRedirect');
|
||||
|
||||
// Redirect to the users page
|
||||
return redirect()->to($redirect)->with('success', trans('auth/message.signin.success'));
|
||||
|
||||
// Ooops.. something went wrong
|
||||
return redirect()->back()->withInput()->withErrors($this->messageBag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout page.
|
||||
*
|
||||
* @return Redirect
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
// Log the user out
|
||||
Auth::logout();
|
||||
|
||||
// Redirect to the users page
|
||||
return redirect()->route('home')->with('success', 'You have successfully logged out!');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'username' => 'required',
|
||||
'password' => 'required',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
/**
|
||||
* This controller handles password resets for the user.
|
||||
* It uses the built-in Laravel magic of ResetsPasswords, so we
|
||||
* don't actually do much here.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @version v1.0
|
||||
*/
|
||||
class PasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Create a new password controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
@@ -1,532 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Category as Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\Setting;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Redirect;
|
||||
use Str;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* This class controls all actions related to Categories for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
*/
|
||||
class CategoriesController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the categories listing, which is generated in getDatatable.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see CategoriesController::getDatatable() method that generates the JSON response
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
// Show the page
|
||||
return View::make('categories/index');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a form view to create a new category.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see CategoriesController::postCreate() method that stores the data
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getCreate()
|
||||
{
|
||||
// Show the page
|
||||
$category_types= Helper::categoryTypeList();
|
||||
return View::make('categories/edit')->with('category', new Category)
|
||||
->with('category_types', $category_types);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates and stores the new category data.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see CategoriesController::getCreate() method that makes the form.
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
|
||||
// create a new model instance
|
||||
$category = new Category();
|
||||
|
||||
// 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->user_id = Auth::user()->id;
|
||||
|
||||
if ($category->save()) {
|
||||
// Redirect to the new category page
|
||||
return redirect()->to("admin/settings/categories")->with('success', trans('admin/categories/message.create.success'));
|
||||
} else {
|
||||
|
||||
// The given data did not pass validation
|
||||
return redirect()->back()->withInput()->withErrors($category->getErrors());
|
||||
|
||||
}
|
||||
|
||||
// Redirect to the category create page
|
||||
return redirect()->to('admin/settings/categories/create')->with('error', trans('admin/categories/message.create.error'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view that makes a form to update a category.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see CategoriesController::postEdit() method saves the data
|
||||
* @param int $categoryId
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit($categoryId = null)
|
||||
{
|
||||
// Check if the category exists
|
||||
if (is_null($category = Category::find($categoryId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/settings/categories')->with('error', trans('admin/categories/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Show the page
|
||||
//$category_options = array('' => 'Top Level') + Category::lists('name', 'id');
|
||||
|
||||
$category_options = array('' => 'Top Level') + DB::table('categories')->where('id', '!=', $categoryId)->lists('name', 'id');
|
||||
$category_types= Helper::categoryTypeList();
|
||||
|
||||
return View::make('categories/edit', compact('category'))
|
||||
->with('category_options', $category_options)
|
||||
->with('category_types', $category_types);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates and stores the updated category data.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see CategoriesController::getEdit() method that makes the form.
|
||||
* @param int $categoryId
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit($categoryId = null)
|
||||
{
|
||||
// Check if the blog post exists
|
||||
if (is_null($category = Category::find($categoryId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/categories')->with('error', trans('admin/categories/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// 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'));
|
||||
|
||||
if ($category->save()) {
|
||||
// Redirect to the new category page
|
||||
return redirect()->to("admin/settings/categories")->with('success', trans('admin/categories/message.update.success'));
|
||||
} // attempt validation
|
||||
else {
|
||||
// The given data did not pass validation
|
||||
return redirect()->back()->withInput()->withErrors($category->getErrors());
|
||||
}
|
||||
|
||||
// Redirect to the category management page
|
||||
return redirect()->back()->with('error', trans('admin/categories/message.update.error'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and marks a category as deleted.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $categoryId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getDelete($categoryId)
|
||||
{
|
||||
// Check if the category exists
|
||||
if (is_null($category = Category::find($categoryId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/settings/categories')->with('error', trans('admin/categories/message.not_found'));
|
||||
}
|
||||
|
||||
|
||||
if ($category->has_models() > 0) {
|
||||
return redirect()->to('admin/settings/categories')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'model']));
|
||||
|
||||
} elseif ($category->accessories()->count() > 0) {
|
||||
return redirect()->to('admin/settings/categories')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'accessory']));
|
||||
|
||||
} elseif ($category->consumables()->count() > 0) {
|
||||
return redirect()->to('admin/settings/categories')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'consumable']));
|
||||
|
||||
} elseif ($category->components()->count() > 0) {
|
||||
return redirect()->to('admin/settings/categories')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'component']));
|
||||
} else {
|
||||
|
||||
$category->delete();
|
||||
|
||||
// Redirect to the locations management page
|
||||
return redirect()->to('admin/settings/categories')->with('success', trans('admin/categories/message.delete.success'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the categories detail view, which is generated in getDataView.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see CategoriesController::getDataView() method that generates the JSON response
|
||||
* @param int $categoryId
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function getView($categoryId = null)
|
||||
{
|
||||
$category = Category::find($categoryId);
|
||||
|
||||
if (isset($category->id)) {
|
||||
return View::make('categories/view', compact('category'));
|
||||
} else {
|
||||
// Prepare the error message
|
||||
$error = trans('admin/categories/message.does_not_exist', compact('id'));
|
||||
|
||||
// Redirect to the user management page
|
||||
return redirect()->route('categories')->with('error', $error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JSON response with the data to populate the bootstrap table on the
|
||||
* cateory listing page.
|
||||
*
|
||||
* @todo Refactor this nastiness. Assets do not behave the same as accessories, etc.
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see CategoriesController::getIndex() method that generates the view
|
||||
* @since [v1.8]
|
||||
* @return String JSON
|
||||
*/
|
||||
public function getDatatable()
|
||||
{
|
||||
// Grab all the categories
|
||||
$categories = Category::with('assets', 'accessories', 'consumables', 'components');
|
||||
|
||||
if (Input::has('search')) {
|
||||
$categories = $categories->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 = ['id','name','category_type'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? e(Input::get('sort')) : 'created_at';
|
||||
|
||||
$categories = $categories->orderBy($sort, $order);
|
||||
|
||||
$catCount = $categories->count();
|
||||
$categories = $categories->skip($offset)->take($limit)->get();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($categories as $category) {
|
||||
|
||||
$actions = '<a href="'.route('update/category', $category->id).'" class="btn btn-warning btn-sm" style="margin-right:5px;">';
|
||||
$actions .='<i class="fa fa-pencil icon-white"></i></a>';
|
||||
$actions .='<a data-html="false" class="btn delete-asset btn-danger btn-sm';
|
||||
if ($category->itemCount() > 0) {
|
||||
$actions .=' disabled';
|
||||
}
|
||||
$actions .=' data-toggle="modal" href="'.route('delete/category', $category->id).'" data-content="'.trans('admin/categories/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($category->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
|
||||
$rows[] = array(
|
||||
'id' => $category->id,
|
||||
'name' => (string)link_to('/admin/settings/categories/'.$category->id.'/view', $category->name) ,
|
||||
'category_type' => ucwords($category->category_type),
|
||||
'count' => $category->itemCount(),
|
||||
'acceptance' => ($category->require_acceptance=='1') ? '<i class="fa fa-check"></i>' : '',
|
||||
//EULA is still not working correctly
|
||||
'eula' => ($category->getEula()) ? '<i class="fa fa-check"></i>' : '',
|
||||
'actions' => $actions
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $catCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getDataViewAssets($categoryID)
|
||||
{
|
||||
|
||||
$category = Category::with('assets.company')->find($categoryID);
|
||||
$category_assets = $category->assets();
|
||||
|
||||
if (Input::has('search')) {
|
||||
$category_assets = $category_assets->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;
|
||||
}
|
||||
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
$allowed_columns = ['id','name','serial','asset_tag'];
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
|
||||
$count = $category_assets->count();
|
||||
$category_assets = $category_assets->skip($offset)->take($limit)->get();
|
||||
$rows = array();
|
||||
|
||||
foreach ($category_assets as $asset) {
|
||||
|
||||
$actions = '';
|
||||
$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="'.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">'.trans('general.checkin').'</a>';
|
||||
} else {
|
||||
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.trans('general.checkout').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $asset->id,
|
||||
'name' => (string)link_to('/hardware/'.$asset->id.'/view', $asset->showAssetName()),
|
||||
'model' => $asset->model->name,
|
||||
'asset_tag' => $asset->asset_tag,
|
||||
'serial' => $asset->serial,
|
||||
'assigned_to' => ($asset->assigneduser) ? (string)link_to('/admin/users/'.$asset->assigneduser->id.'/view', $asset->assigneduser->fullName()): '',
|
||||
'change' => $inout,
|
||||
'actions' => $actions,
|
||||
'companyName' => Company::getName($asset),
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $count, 'rows' => $rows);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getDataViewAccessories($categoryID)
|
||||
{
|
||||
|
||||
$category = Category::with('accessories.company')->find($categoryID);
|
||||
$category_assets = $category->accessories;
|
||||
|
||||
if (Input::has('search')) {
|
||||
$category_assets = $category_assets->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;
|
||||
}
|
||||
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
$allowed_columns = ['id','name','serial','asset_tag'];
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
|
||||
$count = $category_assets->count();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($category_assets as $asset) {
|
||||
|
||||
$actions = '';
|
||||
$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="'.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>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $asset->id,
|
||||
'name' => (string)link_to_route('view/accessory', $asset->name, [$asset->id]),
|
||||
'actions' => $actions,
|
||||
'companyName' => Company::getName($asset),
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $count, 'rows' => $rows);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function getDataViewConsumables($categoryID)
|
||||
{
|
||||
|
||||
$category = Category::with('accessories.company')->find($categoryID);
|
||||
$category_assets = $category->consumables;
|
||||
|
||||
if (Input::has('search')) {
|
||||
$category_assets = $category_assets->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;
|
||||
}
|
||||
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
$allowed_columns = ['id','name','serial','asset_tag'];
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
|
||||
$count = $category_assets->count();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($category_assets as $asset) {
|
||||
|
||||
$actions = '';
|
||||
$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="'.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>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $asset->id,
|
||||
'name' => (string) link_to_route('view/consumable', $asset->name, [$asset->id]),
|
||||
'actions' => $actions,
|
||||
'companyName' => Company::getName($asset),
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $count, 'rows' => $rows);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getDataViewComponent($categoryID)
|
||||
{
|
||||
|
||||
$category = Category::with('accessories.company')->find($categoryID);
|
||||
$category_assets = $category->components;
|
||||
|
||||
if (Input::has('search')) {
|
||||
$category_assets = $category_assets->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;
|
||||
}
|
||||
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
$allowed_columns = ['id','name','serial','asset_tag'];
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
|
||||
$count = $category_assets->count();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($category_assets as $asset) {
|
||||
|
||||
$actions = '';
|
||||
$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="'.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>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $asset->id,
|
||||
'name' => (string)link_to_route('view/accessory', $asset->name, [$asset->id]),
|
||||
'actions' => $actions,
|
||||
'companyName' => Company::getName($asset),
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $count, 'rows' => $rows);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Company;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Redirect;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Companies for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
|
||||
final class CompaniesController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns view to display listing of companies.
|
||||
*
|
||||
* @author [Abdullah Alansari] [<ahimta@gmail.com>]
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
return View::make('companies/index')->with('companies', Company::all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns view to create a new company.
|
||||
*
|
||||
* @author [Abdullah Alansari] [<ahimta@gmail.com>]
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function getCreate()
|
||||
{
|
||||
return View::make('companies/edit')->with('company', new Company);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save data from new company form.
|
||||
*
|
||||
* @author [Abdullah Alansari] [<ahimta@gmail.com>]
|
||||
* @since [v1.8]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
$company = new Company;
|
||||
|
||||
$company->name = e(Input::get('name'));
|
||||
|
||||
if ($company->save()) {
|
||||
return redirect()->to('admin/settings/companies')
|
||||
->with('success', trans('admin/companies/message.create.success'));
|
||||
} else {
|
||||
return redirect()->back()->withInput()->withErrors($company->getErrors());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return form to edit existing company.
|
||||
*
|
||||
* @author [Abdullah Alansari] [<ahimta@gmail.com>]
|
||||
* @since [v1.8]
|
||||
* @param int $companyId
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit($companyId)
|
||||
{
|
||||
if (is_null($company = Company::find($companyId))) {
|
||||
return redirect()->to('admin/settings/companies')
|
||||
->with('error', trans('admin/companies/message.does_not_exist'));
|
||||
} else {
|
||||
return View::make('companies/edit')->with('company', $company);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save data from edit company form.
|
||||
*
|
||||
* @author [Abdullah Alansari] [<ahimta@gmail.com>]
|
||||
* @since [v1.8]
|
||||
* @param int $companyId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit($companyId)
|
||||
{
|
||||
if (is_null($company = Company::find($companyId))) {
|
||||
return redirect()->to('admin/settings/companies')->with('error', trans('admin/companies/message.does_not_exist'));
|
||||
} else {
|
||||
|
||||
|
||||
$company->name = e(Input::get('name'));
|
||||
|
||||
if ($company->save()) {
|
||||
return redirect()->to('admin/settings/companies')
|
||||
->with('success', trans('admin/companies/message.update.success'));
|
||||
} else {
|
||||
return redirect()->to("admin/settings/companies/$companyId/edit")
|
||||
->with('error', trans('admin/companies/message.update.error'));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete company
|
||||
*
|
||||
* @author [Abdullah Alansari] [<ahimta@gmail.com>]
|
||||
* @since [v1.8]
|
||||
* @param int $companyId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postDelete($companyId)
|
||||
{
|
||||
if (is_null($company = Company::find($companyId))) {
|
||||
return redirect()->to('admin/settings/companies')
|
||||
->with('error', trans('admin/companies/message.not_found'));
|
||||
} else {
|
||||
try {
|
||||
$company->delete();
|
||||
return redirect()->to('admin/settings/companies')
|
||||
->with('success', trans('admin/companies/message.delete.success'));
|
||||
} catch (\Illuminate\Database\QueryException $exception) {
|
||||
/*
|
||||
* NOTE: This happens when there's a foreign key constraint violation
|
||||
* For example when rows in other tables are referencing this company
|
||||
*/
|
||||
if ($exception->getCode() == 23000) {
|
||||
return redirect()->to('admin/settings/companies')
|
||||
->with('error', trans('admin/companies/message.assoc_users'));
|
||||
} else {
|
||||
throw $exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,516 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Company;
|
||||
use App\Models\Component;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Models\Asset;
|
||||
use Auth;
|
||||
use Config;
|
||||
use DB;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Mail;
|
||||
use Redirect;
|
||||
use Slack;
|
||||
use Str;
|
||||
use View;
|
||||
use Validator;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* This class controls all actions related to Components for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class ComponentsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the components listing, which is generated in getDatatable.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ComponentsController::getDatatable() method that generates the JSON response
|
||||
* @since [v3.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
return View::make('components/index');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a form to create a new component.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ComponentsController::postCreate() method that stores the data
|
||||
* @since [v3.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getCreate()
|
||||
{
|
||||
// Show the page
|
||||
$category_list = Helper::categoryList('component');
|
||||
$company_list = Helper::companyList();
|
||||
$location_list = Helper::locationsList();
|
||||
|
||||
return View::make('components/edit')
|
||||
->with('component', new Component)
|
||||
->with('category_list', $category_list)
|
||||
->with('company_list', $company_list)
|
||||
->with('location_list', $location_list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate and store data for new component.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ComponentsController::getCreate() method that generates the view
|
||||
* @since [v3.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
|
||||
// create a new model instance
|
||||
$component = new Component();
|
||||
|
||||
// Update the component data
|
||||
$component->name = e(Input::get('name'));
|
||||
$component->category_id = e(Input::get('category_id'));
|
||||
$component->location_id = e(Input::get('location_id'));
|
||||
$component->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
|
||||
$component->order_number = e(Input::get('order_number'));
|
||||
$component->min_amt = e(Input::get('min_amt'));
|
||||
|
||||
if (e(Input::get('purchase_date')) == '') {
|
||||
$component->purchase_date = null;
|
||||
} else {
|
||||
$component->purchase_date = e(Input::get('purchase_date'));
|
||||
}
|
||||
|
||||
if (e(Input::get('purchase_cost')) == '0.00') {
|
||||
$component->purchase_cost = null;
|
||||
} else {
|
||||
$component->purchase_cost = e(Input::get('purchase_cost'));
|
||||
}
|
||||
|
||||
$component->total_qty = e(Input::get('total_qty'));
|
||||
$component->user_id = Auth::user()->id;
|
||||
|
||||
// Was the component created?
|
||||
if ($component->save()) {
|
||||
// Redirect to the new component page
|
||||
return redirect()->to("admin/components")->with('success', trans('admin/components/message.create.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($component->getErrors());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a view to edit a component.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ComponentsController::postEdit() method that stores the data.
|
||||
* @since [v3.0]
|
||||
* @param int $componentId
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit($componentId = null)
|
||||
{
|
||||
// Check if the component exists
|
||||
if (is_null($component = Component::find($componentId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/components')->with('error', trans('admin/components/message.does_not_exist'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($component)) {
|
||||
return redirect()->to('admin/components')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
$category_list = Helper::categoryList('component');
|
||||
$company_list = Helper::companyList();
|
||||
$location_list = Helper::locationsList();
|
||||
|
||||
return View::make('components/edit', compact('component'))
|
||||
->with('category_list', $category_list)
|
||||
->with('company_list', $company_list)
|
||||
->with('location_list', $location_list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a view to edit a component.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ComponentsController::getEdit() method presents the form.
|
||||
* @param int $componentId
|
||||
* @since [v3.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit($componentId = null)
|
||||
{
|
||||
// Check if the blog post exists
|
||||
if (is_null($component = Component::find($componentId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/components')->with('error', trans('admin/components/message.does_not_exist'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($component)) {
|
||||
return redirect()->to('admin/components')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
|
||||
// Update the component data
|
||||
$component->name = e(Input::get('name'));
|
||||
$component->category_id = e(Input::get('category_id'));
|
||||
$component->location_id = e(Input::get('location_id'));
|
||||
$component->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
|
||||
$component->order_number = e(Input::get('order_number'));
|
||||
$component->min_amt = e(Input::get('min_amt'));
|
||||
|
||||
if (e(Input::get('purchase_date')) == '') {
|
||||
$component->purchase_date = null;
|
||||
} else {
|
||||
$component->purchase_date = e(Input::get('purchase_date'));
|
||||
}
|
||||
|
||||
if (e(Input::get('purchase_cost')) == '0.00') {
|
||||
$component->purchase_cost = null;
|
||||
} else {
|
||||
$component->purchase_cost = e(Input::get('purchase_cost'));
|
||||
}
|
||||
|
||||
$component->total_qty = e(Input::get('total_qty'));
|
||||
|
||||
// Was the component created?
|
||||
if ($component->save()) {
|
||||
// Redirect to the new component page
|
||||
return redirect()->to("admin/components")->with('success', trans('admin/components/message.update.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($component->getErrors());
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a component.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @param int $componentId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getDelete($componentId)
|
||||
{
|
||||
// Check if the blog post exists
|
||||
if (is_null($component = Component::find($componentId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/components')->with('error', trans('admin/components/message.not_found'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($component)) {
|
||||
return redirect()->to('admin/components')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
$component->delete();
|
||||
|
||||
// Redirect to the locations management page
|
||||
return redirect()->to('admin/components')->with('success', trans('admin/components/message.delete.success'));
|
||||
|
||||
}
|
||||
|
||||
public function postBulk($componentId = null)
|
||||
{
|
||||
echo 'Stubbed - not yet complete';
|
||||
}
|
||||
|
||||
public function postBulkSave($componentId = null)
|
||||
{
|
||||
echo 'Stubbed - not yet complete';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a view to display component information.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ComponentsController::getDataView() method that generates the JSON response
|
||||
* @since [v3.0]
|
||||
* @param int $componentId
|
||||
* @return View
|
||||
*/
|
||||
public function getView($componentId = null)
|
||||
{
|
||||
$component = Component::find($componentId);
|
||||
|
||||
if (isset($component->id)) {
|
||||
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($component)) {
|
||||
return redirect()->to('admin/components')->with('error', trans('general.insufficient_permissions'));
|
||||
} else {
|
||||
return View::make('components/view', compact('component'));
|
||||
}
|
||||
} else {
|
||||
// Prepare the error message
|
||||
$error = trans('admin/components/message.does_not_exist', compact('id'));
|
||||
|
||||
// Redirect to the user management page
|
||||
return redirect()->route('components')->with('error', $error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view that allows the checkout of a component to an asset.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ComponentsController::postCheckout() method that stores the data.
|
||||
* @since [v3.0]
|
||||
* @param int $componentId
|
||||
* @return View
|
||||
*/
|
||||
public function getCheckout($componentId)
|
||||
{
|
||||
// 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'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($component)) {
|
||||
return redirect()->to('admin/components')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
// Get the dropdown of assets and then pass it to the checkout view
|
||||
$assets_list = Helper::detailedAssetList();
|
||||
|
||||
return View::make('components/checkout', compact('component'))->with('assets_list', $assets_list);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and store checkout data.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ComponentsController::getCheckout() method that returns the form.
|
||||
* @since [v3.0]
|
||||
* @param int $componentId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCheckout(Request $request, $componentId)
|
||||
{
|
||||
|
||||
|
||||
|
||||
// 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'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($component)) {
|
||||
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'));
|
||||
|
||||
// Check if the user exists
|
||||
if (is_null($asset = Asset::find($asset_id))) {
|
||||
// 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'),
|
||||
'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'));
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
if ($settings->slack_endpoint) {
|
||||
|
||||
$slack_settings = [
|
||||
'username' => $settings->botname,
|
||||
'channel' => $settings->slack_channel,
|
||||
'link_names' => true
|
||||
];
|
||||
|
||||
$client = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);
|
||||
|
||||
try {
|
||||
$client->attach([
|
||||
'color' => 'good',
|
||||
'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().'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
'value' => e($logaction->note)
|
||||
],
|
||||
]
|
||||
])->send('Component Checked Out');
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$log = $logaction->logaction('checkout');
|
||||
|
||||
// Redirect to the new component page
|
||||
return redirect()->to("admin/components")->with('success', trans('admin/components/message.checkout.success'));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates the JSON response for accessories listing view.
|
||||
*
|
||||
* For debugging, see at /api/accessories/list
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @return string JSON
|
||||
**/
|
||||
public function getDatatable()
|
||||
{
|
||||
$components = Component::select('components.*')->whereNull('components.deleted_at')
|
||||
->with('company', 'location', 'category');
|
||||
|
||||
if (Input::has('search')) {
|
||||
$components = $components->TextSearch(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 = ['id','name','min_amt','order_number','purchase_date','purchase_cost','companyName','category','total_qty'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
|
||||
|
||||
switch ($sort) {
|
||||
case 'category':
|
||||
$components = $components->OrderCategory($order);
|
||||
break;
|
||||
case 'location':
|
||||
$components = $components->OrderLocation($order);
|
||||
break;
|
||||
case 'companyName':
|
||||
$components = $components->OrderCompany($order);
|
||||
break;
|
||||
default:
|
||||
$components = $components->orderBy($sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
$consumCount = $components->count();
|
||||
$components = $components->skip($offset)->take($limit)->get();
|
||||
|
||||
$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').'" '.(($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>';
|
||||
$company = $component->company;
|
||||
|
||||
$rows[] = array(
|
||||
'checkbox' =>'<div class="text-center"><input type="checkbox" name="component['.$component->id.']" class="one_required"></div>',
|
||||
'id' => $component->id,
|
||||
'name' => (string)link_to('admin/components/'.$component->id.'/view', e($component->name)),
|
||||
'location' => ($component->location) ? e($component->location->name) : '',
|
||||
'total_qty' => e($component->total_qty),
|
||||
'min_amt' => e($component->min_amt),
|
||||
'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): '' ,
|
||||
'numRemaining' => $component->numRemaining(),
|
||||
'actions' => $actions,
|
||||
'companyName' => is_null($company) ? '' : e($company->name),
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $consumCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return JSON data to populate the components view,
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ComponentsController::getView() method that returns the view.
|
||||
* @since [v3.0]
|
||||
* @param int $componentId
|
||||
* @return string JSON
|
||||
*/
|
||||
public function getDataView($componentId)
|
||||
{
|
||||
//$component = Component::find($componentID);
|
||||
$component = Component::with('assets')->find($componentId);
|
||||
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($component)) {
|
||||
return ['total' => 0, 'rows' => []];
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($component->assets as $component_assignment) {
|
||||
$rows[] = array(
|
||||
'name' => (string)link_to('/hardware/'.$component_assignment->id.'/view', e($component_assignment->name)),
|
||||
'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'),
|
||||
);
|
||||
}
|
||||
|
||||
$componentCount = $component->assets->count();
|
||||
$data = array('total' => $componentCount, 'rows' => $rows);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -1,517 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Company;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Auth;
|
||||
use Config;
|
||||
use DB;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Mail;
|
||||
use Redirect;
|
||||
use Slack;
|
||||
use Str;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Consumables for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class ConsumablesController extends Controller
|
||||
{
|
||||
/**
|
||||
* Return a view to display component information.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ConsumablesController::getDatatable() method that generates the JSON response
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
return View::make('consumables/index');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a view to display the form view to create a new consumable
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ConsumablesController::postCreate() method that stores the form data
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getCreate()
|
||||
{
|
||||
// Show the page
|
||||
$category_list = Helper::categoryList('consumable');
|
||||
$company_list = Helper::companyList();
|
||||
$location_list = Helper::locationsList();
|
||||
$manufacturer_list = Helper::manufacturerList();
|
||||
|
||||
return View::make('consumables/edit')
|
||||
->with('consumable', new Consumable)
|
||||
->with('category_list', $category_list)
|
||||
->with('company_list', $company_list)
|
||||
->with('location_list', $location_list)
|
||||
->with('manufacturer_list', $manufacturer_list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate and store new consumable data.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ConsumablesController::getCreate() method that returns the form view
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
$consumable = new Consumable();
|
||||
$consumable->name = e(Input::get('name'));
|
||||
$consumable->category_id = e(Input::get('category_id'));
|
||||
$consumable->location_id = e(Input::get('location_id'));
|
||||
$consumable->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
|
||||
$consumable->order_number = e(Input::get('order_number'));
|
||||
$consumable->min_amt = e(Input::get('min_amt'));
|
||||
$consumable->manufacturer_id = e(Input::get('manufacturer_id'));
|
||||
$consumable->model_no = e(Input::get('model_no'));
|
||||
$consumable->item_no = e(Input::get('item_no'));
|
||||
|
||||
if (e(Input::get('purchase_date')) == '') {
|
||||
$consumable->purchase_date = null;
|
||||
} else {
|
||||
$consumable->purchase_date = e(Input::get('purchase_date'));
|
||||
}
|
||||
|
||||
if (e(Input::get('purchase_cost')) == '0.00') {
|
||||
$consumable->purchase_cost = null;
|
||||
} else {
|
||||
$consumable->purchase_cost = e(Input::get('purchase_cost'));
|
||||
}
|
||||
|
||||
$consumable->qty = e(Input::get('qty'));
|
||||
$consumable->user_id = Auth::user()->id;
|
||||
|
||||
// Was the consumable created?
|
||||
if ($consumable->save()) {
|
||||
// Redirect to the new consumable page
|
||||
return redirect()->to("admin/consumables")->with('success', trans('admin/consumables/message.create.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($consumable->getErrors());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a form view to edit a consumable.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $consumableId
|
||||
* @see ConsumablesController::postEdit() method that stores the form data.
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit($consumableId = null)
|
||||
{
|
||||
// Check if the consumable exists
|
||||
if (is_null($consumable = Consumable::find($consumableId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/consumables')->with('error', trans('admin/consumables/message.does_not_exist'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($consumable)) {
|
||||
return redirect()->to('admin/consumables')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
$category_list = Helper::categoryList('consumable');
|
||||
$company_list = Helper::companyList();
|
||||
$location_list = Helper::locationsList();
|
||||
$manufacturer_list = Helper::manufacturerList();
|
||||
|
||||
return View::make('consumables/edit', compact('consumable'))
|
||||
->with('category_list', $category_list)
|
||||
->with('company_list', $company_list)
|
||||
->with('location_list', $location_list)
|
||||
->with('manufacturer_list', $manufacturer_list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a form view to edit a consumable.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $consumableId
|
||||
* @see ConsumablesController::getEdit() method that stores the form data.
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit($consumableId = null)
|
||||
{
|
||||
if (is_null($consumable = Consumable::find($consumableId))) {
|
||||
return redirect()->to('admin/consumables')->with('error', trans('admin/consumables/message.does_not_exist'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($consumable)) {
|
||||
return redirect()->to('admin/consumables')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
$consumable->name = e(Input::get('name'));
|
||||
$consumable->category_id = e(Input::get('category_id'));
|
||||
$consumable->location_id = e(Input::get('location_id'));
|
||||
$consumable->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
|
||||
$consumable->order_number = e(Input::get('order_number'));
|
||||
$consumable->min_amt = e(Input::get('min_amt'));
|
||||
$consumable->manufacturer_id = e(Input::get('manufacturer_id'));
|
||||
$consumable->model_no = e(Input::get('model_no'));
|
||||
$consumable->item_no = e(Input::get('item_no'));
|
||||
|
||||
if (e(Input::get('purchase_date')) == '') {
|
||||
$consumable->purchase_date = null;
|
||||
} else {
|
||||
$consumable->purchase_date = e(Input::get('purchase_date'));
|
||||
}
|
||||
|
||||
if (e(Input::get('purchase_cost')) == '0.00') {
|
||||
$consumable->purchase_cost = null;
|
||||
} else {
|
||||
$consumable->purchase_cost = e(Input::get('purchase_cost'));
|
||||
}
|
||||
|
||||
$consumable->qty = e(Input::get('qty'));
|
||||
|
||||
if ($consumable->save()) {
|
||||
return redirect()->to("admin/consumables")->with('success', trans('admin/consumables/message.update.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($consumable->getErrors());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a consumable.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $consumableId
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getDelete($consumableId)
|
||||
{
|
||||
// Check if the blog post exists
|
||||
if (is_null($consumable = Consumable::find($consumableId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/consumables')->with('error', trans('admin/consumables/message.not_found'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($consumable)) {
|
||||
return redirect()->to('admin/consumables')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
$consumable->delete();
|
||||
|
||||
// Redirect to the locations management page
|
||||
return redirect()->to('admin/consumables')->with('success', trans('admin/consumables/message.delete.success'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return a view to display component information.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ConsumablesController::getDataView() method that generates the JSON response
|
||||
* @since [v1.0]
|
||||
* @param int $consumableId
|
||||
* @return View
|
||||
*/
|
||||
public function getView($consumableId = null)
|
||||
{
|
||||
$consumable = Consumable::find($consumableId);
|
||||
|
||||
if (isset($consumable->id)) {
|
||||
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($consumable)) {
|
||||
return redirect()->to('admin/consumables')->with('error', trans('general.insufficient_permissions'));
|
||||
} else {
|
||||
return View::make('consumables/view', compact('consumable'));
|
||||
}
|
||||
} else {
|
||||
// Prepare the error message
|
||||
$error = trans('admin/consumables/message.does_not_exist', compact('id'));
|
||||
|
||||
// Redirect to the user management page
|
||||
return redirect()->route('consumables')->with('error', $error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a view to checkout a consumable to a user.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ConsumablesController::postCheckout() method that stores the data.
|
||||
* @since [v1.0]
|
||||
* @param int $consumableId
|
||||
* @return View
|
||||
*/
|
||||
public function getCheckout($consumableId)
|
||||
{
|
||||
// Check if the consumable exists
|
||||
if (is_null($consumable = Consumable::find($consumableId))) {
|
||||
// Redirect to the consumable management page with error
|
||||
return redirect()->to('consumables')->with('error', trans('admin/consumables/message.not_found'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($consumable)) {
|
||||
return redirect()->to('admin/consumables')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
// Get the dropdown of users and then pass it to the checkout view
|
||||
$users_list = Helper::usersList();
|
||||
|
||||
return View::make('consumables/checkout', compact('consumable'))->with('users_list', $users_list);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the checkout information
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ConsumablesController::getCheckout() method that returns the form.
|
||||
* @since [v1.0]
|
||||
* @param int $consumableId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCheckout($consumableId)
|
||||
{
|
||||
// Check if the consumable exists
|
||||
if (is_null($consumable = Consumable::find($consumableId))) {
|
||||
// Redirect to the consumable management page with error
|
||||
return redirect()->to('consumables')->with('error', trans('admin/consumables/message.not_found'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($consumable)) {
|
||||
return redirect()->to('admin/consumables')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
$admin_user = Auth::user();
|
||||
$assigned_to = e(Input::get('assigned_to'));
|
||||
|
||||
// Check if the user exists
|
||||
if (is_null($user = User::find($assigned_to))) {
|
||||
// Redirect to the consumable management page with error
|
||||
return redirect()->to('admin/consumables')->with('error', trans('admin/consumables/message.user_does_not_exist'));
|
||||
}
|
||||
|
||||
// Update the consumable data
|
||||
$consumable->assigned_to = e(Input::get('assigned_to'));
|
||||
|
||||
$consumable->users()->attach($consumable->id, array(
|
||||
'consumable_id' => $consumable->id,
|
||||
'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->asset_id = 0;
|
||||
$logaction->location_id = $user->location_id;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = e(Input::get('note'));
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
if ($settings->slack_endpoint) {
|
||||
|
||||
$slack_settings = [
|
||||
'username' => $settings->botname,
|
||||
'channel' => $settings->slack_channel,
|
||||
'link_names' => true
|
||||
];
|
||||
|
||||
$client = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);
|
||||
|
||||
try {
|
||||
$client->attach([
|
||||
'color' => 'good',
|
||||
'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().'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
'value' => e($logaction->note)
|
||||
],
|
||||
]
|
||||
])->send('Consumable Checked Out');
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$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;
|
||||
$data['eula'] = $consumable->getEula();
|
||||
$data['first_name'] = $user->first_name;
|
||||
$data['item_name'] = $consumable->name;
|
||||
$data['checkout_date'] = $logaction->created_at;
|
||||
$data['note'] = $logaction->note;
|
||||
$data['require_acceptance'] = $consumable->requireAcceptance();
|
||||
|
||||
|
||||
if (($consumable->requireAcceptance()=='1') || ($consumable->getEula())) {
|
||||
|
||||
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');
|
||||
});
|
||||
}
|
||||
|
||||
// Redirect to the new consumable page
|
||||
return redirect()->to("admin/consumables")->with('success', trans('admin/consumables/message.checkout.success'));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the JSON response containing the the consumables data.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ConsumablesController::getIndex() method that returns the view that consumes the JSON.
|
||||
* @since [v1.0]
|
||||
* @param int $consumableId
|
||||
* @return View
|
||||
*/
|
||||
public function getDatatable()
|
||||
{
|
||||
$consumables = Consumable::select('consumables.*')->whereNull('consumables.deleted_at')
|
||||
->with('company', 'location', 'category', 'users');
|
||||
|
||||
if (Input::has('search')) {
|
||||
$consumables = $consumables->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 = ['id','name','order_number','min_amt','purchase_date','purchase_cost','companyName','category','model_no', 'item_no', 'manufacturer'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
|
||||
|
||||
switch ($sort) {
|
||||
case 'category':
|
||||
$consumables = $consumables->OrderCategory($order);
|
||||
break;
|
||||
case 'location':
|
||||
$consumables = $consumables->OrderLocation($order);
|
||||
break;
|
||||
case 'manufacturer':
|
||||
$consumables = $consumables->OrderManufacturer($order);
|
||||
break;
|
||||
case 'companyName':
|
||||
$consumables = $consumables->OrderCompany($order);
|
||||
break;
|
||||
default:
|
||||
$consumables = $consumables->orderBy($sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
$consumCount = $consumables->count();
|
||||
$consumables = $consumables->skip($offset)->take($limit)->get();
|
||||
|
||||
$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>';
|
||||
$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) ? 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',
|
||||
'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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JSON response containing details on the users associated with this consumable.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ConsumablesController::getView() method that returns the form.
|
||||
* @since [v1.0]
|
||||
* @param int $consumableId
|
||||
* @return View
|
||||
*/
|
||||
public function getDataView($consumableId)
|
||||
{
|
||||
//$consumable = Consumable::find($consumableID);
|
||||
$consumable = Consumable::with(array('consumableAssigments'=>
|
||||
function ($query) {
|
||||
$query->orderBy('created_at', 'DESC');
|
||||
},
|
||||
'consumableAssigments.admin'=> function ($query) {
|
||||
},
|
||||
'consumableAssigments.user'=> function ($query) {
|
||||
},
|
||||
))->find($consumableId);
|
||||
|
||||
// $consumable->load('consumableAssigments.admin','consumableAssigments.user');
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($consumable)) {
|
||||
return ['total' => 0, 'rows' => []];
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($consumable->consumableAssigments as $consumable_assignment) {
|
||||
$rows[] = array(
|
||||
'name' => (string)link_to('/admin/users/'.$consumable_assignment->user->id.'/view', e($consumable_assignment->user->fullName())),
|
||||
'created_at' => ($consumable_assignment->created_at->format('Y-m-d H:i:s')=='-0001-11-30 00:00:00') ? '' : $consumable_assignment->created_at->format('Y-m-d H:i:s'),
|
||||
'admin' => ($consumable_assignment->admin) ? e($consumable_assignment->admin->fullName()) : '',
|
||||
);
|
||||
}
|
||||
|
||||
$consumableCount = $consumable->users->count();
|
||||
$data = array('total' => $consumableCount, 'rows' => $rows);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/*! \mainpage Snipe-IT Code Documentation
|
||||
*
|
||||
* \section intro_sec Introduction
|
||||
*
|
||||
* This documentation is designed to allow developers to easily understand
|
||||
* the backend code of Snipe-IT. Familiarity with the PHP language is assumed,
|
||||
* and experience with the Laravel framework (version 5.2) will be very helpful.
|
||||
*
|
||||
* **THIS DOCUMENTATION DOES NOT COVER INSTALLATION.** If you're here and you're not a
|
||||
* developer, you're probably in the wrong place. Please see the
|
||||
* [Installation documentation](http://docs.snipeitapp.com) for
|
||||
* information on how to install Snipe-IT.
|
||||
*
|
||||
* To learn how to set up a development environment and get started developing for Snipe-IT,
|
||||
* please see the [contributing documentation](http://docs.snipeitapp.com/contributing.html).
|
||||
*
|
||||
* Only the Snipe-IT specific controllers, models, helpers, service providers,
|
||||
* etc have been included in this documentation (excluding vendors, Laravel core, etc)
|
||||
* for simplicity.
|
||||
*/
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
abstract class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
view()->share('signedIn', Auth::check());
|
||||
view()->share('user', Auth::user());
|
||||
}
|
||||
}
|
||||
@@ -1,277 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use View;
|
||||
use App\Models\CustomFieldset;
|
||||
use App\Models\CustomField;
|
||||
use Input;
|
||||
use Validator;
|
||||
use Redirect;
|
||||
use App\Models\AssetModel;
|
||||
use Lang;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Custom Asset Fields for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @todo Improve documentation here.
|
||||
* @todo Check for raw DB queries and try to convert them to query builder statements
|
||||
* @version v2.0
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
*/
|
||||
|
||||
class CustomFieldsController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns a view with a listing of custom fields.
|
||||
*
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
$fieldsets=CustomFieldset::with("fields", "models")->get();
|
||||
//$fieldsets=CustomFieldset::all();
|
||||
$fields=CustomField::with("fieldset")->get();
|
||||
//$fields=CustomField::all();
|
||||
return View::make("custom_fields.index")->with("custom_fieldsets", $fieldsets)->with("custom_fields", $fields);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a view with a form for creating a new custom fieldset.
|
||||
*
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
return View::make("custom_fields.create");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates and stores a new custom fieldset.
|
||||
*
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
* @since [v1.8]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
//
|
||||
$cfset=new CustomFieldset(["name" => Input::get("name"),"user_id" => Auth::user()->id]);
|
||||
$validator=Validator::make(Input::all(), $cfset->rules);
|
||||
if ($validator->passes()) {
|
||||
$cfset->save();
|
||||
return redirect()->route("admin.custom_fields.show", [$cfset->id])->with('success', trans('admin/custom_fields/message.fieldset.create.success'));
|
||||
} else {
|
||||
return redirect()->back()->withInput()->withErrors($validator);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate the custom field with a custom fieldset.
|
||||
*
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function associate($id)
|
||||
{
|
||||
|
||||
$set = CustomFieldset::find($id);
|
||||
|
||||
foreach ($set->fields as $field) {
|
||||
if ($field->id == Input::get('field_id')) {
|
||||
return redirect()->route("admin.custom_fields.show", [$id])->withInput()->withErrors(['field_id' => trans('admin/custom_fields/message.field.already_added')]);
|
||||
}
|
||||
}
|
||||
|
||||
$results=$set->fields()->attach(Input::get('field_id'), ["required" => (Input::get('required') == "on"),"order" => Input::get('order')]);
|
||||
|
||||
return redirect()->route("admin.custom_fields.show", [$id])->with("success", trans('admin/custom_fields/message.field.create.assoc_success'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a view with a form to create a new custom field.
|
||||
*
|
||||
* @see CustomFieldsController::storeField()
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function createField()
|
||||
{
|
||||
return View::make("custom_fields.create_field");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates and stores a new custom field.
|
||||
*
|
||||
* @see CustomFieldsController::createField()
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
* @since [v1.8]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function storeField()
|
||||
{
|
||||
$field=new CustomField(["name" => Input::get("name"),"element" => Input::get("element"),"user_id" => Auth::user()->id]);
|
||||
|
||||
|
||||
if (!in_array(Input::get('format'), array_keys(CustomField::$PredefinedFormats))) {
|
||||
$field->format=Input::get("custom_format");
|
||||
} else {
|
||||
$field->format=Input::get('format');
|
||||
}
|
||||
|
||||
$validator=Validator::make(Input::all(), $field->rules);
|
||||
if ($validator->passes()) {
|
||||
$results=$field->save();
|
||||
//return "postCreateField: $results";
|
||||
if ($results) {
|
||||
return redirect()->route("admin.custom_fields.index")->with("success", trans('admin/custom_fields/message.field.create.success'));
|
||||
} else {
|
||||
return redirect()->back()->withInput()->with('error', trans('admin/custom_fields/message.field.create.error'));
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->withInput()->withErrors($validator);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a custom field.
|
||||
*
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
* @since [v1.8]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function deleteField($field_id)
|
||||
{
|
||||
$field=CustomField::find($field_id);
|
||||
|
||||
if ($field->fieldset->count()>0) {
|
||||
return redirect()->back()->withErrors(['message' => "Field is in-use"]);
|
||||
} else {
|
||||
$field->delete();
|
||||
return redirect()->route("admin.custom_fields.index")->with("success", trans('admin/custom_fields/message.field.delete.success'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and stores a new custom field.
|
||||
*
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
* @param int $id
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//$id=$parameters[0];
|
||||
$cfset=CustomFieldset::find($id);
|
||||
|
||||
//print_r($parameters);
|
||||
//
|
||||
$custom_fields_list=["" => "Add New Field to Fieldset"] + CustomField::lists("name", "id")->toArray();
|
||||
// print_r($custom_fields_list);
|
||||
$maxid=0;
|
||||
foreach ($cfset->fields as $field) {
|
||||
// print "Looking for: ".$field->id;
|
||||
if ($field->pivot->order > $maxid) {
|
||||
$maxid=$field->pivot->order;
|
||||
}
|
||||
if (isset($custom_fields_list[$field->id])) {
|
||||
// print "Found ".$field->id.", so removing it.<br>";
|
||||
unset($custom_fields_list[$field->id]);
|
||||
}
|
||||
}
|
||||
|
||||
return View::make("custom_fields.show")->with("custom_fieldset", $cfset)->with("maxid", $maxid+1)->with("custom_fields_list", $custom_fields_list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* What the actual fuck, Brady?
|
||||
*
|
||||
* @todo Uhh, build this?
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
* @param int $id
|
||||
* @since [v1.8]
|
||||
* @return Fuckall
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET IN THE SEA BRADY.
|
||||
*
|
||||
* @todo Uhh, build this too?
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
* @param int $id
|
||||
* @since [v1.8]
|
||||
* @return Fuckall
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates a custom fieldset and then deletes if it has no models associated.
|
||||
*
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
* @param int $id
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
$fieldset=CustomFieldset::find($id);
|
||||
|
||||
$models = AssetModel::where("fieldset_id", "=", $id);
|
||||
if ($models->count()==0) {
|
||||
$fieldset->delete();
|
||||
return redirect()->route("admin.custom_fields.index")->with("success", trans('admin/custom_fields/message.fieldset.delete.success'));
|
||||
} else {
|
||||
return redirect()->route("admin.custom_fields.index")->with("error", trans('admin/custom_fields/message.fieldset.delete.in_use')); //->with("models",$models);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reorder the custom fields within a fieldset
|
||||
*
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
* @param int $id
|
||||
* @since [v3.0]
|
||||
* @return Array
|
||||
*/
|
||||
public function postReorder($id)
|
||||
{
|
||||
$fieldset=CustomFieldset::find($id);
|
||||
$fields = array();
|
||||
|
||||
$items = Input::get('item');
|
||||
foreach ($fieldset->fields as $field) {
|
||||
$value = array_shift($items);
|
||||
$fields[$field->id] = ['required' => $field->pivot->required, 'order' => $value];
|
||||
}
|
||||
return $fieldset->fields()->sync($fields);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\AdminController;
|
||||
use App\Models\Actionlog;
|
||||
use View;
|
||||
use Auth;
|
||||
use Redirect;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Company;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to the Admin Dashboard
|
||||
* for the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
/**
|
||||
* Check authorization and display admin dashboard, otherwise display
|
||||
* the user's checked-out assets.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
// 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();
|
||||
|
||||
if ($asset_stats['rtd']['total'] > 0) {
|
||||
$asset_stats['rtd']['percent'] = round(($asset_stats['rtd']['total']/$asset_stats['total']) * 100);
|
||||
} else {
|
||||
$asset_stats['rtd']['percent'] = 0;
|
||||
}
|
||||
|
||||
|
||||
$asset_stats['pending']['total'] = Asset::Hardware()->Pending()->count();
|
||||
|
||||
if ($asset_stats['pending']['total'] > 0) {
|
||||
$asset_stats['pending']['percent'] = round(($asset_stats['pending']['total']/$asset_stats['total']) * 100);
|
||||
} else {
|
||||
$asset_stats['pending']['percent'] = 0;
|
||||
}
|
||||
|
||||
|
||||
$asset_stats['deployed']['total'] = Asset::Hardware()->Deployed()->count();
|
||||
|
||||
if ($asset_stats['deployed']['total'] > 0) {
|
||||
$asset_stats['deployed']['percent'] = round(($asset_stats['deployed']['total']/$asset_stats['total']) * 100);
|
||||
} else {
|
||||
$asset_stats['deployed']['percent'] = 0;
|
||||
}
|
||||
|
||||
|
||||
$asset_stats['undeployable']['total'] = Asset::Hardware()->Undeployable()->count();
|
||||
|
||||
if ($asset_stats['undeployable']['total'] > 0) {
|
||||
$asset_stats['undeployable']['percent'] = round(($asset_stats['undeployable']['total']/$asset_stats['total']) * 100);
|
||||
} else {
|
||||
$asset_stats['undeployable']['percent'] = 0;
|
||||
}
|
||||
|
||||
$asset_stats['archived']['total'] = Asset::Hardware()->Archived()->count();
|
||||
|
||||
if ($asset_stats['archived']['total'] > 0) {
|
||||
$asset_stats['archived']['percent'] = round(($asset_stats['archived']['total']/$asset_stats['total']) * 100);
|
||||
} else {
|
||||
$asset_stats['archived']['percent'] = 0;
|
||||
}
|
||||
|
||||
|
||||
return View::make('dashboard')->with('asset_stats', $asset_stats)->with('recent_activity', $recent_activity);
|
||||
} else {
|
||||
// Redirect to the profile page
|
||||
return redirect()->route('view-assets');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,226 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Input;
|
||||
use Lang;
|
||||
use App\Models\Depreciation;
|
||||
use Redirect;
|
||||
use App\Models\Setting;
|
||||
use DB;
|
||||
use Str;
|
||||
use View;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Depreciations for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class DepreciationsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the depreciation listing, which is generated in getDatatable.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net]
|
||||
* @see DepreciationsController::getDatatable() method that generates the JSON response
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
// Show the page
|
||||
return View::make('depreciations/index', compact('depreciations'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a view that displays a form to create a new depreciation.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net]
|
||||
* @see DepreciationsController::postCreate()
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getCreate()
|
||||
{
|
||||
// Show the page
|
||||
return View::make('depreciations/edit')->with('depreciation', new Depreciation);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates and stores the new depreciation data.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net]
|
||||
* @see DepreciationsController::postCreate()
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// create a new instance
|
||||
$depreciation = new Depreciation();
|
||||
|
||||
// Depreciation data
|
||||
$depreciation->name = e(Input::get('name'));
|
||||
$depreciation->months = e(Input::get('months'));
|
||||
$depreciation->user_id = Auth::user()->id;
|
||||
|
||||
// Was the asset created?
|
||||
if ($depreciation->save()) {
|
||||
// Redirect to the new depreciation page
|
||||
return redirect()->to("admin/settings/depreciations")->with('success', trans('admin/depreciations/message.create.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($depreciation->getErrors());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view that displays a form to update a depreciation.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net]
|
||||
* @see DepreciationsController::postEdit()
|
||||
* @param int $depreciationId
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit($depreciationId = null)
|
||||
{
|
||||
// Check if the depreciation exists
|
||||
if (is_null($depreciation = Depreciation::find($depreciationId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/settings/depreciations')->with('error', trans('admin/depreciations/message.does_not_exist'));
|
||||
}
|
||||
|
||||
return View::make('depreciations/edit', compact('depreciation'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates and stores the updated depreciation data.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net]
|
||||
* @see DepreciationsController::getEdit()
|
||||
* @param int $depreciationId
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit($depreciationId = null)
|
||||
{
|
||||
// Check if the depreciation exists
|
||||
if (is_null($depreciation = Depreciation::find($depreciationId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/settings/depreciations')->with('error', trans('admin/depreciations/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Depreciation data
|
||||
$depreciation->name = e(Input::get('name'));
|
||||
$depreciation->months = e(Input::get('months'));
|
||||
|
||||
// Was the asset created?
|
||||
if ($depreciation->save()) {
|
||||
// Redirect to the depreciation page
|
||||
return redirect()->to("admin/settings/depreciations/")->with('success', trans('admin/depreciations/message.update.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($depreciation->getErrors());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and deletes a selected depreciation.
|
||||
*
|
||||
* This is a hard-delete. We do not currently soft-delete depreciations.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net]
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getDelete($depreciationId)
|
||||
{
|
||||
// Check if the depreciation exists
|
||||
if (is_null($depreciation = Depreciation::find($depreciationId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/settings/depreciations')->with('error', trans('admin/depreciations/message.not_found'));
|
||||
}
|
||||
|
||||
if ($depreciation->has_models() > 0) {
|
||||
|
||||
// Redirect to the asset management page
|
||||
return redirect()->to('admin/settings/depreciations')->with('error', trans('admin/depreciations/message.assoc_users'));
|
||||
} else {
|
||||
|
||||
$depreciation->delete();
|
||||
|
||||
// Redirect to the depreciations management page
|
||||
return redirect()->to('admin/settings/depreciations')->with('success', trans('admin/depreciations/message.delete.success'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates the JSON used to display the depreciation listing.
|
||||
*
|
||||
* @see DepreciationsController::getIndex()
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param string $status
|
||||
* @since [v1.2]
|
||||
* @return String JSON
|
||||
*/
|
||||
public function getDatatable()
|
||||
{
|
||||
$depreciations = Depreciation::select(array('id','name','months'));
|
||||
|
||||
if (Input::has('search')) {
|
||||
$depreciations = $depreciations->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 = ['id','name','months'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
|
||||
|
||||
$depreciations->orderBy($sort, $order);
|
||||
|
||||
$depreciationsCount = $depreciations->count();
|
||||
$depreciations = $depreciations->skip($offset)->take($limit)->get();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($depreciations as $depreciation) {
|
||||
$actions = '<a href="'.route('update/depreciations', $depreciation->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/depreciations', $depreciation->id).'" data-content="'.trans('admin/depreciations/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($depreciation->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $depreciation->id,
|
||||
'name' => e($depreciation->name),
|
||||
'months' => e($depreciation->months),
|
||||
'actions' => $actions
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $depreciationsCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,238 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Config;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Redirect;
|
||||
use App\Models\Setting;
|
||||
use Validator;
|
||||
use View;
|
||||
use App\Models\Group;
|
||||
use App\Helpers\Helper;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to User Groups for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class GroupsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the user group listing, which is generated in getDatatable.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net]
|
||||
* @see GroupsController::getDatatable() method that generates the JSON response
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
// Show the page
|
||||
return View::make('groups/index', compact('groups'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view that displays a form to create a new User Group.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net]
|
||||
* @see GroupsController::postCreate()
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getCreate()
|
||||
{
|
||||
$group = new Group;
|
||||
// Get all the available permissions
|
||||
$permissions = config('permissions');
|
||||
$groupPermissions = array();
|
||||
$selectedPermissions = Input::old('permissions', $groupPermissions);
|
||||
|
||||
// Show the page
|
||||
return View::make('groups/edit', compact('permissions', 'selectedPermissions', 'groupPermissions'))->with('group', $group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and stores the new User Group data.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net]
|
||||
* @see GroupsController::getCreate()
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
// create a new group instance
|
||||
$group = new Group();
|
||||
$group->name = e(Input::get('name'));
|
||||
$group->permissions = json_encode(Input::get('permission'));
|
||||
|
||||
if ($group->save()) {
|
||||
return redirect()->to("admin/groups")->with('success', trans('admin/groups/message.success.create'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($group->getErrors());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view that presents a form to edit a User Group.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net]
|
||||
* @see GroupsController::postEdit()
|
||||
* @param int $id
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit($id = null)
|
||||
{
|
||||
$group = Group::find($id);
|
||||
$permissions = config('permissions');
|
||||
$groupPermissions = $group->decodePermissions();
|
||||
$selected_array = Helper::selectedPermissionsArray($permissions, $groupPermissions);
|
||||
return View::make('groups/edit', compact('group', 'permissions', 'selected_array', 'groupPermissions'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and stores the updated User Group data.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net]
|
||||
* @see GroupsController::getEdit()
|
||||
* @param int $id
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit($id = null)
|
||||
{
|
||||
$permissions = config('permissions');
|
||||
if (!$group = Group::find($id)) {
|
||||
return redirect()->route('groups')->with('error', trans('admin/groups/message.group_not_found', compact('id')));
|
||||
|
||||
}
|
||||
$group->name = e(Input::get('name'));
|
||||
$group->permissions = json_encode(Input::get('permission'));
|
||||
|
||||
|
||||
if (!config('app.lock_passwords')) {
|
||||
|
||||
if ($group->save()) {
|
||||
return redirect()->to("admin/groups")->with('success', trans('admin/groups/message.success.update'));
|
||||
}
|
||||
return redirect()->back()->withInput()->withErrors($group->getErrors());
|
||||
|
||||
} else {
|
||||
return redirect()->route('update/group', $id)->withInput()->with('error', 'Denied! Editing groups is not allowed in the demo.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and deletes the User Group.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net]
|
||||
* @see GroupsController::getEdit()
|
||||
* @param int $id
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getDelete($id = null)
|
||||
{
|
||||
if (!config('app.lock_passwords')) {
|
||||
try {
|
||||
// Get group information
|
||||
$group = Group::find($id);
|
||||
$group->delete();
|
||||
|
||||
// Redirect to the group management page
|
||||
return redirect()->route('groups')->with('success', trans('admin/groups/message.success.delete'));
|
||||
} catch (GroupNotFoundException $e) {
|
||||
// Redirect to the group management page
|
||||
return redirect()->route('groups')->with('error', trans('admin/groups/message.group_not_found', compact('id')));
|
||||
}
|
||||
} else {
|
||||
return redirect()->route('groups')->with('error', trans('general.feature_disabled'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates the JSON used to display the User Group listing.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v2.0]
|
||||
* @return String JSON
|
||||
*/
|
||||
public function getDatatable()
|
||||
{
|
||||
|
||||
if (Input::has('offset')) {
|
||||
$offset = e(Input::get('offset'));
|
||||
} else {
|
||||
$offset = 0;
|
||||
}
|
||||
|
||||
if (Input::has('limit')) {
|
||||
$limit = e(Input::get('limit'));
|
||||
} else {
|
||||
$limit = 50;
|
||||
}
|
||||
|
||||
if (Input::get('sort')=='name') {
|
||||
$sort = 'first_name';
|
||||
} else {
|
||||
$sort = e(Input::get('sort'));
|
||||
}
|
||||
|
||||
// Grab all the groups
|
||||
$groups = Group::with('users')->orderBy('name', 'ASC');
|
||||
//$users = Company::scopeCompanyables($users);
|
||||
|
||||
if (Input::has('search')) {
|
||||
$groups = $users->TextSearch(e(Input::get('search')));
|
||||
}
|
||||
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
$allowed_columns =
|
||||
[
|
||||
'name','created_at'
|
||||
];
|
||||
|
||||
$sort = in_array($sort, $allowed_columns) ? $sort : 'name';
|
||||
$groups = $groups->orderBy($sort, $order);
|
||||
|
||||
$groupsCount = $groups->count();
|
||||
$groups = $groups->skip($offset)->take($limit)->get();
|
||||
$rows = array();
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$group_names = '';
|
||||
$inout = '';
|
||||
$actions = '<nobr>';
|
||||
|
||||
$actions .= '<a href="' . route('update/group', $group->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> ';
|
||||
|
||||
if (!config('app.lock_passwords')) {
|
||||
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/group', $group->id) . '" data-content="'.trans('admin/groups/message.delete.confirm').'" data-title="Delete ' . htmlspecialchars($group->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>';
|
||||
}
|
||||
|
||||
$actions .= '</nobr>';
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $group->id,
|
||||
'name' => $group->name,
|
||||
'users' => $group->users->count(),
|
||||
'created_at' => $group->created_at->format('Y-m-d'),
|
||||
'actions' => ($actions) ? $actions : '',
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total'=>$groupsCount, 'rows'=>$rows);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,432 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Input;
|
||||
use Lang;
|
||||
use App\Models\Location;
|
||||
use Redirect;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Models\Asset;
|
||||
use DB;
|
||||
use Str;
|
||||
use Validator;
|
||||
use View;
|
||||
use Auth;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Locations for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class LocationsController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the locations listing, which is generated in getDatatable.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::getDatatable() method that generates the JSON response
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
// Grab all the locations
|
||||
$locations = Location::orderBy('created_at', 'DESC')->with('parent', 'assets', 'assignedassets')->get();
|
||||
|
||||
// Show the page
|
||||
return View::make('locations/index', compact('locations'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a form view used to create a new location.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::postCreate() method that validates and stores the data
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getCreate()
|
||||
{
|
||||
$locations = Location::orderBy('name', 'ASC')->get();
|
||||
|
||||
$location_options_array = Location::getLocationHierarchy($locations);
|
||||
$location_options = Location::flattenLocationsArray($location_options_array);
|
||||
$location_options = array('' => 'Top Level') + $location_options;
|
||||
|
||||
return View::make('locations/edit')
|
||||
->with('location_options', $location_options)
|
||||
->with('location', new Location);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates and stores a new location.
|
||||
*
|
||||
* @todo Check if a Form Request would work better here.
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::getCreate() method that makes the form
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
|
||||
// create a new location instance
|
||||
$location = new Location();
|
||||
|
||||
|
||||
// Save the location data
|
||||
$location->name = e(Input::get('name'));
|
||||
if (Input::get('parent_id')=='') {
|
||||
$location->parent_id = null;
|
||||
} else {
|
||||
$location->parent_id = e(Input::get('parent_id'));
|
||||
}
|
||||
$location->currency = e(Input::get('currency', '$'));
|
||||
$location->address = e(Input::get('address'));
|
||||
$location->address2 = e(Input::get('address2'));
|
||||
$location->city = e(Input::get('city'));
|
||||
$location->state = e(Input::get('state'));
|
||||
$location->country = e(Input::get('country'));
|
||||
$location->zip = e(Input::get('zip'));
|
||||
$location->user_id = Auth::user()->id;
|
||||
|
||||
if ($location->save()) {
|
||||
// Redirect to the new location page
|
||||
return redirect()->to("admin/settings/locations")->with('success', trans('admin/locations/message.create.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($location->getErrors());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and stores a new location created via the Create Asset form modal.
|
||||
*
|
||||
* @todo Check if a Form Request would work better here.
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see AssetsController::getCreate() method that makes the form
|
||||
* @since [v1.0]
|
||||
* @return String JSON
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
|
||||
$new['currency']=Setting::first()->default_currency;
|
||||
|
||||
// create a new location instance
|
||||
$location = new Location();
|
||||
|
||||
// Save the location data
|
||||
$location->name = e(Input::get('name'));
|
||||
$location->currency = Setting::first()->default_currency; //e(Input::get('currency'));
|
||||
$location->address = ''; //e(Input::get('address'));
|
||||
// $location->address2 = e(Input::get('address2'));
|
||||
$location->city = e(Input::get('city'));
|
||||
$location->state = '';//e(Input::get('state'));
|
||||
$location->country = e(Input::get('country'));
|
||||
// $location->zip = e(Input::get('zip'));
|
||||
$location->user_id = Auth::user()->id;
|
||||
|
||||
// Was the location created?
|
||||
if ($location->save()) {
|
||||
return JsonResponse::create($location);
|
||||
|
||||
}
|
||||
|
||||
// failure
|
||||
$errors = $location->errors();
|
||||
return JsonResponse::create(["error" => "Failed validation: ".print_r($location->getErrors(), true)], 500);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Makes a form view to edit location information.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::postCreate() method that validates and stores
|
||||
* @param int $locationId
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit($locationId = null)
|
||||
{
|
||||
// Check if the location exists
|
||||
if (is_null($location = Location::find($locationId))) {
|
||||
return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Show the page
|
||||
$locations = Location::orderBy('name', 'ASC')->get();
|
||||
$location_options_array = Location::getLocationHierarchy($locations);
|
||||
$location_options = Location::flattenLocationsArray($location_options_array);
|
||||
$location_options = array('' => 'Top Level') + $location_options;
|
||||
|
||||
return View::make('locations/edit', compact('location'))->with('location_options', $location_options);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates and stores updated location data from edit form.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::getEdit() method that makes the form view
|
||||
* @param int $locationId
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit($locationId = null)
|
||||
{
|
||||
// Check if the location exists
|
||||
if (is_null($location = Location::find($locationId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Update the location data
|
||||
$location->name = e(Input::get('name'));
|
||||
if (Input::get('parent_id')=='') {
|
||||
$location->parent_id = null;
|
||||
} else {
|
||||
$location->parent_id = e(Input::get('parent_id', ''));
|
||||
}
|
||||
$location->currency = e(Input::get('currency', '$'));
|
||||
$location->address = e(Input::get('address'));
|
||||
$location->address2 = e(Input::get('address2'));
|
||||
$location->city = e(Input::get('city'));
|
||||
$location->state = e(Input::get('state'));
|
||||
$location->country = e(Input::get('country'));
|
||||
$location->zip = e(Input::get('zip'));
|
||||
|
||||
// Was the asset created?
|
||||
if ($location->save()) {
|
||||
// Redirect to the saved location page
|
||||
return redirect()->to("admin/settings/locations/")->with('success', trans('admin/locations/message.update.success'));
|
||||
}
|
||||
|
||||
// Redirect to the location management page
|
||||
return redirect()->back()->withInput()->withInput()->withErrors($location->getErrors());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and deletes selected location.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $locationId
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getDelete($locationId)
|
||||
{
|
||||
// Check if the location exists
|
||||
if (is_null($location = Location::find($locationId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.not_found'));
|
||||
}
|
||||
|
||||
|
||||
if ($location->users->count() > 0) {
|
||||
return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.assoc_users'));
|
||||
} elseif ($location->childLocations->count() > 0) {
|
||||
return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.assoc_child_loc'));
|
||||
} elseif ($location->assets->count() > 0) {
|
||||
return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.assoc_assets'));
|
||||
} elseif ($location->assignedassets->count() > 0) {
|
||||
return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.assoc_assets'));
|
||||
} else {
|
||||
$location->delete();
|
||||
return redirect()->to('admin/settings/locations')->with('success', trans('admin/locations/message.delete.success'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the locations detail page.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::getDataViewUsers() method that returns JSON for location users
|
||||
* @see LocationsController::getDataViewAssets() method that returns JSON for location assets
|
||||
* @param int $locationId
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getView($locationId = null)
|
||||
{
|
||||
$location = Location::find($locationId);
|
||||
|
||||
if (isset($location->id)) {
|
||||
return View::make('locations/view', compact('location'));
|
||||
} else {
|
||||
// Prepare the error message
|
||||
$error = trans('admin/locations/message.does_not_exist', compact('id'));
|
||||
|
||||
// Redirect to the user management page
|
||||
return redirect()->route('locations')->with('error', $error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the JSON response to populate the bootstrap tables on the locationa view.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::getIndex() method that returns JSON for location index
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getDatatable()
|
||||
{
|
||||
$locations = Location::select(array('locations.id','locations.name','locations.address','locations.address2','locations.city','locations.state','locations.zip','locations.country','locations.parent_id','locations.currency'))->with('assets');
|
||||
|
||||
|
||||
if (Input::has('search')) {
|
||||
$locations = $locations->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;
|
||||
}
|
||||
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
|
||||
|
||||
switch (Input::get('sort')) {
|
||||
case 'parent':
|
||||
$locations = $locations->OrderParent($order);
|
||||
break;
|
||||
default:
|
||||
$allowed_columns = ['id','name','address','city','state','country','currency'];
|
||||
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
|
||||
$locations = $locations->orderBy($sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$locationsCount = $locations->count();
|
||||
$locations = $locations->skip($offset)->take($limit)->get();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($locations as $location) {
|
||||
$actions = '<nobr><a href="'.route('update/location', $location->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/location', $location->id).'" data-content="'.trans('admin/locations/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($location->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></nobr>';
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $location->id,
|
||||
'name' => (string)link_to('admin/settings/locations/'.$location->id.'/view', e($location->name)),
|
||||
'parent' => ($location->parent) ? e($location->parent->name) : '',
|
||||
// 'assets' => ($location->assets->count() + $location->assignedassets->count()),
|
||||
'assets_default' => $location->assignedassets->count(),
|
||||
'assets_checkedout' => $location->assets->count(),
|
||||
'address' => ($location->address) ? e($location->address): '',
|
||||
'city' => e($location->city),
|
||||
'state' => e($location->state),
|
||||
'country' => e($location->country),
|
||||
'currency' => e($location->currency),
|
||||
'actions' => $actions
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $locationsCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a JSON response that contains the users association with the
|
||||
* selected location, to be used by the location detail view.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::getView() method that creates the display view
|
||||
* @param int $locationId
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function getDataViewUsers($locationID)
|
||||
{
|
||||
$location = Location::find($locationID);
|
||||
$users = User::where('location_id', '=', $location->id);
|
||||
|
||||
if (Input::has('search')) {
|
||||
$users = $users->TextSearch(e(Input::get('search')));
|
||||
}
|
||||
|
||||
$users = $users->get();
|
||||
$rows = array();
|
||||
|
||||
foreach ($users as $user) {
|
||||
$rows[] = array(
|
||||
'name' => (string)link_to('/admin/users/'.$user->id.'/view', e($user->fullName()))
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $users->count(), 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a JSON response that contains the assets association with the
|
||||
* selected location, to be used by the location detail view.
|
||||
*
|
||||
* @todo This is broken for accessories and consumables.
|
||||
* @todo This is a very naive implementation. Should clean this up with query scopes.
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::getView() method that creates the display view
|
||||
* @param int $locationID
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function getDataViewAssets($locationID)
|
||||
{
|
||||
$location = Location::find($locationID)->load('assignedassets.model');
|
||||
$assets = Asset::AssetsByLocation($location);
|
||||
|
||||
if (Input::has('search')) {
|
||||
$assets = $assets->TextSearch(e(Input::get('search')));
|
||||
}
|
||||
|
||||
$assets = $assets->get();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($assets as $asset) {
|
||||
$rows[] = array(
|
||||
'name' => (string)link_to(config('app.url').'/hardware/'.$asset->id.'/view', e($asset->showAssetName())),
|
||||
'asset_tag' => e($asset->asset_tag),
|
||||
'serial' => e($asset->serial),
|
||||
'model' => e($asset->model->name),
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $assets->count(), 'rows' => $rows);
|
||||
return $data;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,327 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Company;
|
||||
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
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class ManufacturersController extends Controller
|
||||
{
|
||||
/**
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the manufacturers listing, which is generated in getDatatable.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ManufacturersController::getDatatable() method that generates the JSON response
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
// Show the page
|
||||
return View::make('manufacturers/index', compact('manufacturers'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a view that displays a form to create a new manufacturer.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ManufacturersController::postCreate()
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getCreate()
|
||||
{
|
||||
return View::make('manufacturers/edit')->with('manufacturer', new Manufacturer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates and stores the data for a new manufacturer.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ManufacturersController::postCreate()
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
$manufacturer = new Manufacturer;
|
||||
$manufacturer->name = e(Input::get('name'));
|
||||
$manufacturer->user_id = Auth::user()->id;
|
||||
|
||||
if ($manufacturer->save()) {
|
||||
return redirect()->to("admin/settings/manufacturers")->with('success', trans('admin/manufacturers/message.create.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($manufacturer->getErrors());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view that displays a form to edit a manufacturer.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ManufacturersController::postEdit()
|
||||
* @param int $manufacturerId
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit($manufacturerId = null)
|
||||
{
|
||||
// Check if the manufacturer exists
|
||||
if (is_null($manufacturer = Manufacturer::find($manufacturerId))) {
|
||||
// Redirect to the manufacturer page
|
||||
return redirect()->to('admin/settings/manufacturers')->with('error', trans('admin/manufacturers/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Show the page
|
||||
return View::make('manufacturers/edit', compact('manufacturer'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates and stores the updated manufacturer data.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ManufacturersController::getEdit()
|
||||
* @param int $manufacturerId
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function postEdit($manufacturerId = null)
|
||||
{
|
||||
// Check if the manufacturer exists
|
||||
if (is_null($manufacturer = Manufacturer::find($manufacturerId))) {
|
||||
// Redirect to the manufacturer page
|
||||
return redirect()->to('admin/settings/manufacturers')->with('error', trans('admin/manufacturers/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Save the data
|
||||
$manufacturer->name = e(Input::get('name'));
|
||||
|
||||
// Was it created?
|
||||
if ($manufacturer->save()) {
|
||||
// Redirect to the new manufacturer page
|
||||
return redirect()->to("admin/settings/manufacturers")->with('success', trans('admin/manufacturers/message.update.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($manufacturer->getErrors());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a manufacturer.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $manufacturerId
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getDelete($manufacturerId)
|
||||
{
|
||||
// Check if the manufacturer exists
|
||||
if (is_null($manufacturer = Manufacturer::find($manufacturerId))) {
|
||||
// Redirect to the manufacturers page
|
||||
return redirect()->to('admin/settings/manufacturers')->with('error', trans('admin/manufacturers/message.not_found'));
|
||||
}
|
||||
|
||||
if ($manufacturer->has_models() > 0) {
|
||||
|
||||
// Redirect to the asset management page
|
||||
return redirect()->to('admin/settings/manufacturers')->with('error', trans('admin/manufacturers/message.assoc_users'));
|
||||
} else {
|
||||
|
||||
// Delete the manufacturer
|
||||
$manufacturer->delete();
|
||||
|
||||
// Redirect to the manufacturers management page
|
||||
return redirect()->to('admin/settings/manufacturers')->with('success', trans('admin/manufacturers/message.delete.success'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the manufacturers detail listing, which is generated in getDatatable.
|
||||
* This data contains a listing of all assets that belong to that manufacturer.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ManufacturersController::getDataView()
|
||||
* @param int $manufacturerId
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getView($manufacturerId = null)
|
||||
{
|
||||
$manufacturer = Manufacturer::find($manufacturerId);
|
||||
|
||||
if (isset($manufacturer->id)) {
|
||||
return View::make('manufacturers/view', compact('manufacturer'));
|
||||
} else {
|
||||
// Prepare the error message
|
||||
$error = trans('admin/manufacturers/message.does_not_exist', compact('id'));
|
||||
|
||||
// Redirect to the user management page
|
||||
return redirect()->route('manufacturers')->with('error', $error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the JSON used to display the manufacturer listings.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ManufacturersController::getIndex()
|
||||
* @since [v1.0]
|
||||
* @return String JSON
|
||||
*/
|
||||
public function getDatatable()
|
||||
{
|
||||
$manufacturers = Manufacturer::select(array('id','name'))->with('assets')
|
||||
->whereNull('deleted_at');
|
||||
|
||||
if (Input::has('search')) {
|
||||
$manufacturers = $manufacturers->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 = ['id','name'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
|
||||
|
||||
$manufacturers->orderBy($sort, $order);
|
||||
|
||||
$manufacturersCount = $manufacturers->count();
|
||||
$manufacturers = $manufacturers->skip($offset)->take($limit)->get();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($manufacturers as $manufacturer) {
|
||||
$actions = '<a href="'.route('update/manufacturer', $manufacturer->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/manufacturer', $manufacturer->id).'" data-content="'.trans('admin/manufacturers/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($manufacturer->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $manufacturer->id,
|
||||
'name' => (string)link_to('admin/settings/manufacturers/'.$manufacturer->id.'/view', e($manufacturer->name)),
|
||||
'assets' => $manufacturer->assets->count(),
|
||||
'actions' => $actions
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $manufacturersCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates the JSON used to display the manufacturer detail.
|
||||
* This JSON returns data on all of the assets with the specified
|
||||
* manufacturer ID number.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ManufacturersController::getView()
|
||||
* @param int $manufacturerId
|
||||
* @since [v1.0]
|
||||
* @return String JSON
|
||||
*/
|
||||
public function getDataView($manufacturerId)
|
||||
{
|
||||
|
||||
$manufacturer = Manufacturer::with('assets.company')->find($manufacturerId);
|
||||
$manufacturer_assets = $manufacturer->assets;
|
||||
|
||||
if (Input::has('search')) {
|
||||
$manufacturer_assets = $manufacturer_assets->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;
|
||||
}
|
||||
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
$allowed_columns = ['id','name','serial','asset_tag'];
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
|
||||
$count = $manufacturer_assets->count();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($manufacturer_assets as $asset) {
|
||||
|
||||
$actions = '';
|
||||
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="'.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">'.trans('general.checkin').'</a>';
|
||||
} else {
|
||||
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.trans('general.checkout').'</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)),
|
||||
);
|
||||
|
||||
if (isset($inout)) {
|
||||
$row['change'] = $inout;
|
||||
}
|
||||
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
$data = array('total' => $count, 'rows' => $rows);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Image;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use App\Models\Location;
|
||||
use View;
|
||||
use Auth;
|
||||
use App\Helpers\Helper;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to User Profiles for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
/**
|
||||
* Returns a view with the user's profile form for editing
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
// Get the user information
|
||||
$user = Auth::user();
|
||||
$location_list = Helper::locationsList();
|
||||
return View::make('account/profile', compact('user'))->with('location_list', $location_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and stores the user's update data.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postIndex()
|
||||
{
|
||||
|
||||
// Grab the user
|
||||
$user = Auth::user();
|
||||
|
||||
// Update the user information
|
||||
$user->first_name = e(Input::get('first_name'));
|
||||
$user->last_name = e(Input::get('last_name'));
|
||||
$user->website = e(Input::get('website'));
|
||||
$user->location_id = e(Input::get('location_id'));
|
||||
$user->gravatar = e(Input::get('gravatar'));
|
||||
$user->locale = e(Input::get('locale'));
|
||||
|
||||
if (Input::file('avatar')) {
|
||||
$image = Input::file('avatar');
|
||||
$file_name = $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;
|
||||
}
|
||||
|
||||
if (Input::get('avatar_delete') == 1 && Input::file('avatar') == "") {
|
||||
$user->avatar = null;
|
||||
}
|
||||
|
||||
if ($user->save()) {
|
||||
return redirect()->route('profile')->with('success', 'Account successfully updated');
|
||||
}
|
||||
return redirect()->back()->withInput()->withErrors($user->getErrors());
|
||||
}
|
||||
}
|
||||
@@ -1,824 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetMaintenance;
|
||||
use Carbon\Carbon;
|
||||
use Category;
|
||||
use App\Models\Company;
|
||||
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;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Reports for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class ReportsController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns a view that displaysthe accessories report.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getAccessoryReport()
|
||||
{
|
||||
$accessories = Accessory::orderBy('created_at', 'DESC')->with('company')->get();
|
||||
|
||||
return View::make('reports/accessories', compact('accessories'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the accessories to CSV
|
||||
*
|
||||
* @deprecated Server-side exports have been replaced by datatables export since v2.
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ManufacturersController::getDatatable() method that generates the JSON response
|
||||
* @since [v1.0]
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function exportAccessoryReport()
|
||||
{
|
||||
$accessories = Accessory::orderBy('created_at', 'DESC')->get();
|
||||
|
||||
$rows = array();
|
||||
$header = array(
|
||||
trans('admin/accessories/table.title'),
|
||||
trans('admin/accessories/general.accessory_category'),
|
||||
trans('admin/accessories/general.total'),
|
||||
trans('admin/accessories/general.remaining')
|
||||
);
|
||||
$header = array_map('trim', $header);
|
||||
$rows[] = implode($header, ', ');
|
||||
|
||||
// Row per accessory
|
||||
foreach ($accessories as $accessory) {
|
||||
$row = array();
|
||||
$row[] = e($accessory->accessory_name);
|
||||
$row[] = e($accessory->accessory_category);
|
||||
$row[] = e($accessory->total);
|
||||
$row[] = e($accessory->remaining);
|
||||
|
||||
$rows[] = implode($row, ',');
|
||||
}
|
||||
|
||||
$csv = implode($rows, "\n");
|
||||
$response = Response::make($csv, 200);
|
||||
$response->header('Content-Type', 'text/csv');
|
||||
$response->header('Content-disposition', 'attachment;filename=report.csv');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display asset report.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the assets to CSV
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function exportAssetReport()
|
||||
{
|
||||
// Grab all the assets
|
||||
$assets = Asset::orderBy('created_at', 'DESC')->get();
|
||||
|
||||
$rows = [ ];
|
||||
|
||||
// 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, ',');
|
||||
|
||||
// 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[] = '';
|
||||
}
|
||||
|
||||
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[] = '';
|
||||
}
|
||||
} elseif ($asset->rtd_location_id) {
|
||||
$location = Location::find($asset->rtd_location_id);
|
||||
if ($location->name) {
|
||||
$row[] = e($location->name);
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
} 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');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show depreciation report for assets.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getDeprecationReport()
|
||||
{
|
||||
|
||||
// Grab all the assets
|
||||
$assets = Asset::with('model', 'assigneduser', 'assetstatus', 'defaultLoc', 'assetlog', 'company')
|
||||
->orderBy('created_at', 'DESC')->get();
|
||||
|
||||
return View::make('reports/depreciation', compact('assets'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the depreciations to CSV
|
||||
*
|
||||
* @deprecated Server-side exports have been replaced by datatables export since v2.
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function exportDeprecationReport()
|
||||
{
|
||||
|
||||
// Grab all the assets
|
||||
$assets = Asset::with('model', 'assigneduser', 'assetstatus', 'defaultLoc', 'assetlog')
|
||||
->orderBy('created_at', 'DESC')->get();
|
||||
|
||||
$csv = \League\Csv\Writer::createFromFileObject(new \SplTempFileObject());
|
||||
$csv->setOutputBOM(Reader::BOM_UTF16_BE);
|
||||
|
||||
$rows = [ ];
|
||||
|
||||
// Create the header row
|
||||
$header = [
|
||||
trans('admin/hardware/table.asset_tag'),
|
||||
trans('admin/hardware/table.title'),
|
||||
trans('admin/hardware/table.serial'),
|
||||
trans('admin/hardware/table.checkoutto'),
|
||||
trans('admin/hardware/table.location'),
|
||||
trans('admin/hardware/table.purchase_date'),
|
||||
trans('admin/hardware/table.purchase_cost'),
|
||||
trans('admin/hardware/table.book_value'),
|
||||
trans('admin/hardware/table.diff')
|
||||
];
|
||||
|
||||
//we insert the CSV header
|
||||
$csv->insertOne($header);
|
||||
|
||||
// Create a row per asset
|
||||
foreach ($assets as $asset) {
|
||||
$row = [ ];
|
||||
$row[] = e($asset->asset_tag);
|
||||
$row[] = e($asset->name);
|
||||
$row[] = e($asset->serial);
|
||||
|
||||
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->city) {
|
||||
$row[] = e($location->city) . ', ' . e($location->state);
|
||||
} elseif ($location->name) {
|
||||
$row[] = e($location->name);
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
} else {
|
||||
$row[] = ''; // Empty string if location is not set
|
||||
}
|
||||
|
||||
if ($asset->assetloc) {
|
||||
$currency = e($asset->assetloc->currency);
|
||||
} else {
|
||||
$currency = e(Setting::first()->default_currency);
|
||||
}
|
||||
|
||||
$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);
|
||||
$csv->insertOne($row);
|
||||
}
|
||||
|
||||
$csv->output('depreciation-report-' . date('Y-m-d') . '.csv');
|
||||
die;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays activity report.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getActivityReport()
|
||||
{
|
||||
$log_actions = Actionlog::orderBy('created_at', 'DESC')
|
||||
->with('adminlog')
|
||||
->with('accessorylog')
|
||||
->with('assetlog')
|
||||
->with('licenselog')
|
||||
->with('userlog')
|
||||
->orderBy('created_at', 'DESC')
|
||||
->get();
|
||||
|
||||
return View::make('reports/activity', compact('log_actions'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays license report
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getLicenseReport()
|
||||
{
|
||||
|
||||
$licenses = License::orderBy('created_at', 'DESC')
|
||||
->with('company')
|
||||
->get();
|
||||
|
||||
return View::make('reports/licenses', compact('licenses'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the licenses to CSV
|
||||
*
|
||||
* @deprecated Server-side exports have been replaced by datatables export since v2.
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function exportLicenseReport()
|
||||
{
|
||||
$licenses = License::orderBy('created_at', 'DESC')->get();
|
||||
|
||||
$rows = [ ];
|
||||
$header = [
|
||||
trans('admin/licenses/table.title'),
|
||||
trans('admin/licenses/table.serial'),
|
||||
trans('admin/licenses/form.seats'),
|
||||
trans('admin/licenses/form.remaining_seats'),
|
||||
trans('admin/licenses/form.expiration'),
|
||||
trans('admin/licenses/form.date'),
|
||||
trans('admin/licenses/form.cost')
|
||||
];
|
||||
|
||||
$header = array_map('trim', $header);
|
||||
$rows[] = implode($header, ', ');
|
||||
|
||||
// Row per license
|
||||
foreach ($licenses as $license) {
|
||||
$row = [ ];
|
||||
$row[] = e($license->name);
|
||||
$row[] = e($license->serial);
|
||||
$row[] = e($license->seats);
|
||||
$row[] = $license->remaincount();
|
||||
$row[] = $license->expiration_date;
|
||||
$row[] = $license->purchase_date;
|
||||
$row[] = '"' . number_format($license->purchase_cost, 2) . '"';
|
||||
|
||||
$rows[] = implode($row, ',');
|
||||
}
|
||||
|
||||
$csv = implode($rows, "\n");
|
||||
$response = Response::make($csv, 200);
|
||||
$response->header('Content-Type', 'text/csv');
|
||||
$response->header('Content-disposition', 'attachment;filename=report.csv');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a form that allows the user to generate a custom CSV report.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ReportsController::postCustomReport() method that generates the CSV
|
||||
* @since [v1.0]
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function getCustomReport()
|
||||
{
|
||||
|
||||
return View::make('reports/custom');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
$rows = [ ];
|
||||
$header = [ ];
|
||||
|
||||
if (e(Input::get('asset_name')) == '1') {
|
||||
$header[] = 'Asset Name';
|
||||
}
|
||||
if (e(Input::get('asset_tag')) == '1') {
|
||||
$header[] = 'Asset Tag';
|
||||
}
|
||||
if (e(Input::get('manufacturer')) == '1') {
|
||||
$header[] = 'Manufacturer';
|
||||
}
|
||||
if (e(Input::get('model')) == '1') {
|
||||
$header[] = 'Model';
|
||||
$header[] = 'Model Number';
|
||||
}
|
||||
if (e(Input::get('category')) == '1') {
|
||||
$header[] = 'Category';
|
||||
}
|
||||
if (e(Input::get('serial')) == '1') {
|
||||
$header[] = 'Serial';
|
||||
}
|
||||
if (e(Input::get('purchase_date')) == '1') {
|
||||
$header[] = 'Purchase Date';
|
||||
}
|
||||
if (( e(Input::get('purchase_cost')) == '1' ) && ( e(Input::get('depreciation')) != '1' )) {
|
||||
$header[] = 'Purchase Cost';
|
||||
}
|
||||
if (e(Input::get('order')) == '1') {
|
||||
$header[] = 'Order Number';
|
||||
}
|
||||
if (e(Input::get('supplier')) == '1') {
|
||||
$header[] = 'Supplier';
|
||||
}
|
||||
if (e(Input::get('location')) == '1') {
|
||||
$header[] = 'Location';
|
||||
}
|
||||
if (e(Input::get('assigned_to')) == '1') {
|
||||
$header[] = 'Assigned To';
|
||||
}
|
||||
if (e(Input::get('status')) == '1') {
|
||||
$header[] = 'Status';
|
||||
}
|
||||
if (e(Input::get('warranty')) == '1') {
|
||||
$header[] = 'Warranty';
|
||||
$header[] = 'Warranty Expires';
|
||||
}
|
||||
if (e(Input::get('depreciation')) == '1') {
|
||||
$header[] = 'Purchase Cost';
|
||||
$header[] = 'Value';
|
||||
$header[] = 'Diff';
|
||||
}
|
||||
|
||||
$header = array_map('trim', $header);
|
||||
$rows[] = implode($header, ',');
|
||||
|
||||
foreach ($assets as $asset) {
|
||||
$row = [ ];
|
||||
if (e(Input::get('asset_name')) == '1') {
|
||||
$row[] = '"' .e($asset->name) . '"';
|
||||
}
|
||||
if (e(Input::get('asset_tag')) == '1') {
|
||||
$row[] = e($asset->asset_tag);
|
||||
}
|
||||
if (e(Input::get('manufacturer')) == '1') {
|
||||
if ($asset->model->manufacturer) {
|
||||
$row[] = '"' .e($asset->model->manufacturer->name) . '"';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
}
|
||||
if (e(Input::get('model')) == '1') {
|
||||
$row[] = '"' . e($asset->model->name) . '"';
|
||||
$row[] = '"' . e($asset->model->modelno) . '"';
|
||||
}
|
||||
if (e(Input::get('category')) == '1') {
|
||||
$row[] = '"' .e($asset->model->category->name) . '"';
|
||||
}
|
||||
|
||||
if (e(Input::get('serial')) == '1') {
|
||||
$row[] = e($asset->serial);
|
||||
}
|
||||
if (e(Input::get('purchase_date')) == '1') {
|
||||
$row[] = e($asset->purchase_date);
|
||||
}
|
||||
if (e(Input::get('purchase_cost')) == '1' && ( e(Input::get('depreciation')) != '1' )) {
|
||||
$row[] = '"' . number_format($asset->purchase_cost, 2) . '"';
|
||||
}
|
||||
if (e(Input::get('order')) == '1') {
|
||||
if ($asset->order_number) {
|
||||
$row[] = e($asset->order_number);
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
}
|
||||
if (e(Input::get('supplier')) == '1') {
|
||||
if ($asset->supplier_id) {
|
||||
$row[] = '"' .e($asset->supplier->name) . '"';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
}
|
||||
if (e(Input::get('location')) == '1') {
|
||||
$show_loc = '';
|
||||
if (( $asset->assigned_to > 0 ) && ( $asset->assigneduser->location_id !='' )) {
|
||||
$location = Location::find($asset->assigneduser->location_id);
|
||||
if ($location) {
|
||||
$show_loc .= '"' .e($location->name). '"';
|
||||
} else {
|
||||
$show_loc .= 'User location '.$asset->assigneduser->location_id.' is invalid';
|
||||
}
|
||||
} elseif ($asset->rtd_location_id!='') {
|
||||
$location = Location::find($asset->rtd_location_id);
|
||||
if ($location) {
|
||||
$show_loc .= '"' .e($location->name). '"';
|
||||
} else {
|
||||
$show_loc .= 'Default location '.$asset->rtd_location_id.' is invalid';
|
||||
}
|
||||
}
|
||||
|
||||
$row[] = $show_loc;
|
||||
|
||||
}
|
||||
if (e(Input::get('assigned_to')) == '1') {
|
||||
if ($asset->assigned_to > 0) {
|
||||
$user = User::find($asset->assigned_to);
|
||||
$row[] = '"' .e($user->fullName()). '"';
|
||||
} 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');
|
||||
} elseif (( $asset->status_id == '' ) && ( $asset->assigned_to == '0' )) {
|
||||
$row[] = trans('general.pending');
|
||||
} elseif ($asset->assetstatus) {
|
||||
$row[] = '"' .e($asset->assetstatus->name). '"';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
}
|
||||
if (e(Input::get('warranty')) == '1') {
|
||||
if ($asset->warranty_months) {
|
||||
$row[] = $asset->warranty_months;
|
||||
$row[] = $asset->warrantee_expires();
|
||||
} else {
|
||||
$row[] = '';
|
||||
$row[] = '';
|
||||
}
|
||||
}
|
||||
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) . '"';
|
||||
}
|
||||
$rows[] = implode($row, ',');
|
||||
}
|
||||
|
||||
// spit out a csv
|
||||
if (array_filter($rows)) {
|
||||
$csv = implode($rows, "\n");
|
||||
$response = Response::make($csv, 200);
|
||||
$response->header('Content-Type', 'text/csv');
|
||||
$response->header('Content-disposition', 'attachment;filename=report.csv');
|
||||
|
||||
return $response;
|
||||
} else {
|
||||
return redirect()->to("reports/custom")
|
||||
->with('error', trans('admin/reports/message.error'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getImprovementsReport
|
||||
*
|
||||
* @return View
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public function getAssetMaintenancesReport()
|
||||
{
|
||||
// Grab all the improvements
|
||||
$assetMaintenances = AssetMaintenance::with('asset', 'supplier', 'asset.company')
|
||||
->orderBy('created_at', 'DESC')
|
||||
->get();
|
||||
|
||||
return View::make('reports/asset_maintenances', compact('assetMaintenances'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* exportImprovementsReport
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public function exportAssetMaintenancesReport()
|
||||
{
|
||||
// Grab all the improvements
|
||||
$assetMaintenances = AssetMaintenance::with('asset', 'supplier')
|
||||
->orderBy('created_at', 'DESC')
|
||||
->get();
|
||||
|
||||
$rows = [ ];
|
||||
|
||||
$header = [
|
||||
trans('admin/asset_maintenances/table.asset_name'),
|
||||
trans('admin/asset_maintenances/table.supplier_name'),
|
||||
trans('admin/asset_maintenances/form.asset_maintenance_type'),
|
||||
trans('admin/asset_maintenances/form.title'),
|
||||
trans('admin/asset_maintenances/form.start_date'),
|
||||
trans('admin/asset_maintenances/form.completion_date'),
|
||||
trans('admin/asset_maintenances/form.asset_maintenance_time'),
|
||||
trans('admin/asset_maintenances/form.cost')
|
||||
];
|
||||
|
||||
$header = array_map('trim', $header);
|
||||
$rows[] = implode($header, ',');
|
||||
|
||||
foreach ($assetMaintenances as $assetMaintenance) {
|
||||
$row = [ ];
|
||||
$row[] = str_replace(',', '', e($assetMaintenance->asset->name));
|
||||
$row[] = str_replace(',', '', e($assetMaintenance->supplier->name));
|
||||
$row[] = e($assetMaintenance->improvement_type);
|
||||
$row[] = e($assetMaintenance->title);
|
||||
$row[] = e($assetMaintenance->start_date);
|
||||
$row[] = e($assetMaintenance->completion_date);
|
||||
if (is_null($assetMaintenance->asset_maintenance_time)) {
|
||||
$improvementTime = intval(Carbon::now()
|
||||
->diffInDays(Carbon::parse($assetMaintenance->start_date)));
|
||||
} else {
|
||||
$improvementTime = intval($assetMaintenance->asset_maintenance_time);
|
||||
}
|
||||
$row[] = $improvementTime;
|
||||
$row[] = trans('general.currency') . number_format($assetMaintenance->cost, 2);
|
||||
$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');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* getAssetAcceptanceReport
|
||||
*
|
||||
* @return mixed
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public function getAssetAcceptanceReport()
|
||||
{
|
||||
$assetsForReport = Asset::notYetAccepted()->with('company')->get();
|
||||
|
||||
return View::make('reports/unaccepted_assets', compact('assetsForReport'));
|
||||
}
|
||||
|
||||
/**
|
||||
* exportAssetAcceptanceReport
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public function exportAssetAcceptanceReport()
|
||||
{
|
||||
|
||||
// Grab all the improvements
|
||||
$assetsForReport = Actionlog::whereIn('id', $this->getAssetsNotAcceptedYet())
|
||||
->get();
|
||||
|
||||
$rows = [ ];
|
||||
|
||||
$header = [
|
||||
trans('general.category'),
|
||||
trans('admin/hardware/form.model'),
|
||||
trans('admin/hardware/form.name'),
|
||||
trans('admin/hardware/table.asset_tag'),
|
||||
trans('admin/hardware/table.checkoutto'),
|
||||
];
|
||||
|
||||
$header = array_map('trim', $header);
|
||||
$rows[] = implode($header, ',');
|
||||
|
||||
foreach ($assetsForReport as $assetItem) {
|
||||
$row = [ ];
|
||||
$row[] = str_replace(',', '', e($assetItem->assetlog->model->category->name));
|
||||
$row[] = str_replace(',', '', e($assetItem->assetlog->model->name));
|
||||
$row[] = str_replace(',', '', e($assetItem->assetlog->showAssetName()));
|
||||
$row[] = str_replace(',', '', e($assetItem->assetlog->asset_tag));
|
||||
$row[] = str_replace(',', '', e($assetItem->assetlog->assigneduser->fullName()));
|
||||
$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');
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* getCheckedOutAssetsRequiringAcceptance
|
||||
*
|
||||
* @param $modelsInCategoriesThatRequireAcceptance
|
||||
*
|
||||
* @return array
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
protected function getCheckedOutAssetsRequiringAcceptance($modelsInCategoriesThatRequireAcceptance)
|
||||
{
|
||||
$assets = Asset::deployed()
|
||||
->inModelList($modelsInCategoriesThatRequireAcceptance)
|
||||
->select('id')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
return array_pluck($assets, 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* getModelsInCategoriesThatRequireAcceptance
|
||||
*
|
||||
* @param $assetCategoriesRequiringAcceptance
|
||||
* @return array
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
protected function getModelsInCategoriesThatRequireAcceptance($assetCategoriesRequiringAcceptance)
|
||||
{
|
||||
|
||||
return array_pluck(Model::inCategory($assetCategoriesRequiringAcceptance)
|
||||
->select('id')
|
||||
->get()
|
||||
->toArray(), 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* getCategoriesThatRequireAcceptance
|
||||
*
|
||||
* @return array
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
protected function getCategoriesThatRequireAcceptance()
|
||||
{
|
||||
|
||||
return array_pluck(Category::requiresAcceptance()
|
||||
->select('id')
|
||||
->get()
|
||||
->toArray(), 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* getAssetsCheckedOutRequiringAcceptance
|
||||
*
|
||||
* @return array
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
protected function getAssetsCheckedOutRequiringAcceptance()
|
||||
{
|
||||
|
||||
return $this->getCheckedOutAssetsRequiringAcceptance(
|
||||
$this->getModelsInCategoriesThatRequireAcceptance($this->getCategoriesThatRequireAcceptance())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* getAssetsNotAcceptedYet
|
||||
*
|
||||
* @return array
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
protected function getAssetsNotAcceptedYet()
|
||||
{
|
||||
return Asset::unaccepted();
|
||||
}
|
||||
}
|
||||
@@ -1,589 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Input;
|
||||
use Lang;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Ldap;
|
||||
use Redirect;
|
||||
use DB;
|
||||
use Str;
|
||||
use View;
|
||||
use Image;
|
||||
use Config;
|
||||
use Response;
|
||||
use Artisan;
|
||||
use Crypt;
|
||||
use Mail;
|
||||
use App\Models\User;
|
||||
use App\Http\Requests\SetupUserRequest;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Settings for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Checks to see whether or not the database has a migrations table
|
||||
* and a user, otherwise display the setup view.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getSetupIndex()
|
||||
{
|
||||
|
||||
|
||||
try {
|
||||
$conn = DB::select('select 2 + 2');
|
||||
$start_settings['db_conn'] = true;
|
||||
$start_settings['db_name'] = DB::connection()->getDatabaseName();
|
||||
$start_settings['db_error'] = null;
|
||||
} catch (\PDOException $e) {
|
||||
$start_settings['db_conn'] = false;
|
||||
$start_settings['db_name'] = config('database.connections.mysql.database');
|
||||
$start_settings['db_error'] = $e->getMessage();
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
$start_settings['env_location'] = $pageURL.'../.env';
|
||||
|
||||
|
||||
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');
|
||||
|
||||
if ($exposed_env) {
|
||||
$start_settings['env_exposed'] = true;
|
||||
} else {
|
||||
$start_settings['env_exposed'] = false;
|
||||
}
|
||||
|
||||
if (\App::Environment('production') && (config('app.debug')==true)) {
|
||||
$start_settings['debug_exposed'] = true;
|
||||
} else {
|
||||
$start_settings['debug_exposed'] = false;
|
||||
}
|
||||
|
||||
$environment = app()->environment();
|
||||
if ($environment!='production') {
|
||||
$start_settings['env'] = $environment;
|
||||
$start_settings['prod'] = false;
|
||||
} else {
|
||||
$start_settings['env'] = $environment;
|
||||
$start_settings['prod'] = true;
|
||||
|
||||
}
|
||||
|
||||
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_is_admin'] = true;
|
||||
} else {
|
||||
$start_settings['owner_is_admin'] = false;
|
||||
}
|
||||
|
||||
if ((is_writable(storage_path()))
|
||||
&& (is_writable(storage_path().'/framework'))
|
||||
&& (is_writable(storage_path().'/framework/cache'))
|
||||
&& (is_writable(storage_path().'/framework/sessions'))
|
||||
&& (is_writable(storage_path().'/framework/views'))
|
||||
&& (is_writable(storage_path().'/logs'))
|
||||
) {
|
||||
$start_settings['writable'] = true;
|
||||
} else {
|
||||
$start_settings['writable'] = false;
|
||||
}
|
||||
|
||||
|
||||
$start_settings['gd'] = extension_loaded('gd');
|
||||
return View::make('setup/index')
|
||||
->with('step', 1)
|
||||
->with('start_settings', $start_settings)
|
||||
->with('section', 'Pre-Flight Check');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the email configuration
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function ajaxTestEmail()
|
||||
{
|
||||
|
||||
try {
|
||||
Mail::send('emails.test', [], function ($m) {
|
||||
$m->to(config('mail.from.address'), config('mail.from.name'));
|
||||
$m->subject('Test Email from Snipe-IT');
|
||||
});
|
||||
return 'success';
|
||||
} catch (Exception $e) {
|
||||
return 'error';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the first admin user from Setup.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postSaveFirstAdmin(SetupUserRequest $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;
|
||||
$permissions = array('superuser' => 1);
|
||||
$user->permissions = json_encode($permissions);
|
||||
$user->username = $data['username'] = e(Input::get('username'));
|
||||
$user->password = bcrypt(Input::get('password'));
|
||||
$data['password'] = Input::get('password');
|
||||
|
||||
$settings = new Setting;
|
||||
$settings->site_name = e(Input::get('site_name'));
|
||||
$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()) || (!$settings->isValid())) {
|
||||
return redirect()->back()->withInput()->withErrors($user->getErrors())->withErrors($settings->getErrors());
|
||||
} else {
|
||||
$user->save();
|
||||
$settings->save();
|
||||
|
||||
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');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return redirect()->route('setup.done');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the admin user creation form in Setup.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getSetupUser()
|
||||
{
|
||||
return View::make('setup/user')
|
||||
->with('step', 3)
|
||||
->with('section', 'Create a User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the view that tells the user that the Setup is done.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getSetupDone()
|
||||
{
|
||||
return View::make('setup/done')
|
||||
->with('step', 4)
|
||||
->with('section', 'Done!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate the database tables, and return the output
|
||||
* to a view for Setup
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getSetupMigrate()
|
||||
{
|
||||
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
|
||||
$output = Artisan::output();
|
||||
return View::make('setup/migrate')
|
||||
->with('output', $output)
|
||||
->with('step', 2)
|
||||
->with('section', 'Create Database Tables');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a view that shows some of the key settings.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
// Grab all the settings
|
||||
$settings = Setting::all();
|
||||
|
||||
// Show the page
|
||||
return View::make('settings/index', compact('settings'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a form to allow a super admin to update settings.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit()
|
||||
{
|
||||
$setting = Setting::first();
|
||||
$is_gd_installed = extension_loaded('gd');
|
||||
|
||||
return View::make('settings/edit', compact('setting'))->with('is_gd_installed', $is_gd_installed);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate and process settings edit form.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit()
|
||||
{
|
||||
|
||||
// Check if the asset exists
|
||||
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'));
|
||||
}
|
||||
|
||||
if (Input::get('clear_logo')=='1') {
|
||||
$setting->logo = null;
|
||||
} elseif (Input::file('logo_img')) {
|
||||
if (!config('app.lock_passwords')) {
|
||||
$image = Input::file('logo_img');
|
||||
$file_name = "logo.".$image->getClientOriginalExtension();
|
||||
$path = public_path('uploads/'.$file_name);
|
||||
Image::make($image->getRealPath())->resize(null, 40, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save($path);
|
||||
$setting->logo = $file_name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (config('app.lock_passwords')==false) {
|
||||
$setting->site_name = e(Input::get('site_name'));
|
||||
$setting->brand = e(Input::get('brand'));
|
||||
$setting->custom_css = e(Input::get('custom_css'));
|
||||
}
|
||||
|
||||
if (Input::get('per_page')!='') {
|
||||
$setting->per_page = e(Input::get('per_page'));
|
||||
} else {
|
||||
$setting->per_page = 200;
|
||||
}
|
||||
|
||||
$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'));
|
||||
$setting->load_remote = e(Input::get('load_remote', '0'));
|
||||
$setting->default_currency = e(Input::get('default_currency', '$'));
|
||||
$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->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'));
|
||||
$setting->labels_width = e(Input::get('labels_width'));
|
||||
$setting->labels_height = e(Input::get('labels_height'));
|
||||
$setting->labels_pmargin_left = e(Input::get('labels_pmargin_left'));
|
||||
$setting->labels_pmargin_right = e(Input::get('labels_pmargin_right'));
|
||||
$setting->labels_pmargin_top = e(Input::get('labels_pmargin_top'));
|
||||
$setting->labels_pmargin_bottom = e(Input::get('labels_pmargin_bottom'));
|
||||
$setting->labels_display_bgutter = e(Input::get('labels_display_bgutter'));
|
||||
$setting->labels_display_sgutter = e(Input::get('labels_display_sgutter'));
|
||||
$setting->labels_fontsize = e(Input::get('labels_fontsize'));
|
||||
$setting->labels_pagewidth = e(Input::get('labels_pagewidth'));
|
||||
$setting->labels_pageheight = e(Input::get('labels_pageheight'));
|
||||
|
||||
if (Input::has('labels_display_name')) {
|
||||
$setting->labels_display_name = 1;
|
||||
} else {
|
||||
$setting->labels_display_name = 0;
|
||||
}
|
||||
|
||||
if (Input::has('labels_display_serial')) {
|
||||
$setting->labels_display_serial = 1;
|
||||
} else {
|
||||
$setting->labels_display_serial = 0;
|
||||
}
|
||||
|
||||
if (Input::has('labels_display_tag')) {
|
||||
$setting->labels_display_tag = 1;
|
||||
} else {
|
||||
$setting->labels_display_tag = 0;
|
||||
}
|
||||
|
||||
$alert_email = rtrim(Input::get('alert_email'), ',');
|
||||
$alert_email = trim(Input::get('alert_email'));
|
||||
|
||||
$setting->alert_email = e($alert_email);
|
||||
$setting->alerts_enabled = e(Input::get('alerts_enabled', '0'));
|
||||
$setting->header_color = e(Input::get('header_color'));
|
||||
$setting->default_eula_text = e(Input::get('default_eula_text'));
|
||||
$setting->slack_endpoint = e(Input::get('slack_endpoint'));
|
||||
$setting->slack_channel = e(Input::get('slack_channel'));
|
||||
$setting->slack_botname = e(Input::get('slack_botname'));
|
||||
$setting->ldap_enabled = e(Input::get('ldap_enabled', '0'));
|
||||
$setting->ldap_server = e(Input::get('ldap_server'));
|
||||
$setting->ldap_server_cert_ignore = e(Input::get('ldap_server_cert_ignore', false));
|
||||
$setting->ldap_uname = e(Input::get('ldap_uname'));
|
||||
if (Input::has('ldap_pword')) {
|
||||
$setting->ldap_pword = Crypt::encrypt(Input::get('ldap_pword'));
|
||||
}
|
||||
$setting->ldap_basedn = e(Input::get('ldap_basedn'));
|
||||
$setting->ldap_filter = Input::get('ldap_filter');
|
||||
$setting->ldap_username_field = Input::get('ldap_username_field');
|
||||
$setting->ldap_lname_field = e(Input::get('ldap_lname_field'));
|
||||
$setting->ldap_fname_field = e(Input::get('ldap_fname_field'));
|
||||
$setting->ldap_auth_filter_query = Input::get('ldap_auth_filter_query');
|
||||
$setting->ldap_version = e(Input::get('ldap_version'));
|
||||
$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'));
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($setting->save()) {
|
||||
return redirect()->to("admin/settings/app")->with('success', trans('admin/settings/message.update.success'));
|
||||
|
||||
} else {
|
||||
return redirect()->back()->withInput()->withErrors($setting->getErrors());
|
||||
}
|
||||
|
||||
|
||||
// Redirect to the setting management page
|
||||
return redirect()->to("admin/settings/app/edit")->with('error', trans('admin/settings/message.update.error'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function getBackups()
|
||||
{
|
||||
|
||||
$path = storage_path().'/app/'.config('laravel-backup.backup.name');
|
||||
|
||||
$files = array();
|
||||
|
||||
if ($handle = opendir($path)) {
|
||||
|
||||
/* This is the correct way to loop over the directory. */
|
||||
while (false !== ($entry = readdir($handle))) {
|
||||
clearstatcache();
|
||||
if (substr(strrchr($entry, '.'), 1)=='zip') {
|
||||
$files[] = array(
|
||||
'filename' => $entry,
|
||||
'filesize' => Setting::fileSizeConvert(filesize($path.'/'.$entry)),
|
||||
'modified' => filemtime($path.'/'.$entry)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
closedir($handle);
|
||||
$files = array_reverse($files);
|
||||
}
|
||||
|
||||
|
||||
return View::make('settings/backups', compact('path', 'files'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process the backup.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.8]
|
||||
* @return Redirect
|
||||
*/
|
||||
|
||||
public function postBackups()
|
||||
{
|
||||
if (!config('app.lock_passwords')) {
|
||||
Artisan::call('backup:run');
|
||||
return redirect()->to("admin/settings/backups")->with('success', trans('admin/settings/message.backup.generated'));
|
||||
} else {
|
||||
|
||||
return redirect()->to("admin/settings/backups")->with('error', trans('general.feature_disabled'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Download the backup file
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.8]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function downloadFile($filename = null)
|
||||
{
|
||||
if (!config('app.lock_passwords')) {
|
||||
$path = storage_path().'/app/'.config('laravel-backup.backup.name');
|
||||
$file = $path.'/'.$filename;
|
||||
if (file_exists($file)) {
|
||||
return Response::download($file);
|
||||
} else {
|
||||
|
||||
// Redirect to the backup page
|
||||
return redirect()->route('settings/backups')->with('error', trans('admin/settings/message.backup.file_not_found'));
|
||||
}
|
||||
} else {
|
||||
// Redirect to the backup page
|
||||
return redirect()->route('settings/backups')->with('error', trans('general.feature_disabled'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the backup file
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function deleteFile($filename = null)
|
||||
{
|
||||
|
||||
if (!config('app.lock_passwords')) {
|
||||
|
||||
$path = storage_path().'/app/'.config('laravel-backup.backup.name');
|
||||
$file = $path.'/'.$filename;
|
||||
if (file_exists($file)) {
|
||||
unlink($file);
|
||||
return redirect()->route('settings/backups')->with('success', trans('admin/settings/message.backup.file_deleted'));
|
||||
} else {
|
||||
return redirect()->route('settings/backups')->with('error', trans('admin/settings/message.backup.file_not_found'));
|
||||
}
|
||||
} else {
|
||||
return redirect()->route('settings/backups')->with('error', trans('general.feature_disabled'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Purges soft-deletes
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.0]
|
||||
* @return View
|
||||
*/
|
||||
public function postPurge()
|
||||
{
|
||||
if (!config('app.lock_passwords')) {
|
||||
if (Input::get('confirm_purge')=='DELETE') {
|
||||
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'));
|
||||
} else {
|
||||
return redirect()->back()->with('error', trans('admin/settings/message.purge.validation_failed'));
|
||||
}
|
||||
|
||||
} else {
|
||||
return redirect()->back()->with('error', trans('general.feature_disabled'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,307 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Input;
|
||||
use Lang;
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\Asset;
|
||||
use Redirect;
|
||||
use DB;
|
||||
use App\Models\Setting;
|
||||
use Str;
|
||||
use View;
|
||||
use App\Helpers\Helper;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Status Labels for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class StatuslabelsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show a list of all the statuslabels.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
|
||||
public function getIndex()
|
||||
{
|
||||
// Show the page
|
||||
return View::make('statuslabels/index', compact('statuslabels'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show a count of assets by status label
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
|
||||
public function getAssetCountByStatuslabel()
|
||||
{
|
||||
$colors = [];
|
||||
|
||||
$statuslabels = Statuslabel::get();
|
||||
$labels=[];
|
||||
$points=[];
|
||||
|
||||
foreach ($statuslabels as $statuslabel) {
|
||||
$labels[]=$statuslabel->name;
|
||||
$points[]=$statuslabel->assets()->whereNull('assigned_to')->count();
|
||||
}
|
||||
$labels[]='Deployed';
|
||||
$points[]=Asset::whereNotNull('assigned_to')->count();
|
||||
|
||||
$result= [
|
||||
"labels" => $labels,
|
||||
"datasets" => [ [
|
||||
"data" => $points,
|
||||
"backgroundColor" => Helper::chartColors(),
|
||||
"hoverBackgroundColor" => Helper::chartColors()
|
||||
]]
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Statuslabel create.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function getCreate()
|
||||
{
|
||||
// Show the page
|
||||
$statuslabel = new Statuslabel;
|
||||
$use_statuslabel_type = $statuslabel->getStatuslabelType();
|
||||
$statuslabel_types = Helper::statusTypeList();
|
||||
|
||||
return View::make('statuslabels/edit', compact('statuslabel_types', 'statuslabel'))->with('use_statuslabel_type', $use_statuslabel_type);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Statuslabel create form processing.
|
||||
*
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate(Request $request)
|
||||
{
|
||||
|
||||
// create a new model instance
|
||||
$statuslabel = new Statuslabel();
|
||||
|
||||
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'));
|
||||
$statuslabel->user_id = Auth::user()->id;
|
||||
$statuslabel->notes = e(Input::get('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 redirect()->to("admin/settings/statuslabels")->with('success', trans('admin/statuslabels/message.create.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($statuslabel->getErrors());
|
||||
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
|
||||
$statuslabel = new Statuslabel();
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Statuslabel update.
|
||||
*
|
||||
* @param int $statuslabelId
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit($statuslabelId = null)
|
||||
{
|
||||
// Check if the Statuslabel exists
|
||||
if (is_null($statuslabel = Statuslabel::find($statuslabelId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/settings/statuslabels')->with('error', trans('admin/statuslabels/message.does_not_exist'));
|
||||
}
|
||||
|
||||
$use_statuslabel_type = $statuslabel->getStatuslabelType();
|
||||
|
||||
$statuslabel_types = array('' => trans('admin/hardware/form.select_statustype')) + array('undeployable' => trans('admin/hardware/general.undeployable')) + array('pending' => trans('admin/hardware/general.pending')) + array('archived' => trans('admin/hardware/general.archived')) + array('deployable' => trans('admin/hardware/general.deployable'));
|
||||
|
||||
return View::make('statuslabels/edit', compact('statuslabel', 'statuslabel_types'))->with('use_statuslabel_type', $use_statuslabel_type);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Statuslabel update form processing page.
|
||||
*
|
||||
* @param int $statuslabelId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit(Request $request, $statuslabelId = null)
|
||||
{
|
||||
// Check if the Statuslabel exists
|
||||
if (is_null($statuslabel = Statuslabel::find($statuslabelId))) {
|
||||
// Redirect to the blogs management page
|
||||
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'));
|
||||
$statuslabel->name = e(Input::get('name'));
|
||||
$statuslabel->notes = e(Input::get('notes'));
|
||||
$statuslabel->deployable = $statustype['deployable'];
|
||||
$statuslabel->pending = $statustype['pending'];
|
||||
$statuslabel->archived = $statustype['archived'];
|
||||
|
||||
|
||||
// Was the asset created?
|
||||
if ($statuslabel->save()) {
|
||||
// Redirect to the saved Statuslabel page
|
||||
return redirect()->to("admin/settings/statuslabels/")->with('success', trans('admin/statuslabels/message.update.success'));
|
||||
} else {
|
||||
return redirect()->back()->withInput()->withErrors($statuslabel->getErrors());
|
||||
}
|
||||
|
||||
|
||||
// Redirect to the Statuslabel management page
|
||||
return redirect()->to("admin/settings/statuslabels/$statuslabelId/edit")->with('error', trans('admin/statuslabels/message.update.error'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the given Statuslabel.
|
||||
*
|
||||
* @param int $statuslabelId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getDelete($statuslabelId)
|
||||
{
|
||||
// Check if the Statuslabel exists
|
||||
if (is_null($statuslabel = Statuslabel::find($statuslabelId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/settings/statuslabels')->with('error', trans('admin/statuslabels/message.not_found'));
|
||||
}
|
||||
|
||||
|
||||
if ($statuslabel->has_assets() > 0) {
|
||||
|
||||
// Redirect to the asset management page
|
||||
return redirect()->to('admin/settings/statuslabels')->with('error', trans('admin/statuslabels/message.assoc_assets'));
|
||||
} else {
|
||||
|
||||
$statuslabel->delete();
|
||||
|
||||
// Redirect to the statuslabels management page
|
||||
return redirect()->to('admin/settings/statuslabels')->with('success', trans('admin/statuslabels/message.delete.success'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getDatatable()
|
||||
{
|
||||
$statuslabels = Statuslabel::select(array('id','name','deployable','pending','archived'))
|
||||
->whereNull('deleted_at');
|
||||
|
||||
if (Input::has('search')) {
|
||||
$statuslabels = $statuslabels->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 = ['id','name'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
|
||||
|
||||
$statuslabels->orderBy($sort, $order);
|
||||
|
||||
$statuslabelsCount = $statuslabels->count();
|
||||
$statuslabels = $statuslabels->skip($offset)->take($limit)->get();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($statuslabels as $statuslabel) {
|
||||
|
||||
if ($statuslabel->deployable == 1) {
|
||||
$label_type = trans('admin/statuslabels/table.deployable');
|
||||
} elseif ($statuslabel->pending == 1) {
|
||||
$label_type = trans('admin/statuslabels/table.pending');
|
||||
} elseif ($statuslabel->archived == 1) {
|
||||
$label_type = trans('admin/statuslabels/table.archived');
|
||||
} else {
|
||||
$label_type = trans('admin/statuslabels/table.undeployable');
|
||||
}
|
||||
|
||||
$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>';
|
||||
|
||||
$rows[] = array(
|
||||
'id' => e($statuslabel->id),
|
||||
'type' => e($label_type),
|
||||
'name' => e($statuslabel->name),
|
||||
'actions' => $actions
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $statuslabelsCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,297 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Image;
|
||||
use App\Models\AssetMaintenance;
|
||||
use Input;
|
||||
use Lang;
|
||||
use App\Models\Supplier;
|
||||
use Redirect;
|
||||
use App\Models\Setting;
|
||||
use Str;
|
||||
use View;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Suppliers for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class SuppliersController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show a list of all suppliers
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
// Grab all the suppliers
|
||||
$suppliers = Supplier::orderBy('created_at', 'DESC')->get();
|
||||
|
||||
// Show the page
|
||||
return View::make('suppliers/index', compact('suppliers'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Supplier create.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function getCreate()
|
||||
{
|
||||
return View::make('suppliers/edit')->with('supplier', new Supplier);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Supplier create form processing.
|
||||
*
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// Create a new supplier
|
||||
$supplier = new Supplier;
|
||||
// Save the location data
|
||||
$supplier->name = e(Input::get('name'));
|
||||
$supplier->address = e(Input::get('address'));
|
||||
$supplier->address2 = e(Input::get('address2'));
|
||||
$supplier->city = e(Input::get('city'));
|
||||
$supplier->state = e(Input::get('state'));
|
||||
$supplier->country = e(Input::get('country'));
|
||||
$supplier->zip = e(Input::get('zip'));
|
||||
$supplier->contact = e(Input::get('contact'));
|
||||
$supplier->phone = e(Input::get('phone'));
|
||||
$supplier->fax = e(Input::get('fax'));
|
||||
$supplier->email = e(Input::get('email'));
|
||||
$supplier->notes = e(Input::get('notes'));
|
||||
$supplier->url = $supplier->addhttp(e(Input::get('url')));
|
||||
$supplier->user_id = Auth::user()->id;
|
||||
|
||||
|
||||
|
||||
|
||||
if (Input::file('image')) {
|
||||
$image = Input::file('image');
|
||||
$file_name = str_random(25).".".$image->getClientOriginalExtension();
|
||||
$path = public_path('uploads/suppliers/'.$file_name);
|
||||
Image::make($image->getRealPath())->resize(300, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save($path);
|
||||
$supplier->image = $file_name;
|
||||
}
|
||||
|
||||
// Was it created?
|
||||
if ($supplier->save()) {
|
||||
// Redirect to the new supplier page
|
||||
return redirect()->to("admin/settings/suppliers")->with('success', trans('admin/suppliers/message.create.success'));
|
||||
}
|
||||
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($supplier->getErrors());
|
||||
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$supplier = new Supplier;
|
||||
$supplier->name = e($request->input('name'));
|
||||
$supplier->user_id = Auth::user()->id;
|
||||
|
||||
if ($supplier->save()) {
|
||||
return JsonResponse::create($supplier);
|
||||
}
|
||||
return JsonResponse::create(["error" => "Failed validation: ".print_r($supplier->getErrors(), true)], 500);
|
||||
return JsonResponse::create(["error" => "Couldn't save Supplier"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supplier update.
|
||||
*
|
||||
* @param int $supplierId
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit($supplierId = null)
|
||||
{
|
||||
// Check if the supplier exists
|
||||
if (is_null($supplier = Supplier::find($supplierId))) {
|
||||
// Redirect to the supplier page
|
||||
return redirect()->to('admin/settings/suppliers')->with('error', trans('admin/suppliers/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Show the page
|
||||
return View::make('suppliers/edit', compact('supplier'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Supplier update form processing page.
|
||||
*
|
||||
* @param int $supplierId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit($supplierId = null)
|
||||
{
|
||||
// Check if the supplier exists
|
||||
if (is_null($supplier = Supplier::find($supplierId))) {
|
||||
// Redirect to the supplier page
|
||||
return redirect()->to('admin/settings/suppliers')->with('error', trans('admin/suppliers/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Save the data
|
||||
$supplier->name = e(Input::get('name'));
|
||||
$supplier->address = e(Input::get('address'));
|
||||
$supplier->address2 = e(Input::get('address2'));
|
||||
$supplier->city = e(Input::get('city'));
|
||||
$supplier->state = e(Input::get('state'));
|
||||
$supplier->country = e(Input::get('country'));
|
||||
$supplier->zip = e(Input::get('zip'));
|
||||
$supplier->contact = e(Input::get('contact'));
|
||||
$supplier->phone = e(Input::get('phone'));
|
||||
$supplier->fax = e(Input::get('fax'));
|
||||
$supplier->email = e(Input::get('email'));
|
||||
$supplier->url = $supplier->addhttp(e(Input::get('url')));
|
||||
$supplier->notes = e(Input::get('notes'));
|
||||
|
||||
if (Input::file('image')) {
|
||||
$image = Input::file('image');
|
||||
$file_name = str_random(25).".".$image->getClientOriginalExtension();
|
||||
$path = public_path('uploads/suppliers/'.$file_name);
|
||||
Image::make($image->getRealPath())->resize(300, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
})->save($path);
|
||||
$supplier->image = $file_name;
|
||||
}
|
||||
|
||||
if (Input::get('image_delete') == 1 && Input::file('image') == "") {
|
||||
$supplier->image = null;
|
||||
}
|
||||
|
||||
if ($supplier->save()) {
|
||||
return redirect()->to("admin/settings/suppliers")->with('success', trans('admin/suppliers/message.update.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($supplier->getErrors());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the given supplier.
|
||||
*
|
||||
* @param int $supplierId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getDelete($supplierId)
|
||||
{
|
||||
// Check if the supplier exists
|
||||
if (is_null($supplier = Supplier::find($supplierId))) {
|
||||
// Redirect to the suppliers page
|
||||
return redirect()->to('admin/settings/suppliers')->with('error', trans('admin/suppliers/message.not_found'));
|
||||
}
|
||||
|
||||
if ($supplier->num_assets() > 0) {
|
||||
|
||||
// Redirect to the asset management page
|
||||
return redirect()->to('admin/settings/suppliers')->with('error', trans('admin/suppliers/message.assoc_users'));
|
||||
} else {
|
||||
|
||||
// Delete the supplier
|
||||
$supplier->delete();
|
||||
|
||||
// Redirect to the suppliers management page
|
||||
return redirect()->to('admin/settings/suppliers')->with('success', trans('admin/suppliers/message.delete.success'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the asset information to present to the supplier view page
|
||||
*
|
||||
* @param int $assetId
|
||||
* @return View
|
||||
**/
|
||||
public function getView($supplierId = null)
|
||||
{
|
||||
$supplier = Supplier::find($supplierId);
|
||||
|
||||
if (isset($supplier->id)) {
|
||||
return View::make('suppliers/view', compact('supplier'));
|
||||
} else {
|
||||
// Prepare the error message
|
||||
$error = trans('admin/suppliers/message.does_not_exist', compact('id'));
|
||||
|
||||
// Redirect to the user management page
|
||||
return redirect()->route('suppliers')->with('error', $error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getDatatable()
|
||||
{
|
||||
$suppliers = Supplier::select(array('id','name','address','address2','city','state','country','fax', 'phone','email','contact'))
|
||||
->whereNull('deleted_at');
|
||||
|
||||
if (Input::has('search')) {
|
||||
$suppliers = $suppliers->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 = ['id','name','address','phone','contact','fax','email'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
|
||||
|
||||
$suppliers->orderBy($sort, $order);
|
||||
|
||||
$suppliersCount = $suppliers->count();
|
||||
$suppliers = $suppliers->skip($offset)->take($limit)->get();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($suppliers as $supplier) {
|
||||
$actions = '<a href="'.route('update/supplier', $supplier->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/supplier', $supplier->id).'" data-content="'.trans('admin/suppliers/message.delete.confirm').'" data-title="'.trans('general.delete').' '.htmlspecialchars($supplier->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
|
||||
|
||||
$rows[] = array(
|
||||
'id' => $supplier->id,
|
||||
'name' => (string)link_to('admin/settings/suppliers/'.$supplier->id.'/view', e($supplier->name)),
|
||||
'contact' => e($supplier->contact),
|
||||
'address' => e($supplier->address).' '.e($supplier->address2).' '.e($supplier->city).' '.e($supplier->state).' '.e($supplier->country),
|
||||
'phone' => e($supplier->phone),
|
||||
'fax' => e($supplier->fax),
|
||||
'email' => ($supplier->email!='') ? '<a href="mailto:'.e($supplier->email).'">'.e($supplier->email).'</a>' : '',
|
||||
'assets' => $supplier->num_assets(),
|
||||
'licenses' => $supplier->num_licenses(),
|
||||
'actions' => $actions
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total' => $suppliersCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,288 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Company;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\Component;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Models\License;
|
||||
use Auth;
|
||||
use Config;
|
||||
use DB;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Mail;
|
||||
use Redirect;
|
||||
use Slack;
|
||||
use Validator;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to the ability for users
|
||||
* to view their own assets in the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class ViewAssetsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Redirect to the profile page.
|
||||
*
|
||||
* @return Redirect
|
||||
*/
|
||||
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');
|
||||
|
||||
|
||||
|
||||
if (isset($user->id)) {
|
||||
return View::make('account/view-assets', compact('user', 'userlog'));
|
||||
} else {
|
||||
// Prepare the error message
|
||||
$error = trans('admin/users/message.user_not_found', compact('id'));
|
||||
|
||||
// Redirect to the user management page
|
||||
return redirect()->route('users')->with('error', $error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getRequestableIndex()
|
||||
{
|
||||
|
||||
$assets = Asset::with('model', 'defaultLoc', 'assetloc', 'assigneduser')->Hardware()->RequestableAssets()->get();
|
||||
|
||||
return View::make('account/requestable-assets', compact('user', 'assets'));
|
||||
}
|
||||
|
||||
|
||||
public function getRequestAsset($assetId = null)
|
||||
{
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if the asset exists and is requestable
|
||||
if (is_null($asset = Asset::RequestableAssets()->find($assetId))) {
|
||||
// Redirect to the asset management page
|
||||
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'));
|
||||
} 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");
|
||||
|
||||
if ($user->location_id) {
|
||||
$logaction->location_id = $user->location_id;
|
||||
}
|
||||
$logaction->user_id = $data['user_id'] = Auth::user()->id;
|
||||
$log = $logaction->logaction('requested');
|
||||
|
||||
$data['requested_by'] = $user->fullName();
|
||||
$data['asset_name'] = $asset->showAssetName();
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
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');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if ($settings->slack_endpoint) {
|
||||
|
||||
|
||||
$slack_settings = [
|
||||
'username' => $settings->botname,
|
||||
'channel' => $settings->slack_channel,
|
||||
'link_names' => true
|
||||
];
|
||||
|
||||
$client = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);
|
||||
|
||||
try {
|
||||
$client->attach([
|
||||
'color' => 'good',
|
||||
'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().'>.'
|
||||
]
|
||||
|
||||
]
|
||||
])->send('Asset Requested');
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return redirect()->route('requestable-assets')->with('success')->with('success', trans('admin/hardware/message.requests.success'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Get the acceptance screen
|
||||
public function getAcceptAsset($logID = null)
|
||||
{
|
||||
|
||||
if (!$findlog = DB::table('asset_logs')->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);
|
||||
// consumable
|
||||
} elseif ($findlog->consumable_id!='') {
|
||||
$item = Consumable::find($findlog->consumable_id);
|
||||
// components
|
||||
} elseif ($findlog->component_id!='') {
|
||||
$item = Component::find($findlog->component_id);
|
||||
}
|
||||
|
||||
// Check if the asset exists
|
||||
if (is_null($item)) {
|
||||
// Redirect to the asset management page
|
||||
return redirect()->to('account')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||
} elseif (!Company::isCurrentUserHasAccess($item)) {
|
||||
return redirect()->route('requestable-assets')->with('error', trans('general.insufficient_permissions'));
|
||||
} else {
|
||||
return View::make('account/accept-asset', compact('item'))->with('findlog', $findlog);
|
||||
}
|
||||
}
|
||||
|
||||
// Save the acceptance
|
||||
public function postAcceptAsset($logID = null)
|
||||
{
|
||||
|
||||
// Check if the asset exists
|
||||
if (is_null($findlog = DB::table('asset_logs')->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'));
|
||||
}
|
||||
|
||||
|
||||
if ($findlog->accepted_id!='') {
|
||||
// Redirect to the asset management page
|
||||
return redirect()->to('account/view-assets')->with('error', trans('admin/users/message.error.asset_already_accepted'));
|
||||
}
|
||||
|
||||
if (!Input::has('asset_acceptance')) {
|
||||
return redirect()->to('account/view-assets')->with('error', trans('admin/users/message.error.accept_or_decline'));
|
||||
}
|
||||
|
||||
$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'));
|
||||
}
|
||||
|
||||
$logaction = new Actionlog();
|
||||
|
||||
if (Input::get('asset_acceptance')=='accepted') {
|
||||
$logaction_msg = 'accepted';
|
||||
$accepted="accepted";
|
||||
$return_msg = trans('admin/users/message.accepted');
|
||||
} else {
|
||||
$logaction_msg = 'declined';
|
||||
$accepted="rejected";
|
||||
$return_msg = trans('admin/users/message.declined');
|
||||
}
|
||||
|
||||
// Asset
|
||||
if (($findlog->asset_id!='') && ($findlog->asset_type=='hardware')) {
|
||||
$logaction->asset_id = $findlog->asset_id;
|
||||
$logaction->accessory_id = null;
|
||||
$logaction->asset_type = 'hardware';
|
||||
|
||||
if (Input::get('asset_acceptance')!='accepted') {
|
||||
DB::table('assets')
|
||||
->where('id', $findlog->asset_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->component_id = null;
|
||||
$logaction->asset_type = 'software';
|
||||
|
||||
// accessories
|
||||
} elseif ($findlog->accessory_id!='') {
|
||||
$logaction->asset_id = null;
|
||||
$logaction->component_id = null;
|
||||
$logaction->accessory_id = $findlog->accessory_id;
|
||||
$logaction->asset_type = 'accessory';
|
||||
// accessories
|
||||
} elseif ($findlog->consumable_id!='') {
|
||||
$logaction->asset_id = null;
|
||||
$logaction->accessory_id = null;
|
||||
$logaction->component_id = null;
|
||||
$logaction->consumable_id = $findlog->consumable_id;
|
||||
$logaction->asset_type = 'consumable';
|
||||
} elseif ($findlog->component_id!='') {
|
||||
$logaction->asset_id = null;
|
||||
$logaction->accessory_id = null;
|
||||
$logaction->consumable_id = null;
|
||||
$logaction->component_id = $findlog->component_id;
|
||||
$logaction->asset_type = 'component';
|
||||
}
|
||||
|
||||
$logaction->checkedout_to = $findlog->checkedout_to;
|
||||
|
||||
$logaction->note = e(Input::get('note'));
|
||||
$logaction->user_id = $user->id;
|
||||
$logaction->accepted_at = date("Y-m-d h:i:s");
|
||||
$log = $logaction->logaction($logaction_msg);
|
||||
|
||||
$update_checkout = DB::table('asset_logs')
|
||||
->where('id', $findlog->id)
|
||||
->update(array('accepted_id' => $logaction->id));
|
||||
|
||||
$affected_asset=$logaction->assetlog;
|
||||
$affected_asset->accepted=$accepted;
|
||||
$affected_asset->save();
|
||||
|
||||
if ($update_checkout) {
|
||||
return redirect()->to('account/view-assets')->with('success', $return_msg);
|
||||
|
||||
} else {
|
||||
return redirect()->to('account/view-assets')->with('error', 'Something went wrong ');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
\Illuminate\Foundation\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,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\App\Http\Middleware\CheckLocale::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'throttle:60,1',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'authorize' => \App\Http\Middleware\CheckPermissions::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
];
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
|
||||
class Authenticate
|
||||
{
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->guest()) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
} else {
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Config;
|
||||
use Route;
|
||||
use Schema;
|
||||
use App\Models\User;
|
||||
use App\Models\Setting;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!$request->is('setup*')) {
|
||||
return redirect(config('app.url').'/setup')->with('Request', $request);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Config;
|
||||
use Route;
|
||||
use Schema;
|
||||
use App\Models\Setting;
|
||||
|
||||
class CheckLocale
|
||||
{
|
||||
/**
|
||||
* Handle the locale for the user, default to settings otherwise
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
if (Schema::hasTable('settings')) {
|
||||
// User's preference
|
||||
if (($request->user()) && ($request->user()->locale)) {
|
||||
\App::setLocale($request->user()->locale);
|
||||
|
||||
// App setting preference
|
||||
} elseif ((Setting::getSettings()) && (Setting::getSettings()->locale!='')) {
|
||||
\App::setLocale(Setting::getSettings()->locale);
|
||||
|
||||
// Default app setting
|
||||
} else {
|
||||
\App::setLocale(config('app.locale'));
|
||||
}
|
||||
}
|
||||
\App::setLocale(config('app.locale'));
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
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 $section
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $section = null)
|
||||
{
|
||||
|
||||
if (Gate::allows($section)) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
return response()->view('layouts/basic', [
|
||||
'content' => view('errors/403')
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
|
||||
|
||||
class EncryptCookies extends BaseEncrypter
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class FrameGuard
|
||||
{
|
||||
/**
|
||||
* Handle the given request and get the response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
$response->headers->set('X-Frame-Options', 'SAMEORIGIN', false);
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class NosniffGuard
|
||||
{
|
||||
/**
|
||||
* Handle the given request and get the response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
$response->headers->set('X-Content-Type-Options', 'nosniff', false);
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
|
||||
|
||||
class VerifyCsrfToken extends BaseVerifier
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
];
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class XssProtectHeader
|
||||
{
|
||||
/**
|
||||
* Handle the given request and get the response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
$response->headers->set('X-XSS-Protection', '1');
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class AssetCheckinRequest 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 [
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function response(array $errors)
|
||||
{
|
||||
return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class AssetCheckoutRequest 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 [
|
||||
"assigned_to" => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class AssetFileRequest 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 [
|
||||
'file.*' => 'required|mimes:png,gif,jpg,jpeg,doc,docx,pdf,txt,zip,rar|max:2000'
|
||||
];
|
||||
}
|
||||
|
||||
public function response(array $errors)
|
||||
{
|
||||
return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\AssetModel;
|
||||
use Session;
|
||||
|
||||
class AssetRequest 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()
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'min:2|max:255',
|
||||
'model_id' => 'required|integer',
|
||||
'status_id' => 'required|integer',
|
||||
'company_id' => 'integer',
|
||||
'warranty_months' => 'integer|min:0|max:240',
|
||||
'physical' => 'integer',
|
||||
'checkout_date' => 'date',
|
||||
'checkin_date' => 'date',
|
||||
'supplier_id' => 'integer',
|
||||
'status' => 'integer',
|
||||
'asset_tag' => 'required',
|
||||
|
||||
];
|
||||
|
||||
$model = AssetModel::find($this->request->get('model_id'));
|
||||
|
||||
if (($model) && ($model->fieldset)) {
|
||||
$rules += $model->fieldset->validation_rules();
|
||||
}
|
||||
|
||||
|
||||
return $rules;
|
||||
|
||||
}
|
||||
|
||||
public function response(array $errors)
|
||||
{
|
||||
$this->session()->flash('errors', Session::get('errors', new \Illuminate\Support\ViewErrorBag)
|
||||
->put('default', new \Illuminate\Support\MessageBag($errors)));
|
||||
\Input::flash();
|
||||
return parent::response($errors);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
abstract class Request extends FormRequest
|
||||
{
|
||||
protected $rules = [];
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return $this->rules;
|
||||
}
|
||||
|
||||
// public function response(array $errors)
|
||||
// {
|
||||
// $this->session->flash('errorMessages', $errors);
|
||||
// return $this->redirector->back()->withErrors($errors)->withInput();
|
||||
// }
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?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',
|
||||
'last_name' => 'required|string|min:1',
|
||||
'username' => 'required|string|min:2|unique:users,username,NULL,deleted_at',
|
||||
'email' => 'email',
|
||||
'password' => 'required|min:6',
|
||||
'password_confirm' => 'sometimes|required_with:password',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class SetupUserRequest 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 [
|
||||
'site_name' => 'required|string|min:1',
|
||||
'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|unique:users,email',
|
||||
'password' => 'required|min:6',
|
||||
'password_confirm' => 'required|min:6|same:password',
|
||||
'email_domain' => 'required|min:4',
|
||||
];
|
||||
}
|
||||
|
||||
public function response(array $errors)
|
||||
{
|
||||
return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class UpdateUserRequest 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',
|
||||
'last_name' => 'required|string|min:1',
|
||||
'email' => 'email',
|
||||
'password_confirm' => 'sometimes|required_with:password',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,878 +0,0 @@
|
||||
<?php
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\Location;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Admin API Routes
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
Route::group([ 'prefix' => 'api', 'middleware' => 'auth' ], function () {
|
||||
|
||||
/*---Hardware API---*/
|
||||
Route::group([ 'prefix' => 'hardware','middleware' => ['web','auth','authorize:assets.view']], function () {
|
||||
|
||||
Route::get('list/{status?}', [ 'as' => 'api.hardware.list', 'uses' => 'AssetsController@getDatatable' ]);
|
||||
|
||||
Route::post('import', 'AssetsController@postAPIImportUpload');
|
||||
});
|
||||
|
||||
/*---Status Label API---*/
|
||||
Route::group([ 'prefix' => 'statuslabels' ,'middleware' => ['web','auth','authorize:admin']], function () {
|
||||
|
||||
Route::resource('/', 'StatuslabelsController');
|
||||
Route::get('{statuslabelId}/deployable', function ($statuslabelId) {
|
||||
|
||||
$statuslabel = Statuslabel::find($statuslabelId);
|
||||
if (( $statuslabel->deployable == '1' ) && ( $statuslabel->pending != '1' )
|
||||
&& ( $statuslabel->archived != '1' )
|
||||
) {
|
||||
return '1';
|
||||
} else {
|
||||
return '0';
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Route::get('list', [ 'as' => 'api.statuslabels.list', 'uses' => 'StatuslabelsController@getDatatable' ]);
|
||||
Route::get('assets', [ 'as' => 'api.statuslabels.assets', 'uses' => 'StatuslabelsController@getAssetCountByStatuslabel' ]);
|
||||
|
||||
});
|
||||
|
||||
/*---Accessories API---*/
|
||||
Route::group([ 'prefix' => 'accessories' ], function () {
|
||||
|
||||
Route::get('list', [ 'as' => 'api.accessories.list', 'uses' => 'AccessoriesController@getDatatable' ]);
|
||||
Route::get(
|
||||
'{accessoryID}/view',
|
||||
[ 'as' => 'api.accessories.view', 'uses' => 'AccessoriesController@getDataView' ]
|
||||
);
|
||||
});
|
||||
|
||||
/*---Consumables API---*/
|
||||
Route::group(array('prefix'=>'consumables'), function () {
|
||||
Route::get('list', array('as'=>'api.consumables.list', 'uses'=>'ConsumablesController@getDatatable'));
|
||||
Route::get('{consumableID}/view', array('as'=>'api.consumables.view', 'uses'=>'ConsumablesController@getDataView'));
|
||||
});
|
||||
|
||||
/*---Components API---*/
|
||||
Route::group(array('prefix'=>'components'), function () {
|
||||
Route::get('list', array('as'=>'api.components.list', 'uses'=>'ComponentsController@getDatatable'));
|
||||
Route::get('{componentID}/view', array('as'=>'api.components.view', 'uses'=>'ComponentsController@getDataView'));
|
||||
});
|
||||
|
||||
/*---Locations API---*/
|
||||
Route::group(array('prefix'=>'locations'), function () {
|
||||
Route::get('list', array('as'=>'api.locations.list', 'uses'=>'LocationsController@getDatatable'));
|
||||
Route::get('{locationID}/view', array('as'=>'api.locations.view', 'uses'=>'LocationsController@getDataView'));
|
||||
Route::get('{locationID}/users', array('as'=>'api.locations.viewusers', 'uses'=>'LocationsController@getDataViewUsers'));
|
||||
Route::get('{locationID}/assets', array('as'=>'api.locations.viewassets', 'uses'=>'LocationsController@getDataViewAssets'));
|
||||
});
|
||||
|
||||
/*---Depreciations API---*/
|
||||
Route::group(array('prefix'=>'depreciations'), function () {
|
||||
Route::get('list', array('as'=>'api.depreciations.list', 'uses'=>'DepreciationsController@getDatatable'));
|
||||
Route::get('{$depreciationID}/view', array('as'=>'api.depreciations.view', 'uses'=>'DepreciationsController@getDataView'));
|
||||
});
|
||||
|
||||
/*---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'));
|
||||
});
|
||||
|
||||
/*---Suppliers API---*/
|
||||
Route::group(array('prefix'=>'suppliers'), function () {
|
||||
Route::get('list', array('as'=>'api.suppliers.list', 'uses'=>'SuppliersController@getDatatable'));
|
||||
});
|
||||
|
||||
/*---Users API---*/
|
||||
Route::group([ 'prefix' => 'users' ], function () {
|
||||
Route::post('/', [ 'as' => 'api.users.store', 'uses' => 'UsersController@store' ]);
|
||||
Route::get('list/{status?}', [ 'as' => 'api.users.list', 'uses' => 'UsersController@getDatatable' ]);
|
||||
Route::get('{userId}/assets', [ 'as' => 'api.users.assetlist', 'uses' => 'UsersController@getAssetList' ]);
|
||||
Route::post('{userId}/upload', [ 'as' => 'upload/user', 'uses' => 'UsersController@postUpload' ]);
|
||||
});
|
||||
|
||||
/*---Groups API---*/
|
||||
Route::group([ 'prefix' => 'groups' ], function () {
|
||||
Route::get('list', [ 'as' => 'api.groups.list', 'uses' => 'GroupsController@getDatatable' ]);
|
||||
});
|
||||
|
||||
/*---Licenses API---*/
|
||||
Route::group([ 'prefix' => 'licenses' ], function () {
|
||||
|
||||
Route::get('list', [ 'as' => 'api.licenses.list', 'uses' => 'LicensesController@getDatatable' ]);
|
||||
});
|
||||
|
||||
/*---Locations API---*/
|
||||
Route::group([ 'prefix' => 'locations' ], function () {
|
||||
|
||||
Route::resource('/', 'LocationsController');
|
||||
Route::get('{locationID}/check', function ($locationID) {
|
||||
|
||||
$location = Location::find($locationID);
|
||||
|
||||
return $location;
|
||||
});
|
||||
});
|
||||
|
||||
/*---Improvements API---*/
|
||||
Route::group([ 'prefix' => 'asset_maintenances' ], function () {
|
||||
|
||||
Route::get(
|
||||
'list',
|
||||
[ 'as' => 'api.asset_maintenances.list', 'uses' => 'AssetMaintenancesController@getDatatable' ]
|
||||
);
|
||||
});
|
||||
|
||||
/*---Models API---*/
|
||||
Route::group([ 'prefix' => 'models' ], function () {
|
||||
|
||||
Route::resource('/', 'AssetModelsController');
|
||||
Route::get('list/{status?}', [ 'as' => 'api.models.list', 'uses' => 'AssetModelsController@getDatatable' ]);
|
||||
Route::get('{modelID}/view', [ 'as' => 'api.models.view', 'uses' => 'AssetModelsController@getDataView' ]);
|
||||
});
|
||||
|
||||
/*--- Categories API---*/
|
||||
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' ]
|
||||
);
|
||||
});
|
||||
|
||||
/*-- Suppliers API (mostly for creating new ones in-line while creating an asset) --*/
|
||||
Route::group([ 'prefix' => 'suppliers' ], function () {
|
||||
|
||||
Route::resource('/', 'SuppliersController');
|
||||
});
|
||||
|
||||
/*-- Custom fields API --*/
|
||||
Route::group([ 'prefix' => 'custom_fields' ], function () {
|
||||
Route::post(
|
||||
'{fieldsetID}/order',
|
||||
[ 'as' => 'api.customfields.order', 'uses' => 'CustomFieldsController@postReorder' ]
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Asset Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Register all the asset routes.
|
||||
|
|
||||
*/
|
||||
|
||||
Route::group(
|
||||
[ 'prefix' => 'hardware',
|
||||
'middleware' => ['web',
|
||||
'auth',
|
||||
'authorize:assets.view']],
|
||||
function () {
|
||||
|
||||
Route::get('create/{model?}', [
|
||||
'as' => 'create/hardware',
|
||||
'uses' => 'AssetsController@getCreate'
|
||||
]);
|
||||
|
||||
Route::post('create', [
|
||||
'as' => 'savenew/hardware',
|
||||
'uses' => 'AssetsController@postCreate'
|
||||
]);
|
||||
|
||||
Route::get('{assetId}/edit', [
|
||||
'as' => 'update/hardware',
|
||||
'uses' => 'AssetsController@getEdit'
|
||||
]);
|
||||
Route::get('/bytag', [
|
||||
'as' => 'findbytag/hardware',
|
||||
'uses' => 'AssetsController@getAssetByTag'
|
||||
]);
|
||||
|
||||
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}/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(
|
||||
'import/delete-import/{filename}',
|
||||
[ 'as' => 'assets/import/delete-file', 'uses' => 'AssetsController@getDeleteImportFile' ]
|
||||
);
|
||||
|
||||
Route::get(
|
||||
'import/process/{filename}',
|
||||
[ 'as' => 'assets/import/process-file', 'uses' => 'AssetsController@getProcessImportFile' ]
|
||||
);
|
||||
|
||||
Route::get(
|
||||
'import',
|
||||
[ 'as' => 'assets/import', 'uses' => 'AssetsController@getImportUpload' ]
|
||||
);
|
||||
|
||||
|
||||
Route::post('{assetId}/edit', 'AssetsController@postEdit');
|
||||
|
||||
Route::post(
|
||||
'bulkedit',
|
||||
[
|
||||
'as' => 'hardware/bulkedit',
|
||||
'uses' => 'AssetsController@postBulkEdit'
|
||||
]
|
||||
);
|
||||
Route::post(
|
||||
'bulkdelete',
|
||||
[
|
||||
'as' => 'hardware/bulkdelete',
|
||||
'uses' => 'AssetsController@postBulkDelete'
|
||||
]
|
||||
);
|
||||
Route::post(
|
||||
'bulksave',
|
||||
[
|
||||
'as' => 'hardware/bulksave',
|
||||
'uses' => 'AssetsController@postBulkSave'
|
||||
]
|
||||
);
|
||||
|
||||
# Asset Model Management
|
||||
Route::group([ 'prefix' => 'models', 'middleware' => 'auth' ], function () {
|
||||
|
||||
Route::get('/', [ 'as' => 'models', 'uses' => 'AssetModelsController@getIndex' ]);
|
||||
Route::get('create', [ 'as' => 'create/model', 'uses' => 'AssetModelsController@getCreate' ]);
|
||||
Route::post('create', 'AssetModelsController@postCreate');
|
||||
Route::get('{modelId}/edit', [ 'as' => 'update/model', 'uses' => 'AssetModelsController@getEdit' ]);
|
||||
Route::post('{modelId}/edit', 'AssetModelsController@postEdit');
|
||||
Route::get('{modelId}/clone', [ 'as' => 'clone/model', 'uses' => 'AssetModelsController@getClone' ]);
|
||||
Route::post('{modelId}/clone', 'AssetModelsController@postCreate');
|
||||
Route::get('{modelId}/delete', [ 'as' => 'delete/model', 'uses' => 'AssetModelsController@getDelete' ]);
|
||||
Route::get('{modelId}/view', [ 'as' => 'view/model', 'uses' => 'AssetModelsController@getView' ]);
|
||||
Route::get('{modelID}/restore', [ 'as' => 'restore/model', 'uses' => 'AssetModelsController@getRestore' ]);
|
||||
Route::get('{modelId}/custom_fields', ['as' => 'custom_fields/model','uses' => 'AssetModelsController@getCustomFields']);
|
||||
});
|
||||
|
||||
Route::get('/', [
|
||||
'as' => 'hardware',
|
||||
'uses' => 'AssetsController@getIndex'
|
||||
]);
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Admin Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Register all the admin routes.
|
||||
|
|
||||
*/
|
||||
|
||||
Route::group([ 'prefix' => 'admin','middleware' => ['web','auth']], function () {
|
||||
|
||||
# Licenses
|
||||
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(
|
||||
'{licenseId}/checkout',
|
||||
[ 'as' => 'checkout/license', 'uses' => 'LicensesController@getCheckout' ]
|
||||
);
|
||||
Route::post('{licenseId}/checkout', 'LicensesController@postCheckout');
|
||||
Route::get(
|
||||
'{licenseId}/checkin/{backto?}',
|
||||
[ 'as' => 'checkin/license', 'uses' => 'LicensesController@getCheckin' ]
|
||||
);
|
||||
Route::post('{licenseId}/checkin/{backto?}', 'LicensesController@postCheckin');
|
||||
Route::get('{licenseId}/view', [ 'as' => 'view/license', 'uses' => 'LicensesController@getView' ]);
|
||||
Route::post(
|
||||
'{licenseId}/upload',
|
||||
[ 'as' => 'upload/license', 'uses' => 'LicensesController@postUpload' ]
|
||||
);
|
||||
Route::get(
|
||||
'{licenseId}/deletefile/{fileId}',
|
||||
[ 'as' => 'delete/licensefile', 'uses' => 'LicensesController@getDeleteFile' ]
|
||||
);
|
||||
Route::get(
|
||||
'{licenseId}/showfile/{fileId}',
|
||||
[ 'as' => 'show/licensefile', 'uses' => 'LicensesController@displayFile' ]
|
||||
);
|
||||
Route::get('/', [ 'as' => 'licenses', 'uses' => 'LicensesController@getIndex' ]);
|
||||
});
|
||||
|
||||
# Asset Maintenances
|
||||
Route::group([ 'prefix' => 'asset_maintenances', 'middleware'=>'authorize:assets.view' ], function () {
|
||||
|
||||
Route::get(
|
||||
'create/{assetId?}',
|
||||
[ 'as' => 'create/asset_maintenances', 'uses' => 'AssetMaintenancesController@getCreate' ]
|
||||
);
|
||||
Route::post('create/{assetId?}', 'AssetMaintenancesController@postCreate');
|
||||
Route::get('/', [ 'as' => 'asset_maintenances', 'uses' => 'AssetMaintenancesController@getIndex' ]);
|
||||
Route::get(
|
||||
'{assetMaintenanceId}/edit',
|
||||
[ 'as' => 'update/asset_maintenance', 'uses' => 'AssetMaintenancesController@getEdit' ]
|
||||
);
|
||||
Route::post('{assetMaintenanceId}/edit', 'AssetMaintenancesController@postEdit');
|
||||
Route::get(
|
||||
'{assetMaintenanceId}/delete',
|
||||
[ 'as' => 'delete/asset_maintenance', 'uses' => 'AssetMaintenancesController@getDelete' ]
|
||||
);
|
||||
Route::get(
|
||||
'{assetMaintenanceId}/view',
|
||||
[ 'as' => 'view/asset_maintenance', 'uses' => 'AssetMaintenancesController@getView' ]
|
||||
);
|
||||
});
|
||||
|
||||
# Accessories
|
||||
Route::group([ 'prefix' => 'accessories', 'middleware'=>'authorize:accessories.view' ], function () {
|
||||
|
||||
Route::get('create', [ 'as' => 'create/accessory', 'uses' => 'AccessoriesController@getCreate' ]);
|
||||
Route::post('create', 'AccessoriesController@postCreate');
|
||||
Route::get(
|
||||
'{accessoryID}/edit',
|
||||
[ 'as' => 'update/accessory', 'uses' => 'AccessoriesController@getEdit' ]
|
||||
);
|
||||
Route::post('{accessoryID}/edit', 'AccessoriesController@postEdit');
|
||||
Route::get(
|
||||
'{accessoryID}/delete',
|
||||
[ 'as' => 'delete/accessory', 'uses' => 'AccessoriesController@getDelete' ]
|
||||
);
|
||||
Route::get('{accessoryID}/view', [ 'as' => 'view/accessory', 'uses' => 'AccessoriesController@getView' ]);
|
||||
Route::get(
|
||||
'{accessoryID}/checkout',
|
||||
[ 'as' => 'checkout/accessory', 'uses' => 'AccessoriesController@getCheckout' ]
|
||||
);
|
||||
Route::post('{accessoryID}/checkout', 'AccessoriesController@postCheckout');
|
||||
Route::get(
|
||||
'{accessoryID}/checkin/{backto?}',
|
||||
[ 'as' => 'checkin/accessory', 'uses' => 'AccessoriesController@getCheckin' ]
|
||||
);
|
||||
Route::post('{accessoryID}/checkin/{backto?}', 'AccessoriesController@postCheckin');
|
||||
|
||||
Route::get('/', [ 'as' => 'accessories', 'uses' => 'AccessoriesController@getIndex' ]);
|
||||
});
|
||||
|
||||
# Consumables
|
||||
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(
|
||||
'{consumableID}/edit',
|
||||
[ 'as' => 'update/consumable', 'uses' => 'ConsumablesController@getEdit' ]
|
||||
);
|
||||
Route::post('{consumableID}/edit', 'ConsumablesController@postEdit');
|
||||
Route::get(
|
||||
'{consumableID}/delete',
|
||||
[ 'as' => 'delete/consumable', 'uses' => 'ConsumablesController@getDelete' ]
|
||||
);
|
||||
Route::get(
|
||||
'{consumableID}/view',
|
||||
[ 'as' => 'view/consumable', 'uses' => 'ConsumablesController@getView' ]
|
||||
);
|
||||
Route::get(
|
||||
'{consumableID}/checkout',
|
||||
[ 'as' => 'checkout/consumable', 'uses' => 'ConsumablesController@getCheckout' ]
|
||||
);
|
||||
Route::post('{consumableID}/checkout', 'ConsumablesController@postCheckout');
|
||||
Route::get('/', [ 'as' => 'consumables', 'uses' => 'ConsumablesController@getIndex' ]);
|
||||
});
|
||||
|
||||
# Components
|
||||
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(
|
||||
'{componentID}/edit',
|
||||
[ 'as' => 'update/component', 'uses' => 'ComponentsController@getEdit' ]
|
||||
);
|
||||
Route::post('{componentID}/edit', 'ComponentsController@postEdit');
|
||||
Route::get(
|
||||
'{componentID}/delete',
|
||||
[ 'as' => 'delete/component', 'uses' => 'ComponentsController@getDelete' ]
|
||||
);
|
||||
Route::get(
|
||||
'{componentID}/view',
|
||||
[ 'as' => 'view/component', 'uses' => 'ComponentsController@getView' ]
|
||||
);
|
||||
Route::get(
|
||||
'{componentID}/checkout',
|
||||
[ 'as' => 'checkout/component', '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' ]);
|
||||
});
|
||||
|
||||
# Admin Settings Routes (for categories, maufactureres, etc)
|
||||
Route::group([ 'prefix' => 'settings', 'middleware'=>'authorize:superuser'], function () {
|
||||
|
||||
|
||||
|
||||
# Settings
|
||||
Route::group([ 'prefix' => 'app' ], function () {
|
||||
|
||||
Route::post('purge', ['as' => 'purge', 'uses' => 'SettingsController@postPurge']);
|
||||
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 () {
|
||||
|
||||
|
||||
Route::get('download/{filename}', [
|
||||
'as' => 'settings/download-file',
|
||||
'uses' => 'SettingsController@downloadFile' ]);
|
||||
|
||||
Route::get('delete/{filename}', [
|
||||
'as' => 'settings/delete-file',
|
||||
'uses' => 'SettingsController@deleteFile' ]);
|
||||
|
||||
Route::post('/', [
|
||||
'as' => 'settings/backups',
|
||||
'uses' => 'SettingsController@postBackups'
|
||||
]);
|
||||
|
||||
|
||||
Route::get('/', [ 'as' => 'settings/backups', 'uses' => 'SettingsController@getBackups' ]);
|
||||
});
|
||||
|
||||
# Companies
|
||||
Route::group([ 'prefix' => 'companies' ], function () {
|
||||
|
||||
Route::get('{companyId}/edit', ['as' => 'update/company', 'uses' => 'CompaniesController@getEdit']);
|
||||
Route::get('create', ['as' => 'create/company', 'uses' => 'CompaniesController@getCreate']);
|
||||
Route::get('/', ['as' => 'companies', 'uses' => 'CompaniesController@getIndex']);
|
||||
|
||||
Route::post('{companyId}/delete', ['as' => 'delete/company', 'uses' => 'CompaniesController@postDelete']);
|
||||
Route::post('{companyId}/edit', 'CompaniesController@postEdit');
|
||||
Route::post('create', 'CompaniesController@postCreate');
|
||||
});
|
||||
|
||||
|
||||
|
||||
# Manufacturers
|
||||
Route::group([ 'prefix' => 'manufacturers' ], function () {
|
||||
|
||||
Route::get('/', [ 'as' => 'manufacturers', 'uses' => 'ManufacturersController@getIndex' ]);
|
||||
Route::get(
|
||||
'create',
|
||||
[ 'as' => 'create/manufacturer', 'uses' => 'ManufacturersController@getCreate' ]
|
||||
);
|
||||
Route::post('create', 'ManufacturersController@postCreate');
|
||||
Route::get(
|
||||
'{manufacturerId}/edit',
|
||||
[ 'as' => 'update/manufacturer', 'uses' => 'ManufacturersController@getEdit' ]
|
||||
);
|
||||
Route::post('{manufacturerId}/edit', 'ManufacturersController@postEdit');
|
||||
Route::get(
|
||||
'{manufacturerId}/delete',
|
||||
[ 'as' => 'delete/manufacturer', 'uses' => 'ManufacturersController@getDelete' ]
|
||||
);
|
||||
Route::get(
|
||||
'{manufacturerId}/view',
|
||||
[ 'as' => 'view/manufacturer', 'uses' => 'ManufacturersController@getView' ]
|
||||
);
|
||||
});
|
||||
|
||||
# Suppliers
|
||||
Route::group([ 'prefix' => 'suppliers' ], function () {
|
||||
|
||||
Route::get('/', [ 'as' => 'suppliers', 'uses' => 'SuppliersController@getIndex' ]);
|
||||
Route::get('create', [ 'as' => 'create/supplier', 'uses' => 'SuppliersController@getCreate' ]);
|
||||
Route::post('create', 'SuppliersController@postCreate');
|
||||
Route::get(
|
||||
'{supplierId}/edit',
|
||||
[ 'as' => 'update/supplier', 'uses' => 'SuppliersController@getEdit' ]
|
||||
);
|
||||
Route::post('{supplierId}/edit', 'SuppliersController@postEdit');
|
||||
Route::get(
|
||||
'{supplierId}/delete',
|
||||
[ 'as' => 'delete/supplier', 'uses' => 'SuppliersController@getDelete' ]
|
||||
);
|
||||
Route::get('{supplierId}/view', [ 'as' => 'view/supplier', 'uses' => 'SuppliersController@getView' ]);
|
||||
});
|
||||
|
||||
# Categories
|
||||
Route::group([ 'prefix' => 'categories' ], function () {
|
||||
|
||||
Route::get('create', [ 'as' => 'create/category', 'uses' => 'CategoriesController@getCreate' ]);
|
||||
Route::post('create', 'CategoriesController@postCreate');
|
||||
Route::get(
|
||||
'{categoryId}/edit',
|
||||
[ 'as' => 'update/category', 'uses' => 'CategoriesController@getEdit' ]
|
||||
);
|
||||
Route::post('{categoryId}/edit', 'CategoriesController@postEdit');
|
||||
Route::get(
|
||||
'{categoryId}/delete',
|
||||
[ 'as' => 'delete/category', 'uses' => 'CategoriesController@getDelete' ]
|
||||
);
|
||||
Route::get(
|
||||
'{categoryId}/view',
|
||||
[ 'as' => 'view/category', 'uses' => 'CategoriesController@getView' ]
|
||||
);
|
||||
Route::get('/', [ 'as' => 'categories', 'uses' => 'CategoriesController@getIndex' ]);
|
||||
});
|
||||
|
||||
# Depreciations
|
||||
Route::group([ 'prefix' => 'depreciations' ], function () {
|
||||
|
||||
Route::get('/', [ 'as' => 'depreciations', 'uses' => 'DepreciationsController@getIndex' ]);
|
||||
Route::get(
|
||||
'create',
|
||||
[ 'as' => 'create/depreciations', 'uses' => 'DepreciationsController@getCreate' ]
|
||||
);
|
||||
Route::post('create', 'DepreciationsController@postCreate');
|
||||
Route::get(
|
||||
'{depreciationId}/edit',
|
||||
[ 'as' => 'update/depreciations', 'uses' => 'DepreciationsController@getEdit' ]
|
||||
);
|
||||
Route::post('{depreciationId}/edit', 'DepreciationsController@postEdit');
|
||||
Route::get(
|
||||
'{depreciationId}/delete',
|
||||
[ 'as' => 'delete/depreciations', 'uses' => 'DepreciationsController@getDelete' ]
|
||||
);
|
||||
});
|
||||
|
||||
# Locations
|
||||
Route::group([ 'prefix' => 'locations' ], function () {
|
||||
|
||||
Route::get('/', [ 'as' => 'locations', 'uses' => 'LocationsController@getIndex' ]);
|
||||
Route::get('create', [ 'as' => 'create/location', 'uses' => 'LocationsController@getCreate' ]);
|
||||
Route::post('create', 'LocationsController@postCreate');
|
||||
Route::get(
|
||||
'{locationId}/edit',
|
||||
[ 'as' => 'update/location', 'uses' => 'LocationsController@getEdit' ]
|
||||
);
|
||||
Route::post('{locationId}/edit', 'LocationsController@postEdit');
|
||||
Route::get('{locationId}/view', 'LocationsController@getView');
|
||||
Route::get(
|
||||
'{locationId}/delete',
|
||||
[ 'as' => 'delete/location', 'uses' => 'LocationsController@getDelete' ]
|
||||
);
|
||||
});
|
||||
|
||||
# Status Labels
|
||||
Route::group([ 'prefix' => 'statuslabels' ], function () {
|
||||
|
||||
Route::get('/', [ 'as' => 'statuslabels', 'uses' => 'StatuslabelsController@getIndex' ]);
|
||||
Route::get('create', [ 'as' => 'create/statuslabel', 'uses' => 'StatuslabelsController@getCreate' ]);
|
||||
Route::post('create', 'StatuslabelsController@postCreate');
|
||||
Route::get(
|
||||
'{statuslabelId}/edit',
|
||||
[ 'as' => 'update/statuslabel', 'uses' => 'StatuslabelsController@getEdit' ]
|
||||
);
|
||||
Route::post('{statuslabelId}/edit', 'StatuslabelsController@postEdit');
|
||||
Route::get(
|
||||
'{statuslabelId}/delete',
|
||||
[ 'as' => 'delete/statuslabel', 'uses' => 'StatuslabelsController@getDelete' ]
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
# Custom fields support
|
||||
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::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', 'middleware' => ['web','auth','authorize:users.view']], function () {
|
||||
|
||||
Route::get('ldap', ['as' => 'ldap/user', 'uses' => 'UsersController@getLDAP' ]);
|
||||
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(
|
||||
'{userId}/deletefile/{fileId}',
|
||||
[ 'as' => 'delete/userfile', 'uses' => 'UsersController@getDeleteFile' ]
|
||||
);
|
||||
Route::get(
|
||||
'{userId}/showfile/{fileId}',
|
||||
[ 'as' => 'show/userfile', 'uses' => 'UsersController@displayFile' ]
|
||||
);
|
||||
|
||||
Route::post(
|
||||
'bulkedit',
|
||||
[
|
||||
'as' => 'users/bulkedit',
|
||||
'uses' => 'UsersController@postBulkEdit'
|
||||
]
|
||||
);
|
||||
Route::post(
|
||||
'bulksave',
|
||||
[
|
||||
'as' => 'users/bulksave',
|
||||
'uses' => 'UsersController@postBulkSave'
|
||||
]
|
||||
);
|
||||
|
||||
Route::get('/', [ 'as' => 'users', 'uses' => 'UsersController@getIndex' ]);
|
||||
|
||||
});
|
||||
|
||||
# Group Management
|
||||
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' ]);
|
||||
Route::post('create', 'GroupsController@postCreate');
|
||||
Route::get('{groupId}/edit', [ 'as' => 'update/group', 'uses' => 'GroupsController@getEdit' ]);
|
||||
Route::post('{groupId}/edit', 'GroupsController@postEdit');
|
||||
Route::get('{groupId}/delete', [ 'as' => 'delete/group', 'uses' => 'GroupsController@getDelete' ]);
|
||||
Route::get('{groupId}/restore', [ 'as' => 'restore/group', 'uses' => 'GroupsController@getRestore' ]);
|
||||
Route::get('{groupId}/view', [ 'as' => 'view/group', 'uses' => 'GroupsController@getView' ]);
|
||||
});
|
||||
|
||||
# Dashboard
|
||||
Route::get('/', [ 'as' => 'admin', 'uses' => 'DashboardController@getIndex' ]);
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Account Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
|
|
||||
|
|
||||
*/
|
||||
Route::group([ 'prefix' => 'account', 'middleware' => ['web', 'auth']], function () {
|
||||
|
||||
# Profile
|
||||
Route::get('profile', [ 'as' => 'profile', 'uses' => 'ProfileController@getIndex' ]);
|
||||
Route::post('profile', 'ProfileController@postIndex');
|
||||
|
||||
# View Assets
|
||||
Route::get('view-assets', [ 'as' => 'view-assets', 'uses' => 'ViewAssetsController@getIndex' ]);
|
||||
|
||||
# Accept Asset
|
||||
Route::get(
|
||||
'accept-asset/{logID}',
|
||||
[ 'as' => 'account/accept-assets', 'uses' => 'ViewAssetsController@getAcceptAsset' ]
|
||||
);
|
||||
Route::post(
|
||||
'accept-asset/{logID}',
|
||||
[ 'as' => 'account/asset-accepted', 'uses' => 'ViewAssetsController@postAcceptAsset' ]
|
||||
);
|
||||
|
||||
# Profile
|
||||
Route::get(
|
||||
'requestable-assets',
|
||||
[ 'as' => 'requestable-assets', 'uses' => 'ViewAssetsController@getRequestableIndex' ]
|
||||
);
|
||||
Route::get(
|
||||
'request-asset/{assetId}',
|
||||
[ 'as' => 'account/request-asset', 'uses' => 'ViewAssetsController@getRequestAsset' ]
|
||||
);
|
||||
|
||||
# Account Dashboard
|
||||
Route::get('/', [ 'as' => 'account', 'uses' => 'ViewAssetsController@getIndex' ]);
|
||||
|
||||
});
|
||||
|
||||
|
||||
Route::group(['middleware' => ['web','auth','authorize:reports.view']], function () {
|
||||
|
||||
Route::get(
|
||||
'reports/depreciation',
|
||||
[ 'as' => 'reports/depreciation', 'uses' => 'ReportsController@getDeprecationReport' ]
|
||||
);
|
||||
Route::get(
|
||||
'reports/export/depreciation',
|
||||
[ 'as' => 'reports/export/depreciation', 'uses' => 'ReportsController@exportDeprecationReport' ]
|
||||
);
|
||||
Route::get(
|
||||
'reports/asset_maintenances',
|
||||
[ 'as' => 'reports/asset_maintenances', 'uses' => 'ReportsController@getAssetMaintenancesReport' ]
|
||||
);
|
||||
Route::get(
|
||||
'reports/export/asset_maintenances',
|
||||
[
|
||||
'as' => 'reports/export/asset_maintenances',
|
||||
'uses' => 'ReportsController@exportAssetMaintenancesReport'
|
||||
]
|
||||
);
|
||||
Route::get(
|
||||
'reports/licenses',
|
||||
[ 'as' => 'reports/licenses', 'uses' => 'ReportsController@getLicenseReport' ]
|
||||
);
|
||||
Route::get(
|
||||
'reports/export/licenses',
|
||||
[ 'as' => 'reports/export/licenses', 'uses' => 'ReportsController@exportLicenseReport' ]
|
||||
);
|
||||
Route::get('reports/assets', [ 'as' => 'reports/assets', 'uses' => 'ReportsController@getAssetsReport' ]);
|
||||
Route::get(
|
||||
'reports/export/assets',
|
||||
[ 'as' => 'reports/export/assets', 'uses' => 'ReportsController@exportAssetReport' ]
|
||||
);
|
||||
Route::get('reports/accessories', [ 'as' => 'reports/accessories', 'uses' => 'ReportsController@getAccessoryReport' ]);
|
||||
Route::get(
|
||||
'reports/export/accessories',
|
||||
[ 'as' => 'reports/export/accessories', 'uses' => 'ReportsController@exportAccessoryReport' ]
|
||||
);
|
||||
Route::get('reports/custom', [ 'as' => 'reports/custom', 'uses' => 'ReportsController@getCustomReport' ]);
|
||||
Route::post('reports/custom', 'ReportsController@postCustom');
|
||||
|
||||
Route::get(
|
||||
'reports/activity',
|
||||
[ 'as' => 'reports/activity', 'uses' => 'ReportsController@getActivityReport' ]
|
||||
);
|
||||
Route::get(
|
||||
'reports/unaccepted_assets',
|
||||
[ 'as' => 'reports/unaccepted_assets', 'uses' => 'ReportsController@getAssetAcceptanceReport' ]
|
||||
);
|
||||
Route::get(
|
||||
'reports/export/unaccepted_assets',
|
||||
[ 'as' => 'reports/export/unaccepted_assets', 'uses' => 'ReportsController@exportAssetAcceptanceReport' ]
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Setup Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
|
|
||||
|
|
||||
*/
|
||||
Route::group([ 'prefix' => 'setup', 'middleware' => 'web'], function () {
|
||||
Route::get(
|
||||
'user',
|
||||
[
|
||||
'as' => 'setup.user',
|
||||
'uses' => 'SettingsController@getSetupUser' ]
|
||||
);
|
||||
|
||||
Route::post(
|
||||
'user',
|
||||
[
|
||||
'as' => 'setup.user.save',
|
||||
'uses' => 'SettingsController@postSaveFirstAdmin' ]
|
||||
);
|
||||
|
||||
|
||||
Route::get(
|
||||
'migrate',
|
||||
[
|
||||
'as' => 'setup.migrate',
|
||||
'uses' => 'SettingsController@getSetupMigrate' ]
|
||||
);
|
||||
|
||||
Route::get(
|
||||
'done',
|
||||
[
|
||||
'as' => 'setup.done',
|
||||
'uses' => 'SettingsController@getSetupDone' ]
|
||||
);
|
||||
|
||||
Route::get(
|
||||
'mailtest',
|
||||
[
|
||||
'as' => 'setup.mailtest',
|
||||
'uses' => 'SettingsController@ajaxTestEmail' ]
|
||||
);
|
||||
|
||||
|
||||
Route::get(
|
||||
'/',
|
||||
[
|
||||
'as' => 'setup',
|
||||
'uses' => 'SettingsController@getSetupIndex' ]
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
|
||||
Route::get(
|
||||
'/',
|
||||
[
|
||||
'as' => 'home',
|
||||
'middleware' => ['web', 'auth'],
|
||||
'uses' => 'DashboardController@getIndex' ]
|
||||
);
|
||||
|
||||
Route::group(['middleware' => 'web'], function () {
|
||||
Route::auth();
|
||||
});
|
||||
|
||||
Route::get('home', function () {
|
||||
return redirect('/');
|
||||
});
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
|
||||
abstract class Job
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queueable Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This job base class provides a central location to place any logic that
|
||||
| is shared across all of your jobs. The trait included with the class
|
||||
| provides access to the "onQueue" and "delay" queue helper methods.
|
||||
|
|
||||
*/
|
||||
|
||||
use Queueable;
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
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;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'accessories';
|
||||
|
||||
/**
|
||||
* 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',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
* is not set in the model it will default to true.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name','qty','category_id'];
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Company', 'company_id');
|
||||
}
|
||||
|
||||
public function location()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Location', 'location_id');
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Category', 'category_id')->where('category_type', '=', 'accessory');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action logs for this accessory
|
||||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'accessory_id')->where('asset_type', '=', 'accessory')->orderBy('created_at', 'desc')->withTrashed();
|
||||
}
|
||||
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\User', 'accessories_users', 'accessory_id', 'assigned_to')->withPivot('id')->withTrashed();
|
||||
}
|
||||
|
||||
public function hasUsers()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\User', 'accessories_users', 'accessory_id', 'assigned_to')->count();
|
||||
}
|
||||
|
||||
public function checkin_email()
|
||||
{
|
||||
return $this->category->checkin_email;
|
||||
}
|
||||
|
||||
public function requireAcceptance()
|
||||
{
|
||||
return $this->category->require_acceptance;
|
||||
}
|
||||
|
||||
public function getEula()
|
||||
{
|
||||
|
||||
$Parsedown = new \Parsedown();
|
||||
|
||||
if ($this->category->eula_text) {
|
||||
return $Parsedown->text(e($this->category->eula_text));
|
||||
} elseif ((Setting::getSettings()->default_eula_text) && ($this->category->use_default_eula=='1')) {
|
||||
return $Parsedown->text(e(Setting::getSettings()->default_eula_text));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function numRemaining()
|
||||
{
|
||||
$checkedout = $this->users->count();
|
||||
$total = $this->qty;
|
||||
$remaining = $total - $checkedout;
|
||||
return $remaining;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$search = explode('+', $search);
|
||||
|
||||
return $query->where(function ($query) use ($search) {
|
||||
|
||||
foreach ($search as $search) {
|
||||
$query->whereHas('category', function ($query) use ($search) {
|
||||
$query->where('categories.name', 'LIKE', '%'.$search.'%');
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('company', function ($query) use ($search) {
|
||||
$query->where('companies.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('assetlog', function ($query) use ($search) {
|
||||
$query->where('action_type', '=', 'checkout')
|
||||
->where('created_at', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('location', function ($query) use ($search) {
|
||||
$query->where('locations.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere('accessories.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('accessories.order_number', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('accessories.purchase_cost', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('accessories.purchase_date', 'LIKE', '%'.$search.'%');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 scopeOrderCompany($query, $order)
|
||||
{
|
||||
return $query->leftJoin('companies', 'accessories.company_id', '=', 'companies.id')->orderBy('companies.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
|
||||
*/
|
||||
public function scopeOrderCategory($query, $order)
|
||||
{
|
||||
return $query->leftJoin('categories', 'accessories.category_id', '=', 'categories.id')->orderBy('categories.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
|
||||
*/
|
||||
public function scopeOrderLocation($query, $order)
|
||||
{
|
||||
return $query->leftJoin('locations', 'consumables.location_id', '=', 'locations.id')->orderBy('locations.name', $order);
|
||||
}
|
||||
}
|
||||
@@ -1,177 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
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
|
||||
* checkouts, checkins, and updates).
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class Actionlog extends Model implements ICompanyableChild
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableChildTrait;
|
||||
|
||||
protected $dates = [ 'deleted_at' ];
|
||||
|
||||
protected $table = 'asset_logs';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [ 'created_at', 'asset_type' ];
|
||||
|
||||
public function getCompanyableParents()
|
||||
{
|
||||
return [ 'accessorylog', 'assetlog', 'licenselog', 'consumablelog' ];
|
||||
}
|
||||
|
||||
public function assetlog()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\Asset', 'asset_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function uploads()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\Asset', 'asset_id')
|
||||
->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->belongsTo('\App\Models\User', 'checkedout_to')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function childlogs()
|
||||
{
|
||||
|
||||
return $this->hasMany('\App\Models\ActionLog', 'thread_id');
|
||||
}
|
||||
|
||||
public function parentlog()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\ActionLog', 'thread_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the file exists, and if it does, force a download
|
||||
**/
|
||||
public function get_src($type = 'assets')
|
||||
{
|
||||
|
||||
$file = config('app.private_uploads') . '/' . $type . '/' . $this->filename;
|
||||
|
||||
return $file;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent category name
|
||||
*/
|
||||
public function logaction($actiontype)
|
||||
{
|
||||
|
||||
$this->action_type = $actiontype;
|
||||
|
||||
if ($this->save()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getListingOfActionLogsChronologicalOrder
|
||||
*
|
||||
* @return mixed
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public function getListingOfActionLogsChronologicalOrder()
|
||||
{
|
||||
|
||||
return DB::table('asset_logs')
|
||||
->select('*')
|
||||
->where('action_type', '!=', 'uploaded')
|
||||
->orderBy('asset_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,897 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Company;
|
||||
use App\Models\Location;
|
||||
use Config;
|
||||
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;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* Model for Assets.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class Asset extends Depreciable
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'assets';
|
||||
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
* is not set in the model it will default to true.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
protected $rules = [
|
||||
'name' => 'min:2|max:255',
|
||||
'model_id' => 'required|integer',
|
||||
'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',
|
||||
'supplier_id' => 'integer',
|
||||
'asset_tag' => 'required|min:1|max:255|unique:assets,asset_tag,NULL,deleted_at',
|
||||
'status' => 'integer',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name','model_id','status_id','asset_tag'];
|
||||
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Company', 'company_id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checkout asset
|
||||
*/
|
||||
public function checkOutToUser($user, $admin, $checkout_at = null, $expected_checkin = null, $note = null, $name = null)
|
||||
{
|
||||
|
||||
if ($expected_checkin) {
|
||||
$this->expected_checkin = $expected_checkin ;
|
||||
}
|
||||
|
||||
$this->last_checkout = $checkout_at;
|
||||
|
||||
$this->assigneduser()->associate($user);
|
||||
$this->name = $name;
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
if ($this->requireAcceptance()) {
|
||||
$this->accepted="pending";
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->save()) {
|
||||
|
||||
// $action, $admin, $user, $expected_checkin = null, $note = null, $checkout_at = null
|
||||
$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);
|
||||
}
|
||||
|
||||
if ($settings->slack_endpoint) {
|
||||
$this->checkOutNotifySlack($settings, $admin, $note);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public function checkOutNotifyMail($log_id, $user, $checkout_at, $expected_checkin, $note)
|
||||
{
|
||||
$data['log_id'] = $log_id;
|
||||
$data['eula'] = $this->getEula();
|
||||
$data['first_name'] = $user->first_name;
|
||||
$data['item_name'] = $this->showAssetName();
|
||||
$data['checkout_date'] = $checkout_at;
|
||||
$data['expected_checkin'] = $expected_checkin;
|
||||
$data['item_tag'] = $this->asset_tag;
|
||||
$data['note'] = $note;
|
||||
$data['item_serial'] = $this->serial;
|
||||
$data['require_acceptance'] = $this->requireAcceptance();
|
||||
|
||||
if ((($this->requireAcceptance()=='1') || ($this->getEula())) && (!config('app.lock_passwords'))) {
|
||||
|
||||
\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');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function checkOutNotifySlack($settings, $admin, $note = null)
|
||||
{
|
||||
|
||||
if ($settings->slack_endpoint) {
|
||||
|
||||
$slack_settings = [
|
||||
'username' => $settings->botname,
|
||||
'channel' => $settings->slack_channel,
|
||||
'link_names' => true
|
||||
];
|
||||
|
||||
$client = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);
|
||||
|
||||
try {
|
||||
$client->attach([
|
||||
'color' => 'good',
|
||||
'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').'/admin/users/'.Auth::user()->id.'/view'.'|'.$admin->fullName().'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
'value' => e($note)
|
||||
],
|
||||
]
|
||||
])->send('Asset Checked Out');
|
||||
|
||||
} catch (Exception $e) {
|
||||
LOG::error($e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getDetailedNameAttribute()
|
||||
{
|
||||
if ($this->assigned_user) {
|
||||
$user_name = $user->fullName();
|
||||
} else {
|
||||
$user_name = "Unassigned";
|
||||
}
|
||||
return $this->asset_tag . ' - ' . $this->name . ' (' . $user_name . ') ' . $this->model->name;
|
||||
}
|
||||
public function validationRules($id = '0')
|
||||
{
|
||||
return $this->rules;
|
||||
}
|
||||
|
||||
|
||||
public function createLogRecord($action, $asset, $admin, $user, $expected_checkin = null, $note = null, $checkout_at = null)
|
||||
{
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $this->id;
|
||||
$logaction->checkedout_to = $this->assigned_to;
|
||||
$logaction->asset_type = 'hardware';
|
||||
$logaction->note = $note;
|
||||
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 {
|
||||
$logaction->created_at = \Carbon\Carbon::now();
|
||||
}
|
||||
|
||||
if ($action=="checkout") {
|
||||
if ($user) {
|
||||
$logaction->location_id = $user->location_id;
|
||||
}
|
||||
} 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->location_id = null;
|
||||
$logaction->asset_type = 'hardware';
|
||||
$logaction->note = $note;
|
||||
$logaction->user_id = $admin->id;
|
||||
}
|
||||
$logaction->adminlog()->associate($admin);
|
||||
$log = $logaction->logaction($action);
|
||||
|
||||
return $logaction;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set depreciation relationship
|
||||
*/
|
||||
public function depreciation()
|
||||
{
|
||||
return $this->model->belongsTo('\App\Models\Depreciation', 'depreciation_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get components assigned to this asset
|
||||
*/
|
||||
public function components()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\Component', 'components_assets', 'asset_id', 'component_id')->withPivot('id')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get depreciation attribute from associated asset model
|
||||
*/
|
||||
public function get_depreciation()
|
||||
{
|
||||
return $this->model->depreciation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get uploads for this asset
|
||||
*/
|
||||
public function uploads()
|
||||
{
|
||||
|
||||
return $this->hasMany('\App\Models\Actionlog', 'asset_id')
|
||||
->where('asset_type', '=', 'hardware')
|
||||
->where('action_type', '=', 'uploaded')
|
||||
->whereNotNull('filename')
|
||||
->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
public function assigneduser()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\User', 'assigned_to')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the asset's location based on the assigned user
|
||||
**/
|
||||
public function assetloc()
|
||||
{
|
||||
if ($this->assigneduser) {
|
||||
return $this->assigneduser->userloc();
|
||||
} else {
|
||||
return $this->belongsTo('\App\Models\Location', 'rtd_location_id');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the asset's location based on default RTD location
|
||||
**/
|
||||
public function defaultLoc()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Location', 'rtd_location_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action logs for this asset
|
||||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'asset_id')
|
||||
->where('asset_type', '=', 'hardware')
|
||||
->orderBy('created_at', 'desc')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* assetmaintenances
|
||||
* Get improvements for this asset
|
||||
*
|
||||
* @return mixed
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public function assetmaintenances()
|
||||
{
|
||||
|
||||
return $this->hasMany('\App\Models\AssetMaintenance', 'asset_id')
|
||||
->orderBy('created_at', 'desc')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action logs for this asset
|
||||
*/
|
||||
public function adminuser()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\User', 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total assets
|
||||
*/
|
||||
public static function assetcount()
|
||||
{
|
||||
|
||||
return Asset::where('physical', '=', '1')
|
||||
->whereNull('deleted_at', 'and')
|
||||
->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total assets not checked out
|
||||
*/
|
||||
public static function availassetcount()
|
||||
{
|
||||
|
||||
return Asset::RTD()
|
||||
->whereNull('deleted_at')
|
||||
->count();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get requestable assets
|
||||
*/
|
||||
public static function getRequestable()
|
||||
{
|
||||
|
||||
return Asset::Requestable()
|
||||
->whereNull('deleted_at')
|
||||
->count();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get asset status
|
||||
*/
|
||||
public function assetstatus()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Statuslabel', 'status_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name for EULA
|
||||
**/
|
||||
public function showAssetName()
|
||||
{
|
||||
|
||||
if ($this->name == '') {
|
||||
return $this->model->name;
|
||||
} else {
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
||||
public function warrantee_expires()
|
||||
{
|
||||
$date = date_create($this->purchase_date);
|
||||
date_add($date, date_interval_create_from_date_string($this->warranty_months . ' months'));
|
||||
return date_format($date, 'Y-m-d');
|
||||
}
|
||||
|
||||
|
||||
public function model()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\AssetModel', 'model_id')->withTrashed();
|
||||
}
|
||||
|
||||
public static function getExpiringWarrantee($days = 30)
|
||||
{
|
||||
|
||||
return Asset::where('archived', '=', '0')
|
||||
->whereNotNull('warranty_months')
|
||||
->whereNotNull('purchase_date')
|
||||
->whereNull('deleted_at')
|
||||
->whereRaw(\DB::raw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH) <= DATE(NOW() + INTERVAL '
|
||||
. $days
|
||||
. ' DAY) AND DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH) > NOW()'))
|
||||
->orderBy('purchase_date', 'ASC')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the license seat information
|
||||
**/
|
||||
public function licenses()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\License', 'license_seats', 'asset_id', 'license_id');
|
||||
}
|
||||
|
||||
public function licenseseats()
|
||||
{
|
||||
return $this->hasMany('\App\Models\LicenseSeat', 'asset_id');
|
||||
}
|
||||
|
||||
public function supplier()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Supplier', 'supplier_id');
|
||||
}
|
||||
|
||||
public function months_until_eol()
|
||||
{
|
||||
|
||||
$today = date("Y-m-d");
|
||||
$d1 = new DateTime($today);
|
||||
$d2 = new DateTime($this->eol_date());
|
||||
|
||||
if ($this->eol_date() > $today) {
|
||||
$interval = $d2->diff($d1);
|
||||
} else {
|
||||
$interval = null;
|
||||
}
|
||||
|
||||
return $interval;
|
||||
}
|
||||
|
||||
public function eol_date()
|
||||
{
|
||||
|
||||
if (( $this->purchase_date ) && ( $this->model )) {
|
||||
$date = date_create($this->purchase_date);
|
||||
date_add($date, date_interval_create_from_date_string($this->model->eol . ' months'));
|
||||
return date_format($date, 'Y-m-d');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get auto-increment
|
||||
*/
|
||||
public static function autoincrement_asset()
|
||||
{
|
||||
|
||||
$settings = \App\Models\Setting::getSettings();
|
||||
|
||||
if ($settings->auto_increment_assets == '1') {
|
||||
$asset_tag = \DB::table('assets')
|
||||
->where('physical', '=', '1')
|
||||
->max('id');
|
||||
return $settings->auto_increment_prefix.($asset_tag + 1);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkin_email()
|
||||
{
|
||||
return $this->model->category->checkin_email;
|
||||
}
|
||||
|
||||
public function requireAcceptance()
|
||||
{
|
||||
return $this->model->category->require_acceptance;
|
||||
}
|
||||
|
||||
public function getEula()
|
||||
{
|
||||
|
||||
$Parsedown = new \Parsedown();
|
||||
|
||||
if ($this->model->category->eula_text) {
|
||||
return $Parsedown->text(e($this->model->category->eula_text));
|
||||
} elseif ($this->model->category->use_default_eula == '1') {
|
||||
return $Parsedown->text(e(Setting::getSettings()->default_eula_text));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* -----------------------------------------------
|
||||
* BEGIN QUERY SCOPES
|
||||
* -----------------------------------------------
|
||||
**/
|
||||
|
||||
/**
|
||||
* Query builder scope for hardware
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
|
||||
public function scopeHardware($query)
|
||||
{
|
||||
|
||||
return $query->where('physical', '=', '1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope for pending assets
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
|
||||
public function scopePending($query)
|
||||
{
|
||||
|
||||
return $query->whereHas('assetstatus', function ($query) {
|
||||
|
||||
$query->where('deployable', '=', 0)
|
||||
->where('pending', '=', 1)
|
||||
->where('archived', '=', 0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope for pending assets
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
|
||||
public function scopeAssetsByLocation($query, $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) {
|
||||
|
||||
$query->where('assets.rtd_location_id', '=', $location->id);
|
||||
$query->whereNull('assets.assigned_to');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope for RTD assets
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
|
||||
public function scopeRTD($query)
|
||||
{
|
||||
|
||||
return $query->whereNULL('assigned_to')
|
||||
->whereHas('assetstatus', function ($query) {
|
||||
|
||||
$query->where('deployable', '=', 1)
|
||||
->where('pending', '=', 0)
|
||||
->where('archived', '=', 0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope for Undeployable assets
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
|
||||
public function scopeUndeployable($query)
|
||||
{
|
||||
|
||||
return $query->whereHas('assetstatus', function ($query) {
|
||||
|
||||
$query->where('deployable', '=', 0)
|
||||
->where('pending', '=', 0)
|
||||
->where('archived', '=', 0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope for Archived assets
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
|
||||
public function scopeArchived($query)
|
||||
{
|
||||
|
||||
return $query->whereHas('assetstatus', function ($query) {
|
||||
|
||||
$query->where('deployable', '=', 0)
|
||||
->where('pending', '=', 0)
|
||||
->where('archived', '=', 1);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope for Deployed assets
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
|
||||
public function scopeDeployed($query)
|
||||
{
|
||||
|
||||
return $query->where('assigned_to', '>', '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope for Requestable assets
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
|
||||
public function scopeRequestableAssets($query)
|
||||
{
|
||||
|
||||
return $query->where('requestable', '=', 1)
|
||||
->whereHas('assetstatus', function ($query) {
|
||||
|
||||
$query->where('deployable', '=', 1)
|
||||
->where('pending', '=', 0)
|
||||
->where('archived', '=', 0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* scopeInModelList
|
||||
* Get all assets in the provided listing of model ids
|
||||
*
|
||||
* @param $query
|
||||
* @param array $modelIdListing
|
||||
*
|
||||
* @return mixed
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public function scopeInModelList($query, array $modelIdListing)
|
||||
{
|
||||
return $query->whereIn('model_id', $modelIdListing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to get not-yet-accepted assets
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeNotYetAccepted($query)
|
||||
{
|
||||
return $query->where("accepted", "=", "pending");
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to get rejected assets
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeRejected($query)
|
||||
{
|
||||
return $query->where("accepted", "=", "rejected");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope to get accepted assets
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeAccepted($query)
|
||||
{
|
||||
return $query->where("accepted", "=", "accepted");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope to search on text for complex Bootstrap Tables API
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $search Search term
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeTextSearch($query, $search)
|
||||
{
|
||||
$search = explode(' OR ', $search);
|
||||
|
||||
return $query->where(function ($query) use ($search) {
|
||||
|
||||
foreach ($search as $search) {
|
||||
$query->whereHas('model', function ($query) use ($search) {
|
||||
$query->whereHas('category', function ($query) use ($search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->where('categories.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('models.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('models.modelno', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
});
|
||||
})->orWhereHas('model', function ($query) use ($search) {
|
||||
$query->whereHas('manufacturer', function ($query) use ($search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->where('manufacturers.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
});
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('assetstatus', function ($query) use ($search) {
|
||||
$query->where('status_labels.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('company', function ($query) use ($search) {
|
||||
$query->where('companies.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('defaultLoc', function ($query) use ($search) {
|
||||
$query->where('locations.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('assigneduser', function ($query) use ($search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->where('users.first_name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('users.last_name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('userloc', function ($query) use ($search) {
|
||||
$query->where('locations.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})->orWhere('assets.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets.asset_tag', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets.serial', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets.order_number', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('assets.notes', 'LIKE', '%'.$search.'%');
|
||||
}
|
||||
foreach (CustomField::all() as $field) {
|
||||
$query->orWhere($field->db_column_name(), 'LIKE', "%$search%");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on model
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderModels($query, $order)
|
||||
{
|
||||
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
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderAssigned($query, $order)
|
||||
{
|
||||
return $query->join('users', 'assets.assigned_to', '=', 'users.id')->orderBy('users.first_name', $order)->orderBy('users.last_name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on status
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderStatus($query, $order)
|
||||
{
|
||||
return $query->join('status_labels', 'assets.status_id', '=', 'status_labels.id')->orderBy('status_labels.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
|
||||
*/
|
||||
public function scopeOrderCompany($query, $order)
|
||||
{
|
||||
return $query->leftJoin('companies', 'assets.company_id', '=', 'companies.id')->orderBy('companies.name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on category
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderCategory($query, $order)
|
||||
{
|
||||
return $query->join('models', 'assets.model_id', '=', 'models.id')
|
||||
->join('categories', 'models.category_id', '=', 'categories.id')
|
||||
->orderBy('categories.name', $order);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope to order on manufacturer
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderManufacturer($query, $order)
|
||||
{
|
||||
return $query->join('models', 'assets.model_id', '=', 'models.id')
|
||||
->join('manufacturers', 'models.manufacturer_id', '=', 'manufacturers.id')
|
||||
->orderBy('manufacturers.name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on location
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
* TODO: Extend this method out for checked out assets as well. Right now it
|
||||
* only checks the location name related to rtd_location_id
|
||||
*/
|
||||
public function scopeOrderLocation($query, $order)
|
||||
{
|
||||
return $query->join('locations', 'locations.id', '=', 'assets.rtd_location_id')->orderBy('locations.name', $order);
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Model for Asset Maintenances.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class AssetMaintenance extends Model implements ICompanyableChild
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableChildTrait;
|
||||
use ValidatingTrait;
|
||||
|
||||
|
||||
protected $dates = [ 'deleted_at' ];
|
||||
protected $table = 'asset_maintenances';
|
||||
|
||||
// Declaring rules for form validation
|
||||
protected $rules = [
|
||||
'asset_id' => 'required|integer',
|
||||
'supplier_id' => 'required|integer',
|
||||
'asset_maintenance_type' => 'required',
|
||||
'title' => 'required|max:100',
|
||||
'is_warranty' => 'boolean',
|
||||
'start_date' => 'required|date_format:Y-m-d',
|
||||
'completion_date' => 'date_format:Y-m-d',
|
||||
'notes' => 'string',
|
||||
'cost' => 'numeric'
|
||||
];
|
||||
|
||||
public function getCompanyableParents()
|
||||
{
|
||||
return [ 'asset' ];
|
||||
}
|
||||
|
||||
/**
|
||||
* getImprovementOptions
|
||||
*
|
||||
* @return array
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public static function getImprovementOptions()
|
||||
{
|
||||
|
||||
return [
|
||||
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')
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* asset
|
||||
* Get asset for this improvement
|
||||
*
|
||||
* @return mixed
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public function asset()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\Asset', 'asset_id')
|
||||
->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()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\Supplier', 'supplier_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* -----------------------------------------------
|
||||
* BEGIN QUERY SCOPES
|
||||
* -----------------------------------------------
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* 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('title', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('notes', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('asset_maintenance_type', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('cost', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('start_date', 'LIKE', '%'.$search.'%')
|
||||
->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,164 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Model for Asset Models. Asset Models contain higher level
|
||||
* attributes that are common among the same type of asset.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class AssetModel extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'models';
|
||||
|
||||
// Declare the rules for the model validation
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:1|max:255',
|
||||
'modelno' => 'min:1|max:255',
|
||||
'category_id' => 'required|integer',
|
||||
'manufacturer_id' => 'required|integer',
|
||||
'eol' => 'integer:min:0|max:240',
|
||||
'user_id' => 'integer',
|
||||
);
|
||||
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
* is not set in the model it will default to true.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name','manufacturer_id','category_id','eol'];
|
||||
|
||||
|
||||
|
||||
public function assets()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Asset', 'model_id');
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Category', 'category_id');
|
||||
}
|
||||
|
||||
public function depreciation()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Depreciation', 'depreciation_id');
|
||||
}
|
||||
|
||||
public function adminuser()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\User', 'user_id');
|
||||
}
|
||||
|
||||
public function manufacturer()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Manufacturer', 'manufacturer_id');
|
||||
}
|
||||
|
||||
public function fieldset()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\CustomFieldset', 'fieldset_id');
|
||||
}
|
||||
|
||||
public function getNote()
|
||||
{
|
||||
|
||||
$Parsedown = new \Parsedown();
|
||||
|
||||
if ($this->note) {
|
||||
return $Parsedown->text(e($this->note));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function displayModelName()
|
||||
{
|
||||
$name = $this->manufacturer->name.' '.$this->name;
|
||||
if ($this->modelno) {
|
||||
$name .=" / ".$this->modelno;
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* -----------------------------------------------
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* scopeInCategory
|
||||
* Get all models that are in the array of category ids
|
||||
*
|
||||
* @param $query
|
||||
* @param array $categoryIdListing
|
||||
*
|
||||
* @return mixed
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public function scopeInCategory($query, array $categoryIdListing)
|
||||
{
|
||||
|
||||
return $query->whereIn('category_id', $categoryIdListing);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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('name', 'LIKE', "%$search%")
|
||||
->orWhere('modelno', 'LIKE', "%$search%")
|
||||
->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('depreciation', function ($query) use ($search) {
|
||||
$query->where('name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})
|
||||
->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('category', function ($query) use ($search) {
|
||||
$query->where('name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})
|
||||
->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('manufacturer', function ($query) use ($search) {
|
||||
$query->where('name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Model for Categories. Categories are a higher-level group
|
||||
* than Asset Models, and handle things like whether or not
|
||||
* to require acceptance from the user, whether or not to
|
||||
* send a EULA to the user, etc.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'categories';
|
||||
|
||||
/**
|
||||
* Category validation rules
|
||||
*/
|
||||
public $rules = array(
|
||||
'user_id' => 'numeric',
|
||||
'name' => 'required|min:1|max:255|unique:categories,name,NULL,deleted_at',
|
||||
'category_type' => 'required',
|
||||
);
|
||||
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
* is not set in the model it will default to true.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name','category_type'];
|
||||
|
||||
|
||||
public function has_models()
|
||||
{
|
||||
return $this->hasMany('\App\Models\AssetModel', 'category_id')->count();
|
||||
}
|
||||
|
||||
public function accessories()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Accessory');
|
||||
}
|
||||
|
||||
public function consumables()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Consumable');
|
||||
}
|
||||
|
||||
public function components()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Component');
|
||||
}
|
||||
|
||||
public function itemCount()
|
||||
{
|
||||
switch ($this->category_type) {
|
||||
case 'asset':
|
||||
return $this->assets->count();
|
||||
case 'accessory':
|
||||
return $this->accessories->count();
|
||||
case 'component':
|
||||
return $this->components->count();
|
||||
case 'consumable':
|
||||
return $this->consumables->count();
|
||||
}
|
||||
return '0';
|
||||
}
|
||||
|
||||
public function assets()
|
||||
{
|
||||
return $this->hasManyThrough('\App\Models\Asset', '\App\Models\AssetModel', 'category_id', 'model_id');
|
||||
}
|
||||
|
||||
public function models()
|
||||
{
|
||||
return $this->hasMany('\App\Models\AssetModel', 'category_id');
|
||||
}
|
||||
|
||||
public function getEula()
|
||||
{
|
||||
|
||||
$Parsedown = new \Parsedown();
|
||||
|
||||
if ($this->eula_text) {
|
||||
return $Parsedown->text(e($this->eula_text));
|
||||
} elseif ((Setting::getSettings()->default_eula_text) && ($this->use_default_eula=='1')) {
|
||||
return $Parsedown->text(e(Setting::getSettings()->default_eula_text));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* scopeRequiresAcceptance
|
||||
*
|
||||
* @param $query
|
||||
*
|
||||
* @return mixed
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public function scopeRequiresAcceptance($query)
|
||||
{
|
||||
|
||||
return $query->where('require_acceptance', '=', 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
|
||||
*/
|
||||
public function scopeTextSearch($query, $search)
|
||||
{
|
||||
|
||||
return $query->where(function ($query) use ($search) {
|
||||
|
||||
$query->where('name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('category_type', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use Auth;
|
||||
use DB;
|
||||
|
||||
/**
|
||||
* Model for Companies.
|
||||
*
|
||||
* @version v1.8
|
||||
*/
|
||||
final class Company extends Model
|
||||
{
|
||||
protected $table = 'companies';
|
||||
|
||||
// Declare the rules for the model validation
|
||||
protected $rules = ['name' => 'required|min:1|max:255|unique:companies,name'];
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
* is not set in the model it will default to true.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name'];
|
||||
|
||||
private static function isFullMultipleCompanySupportEnabled()
|
||||
{
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
// NOTE: this can happen when seeding the database
|
||||
if (is_null($settings)) {
|
||||
return false;
|
||||
} else {
|
||||
return $settings->full_multiple_companies_support == 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static function scopeCompanyablesDirectly($query, $column = 'company_id')
|
||||
{
|
||||
if (Auth::user()) {
|
||||
$company_id = Auth::user()->company_id;
|
||||
} else {
|
||||
$company_id = null;
|
||||
}
|
||||
|
||||
if ($company_id == null) {
|
||||
return $query;
|
||||
} else {
|
||||
return $query->where($column, '=', $company_id);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSelectList()
|
||||
{
|
||||
$select_company = trans('general.select_company');
|
||||
return ['0' => $select_company] + DB::table('companies')->orderBy('name', 'ASC')->lists('name', 'id');
|
||||
}
|
||||
|
||||
public static function getIdFromInput($unescaped_input)
|
||||
{
|
||||
$escaped_input = e($unescaped_input);
|
||||
|
||||
if ($escaped_input == '0') {
|
||||
return null;
|
||||
} else {
|
||||
return $escaped_input;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getIdForCurrentUser($unescaped_input)
|
||||
{
|
||||
if (!static::isFullMultipleCompanySupportEnabled()) {
|
||||
return static::getIdFromInput($unescaped_input);
|
||||
} else {
|
||||
$current_user = Auth::user();
|
||||
|
||||
if ($current_user->company_id != null) {
|
||||
return $current_user->company_id;
|
||||
} else {
|
||||
return static::getIdFromInput($unescaped_input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function isCurrentUserHasAccess($companyable)
|
||||
{
|
||||
if (is_null($companyable)) {
|
||||
return false;
|
||||
} elseif (!static::isFullMultipleCompanySupportEnabled()) {
|
||||
return true;
|
||||
} 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 || Auth::user()->isSuperUser());
|
||||
}
|
||||
}
|
||||
|
||||
public static function isCurrentUserAuthorized()
|
||||
{
|
||||
|
||||
return ((!static::isFullMultipleCompanySupportEnabled()) || (Auth::user()->company_id == null) || (Auth::user()->isSuperUser()));
|
||||
}
|
||||
|
||||
public static function canManageUsersCompanies()
|
||||
{
|
||||
return (!static::isFullMultipleCompanySupportEnabled() || Auth::user()->isSuperUser() ||
|
||||
Auth::user()->company_id == null);
|
||||
}
|
||||
|
||||
public static function getIdForUser($unescaped_input)
|
||||
{
|
||||
if (!static::isFullMultipleCompanySupportEnabled() || Auth::user()->isSuperUser()) {
|
||||
return static::getIdFromInput($unescaped_input);
|
||||
} else {
|
||||
return static::getIdForCurrentUser($unescaped_input);
|
||||
}
|
||||
}
|
||||
|
||||
public static function scopeCompanyables($query, $column = 'company_id')
|
||||
{
|
||||
if (!static::isFullMultipleCompanySupportEnabled() || (Auth::check() && Auth::user()->isSuperUser())) {
|
||||
return $query;
|
||||
} else {
|
||||
return static::scopeCompanyablesDirectly($query, $column);
|
||||
}
|
||||
}
|
||||
|
||||
public static function scopeCompanyableChildren(array $companyable_names, $query)
|
||||
{
|
||||
if (count($companyable_names) == 0) {
|
||||
throw new Exception('No Companyable Children to scope');
|
||||
} elseif (!static::isFullMultipleCompanySupportEnabled()) {
|
||||
return $query;
|
||||
} else {
|
||||
$f = function ($q) {
|
||||
|
||||
static::scopeCompanyablesDirectly($q);
|
||||
};
|
||||
|
||||
$q = $query->where(function ($q) use ($companyable_names, $f) {
|
||||
$q2 = $q->whereHas($companyable_names[0], $f);
|
||||
|
||||
for ($i = 1; $i < count($companyable_names); $i++) {
|
||||
$q2 = $q2->orWhereHas($companyable_names[$i], $f);
|
||||
}
|
||||
});
|
||||
return $q;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getName($companyable)
|
||||
{
|
||||
$company = $companyable->company;
|
||||
|
||||
if (is_null($company)) {
|
||||
return '';
|
||||
} else {
|
||||
return e($company->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use \Illuminate\Database\Eloquent\Builder;
|
||||
use \Illuminate\Database\Eloquent\Scope;
|
||||
|
||||
/**
|
||||
* Handle query scoping for full company support.
|
||||
*
|
||||
* @todo Move this to a more Laravel 5.2 esque way
|
||||
* @version v1.0
|
||||
*/
|
||||
final class CompanyableChildScope implements Scope
|
||||
{
|
||||
/**
|
||||
* Apply the scope to a given Eloquent query builder.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $builder
|
||||
* @return void
|
||||
*/
|
||||
public function apply(Builder $builder, Model $model)
|
||||
{
|
||||
$model = $builder->getModel();
|
||||
return Company::scopeCompanyableChildren($model->getCompanyableParents(), $builder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo IMPLEMENT
|
||||
* Remove the scope from the given Eloquent query builder.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $builder
|
||||
* @return void
|
||||
*/
|
||||
public function remove(Builder $builder)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
trait CompanyableChildTrait
|
||||
{
|
||||
/**
|
||||
* Boot the companyable trait for a model.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function bootCompanyableChildTrait()
|
||||
{
|
||||
static::addGlobalScope(new CompanyableChildScope);
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use \Illuminate\Database\Eloquent\Builder;
|
||||
use \Illuminate\Database\Eloquent\Scope;
|
||||
|
||||
/**
|
||||
* Handle query scoping for full company support.
|
||||
*
|
||||
* @todo Move this to a more Laravel 5.2 esque way
|
||||
* @version v1.0
|
||||
*/
|
||||
final class CompanyableScope implements Scope
|
||||
{
|
||||
/**
|
||||
* Apply the scope to a given Eloquent query builder.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $builder
|
||||
* @return void
|
||||
*/
|
||||
public function apply(Builder $builder, Model $model)
|
||||
{
|
||||
return Company::scopeCompanyables($builder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo IMPLEMENT
|
||||
* Remove the scope from the given Eloquent query builder.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $builder
|
||||
* @return void
|
||||
*/
|
||||
public function remove(Builder $builder)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
trait CompanyableTrait
|
||||
{
|
||||
/**
|
||||
* Boot the companyable trait for a model.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function bootCompanyableTrait()
|
||||
{
|
||||
static::addGlobalScope(new CompanyableScope);
|
||||
}
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
<?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 Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Model for Components.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class Component extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableTrait;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'components';
|
||||
|
||||
|
||||
/**
|
||||
* Category validation rules
|
||||
*/
|
||||
public $rules = array(
|
||||
'name' => 'required|min:3|max:255',
|
||||
'total_qty' => 'required|integer|min:1',
|
||||
'category_id' => 'required|integer',
|
||||
'company_id' => 'integer',
|
||||
'purchase_date' => 'date',
|
||||
);
|
||||
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
* is not set in the model it will default to true.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name','company_id','category_id'];
|
||||
|
||||
public function location()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Location', 'location_id');
|
||||
}
|
||||
|
||||
public function assets()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\Asset', 'components_assets')->withPivot('assigned_qty', 'created_at', 'user_id');
|
||||
}
|
||||
|
||||
public function admin()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\User', 'user_id');
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Company', 'company_id');
|
||||
}
|
||||
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Category', 'category_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action logs for this consumable
|
||||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'component_id')->where('asset_type', '=', 'component')->orderBy('created_at', 'desc')->withTrashed();
|
||||
}
|
||||
|
||||
|
||||
public function numRemaining()
|
||||
{
|
||||
$checkedout = 0;
|
||||
|
||||
foreach ($this->assets as $checkout) {
|
||||
$checkedout += $checkout->pivot->assigned_qty;
|
||||
}
|
||||
|
||||
|
||||
$total = $this->total_qty;
|
||||
$remaining = $total - $checkedout;
|
||||
return $remaining;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$search = explode(' ', $search);
|
||||
|
||||
return $query->where(function ($query) use ($search) {
|
||||
|
||||
foreach ($search as $search) {
|
||||
$query->whereHas('category', function ($query) use ($search) {
|
||||
$query->where('categories.name', 'LIKE', '%'.$search.'%');
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('company', function ($query) use ($search) {
|
||||
$query->where('companies.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('location', function ($query) use ($search) {
|
||||
$query->where('locations.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere('components.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('components.order_number', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('components.purchase_cost', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('components.purchase_date', 'LIKE', '%'.$search.'%');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 scopeOrderCategory($query, $order)
|
||||
{
|
||||
return $query->join('categories', 'components.category_id', '=', 'categories.id')->orderBy('categories.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
|
||||
*/
|
||||
public function scopeOrderLocation($query, $order)
|
||||
{
|
||||
return $query->leftJoin('locations', 'components.location_id', '=', 'locations.id')->orderBy('locations.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
|
||||
*/
|
||||
public function scopeOrderCompany($query, $order)
|
||||
{
|
||||
return $query->leftJoin('companies', 'components.company_id', '=', 'companies.id')->orderBy('companies.name', $order);
|
||||
}
|
||||
}
|
||||
@@ -1,227 +0,0 @@
|
||||
<?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 Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Consumable extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableTrait;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'consumables';
|
||||
|
||||
|
||||
/**
|
||||
* Category validation rules
|
||||
*/
|
||||
public $rules = array(
|
||||
'name' => 'required|min:3|max:255',
|
||||
'qty' => 'required|integer|min:0',
|
||||
'category_id' => 'required|integer',
|
||||
'company_id' => 'integer',
|
||||
'min_amt' => 'integer|min:1',
|
||||
);
|
||||
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
* is not set in the model it will default to true.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name','qty','company_id','category_id'];
|
||||
|
||||
|
||||
public function admin()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\User', 'user_id');
|
||||
}
|
||||
|
||||
public function consumableAssigments()
|
||||
{
|
||||
return $this->hasMany('\App\Models\ConsumableAssignment');
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Company', 'company_id');
|
||||
}
|
||||
|
||||
public function manufacturer()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Manufacturer', 'manufacturer_id');
|
||||
}
|
||||
|
||||
public function location()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Location', 'location_id');
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Category', 'category_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action logs for this consumable
|
||||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'consumable_id')->where('asset_type', '=', 'consumable')->orderBy('created_at', 'desc')->withTrashed();
|
||||
}
|
||||
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\User', 'consumables_users', 'consumable_id', 'assigned_to')->withPivot('user_id')->withTrashed()->withTimestamps();
|
||||
}
|
||||
|
||||
public function hasUsers()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\User', 'consumables_users', 'consumable_id', 'assigned_to')->count();
|
||||
}
|
||||
|
||||
|
||||
public function requireAcceptance()
|
||||
{
|
||||
return $this->category->require_acceptance;
|
||||
}
|
||||
|
||||
public function getEula()
|
||||
{
|
||||
|
||||
$Parsedown = new \Parsedown();
|
||||
|
||||
if ($this->category->eula_text) {
|
||||
return $Parsedown->text(e($this->category->eula_text));
|
||||
} elseif ((Setting::getSettings()->default_eula_text) && ($this->category->use_default_eula=='1')) {
|
||||
return $Parsedown->text(e(Setting::getSettings()->default_eula_text));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function numRemaining()
|
||||
{
|
||||
$checkedout = $this->users->count();
|
||||
$total = $this->qty;
|
||||
$remaining = $total - $checkedout;
|
||||
return $remaining;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$search = explode(' ', $search);
|
||||
|
||||
return $query->where(function ($query) use ($search) {
|
||||
|
||||
foreach ($search as $search) {
|
||||
$query->whereHas('category', function ($query) use ($search) {
|
||||
$query->where('categories.name', 'LIKE', '%'.$search.'%');
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('company', function ($query) use ($search) {
|
||||
$query->where('companies.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('location', function ($query) use ($search) {
|
||||
$query->where('locations.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('manufacturer', function ($query) use ($search) {
|
||||
$query->where('manufacturers.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere('consumables.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('consumables.order_number', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('consumables.purchase_cost', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('consumables.purchase_date', 'LIKE', '%'.$search.'%');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 scopeOrderCategory($query, $order)
|
||||
{
|
||||
return $query->join('categories', 'consumables.category_id', '=', 'categories.id')->orderBy('categories.name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on location
|
||||
*
|
||||
* @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', 'consumables.location_id', '=', 'locations.id')->orderBy('locations.name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on manufacturer
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderManufacturer($query, $order)
|
||||
{
|
||||
return $query->leftJoin('manufacturers', 'consumables.manufacturer_id', '=', 'manufacturers.id')->orderBy('manufacturers.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
|
||||
*/
|
||||
public function scopeOrderCompany($query, $order)
|
||||
{
|
||||
return $query->leftJoin('companies', 'consumables.company_id', '=', 'companies.id')->orderBy('companies.name', $order);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ConsumableAssignment extends Model
|
||||
{
|
||||
use CompanyableTrait;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'consumables_users';
|
||||
|
||||
public function consumable()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Consumable');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\User', 'assigned_to');
|
||||
}
|
||||
|
||||
public function admin()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\User', 'user_id');
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CustomField extends Model
|
||||
{
|
||||
public $guarded=["id"];
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
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"
|
||||
];
|
||||
|
||||
public $rules=[
|
||||
"name" => "required|unique:custom_fields"
|
||||
];
|
||||
|
||||
public static $table_name="assets";
|
||||
|
||||
public static function name_to_db_name($name)
|
||||
{
|
||||
return "_snipeit_".preg_replace("/[^a-zA-Z0-9]/", "_", strtolower($name));
|
||||
}
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
self::creating(function ($custom_field) {
|
||||
|
||||
if (in_array($custom_field->db_column_name(), \Schema::getColumnListing(\DB::getTablePrefix().CustomField::$table_name))) {
|
||||
//field already exists when making a new custom field; fail.
|
||||
return false;
|
||||
}
|
||||
|
||||
\Schema::table(\DB::getTablePrefix().\App\Models\CustomField::$table_name, function ($table) use ($custom_field) {
|
||||
$table->text($custom_field->db_column_name())->nullable();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
self::updating(function ($custom_field) {
|
||||
if ($custom_field->isDirty("name")) {
|
||||
if (in_array($custom_field->db_column_name(), \Schema::getColumnListing(CustomField::$table_name))) {
|
||||
//field already exists when renaming a custom field
|
||||
return false;
|
||||
}
|
||||
return \DB::statement("UPDATE ".CustomField::$table_name." RENAME ".self::name_to_db_name($custom_field->get_original("name"))." TO ".$custom_field->db_column_name());
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
self::deleting(function ($custom_field) {
|
||||
return \DB::statement("ALTER TABLE ".CustomField::$table_name." DROP COLUMN ".$custom_field->db_column_name());
|
||||
});
|
||||
}
|
||||
|
||||
public function fieldset()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\CustomFieldset'); //?!?!?!?!?!?
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\User');
|
||||
}
|
||||
|
||||
//public function
|
||||
|
||||
//need helper to go from regex->English
|
||||
//need helper to go from English->regex
|
||||
|
||||
//need helper for save() stuff - basically to alter table for the fields in question
|
||||
|
||||
public function check_format($value)
|
||||
{
|
||||
return preg_match('/^'.$this->attributes['format'].'$/', $value)===1;
|
||||
}
|
||||
|
||||
public function db_column_name()
|
||||
{
|
||||
return self::name_to_db_name($this->name);
|
||||
}
|
||||
|
||||
//mutators for 'format' attribute
|
||||
public function getFormatAttribute($value)
|
||||
{
|
||||
foreach (self::$PredefinedFormats as $name => $pattern) {
|
||||
if ($pattern===$value) {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function setFormatAttribute($value)
|
||||
{
|
||||
if (isset(self::$PredefinedFormats[$value])) {
|
||||
$this->attributes['format']=self::$PredefinedFormats[$value];
|
||||
} else {
|
||||
$this->attributes['format']=$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CustomFieldset extends Model
|
||||
{
|
||||
protected $guarded=["id"];
|
||||
|
||||
public $rules=[
|
||||
"name" => "required|unique:custom_fieldsets"
|
||||
];
|
||||
|
||||
public function fields()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\CustomField')->withPivot(["required","order"])->orderBy("pivot_order");
|
||||
}
|
||||
|
||||
public function models()
|
||||
{
|
||||
return $this->hasMany('\App\Models\AssetModel', "fieldset_id");
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\User'); //WARNING - not all CustomFieldsets have a User!!
|
||||
}
|
||||
|
||||
public function validation_rules()
|
||||
{
|
||||
$rules=[];
|
||||
foreach ($this->fields as $field) {
|
||||
$rule=[];
|
||||
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?
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Depreciation extends Model
|
||||
{
|
||||
// Declare the rules for the form validation
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:3|max:255|unique:depreciations,name',
|
||||
'months' => 'required|max:240|integer',
|
||||
);
|
||||
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
* is not set in the model it will default to true.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name','months'];
|
||||
|
||||
|
||||
|
||||
public function has_models()
|
||||
{
|
||||
return $this->hasMany('\App\Models\AssetModel', 'depreciation_id')->count();
|
||||
}
|
||||
|
||||
public function has_licenses()
|
||||
{
|
||||
return $this->hasMany('\App\Models\License', 'depreciation_id')->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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('name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('months', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Group extends Model
|
||||
{
|
||||
protected $table = 'groups';
|
||||
|
||||
public $rules = array(
|
||||
'name' => 'required|min:3|max:255',
|
||||
);
|
||||
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
* is not set in the model it will default to true.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* Get user groups
|
||||
*/
|
||||
public function users()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\User', 'users_groups');
|
||||
}
|
||||
|
||||
|
||||
public function decodePermissions()
|
||||
{
|
||||
return json_decode($this->permissions, true);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
interface ICompanyableChild
|
||||
{
|
||||
public function getCompanyableParents();
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
<?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;
|
||||
|
||||
|
||||
// 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($ldap_host) or die("Could not connect to {$ldap_host}");
|
||||
|
||||
if (!$connection) {
|
||||
throw new Exception('Could not connect to LDAP server at '.$ldap_host.': '.ldap_error($connection));
|
||||
}
|
||||
|
||||
// Needed for AD
|
||||
ldap_set_option($connection, LDAP_OPT_REFERRALS, 0);
|
||||
ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, $ldap_version);
|
||||
|
||||
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')
|
||||
{
|
||||
|
||||
// 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"];
|
||||
$user->password = bcrypt(Input::get("password"));
|
||||
$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)
|
||||
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);
|
||||
|
||||
return $results;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Company;
|
||||
use DB;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class License extends Depreciable
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableTrait;
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
protected $guarded = 'id';
|
||||
protected $table = 'licenses';
|
||||
protected $rules = array(
|
||||
'name' => 'required|string|min:3|max:255',
|
||||
'serial' => 'required|min:5',
|
||||
'seats' => 'required|min:1|max:10000|integer',
|
||||
'license_email' => 'email|min:0|max:120',
|
||||
'license_name' => 'string|min:0|max:100',
|
||||
'note' => 'string',
|
||||
'notes' => 'string|min:0',
|
||||
'company_id' => 'integer',
|
||||
);
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Company', 'company_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the assigned user
|
||||
*/
|
||||
public function assignedusers()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\User', 'license_seats', 'assigned_to', 'license_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get asset logs for this asset
|
||||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'asset_id')
|
||||
->where('asset_type', '=', 'software')
|
||||
->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get uploads for this asset
|
||||
*/
|
||||
public function uploads()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'asset_id')
|
||||
->where('asset_type', '=', 'software')
|
||||
->where('action_type', '=', 'uploaded')
|
||||
->whereNotNull('filename')
|
||||
->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get admin user for this asset
|
||||
*/
|
||||
public function adminuser()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\User', 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total licenses
|
||||
*/
|
||||
public static function assetcount()
|
||||
{
|
||||
return LicenseSeat::whereNull('deleted_at')
|
||||
->count();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get total licenses
|
||||
*/
|
||||
public function totalSeatsByLicenseID()
|
||||
{
|
||||
return LicenseSeat::where('license_id', '=', $this->id)
|
||||
->whereNull('deleted_at')
|
||||
->count();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get total licenses not checked out
|
||||
*/
|
||||
public static function availassetcount()
|
||||
{
|
||||
return LicenseSeat::whereNull('assigned_to')
|
||||
->whereNull('asset_id')
|
||||
->whereNull('deleted_at')
|
||||
->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of available seats
|
||||
*/
|
||||
public function availcount()
|
||||
{
|
||||
return LicenseSeat::whereNull('assigned_to')
|
||||
->whereNull('asset_id')
|
||||
->where('license_id', '=', $this->id)
|
||||
->whereNull('deleted_at')
|
||||
->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of assigned seats
|
||||
*
|
||||
*/
|
||||
public function assignedcount()
|
||||
{
|
||||
|
||||
return \App\Models\LicenseSeat::where('license_id', '=', $this->id)
|
||||
->where(function ($query) {
|
||||
|
||||
$query->whereNotNull('assigned_to')
|
||||
->orWhereNotNull('asset_id');
|
||||
})
|
||||
->count();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function remaincount()
|
||||
{
|
||||
$total = $this->totalSeatsByLicenseID();
|
||||
$taken = $this->assignedcount();
|
||||
$diff = ($total - $taken);
|
||||
return $diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of seats
|
||||
*/
|
||||
public function totalcount()
|
||||
{
|
||||
$avail = $this->availcount();
|
||||
$taken = $this->assignedcount();
|
||||
$diff = ($avail + $taken);
|
||||
return $diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get license seat data
|
||||
*/
|
||||
public function licenseseats()
|
||||
{
|
||||
return $this->hasMany('\App\Models\LicenseSeat');
|
||||
}
|
||||
|
||||
public function supplier()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Supplier', 'supplier_id');
|
||||
}
|
||||
|
||||
public function freeSeat()
|
||||
{
|
||||
$seat = LicenseSeat::where('license_id', '=', $this->id)
|
||||
->whereNull('deleted_at')
|
||||
->whereNull('assigned_to')
|
||||
->whereNull('asset_id')
|
||||
->first();
|
||||
return $seat->id;
|
||||
}
|
||||
|
||||
public static function getExpiringLicenses($days = 60)
|
||||
{
|
||||
|
||||
return License::whereNotNull('expiration_date')
|
||||
->whereNull('deleted_at')
|
||||
->whereRaw(DB::raw('DATE_SUB(`expiration_date`,INTERVAL '.$days.' DAY) <= DATE(NOW()) '))
|
||||
->where('expiration_date', '>', date("Y-m-d"))
|
||||
->orderBy('expiration_date', 'ASC')
|
||||
->get();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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('name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('serial', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('notes', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('order_number', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('purchase_date', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('purchase_cost', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class LicenseSeat extends Model implements ICompanyableChild
|
||||
{
|
||||
use CompanyableChildTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $guarded = 'id';
|
||||
protected $table = 'license_seats';
|
||||
|
||||
public function getCompanyableParents()
|
||||
{
|
||||
return ['asset', 'license'];
|
||||
}
|
||||
|
||||
public function license()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\License', 'license_id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\User', 'assigned_to')->withTrashed();
|
||||
}
|
||||
|
||||
public function asset()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Asset', 'asset_id')->withTrashed();
|
||||
}
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Models\User;
|
||||
use App\Models\Asset;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Location extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'locations';
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:3|max:255|unique:locations,name,NULL,deleted_at',
|
||||
'city' => 'min:3|max:255',
|
||||
'state' => 'min:2|max:32',
|
||||
'country' => 'min:2|max:2|max:2',
|
||||
'address' => 'min:5|max:80',
|
||||
'address2' => 'min:2|max:80',
|
||||
'zip' => 'min:3|max:10',
|
||||
);
|
||||
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
* is not set in the model it will default to true.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name'];
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany('\App\Models\User', 'location_id');
|
||||
}
|
||||
|
||||
public function assets()
|
||||
{
|
||||
return $this->hasManyThrough('\App\Models\Asset', '\App\Models\Actionlog', 'location_id', 'id');
|
||||
}
|
||||
|
||||
public function assignedassets()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Asset', 'rtd_location_id');
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Location', 'parent_id');
|
||||
}
|
||||
|
||||
public function childLocations()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Location', 'parent_id');
|
||||
}
|
||||
|
||||
public static function getLocationHierarchy($locations, $parent_id = null)
|
||||
{
|
||||
|
||||
|
||||
$op = array();
|
||||
|
||||
foreach ($locations as $location) {
|
||||
|
||||
if ($location['parent_id'] == $parent_id) {
|
||||
$op[$location['id']] =
|
||||
array(
|
||||
'name' => $location['name'],
|
||||
'parent_id' => $location['parent_id']
|
||||
);
|
||||
|
||||
// Using recursion
|
||||
$children = Location::getLocationHierarchy($locations, $location['id']);
|
||||
if ($children) {
|
||||
$op[$location['id']]['children'] = $children;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return $op;
|
||||
}
|
||||
|
||||
|
||||
public static function flattenLocationsArray($location_options_array = null)
|
||||
{
|
||||
$location_options = array();
|
||||
foreach ($location_options_array as $id => $value) {
|
||||
|
||||
// get the top level key value
|
||||
$location_options[$id] = $value['name'];
|
||||
|
||||
// If there is a key named children, it has child locations and we have to walk it
|
||||
if (array_key_exists('children', $value)) {
|
||||
|
||||
foreach ($value['children'] as $child_id => $child_location_array) {
|
||||
$child_location_options = Location::flattenLocationsArray($value['children']);
|
||||
|
||||
foreach ($child_location_options as $child_id => $child_name) {
|
||||
$location_options[$child_id] = '--'.$child_name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $location_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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('name', 'LIKE', "%$search%")
|
||||
->orWhere('address', 'LIKE', "%$search%")
|
||||
->orWhere('city', 'LIKE', "%$search%")
|
||||
->orWhere('state', 'LIKE', "%$search%")
|
||||
->orWhere('zip', 'LIKE', "%$search%")
|
||||
|
||||
// This doesn't actually work - need to use a table alias maybe?
|
||||
->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('parent', function ($query) use ($search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->where('name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})
|
||||
// Ugly, ugly code because Laravel sucks at self-joins
|
||||
->orWhere(function ($query) use ($search) {
|
||||
$query->whereRaw("parent_id IN (select id from locations where name LIKE '%".$search."%') ");
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope to order on parent
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderParent($query, $order)
|
||||
{
|
||||
// Left join here, or it will only return results with parents
|
||||
return $query->leftJoin('locations as parent_loc', 'locations.parent_id', '=', 'parent_loc.id')->orderBy('parent_loc.name', $order);
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Manufacturer extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'manufacturers';
|
||||
|
||||
// Declare the rules for the form validation
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:2|max:255|unique:manufacturers,name,NULL,deleted_at',
|
||||
'user_id' => 'integer',
|
||||
);
|
||||
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
* is not set in the model it will default to true.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name'];
|
||||
|
||||
|
||||
|
||||
public function has_models()
|
||||
{
|
||||
return $this->hasMany('\App\Models\AssetModel', 'manufacturer_id')->count();
|
||||
}
|
||||
|
||||
public function assets()
|
||||
{
|
||||
return $this->hasManyThrough('\App\Models\Asset', '\App\Models\AssetModel', 'manufacturer_id', 'model_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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('name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use Schema;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
protected $rules = [
|
||||
"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','email_domain','email_format','username_format'];
|
||||
|
||||
public static function getSettings()
|
||||
{
|
||||
static $static_cache = null;
|
||||
|
||||
if (!$static_cache) {
|
||||
$static_cache = Setting::first();
|
||||
}
|
||||
return $static_cache;
|
||||
}
|
||||
|
||||
public static function setupCompleted()
|
||||
{
|
||||
|
||||
$users_table_exists = Schema::hasTable('users');
|
||||
$settings_table_exists = Schema::hasTable('settings');
|
||||
|
||||
if ($users_table_exists && $settings_table_exists) {
|
||||
$usercount = User::withTrashed()->count();
|
||||
|
||||
if ($usercount > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function lar_ver()
|
||||
{
|
||||
$app = \App::getFacadeApplication();
|
||||
return $app::VERSION;
|
||||
}
|
||||
|
||||
public static function getDefaultEula()
|
||||
{
|
||||
|
||||
$Parsedown = new \Parsedown();
|
||||
if (Setting::getSettings()->default_eula_text) {
|
||||
return $Parsedown->text(e(Setting::getSettings()->default_eula_text));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function show_custom_css()
|
||||
{
|
||||
$custom_css = Setting::getSettings()->custom_css;
|
||||
$custom_css = e($custom_css);
|
||||
// Needed for modifying the bootstrap nav :(
|
||||
$custom_css = str_ireplace('script', 'SCRIPTS-NOT-ALLOWED-HERE', $custom_css);
|
||||
$custom_css = str_replace('>', '>', $custom_css);
|
||||
return $custom_css;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts bytes into human readable file size.
|
||||
*
|
||||
* @param string $bytes
|
||||
* @return string human readable file size (2,87 Мб)
|
||||
* @author Mogilev Arseny
|
||||
*/
|
||||
public static function fileSizeConvert($bytes)
|
||||
{
|
||||
$bytes = floatval($bytes);
|
||||
$arBytes = array(
|
||||
0 => array(
|
||||
"UNIT" => "TB",
|
||||
"VALUE" => pow(1024, 4)
|
||||
),
|
||||
1 => array(
|
||||
"UNIT" => "GB",
|
||||
"VALUE" => pow(1024, 3)
|
||||
),
|
||||
2 => array(
|
||||
"UNIT" => "MB",
|
||||
"VALUE" => pow(1024, 2)
|
||||
),
|
||||
3 => array(
|
||||
"UNIT" => "KB",
|
||||
"VALUE" => 1024
|
||||
),
|
||||
4 => array(
|
||||
"UNIT" => "B",
|
||||
"VALUE" => 1
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($arBytes as $arItem) {
|
||||
if ($bytes >= $arItem["VALUE"]) {
|
||||
$result = $bytes / $arItem["VALUE"];
|
||||
$result = round($result, 2) .$arItem["UNIT"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Statuslabel extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use ValidatingTrait;
|
||||
|
||||
protected $injectUniqueIdentifier = true;
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'status_labels';
|
||||
|
||||
|
||||
protected $rules = array(
|
||||
'name' => 'required|string|unique:status_labels,name,NULL,deleted_at',
|
||||
'notes' => 'string',
|
||||
'deployable' => 'required',
|
||||
'pending' => 'required',
|
||||
'archived' => 'required',
|
||||
);
|
||||
|
||||
protected $fillable = ['name'];
|
||||
|
||||
/**
|
||||
* 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') && ($this->archived == '0') && ($this->deployable == '0')) {
|
||||
return 'pending';
|
||||
} elseif (($this->pending == '0') && ($this->archived == '1') && ($this->deployable == '0')) {
|
||||
return 'archived';
|
||||
} elseif (($this->pending == '0') && ($this->archived == '0') && ($this->deployable == '0')) {
|
||||
return 'undeployable';
|
||||
} else {
|
||||
return 'deployable';
|
||||
}
|
||||
}
|
||||
|
||||
public static function getStatuslabelTypesForDB($type)
|
||||
{
|
||||
if ($type == 'pending') {
|
||||
$statustype['pending'] = 1;
|
||||
$statustype['deployable'] = 0;
|
||||
$statustype['archived'] = 0;
|
||||
|
||||
} elseif ($type == 'deployable') {
|
||||
$statustype['pending'] = 0;
|
||||
$statustype['deployable'] = 1;
|
||||
$statustype['archived'] = 0;
|
||||
|
||||
} elseif ($type == 'archived') {
|
||||
$statustype['pending'] = 0;
|
||||
$statustype['deployable'] = 0;
|
||||
$statustype['archived'] = 1;
|
||||
|
||||
} else {
|
||||
$statustype['pending'] = 0;
|
||||
$statustype['deployable'] = 0;
|
||||
$statustype['archived'] = 0;
|
||||
|
||||
}
|
||||
|
||||
return $statustype;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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('name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user