Compare commits

..

1312 Commits

Author SHA1 Message Date
snipe 7a4f115cb3 Merge remote-tracking branch 'origin/develop' 2015-02-11 22:57:47 -08:00
snipe 58ff929d71 Fixes error when no model present because new asset 2015-02-11 22:57:22 -08:00
snipe 49f25a23a9 Merge pull request #516 from splaer/fix-475
Fix 475
2015-02-11 21:42:33 -08:00
Splaer bcf75073ec Update style
updated the scss as well until that starts getting auto compiled
2015-02-12 00:38:58 -05:00
snipe 6908456d09 Merge remote-tracking branch 'origin/develop' 2015-02-11 21:27:56 -08:00
snipe c26369f8cc Added spacing between buttons 2015-02-11 21:21:19 -08:00
snipe 56e090f3e7 Unlink username if they've been deleted 2015-02-11 21:19:18 -08:00
Splaer 00f7717142 Fix #475 and styling
Cleaned up styling to break lines with larger notes on hardware view
and asset view. Changed column type to text.
2015-02-11 23:38:59 -05:00
snipe 823e0c8562 Merge remote-tracking branch 'origin/develop' 2015-02-11 16:55:29 -08:00
snipe 95be7908f8 New language strings 2015-02-11 16:51:16 -08:00
snipe c660c71556 Added MAC address to view 2015-02-11 16:43:46 -08:00
snipe fbf03b225d Fixes #509 - added MAC address as model option 2015-02-11 16:37:24 -08:00
snipe a5f4c51ab2 Merge remote-tracking branch 'origin/develop' 2015-02-11 14:31:25 -08:00
snipe 89dce89035 Moved expiration date below purchase date 2015-02-11 14:02:34 -08:00
snipe 8cdd215614 Fixed intenting 2015-02-11 14:02:21 -08:00
snipe 342a8b81af Fix for error when asset has null status 2015-02-11 13:51:28 -08:00
snipe cd5a352961 Fix for wrong math on remaining licenses when assigned to an asset 2015-02-11 13:39:08 -08:00
snipe a451fa1fa6 Merge remote-tracking branch 'origin/develop' 2015-02-11 12:49:39 -08:00
snipe e343c157c5 Fixed naming conflict for requestable 2015-02-11 12:49:21 -08:00
snipe 37fc216c5a Additional language strings 2015-02-11 05:19:23 -08:00
snipe 96feb84fd4 Merge remote-tracking branch 'origin/develop' 2015-02-11 04:59:35 -08:00
snipe 80e10c4c98 Fixes #387 - sortable asset view by manufacturer 2015-02-11 04:57:59 -08:00
snipe 35a133bbf9 Fixes #382 - allow admins to restore deleted assets 2015-02-11 04:44:39 -08:00
snipe 0adbce77f9 Merge remote-tracking branch 'origin/develop' 2015-02-11 03:52:08 -08:00
snipe c89be34503 Fixes #329 and #454 - added category asset view 2015-02-11 03:51:01 -08:00
snipe 9c3873e712 Category asset view 2015-02-11 03:50:16 -08:00
snipe 4f6eeda368 View asset for requests 2015-02-11 03:49:33 -08:00
snipe f690cd6305 Requests table 2015-02-11 03:49:13 -08:00
snipe 447ed3518e Merge remote-tracking branch 'origin/develop' 2015-02-11 00:56:17 -08:00
snipe d9d99b2223 No trashed 2015-02-11 00:44:22 -08:00
snipe 2b99adba5f Do not include trashed for user view 2015-02-11 00:43:50 -08:00
snipe 11aa98d389 Removed extra comments 2015-02-11 00:43:38 -08:00
snipe 591f97f149 Mark unassigned if deleted 2015-02-11 00:43:25 -08:00
snipe ef696f8207 Update licenses to assigned to null if deleted 2015-02-11 00:29:16 -08:00
snipe ab1c921443 Requestable assets views and controllers 2015-02-10 23:55:06 -08:00
snipe 7b165a12e0 Fixes #508 - compacted UI for licenses overview 2015-02-10 21:52:11 -08:00
snipe 6f2f7cc214 Updated language strings 2015-02-10 20:52:22 -08:00
snipe 89729bfa51 Removed invalid comments 2015-02-10 20:47:24 -08:00
snipe 34032c73ce Fixed licenses so null instead of 0 2015-02-10 20:47:11 -08:00
snipe f72b385790 Fix licenses so null instead of 0 2015-02-10 20:46:58 -08:00
snipe d541ded862 Merge remote-tracking branch 'origin/develop'
Conflicts:
	app/views/backend/layouts/default.blade.php
2015-02-10 19:47:43 -08:00
snipe 8cc95a3b9b Merge pull request #507 from madd15/patch-2
Added Archived Lang
2015-02-10 19:19:03 -08:00
snipe bf9a825095 Removed extraneous ID 2015-02-10 19:18:15 -08:00
madd15 5c92be5190 Added Archived Lang 2015-02-11 13:45:04 +10:30
madd15 fa9cf35ff5 Added Archived Lang 2015-02-11 13:43:19 +10:30
snipe f36029a34a Fixed migration for to set assigned_to to null per #506 2015-02-10 18:41:45 -08:00
snipe c2e532e32e Fixed language file for status label messages 2015-02-10 18:33:19 -08:00
snipe 9bcc9a7ed1 Check not deleted 2015-02-10 18:27:00 -08:00
snipe 7715731c4a Fix count in header 2015-02-10 18:26:35 -08:00
snipe a2178392e6 Fixed seeder 2015-02-10 18:09:36 -08:00
snipe 0aa4d2a3db Added undeployable as allowed validation type 2015-02-10 18:06:55 -08:00
snipe 5867c60410 Fixed scope chaining on assigned_to 2015-02-10 17:58:47 -08:00
snipe 268fb98dbb Indented for better readibility 2015-02-10 17:41:42 -08:00
snipe 5f1227d0fa Removed stray chars 2015-02-10 17:41:27 -08:00
snipe 1b93c5538a Get trashed for admins 2015-02-10 17:41:19 -08:00
snipe 3645f85731 Typo :( 2015-02-10 17:23:25 -08:00
snipe 0b02b1631b Merge pull request #505 from madd15/patch-1
Fix RTD query to not display checked out asset
2015-02-10 17:20:20 -08:00
madd15 31f4ba88f6 Fix RTD query to not display checked out asset 2015-02-11 11:49:28 +10:30
snipe c06a4d4118 Fixed wonky checkin/checkout buttons 2015-02-10 17:17:33 -08:00
snipe dbc93de6b3 Fixes checkin button on view 2015-02-10 17:11:40 -08:00
snipe 2277b6ee69 Fixed checkout logic for new assigned_to 2015-02-10 17:04:15 -08:00
snipe b36d73a4bb Missing checkin buttons on index 2015-02-10 17:03:13 -08:00
snipe 283d2855d7 Added user_id to status label migration for strict mode 2015-02-10 16:22:02 -08:00
snipe f175f52530 Fixed spacer in sidenav for list all 2015-02-10 16:08:54 -08:00
snipe e29da5521d Moved location of archived link 2015-02-10 16:08:02 -08:00
snipe 1db1819a56 Added Archived as view for filter 2015-02-10 16:06:33 -08:00
snipe aef3a734a3 Small fix for pending status 2015-02-10 16:06:24 -08:00
snipe d2438f9fdb Fixes #502 - normalized statuses 2015-02-10 15:57:19 -08:00
snipe 53d000e2d0 Migration to correct previous assigned_to=0 issue 2015-02-09 20:29:48 -08:00
snipe addfcd4bc5 Fix RTD bug 2015-02-09 20:02:40 -08:00
snipe b360736b77 Fixes #484 2015-02-09 19:26:57 -08:00
snipe 2bae77b3af Removed extranneous text field 2015-02-09 16:50:12 -08:00
snipe c1600a33db Fixes #499 - timestamps in asset logs 2015-02-09 16:47:36 -08:00
snipe 5d3b84e01a Misc additional assets 2015-02-09 16:45:01 -08:00
snipe 7ed098de67 Merge branch 'develop' of github.com:snipe/snipe-it into develop 2015-02-09 00:48:19 -08:00
snipe 22af5561b2 Updated translation strings 2015-02-09 00:48:03 -08:00
snipe 7009b24748 Merge pull request #498 from snipe/fixes/477
Fixes #477 - wrong sidebar on asset view
2015-02-09 00:35:04 -08:00
snipe 389c27b2e6 Fixes #477 - wrong sidebar on asset view 2015-02-09 00:34:29 -08:00
snipe a61e913824 Squashed commit of the following:
commit 95ae26eb2a
Author: snipe <snipe@snipe.net>
Date:   Sun Feb 8 16:21:33 2015 -0800

    Updated docs location

commit cfebe11755
Author: snipe <snipe@snipe.net>
Date:   Sun Feb 8 16:20:36 2015 -0800

    Updated docs for 4.2

commit d86b5aa613
Author: snipe <snipe@snipe.net>
Date:   Sun Feb 8 16:20:24 2015 -0800

    Bumped version
2015-02-08 16:22:12 -08:00
snipe 95ae26eb2a Updated docs location 2015-02-08 16:21:33 -08:00
snipe cfebe11755 Updated docs for 4.2 2015-02-08 16:20:36 -08:00
snipe d86b5aa613 Bumped version 2015-02-08 16:20:24 -08:00
snipe c255de7fc0 Merge remote-tracking branch 'origin/develop' 2015-02-08 16:18:09 -08:00
snipe 42d5d8db80 Updated language files 2015-02-08 16:17:45 -08:00
snipe 91bf9763d2 Merge remote-tracking branch 'origin/develop' 2015-02-08 16:13:25 -08:00
snipe 9c66dd5431 Added gitignore 2015-02-08 16:13:10 -08:00
snipe 614396a15b Utilize query scopes for cleaner controllers 2015-02-08 16:02:35 -08:00
snipe cfe0472ea2 New language strings for file uploads 2015-02-06 22:18:57 -08:00
snipe d20b5136b8 Nicer display if no files have been uploaded 2015-02-06 22:02:52 -08:00
snipe 29f5b7c5e3 Fixed datetime 2015-02-06 21:54:44 -08:00
snipe 140bd137a4 Minor display fixes 2015-02-06 21:54:36 -08:00
snipe 3a9cb9ba7a Display uploaded files 2015-02-06 21:31:16 -08:00
snipe 6d0828bfe5 Delete file interface and routes 2015-02-06 20:42:40 -08:00
snipe 51a7752771 Moved cancel text to buttons language file 2015-02-06 18:52:09 -08:00
snipe a8681225f5 Added language for add button 2015-02-06 18:46:20 -08:00
snipe 26a59afa44 Basic upload display and form 2015-02-06 18:43:15 -08:00
snipe e22ce0d377 Changes added_on to created_at 2015-02-06 18:43:04 -08:00
snipe 2fbef7f561 Updated field name for asset log 2015-02-06 18:42:48 -08:00
snipe 2678611c79 Included doctrine for field renaming 2015-02-06 18:42:36 -08:00
snipe 416cd236d2 Updated to new fieldname 2015-02-06 18:42:24 -08:00
snipe 4936a5914f Folder for private uploads 2015-02-06 18:41:56 -08:00
snipe 36fce27297 Added uploads methods 2015-02-06 18:41:47 -08:00
snipe 4b2e45c5f2 Added uploads methods 2015-02-06 18:41:35 -08:00
snipe 11f46474ab New file upload language 2015-02-06 18:41:24 -08:00
snipe b0d52a4158 Updated field name 2015-02-06 18:41:16 -08:00
snipe 7b4845c255 Added soft delete to asset log 2015-02-06 18:40:58 -08:00
snipe 223ba349ea Minor change to comment for clarify 2015-02-06 16:57:15 -08:00
snipe feeef4b66c Fix for asset log incorrectly using soft deletes 2015-02-06 14:54:13 -08:00
snipe 42f8a35078 Additional translation files 2015-02-05 17:08:20 -08:00
snipe 0128505213 Overwriting Smfony YAML deps 2015-02-05 15:50:32 -08:00
snipe 06bee68cd2 Testing config for travis 2015-02-05 15:34:26 -08:00
snipe c255edaf61 More travis fixes 2015-02-05 15:30:51 -08:00
snipe 7f0e21d50c Changes to make travis build pass 2015-02-05 15:02:57 -08:00
snipe 1aeb4de0fa Possible fix for #491 - solving for giticide on package dep 2015-02-05 14:43:01 -08:00
snipe bff33cb7f5 removed old package dep 2015-02-05 14:10:25 -08:00
snipe 5695815360 Missed one --force 2015-02-04 16:22:45 -08:00
snipe e67ba8a743 Fix reporting error on depreciation 2015-02-04 16:13:11 -08:00
snipe 3669ab2ae8 Updated travis for forced migration in production 2015-02-04 16:07:41 -08:00
snipe e2ee954592 Updated composer and composer.lock for 4.2 2015-02-04 15:50:54 -08:00
snipe b4750f016d Added new 4.2 SoftDeletingTrait 2015-02-04 15:50:40 -08:00
snipe 7069d9c6b1 Added new cipher to config 2015-02-04 15:50:07 -08:00
snipe 8e0d774023 Added strict option in database config 2015-02-04 15:49:50 -08:00
snipe 394836821c Added catehory nav item in sidebar 2015-02-04 15:01:36 -08:00
snipe a1ac7f8676 Removed cruft 2015-02-04 15:01:08 -08:00
snipe cd338d2a70 Fixes #483 - line breaks in notes on view 2015-02-04 10:21:02 -08:00
snipe 4dc81ce65f Resolves #478 - redirects non-reporting users to view assets page 2015-02-04 09:31:01 -08:00
snipe f5efc368a5 Fixes #487 - maintained and purchase order in strict mode 2015-02-04 08:51:03 -08:00
snipe 1db806f8b2 Fixes #488 - longer user jobtitle 2015-02-04 07:59:45 -08:00
snipe b3af102d22 Fixed safe mode issue with license seeder 2015-02-04 07:49:28 -08:00
snipe 2b86f14e30 Possible fix for #484 - fullname issue 2015-02-01 14:33:58 -08:00
snipe 3f0e494276 Updated contributing info 2015-01-23 15:39:03 -08:00
snipe a4bac03692 Increment version number 2015-01-23 15:38:48 -08:00
snipe 950567e9d6 Fixes issue related to #471 - assigning to user ID 0 causes erro 2015-01-23 15:38:39 -08:00
snipe dede09e9c5 Merge remote-tracking branch 'origin/develop' 2015-01-22 15:41:36 -08:00
snipe 3787a3f4ba Fixed language strings for incrementing IDs 2015-01-22 15:34:19 -08:00
snipe 95141d49ba Fixes #432 - add model name to checkout 2015-01-22 15:20:16 -08:00
snipe d85e524680 Fixes #451 - allows spaces in state name 2015-01-22 14:29:53 -08:00
snipe 4a77dee79c Fixes #447 - added asset log entry on save 2015-01-22 14:16:09 -08:00
snipe 6fba41e026 Updated gitignore to ignore crowdin 2015-01-22 13:42:32 -08:00
snipe f39922f51f Merge remote-tracking branch 'origin/develop'
Conflicts:
	CONTRIBUTING.md
2015-01-22 13:31:19 -08:00
snipe 53085983f8 Added UK English language file 2015-01-22 13:24:01 -08:00
snipe 4a2ac03ace New Spanish strings 2015-01-22 13:23:29 -08:00
snipe 548de1a1a2 Fixes #468 - updated ordering on license checkout 2015-01-22 13:03:07 -08:00
snipe 82560b1098 Updated language files with new strings 2015-01-22 13:00:38 -08:00
snipe 3c141e8f50 Fixes #467 2015-01-22 12:56:13 -08:00
snipe 5e496672c6 Fixes #469 2015-01-22 12:54:22 -08:00
snipe 4887c53f25 Merge pull request #452 from gitter-badger/gitter-badge
Add a Gitter chat badge to README.md
2015-01-12 15:16:57 -08:00
The Gitter Badger 2b79a61d65 Added Gitter badge 2015-01-12 23:15:02 +00:00
snipe 5268c579e2 Update CONTRIBUTING.md 2015-01-08 17:34:23 -08:00
snipe 21448ea8e6 Update CONTRIBUTING.md 2015-01-08 17:33:49 -08:00
snipe 778a7bb18c Additional translations 2015-01-08 17:24:13 -08:00
snipe 685881cf27 Too many thanks (too many thanks) 2015-01-08 17:19:02 -08:00
snipe cf4b80bbd5 Updated contributing guidelines 2015-01-08 17:18:19 -08:00
snipe 5c98dae57d Merge branch 'develop' 2015-01-08 11:34:19 -08:00
snipe e434616db8 Merge pull request #436 from rashivkp/fix-435
fixed #435. using namespace with route groups to increase the readability
2015-01-04 21:50:07 -06:00
snipe 8a7b7418db Merge pull request #433 from thehereward/tidy-up-models
Tidy up models
2015-01-04 21:49:57 -06:00
Mohamed Rashid 533be7f942 fixed #435. using namespace with route groups to increase the readability 2015-01-05 01:24:16 +05:30
Hereward Mills 094ec50a68 TidyUp: Commonise the depreciate method of Asset and License. 2014-12-24 23:03:06 +00:00
Hereward Mills 98a29e460d TidyUp: Remove excess whitespace. 2014-12-24 22:34:16 +00:00
snipe 27fabfd110 Updated readme 2014-12-23 14:50:34 -05:00
snipe dce1d47228 Updated language files 2014-12-23 14:48:43 -05:00
snipe 9bbec53635 Added --no-dev to composer for CI 2014-12-23 14:19:46 -05:00
snipe 82232a34ee Merge pull request #415 from svpernova09/feature/software-maintenance-additions
Feature/software maintenance additions Working on #232
2014-12-23 14:11:20 -05:00
Svpernova09 3d1795e312 Add process handling of new maintained and termination_date fields to the licenses methods for creating and editing licenses. Also add array for getCreate and getEdit to easily display maintained options in drop down 2014-12-10 07:45:53 -06:00
Svpernova09 d858861d0f Add termination_date and maintained fields to the License edit form. Add field labels to language file. 2014-12-10 07:44:47 -06:00
Svpernova09 eec36cb13a Add migration to add maintained and termination_date fields to licenses table 2014-12-10 07:43:57 -06:00
snipe cee966e76e Merge pull request #408 from svpernova09/feature/add-asset-from-model-view
Feature/add asset from model view for #365
2014-12-03 15:25:56 -05:00
Svpernova09 dcf2b428da If we are passing along an id of a previously selected model, use that as the default selection. Otherwise we should fall back to Input::old() 2014-12-03 14:06:33 -06:00
Svpernova09 80d8432c35 Check the optional parameter and if there is a value, grab that model and pass along to the view. Refactored the view return to be easier to read and able to interject if our parameter was set. 2014-12-03 14:05:42 -06:00
Svpernova09 8ec5934af5 Add menu option in dropdown to create new hardware. Add optional parameter in create/hardware route to handle the parameter in the incoming link 2014-12-03 14:04:02 -06:00
snipe 31f77dcb4b Merge pull request #407 from svpernova09/bug/500-error-when-viewing-asset
Check if ->adminuser->id isset before trying to print the fullName so we...
2014-12-03 14:08:09 -05:00
Svpernova09 0663ccb99f Check if ->adminuser->id isset before trying to print the fullName so we can catch when a user that created an asset has been deleted. Fixes #349 2014-12-03 07:46:29 -06:00
snipe 19189f688f Merge pull request #405 from svpernova09/enhancement/make-notes-field-textarea
Enhancement/make notes field textarea
2014-12-02 11:21:36 -05:00
Svpernova09 7849320db0 Convert note fields to text areas for licenses views 2014-12-02 06:59:16 -06:00
Svpernova09 cc8ca54b3f Convert note fields to text areas for hardware views 2014-12-02 06:59:01 -06:00
Svpernova09 ecb4d0d948 Add jetbrains IDE's config folders to gitignore 2014-12-02 06:51:50 -06:00
snipe f20566f222 Merge pull request #393 from madd15/patch-1
Fix #388 - License not showing checked out in view
2014-11-23 19:36:28 -05:00
madd15 73dd339772 Fix #388 - License not showing checked out in view 2014-11-24 11:05:24 +10:30
snipe 5a6139fb64 Merge pull request #391 from bitdeli-chef/master
Add a Bitdeli Badge to README
2014-11-22 22:57:29 -05:00
Bitdeli Chef 0fb2728e3f Add a Bitdeli badge to README 2014-11-23 04:06:26 +00:00
snipe 5e6c4a250a Updated composer lock 2014-11-21 07:34:06 -05:00
snipe bf96aae9d9 Truncate license in report 2014-11-21 07:32:12 -05:00
snipe daefc86e58 Formattig fixes for #386 2014-11-21 06:10:30 -05:00
snipe 64c16a0bac Fixes #386 and #273 - altered column type to text 2014-11-21 05:47:49 -05:00
snipe 89a2b87e42 Fixes #367 - added model number to dropdown 2014-11-21 05:20:08 -05:00
snipe 1b41c974cf Fixes #348 - remove constraints on license keys 2014-11-20 18:43:33 -05:00
snipe d6a0249c60 Fixed #373 - added ability to auto-increment asset tags 2014-11-20 18:28:45 -05:00
snipe 6a6676b1e7 Merge pull request #383 from madd15/patch-1
Fix half #377 - Checkout users last_name, first_name
2014-11-20 17:19:44 -05:00
madd15 1024816313 Fix #377 - Checkout users last_name, first_name 2014-11-21 08:47:19 +10:30
snipe 6905d82fc4 Fixes #374 to keep the requirement to PHP 5.4 2014-11-20 16:38:50 -05:00
snipe 22746db8b7 Newest translations 2014-11-20 16:28:38 -05:00
snipe b826673d0d Added username field for #377 2014-11-20 16:17:48 -05:00
snipe 637009054c Fixed typo in english 2014-11-20 16:09:30 -05:00
snipe 5f5be6aa2a Removed line break 2014-11-20 16:09:21 -05:00
snipe a863cf1615 Merge pull request #364 from madd15/patch-1
Remove Double </label>
2014-11-13 18:30:40 -05:00
madd15 05d8ff0252 Remove Double </label> 2014-11-14 09:57:02 +10:30
snipe b73ae3147a Fixes #362, reduced asset name to 2 char min 2014-11-13 16:26:39 -05:00
snipe 81b2ce33c2 Polish, german and spanish translation strings 2014-11-12 21:13:46 -05:00
snipe 501e1749b3 Updated localization strings 2014-11-12 17:38:56 -05:00
snipe 53f279f55f Language string for "generate" 2014-11-12 17:34:22 -05:00
snipe f5fb2525de Merge branch 'develop' of github.com:snipe/snipe-it into develop 2014-11-12 17:32:58 -05:00
snipe 53951c8bbc Nicer custom reports form layout 2014-11-12 17:32:48 -05:00
snipe 00755eadf0 Merge pull request #359 from madd15/patch-1
Fix Lang for Reports
2014-11-12 17:17:07 -05:00
madd15 13b173409f Fix License form langs 2014-11-13 08:44:47 +10:30
madd15 7ddc6d497a Fix Report Langs 2014-11-13 08:43:42 +10:30
snipe 2829eeca7c New reports language files 2014-11-12 17:05:46 -05:00
snipe e39227633f Merge pull request #358 from madd15/feature-reports
Add error on empty options and Update to Lang for error and info
2014-11-12 17:01:31 -05:00
Madd15 89c7159c56 Fix array check for empty rows 2014-11-13 08:29:15 +10:30
snipe 6854453bc5 English is hard :( 2014-11-12 16:38:31 -05:00
snipe ce9c616843 Updated language strings 2014-11-12 16:33:11 -05:00
Madd15 40b0ced8da Update Lang for error and info 2014-11-13 08:02:39 +10:30
Madd15 57ec8aa3c2 Add error for no options selected 2014-11-13 08:02:25 +10:30
snipe 02feb69d5d Localization on user's view page, new strings 2014-11-12 16:22:30 -05:00
snipe fc2d472ed3 Fixed english language string 2014-11-12 15:52:08 -05:00
snipe b622d977d9 Merge pull request #355 from madd15/feature-reports
Added Customizable Asset Report
2014-11-12 01:35:44 -05:00
Madd15 6d2a073d04 Custom Asset Report 2014-11-12 16:05:59 +10:30
snipe 564cf90e58 Merge pull request #354 from madd15/feature-reports
Feature Extended Reports
2014-11-12 00:32:51 -05:00
Madd15 c60e40096a Replace static titles with lang 2014-11-12 13:38:31 +10:30
Madd15 74ae2fceea Fix class on th 2014-11-12 13:34:53 +10:30
Madd15 02605bdf69 Add Asset Report with Reduced Load Time 2014-11-12 12:03:33 +10:30
Madd15 432e348e56 Add Report Controller and License Report 2014-11-12 12:02:55 +10:30
snipe d91a7c7aa8 Merge pull request #351 from diwanicki/patch-1
Update view.blade.php
2014-11-07 16:57:39 -05:00
diwanicki f2ae05786b Update view.blade.php
closing parens was missing from Depreciation, EOL was not configured for translations
2014-11-07 16:56:28 -05:00
snipe 3d3e2dc985 Merge pull request #346 from madd15/feature-supplier-image
Add image to supplier
2014-11-06 22:24:37 -05:00
madd15 3c3617d641 Add image to supplier 2014-11-07 13:46:14 +10:30
snipe b518162c50 Merge pull request #345 from madd15/patch-1
Fix #342
2014-11-06 16:23:50 -05:00
madd15 b2d5dc9ec5 Fix #342 2014-11-07 07:52:44 +10:30
snipe cff24309a1 Possibly fixes #343 2014-11-06 15:21:54 -05:00
snipe b25c94e429 Purchase cost is not required 2014-11-06 15:21:32 -05:00
snipe 53a47743e8 Language string udpates 2014-11-05 23:06:06 -05:00
snipe 8a10386737 Merge pull request #338 from madd15/patch-license-lang
Lang changes for new licenses functions
2014-11-05 22:49:00 -05:00
madd15 7e95d36245 Lang changes for new licenses functions 2014-11-06 14:15:09 +10:30
snipe f90327ee9c Merge pull request #337 from madd15/patch-1
Update to v1.1
2014-11-05 22:21:10 -05:00
madd15 3b5670965c Update to v1.1 2014-11-06 13:50:13 +10:30
snipe 8699a90093 Fixed changelog 2014-11-05 22:05:32 -05:00
snipe 562e5cd700 Changelog generator 2014-11-05 22:03:01 -05:00
snipe 3f7486e1a9 Updated changelog 2014-11-05 22:02:51 -05:00
snipe 0eb6183711 New strings for translation 2014-11-05 21:16:26 -05:00
snipe cdf5ecc084 Merge pull request #336 from madd15/feature-updated-setting-view
Update Settings to contain PHP & Laravel versions
2014-11-05 21:03:27 -05:00
madd15 0eda46da0c Move side column back to top on the right 2014-11-06 11:23:07 +10:30
madd15 1047c5c8bb Update Settings to contain PHP & Laravel versions 2014-11-06 11:12:15 +10:30
snipe 5f6f3de25e Merge pull request #335 from madd15/feature-new-license-fields
Add Fields to Licenses and Update Supplier for Licenses
2014-11-05 18:26:57 -05:00
madd15 7833d10006 Add Fields to Licenses and Update Supplier for Licenses 2014-11-06 09:32:50 +10:30
snipe 122b3d89d9 Added assetlog to other status types 2014-11-05 16:11:07 -05:00
snipe 14801eca79 Merge branch 'develop' of github.com:snipe/snipe-it into develop 2014-11-05 16:10:11 -05:00
snipe 4a4b974f41 Merge pull request #333 from madd15/patch-1
Add assetlog to Deployed Loading
2014-11-05 16:09:55 -05:00
snipe ab7b828e33 Romanian translations 2014-11-05 16:08:54 -05:00
snipe b0e87d967a Arr! Pirate translations 2014-11-05 16:08:19 -05:00
snipe a0001fe1ed Arabic translations 2014-11-05 16:08:08 -05:00
madd15 ac5fa1641e Add assetlog to Deployed Loading 2014-11-06 07:35:49 +10:30
snipe 7c16dd8c92 Eager loading on other status types 2014-11-05 15:57:10 -05:00
snipe 294b02127b Don't show asset name field if there is none 2014-11-05 15:16:38 -05:00
snipe e04cc806d9 Fixes #327 2014-11-05 15:16:22 -05:00
snipe 2bee522a7c Included defaultLoc to assets view 2014-11-04 19:23:11 -05:00
snipe 5441dd41f0 Eager loading on assets listing 2014-11-04 18:58:16 -05:00
snipe 7858252fca More brazilian portuguese translations 2014-11-04 18:33:35 -05:00
snipe 6c6d31f15a A few more hungarian translations 2014-11-04 18:32:38 -05:00
snipe 6b2d3efe3e Fixes #237 - reporting-only group 2014-11-04 18:21:10 -05:00
snipe 1078dbf5c5 Fixes #324 2014-11-03 02:39:11 -05:00
snipe 300c262739 Merge pull request #320 from diwanicki/asset-view-edit-new-org
Adjustments to Asset Edit and Asset View layouts
2014-11-03 00:40:44 -05:00
snipe 25a7b05de6 Merge pull request #323 from madd15/patch-1
Fix if no asset selected sql error
2014-11-03 00:22:00 -05:00
madd15 70d7748229 Remove asterisk from asset 2014-11-03 15:48:51 +10:30
madd15 6315db7fd8 Allow checkout to user without asset 2014-11-03 15:35:04 +10:30
snipe 343798d241 Merge pull request #322 from madd15/fix-js-delete-asset
Delegate to table, add button to on()
2014-11-02 20:10:05 -05:00
snipe 5050862979 Merge pull request #321 from madd15/patch-5
Fix #318 - Missing end div causing layout issues
2014-11-02 17:34:36 -05:00
madd15 90baf2eeba Delegate to table, add button to on() 2014-11-03 08:58:19 +10:30
madd15 0022389463 Fix dropdown menu position 2014-11-03 08:24:53 +10:30
madd15 04123b3fe8 Missing end div causing layout issues 2014-11-03 08:12:34 +10:30
snipe 491de30374 Finnish translation via jarnok 2014-11-02 13:41:12 -05:00
snipe 0d402f52c8 Localization 2014-11-02 13:34:08 -05:00
diwanicki 55cd7c0f81 move br in notes div, almost there 2014-11-02 13:27:32 -05:00
diwanicki 63656762b0 changed style for notes, brd in div 2014-11-02 13:26:09 -05:00
diwanicki 87a9399b6b maybe a break? 2014-11-02 13:18:58 -05:00
diwanicki ed5ff9a01b trying hard space 2014-11-02 13:14:56 -05:00
diwanicki 68bf40a7ea typo2 2014-11-02 13:10:01 -05:00
diwanicki 0cf24bdde1 typo 2014-11-02 13:08:44 -05:00
diwanicki 05502cf29d trying serial in col-md12 2014-11-02 13:03:06 -05:00
diwanicki 1305ea9597 move in div? 2014-11-02 11:27:56 -05:00
diwanicki 94e1fcb01b maybe breaks? 2014-11-02 11:24:28 -05:00
diwanicki 9c01ab334f playing with paragraph tags 2014-11-02 11:22:05 -05:00
diwanicki b685ea666c em, small, and paragraphs 2014-11-02 11:17:34 -05:00
diwanicki ee35948980 fix div issues 2014-11-02 11:09:29 -05:00
diwanicki 569714315c Revert c122cc2..f094551
This rolls back to commit c122cc2647.
2014-11-02 10:54:52 -05:00
diwanicki f09455117b . 2014-11-02 10:51:45 -05:00
diwanicki af70559754 . 2014-11-02 10:50:35 -05:00
diwanicki 07e6d49dce . 2014-11-02 10:49:22 -05:00
diwanicki 86597bb863 more 2014-11-02 10:46:57 -05:00
diwanicki 6d057846a1 again 2014-11-02 10:45:33 -05:00
diwanicki ba9f8c61f1 more 2014-11-02 10:41:52 -05:00
diwanicki d3266dd4e8 still more 2014-11-02 10:40:10 -05:00
diwanicki 9143ac461f and more 2014-11-02 10:37:32 -05:00
diwanicki 7199d6fd22 more adjustments 2014-11-02 10:29:24 -05:00
diwanicki 2b21b26950 more layout adjustments 2014-11-02 10:24:34 -05:00
diwanicki c122cc2647 layout adjustments
layout adjustment to Notes field, hide Notes from asset creation log
display
2014-11-02 10:06:23 -05:00
diwanicki ced8610833 cleanup, reorder, restore Asset view and edit
reordered fields on Asset Add/Edit form to flow more logically.
reordered fields on Asset View to flow more logically. Restored serial
number to Asset View. Added Asset specific notes field to Asset View
(they are in the log as part of the initial asset creation, but need to
be more prominent, especially if the device has a lot of history.
adjusted wording in EN lang template for clarity.
2014-11-02 08:48:42 -05:00
snipe af63d34412 Updated language strings 2014-11-01 19:06:44 -04:00
snipe 9e85dcb9fc Fixes #315 - add EOL as display option in settings (run migrations) 2014-11-01 18:38:24 -04:00
snipe 687c629953 Bootstrap HTML cleanup 2014-11-01 17:45:28 -04:00
snipe 13b3e2c4d4 HTML cleanup 2014-11-01 17:42:15 -04:00
snipe 4d8e663bd1 Replaced hard-coded month string for languag support 2014-11-01 17:27:07 -04:00
snipe 3e11ea70da Reverting to old page title 2014-11-01 17:24:57 -04:00
snipe 86b7b6946f Fixes #316 - added model name back to view 2014-11-01 17:14:36 -04:00
snipe 3184c3e03b Updated language files 2014-10-30 07:51:11 -04:00
snipe 55eb4325bc Merge pull request #309 from madd15/patch-2
Allow checkout to user or asset
2014-10-29 23:15:18 -04:00
snipe d4ef8a75b8 Merge pull request #310 from madd15/patch-3
Change file name to str_random(25) & prevent upsizing
2014-10-29 23:14:56 -04:00
madd15 cf4804a994 Added constraint to image to prevent upsizing 2014-10-30 10:34:52 +10:30
madd15 22590e2a43 Change file name to str_random(25) 2014-10-30 09:52:20 +10:30
madd15 d9f86df05f Uncomment User section 2014-10-30 09:34:55 +10:30
madd15 636eb29421 Change rule back to asset_id required_without 2014-10-30 09:33:31 +10:30
snipe 5dea4c7691 Merge pull request #308 from madd15/patch-1
Fix Gravatar email lang and < conflict
2014-10-29 18:56:26 -04:00
madd15 672e2e5fd4 Add gravatar_email 2014-10-30 09:06:13 +10:30
madd15 42ad3da3d3 Moved part of gravatar label to new line
<small> was conflicting with @lang
2014-10-30 09:04:47 +10:30
snipe bb3aa99b9c Added CrowdIn badge 2014-10-29 18:33:13 -04:00
snipe 676155eacb Added translation link to footer 2014-10-29 17:50:21 -04:00
snipe 54071d1837 Updated readme for translation info 2014-10-29 17:49:55 -04:00
snipe 5abc4467df New placeholder language files for translations 2014-10-29 17:38:24 -04:00
snipe ffe095d64b Updates to language files 2014-10-29 17:38:07 -04:00
snipe ce566509ce Merge pull request #306 from madd15/patch-1
Allow spaces in category name
2014-10-29 14:27:48 -04:00
madd15 84cb51b4c3 Allow spaces in category name 2014-10-29 21:59:51 +10:30
snipe 9b0d930a21 Updated requirements in main README 2014-10-29 05:56:05 -04:00
snipe 1680d45163 Updated composer lock 2014-10-29 05:38:03 -04:00
snipe 5e1f61ea2a Ignore new uploads subdirectories 2014-10-29 05:37:48 -04:00
snipe 75d0136d7f Merge pull request #304 from madd15/feature-avatars
Feature local avatars and model images
2014-10-29 05:08:49 -04:00
madd15 30428cb858 Vars for lang - Image 2014-10-29 17:34:47 +10:30
madd15 26ab53c02c Added Location and Website 2014-10-29 17:33:10 +10:30
madd15 d8815b5ef5 Change to Vars for labels 2014-10-29 17:32:19 +10:30
madd15 e8737b156a Add image and avatar lang vars 2014-10-29 17:19:27 +10:30
madd15 f200e81334 Remove circle effect from image 2014-10-29 15:58:39 +10:30
madd15 03f3294873 Add images to models
Appropriate changes to views and controllers
includes migration and folder
2014-10-29 15:54:55 +10:30
madd15 da70d5042c uploads\avatars folder 2014-10-29 14:43:27 +10:30
madd15 239370058c changed to avatar 2014-10-29 14:28:24 +10:30
madd15 0b4c1b8d83 Feature Avatars
Appropriate changes to views and controllers
User Avatar Migration
Add intervention/image
2014-10-29 14:18:54 +10:30
snipe 736c9a1ad7 Merge pull request #302 from madd15/patch-2
Change Locations to sort by name asc
2014-10-28 02:05:05 -04:00
madd15 fb46a04d78 Change Locations to sort by name asc 2014-10-28 16:01:11 +10:30
snipe e9e332e19e Merge pull request #300 from madd15/patch-2
Change paginate to get for Index
2014-10-27 15:19:33 -04:00
madd15 16420dafa9 Change paginate to get for Index
Fixes #261 - Pagination appears to work correctly after this change
2014-10-27 12:14:55 +10:30
rob 22f81912e4 Fixes #299 2014-10-24 17:08:50 -04:00
snipe e61f93deb8 Merge pull request #297 from madd15/patch-4
Changed rtd_location_id for edit to match create
2014-10-24 16:38:18 -04:00
snipe 8d2b09a647 Merge pull request #298 from madd15/patch-1
Changed to == on $setting->qr_code
2014-10-24 12:11:36 -04:00
madd15 b11a0cb436 Changed to == on $setting->qr_code 2014-10-25 00:27:25 +10:30
madd15 dd923984ef Changed rtd_location_id for edit to match create
Forgot to change postEdit
2014-10-24 15:17:07 +10:30
snipe d36c73550b Merge pull request #296 from madd15/patch-4
Change rtd_location_id to allow no location set
2014-10-24 00:24:05 -04:00
madd15 bbfc87dddf Change rtd_location_id to allow no location set 2014-10-24 14:50:27 +10:30
snipe 90497bb6a4 Updated spanish translations 2014-10-23 23:37:15 -04:00
snipe 35ce00f6ab Merge remote-tracking branch 'origin/master' into develop 2014-10-23 23:22:51 -04:00
snipe 3cbd8c9b5d Added CrowdIn link 2014-10-23 23:22:35 -04:00
snipe 599520dff6 Squashed commit of the following:
commit 309772e67d
Author: snipe <snipe@snipe.net>
Date:   Thu Oct 23 22:43:06 2014 -0400

    Fixed operator for setting bool display

commit 139a0a2e2a
Merge: 88459b7 14a9500
Author: snipe <snipe@snipe.net>
Date:   Thu Oct 23 22:39:55 2014 -0400

    Merge branch 'develop' of github.com:snipe/snipe-it into develop

commit 88459b755f
Merge: 05fb2a4 e17de3d
Author: snipe <snipe@snipe.net>
Date:   Thu Oct 23 22:39:22 2014 -0400

    Merge branch 'madd15-patch-2' into develop

commit e17de3d34f
Merge: 062d16b a6cd7c0
Author: snipe <snipe@snipe.net>
Date:   Thu Oct 23 22:38:11 2014 -0400

    Merge branch 'patch-2' of github.com:madd15/snipe-it into madd15-patch-2

commit a6cd7c0bab
Author: madd15 <joshdeakin@adam.com.au>
Date:   Fri Oct 24 13:07:57 2014 +1030

    Changed to only one date for checkout date

commit 062d16b2c0
Merge: 05fb2a4 7f44d6d
Author: snipe <snipe@snipe.net>
Date:   Thu Oct 23 22:22:55 2014 -0400

    Merge branch 'patch-2' of github.com:madd15/snipe-it into madd15-patch-2

commit 7f44d6dd47
Author: madd15 <joshdeakin@adam.com.au>
Date:   Fri Oct 24 12:48:04 2014 +1030

    Add display_checkout_date to settings table

commit 9125def119
Author: madd15 <joshdeakin@adam.com.au>
Date:   Fri Oct 24 12:41:25 2014 +1030

    Add checkout_date

commit 024972e239
Author: madd15 <joshdeakin@adam.com.au>
Date:   Fri Oct 24 12:35:42 2014 +1030

    Add Checkout Date column

commit b0e1ef6024
Author: madd15 <joshdeakin@adam.com.au>
Date:   Fri Oct 24 12:32:44 2014 +1030

    Add Display Checkout Date

commit d74bddb51f
Author: madd15 <joshdeakin@adam.com.au>
Date:   Fri Oct 24 12:32:06 2014 +1030

    Add display_checkout_date

commit 189523a943
Author: madd15 <joshdeakin@adam.com.au>
Date:   Fri Oct 24 12:30:51 2014 +1030

    Add Display Checkout Date Setting

commit 98b96d372d
Author: madd15 <joshdeakin@adam.com.au>
Date:   Fri Oct 24 12:29:58 2014 +1030

    Add Display Checkout Date Setting

commit 14a9500c6f
Merge: 7bea50f 0e9e659
Author: snipe <snipe@snipe.net>
Date:   Thu Oct 23 20:12:45 2014 -0400

    Merge pull request #293 from madd15/patch-5

    Update Country, Change to Form::, Change state to max 32

commit 0e9e659dc4
Author: madd15 <joshdeakin@adam.com.au>
Date:   Fri Oct 24 10:40:14 2014 +1030

    Alter State to varchar(32) in Suppliers Table

commit 7bea50feca
Merge: 05fb2a4 fafd03f
Author: snipe <snipe@snipe.net>
Date:   Thu Oct 23 20:08:31 2014 -0400

    Merge pull request #294 from madd15/patch-4

    Added DB Prefix to Migrations

commit 8f582f29e2
Author: madd15 <joshdeakin@adam.com.au>
Date:   Fri Oct 24 10:17:19 2014 +1030

    Change state to max 32

commit cbf23fc455
Author: madd15 <joshdeakin@adam.com.au>
Date:   Fri Oct 24 10:16:08 2014 +1030

    Update Country, Change to Form::

commit fafd03f00f
Author: madd15 <joshdeakin@adam.com.au>
Date:   Thu Oct 23 11:47:46 2014 +1030

    Added DB Prefix to Migrations

    Added DB::getTablePrefix(); to migrations to fix #284

    not sure if there is another way to achieve this

commit 05fb2a434c
Merge: 255b618 e43a945
Author: snipe <snipe@snipe.net>
Date:   Sun Oct 19 18:47:12 2014 -0400

    Merge pull request #283 from madd15/patch-3

    Update table.action to table.actions

commit e43a94586b
Author: madd15 <joshdeakin@adam.com.au>
Date:   Mon Oct 20 08:46:27 2014 +1030

    Update table.action to table.action

commit 0d12428140
Author: madd15 <joshdeakin@adam.com.au>
Date:   Fri Oct 17 15:39:58 2014 +1030

    Reordered, Changed title and added per_page

    Reordered, Changed title and added per_page

commit 692c861594
Author: madd15 <joshdeakin@adam.com.au>
Date:   Fri Oct 17 15:36:31 2014 +1030

    Updated static text to Lang vars

    Updated static text to Lang vars

commit c68d76870e
Author: madd15 <joshdeakin@adam.com.au>
Date:   Fri Oct 17 15:35:56 2014 +1030

    Change all form to use Form:: & update Lang

    Updated <input> to Form::
    Update static text to Lang Vars
2014-10-23 22:46:20 -04:00
snipe 309772e67d Fixed operator for setting bool display 2014-10-23 22:43:06 -04:00
snipe 139a0a2e2a Merge branch 'develop' of github.com:snipe/snipe-it into develop 2014-10-23 22:39:55 -04:00
snipe 88459b755f Merge branch 'madd15-patch-2' into develop 2014-10-23 22:39:22 -04:00
snipe e17de3d34f Merge branch 'patch-2' of github.com:madd15/snipe-it into madd15-patch-2 2014-10-23 22:38:11 -04:00
madd15 a6cd7c0bab Changed to only one date for checkout date 2014-10-24 13:07:57 +10:30
snipe 062d16b2c0 Merge branch 'patch-2' of github.com:madd15/snipe-it into madd15-patch-2 2014-10-23 22:22:55 -04:00
madd15 7f44d6dd47 Add display_checkout_date to settings table 2014-10-24 12:48:04 +10:30
madd15 9125def119 Add checkout_date 2014-10-24 12:41:25 +10:30
madd15 024972e239 Add Checkout Date column 2014-10-24 12:35:42 +10:30
madd15 b0e1ef6024 Add Display Checkout Date 2014-10-24 12:32:44 +10:30
madd15 d74bddb51f Add display_checkout_date 2014-10-24 12:32:06 +10:30
madd15 189523a943 Add Display Checkout Date Setting 2014-10-24 12:30:51 +10:30
madd15 98b96d372d Add Display Checkout Date Setting 2014-10-24 12:29:58 +10:30
snipe 14a9500c6f Merge pull request #293 from madd15/patch-5
Update Country, Change to Form::, Change state to max 32
2014-10-23 20:12:45 -04:00
madd15 0e9e659dc4 Alter State to varchar(32) in Suppliers Table 2014-10-24 10:40:14 +10:30
snipe 7bea50feca Merge pull request #294 from madd15/patch-4
Added DB Prefix to Migrations
2014-10-23 20:08:31 -04:00
madd15 8f582f29e2 Change state to max 32 2014-10-24 10:17:19 +10:30
madd15 cbf23fc455 Update Country, Change to Form:: 2014-10-24 10:16:08 +10:30
madd15 fafd03f00f Added DB Prefix to Migrations
Added DB::getTablePrefix(); to migrations to fix #284

not sure if there is another way to achieve this
2014-10-23 11:47:46 +10:30
snipe 05fb2a434c Merge pull request #283 from madd15/patch-3
Update table.action to table.actions
2014-10-19 18:47:12 -04:00
madd15 e43a94586b Update table.action to table.action 2014-10-20 08:46:27 +10:30
madd15 0d12428140 Reordered, Changed title and added per_page
Reordered, Changed title and added per_page
2014-10-17 15:39:58 +10:30
madd15 692c861594 Updated static text to Lang vars
Updated static text to Lang vars
2014-10-17 15:36:31 +10:30
madd15 c68d76870e Change all form to use Form:: & update Lang
Updated <input> to Form::
Update static text to Lang Vars
2014-10-17 15:35:56 +10:30
snipe 255b618559 Updated for 1.0 release 2014-10-16 18:40:31 -04:00
snipe bf1e075551 Fixes #87 - made datatables responsive 2014-10-16 17:46:47 -04:00
snipe 7c97477a53 Added default location to physical hardware 2014-10-16 17:41:56 -04:00
snipe ee7d9bec70 Fixes #279 - QR checkbox not staying checked 2014-10-16 15:39:05 -04:00
snipe 58a99a2219 Merge pull request #246 from mrshu/patch-2
fix: Use the old asset tag when cloning
2014-09-10 11:51:31 -04:00
Marek Šuppa a829fcf52f fix: Use the old asset tag when cloning
* Removed previous use of placeholder, added code to set the old asset tag as the new one since it is being checked for uniqueness.
* For more rationale see our discussion with @technogenus in #241
2014-09-10 08:55:57 +02:00
snipe af450c9bcc Merge pull request #241 from mrshu/patch-1
views: Added old tag to placeholder when cloning
2014-09-08 14:25:32 -04:00
snipe 5575567726 Merge pull request #235 from rrdial/patch-1
Spelling correction.
2014-09-08 14:25:01 -04:00
snipe 97724a95e3 Merge pull request #242 from mizar1616/spanish
Spanish Translation 1.0
2014-09-08 14:23:15 -04:00
mizar1616 2bf57febd8 Spanish Translation
Ver 1.1
2014-09-08 15:19:35 +02:00
Marek Šuppa a82a35d921 views: Added old tag to placeholder when cloning
* Added the old tag to the placeholder attribute of the `asset_tag` input to improve the UX.
2014-09-08 14:45:06 +02:00
R Ryan Dial 94ead64386 Spelling correction. 2014-09-02 14:57:27 -04:00
snipe e978038cc0 Merge pull request #234 from burlito/typo-fix
fix typo: artisand -> artisan
2014-09-01 23:53:31 -04:00
Andrej Manduch 96e40d72b9 fix typo: artisand -> artisan
In few app.example.php config files was artisand instead artisan.

Signed-off-by: Andrej Manduch <amanduch@gmail.com>
2014-09-02 05:47:12 +02:00
snipe 284154a2d7 Merge remote-tracking branch 'origin/master' into develop 2014-08-17 04:38:19 -04:00
snipe e0da7ffe9b Updated composer lock 2014-08-17 04:38:01 -04:00
snipe 35479bfa40 Removed pre-update-cmd 2014-08-17 04:37:38 -04:00
snipe 582a9bf78b Make location_id nullable 2014-08-17 04:37:30 -04:00
snipe e8c197c6a5 No upper cap to password 2014-08-15 23:10:41 -04:00
snipe ec658b0cf5 Stronger input validation 2014-08-15 22:13:09 -04:00
snipe 68d44e65d3 XSS filtering 2014-08-15 22:12:48 -04:00
snipe 6fd0cbe044 Allow up to 50-character password 2014-08-15 21:02:41 -04:00
snipe 4629875bdf Removed ID from listbox debugging 2014-08-15 20:16:19 -04:00
snipe 297f986c4b Merge remote-tracking branch 'origin/develop' 2014-08-15 20:11:00 -04:00
snipe ccb49f4b23 I don't know why I have to keep committing this file 2014-08-15 20:10:52 -04:00
snipe 49c5607e1c Fixes #222 2014-08-15 20:05:48 -04:00
snipe 13f61e1e8a Newline 2014-08-15 19:46:10 -04:00
snipe cd4e994ef5 Removed erronerous "All the users!" text 2014-08-15 19:27:35 -04:00
snipe 974fb6b9ae Added language string for #222 2014-08-15 19:15:00 -04:00
snipe 4365659a2c Removed IDE files 2014-08-13 15:45:29 -04:00
snipe 363d084bd6 Fixed DB name in travis CI 2014-08-12 15:06:52 -04:00
snipe 69cd6404f5 Merge remote-tracking branch 'origin/develop' 2014-08-12 14:58:48 -04:00
snipe 229291999f ... 2014-08-12 14:58:40 -04:00
snipe 2cb61ab1c5 Added link to @GR360RY's Ubuntu Ansible/Vagrant 2014-08-12 14:57:53 -04:00
snipe 652f1c746c Fixes Travis CI build 2014-08-12 14:53:51 -04:00
snipe caaa96ec67 ... 2014-08-12 14:39:59 -04:00
snipe db49e570fd ... 2014-08-12 14:03:29 -04:00
snipe e242f8da0d Merge pull request #216 from cordeos/develop
A0.4.3 add asset, license, user, model clone and artisan db migration
2014-08-12 13:52:51 -04:00
Cordeos Team 8d3d8c86b1 A0.4.3 add asset, license, user, model clone and artisan db migration 2014-08-12 17:25:07 +09:00
Cordeos Team 144c9eb7f8 A0.4.2: asset, license, user, model cloning and move db migration 2014-08-12 15:54:12 +09:00
Cordeos Team 9ccc7d756f A0.4.2: Added asset, license, user, model cloning and fixed some bugs. 2014-08-12 14:28:41 +09:00
Cordeos Team b1fafa7ca4 Added asset, license, user and model cloning 2014-08-12 13:41:17 +09:00
Cordeos Team 62a3ed671b DB migration, layout and clone fixes 2014-08-11 20:18:45 +09:00
Cordeos Team 7ac06fa004 DB migration script Rev 0.11 2014-08-11 17:45:11 +09:00
Cordeos Team 54c3dfbcce Added licence clone 2014-08-11 17:19:28 +09:00
Cordeos Team 0dfc9660ca alpha 0.4.0 release candidate 2014-08-11 17:13:43 +09:00
Cordeos Team d6404dc734 0.4.1 release candidate 2014-08-11 13:32:24 +09:00
Cordeos Team d482b1ea69 0.4.0 release candidate 2014-08-11 13:22:42 +09:00
Cordeos Team 8c7be8fbb3 0.4.0 release candidate 2014-08-11 13:15:08 +09:00
Cordeos Team 3944ebddf3 0.4.0 release candidate 2014-08-11 13:14:22 +09:00
Cordeos Team 6cfb4ab5d8 0.4.0 release candidate 2014-08-11 13:10:00 +09:00
Cordeos Team 64abdddccb Database migration update 2014-08-10 22:59:57 +09:00
Cordeos Team 23a64cfe26 Database migration update 2014-08-10 22:35:14 +09:00
Cordeos Team 448b54d8e2 DBUpdate 2014-08-10 22:08:38 +09:00
Cordeos Team 72671d3e1d initial beta .4 draft 2014-08-10 20:01:38 +09:00
Cordeos Team efbe7b0fee initial beta .4 draft 2014-08-10 19:58:23 +09:00
Cordeos Team af083570a0 initial beta .4 draft 2014-08-10 19:09:08 +09:00
Cordeos Team 87c2a4c9c0 initial commit 2014-08-10 16:42:40 +09:00
root cb8369e9de Initial QA Patch to fix errors
Add License
Add Asset
Show Deleted Users
License Assign
2014-08-08 00:03:12 +09:00
root 6c5bbec44e Changes:
Updated user create to make LOCATION required - same as user edit
Own account password change updated to require only 6-12 characters
2014-08-05 14:56:37 +09:00
root d71a02982d Changes:
set new user create to active YES as default
Changed user password validation to 6-12 characters
Licenses controller removed asset_id from the INSERT column list
2014-08-05 13:36:47 +09:00
root b8a4c7e4d6 Initial COMMIT to set the file modified tracking. No changes made. 2014-08-05 13:22:08 +09:00
snipe 8197e6174e Fixes #200 2014-07-22 17:57:50 -04:00
snipe 3de929bb28 Merge pull request #199 from buzzedword/feature/gitignore-bin
Add bin directory to gitignore so vendor assets don't get committed.
2014-07-22 15:10:57 -04:00
snipe f2036e0951 Merge pull request #197 from jarnokurlin/develop
user id 3 does not exists!
2014-07-22 14:54:42 -04:00
Danny Garcia 213e313e45 Add bin directory to gitignore so vendor assets don't get committed. 2014-07-22 14:52:08 -04:00
snipe a695d8513c Merge pull request #198 from buzzedword/feature/bug-58
Fixed #58
2014-07-22 14:24:02 -04:00
Danny Garcia 69fca5d1ed Fixed #58
Added module scoping for all components, and stored lookups in event handlers instead
of querying live. Delays would erroniously cause values to persist.
2014-07-22 13:33:58 -04:00
Jarno Kurlin 94daba9bab user id 3 does not exists! 2014-07-22 18:53:45 +03:00
snipe 56d619b218 Fixed missing language string 2014-07-19 18:10:10 -04:00
snipe dc1033025a Fixed #151 - more complete translations 2014-07-19 17:53:04 -04:00
snipe a4b220d6c3 Fixed #191 - allow admins to assign a user during asset creation 2014-07-19 17:28:51 -04:00
snipe a8c2955218 Updated changelog 2014-07-19 01:30:24 -04:00
snipe 03cd9f893c Better asset dropdown to include user it's assigned to where applicable 2014-07-19 01:16:53 -04:00
snipe 4f04b96a13 Adding 5.6 back in 2014-07-18 23:55:44 -04:00
snipe d2d85436ad Tweaks to travis 2014-07-18 23:54:11 -04:00
snipe 85cd343bb6 Tried again - tweaking travis settings 2014-07-18 23:51:49 -04:00
snipe 6f6b98186e NFC why this is suddenly failing :( 2014-07-18 23:48:43 -04:00
snipe f855be45aa Removed 5.6 2014-07-18 23:45:01 -04:00
snipe ddf946ad5e Tried to fix failing build caused by travis composer 2014-07-18 23:42:36 -04:00
snipe 4a13cded60 Fixed path for Travis composer 2014-07-18 23:40:57 -04:00
snipe 27e43eebcb Added asset tag to license index view 2014-07-18 23:29:05 -04:00
snipe 196dbb856e Merge remote-tracking branch 'origin/develop' 2014-07-18 23:25:48 -04:00
snipe 3d91a43554 Added asset tag to asset list 2014-07-18 23:25:33 -04:00
snipe 9df9371ffe Merge remote-tracking branch 'origin/develop' 2014-07-18 20:25:12 -04:00
snipe ca24ef1cd8 Merge branch 'refs/heads/feature/add-asset-to-software' into develop
Conflicts:
	app/controllers/admin/LicensesController.php
2014-07-18 20:24:51 -04:00
snipe ac4c905c42 Fixed #140 2014-07-18 20:09:58 -04:00
snipe 7f48ca04b0 Updated changelog 2014-07-17 14:01:04 -04:00
snipe 39fff92bdb Updated changelog 2014-07-17 13:57:58 -04:00
snipe 43b98eff92 Merge remote-tracking branch 'origin/develop' 2014-07-17 13:54:10 -04:00
snipe e203fc516f Fixes #194 2014-07-17 13:51:58 -04:00
snipe ff61705a8f More edits for #140 2014-07-17 13:38:53 -04:00
snipe aa8bbb88e9 Updated MVC for #140, ability to assign software to asset (incomplete) 2014-07-17 08:33:30 -04:00
snipe 7d04ded02a DB migration for #140 2014-07-17 08:32:11 -04:00
snipe 04ea0528a8 Merge remote-tracking branch 'origin/develop' 2014-07-16 18:21:42 -04:00
snipe 89000440f3 Added admin ability to unsuspend locked accounts #changelog 2014-07-16 18:21:22 -04:00
snipe 73b469621f Merge remote-tracking branch 'origin/develop' 2014-07-13 07:35:28 -04:00
snipe e94087d62b Changed country to dropdown 2014-07-11 19:12:53 -04:00
snipe 21251b4623 Fixed #190, where depreciation on licenses would not be saved 2014-07-09 21:12:58 -04:00
snipe 381f99543f Merge remote-tracking branch 'origin/develop' 2014-07-09 11:58:47 -04:00
snipe 6f2b78ad9f Added DB migration for #15 2014-07-09 11:50:54 -04:00
snipe 6043321bed Added checkbox for marking an asset as requestable 2014-07-09 10:35:15 -04:00
snipe 03dffa3541 Added language string for requestable field 2014-07-09 10:34:54 -04:00
snipe 99003e126a Fixed bug with edit (supplier_id), added requestable field for assets 2014-07-09 10:34:39 -04:00
snipe 82a84310ed Added links to documentation and issues in footer 2014-07-09 08:45:11 -04:00
snipe 9dc40a3a9c Fixed a few CSS quirks 2014-07-09 08:45:02 -04:00
snipe 784f7e8dec WTF is wrong with me this morning? Hurr. 2014-07-09 07:08:15 -04:00
snipe deb9f42ec8 Added gitbook.io badge 2014-07-09 07:07:22 -04:00
snipe beb4d6500a Added back the line separators 2014-07-09 07:05:47 -04:00
snipe 45fa66b41e Updated copy 2014-07-09 07:03:10 -04:00
snipe 8eb2523293 Updated README to point to new documentation URL/branch 2014-07-09 07:02:08 -04:00
snipe 2b9494ed82 Fixed inconsistent password requirements across admin user creation, user profile and forgotten password 2014-07-09 05:18:53 -04:00
snipe 66c9264fcb More consistent spacing on forgotten password page (col-md-3) 2014-07-09 05:11:53 -04:00
snipe f22f23f21d Fixed button label on forgotten password page 2014-07-09 05:10:57 -04:00
snipe 90eb883b67 Fixed #187 - replaced dummy site name with site name from admin panel preferences 2014-07-09 05:04:49 -04:00
snipe 300358bc46 Link to demo 2014-07-09 03:38:09 -04:00
snipe 3cffff3415 Added "still maintained" badge 2014-07-09 03:22:02 -04:00
snipe 4253744d9d Merge remote-tracking branch 'origin/develop' 2014-07-09 03:10:42 -04:00
snipe 6b5a552d95 Fixed #186 - Bug with select box not retaining selections on edit screen 2014-07-09 03:09:55 -04:00
snipe 43485e1a51 Fixed language definition 2014-07-09 02:50:58 -04:00
snipe 5cdceb1db1 Merge remote-tracking branch 'origin/develop' 2014-07-08 19:55:03 -04:00
snipe 0c285d64bc Tightened up Bootstrap 3 design, took care of leftover elements from 2.3 2014-07-08 19:47:19 -04:00
snipe 38cdbf8804 Added submit button language file 2014-07-08 19:44:17 -04:00
snipe 9606834e14 Made password length match 10 character standard imposed by admin user creation 2014-07-08 19:44:06 -04:00
snipe 276b1553c1 Mark required form elements as required 2014-07-08 19:17:31 -04:00
snipe 182f2bfa62 Merge remote-tracking branch 'origin/develop' 2014-07-08 05:38:27 -04:00
snipe 5266d9a30a Fixed title tag for user list view 2014-07-08 05:38:07 -04:00
snipe 6068a940bd Added employee number to user view, per #183 2014-07-08 04:44:36 -04:00
snipe fc032c95b4 Misc indenting 2014-07-08 04:40:09 -04:00
snipe 2265b9321e Additional language strings for #151 2014-07-08 04:40:01 -04:00
snipe a7b809cb91 Updated title/header for users, additional fixes for #151 2014-07-08 04:39:51 -04:00
snipe af269b536e Refactored users to use same form for edit/create 2014-07-08 04:35:23 -04:00
snipe 89a8f3c277 Fixes #183 - added employee number to users 2014-07-08 02:57:15 -04:00
snipe 57b3f6c44f Security recommendations 2014-07-07 13:58:51 -04:00
snipe 380ff9917d Updated changelog for newest release 2014-07-02 22:12:06 -04:00
snipe 6532f1aba5 Merge remote-tracking branch 'origin/develop' 2014-07-02 22:08:38 -04:00
snipe 49dfd259b4 Props where props are due, yo. 2014-07-02 22:05:09 -04:00
snipe fad2ec66fa More README fixes and refinement 2014-07-02 22:00:45 -04:00
snipe e455de65f9 Added table of contents outline to README for easier readability 2014-07-02 21:54:33 -04:00
snipe 7a0c1cc6ff Streamlined README for easier production install, developer instructions moved to the bottom. 2014-07-02 21:43:37 -04:00
snipe 2517359f3a Merge remote-tracking branch 'origin/develop' 2014-07-02 14:58:27 -04:00
snipe c782f29f5a Pulled account sub-nav into top menu to free up UI space. #changelog 2014-07-02 13:56:12 -04:00
snipe 2825bcb431 Fixed #179 - account page to show assets checked out to the logged in user 2014-07-02 13:55:34 -04:00
snipe 1117c2958a Slightly nicer output 2014-06-27 20:17:42 -04:00
snipe 4464c221b7 Better changelog 2014-06-27 19:05:13 -04:00
snipe 21e6f2c249 Merge remote-tracking branch 'origin/develop' 2014-06-27 17:28:22 -04:00
snipe ec9eab81bf Closes #177 - change log file added, needs refining 2014-06-27 17:27:53 -04:00
snipe b863bd2c53 Merge remote-tracking branch 'origin/develop' 2014-06-26 13:28:41 -04:00
snipe 09ca2be28d Merge pull request #175 from leostat/develop
Fix for ~167
2014-06-26 13:28:12 -04:00
leostat a170efae27 fix for #167 2014-06-26 11:10:13 +01:00
leostat 919119c5b9 Sanatise fullname class #167 2014-06-26 10:45:31 +01:00
snipe 7cb0db5b83 Added local flag for easier install 2014-06-25 04:24:13 -04:00
snipe d24c4ed7eb Widened column for nicer layout 2014-06-24 18:22:26 -04:00
snipe a0f7083e9c Improved bootstrap nav for mobile 2014-06-24 18:04:15 -04:00
snipe 8b914102b7 Updated spacing for PSR-2 2014-06-24 17:49:39 -04:00
snipe 77f4848d6e Missed a few 2014-06-24 17:45:21 -04:00
snipe afabd28142 Additional fixes for #167 2014-06-24 16:28:20 -04:00
snipe 67d23bdb45 Janky url validator to add http:// 2014-06-24 15:51:13 -04:00
snipe 124acc89c4 Resolves #174 2014-06-24 14:15:39 -04:00
snipe 5c0e912080 Merge remote-tracking branch 'origin/develop' 2014-06-23 23:52:51 -04:00
snipe 47a8363f1d Merge pull request #173 from madd15/develop
Remove Double 'Display QR Codes' and change triple =
2014-06-23 23:48:15 -04:00
snipe b09aec67f1 Fixes #155 2014-06-23 23:46:14 -04:00
snipe 86400f435b New list URL 2014-06-23 23:36:13 -04:00
madd15 82f0c6f00c Change to Triple = and no ' 2014-06-24 13:02:13 +09:30
madd15 9fe76a21f6 Remove double 'Display QR Codes' 2014-06-24 12:46:37 +09:30
snipe 264a6e304d Link to mailing list 2014-06-23 23:12:45 -04:00
snipe ad62ec7540 Merge pull request #172 from madd15/develop
Check boxes in settings not showing correct settings
2014-06-23 23:06:25 -04:00
madd15 3b9f96419b Check boxes not showing correct settings 2014-06-24 12:31:43 +09:30
snipe 6b8ed1a1ad Merge pull request #171 from madd15/develop
Change Back Button Icon on Update Supplier
2014-06-23 22:44:06 -04:00
madd15 164ca5f77b Change Back Button Icon on Update Supplier 2014-06-24 12:12:45 +09:30
snipe a142afe177 Oops. Forgot zip code. 2014-06-23 22:38:19 -04:00
snipe 15d48c903e Helpful links for hardware view 2014-06-23 22:33:42 -04:00
snipe cbd3420327 Better phrasing 2014-06-23 22:23:14 -04:00
snipe 380417953b Fixed missing string 2014-06-23 22:17:07 -04:00
snipe 6f42b3045e Resolves #155 2014-06-23 22:09:32 -04:00
snipe b717a3ee34 Merge pull request #170 from madd15/develop
Fix #117
2014-06-23 20:59:16 -04:00
madd15 945cb3253f Fix #117
Fix CCS for #117
#166 also fixed edit user page
2014-06-24 10:25:35 +09:30
snipe 3e7a9e45d1 Fixes PR #168 and #167 2014-06-23 19:40:09 -04:00
snipe 0c9d94deb1 Merge pull request #166 from madd15/develop
No Result on user page not showing correctly
2014-06-23 18:19:41 -04:00
madd15 19de7425e6 Select2.css image paths - #2
Change image paths in select2.css to match correct location of images.
Damn I fail.
2014-06-23 10:37:54 +09:30
madd15 3cc038208f Revert "Select2.css image paths"
This reverts commit a48efb8855.
2014-06-23 10:33:22 +09:30
madd15 a48efb8855 Select2.css image paths
Change image paths in select2.css to match correct location of images.
2014-06-23 10:18:02 +09:30
Josh Deakin 7ddf84adf7 Change Warning to Info User no results 2014-06-21 12:43:18 +09:30
Josh Deakin 57628d725e User No Results
Change No Results on user page to general no results
2014-06-21 12:37:51 +09:30
snipe 45f353e575 Merge remote-tracking branch 'origin/develop' 2014-06-19 22:23:09 -04:00
snipe bef5170b7c More cleanup 2014-06-19 22:19:20 -04:00
snipe e7e75631c5 Merge remote-tracking branch 'origin/bugs/160' into develop 2014-06-19 22:15:44 -04:00
snipe a4c931e4fd Cleanup 2014-06-19 22:14:54 -04:00
snipe d1499deecd Provisions for strict mode, fixed license deletion bug 2014-06-19 22:13:59 -04:00
snipe b365ada0ce Provisions for strict mode 2014-06-19 22:13:43 -04:00
snipe 185ffd3df1 Merge remote-tracking branch 'origin/develop' 2014-06-19 18:27:59 -04:00
snipe 5fdb61589f Linked to Waffle in text 2014-06-19 18:20:14 -04:00
snipe b3292c3a35 Updated README with waffle.io info 2014-06-19 18:14:21 -04:00
snipe 4ce1c94bc3 Merge remote-tracking branch 'origin/master' into develop 2014-06-19 16:10:27 -04:00
snipe 08d05b481f Fixes #158 2014-06-19 16:10:00 -04:00
snipe 7742bb30c1 Merge remote-tracking branch 'origin/develop' 2014-06-18 16:04:46 -04:00
snipe bf3062f4ef Merge pull request #160 from exula/issue-125-license-seat
Improve License Editing to add or delete seats
2014-06-18 15:48:52 -04:00
Brad Coudriet 8f744e02fd Improve License Editing to add or delete seats 2014-06-18 13:39:54 -04:00
snipe ba3e56df9a Merge remote-tracking branch 'origin/develop' 2014-06-17 14:07:32 -04:00
snipe 8aebaaf502 Few more localization strings for #151 2014-06-10 04:15:50 -04:00
snipe c937796224 More language strings, per #151 2014-06-09 21:30:58 -04:00
snipe 74653d3480 More refactoring of language structure, language strings per #151 2014-06-09 19:56:47 -04:00
snipe 65d298a557 Merge branch 'develop' of github.com:snipe/snipe-it into develop
Conflicts:
	.travis.yml
2014-06-09 18:34:58 -04:00
snipe 04f23ef792 Encrypted slack API token after regen 2014-06-09 18:27:16 -04:00
snipe 507b6e5128 Merge pull request #154 from buzzedword/patch-2
Update .travis.yml
2014-06-09 18:22:21 -04:00
Danny Garcia 4271f5265d Update .travis.yml
Added composer validation to fail fast on travis build instead of going directly to install.
2014-06-09 18:19:22 -04:00
snipe d9a8ede623 Merge pull request #153 from buzzedword/patch-1
Update composer.json
2014-06-09 18:06:03 -04:00
Danny Garcia 117ed3294b Update composer.json
Modified composer.json away from laravel defaults to be more on brand.

- Specified support locations
  - Issues
  - Source
- Added license shorthand as defined by http://spdx.org
- Added homepage
- Added keywords
- Added name
- Added description
2014-06-09 18:03:08 -04:00
snipe cd0f42c508 Alphabetized language files, more for #151, refactoring language string hierarchy. 2014-06-09 17:45:52 -04:00
snipe 2fe66c1bdc More internationalization per #151 2014-06-09 16:01:44 -04:00
snipe dae3220f2b Nicer formatting when 0 years 2014-06-09 02:52:19 -04:00
snipe 7448db6334 Notes on feature branches 2014-06-09 02:04:21 -04:00
snipe 2f90069792 Updated to request translation files 2014-06-09 01:59:03 -04:00
snipe ffab309940 More internationalization improvements per #151 2014-06-09 01:47:05 -04:00
snipe 34b4615f4e Additional internationalization for Hardware per #151 2014-06-09 01:12:08 -04:00
snipe 75590b6852 More internationalization strings for #151 2014-06-09 00:49:52 -04:00
snipe 610c405aa5 More fixes for #151 2014-06-09 00:25:45 -04:00
snipe 94016678f8 More internationalization per #151 2014-06-09 00:02:31 -04:00
snipe dc256583d4 Fixes #144 2014-06-06 13:40:54 -04:00
snipe cbc945299e Fixes #148 2014-06-05 13:39:14 -04:00
snipe 607484b294 Fixes #141 for mysql with strict mode enabled 2014-05-27 19:51:24 -04:00
snipe 9714178ce1 Fixes #141 2014-05-24 05:48:50 -04:00
snipe 46afc0cc73 Merge remote-tracking branch 'origin/develop' 2014-05-12 20:30:30 -04:00
snipe dfa5d1c642 Fixes #136 2014-05-12 18:06:49 -04:00
snipe e463b28b37 Deliberately vague message when user account doesn't exist 2014-05-06 16:16:19 -04:00
snipe 9db6605085 Smaller name requirement, to allow for folks like AJ Li, etc. 2014-05-06 16:08:05 -04:00
snipe d57955c7e7 Enforce password requirements on password reset 2014-05-06 16:07:00 -04:00
snipe ad9b1fc446 Fixes #139 2014-05-06 16:06:43 -04:00
snipe 3518ab9f55 Fixes #139 2014-05-06 16:06:22 -04:00
snipe cd8ebbd7b6 Merge remote-tracking branch 'origin/develop' 2014-05-06 05:29:03 -04:00
snipe c2ed0f6b21 More auth refinement 2014-05-06 04:26:21 -04:00
snipe f4c5da57d0 Fixed auth error when user isn't logged in 2014-05-06 04:17:46 -04:00
snipe 8a7f71ec56 Better handling of non-admin roles 2014-05-06 04:14:14 -04:00
snipe b627c5cfbf More translation substitutions 2014-05-06 03:39:02 -04:00
snipe c21c3a4a9e Removed erroneous PDF option 2014-05-06 03:38:51 -04:00
snipe d29e30bcf6 Translations 2014-05-06 03:38:05 -04:00
snipe 1cf42932fb Added currency symbol 2014-05-06 03:35:47 -04:00
snipe fee5fcf608 Titles for Group admin 2014-05-06 03:35:34 -04:00
snipe e512b8f7ef Removed hardcoded USD symbol 2014-05-06 03:35:03 -04:00
snipe 5e1fedda45 Added Travis-CI badge 2014-05-06 01:28:21 -04:00
snipe d0789da472 Copy the mail config file to prod for CI build as well. Duh. 2014-05-06 01:22:01 -04:00
snipe fc21fc1aab Put prod database file in app/config 2014-05-06 01:13:24 -04:00
snipe 24ae1b948f Updated username so the DB can be created
(travis CI doesn't allow custom DB usernames)
2014-05-06 01:07:16 -04:00
snipe f1cc547151 Copy DB config file for travis 2014-05-06 01:02:49 -04:00
snipe 594212db6b Merge remote-tracking branch 'origin/develop' 2014-05-06 00:50:05 -04:00
snipe ca0f5df63a Reverting Pull Request #138 2014-05-06 00:48:09 -04:00
snipe 57e903a926 Added Diff language string 2014-05-06 00:10:29 -04:00
snipe 06067fc19c Fixed CSV rexport 2014-05-06 00:10:19 -04:00
snipe 67aba76d3f Fixing this change from #109 that somehow got reverted 2014-05-05 23:41:41 -04:00
snipe 96e47612fa Longer default password requirement 2014-05-05 23:40:05 -04:00
snipe 97af71d592 Merge remote-tracking branch 'origin/develop' 2014-05-05 22:19:31 -04:00
snipe 71c0c01430 Updated environmental config for hostname-only 2014-05-05 22:02:32 -04:00
snipe 78f4615d01 Travis CI 2014-05-05 21:59:23 -04:00
snipe d93639d480 Updated README for 4.1 2014-05-05 21:38:18 -04:00
snipe 70fb2d98a0 Merge remote-tracking branch 'origin/develop'
Conflicts:
	.gitignore
2014-05-05 21:36:16 -04:00
snipe 34960e26cc Merge pull request #138 from refinery29/qr-codes-ftw
Add site setting to define text below asset QR codes
2014-05-05 21:31:45 -04:00
snipe 3473ef5fa6 Updated to Laravel 4.1 2014-05-05 21:28:58 -04:00
snipe 2fc197623a Update to Laravel 4.1 2014-05-05 21:21:56 -04:00
snipe 7bc681dfef Bumped to laravel 4.1 2014-05-05 20:38:02 -04:00
Jake McGraw af603f0380 make text below asset tags configurable 2014-05-03 20:06:59 +00:00
snipe 1d10425d19 Merge pull request #135 from Zyg0te/develop
Adjusted zip and state field length requirements
2014-04-29 17:21:03 -04:00
Zyg0te 5690e9ce1f Fixed code indentation for Apache virtualhost example
The code indentation was incorrect, borking the syntax highlighting in
the README.
2014-04-24 11:25:55 +02:00
Zyg0te 792e45bd12 Adjusted zip and state field length requirements
State abbreviations, if used at all, are not neccessarily 2 characters
outside the US and zip codes aren't always 5 digits either. It's
probably a good idea not to enforce US centric length requirements to
these fields in the Location model.
2014-04-24 11:20:20 +02:00
snipe 5a798110ad Merge branch 'refs/heads/develop' 2014-04-22 02:26:54 -04:00
snipe ad8b95f07c Merge pull request #130 from FleischKarussel/patch-1
vhost.conf for linux mod_rewrite enabled
2014-04-04 14:07:50 -04:00
FleischKarussel 729f94331f vhost.conf for linux mod_rewrite enabled 2014-04-04 13:17:31 +02:00
snipe faa9b95a6f Merge pull request #128 from FleischKarussel/patch-1
https for getcomposer and github downloads
2014-04-03 15:11:03 -04:00
FleischKarussel 0e633efca2 https for getcomposer and github downloads 2014-04-03 17:10:41 +02:00
snipe b2015e7e08 Merge pull request #127 from domtancredi/develop
Fix for broken datatables in upgrading to v2.2
2014-03-18 17:07:12 -04:00
Dom Tancredi efad5db082 Fix for broken datatables in upgrading to v2.2 2014-03-16 15:00:30 -04:00
snipe 9423c9e9d3 Merge pull request #124 from DGAzr/develop
Adding escape to the dash so that it is a literal rather than a range
2014-02-11 14:31:49 -05:00
Dustan Ashley 366e7d01a3 Adding escape to the dash so that it is a literal rather than a range 2014-02-11 07:24:27 -05:00
snipe 869cd3ea14 Merge branch 'refs/heads/develop'
Conflicts:
	.gitignore
2014-01-28 23:24:07 -05:00
snipe a2f068eb8f Missed one 2014-01-28 20:28:31 -05:00
snipe 580590b4c0 Fixed === to == (PHP is loosely typed) 2014-01-28 20:24:37 -05:00
snipe 5ec87e81b1 Handle logs/views dir better 2014-01-28 18:05:15 -05:00
snipe 60d94eea04 Changes serial to text area, allow new lines. Fixes #118 2014-01-28 17:42:20 -05:00
snipe 78e3171fa6 Merge branch 'develop' of github.com:snipe/snipe-it into develop 2014-01-28 17:41:35 -05:00
snipe d03d692868 Merge pull request #121 from buzzedword/feature/default-directories-in-storage
Added default folder structure for laravel.
2014-01-28 14:37:46 -08:00
Daniel Garcia 4b4eefb4cc Added default folder structure for laravel. 2014-01-28 17:35:57 -05:00
snipe 940cf7b227 Merge pull request #120 from buzzedword/feature/patch-1
Add logs and views folder to repo, omit additional files.
2014-01-28 14:02:35 -08:00
Daniel Garcia 3e47e47add Add logs and views folder to repo, omit additional files. 2014-01-28 16:59:10 -05:00
snipe 8b3f409703 Added logs and views dir 2014-01-28 16:56:33 -05:00
snipe d497a84245 Merge pull request #119 from refinery29/qr-codes-ftw
Added support for QR codes in Asset view
2014-01-28 11:52:22 -08:00
Jake McGraw 01612652b5 use same dimensions in render and display 2014-01-28 05:33:03 +00:00
Jake McGraw 5cb0a1465e added QR code route for asset controller
added QR code inclusion on asset controller getView  action/template
2014-01-28 05:16:57 +00:00
Jake McGraw 55b54e0a42 added sql migration for qr_code in settings table
added baconqr to composer package list
added admin settings page for qr code
2014-01-28 04:25:58 +00:00
snipe a3eb61b307 Cleaned up gitignore 2014-01-14 18:41:07 -05:00
snipe 9e5e9ee96b Minor formatting change 2014-01-14 18:34:36 -05:00
snipe 92347c6707 Full path to avoid any confusion 2014-01-14 18:26:52 -05:00
snipe dc5ea81d34 Backticks are hard. 2014-01-14 18:23:56 -05:00
snipe 9c369d72e1 Fixed typo 2014-01-14 18:20:41 -05:00
snipe ea0560e1ce Updated readme for #116 2014-01-14 18:19:22 -05:00
snipe cd62be0de0 Minor div fix 2014-01-04 18:35:06 -05:00
snipe e186bb115d Merge branch 'refs/heads/develop' 2014-01-04 18:28:05 -05:00
snipe 7a3f6fb714 Merge branch 'refs/heads/feeva-localization' into develop 2014-01-04 18:25:57 -05:00
snipe 1ed761c97f Merge branch 'localization' of github.com:feeva/snipe-it into feeva-localization
Conflicts:
	app/views/backend/layouts/default.blade.php
2014-01-04 18:25:25 -05:00
snipe a193e3118d Merge pull request #113 from feeva/issue58-modal-failure
Issue #58 - Modal stops passing title/message/href through if modal is canceled
2014-01-04 15:09:44 -08:00
feeva e9a675a9a4 Merge branch 'issue58-modal-failure' of https://github.com/feeva/snipe-it into issue58-modal-failure 2014-01-04 18:24:42 +00:00
feeva 439a139d7c Issue #58 - Modal stops passing title/message/href through if modal is
canceled
2014-01-04 18:23:52 +00:00
feeva 40d6ad09ae Hard-coded English text strings should be moved to their language files 2014-01-04 17:55:19 +00:00
mars 3acd88d451 Issue #58 - Modal stops passing title/message/href through if modal is
canceled
2013-12-26 02:51:01 +09:00
snipe 8806208e83 More gracefully handle TokenMismatchException errors 2013-12-13 14:34:09 -05:00
snipe 5ba487d74e Removed CSRF filters - they already run elsewhere 2013-12-13 14:33:42 -05:00
snipe 7c12d5fed0 Merge branch 'refs/heads/develop' 2013-12-12 01:52:59 -05:00
snipe f6717d9f49 Added manager drop down for users, manager name in index 2013-12-12 01:49:38 -05:00
snipe 3ec6df492d Added manager_id to DB, install script 2013-12-12 01:12:42 -05:00
snipe cdddbcf695 Using URL::previous to determine back button address 2013-12-12 00:50:56 -05:00
snipe 483f9b1289 Slight layout tweak for smaller buttons 2013-12-10 17:13:33 -05:00
snipe b2912195ac Added EOL to report view 2013-12-10 14:56:16 -05:00
snipe 19b524e113 Merge branch 'refs/heads/develop' 2013-12-10 13:01:05 -05:00
snipe 1cec46f997 Updated comment, made save on edit return to listing page 2013-12-10 05:17:15 -05:00
snipe 4468cbd096 Fixes #112 2013-12-10 04:48:40 -05:00
snipe 4c3e2a9a68 DB seeding for #112 2013-12-10 03:52:23 -05:00
snipe da9f28fbe7 DB migration for #112 2013-12-10 03:48:20 -05:00
snipe 8ac394bd3f Escaping parens 2013-12-06 12:36:43 -05:00
snipe ff22ee8292 Merge branch 'refs/heads/develop' 2013-12-06 06:40:43 -05:00
snipe d36409d037 Layout improvements 2013-12-06 05:18:04 -05:00
snipe 7e9be9b935 Truncate serial on index view at 40, UX improvements 2013-12-06 05:07:26 -05:00
snipe dd701d253c Set values to null if they are 0 2013-12-06 04:59:24 -05:00
snipe 78b3a0e1f9 Make license fields nullable migration 2013-12-06 04:58:53 -05:00
snipe 1e9a81f59d Cleanup for licenses view page 2013-12-06 04:58:37 -05:00
snipe 432f44118f Fixed FK in licenses model 2013-12-06 04:58:21 -05:00
snipe b697c77cd8 Fixing error when no depreciation 2013-12-06 02:50:14 -05:00
snipe 23ce0a9e67 Missing closing divs 2013-12-06 02:46:38 -05:00
snipe 0cd6c60fd9 Cleaner license UI 2013-12-06 02:41:53 -05:00
snipe 82de635a75 Fixed invalid seed data 2013-12-06 02:10:08 -05:00
snipe 299393aa26 Set the log to track the license_id instead of seat id 2013-12-06 02:09:46 -05:00
snipe 7bc9a53b13 Fixed error when user is invalid 2013-12-06 02:09:23 -05:00
snipe c1bf27fcba Better comments 2013-12-05 22:14:24 -05:00
snipe d72daf14ff Added filename to log seeder for mysql strict mode 2013-12-04 12:14:02 -05:00
snipe c5678414ae Groundwork for #11 2013-12-04 12:13:23 -05:00
snipe 329980c6c6 Unsquished blade for group display 2013-12-04 12:05:37 -05:00
snipe 5fb649b59e Fixed error message layout 2013-12-03 19:26:01 -05:00
snipe 900a441908 Merge branch 'refs/heads/develop' 2013-12-03 13:32:20 -05:00
snipe 19de8a15cf Allow numbers signs, parens 2013-12-03 13:31:42 -05:00
snipe ab99e6a64f Changed alpha_dash to alpha_space for Axure licenses
(which have slashes in them)
2013-12-03 06:50:58 -05:00
snipe 5dc9c30bca Duplicate field 2013-12-03 06:34:05 -05:00
snipe 9308059230 Can't enforce unique here, or it will see itself and fail 2013-12-03 06:26:27 -05:00
snipe ac9dfe2edc DESC? WTF? Hurr. 2013-12-03 06:14:02 -05:00
snipe ae26b683fb Merge branch 'refs/heads/develop' 2013-12-03 06:08:44 -05:00
snipe cf9cd1a7a0 Allow slashes 2013-12-03 06:08:05 -05:00
snipe 194150bbf0 Hacky shit to fix pagination weirdness - will come back to this 2013-12-03 06:02:29 -05:00
snipe b97f5fc043 Serial should be unique for hardware 2013-12-03 05:46:19 -05:00
snipe aaebaa8d36 Bugfix to put custom title in the page title 2013-12-03 05:41:03 -05:00
snipe ef4743ed49 Specifying feature branches 2013-12-03 05:40:44 -05:00
snipe 6737a9a91a Added quick create menu to topnav 2013-12-03 05:14:56 -05:00
snipe 965d329ae5 Order by name in user drop down list 2013-12-03 04:53:07 -05:00
snipe e4fd2373fb Changed table to show asset tag 2013-12-03 04:52:51 -05:00
snipe e784854e05 Changed column from asset name to model 2013-12-03 04:24:34 -05:00
snipe c4c4db201f Changed th sizes 2013-12-03 04:07:54 -05:00
snipe 33df88d434 Only print name if there is one 2013-12-03 04:07:34 -05:00
snipe f02f4341ca Tweaked table layout 2013-12-03 03:40:28 -05:00
snipe 211a527ae1 Fixed FK 2013-12-03 03:40:15 -05:00
snipe cc275367bf Removed close button on 'no results' error 2013-12-03 03:18:39 -05:00
snipe 65e0e4d749 Merge branch 'refs/heads/develop' 2013-12-03 03:15:40 -05:00
snipe 1dc7fd1bdf Fixed depreciation display on asset view 2013-12-03 03:15:02 -05:00
snipe e49420f62d Fixed bug in depreciation display 2013-12-03 03:02:00 -05:00
snipe 9fe8ace39b Order form lists by name 2013-12-03 02:41:16 -05:00
snipe d591c1ea04 Fixed bug where RTD = 1 instead of 0 2013-12-03 02:14:05 -05:00
snipe ae05f27015 Fixed depreciation bug 2013-12-03 02:05:00 -05:00
snipe b8ebcf769a Added model name to listing 2013-12-03 01:28:21 -05:00
snipe 9c718dce59 Removed serial requirement 2013-12-03 01:11:23 -05:00
snipe efb3ed4932 Merge branch 'refs/heads/develop' 2013-12-03 00:20:25 -05:00
snipe e09d250dd6 Removed name as required field 2013-12-03 00:19:22 -05:00
snipe 4d27008c5d Commented out breaking data table 2013-12-03 00:18:59 -05:00
snipe cfd6c4301c Merge pull request #110 from flashingcursor/develop
Started implementing Datatables ... User table partially implemented.
2013-12-02 03:09:10 -08:00
snipe dddba1198d Merge pull request #109 from desmondmorris/report-csv-export
Implements first pass at csv exports of reports
2013-12-02 03:08:57 -08:00
Gil Rutkowski a0267db832 Datatables partially implemented on user table. 2013-12-02 00:21:04 -06:00
Desmond Morris 0d46eba76e Updates csv export link path 2013-12-01 22:23:55 -05:00
Desmond Morris c8e47ad00e Adds fullname of user assigned user to report export 2013-12-01 22:16:16 -05:00
Desmond Morris 47b065208e Implements first pass at csv exports of reports (#35) 2013-12-01 22:04:56 -05:00
snipe edf71a7692 Merge branch 'refs/heads/develop' 2013-12-01 21:44:06 -05:00
snipe 775ec10114 Change cursor so that it doesn't change to a hand if not sortable 2013-12-01 21:43:34 -05:00
snipe d19721d17a Merge pull request #108 from desmondmorris/disable-sortable-actions
Removes sorting from actions column.  Fixes #56
2013-12-01 18:04:22 -08:00
Desmond Morris c11510fdca Removes sorting from actions column. Fixes #56 2013-12-01 20:54:43 -05:00
snipe 1f2b3f8505 Merge pull request #107 from desmondmorris/composer-json-formatting
Fixes composer formatting issues
2013-12-01 17:32:49 -08:00
Desmond Morris fba853a6a7 Fixes composer formatting issues 2013-12-01 20:24:02 -05:00
snipe 1af24827bd Merge branch 'refs/heads/develop' 2013-12-01 19:03:23 -05:00
snipe 392cc8eb44 Grammar is hard. 2013-12-01 19:03:06 -05:00
snipe c21a1ef16b Merge branch 'refs/heads/develop' 2013-12-01 19:00:34 -05:00
snipe 46281dd39b Merge branch 'develop' of github.com:snipe/snipe-it into develop 2013-12-01 19:00:08 -05:00
snipe db2c751480 Merge pull request #105 from desmondmorris/develop
Fixes mail config documentation
2013-12-01 15:59:24 -08:00
Desmond Morris c08d672e49 Fixes mail config documentation 2013-12-01 18:50:58 -05:00
snipe 70c446cb35 Baseline test class - nothing good here yet 2013-12-01 18:47:40 -05:00
snipe 2de48f2b91 This gets created by the user 2013-12-01 18:45:47 -05:00
snipe 391334ee13 WTF seriously? 2013-12-01 18:40:46 -05:00
Gil Rutkowski a678ec4171 Fixed Gravatar Hash 2013-12-01 17:11:44 -06:00
snipe ea42a18930 Merge pull request #99 from flashingcursor/develop
Datatables groundwork, minor tweaks.
2013-12-01 13:34:44 -08:00
Gil Rutkowski 36a714b154 Published debug bar assets on install. Moved jQuery & data tables to the head. Added Chumper Datatables. 2013-12-01 15:15:52 -06:00
snipe bee260b1f0 Added filename to log 2013-12-01 06:45:03 -05:00
snipe 45f46466d7 More fleshed out default db for testing 2013-11-30 22:04:33 -05:00
snipe 8f235881c5 Added phpunit in require-dev, removed ardent, as we're not actually using it at this point 2013-11-30 22:04:00 -05:00
snipe 8bf6a34c58 Unit testing conf files 2013-11-30 22:01:59 -05:00
snipe ca591ccb5d One more 2013-11-30 22:01:42 -05:00
snipe 9d22ce5ac7 Added gitignore lines for new conf files 2013-11-30 22:00:44 -05:00
snipe 067ddb9aac Config tweaks 2013-11-30 17:53:21 -05:00
snipe 66bddba6fe Merge branch 'refs/heads/develop' 2013-11-30 17:43:10 -05:00
snipe fbe3ace0dd Ignore configs 2013-11-30 17:42:58 -05:00
snipe b352817407 Ignoring configs 2013-11-30 17:42:15 -05:00
snipe e2dc24d926 Updated readme 2013-11-30 17:39:02 -05:00
snipe baab758377 Fixed language support 2013-11-30 17:30:02 -05:00
snipe d91d75abe4 Fixing JSON parse errors from #97 2013-11-30 17:08:39 -05:00
snipe 12d3d10dec Merge branch 'develop' of github.com:snipe/snipe-it into develop 2013-11-30 17:02:22 -05:00
snipe 7693e83d7f wtf 2013-11-30 17:02:11 -05:00
snipe 3bc35208af Merge pull request #97 from flashingcursor/develop
Making things a bit more environmentally sensitive...
2013-11-30 13:53:49 -08:00
Gil Rutkowski 78d1c0345e Merge remote-tracking branch 'upstream/develop' into develop 2013-11-30 11:52:27 -06:00
Gil Rutkowski ca39b34b8c Automatically run Sentry Migrations and DB migrations after composer install. 2013-11-30 11:36:05 -06:00
Gil Rutkowski 3d1a533bf2 Environmental cleanup. 2013-11-30 11:17:02 -06:00
Gil Rutkowski 71eaeb2783 Updated README for Environments and revised the order of things. 2013-11-29 23:56:48 -06:00
Gil Rutkowski f9d8cb1b93 Made things a bit more environmentally sensitive. 2013-11-29 23:22:48 -06:00
snipe d535adcc5e Merge branch 'refs/heads/develop' 2013-11-29 17:09:07 -05:00
snipe f62ce4039d @uberbrady is a pedantic shitbag. 2013-11-29 17:07:49 -05:00
snipe 8f9a82e400 Prevent user editing on deleted user 2013-11-29 17:05:55 -05:00
snipe 2be6c6f5da Hurr. 2013-11-29 16:57:49 -05:00
snipe 35155dfc4c Prevent user from being deleted if they still have assets assigned to them 2013-11-29 16:57:24 -05:00
Gil Rutkowski 2e82794ab4 Merge branch 'develop' of github.com:snipe/snipe-it into develop 2013-11-29 15:45:41 -06:00
snipe 7142e37372 Deleted users 2013-11-29 16:44:48 -05:00
snipe dca7a7f2eb Allow deleted users 2013-11-29 16:39:24 -05:00
snipe a7ca9f0c9f Layout tweaks 2013-11-29 16:36:11 -05:00
Gil Rutkowski 7c3a9faf53 Updating from upstream
Merge remote-tracking branch 'upstream/develop' into develop
2013-11-29 15:20:28 -06:00
Gil Rutkowski 2fe58f8d6d Merge branch 'patch-1' of github.com:flashingcursor/snipe-it into develop 2013-11-29 15:16:01 -06:00
snipe bc16276a38 Merge pull request #96 from flashingcursor/patch-1
Removed post-install-cmd php artisan optimize.
2013-11-29 13:10:47 -08:00
snipe 3420f3ed8b Merge branch 'refs/heads/develop' 2013-11-29 16:09:36 -05:00
snipe 11c657ffa4 Fixes #36 2013-11-29 16:08:18 -05:00
snipe 80afa7cbc7 Disallow checkout of undeployable items 2013-11-29 15:27:44 -05:00
snipe 75fc552637 Merge branch 'refs/heads/develop' 2013-11-29 15:22:54 -05:00
snipe 56adc67e67 Require manufacturer ID 2013-11-29 15:21:11 -05:00
snipe 02f1977d30 Fixed error message 2013-11-29 15:20:29 -05:00
snipe b68e39472d Updating to bootstrap 3 2013-11-29 15:19:00 -05:00
snipe 10df2bc950 Bootstrap 3 2013-11-29 14:46:38 -05:00
Gil Rutkowski f6aecd8af9 Removed post-install-cmd php artisan optimize. Causes initial install to fail due to lack of required config (mail.php) 2013-11-29 14:37:44 -05:00
snipe 567f395afa More fixes for #88 2013-11-29 14:37:06 -05:00
snipe 7003eff42c More fixes for #88 2013-11-29 14:36:46 -05:00
snipe d54eb94497 Improved layout 2013-11-29 14:35:24 -05:00
Gil Rutkowski 295cef61df Merge branch 'develop' of github.com:snipe/snipe-it into develop 2013-11-29 12:52:03 -06:00
Gil Rutkowski 8ed5584565 Removed post-install artisan optimize from composer.json — this breaks first time install as a mail config doesn’t exist yet. 2013-11-29 12:42:14 -06:00
snipe e305099b45 Fixed model view 2013-11-29 09:52:51 -05:00
snipe 091de54bab BS3 error validation text 2013-11-29 09:45:30 -05:00
snipe 112d5d5994 Style change - removed underline from header 2013-11-29 09:35:51 -05:00
snipe 428998c6fb Prettier buttons 2013-11-29 09:32:10 -05:00
snipe 56b52392e8 honor user soft-deletes 2013-11-29 09:28:45 -05:00
snipe ddf0997a93 Signin BS3 2013-11-29 09:05:30 -05:00
snipe e1207e0e27 Merge branch 'refs/heads/develop' 2013-11-29 08:41:47 -05:00
snipe 3544be0960 Merge branch 'refs/heads/feature-bootstrap3' into develop 2013-11-29 08:41:24 -05:00
snipe 2e916d0246 MOAR BOOTSTRAP 2013-11-29 08:39:10 -05:00
snipe 809e176908 Updating for bootstrap3 2013-11-29 07:39:41 -05:00
snipe c2bf033fb8 More form/button class changes 2013-11-29 07:11:33 -05:00
snipe d67c01e652 Whitespace 2013-11-29 05:21:00 -05:00
snipe 8d82338e1e Remove underline from stats blocks 2013-11-29 05:20:49 -05:00
snipe 89e6f52142 More bootstrap 3 2013-11-29 05:15:51 -05:00
snipe 030db6e267 Upgrading to bootstrap 3
Ugh.
2013-11-29 04:10:25 -05:00
snipe aae590adc4 Merge branch 'refs/heads/develop' 2013-11-28 23:33:33 -05:00
snipe 06cbd0723e Fixes #93 2013-11-28 23:32:44 -05:00
snipe ddabdaca02 Merge branch 'refs/heads/develop' 2013-11-28 20:59:05 -05:00
snipe 839d01a3af Fixed relationship method because fuck you ORM 2013-11-28 20:58:40 -05:00
snipe 4d421c9a50 Leftover method that's not used since the license/asset split 2013-11-28 20:58:15 -05:00
snipe 9fa826b2e7 Fixed assigned to id 2013-11-28 20:40:02 -05:00
snipe 7718e8d928 Checks that checkedout_to isn't 0 before trying to get fullName() 2013-11-28 20:28:09 -05:00
snipe 23374b7fc6 Another leftover from #88 2013-11-28 20:27:44 -05:00
snipe f0f07b578b Fixing pivot for users 2013-11-28 20:19:23 -05:00
snipe e23f1f10b7 Switched validation to alpha_space on notes 2013-11-28 20:02:11 -05:00
snipe 1b56c31a22 Fixed relationship between users/locations because fuck you ORM 2013-11-28 19:58:16 -05:00
snipe 9f7cbc8a4f Another fix related to #88, also accounts for users with invalid location_ids 2013-11-28 19:57:42 -05:00
snipe f504175578 Smaller char req for first/last name, longer req for password 2013-11-28 19:45:47 -05:00
snipe 103faca6ef Clearer display of current vs trashed 2013-11-28 19:45:25 -05:00
snipe 2fce4884d7 Cosmetic changes 2013-11-28 19:45:05 -05:00
snipe 4142629665 Layout tweaks for mobile - related to #54 2013-11-28 19:22:39 -05:00
snipe 03821838eb Merge branch 'refs/heads/develop' 2013-11-28 18:48:15 -05:00
snipe d2959e82a1 Redirect to /hardware to finish cleaning up re-routing from #88 2013-11-28 18:47:54 -05:00
snipe 6a5ccc89df Updated urls from #88 2013-11-28 18:44:20 -05:00
snipe 5858bfb99b Fixed language file paths caused by #88 2013-11-28 18:44:04 -05:00
snipe 3cce78c087 Weird layout 2013-11-28 18:43:30 -05:00
snipe 0d0d42f86a Merge branch 'refs/heads/develop' 2013-11-28 18:32:07 -05:00
snipe d9a37f3822 Fixes #88 2013-11-28 18:31:36 -05:00
snipe 4fcdf72ab6 Responsive design bug fixes, placeholder code for #64 (commented out) 2013-11-28 16:50:53 -05:00
snipe 8680d98bc3 Fixed status display bug 2013-11-28 16:46:34 -05:00
snipe b3bb2d4f11 Added soon-out-of-warranty example to test notifications 2013-11-28 16:37:24 -05:00
snipe 5c28089f2b RTD has to be 0, or it will conflict with the custom status labels 2013-11-28 16:37:05 -05:00
snipe c3769adf80 Merge branch 'refs/heads/develop' 2013-11-28 15:52:23 -05:00
snipe 9e189aa309 Fixes #80, also prevents the user from checking out an asset that is undeployable, etc 2013-11-28 15:52:00 -05:00
snipe 7a3d92522e Merge pull request #86 from peelman/develop
Cancel and back buttons on edit forms now take you back properly
2013-11-28 11:13:32 -08:00
Nick Peelman 54013cfd42 Cancel and back buttons on edit forms now take you back properly 2013-11-28 10:23:52 -05:00
snipe ccb7a5ddba Merge branch 'refs/heads/develop' 2013-11-28 01:16:05 -05:00
snipe 54d9d72549 Tweaks to example configs to prevent data leakage 2013-11-28 01:15:30 -05:00
snipe 819a606204 Changed modelno validator to alpha_space 2013-11-28 00:58:34 -05:00
snipe 33f81abcd3 Added a few more symbols for alpha_space 2013-11-28 00:58:08 -05:00
snipe fbb0b22522 vi or GTFO
:P
2013-11-28 00:57:40 -05:00
snipe 6b017d12c0 Merge pull request #85 from snipe/gitignore_clean
Replace enumeration of files with wildcard
2013-11-27 21:33:23 -08:00
Brady Wetherington 6691447624 Replace enumeration of files with wildcard 2013-11-27 19:26:53 -05:00
snipe 39cc0c6ad7 Merge pull request #83 from peelman/IgorningProductionConfigs
Igorning production configs
2013-11-27 16:22:10 -08:00
Nick Peelman cb87b16e28 its code, not a block quote...
i are stupid.
2013-11-27 19:22:04 -05:00
Nick Peelman 5be13d5eb5 Ignore production configs and sqlite files. Provide example files for renaming. Update install instructions in README accordingly. 2013-11-27 19:19:07 -05:00
snipe eb015b1e22 Merge branch 'refs/heads/develop' 2013-11-27 14:14:41 -05:00
snipe 012a889444 Corrected license seat count associated with license. Fixes #75 2013-11-27 14:13:29 -05:00
snipe e79d27c984 Merge branch 'refs/heads/develop' 2013-11-27 12:26:15 -05:00
snipe 6552401fd8 Fixes #77 2013-11-27 12:25:48 -05:00
snipe da96126445 Merge pull request #78 from peelman/ExpandManufacturer
Expand Manufacturer
2013-11-27 09:05:10 -08:00
Nick Peelman 301ef3fddb Add Manufacturer and Model info to asset page 2013-11-27 11:37:22 -05:00
Nick Peelman d6ba98252d Change N/A to Select One 2013-11-27 11:37:02 -05:00
snipe 9aa6b519c9 Wider display for address field in index blade 2013-11-27 10:34:51 -05:00
Nick Peelman 9f19792985 Save manufacturer ID 2013-11-27 10:32:50 -05:00
snipe e4d56dba92 Merge pull request #73 from peelman/EmailInputTypes
Email input types
2013-11-27 07:28:15 -08:00
snipe e49cb9eb85 Merge pull request #72 from peelman/AddAddressToLocation
Add address to location form
2013-11-27 07:27:45 -08:00
Nick Peelman b7579a1420 Copy/Paste Error 2013-11-27 10:25:25 -05:00
Nick Peelman 6f59617546 Add to controller's edit method too... 2013-11-27 10:23:11 -05:00
Nick Peelman 996458dde3 missing semicolon 2013-11-27 10:18:43 -05:00
Nick Peelman c2d889de12 Add necessary use statements, clean up the run-on return statement that was forming... 2013-11-27 10:18:15 -05:00
Nick Peelman b5a0da03a8 Add manufacturer to edit form 2013-11-27 10:06:36 -05:00
Nick Peelman 8d3d337820 Change input type to email where relevant (better mobile support) 2013-11-27 08:42:31 -05:00
Nick Peelman 1314a1ffea Add location address values to controller save methods... 2013-11-27 08:30:51 -05:00
Nick Peelman bed78dd935 Remove erroneous rule from address2 2013-11-27 08:28:00 -05:00
Nick Peelman 02e5333101 Add address fields to Location edit form 2013-11-27 08:21:12 -05:00
snipe 0aa3c676c2 Merge branch 'refs/heads/develop' 2013-11-27 03:40:21 -05:00
snipe acd9505597 Two-digit decimal for purchase_cost 2013-11-27 03:40:01 -05:00
snipe 65cd28aad3 Fixes #14 2013-11-27 03:39:28 -05:00
snipe 12684b214a Merge branch 'refs/heads/develop' 2013-11-27 02:57:21 -05:00
snipe 5c72aabdea Updated readme for DB migrations reminder 2013-11-27 02:57:02 -05:00
snipe a2b353fb6d Merge branch 'refs/heads/develop' 2013-11-27 02:41:04 -05:00
snipe aa38d83ba6 Fixes #63 and #70 2013-11-27 02:38:16 -05:00
snipe af69467bea Added notes to log table 2013-11-27 01:29:57 -05:00
snipe 432600ab7b Merge branch 'refs/heads/develop' 2013-11-27 01:21:19 -05:00
snipe b1aa67ddb7 Fixes #69
Removed problem migration file
2013-11-27 01:20:57 -05:00
snipe c16382e9d4 Merge branch 'refs/heads/develop' 2013-11-26 22:07:26 -05:00
snipe 9f9bb96076 Merge pull request #67 from abrahamvegh/patch-1
Patch 1
2013-11-26 18:56:54 -08:00
snipe f1e280ccde Merge pull request #68 from abrahamvegh/patch-2
Fix insecure content warnings
2013-11-26 18:55:14 -08:00
Abraham Vegh cfe28ad903 Update default.blade.php
Remove protocol from Google and jQuery CDN URLs, to fix insecure content warnings in SSL-only environments
2013-11-26 20:33:44 -05:00
Abraham Vegh bda827c590 Update User.php
Fix incorrect Gravatar domain name
2013-11-26 20:19:30 -05:00
Abraham Vegh ebc40857e4 Update AssetsController.php
Fix invalid SQL
2013-11-26 20:15:41 -05:00
snipe 69ede7f82c Merge branch 'refs/heads/develop' 2013-11-26 18:11:00 -05:00
snipe 0e3bcfecd0 Should be final fixes for mysql strict mode 2013-11-26 18:10:46 -05:00
snipe 96368444ac Default user id 2013-11-26 17:53:03 -05:00
snipe ec4172d41a Merge branch 'refs/heads/develop' 2013-11-26 17:49:51 -05:00
snipe 8eeae70313 Formatting cleanup 2013-11-26 17:48:51 -05:00
snipe a33435ee12 No seriously. Fuck you, MySQL strict. 2013-11-26 17:47:21 -05:00
snipe eb7801abf9 Fuck you, MySQL strict mode. Right in the eye. 2013-11-26 17:36:06 -05:00
snipe 42450d9cd6 Merge branch 'refs/heads/master' into develop 2013-11-26 17:24:05 -05:00
snipe 4c0af1eae1 Fixed typo causing failure with mysql strict 2013-11-26 17:22:40 -05:00
snipe 35e5df8bdc Merge branch 'refs/heads/develop' 2013-11-26 16:51:44 -05:00
snipe dfd374b875 Removed optional from db seed 2013-11-26 16:51:23 -05:00
snipe 7722c50312 Merge branch 'refs/heads/develop' 2013-11-26 16:37:09 -05:00
snipe 1527b88fd6 Fixes #61 2013-11-26 16:36:42 -05:00
snipe 7f82a6e9fa Merge branch 'refs/heads/develop' 2013-11-26 14:55:49 -05:00
snipe 196710dac8 Fixed bug in error validation display 2013-11-26 14:55:04 -05:00
snipe 194c0b6c7b Implemented new alpha_space validation 2013-11-26 14:54:46 -05:00
snipe b3b67abaa0 New alpha_space custom validation 2013-11-26 14:08:17 -05:00
snipe 0f0059342c CSRF routing
Not sure if this method will work
2013-11-26 12:49:04 -05:00
snipe d7a8cac1dc Fixed validation 2013-11-26 12:46:23 -05:00
snipe c8288b430e Merge branch 'refs/heads/develop' 2013-11-26 11:57:39 -05:00
snipe dc5ad87686 Fixes #59 2013-11-26 11:57:14 -05:00
snipe 1ff93f65b3 Merge branch 'refs/heads/develop' 2013-11-26 07:29:08 -05:00
snipe 4ccb93665b Sexy typeahead select2 boxes for license and asset checkout 2013-11-26 07:28:47 -05:00
snipe 32a63cdd56 Switched asset->id to license->id 2013-11-26 07:26:07 -05:00
snipe 635cd71ef7 Herp-derp. Braces. 2013-11-26 07:23:47 -05:00
snipe 116af7e809 Merge branch 'refs/heads/develop' 2013-11-26 07:12:14 -05:00
snipe ee3fb2785e Fixed XSS on modal
Weird thing. The values were being escaped on the way out but something in the modal javascript was parsing them out as if they weren't. Using data-html="false" seemed to have no effect on the modal. *shrug* Problem for another time.
2013-11-26 07:05:04 -05:00
snipe 2b1ddd9a45 Escaping HTML in modal title 2013-11-26 06:58:14 -05:00
snipe 1fe925ad5f Removing alpha_dash 2013-11-26 06:56:54 -05:00
snipe c220c0a427 Alpha_dash is too contrictive 2013-11-26 06:56:20 -05:00
snipe 52fa847769 Updated to prevent the XSS in the menu 2013-11-26 06:20:46 -05:00
snipe 9854752036 Don't need it 2013-11-26 04:45:11 -05:00
snipe 37fd854003 Merge branch 'refs/heads/develop' 2013-11-26 03:13:33 -05:00
snipe e6fc1956fc Fixes #55 2013-11-26 03:13:09 -05:00
snipe 5bf38b1d02 Fixes #50 2013-11-26 02:33:16 -05:00
snipe 5b8adda5da Merge branch 'refs/heads/develop' 2013-11-26 02:14:31 -05:00
snipe d0cbb9f3a7 Fixes #52 2013-11-26 02:14:06 -05:00
snipe 1295855302 Fixes #51 2013-11-26 02:12:32 -05:00
snipe 4d1dd1c446 Fixed #50 - MOAR VALIDATION! 2013-11-26 02:09:37 -05:00
snipe e77b47717e More validation 2013-11-26 02:04:29 -05:00
snipe 3f4ce4025f Tighter data validation on name 2013-11-26 01:58:57 -05:00
snipe 680b377bd1 Validation on price 2013-11-26 01:28:45 -05:00
snipe 45c04b1cde Fixed display bug 2013-11-26 01:27:27 -05:00
snipe e13578d97d Fixed error when no category is given 2013-11-26 01:21:55 -05:00
snipe 1d50724c91 Removed parent from category
Since the field was already removed
2013-11-26 01:15:25 -05:00
snipe d469a9601b Merge branch 'refs/heads/develop' 2013-11-25 19:57:40 -05:00
snipe fa246aade1 Removed line thingie 2013-11-25 19:57:28 -05:00
snipe a27be4e053 Merge branch 'refs/heads/develop' 2013-11-25 19:56:41 -05:00
snipe 7e6013b125 Added seat numbers 2013-11-25 19:56:22 -05:00
snipe e310d16fb7 Merge branch 'refs/heads/develop' 2013-11-25 18:33:53 -05:00
snipe 6b224ea8aa Removed dummy text 2013-11-25 18:33:27 -05:00
snipe 7a5b133c58 Fixed bug linking to assets when they should be pointing to licenses 2013-11-25 18:31:59 -05:00
snipe 4e25a9e815 Removed extra columns 2013-11-25 18:31:44 -05:00
snipe 084ec064cb Removed created_at from listing. Not important enough to waste the screen space on 2013-11-25 13:38:14 -05:00
snipe 0eb86ccd1d Merge branch 'refs/heads/develop' 2013-11-25 13:35:32 -05:00
snipe e87e5b9cae Fixes #46 2013-11-25 13:34:52 -05:00
snipe 20cce33273 Merge branch 'refs/heads/develop' 2013-11-25 13:18:49 -05:00
snipe e235a4565c Added manufacturer to model display 2013-11-25 13:16:59 -05:00
snipe a345cbd907 Added view for model in routes 2013-11-25 12:40:09 -05:00
snipe 5959e1f9fc Layout tweaks 2013-11-25 12:39:59 -05:00
snipe 3ea0ad87c8 Fixes #22 2013-11-25 12:39:47 -05:00
snipe cf438d0207 Whitespace 2013-11-25 12:37:26 -05:00
snipe 1624dbffa4 Added model view 2013-11-25 12:37:11 -05:00
snipe e2a1cda50e Changed method name 2013-11-25 12:36:51 -05:00
snipe 6fee1067bc Added depreciate flag for assets and licenses 2013-11-25 11:31:02 -05:00
snipe 3ba2880a35 Layout tweaks 2013-11-25 10:12:41 -05:00
snipe 5a2c6391bf Added category relationship 2013-11-25 10:12:23 -05:00
snipe 447a74928b Ditched parent ID - extraneous feature, not really needed 2013-11-25 10:11:40 -05:00
snipe 62e03e0910 Merge branch 'refs/heads/develop' 2013-11-25 08:26:05 -05:00
snipe 1a970716cc Experimenting with nicer error messages 2013-11-25 08:25:47 -05:00
snipe 57d0f36435 Fixes #4 2013-11-25 08:25:34 -05:00
snipe a8d01550dc Prep for unit testing 2013-11-25 08:09:14 -05:00
snipe f071fe5867 Merge branch 'refs/heads/develop' 2013-11-25 07:57:59 -05:00
snipe acfda8dc82 One more change to tighten the sorting.
Still looks weird, still need to revisit.
2013-11-25 07:57:43 -05:00
snipe 3cc0ed8743 Fixed sorting weirdness
Sort of. Still need to revisit, but this works for now.
2013-11-25 07:55:18 -05:00
snipe ffcfc853b3 Merge branch 'refs/heads/develop' 2013-11-25 07:47:18 -05:00
snipe 051ef0a218 Weird sorting on License table
Need to come back to this
2013-11-25 07:38:06 -05:00
snipe 5fcbc9ba78 ALL THE DATATABLES! 2013-11-25 07:24:51 -05:00
snipe 9dbb147ada Removed pagination, since that's handled via data tables now 2013-11-25 07:07:15 -05:00
snipe 718236b2d4 Fixed #9 2013-11-25 07:06:49 -05:00
snipe efb5269a0c Removed unnecessary image 2013-11-25 07:03:42 -05:00
snipe 74034ae69e Sortable, searchable datatables 2013-11-25 07:03:32 -05:00
snipe 9284164e96 Removed unnecessary graphics 2013-11-25 07:03:15 -05:00
snipe dc26a901d4 More paring down the licenses interface
Still looks assy, but it's a little better now
2013-11-25 06:07:52 -05:00
snipe ad680a337e Fixed column name spelling in DB 2013-11-25 05:47:17 -05:00
snipe dab7ec3457 Sigh. 2013-11-25 05:41:57 -05:00
snipe 46714172ba Spelling is still hard. 2013-11-25 05:41:25 -05:00
snipe 4844cd0b38 Copy edit 2013-11-25 05:40:01 -05:00
snipe 79f93ab475 Merge branch 'refs/heads/develop' 2013-11-25 05:37:02 -05:00
snipe 2b088a3fb2 Fixes #17 2013-11-25 05:36:42 -05:00
snipe 2353eda611 Removed extra columns in license table to make it easier to read, moved buttons for more compact view 2013-11-25 05:12:23 -05:00
snipe 343eb31c56 More info on license page 2013-11-25 05:11:46 -05:00
snipe 56586b7e83 Smaller flat buttons 2013-11-25 05:07:20 -05:00
snipe 1b152396ad Merge branch 'refs/heads/develop' 2013-11-25 04:43:42 -05:00
snipe 69badc7fda Filter action log for hardware 2013-11-25 04:41:03 -05:00
snipe 2727ec13c6 Action log seeder 2013-11-25 04:40:51 -05:00
snipe e457aaee6a Remove software models from model seeder 2013-11-25 04:33:14 -05:00
snipe 03edbc008c Fixes #43 2013-11-25 04:28:51 -05:00
snipe 2203789f4c Fixes #41 2013-11-25 04:00:04 -05:00
snipe 74607c0534 Added set count 2013-11-25 03:59:28 -05:00
snipe 0d9184870c More license tweaks - view blade, asset log 2013-11-25 03:48:54 -05:00
snipe faae6a21d3 More license tweaks 2013-11-25 03:22:38 -05:00
snipe 1b01074b9e Changed license structure to use join table to handle multiple seats 2013-11-25 01:04:39 -05:00
snipe 54894227f0 Removed unneeded 2013-11-25 01:02:27 -05:00
snipe c72e98a193 Drop old tables 2013-11-24 19:07:08 -05:00
snipe 295c2e35eb Edits to status dropdown 2013-11-24 19:06:52 -05:00
snipe 75c48c351c Merge branch 'refs/heads/develop' 2013-11-22 18:16:42 -05:00
snipe 37e1ae7f5a Changed settings table structure
Need to refactor this later
2013-11-22 18:04:16 -05:00
snipe e9bd8397d8 Added site settings into controllers for page_num, added site_name to blade 2013-11-22 18:03:57 -05:00
snipe 9b5274fdcd Nicer title display based on filter 2013-11-22 06:47:51 -05:00
snipe d5bbf38915 View status on show all state 2013-11-22 06:07:03 -05:00
snipe c32d45e901 Fixed ID 2013-11-22 06:01:27 -05:00
snipe 2774b07bce Show asset status on undeployable 2013-11-22 05:54:55 -05:00
snipe a356dbd73d Change table display based on filters 2013-11-22 05:43:40 -05:00
snipe 9249786a25 Fixed status display 2013-11-22 05:37:36 -05:00
snipe 135d21e27d Filtering options on assets page 2013-11-22 05:14:21 -05:00
snipe 95fb2f6efd Include filtering 2013-11-22 04:57:31 -05:00
snipe 6434db2a8e Buttons for asset filtering 2013-11-22 04:31:57 -05:00
snipe d0d94bac44 Merge branch 'refs/heads/develop' 2013-11-22 03:25:25 -05:00
snipe b7251d9992 Fixed potential bug in blade 2013-11-22 03:24:48 -05:00
snipe 1b1efec858 Fixed foreign key in assets 2013-11-22 03:24:34 -05:00
snipe 52020d09f0 Fixed bomb when asset is unassigned 2013-11-22 03:18:11 -05:00
snipe 8dd5704697 Added settings 2013-11-22 03:17:55 -05:00
snipe 7b2cf64d7f DB seed info 2013-11-22 03:17:32 -05:00
snipe 60b577166a Added label for setting readability 2013-11-22 03:17:19 -05:00
snipe da93fb18b8 Added settings controller 2013-11-22 03:16:58 -05:00
snipe a3db6ba99c Comment typo 2013-11-22 03:16:44 -05:00
snipe 08db7fbb38 Hurr. Already had a settings table. 2013-11-22 01:07:41 -05:00
snipe 7b9eebe51c Settings table 2013-11-22 00:53:50 -05:00
snipe 8a348ead33 Merge pull request #38 from rashivkp/develop
Develop
2013-11-21 12:30:56 -08:00
Mohamed Rashid fc8c3c086c fixed #37 2013-11-21 20:34:54 +05:30
snipe 5fae91d4e9 Added status label functionality
remember to run artisan DB migrations to make this work
2013-11-20 22:06:41 -05:00
snipe f7cdc8d5c0 Status addition, seeder stuff 2013-11-20 16:57:45 -05:00
snipe de98f20b9c Added status label table 2013-11-20 08:22:36 -05:00
snipe 904a024636 Status table for non-deployed 2013-11-20 08:10:49 -05:00
snipe 261690986a Prevent orphans in categories 2013-11-20 07:43:18 -05:00
snipe 7ada2cc021 Adding soft-delete to manufacturers 2013-11-20 07:33:54 -05:00
snipe 1b5f0e1dd1 Add check to prevent orphaned models 2013-11-20 07:33:41 -05:00
snipe 595f151ff9 Add soft delete to locations - migration 2013-11-20 07:28:34 -05:00
snipe aa34c4a4dd Add checks to prevent orphaned records 2013-11-20 07:28:24 -05:00
snipe 1d04235520 Associated error messages 2013-11-20 07:27:27 -05:00
snipe ed3fd129bf Get the number of models for the depreciation 2013-11-20 07:27:10 -05:00
snipe 53e6d22f83 Soft delete for locations 2013-11-20 07:26:39 -05:00
snipe f3114dec7a Prevent licenses, models and assets from being deleted if they are assigned to something else 2013-11-20 06:48:25 -05:00
snipe d46556a83d Fixed phone display if no value set 2013-11-20 05:56:22 -05:00
snipe 7f77f1e0b1 Better handling for displaying assets that have been soft-deleted so you don't lose their history 2013-11-20 05:55:18 -05:00
snipe 11a6ee5e8d Merge branch 'refs/heads/develop' 2013-11-20 05:08:41 -05:00
snipe 549c0a9fd6 Linked header boxes
Need to add filters on these asset screens to filter avail vs checked out
2013-11-20 04:54:45 -05:00
snipe 84dbb64caf Removed placeholder copy 2013-11-20 04:32:39 -05:00
snipe c93469c465 Fixed query for asset/license header boxes 2013-11-20 04:31:40 -05:00
snipe 781deb2551 Added live counts to the top callout boxes 2013-11-20 04:12:04 -05:00
snipe 44c5817992 Deleted unnecessary crap 2013-11-20 04:11:42 -05:00
snipe c25122273d Merge branch 'refs/heads/develop' 2013-11-20 01:12:37 -05:00
snipe 4e9aa99e42 Merge branch 'develop' of github.com:snipe/snipe-it into develop
Conflicts:
	app/views/backend/layouts/default.blade.php
2013-11-20 01:08:50 -05:00
snipe fb9f0d837e More detailed modal confirm 2013-11-20 01:05:55 -05:00
snipe 080f38a899 enable soft-deletes on assets 2013-11-20 01:04:35 -05:00
snipe b00f3430cb Added a check where the system wouldn't blow up if asset isn't found 2013-11-20 00:57:21 -05:00
snipe 97a69625ba Please submit your pull requests to develop - thanks! 2013-11-20 00:57:03 -05:00
snipe 34bbf460ee Added modal confirm-delete 2013-11-20 00:56:39 -05:00
snipe 171346b5ea Merge branch 'refs/heads/Chandu-feature-confirm-deletes' into develop 2013-11-19 22:29:11 -05:00
snipe 61cceb5f0b Fixed open tag in CSS 2013-11-19 22:28:35 -05:00
snipe f7032f0eaa Merge branch 'feature-confirm-deletes' of github.com:Chandu/snipe-it into Chandu-feature-confirm-deletes 2013-11-19 22:19:40 -05:00
Chandu e3160957e6 Added confirmation popups for deletes 2013-11-19 21:37:01 -05:00
snipe 57f5f5705f Merge branch 'refs/heads/develop' 2013-11-19 18:28:46 -05:00
snipe 4e8c3517a7 Tightened up display if admin is deleted 2013-11-19 17:50:20 -05:00
snipe 0ee08e47e9 Fixed fatal error if admin who created the asset was deleted. (This should never happen, but...) 2013-11-19 17:48:53 -05:00
snipe 9c08d6fcf7 weird bug 2013-11-19 17:43:55 -05:00
snipe d6a718e997 Fixed bug in views for created_at date 2013-11-19 17:40:06 -05:00
snipe 8daffa82fe Added logging to license checkin/checkout 2013-11-19 17:32:50 -05:00
snipe 7352eaec2e Helper methods for license view display 2013-11-19 17:32:33 -05:00
snipe 67aaeaf7f8 Added route for license view 2013-11-19 17:32:18 -05:00
snipe 76da83cbe1 Fixed links to edit/checkout 2013-11-19 17:31:52 -05:00
snipe 4929f803cc Added view links to index 2013-11-19 17:31:39 -05:00
snipe 24972a330a Added license view blade 2013-11-19 17:31:23 -05:00
snipe 1b160d251e Tidied up the user view, added more info 2013-11-19 17:13:35 -05:00
snipe fa175feb45 Added placeholder "out for digs" option 2013-11-19 17:13:15 -05:00
snipe f0f0019d3b Get the user's location 2013-11-19 17:12:48 -05:00
snipe 8cc367f9e6 Get the admin user details 2013-11-19 17:12:30 -05:00
snipe 55aa41dc32 Tightened up display a little 2013-11-19 16:14:34 -05:00
snipe 08f6d7e17d Added user detail on who it's checked out to 2013-11-19 15:54:59 -05:00
snipe 961baffa4f Improved assetloc function 2013-11-19 15:54:36 -05:00
snipe 9e235b6825 Check asset exists before displaying view 2013-11-19 05:55:58 -05:00
snipe db80b36d0f Added some error checking for invalid users 2013-11-19 05:51:40 -05:00
snipe 02829cb138 Re-ordered columns 2013-11-19 05:51:25 -05:00
snipe 123b6f2a37 Linked assets to user view 2013-11-19 05:31:33 -05:00
snipe 1567a8bde1 Asset view blade 2013-11-19 05:31:07 -05:00
snipe 30a8a96113 Linked asset tags to their new view page 2013-11-19 05:30:54 -05:00
snipe cab75ed7d6 Added asset view to routes 2013-11-19 05:30:32 -05:00
snipe e2c1671d21 Spelling continues to be hard. Apparently. 2013-11-19 05:30:20 -05:00
snipe 5b27a34f05 Fixed fieldname in userlog 2013-11-19 05:30:04 -05:00
snipe ea312fc161 Added asset view in controller 2013-11-19 05:29:42 -05:00
snipe b8908bf246 Add checkin/checkout log to user profile view 2013-11-19 03:58:26 -05:00
snipe f7f79681f3 Added logging action on checkin and checkout 2013-11-19 02:00:17 -05:00
snipe e22d381a20 Added asset logger 2013-11-19 02:00:02 -05:00
snipe 9ebe62f044 Added asset logger 2013-11-19 01:59:45 -05:00
snipe 719c36d482 migration to fix a few fields in the log table 2013-11-19 01:57:34 -05:00
snipe 8c1f6ada67 Number format on diff column 2013-11-18 22:08:00 -05:00
snipe 5bcfca18c7 Added download button, right-aligned fields, added diff math 2013-11-18 22:03:05 -05:00
snipe a28775b9b7 Routes updated for reports 2013-11-18 21:51:02 -05:00
snipe bbaed47e90 Added nav option to get to reports 2013-11-18 21:50:20 -05:00
snipe 8bf1640721 Basic report blade - more to come here 2013-11-18 21:48:44 -05:00
snipe 6265f530ed Added reports controller method 2013-11-18 21:48:28 -05:00
snipe 015c09f560 Swapped people and licenses 2013-11-18 21:48:15 -05:00
snipe 0023b04396 Removed columns from assets view for more compact table
Purchase cost and value are not important day to day. That can be figured out in the reports.
2013-11-18 21:48:03 -05:00
snipe 98cf8767f2 Locked new top boxes down to admin 2013-11-18 21:23:34 -05:00
snipe 3bbd98f1c7 Merge branch 'develop' of github.com:snipe/snipe-it into develop 2013-11-18 21:20:16 -05:00
snipe 532c03a73d Placeholder top summary boxes
There aren't wired up yet
2013-11-18 21:19:30 -05:00
snipe 44ba90f9f0 Fixed icon set to white in main nav 2013-11-18 21:11:50 -05:00
snipe 981ff2b6e5 Asset action log table 2013-11-18 21:10:30 -05:00
Brady Wetherington e819c642db Merge branch 'develop' of github.com:snipe/snipe-it into develop 2013-11-18 15:29:49 -05:00
Brady Wetherington 8268edae81 Merge branch 'develop' of github.com:snipe/snipe-it into develop 2013-11-18 15:16:02 -05:00
snipe edbf195034 Changed footer 2013-11-18 14:52:01 -05:00
snipe 1590c1a300 whitespace 2013-11-18 14:40:32 -05:00
snipe 6dd320171f log files 2013-11-18 14:36:38 -05:00
snipe 5c43caf057 More table fixes 2013-11-18 13:30:48 -05:00
snipe ddfd69e510 More table fixes 2013-11-18 13:23:15 -05:00
snipe 0e11b29cf9 Sigh. 2013-11-18 13:15:38 -05:00
snipe 3401fee672 Another table fix 2013-11-18 13:14:26 -05:00
snipe ffdb4b1aa8 Fixed wonky layout issue 2013-11-18 13:10:38 -05:00
snipe f409ade3a5 So wow. Missed tables disappoint. Such code. 2013-11-18 12:51:20 -05:00
Brady Wetherington 064d7da38e Merge branch 'develop' of github.com:snipe/snipe-it into develop 2013-11-18 12:40:22 -05:00
snipe 4854228851 Moved font awesome files 2013-11-18 12:39:26 -05:00
Brady Wetherington 88599fad7f Merge branch 'develop' of github.com:snipe/snipe-it into develop 2013-11-18 12:37:59 -05:00
snipe d0a5afbf02 Tweaking backend display 2013-11-18 12:36:41 -05:00
snipe c2f5b48635 Removed extraneous images 2013-11-18 12:36:18 -05:00
snipe 5172954aef Added wildcard to nav display 2013-11-18 12:33:32 -05:00
Brady Wetherington 14de269474 Merge branch 'develop' of github.com:snipe/snipe-it into develop 2013-11-18 12:25:23 -05:00
snipe ad914b73b0 Ghetto way to grab location by asset
Need to move this out of the view
2013-11-18 11:51:09 -05:00
snipe c679d446fd Nulled extra values for artisan install 2013-11-18 11:50:17 -05:00
snipe 889b66d578 hurrr 2013-11-18 10:53:20 -05:00
snipe b966bb2889 Added location to asset view 2013-11-18 10:45:14 -05:00
snipe abac6489c4 Removed location_id from assets table
Going to handle this via the people it's checked out to instead
2013-11-18 10:33:35 -05:00
snipe 4ef506cde7 New language entry for no results on user filter 2013-11-18 10:28:03 -05:00
snipe c7c072b07c New fields included in table view 2013-11-18 10:27:48 -05:00
snipe 7b59f42fb0 Fixed pagination bug, styled buttons 2013-11-18 10:27:26 -05:00
snipe 50387874bf Added complete info to the locations seeder 2013-11-18 10:26:47 -05:00
snipe 02ed943ffa New fields in form view 2013-11-18 09:55:07 -05:00
snipe 8f665e82ae Style update for action buttons 2013-11-18 09:54:52 -05:00
snipe 897bc63621 Location drop down to user in views 2013-11-18 09:54:37 -05:00
snipe 673f5accf9 Added location drop down to user 2013-11-18 09:54:19 -05:00
snipe 6214c7b706 migration for new user and location fields 2013-11-18 09:54:00 -05:00
snipe 7c37f91dd5 Linked user in asset view to user profile view 2013-11-18 07:58:20 -05:00
snipe ca90300d2f Added user profile view 2013-11-18 07:53:33 -05:00
snipe d2427bdea2 Cosmetic tweaks 2013-11-18 06:54:12 -05:00
snipe 57107dceee Fixed checkin text
Was mistakenly using checkout text on error/confirmation
2013-11-18 04:54:22 -05:00
snipe 48e180c691 Fixed asset bug caused by unique validation in assets model
Pulled validation back out into the controller for asset tag
2013-11-18 04:50:28 -05:00
snipe b554a9f9db Updated blades with new style buttons 2013-11-18 04:49:54 -05:00
snipe e3fa628bac Reskin files 2013-11-18 04:04:06 -05:00
snipe c29b3c93f7 Removed old bootstrap files 2013-11-18 04:03:20 -05:00
snipe 524d3d233d Added count of assets in asset models table 2013-11-18 01:32:22 -05:00
snipe 2fd8b1760c Removed the note that it's not ready for you yet :) 2013-11-18 01:24:54 -05:00
snipe 7bc7ffb728 Fixed some error reporting/required fields around checkout/checkin 2013-11-18 01:16:08 -05:00
snipe 7d38a7db61 Added checkout/checkin to index display 2013-11-18 00:56:14 -05:00
snipe 785b32c8ff Cleaned up user function for assets 2013-11-18 00:55:57 -05:00
snipe 2d9f56c02a Cleaned up user method 2013-11-18 00:55:36 -05:00
snipe 36bef5bfa5 Language update 2013-11-18 00:55:24 -05:00
snipe ec4239693d Checkin/Checkout for licenses 2013-11-18 00:55:05 -05:00
snipe 17cb895633 Checkin/Checkout for licenses 2013-11-18 00:54:56 -05:00
Brady Wetherington a8372dc998 Merge branch 'develop' of github.com:snipe/snipe-it into develop 2013-11-17 23:44:26 -05:00
snipe d9f434ca12 Short tags FTL 2013-11-17 23:33:21 -05:00
snipe 3a5300e805 license indentation 2013-11-17 23:03:29 -05:00
snipe b22621ab55 typo 2013-11-17 23:03:13 -05:00
snipe 4da2bccbf7 Merge pull request #27 from snipe/depreciation_fix
Depreciation fix
2013-11-17 20:01:46 -08:00
snipe eae1c29262 moar notes!! 2013-11-17 23:00:50 -05:00
Brady Wetherington 127c378b36 Merge branch 'develop' of github.com:snipe/snipe-it into develop 2013-11-17 22:50:22 -05:00
snipe 284645fa7c Added depreciation seed to DatabaseSeeder file
depreciation seed info wasn't being included in the initial seed
2013-11-17 22:49:12 -05:00
snipe 03959b4783 Added note on permissions and documentroot 2013-11-17 22:46:24 -05:00
Brady Wetherington 90c4dfecdf Merge branch 'develop' of github.com:snipe/snipe-it into develop 2013-11-17 22:44:47 -05:00
Brady Wetherington 8f86ec9dae Change depreciation to be by month; formatting fixes. 2013-11-17 22:44:32 -05:00
snipe 3d5dcf7c0e Moved validation to models 2013-11-17 22:34:51 -05:00
snipe 31d323fb71 Cosmetic fix on form 2013-11-17 22:34:43 -05:00
snipe 940281dd4d Fixed bug on validation display 2013-11-17 22:28:59 -05:00
snipe 238e933f00 Moved asset model validation into model 2013-11-17 22:28:49 -05:00
snipe 03e95743e2 Moved manufacturer validation into model 2013-11-17 22:24:01 -05:00
snipe 2f67ee659f Moved validation into models 2013-11-17 22:19:09 -05:00
snipe ea571535b0 extra whitespace 2013-11-17 22:14:32 -05:00
snipe 7bdd5505fd Moved validation to model 2013-11-17 22:14:02 -05:00
snipe 3aea00841a Category using Elegant validation now 2013-11-17 22:05:56 -05:00
snipe 76ac391153 Fixed edit bug where new Category was invoked twice 2013-11-17 22:05:39 -05:00
snipe 7d1a2b2bec Removed validation rules, as they're now in the model 2013-11-17 21:47:59 -05:00
snipe ca842ee447 Added Elegant model and validation rules 2013-11-17 21:47:46 -05:00
snipe 16afe9eb02 Validation abstraction model 2013-11-17 21:46:19 -05:00
snipe 343e13efee Checkout/checkin functionality for assets
Need to refactor a bit and add to licenses as well
2013-11-17 20:36:54 -05:00
snipe a7281ef5b5 programming is hard.
added missing comma
2013-11-17 20:07:42 -05:00
snipe cfb37dcec0 Replaced english text with language reference on buttons 2013-11-17 20:05:12 -05:00
snipe cb5b365631 view logic to determine whether to print out a checkout button 2013-11-17 20:04:43 -05:00
snipe 23c35522c8 Unified save/cancel language option for buttons 2013-11-17 20:04:25 -05:00
snipe 92eab82328 english language messages for checkout 2013-11-17 20:04:13 -05:00
snipe 774b182e9f mark assets as physical, new methods for checkout 2013-11-17 20:03:56 -05:00
snipe 51c1bf4b63 new checkout view 2013-11-17 20:03:34 -05:00
snipe c9a78b319a Added asset checkout routes 2013-11-17 20:03:18 -05:00
snipe f62fdd9aeb Email validation if the license_email field is filled in 2013-11-17 18:41:16 -05:00
snipe 89ede0f8cf Added date picker 2013-11-17 01:53:21 -05:00
snipe 939648e9de Switched to use assets table 2013-11-17 01:53:04 -05:00
snipe 66c9b81118 Seeder changes for new schema 2013-11-17 01:52:44 -05:00
snipe 4143fa6a25 Changes to migrations tables to merge license table 2013-11-17 01:52:18 -05:00
snipe 961a4068b4 Deleted these files - not needed 2013-11-17 01:51:35 -05:00
snipe 38d85afc2b Added where clause for physical = 0 for non-physical assets 2013-11-17 01:51:19 -05:00
snipe 5adb65b4cb Added where clause for physical assets 2013-11-17 01:50:03 -05:00
snipe 17be6b3efe Note about enabling swap in EC2 micros for composer. 2013-11-17 00:14:51 -05:00
snipe a3837eb641 Added note on publishing the debugbar 2013-11-17 00:05:44 -05:00
snipe 90ac04eac7 Edits to DB seeder 2013-11-16 22:42:53 -05:00
snipe eddbb7d973 User/assets tie-in 2013-11-16 22:04:52 -05:00
snipe eee22a9f2b Updated link, added pledgie 2013-11-16 12:47:07 -05:00
snipe 98990d852d Updated Trello url to GH Issues url
Better to keep it all in one place
2013-11-16 12:39:34 -05:00
snipe 33a0d2e191 DB seeds 2013-11-16 11:32:25 -05:00
snipe cf59ec8c67 Fixed pagination bug
Code required
@if ($models->getTotal() > 10)

NOT

@if (count($models) > 10)
2013-11-16 11:32:18 -05:00
snipe 24c3a153e5 Database seeders 2013-11-16 10:57:07 -05:00
snipe ffe786f659 Fixed routes. 2013-11-16 09:33:30 -05:00
snipe 173a7d120f SRSLY WTF OMG.
No idea how that broke.
2013-11-16 09:21:08 -05:00
snipe 4756e950ef oops 2013-11-16 09:17:40 -05:00
snipe 9e96e4b60a very simple lockdown for demo site 2013-11-16 09:03:57 -05:00
snipe c1e1323e68 cleanup 2013-11-16 08:12:25 -05:00
snipe ea7b0c1c0c added alpha reqs to state/country 2013-11-16 07:40:14 -05:00
snipe 27514f85c3 Fixed typo in variable name 2013-11-16 07:19:01 -05:00
snipe 5dc449a99e Added locations CRUD 2013-11-16 07:18:47 -05:00
snipe 7def599141 redirect login to assets page by default, removed dashboard link for now 2013-11-16 06:49:47 -05:00
snipe e4443b8988 Removing unnecessary cruft 2013-11-16 06:38:51 -05:00
snipe bb167aac59 minor cosmetic changes to form 2013-11-16 06:29:14 -05:00
snipe 4742c5e906 require unique asset tags 2013-11-16 06:22:51 -05:00
snipe a62ffa96cf history table, location table 2013-11-16 05:51:38 -05:00
snipe 0894832e60 Cleanup, adding model CRUD 2013-11-16 03:55:18 -05:00
snipe 2e132331e7 Refactoring
Removes extraneous create.blade.php, cleaned up some functions
2013-11-16 03:25:40 -05:00
snipe 4f0a1789db Fixed license blades 2013-11-16 01:14:52 -05:00
snipe 23a6e867e6 Math is hard. :(
Some ghetto straight-line depreciation shit happening here. Assumign 30 days in a month, blah blah blah. Will need a better fix later, but this is fine for MVP
2013-11-16 01:09:21 -05:00
snipe 9720ff9fd5 Added (non-functional) search field 2013-11-15 23:46:20 -05:00
snipe 32eb9d1d30 Added depreciations 2013-11-15 23:46:03 -05:00
snipe 31b90cf2a3 removed ID column. No one cares about the ID 2013-11-15 22:33:02 -05:00
snipe e475846fb6 nav lockout for non-logged in users 2013-11-15 22:27:13 -05:00
snipe 95750cb3a9 Added auth check in header 2013-11-15 22:08:48 -05:00
snipe 86087b2c4f merged fronted with backend 2013-11-15 22:08:36 -05:00
snipe 9c3be972f0 Skip all the public crap. Login or GTFO 2013-11-15 22:01:19 -05:00
snipe 6a70acbe5f sexy calendar date picker icon 2013-11-15 22:01:01 -05:00
snipe f60cba1a4a Added date picker for purchase date 2013-11-15 21:32:54 -05:00
snipe 38154c0df8 typo 2013-11-15 21:31:33 -05:00
snipe 3af94b4e7e Added model drop down 2013-11-15 21:30:48 -05:00
snipe 4cd458cc7a Minor column edits 2013-11-15 19:21:20 -05:00
snipe ccf59fb79d updated url with asset link
this link is dumb and I will probably fix it later
2013-11-15 19:20:49 -05:00
snipe 7e840ec273 Asset view blades 2013-11-15 19:20:26 -05:00
snipe 8b57cd8ab9 Updated routes with assets 2013-11-15 19:20:04 -05:00
snipe 0839510807 Placeholder asset model 2013-11-15 19:19:54 -05:00
snipe b0eb5e5bdd Language files for messages + index table 2013-11-15 19:19:41 -05:00
snipe f12e6b0837 Added DB 2013-11-15 19:18:48 -05:00
snipe 16143c4ff7 New asset controller 2013-11-15 19:18:28 -05:00
snipe 40713d04f9 Add/Edit/View blades 2013-11-15 15:48:30 -05:00
snipe 2a08e00a16 License routes 2013-11-15 15:48:11 -05:00
snipe 5e6a22d973 Added currency 2013-11-15 15:48:00 -05:00
snipe f27fa40f1c Added license name 2013-11-15 15:47:47 -05:00
snipe abd060679e License CRUD 2013-11-15 15:47:34 -05:00
snipe 34cb25296f Added purchase date, etc to language files 2013-11-15 15:47:02 -05:00
snipe 9bbc25fc76 License language files 2013-11-15 15:00:50 -05:00
snipe e9fe59444f Placeholder licenses model 2013-11-15 14:59:50 -05:00
snipe 9364c46c2d Fixed licensed link 2013-11-15 14:59:35 -05:00
snipe 50dfa27689 Licenses route 2013-11-15 14:59:03 -05:00
snipe d7dedf84ad Added assets column to index blade 2013-11-15 14:28:07 -05:00
snipe fd0e5959b5 Nav tweaks
Still working on the info architecture of this - added licenses, and removed users, as users will go under People
2013-11-15 14:27:43 -05:00
snipe ba8cf36691 Added assets column 2013-11-15 14:26:35 -05:00
snipe 5a46c85533 asset count per user.
this shit is very broken right now.
2013-11-15 14:25:57 -05:00
snipe 9159d5f771 Added license/asset tables 2013-11-15 14:25:28 -05:00
snipe c9293897fb manufacturer CRUD 2013-11-15 06:39:58 -05:00
snipe 0e4e26206b fixed broken redirect route 2013-11-15 06:39:07 -05:00
snipe 884131f729 added user_id to manufacturer table 2013-11-15 06:38:50 -05:00
snipe 1f2badfc39 minor UI tweaks
Added icons to action buttons, removed ability to edit a deleted user
2013-11-15 06:20:06 -05:00
snipe 79da13dff7 Fixed layout for category view 2013-11-15 05:07:34 -05:00
snipe b8d4823cae Removed created_at column in results.
No one cares when a category or manufacturer was created.
2013-11-15 05:06:26 -05:00
snipe 0789108e74 Added Trello board URL 2013-11-15 04:59:36 -05:00
snipe c591a71141 only show pagination if results > 10 2013-11-15 04:46:41 -05:00
snipe 2b930ff1e7 minor UI flow changes, disallow a category to be its own parent 2013-11-15 04:34:10 -05:00
snipe af03d60d28 Copy tweak 2013-11-15 04:30:49 -05:00
snipe 51cd0b0208 only paginate if there are > 10 results, added parentname output 2013-11-15 04:30:38 -05:00
snipe e5aa5f1a5b Added parentname method to get the name of the parent category for display 2013-11-15 04:30:05 -05:00
snipe 1bd87cca05 removed excess white space 2013-11-15 04:27:26 -05:00
snipe 0fcd64c386 categories dropdown in create/edit form 2013-11-14 22:32:16 -05:00
snipe 590dbb2bd5 Create form
I will probably make these modals later - the UX is a little clumsy this way
2013-11-14 21:46:13 -05:00
snipe 54cd3d04b1 Added buttons for edit/delete 2013-11-14 21:45:33 -05:00
snipe 6218e1912f Added edit/delete routes for categories 2013-11-14 21:45:01 -05:00
snipe 14972f894b fixed typo 2013-11-14 21:44:51 -05:00
snipe cf1134db37 Edit/Delete categories 2013-11-14 21:44:42 -05:00
snipe 963d3a764a adding user ID to category table 2013-11-14 21:44:19 -05:00
snipe 07e71a547c controller cleanup 2013-11-13 17:49:07 -05:00
snipe 98afb39ef0 manufacturer's nav 2013-11-13 17:48:54 -05:00
snipe 5d3d1eb319 manufacturers language files 2013-11-13 17:48:37 -05:00
snipe a1f9296700 new route for manufacturers 2013-11-13 17:47:26 -05:00
snipe a8d192d263 updated category view 2013-11-13 17:47:16 -05:00
snipe 7785743d85 new manufacturers views 2013-11-13 17:46:55 -05:00
snipe 4ac4b2fde0 Added model number to blades 2013-11-13 17:46:37 -05:00
snipe f387f7e005 spelling is really hard :( 2013-11-13 17:29:28 -05:00
snipe 721a858aa3 Added categories to router 2013-11-13 17:04:05 -05:00
snipe b3c85cd554 rough category model 2013-11-13 17:02:48 -05:00
snipe 760c41896e first manufacturer controller 2013-11-13 17:02:37 -05:00
snipe b18f69330f language files for category view 2013-11-13 17:02:25 -05:00
snipe e08741b104 created category controller 2013-11-13 17:02:11 -05:00
snipe dd8d23bcf7 category view blades 2013-11-13 17:01:52 -05:00
snipe 1ff564ad9f updated nav 2013-11-13 17:01:33 -05:00
snipe f7466a335d nav additions 2013-11-13 16:23:36 -05:00
snipe 261049e848 placeholder model/category models 2013-11-13 16:23:18 -05:00
snipe 9747815960 license/contribution info 2013-11-13 16:22:59 -05:00
snipe 4c9b66150d added travis-ci yml 2013-11-13 15:24:25 -05:00
snipe 41efea5929 Updated read me 2013-11-13 14:45:48 -05:00
snipe 52acfafc42 updated read me 2013-11-13 14:44:11 -05:00
snipe 5721636b71 minor change to readme 2013-11-13 05:57:03 -05:00
snipe 01dadedc78 Rough model view blades 2013-11-13 05:56:24 -05:00
snipe 6bca4fa187 Rough scaffold for models controller 2013-11-13 05:56:05 -05:00
snipe 92f80f979f Adding english language phrases for the mode display table 2013-11-13 05:54:57 -05:00
snipe fc6e41e464 Removing extraneous nav
This view/nav will probably go away, since we don't really have a frontend, everything is behind a login
2013-11-13 05:54:23 -05:00
snipe 574822f278 modified nav 2013-11-13 05:53:30 -05:00
snipe 91b85de6cf New routes for new sections 2013-11-13 05:53:14 -05:00
snipe dd20f519b5 DB seeds 2013-11-13 05:50:20 -05:00
snipe 6f80a2dedd Default DB creds 2013-11-13 05:49:22 -05:00
snipe 53ca5e9c5d Create models/categories/manufacturer table migrations 2013-11-13 05:49:03 -05:00
snipe feda21a6e3 Initial laravel import 2013-11-13 01:59:39 -05:00
snipe 87e90f12ea Initial commit 2013-11-12 14:25:47 -08:00
5699 changed files with 100500 additions and 578895 deletions
Executable
+37
View File
@@ -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
-5
View File
@@ -1,5 +0,0 @@
.git
.dockerignore
app/storage/logs/*
app/storage/views/*
vendor/*
-77
View File
@@ -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
-71
View File
@@ -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
-71
View File
@@ -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
-31
View File
@@ -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
+16 -35
View File
@@ -1,39 +1,20 @@
.couscous
.DS_Store
.env
.idea
/bin/
/bootstrap/compiled.php
/node_modules
/vendor
app/database/*.sqlite
app/storage/meta/services.json
composer.phar
crowdin.yaml
Homestead.json
Homestead.yaml
output
phpDocumentor.phar
public/uploads/*.gif
public/uploads/barcodes/*.png
public/uploads/*.jpg
public/uploads/*.png
public/uploads/*.svg
public/uploads/*.tif
public/uploads/assets/*
public/uploads/avatars/*
public/uploads/logo.gif
public/uploads/logo.png
public/uploads/logo.svg
.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/suppliers/*
public/uploads/users/*
storage/app/private_uploads/users/*
storage/debugbar/
storage/dumps/*
storage/laravel-backups
storage/logs/*
storage/private_uploads/users/*
tests/_data/scenarios
tests/_output/*
tests/_support/_generated/*
public/uploads/avatars/*
/app/storage/views/*
/app/storage/logs/*
/app/storage/debugbar/
/bin/
.idea
crowdin.yaml
-11
View File
@@ -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
View File
@@ -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
View File
@@ -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> &bull; Added DB Prefix to Migrations
* <a href="http://github.com/snipe/snipe-it/commit/309772e67d62989f1f60141a4a10d724a44c6baa">view</a> &bull; Fixed operator for setting bool display
* <a href="http://github.com/snipe/snipe-it/commit/22f81912e416cfe1227a08b5d8b6323e32e1ef36">view</a> &bull; Fixes #299
* <a href="http://github.com/snipe/snipe-it/commit/86b7b6946f1e1bd404127e228c615e4abe0b20fb">view</a> &bull; Fixes #316 - added model name back to view
* <a href="http://github.com/snipe/snipe-it/commit/9e85dcb9fcb4cc932ecddd23caa6b51e83110543">view</a> &bull; Fixes #315 - add EOL as display option in settings (run migrations)
* <a href="http://github.com/snipe/snipe-it/commit/ee35948980c22f9256241c02d7febd90275f6229">view</a> &bull; fix div issues
* <a href="http://github.com/snipe/snipe-it/commit/0022389463e251e73402450cfbc280cb05633bd1">view</a> &bull; Fix dropdown menu position
* <a href="http://github.com/snipe/snipe-it/commit/343798d241172707145ef365445062db9bb6b99a">view</a> &bull; Merge pull request #322 from madd15/fix-js-delete-asset
* <a href="http://github.com/snipe/snipe-it/commit/1078dbf5c5f6a5bec1a2ef864cebfcc7883d31e6">view</a> &bull; Fixes #324
* <a href="http://github.com/snipe/snipe-it/commit/6b2d3efe3e76429c9c2f5de78f04c4f7e2748a3d">view</a> &bull; Fixes #237 - reporting-only group
* <a href="http://github.com/snipe/snipe-it/commit/e04cc806d9209b54a1833172ebb66ab55b5f0c06">view</a> &bull; Fixes #327
### v1.0 - Released Oct 16, 2014 09:46:47
* <a href="http://github.com/snipe/snipe-it/commit/a4b220d6c31c97f6504023f0b52527825a4cd897">view</a> &bull; Fixed #191 - allow admins to assign a user during asset creation
* <a href="http://github.com/snipe/snipe-it/commit/dc1033025a0bc1b2d657e06c89058c3ab95f2c59">view</a> &bull; Fixed #151 - more complete translations
* <a href="http://github.com/snipe/snipe-it/commit/56d619b218794b43d8c6b182c89c75f83af9dcd9">view</a> &bull; Fixed missing language string
* <a href="http://github.com/snipe/snipe-it/commit/69fca5d1eda0e5f26d2085f7eebc08fafd84a3ae">view</a> &bull; Fixed #58
* <a href="http://github.com/snipe/snipe-it/commit/8197e6174e9f12bcfddd94c6bf606ee36e6801bf">view</a> &bull; Fixes #200
* <a href="http://github.com/snipe/snipe-it/commit/cb8369e9de96aaf1cf9108e22f4038fa6486b881">view</a> &bull; 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> &bull; DB migration, layout and clone fixes
* <a href="http://github.com/snipe/snipe-it/commit/9ccc7d756f9361757eafc1dce9684ee9f5ecc1c3">view</a> &bull; 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> &bull; Fixes Travis CI build
* <a href="http://github.com/snipe/snipe-it/commit/363d084bd623f778cd72ca7d385a4fb2f67ef474">view</a> &bull; Fixed DB name in travis CI
* <a href="http://github.com/snipe/snipe-it/commit/49c5607e1c8a82a3111123ad84b537644546ebb3">view</a> &bull; Fixes #222
* <a href="http://github.com/snipe/snipe-it/commit/96e40d72b9ac3f74b94b0e39b6f296f0f0b2a1f4">view</a> &bull; fix typo: artisand -> artisan
* <a href="http://github.com/snipe/snipe-it/commit/e978038cc044f60c2eca71b6319063009a57886f">view</a> &bull; Merge pull request #234 from burlito/typo-fix
* <a href="http://github.com/snipe/snipe-it/commit/a829fcf52f933d087c3776993b42311ec9a8988e">view</a> &bull; fix: Use the old asset tag when cloning
* <a href="http://github.com/snipe/snipe-it/commit/ee7d9bec7082dc2e60a4797dea84a0b7443c8090">view</a> &bull; Fixes #279 - QR checkbox not staying checked
* <a href="http://github.com/snipe/snipe-it/commit/bf1e07555160ede517d41f649d6b1d0911f89dd2">view</a> &bull; 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> &bull; Fixed #140
* <a href="http://github.com/snipe/snipe-it/commit/4a13cded607415d749151cef495332c48c58cf86">view</a> &bull; Fixed path for Travis composer
* <a href="http://github.com/snipe/snipe-it/commit/ddf946ad5eb6dd8480eeaa709f82af75e0c61444">view</a> &bull; 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> &bull; Fixes #183 - added employee number to users
* <a href="http://github.com/snipe/snipe-it/commit/a7b809cb91f49fb2c8eaecc67822fa155a0f20ce">view</a> &bull; Updated title/header for users, additional fixes for #151
* <a href="http://github.com/snipe/snipe-it/commit/5266d9a30a9663fa80ff764b25ff71726e5c4f4c">view</a> &bull; Fixed title tag for user list view
* <a href="http://github.com/snipe/snipe-it/commit/43485e1a51330ef585a65b469d7eb85ae7bde13a">view</a> &bull; Fixed language definition
* <a href="http://github.com/snipe/snipe-it/commit/6b5a552d95ff6f6d5567275b50fcd487fb793820">view</a> &bull; Fixed #186 - Bug with select box not retaining selections on edit screen
* <a href="http://github.com/snipe/snipe-it/commit/90eb883b671919ea360122c2bf44433995a12144">view</a> &bull; 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> &bull; Fixed button label on forgotten password page
* <a href="http://github.com/snipe/snipe-it/commit/2b9494ed8271254f8f84e016f238d518e6109842">view</a> &bull; 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> &bull; Fixed a few CSS quirks
* <a href="http://github.com/snipe/snipe-it/commit/99003e126a8fd0ad9aaea5a550e0af5e306fc1bb">view</a> &bull; Fixed bug with edit (supplier_id), added requestable field for assets
* <a href="http://github.com/snipe/snipe-it/commit/21251b462308f2d783b83be1a331a0faf0813d16">view</a> &bull; Fixed #190, where depreciation on licenses would not be saved
* <a href="http://github.com/snipe/snipe-it/commit/89000440f344f766a31adc69718d7f66df235abf">view</a> &bull; Added admin ability to unsuspend locked accounts #changelog
* <a href="http://github.com/snipe/snipe-it/commit/e203fc516fadf6218f5ce87c070d0cdba9fca188">view</a> &bull; 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> &bull; 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> &bull; 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> &bull; 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> &bull; Fixes PR #168 and #167
* <a href="http://github.com/snipe/snipe-it/commit/945cb3253f1349e30aafa4e7cb57bb507a2ea0cc">view</a> &bull; Fix #117
* <a href="http://github.com/snipe/snipe-it/commit/6f42b3045e2a65cdf98ec1038284cc2ecf01fa5d">view</a> &bull; Resolves #155
* <a href="http://github.com/snipe/snipe-it/commit/380417953b6b67a506f0cc395fd2dfb744cf26cd">view</a> &bull; Fixed missing string
* <a href="http://github.com/snipe/snipe-it/commit/b09aec67f1ab76ff0435a2e1e49b179c3d73bc12">view</a> &bull; Fixes #155
* <a href="http://github.com/snipe/snipe-it/commit/124acc89c4027e346daf54c62cb38b85586de870">view</a> &bull; Resolves #174
* <a href="http://github.com/snipe/snipe-it/commit/afabd2814205fdcd83b7bf9ce9095aa367b08311">view</a> &bull; Additional fixes for #167
* <a href="http://github.com/snipe/snipe-it/commit/a170efae2796314896d548d86b79d89d859c37d2">view</a> &bull; fix for #167
* <a href="http://github.com/snipe/snipe-it/commit/ec9eab81bfb3b35bfe7ad06008b26f19009e6638">view</a> &bull; 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> &bull; 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> &bull; 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> &bull; Fixes #139
* <a href="http://github.com/snipe/snipe-it/commit/ad9b1fc446ab15157502fe7c52ddbda455e3ea8f">view</a> &bull; Fixes #139
* <a href="http://github.com/snipe/snipe-it/commit/dfa5d1c64205b23c4c3d16190d1478da8aa0edbb">view</a> &bull; Fixes #136
* <a href="http://github.com/snipe/snipe-it/commit/9714178ce1fa1e2814389e4b6b82eb596a650084">view</a> &bull; Fixes #141
* <a href="http://github.com/snipe/snipe-it/commit/607484b29407718238571eb5269c9c27830338f7">view</a> &bull; Fixes #141 for mysql with strict mode enabled
* <a href="http://github.com/snipe/snipe-it/commit/cbc945299e7f67f5f10dfdc6a875e5c53ac8440a">view</a> &bull; Fixes #148
* <a href="http://github.com/snipe/snipe-it/commit/dc256583d410cb09253e30b075149c79fb4864e5">view</a> &bull; Fixes #144
* <a href="http://github.com/snipe/snipe-it/commit/610c405aa50118163ad5d26d43e4bf6c2456f624">view</a> &bull; 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> &bull; 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> &bull; Fix for broken datatables in upgrading to v2.2
* <a href="http://github.com/snipe/snipe-it/commit/5690e9ce1f178486179ce6cdfb00ca417acd87dd">view</a> &bull; Fixed code indentation for Apache virtualhost example
* <a href="http://github.com/snipe/snipe-it/commit/67aba76d3f83c5f374c05fe07d52eebd81d13278">view</a> &bull; Fixing this change from #109 that somehow got reverted
* <a href="http://github.com/snipe/snipe-it/commit/06067fc19c0127fdcbb78541e7cdc8e77f5444ac">view</a> &bull; 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> &bull; Fixing JSON parse errors from #97
* <a href="http://github.com/snipe/snipe-it/commit/baab758377e117a86c3273dd1d6e03e66b02dc8b">view</a> &bull; Fixed language support
* <a href="http://github.com/snipe/snipe-it/commit/a678ec41714f5d7f77418b5933bc112aa67eae9c">view</a> &bull; Fixed Gravatar Hash
* <a href="http://github.com/snipe/snipe-it/commit/c08d672e4923b12972eae76d0699e6a301f911cd">view</a> &bull; Fixes mail config documentation
* <a href="http://github.com/snipe/snipe-it/commit/fba853a6a7a2f8166265cac2e99a526fd9b88c7b">view</a> &bull; Fixes composer formatting issues
* <a href="http://github.com/snipe/snipe-it/commit/c11510fdcac2b2de09ae9e241c846426bdf0b187">view</a> &bull; Removes sorting from actions column. Fixes #56
* <a href="http://github.com/snipe/snipe-it/commit/ae05f2701559a841cb8d9bc8767e6d7a56dcd93c">view</a> &bull; Fixed depreciation bug
* <a href="http://github.com/snipe/snipe-it/commit/d591c1ea0495de091eb0f71daa8572929096c897">view</a> &bull; Fixed bug where RTD = 1 instead of 0
* <a href="http://github.com/snipe/snipe-it/commit/e49420f62d26405b2fa0385f0ae7b3009b3beeaf">view</a> &bull; Fixed bug in depreciation display
* <a href="http://github.com/snipe/snipe-it/commit/1dc7fd1bdf8852fed6d886938f632c8ea69d4798">view</a> &bull; Fixed depreciation display on asset view
* <a href="http://github.com/snipe/snipe-it/commit/211a527ae176df667f6f8fbc95901c53a368d8e2">view</a> &bull; Fixed FK
* <a href="http://github.com/snipe/snipe-it/commit/aaebaa8d36158aafc61988a6370239e85f2e75e5">view</a> &bull; Bugfix to put custom title in the page title
* <a href="http://github.com/snipe/snipe-it/commit/194150bbf0493512018390d011e8d88d144e9763">view</a> &bull; Hacky shit to fix pagination weirdness - will come back to this
* <a href="http://github.com/snipe/snipe-it/commit/5fb649b59e76aa9db6e433ad8c9fc75b4b8d5fc2">view</a> &bull; Fixed error message layout
* <a href="http://github.com/snipe/snipe-it/commit/7bc9a53b133895206a3df230baca50d3879abbe5">view</a> &bull; Fixed error when user is invalid
* <a href="http://github.com/snipe/snipe-it/commit/82de635a75aba376209b741ce1ed4497b91e65e0">view</a> &bull; Fixed invalid seed data
* <a href="http://github.com/snipe/snipe-it/commit/b697c77cd85416ca502ec3bb28c990099c7faae3">view</a> &bull; Fixing error when no depreciation
* <a href="http://github.com/snipe/snipe-it/commit/432f44118f46381bdaa44daf61dfa35677aba0ee">view</a> &bull; Fixed FK in licenses model
* <a href="http://github.com/snipe/snipe-it/commit/4468cbd096e9990300240205baf7139eafbc423c">view</a> &bull; Fixes #112
* <a href="http://github.com/snipe/snipe-it/commit/cd62be0de03da071f344c8f66730cbc9e1475fb7">view</a> &bull; Minor div fix
* <a href="http://github.com/snipe/snipe-it/commit/9c369d72e1e7e29f3c205586c916b2f42b250047">view</a> &bull; Fixed typo
* <a href="http://github.com/snipe/snipe-it/commit/60d94eea04d1ebb93704e6a0d20621ff18708272">view</a> &bull; Changes serial to text area, allow new lines. Fixes #118
* <a href="http://github.com/snipe/snipe-it/commit/580590b4c0b4a2f76ef8edfe02de986267fc7395">view</a> &bull; 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> &bull; Fixes #93
* <a href="http://github.com/snipe/snipe-it/commit/e305099b45401c871f16fec23c200080830fcd5d">view</a> &bull; Fixed model view
* <a href="http://github.com/snipe/snipe-it/commit/7003eff42ca0e0ea2b9070187c0afd8ba1a8d8b0">view</a> &bull; More fixes for #88
* <a href="http://github.com/snipe/snipe-it/commit/567f395afaa19335671f366ce889630426f33273">view</a> &bull; More fixes for #88
* <a href="http://github.com/snipe/snipe-it/commit/02f1977d301cd449aa806e02e8a829516d436ef7">view</a> &bull; Fixed error message
* <a href="http://github.com/snipe/snipe-it/commit/11c657ffa4c3bdd01cd04b81d01980b2d795107c">view</a> &bull; 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> &bull; Fixes #69
* <a href="http://github.com/snipe/snipe-it/commit/aa38d83ba6369215451d905e599492214e9f4b8b">view</a> &bull; Fixes #63 and #70
* <a href="http://github.com/snipe/snipe-it/commit/65cd28aad3903e11879e01faba382454dec7e75c">view</a> &bull; Fixes #14
* <a href="http://github.com/snipe/snipe-it/commit/6552401fd869fd285aef5e217438f4f055b53ab6">view</a> &bull; Fixes #77
* <a href="http://github.com/snipe/snipe-it/commit/012a889444fa25b174a5fb2c67e89c8c5fcf09aa">view</a> &bull; Corrected license seat count associated with license. Fixes #75
* <a href="http://github.com/snipe/snipe-it/commit/9e189aa309750c221c27352f35e2ca1f5fab9173">view</a> &bull; 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> &bull; Fixed status display bug
* <a href="http://github.com/snipe/snipe-it/commit/4fcdf72ab6505625f244a6e6ee8683204fb81ccd">view</a> &bull; Responsive design bug fixes, placeholder code for #64 (commented out)
* <a href="http://github.com/snipe/snipe-it/commit/d9a37f38228d55bb6265efc626e3ab7919013362">view</a> &bull; Fixes #88
* <a href="http://github.com/snipe/snipe-it/commit/5858bfb99b2144fbc805ec62cc90e6aaaf019f77">view</a> &bull; Fixed language file paths caused by #88
* <a href="http://github.com/snipe/snipe-it/commit/9f7cbc8a4f01ddf2596e831f658c9a8c321b2f46">view</a> &bull; 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> &bull; Fixed relationship between users/locations because fuck you ORM
* <a href="http://github.com/snipe/snipe-it/commit/f0f07b578b2439a627e5e946df0849d88d8526cf">view</a> &bull; Fixing pivot for users
* <a href="http://github.com/snipe/snipe-it/commit/9fa826b2e77ce22d25a8b3094bc825802d25be85">view</a> &bull; Fixed assigned to id
* <a href="http://github.com/snipe/snipe-it/commit/839d01a3af08d780be4152bc02b33bff1a7d7f20">view</a> &bull; 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> &bull; Fixes #61
* <a href="http://github.com/snipe/snipe-it/commit/4c0af1eae1031c2630f6e29cc73f8a9dfac1081c">view</a> &bull; Fixed typo causing failure with mysql strict
* <a href="http://github.com/snipe/snipe-it/commit/0e3bcfecd05a39bfea6fc7ba11cb24d9d49e6d86">view</a> &bull; 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> &bull; fixed typo
* <a href="http://github.com/snipe/snipe-it/commit/79da13dff767d57f6f4fbb12f195e25f409ee5ec">view</a> &bull; Fixed layout for category view
* <a href="http://github.com/snipe/snipe-it/commit/0e4e26206bdcc164e5df586368ed45edd45b9a74">view</a> &bull; fixed broken redirect route
* <a href="http://github.com/snipe/snipe-it/commit/9364c46c2df79c0de07dc5dbb724a3c44485b739">view</a> &bull; Fixed licensed link
* <a href="http://github.com/snipe/snipe-it/commit/4f0a1789db01f12ebc4bd47e7e0594bf67b64daf">view</a> &bull; Fixed license blades
* <a href="http://github.com/snipe/snipe-it/commit/27514f85c3ba9056c4609774a482a58605f4d8cf">view</a> &bull; Fixed typo in variable name
* <a href="http://github.com/snipe/snipe-it/commit/ffe786f659e3e8c5b91c27cd33cb77b6d24d3545">view</a> &bull; Fixed routes.
* <a href="http://github.com/snipe/snipe-it/commit/cf59ec8c67e142c0612fb7797448057b19af5cfa">view</a> &bull; Fixed pagination bug
* <a href="http://github.com/snipe/snipe-it/commit/76ac39115347dabac8ada21d981494a3edf7a29c">view</a> &bull; Fixed edit bug where new Category was invoked twice
* <a href="http://github.com/snipe/snipe-it/commit/940281dd4dd0a69b900a052c0bb84e24dde89666">view</a> &bull; Fixed bug on validation display
* <a href="http://github.com/snipe/snipe-it/commit/31d323fb71fcbe94f17f0a2b38183709e8c77151">view</a> &bull; Cosmetic fix on form
* <a href="http://github.com/snipe/snipe-it/commit/8f86ec9dae58cef27387b028f70c8116d649b425">view</a> &bull; Change depreciation to be by month; formatting fixes.
* <a href="http://github.com/snipe/snipe-it/commit/4da2bccbf78a0b630267c6ed75f3a1bd8100e20d">view</a> &bull; Merge pull request #27 from snipe/depreciation_fix
* <a href="http://github.com/snipe/snipe-it/commit/7bc7ffb72813cd176658d536bbdd6be0faa9a45c">view</a> &bull; Fixed some error reporting/required fields around checkout/checkin
* <a href="http://github.com/snipe/snipe-it/commit/48e180c6910d30732559b0cc077fce679344f56e">view</a> &bull; Fixed asset bug caused by unique validation in assets model
* <a href="http://github.com/snipe/snipe-it/commit/57107dceeee81e8618198da33af79fe66bde0d9e">view</a> &bull; Fixed checkin text
* <a href="http://github.com/snipe/snipe-it/commit/7b59f42fb03ee5017c11cf32abc8a23c3f5d2141">view</a> &bull; Fixed pagination bug, styled buttons
* <a href="http://github.com/snipe/snipe-it/commit/ffdb4b1aa8dde9942f7c3b110e9a68006779998b">view</a> &bull; Fixed wonky layout issue
* <a href="http://github.com/snipe/snipe-it/commit/3401fee672d796f4aca8dafced6917c7caf87866">view</a> &bull; Another table fix
* <a href="http://github.com/snipe/snipe-it/commit/ddfd69e5100b19bb05d6b76cb9fad3dbadad1921">view</a> &bull; More table fixes
* <a href="http://github.com/snipe/snipe-it/commit/5c43caf0579a26c1604fc81f5cbdf8f0d43c157d">view</a> &bull; More table fixes
* <a href="http://github.com/snipe/snipe-it/commit/44ba90f9f0a968999a743c35dd2bf153c2edbf1d">view</a> &bull; Fixed icon set to white in main nav
* <a href="http://github.com/snipe/snipe-it/commit/719c36d482cc67f1513351672eda057519f7f735">view</a> &bull; migration to fix a few fields in the log table
* <a href="http://github.com/snipe/snipe-it/commit/5b27a34f050646467a178ff780efc80036aadf1b">view</a> &bull; Fixed fieldname in userlog
* <a href="http://github.com/snipe/snipe-it/commit/76da83cbe1c4334380bb996a40cc374ab4ec12e9">view</a> &bull; Fixed links to edit/checkout
* <a href="http://github.com/snipe/snipe-it/commit/d6a718e99766829e700760c2266b62ad37cdb66b">view</a> &bull; Fixed bug in views for created_at date
* <a href="http://github.com/snipe/snipe-it/commit/0ee08e47e9f2b144084703142ae5eb099090476d">view</a> &bull; 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> &bull; Fixed open tag in CSS
* <a href="http://github.com/snipe/snipe-it/commit/c93469c465c0ce8a291d595ac8ccbafbfc68c71a">view</a> &bull; Fixed query for asset/license header boxes
* <a href="http://github.com/snipe/snipe-it/commit/d46556a83d5335913b8b7fe8558f416540290343">view</a> &bull; Fixed phone display if no value set
* <a href="http://github.com/snipe/snipe-it/commit/fc8c3c086ca70a513cd3fff39275fcf035cead5a">view</a> &bull; fixed #37
* <a href="http://github.com/snipe/snipe-it/commit/52020d09f034c9de78b798725c0f3700d0253beb">view</a> &bull; Fixed bomb when asset is unassigned
* <a href="http://github.com/snipe/snipe-it/commit/1b1efec858e8e0cfc5cfafc63bfb537e45191cd1">view</a> &bull; Fixed foreign key in assets
* <a href="http://github.com/snipe/snipe-it/commit/b7251d9992401c04a5da1771af0fcddad2754362">view</a> &bull; Fixed potential bug in blade
* <a href="http://github.com/snipe/snipe-it/commit/9249786a25bc166bf5341f59a11d644cf4f6425c">view</a> &bull; Fixed status display
* <a href="http://github.com/snipe/snipe-it/commit/c32d45e90142b41b567a350af6d399af67994a02">view</a> &bull; Fixed ID
* <a href="http://github.com/snipe/snipe-it/commit/2203789f4c5310599a94799bb3ead9ff9c1ce802">view</a> &bull; Fixes #41
* <a href="http://github.com/snipe/snipe-it/commit/03edbc008c671c868fced94a7761683309d9ab8b">view</a> &bull; Fixes #43
* <a href="http://github.com/snipe/snipe-it/commit/2b088a3fb2ea7711f66e4a887882b17f401ba4bc">view</a> &bull; Fixes #17
* <a href="http://github.com/snipe/snipe-it/commit/ad680a337e50638b4b9865e42e4ea7e453c4151b">view</a> &bull; Fixed column name spelling in DB
* <a href="http://github.com/snipe/snipe-it/commit/718236b2d4bedeaaad80cc601e3e91a3229e81fa">view</a> &bull; Fixed #9
* <a href="http://github.com/snipe/snipe-it/commit/3cc0ed87438b632679ce8b61a7ea0fae48999438">view</a> &bull; Fixed sorting weirdness
* <a href="http://github.com/snipe/snipe-it/commit/57d0f3643518190f0b4a6fe33ac6d83eda647119">view</a> &bull; Fixes #4
* <a href="http://github.com/snipe/snipe-it/commit/3ea0ad87c8733ce1bac0e9c10c2cdaf3254743d5">view</a> &bull; Fixes #22
* <a href="http://github.com/snipe/snipe-it/commit/e87e5b9cae19bfd06b815cf01be309d665409828">view</a> &bull; Fixes #46
* <a href="http://github.com/snipe/snipe-it/commit/7a5b133c5875959c5d7bebf16ea82bac7ceb3989">view</a> &bull; Fixed bug linking to assets when they should be pointing to licenses
* <a href="http://github.com/snipe/snipe-it/commit/e13578d97d6b1ef1990f171beda9b35868fda47c">view</a> &bull; Fixed error when no category is given
* <a href="http://github.com/snipe/snipe-it/commit/45c04b1cdebc0b19243a519d2580af921c82b47b">view</a> &bull; Fixed display bug
* <a href="http://github.com/snipe/snipe-it/commit/4d1dd1c446f76e5530d6fb7f932a77a8da2d0b73">view</a> &bull; Fixed #50 - MOAR VALIDATION!
* <a href="http://github.com/snipe/snipe-it/commit/12958553022d4b7b2184ebf837d4113b23f5cf27">view</a> &bull; Fixes #51
* <a href="http://github.com/snipe/snipe-it/commit/d0cbb9f3a7e4a1fc05ddcabd19e201434c14370b">view</a> &bull; Fixes #52
* <a href="http://github.com/snipe/snipe-it/commit/5bf38b1d02e743af22a51393f1e477100b1f76b7">view</a> &bull; Fixes #50
* <a href="http://github.com/snipe/snipe-it/commit/e6fc1956fc93132d04bf5ac4c0d108c1ae9eee0b">view</a> &bull; Fixes #55
* <a href="http://github.com/snipe/snipe-it/commit/ee3fb2785e719c938b6036f6ea74527c1217aba8">view</a> &bull; Fixed XSS on modal
* <a href="http://github.com/snipe/snipe-it/commit/dc5ad876863a1e17babce06adfb365f38c30ca59">view</a> &bull; Fixes #59
* <a href="http://github.com/snipe/snipe-it/commit/d7a8cac1dc6158983673688c2e48e9a48217b6f2">view</a> &bull; Fixed validation
* <a href="http://github.com/snipe/snipe-it/commit/196710dac807d48f6c73b02c2444a5b8d301b8a6">view</a> &bull; Fixed bug in error validation display
+20
View File
@@ -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.
-----
[![Stories in Ready](https://badge.waffle.io/snipe/snipe-it.png?label=ready&title=Ready)](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
View File
@@ -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
+39 -23
View File
@@ -1,55 +1,71 @@
[![Build Status](https://travis-ci.org/snipe/snipe-it.svg?branch=develop)](https://travis-ci.org/snipe/snipe-it) [![Stories in Ready](https://badge.waffle.io/snipe/snipe-it.png?label=ready+for+dev&amp;title=Ready+for+development)](http://waffle.io/snipe/snipe-it) [![Maintenance](https://img.shields.io/maintenance/yes/2016.svg)]() [![Crowdin](https://d322cqt584bo4o.cloudfront.net/snipe-it/localized.png)](https://crowdin.com/project/snipe-it) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/snipe/snipe-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Docker Pulls](https://img.shields.io/docker/pulls/snipe/snipe-it.svg)](https://hub.docker.com/r/snipe/snipe-it/) [![Twitter Follow](https://img.shields.io/twitter/follow/snipeyhead.svg?style=social)](https://twitter.com/snipeyhead) [![Zenhub](https://raw.githubusercontent.com/ZenHubIO/support/master/zenhub-badge.png)](https://zenhub.io) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/553ce52037fc43ea99149785afcfe641)](https://www.codacy.com/app/snipe/snipe-it?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=snipe/snipe-it&amp;utm_campaign=Badge_Grade)
[![Click here to lend your support to: Snipe IT - Free Open Source Asset Management System and make a donation at pledgie.com](https://pledgie.com/campaigns/22899.png?skin_name=chrome)](https://pledgie.com/campaigns/22899) [![Build Status](https://travis-ci.org/snipe/snipe-it.svg?branch=develop)](https://travis-ci.org/snipe/snipe-it) [![Stories in Ready](https://badge.waffle.io/snipe/snipe-it.png?label=ready&title=Ready)](http://waffle.io/snipe/snipe-it) [![ProjectStatus](http://stillmaintained.com/snipe/snipe-it.png)](http://stillmaintained.com/snipe/snipe-it) [![Crowdin](https://d322cqt584bo4o.cloudfront.net/snipe-it/localized.png)](https://crowdin.com/project/snipe-it)
## Snipe-IT - Open Source Asset Management System
## Snipe-IT - Asset Management For the Rest of Us
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](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.
[![Stories in Ready](https://badge.waffle.io/snipe/snipe-it.png?label=ready&title=Ready)](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.
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/snipe/snipe-it/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
-463
View File
@@ -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),
);
}
}
-85
View File
@@ -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'),
// );
// }
}
-56
View File
@@ -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,993 +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');
$tmp_password = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
$password = bcrypt($tmp_password);
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, $password) {
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, $password);
$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;
$status->deployable = 1;
$status->pending = 0;
$status->archived = 0;
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, $password = null)
{
$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=='') {
if (Setting::getSettings()->email_domain) {
$user_email = str_slug($user_email_array['username']).'@'.Setting::getSettings()->email_domain;
} else {
$user_email = '';
}
}
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;
$user->first_name = $first_name;
$user->last_name = $last_name;
$user->username = $user_username;
$user->email = $user_email;
$user->activated = 1;
$user->password = $password;
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)
);
}
}
-128
View File
@@ -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');
}
}
}
}
-174
View File
@@ -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";
}
}
}
}
-45
View File
@@ -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');
}
}
-92
View File
@@ -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 = '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];
// 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(
);
}
}
-42
View File
@@ -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();
}
}
-8
View File
@@ -1,8 +0,0 @@
<?php
namespace App\Events;
abstract class Event
{
//
}
-67
View File
@@ -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);
}
}
-432
View File
@@ -1,432 +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;
}
/**
* Introspects into the model validation to see if the field passed is required.
* This is used by the blades to add a required class onto the HTML element.
* This isn't critical, but is helpful to keep form fields in sync with the actual
* model level validation.
*
* This does not currently handle form request validation requiredness :(
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0]
* @return boolean
*/
public static function checkIfRequired($class, $field) {
$rules = $class::rules();
foreach ($rules as $rule_name => $rule) {
if ($rule_name == $field) {
if (strpos($rule, 'required') === false) {
return false;
} else {
return true;
}
}
}
}
}
@@ -1,694 +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;
use Gate;
/** 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 = Company::scopeCompanyables(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>';
if (Gate::allows('accessories.checkout')) {
$actions .= '<a href="' . route('checkout/accessory',
$accessory->id) . '" style="margin-right:5px;" class="btn btn-info btn-sm" ' . (($accessory->numRemaining() > 0) ? '' : ' disabled') . '>' . trans('general.checkout') . '</a>';
}
if (Gate::allows('accessories.edit')) {
$actions .= '<a href="' . route('update/accessory',
$accessory->id) . '" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a>';
}
if (Gate::allows('accessories.delete')) {
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/accessory',
$accessory->id) . '" data-content="' . trans('admin/accessories/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($accessory->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
}
$actions .= '</nobr>';
$company = $accessory->company;
$rows[] = array(
'name' => '<a href="'.url('admin/accessories/'.$accessory->id).'/view">'. $accessory->name.'</a>',
'category' => ($accessory->category) ? (string)link_to('admin/settings/categories/'.$accessory->category->id.'/view', $accessory->category->name) : '',
'qty' => e($accessory->qty),
'order_number' => e($accessory->order_number),
'min_amt' => e($accessory->min_amt),
'location' => ($accessory->location) ? e($accessory->location->name): '',
'purchase_date' => e($accessory->purchase_date),
'purchase_cost' => number_format($accessory->purchase_cost, 2),
'numRemaining' => $accessory->numRemaining(),
'actions' => $actions,
'companyName' => is_null($company) ? '' : e($company->name)
);
}
$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 = '';
if (Gate::allows('accessories.checkin')) {
$actions .= '<a href="' . route('checkin/accessory',
$user->pivot->id) . '" class="btn btn-info btn-sm">Checkin</a>';
}
if (Gate::allows('users.view')) {
$name = (string) link_to('/admin/users/'.$user->id.'/view', e($user->fullName()));
} else {
$name = e($user->fullName());
}
$rows[] = array(
'name' => $name,
'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,535 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
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(Request $request, $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($request->input('name'));
// If the item count is > 0, we disable the category type in the edit. Disabled items
// don't POST, so if the category_type is blank we just set it to the default.
$category->category_type = e($request->input('category_type', $category->category_type));
$category->eula_text = e($request->input('eula_text'));
$category->use_default_eula = e($request->input('use_default_eula', '0'));
$category->require_acceptance = e($request->input('require_acceptance', '0'));
$category->checkin_email = e($request->input('checkin_email', '0'));
if ($category->save()) {
// Redirect to the new category page
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,533 +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;
use Gate;
/**
* 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 = Company::scopeCompanyables(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>';
if (Gate::allows('components.checkout')) {
$actions .= '<a href="' . route('checkout/component',
$component->id) . '" style="margin-right:5px;" class="btn btn-info btn-sm ' . (($component->numRemaining() > 0) ? '' : ' disabled') . '" ' . (($component->numRemaining() > 0) ? '' : ' disabled') . '>' . trans('general.checkout') . '</a>';
}
if (Gate::allows('components.edit')) {
$actions .= '<a href="' . route('update/component',
$component->id) . '" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a>';
}
if (Gate::allows('components.delete')) {
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/component',
$component->id) . '" data-content="' . trans('admin/components/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($component->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
}
$actions .='</nobr>';
$company = $component->company;
$rows[] = array(
'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->showAssetName())),
'qty' => e($component_assignment->pivot->assigned_qty),
'created_at' => ($component_assignment->created_at->format('Y-m-d H:i:s')=='-0001-11-30 00:00:00') ? '' : $component_assignment->created_at->format('Y-m-d H:i:s'),
);
}
$componentCount = $component->assets->count();
$data = array('total' => $componentCount, 'rows' => $rows);
return $data;
}
}
@@ -1,534 +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;
use Gate;
/**
* 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 = Company::scopeCompanyables(Consumable::select('consumables.*')->whereNull('consumables.deleted_at')
->with('company', 'location', 'category', 'users'));
if (Input::has('search')) {
$consumables = $consumables->TextSearch(e(Input::get('search')));
}
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>';
if (Gate::allows('consumables.checkout')) {
$actions .= '<a href="' . route('checkout/consumable',
$consumable->id) . '" style="margin-right:5px;" class="btn btn-info btn-sm" ' . (($consumable->numRemaining() > 0) ? '' : ' disabled') . '>' . trans('general.checkout') . '</a>';
}
if (Gate::allows('consumables.edit')) {
$actions .= '<a href="' . route('update/consumable',
$consumable->id) . '" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a>';
}
if (Gate::allows('consumables.delete')) {
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/consumable',
$consumable->id) . '" data-content="' . trans('admin/consumables/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($consumable->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
}
$actions .='</nobr>';
$company = $consumable->company;
$rows[] = array(
'id' => $consumable->id,
'name' => (string)link_to('admin/consumables/'.$consumable->id.'/view', e($consumable->name)),
'location' => ($consumable->location) ? e($consumable->location->name) : '',
'min_amt' => e($consumable->min_amt),
'qty' => e($consumable->qty),
'manufacturer' => ($consumable->manufacturer) ? 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;
}
}
-39
View File
@@ -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,298 +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);
}
}
/**
* Detach a custom field from a fieldset.
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0]
* @return Redirect
*/
public function deleteFieldFromFieldset($field_id, $fieldset_id)
{
$field = CustomField::find($field_id);
if ($field->fieldset()->detach($fieldset_id)) {
return redirect()->route("admin.custom_fields.index")->with("success", trans('admin/custom_fields/message.field.delete.success'));
}
return redirect()->back()->withErrors(['message' => "Field is in-use"]);
}
/**
* Delete a custom field.
*
* @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;
}
}
-238
View File
@@ -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());
}
}
-854
View File
@@ -1,854 +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 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 App\Models\CustomField;
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()
{
$customfields = CustomField::get();
return View::make('reports/custom')->with('customfields',$customfields);
}
/**
* Exports the custom report to CSV
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @see ReportsController::getCustomReport() method that generates form view
* @since [v1.0]
* @return \Illuminate\Http\Response
*/
public function postCustom()
{
$assets = Asset::orderBy('created_at', 'DESC')->get();
$customfields = CustomField::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('username')) == '1') {
$header[] = 'Username';
}
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';
}
foreach ($customfields as $customfield) {
if (e(Input::get($customfield->db_column_name())) == '1') {
$header[] = $customfield->name;
}
}
$header = array_map('trim', $header);
$rows[] = implode($header, ',');
foreach ($assets as $asset) {
$row = [ ];
if (e(Input::get('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('username')) == '1') {
if ($asset->assigned_to > 0) {
$user = User::find($asset->assigned_to);
$row[] = '"' .e($user->username). '"';
} else {
$row[] = ''; // Empty string if unassigned
}
}
if (e(Input::get('status')) == '1') {
if (( $asset->status_id == '0' ) && ( $asset->assigned_to == '0' )) {
$row[] = trans('general.ready_to_deploy');
} 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) . '"';
}
foreach ($customfields as $customfield) {
$column_name = $customfield->db_column_name();
if (e(Input::get($customfield->db_column_name())) == '1') {
$row[] = $asset->$column_name;
}
}
$rows[] = implode($row, ',');
}
// 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();
}
}
-591
View File
@@ -1,591 +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->zerofill_count = e(Input::get('zerofill_count'));
$setting->alert_interval = e(Input::get('alert_interval'));
$setting->alert_threshold = e(Input::get('alert_threshold'));
$setting->email_domain = e(Input::get('email_domain'));
$setting->email_format = e(Input::get('email_format'));
$setting->username_format = e(Input::get('username_format'));
$setting->labels_per_page = e(Input::get('labels_per_page'));
$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'));
$setting->ldap_tls = e(Input::get('ldap_tls', '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,326 +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::with('assets')->get();
$labels=[];
$points=[];
$colors=[];
foreach ($statuslabels as $statuslabel) {
if ($statuslabel->assets->count() > 0) {
$labels[]=$statuslabel->name;
$points[]=$statuslabel->assets()->whereNull('assigned_to')->count();
if ($statuslabel->color!='') {
$colors[]=$statuslabel->color;
}
}
}
$labels[]='Deployed';
$points[]=Asset::whereNotNull('assigned_to')->count();
$colors_array = array_merge($colors, Helper::chartColors());
$result= [
"labels" => $labels,
"datasets" => [ [
"data" => $points,
"backgroundColor" => $colors_array,
"hoverBackgroundColor" => $colors_array
]]
];
return $result;
}
/**
* Statuslabel create.
*
* @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'];
$statuslabel->color = e(Input::get('color'));
// 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'];
$statuslabel->color = e(Input::get('color'));
// 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','color'))
->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>';
if ($statuslabel->color!='') {
$color = '<div class="pull-left" style="margin-right: 5px; height: 20px; width: 20px; background-color: '.e($statuslabel->color).'"></div>'.e($statuslabel->color);
} else {
$color = '';
}
$rows[] = array(
'id' => e($statuslabel->id),
'type' => e($label_type),
'name' => e($statuslabel->name),
'color' => $color,
'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 ');
}
}
}
-59
View File
@@ -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,
];
}
-47
View File
@@ -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);
}
}
-36
View File
@@ -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);
}
}
}
-42
View File
@@ -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);
}
}
-38
View File
@@ -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')
]);
}
}
-17
View File
@@ -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 = [
//
];
}
-21
View File
@@ -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;
}
}
-21
View File
@@ -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);
}
}
-16
View File
@@ -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 = [
];
}
-21
View File
@@ -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;
}
}
-35
View File
@@ -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',
];
}
}
-35
View File
@@ -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);
}
}
-61
View File
@@ -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);
}
}
-21
View File
@@ -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();
// }
}
-34
View File
@@ -1,34 +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',
'email' => 'email',
'password' => 'required|min:6',
'password_confirm' => 'sometimes|required_with:password',
];
}
}
-42
View File
@@ -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);
}
}
-32
View File
@@ -1,32 +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',
'email' => 'email',
'password_confirm' => 'sometimes|required_with:password',
];
}
}
-23
View File
@@ -1,23 +0,0 @@
<?php
namespace App\Http\Traits;
trait UniqueUndeletedTrait
{
/**
* Prepare a unique_ids rule, adding a model identifier if required.
*
* @param array $parameters
* @param string $field
* @return string
*/
protected function prepareUniqueUndeletedRule($parameters, $field)
{
// Only perform a replacement if the model has been persisted.
if ($this->exists) {
return 'unique_undeleted:'.$this->table.','. $this->getKey();
}
return 'unique_undeleted:'.$this->table.',0';
}
}
-977
View File
@@ -1,977 +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']],
function () {
Route::get('create/{model?}', [
'as' => 'create/hardware',
'middleware' => 'authorize:assets.create',
'uses' => 'AssetsController@getCreate'
]);
Route::post('create', [
'as' => 'savenew/hardware',
'middleware' => 'authorize:assets.create',
'uses' => 'AssetsController@postCreate'
]);
Route::get('{assetId}/edit', [
'as' => 'update/hardware',
'middleware' => 'authorize:assets.edit',
'uses' => 'AssetsController@getEdit'
]);
Route::get('/bytag', [
'as' => 'findbytag/hardware',
'middleware' => 'authorize:assets.view',
'uses' => 'AssetsController@getAssetByTag'
]);
Route::get('{assetId}/clone', [
'as' => 'clone/hardware',
'middleware' => 'authorize:assets.create',
'uses' => 'AssetsController@getClone'
]);
Route::post('{assetId}/clone', 'AssetsController@postCreate');
Route::get('{assetId}/delete', [
'as' => 'delete/hardware',
'middleware' => 'authorize:assets.delete',
'uses' => 'AssetsController@getDelete'
]);
Route::get('{assetId}/checkout', [
'as' => 'checkout/hardware',
'middleware' => 'authorize:assets.checkout',
'uses' => 'AssetsController@getCheckout'
]);
Route::post('{assetId}/checkout', [
'as' => 'checkout/hardware',
'middleware' => 'authorize:assets.checkout',
'uses' => 'AssetsController@postCheckout'
]);
Route::get('{assetId}/checkin/{backto?}', [
'as' => 'checkin/hardware',
'middleware' => 'authorize:assets.checkin',
'uses' => 'AssetsController@getCheckin'
]);
Route::post('{assetId}/checkin/{backto?}', [
'as' => 'checkin/hardware',
'middleware' => 'authorize:assets.checkin',
'uses' => 'AssetsController@postCheckin'
]);
Route::get('{assetId}/view', [
'as' => 'view/hardware',
'middleware' => ['authorize:assets.view'],
'uses' => 'AssetsController@getView'
]);
Route::get('{assetId}/qr-view', [ 'as' => 'qr-view/hardware', 'uses' => 'AssetsController@getView' ]);
Route::get('{assetId}/qr_code', [ 'as' => 'qr_code/hardware', 'uses' => 'AssetsController@getQrCode' ]);
Route::get('{assetId}/barcode', [ 'as' => 'barcode/hardware', 'uses' => 'AssetsController@getBarCode' ]);
Route::get('{assetId}/restore', [
'as' => 'restore/hardware',
'middleware' => 'authorize:assets.delete',
'uses' => 'AssetsController@getRestore'
]);
Route::post('{assetId}/upload', [
'as' => 'upload/asset',
'middleware' => 'authorize:assets.edit',
'uses' => 'AssetsController@postUpload'
]);
Route::get('{assetId}/deletefile/{fileId}', [
'as' => 'delete/assetfile',
'middleware' => 'authorize:assets.edit',
'uses' => 'AssetsController@getDeleteFile'
]);
Route::get('{assetId}/showfile/{fileId}', [
'as' => 'show/assetfile',
'middleware' => 'authorize:assets.view',
'uses' => 'AssetsController@displayFile'
]);
Route::get('import/delete-import/{filename}', [
'as' => 'assets/import/delete-file',
'middleware' => 'authorize:assets.create',
'uses' => 'AssetsController@getDeleteImportFile'
]);
Route::get( 'import/process/{filename}', [ 'as' => 'assets/import/process-file',
'middleware' => 'authorize:assets.create',
'uses' => 'AssetsController@getProcessImportFile'
]);
Route::get('import',[
'as' => 'assets/import',
'middleware' => 'authorize:assets.create',
'uses' => 'AssetsController@getImportUpload'
]);
Route::post('{assetId}/edit',[
'as' => 'assets/import',
'middleware' => 'authorize:assets.edit',
'uses' => 'AssetsController@postEdit'
]);
Route::post(
'bulkedit',
[
'as' => 'hardware/bulkedit',
'middleware' => 'authorize:assets.edit',
'uses' => 'AssetsController@postBulkEdit'
]
);
Route::post(
'bulkdelete',
[
'as' => 'hardware/bulkdelete',
'middleware' => 'authorize:assets.delete',
'uses' => 'AssetsController@postBulkDelete'
]
);
Route::post(
'bulksave',
[
'as' => 'hardware/bulksave',
'middleware' => 'authorize:assets.edit',
'uses' => 'AssetsController@postBulkSave'
]
);
# Bulk checkout / checkin
Route::get( 'bulkcheckout', [
'as' => 'hardware/bulkcheckout',
'middleware' => 'authorize:assets.checkout',
'uses' => 'AssetsController@getBulkCheckout'
]);
Route::post( 'bulkcheckout', [
'as' => 'hardware/bulkcheckout',
'middleware' => 'authorize:assets.checkout',
'uses' => 'AssetsController@postBulkCheckout'
]);
# Asset Model Management
Route::group([ 'prefix' => 'models', 'middleware' => 'auth' ], function () {
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',
'middleware' => 'authorize:assets.view',
'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', 'middleware' => 'authorize:licenses.create','uses' => 'LicensesController@getCreate' ]);
Route::post('create', [ 'as' => 'create/licenses', 'middleware' => 'authorize:licenses.create','uses' => 'LicensesController@postCreate' ]);
Route::get('{licenseId}/edit', [ 'as' => 'update/license', 'middleware' => 'authorize:licenses.edit', 'uses' => 'LicensesController@getEdit' ]);
Route::post('{licenseId}/edit', [ 'as' => 'update/license', 'middleware' => 'authorize:licenses.edit', 'uses' => 'LicensesController@postEdit' ]);
Route::get('{licenseId}/clone', [ 'as' => 'clone/license', 'middleware' => 'authorize:licenses.create', 'uses' => 'LicensesController@getClone' ]);
Route::post('{licenseId}/clone', [ 'as' => 'clone/license', 'middleware' => 'authorize:licenses.create', 'uses' => 'LicensesController@postCreate' ]);
Route::get('{licenseId}/delete', [ 'as' => 'delete/license', 'middleware' => 'authorize:licenses.delete', 'uses' => 'LicensesController@getDelete' ]);
Route::get('{licenseId}/freecheckout', [
'as' => 'freecheckout/license',
'middleware' => 'authorize:licenses.checkout',
'uses' => 'LicensesController@getFreeLicense'
]);
Route::get(
'{licenseId}/checkout',
[ 'as' => 'checkout/license', 'middleware' => 'authorize:licenses.checkout','uses' => 'LicensesController@getCheckout' ]
);
Route::post(
'{licenseId}/checkout',
[ 'as' => 'checkout/license', 'middleware' => 'authorize:licenses.checkout','uses' => 'LicensesController@postCheckout' ]
);
Route::get('{licenseId}/checkin/{backto?}', [
'as' => 'checkin/license',
'middleware' => 'authorize:licenses.checkin',
'uses' => 'LicensesController@getCheckin'
]);
Route::post('{licenseId}/checkin/{backto?}', [
'as' => 'checkin/license',
'middleware' => 'authorize:licenses.checkin',
'uses' => 'LicensesController@postCheckin'
]);
Route::get('{licenseId}/view', [
'as' => 'view/license',
'middleware' => 'authorize:licenses.view',
'uses' => 'LicensesController@getView'
]);
Route::post(
'{licenseId}/upload',
[ 'as' => 'upload/license', 'middleware' => 'authorize:licenses.edit','uses' => 'LicensesController@postUpload' ]
);
Route::get(
'{licenseId}/deletefile/{fileId}',
[ 'as' => 'delete/licensefile', 'middleware' => 'authorize:licenses.edit', 'uses' => 'LicensesController@getDeleteFile' ]
);
Route::get(
'{licenseId}/showfile/{fileId}',
[ 'as' => 'show/licensefile', 'middleware' => 'authorize:licenses.view','uses' => 'LicensesController@displayFile' ]
);
Route::get('/', [ 'as' => 'licenses', 'middleware' => 'authorize:licenses.view','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', 'middleware' => 'authorize:accessories.create','uses' => 'AccessoriesController@getCreate' ]);
Route::post('create', 'AccessoriesController@postCreate');
Route::get(
'{accessoryID}/edit',
[ 'as' => 'update/accessory', 'middleware' => 'authorize:accessories.edit','uses' => 'AccessoriesController@getEdit' ]
);
Route::post('{accessoryID}/edit', 'AccessoriesController@postEdit');
Route::get(
'{accessoryID}/delete',
[ 'as' => 'delete/accessory', 'middleware' => 'authorize:accessories.delete','uses' => 'AccessoriesController@getDelete' ]
);
Route::get('{accessoryID}/view', [ 'as' => 'view/accessory', 'middleware' => 'authorize:accessories.view','uses' => 'AccessoriesController@getView' ]);
Route::get(
'{accessoryID}/checkout',
[ 'as' => 'checkout/accessory', 'middleware' => 'authorize:accessories.checkout','uses' => 'AccessoriesController@getCheckout' ]
);
Route::post(
'{accessoryID}/checkout',
[ 'as' => 'checkout/accessory', 'middleware' => 'authorize:accessories.checkout','uses' => 'AccessoriesController@postCheckout' ]
);
Route::get(
'{accessoryID}/checkin/{backto?}',
[ 'as' => 'checkin/accessory', 'middleware' => 'authorize:accessories.checkin','uses' => 'AccessoriesController@getCheckin' ]
);
Route::post(
'{accessoryID}/checkin/{backto?}',
[ 'as' => 'checkin/accessory', 'middleware' => 'authorize:accessories.checkin','uses' => 'AccessoriesController@postCheckin' ]
);
Route::get('/', [ 'as' => 'accessories', 'middleware'=>'authorize:accessories.view', 'uses' => 'AccessoriesController@getIndex' ]);
});
# Consumables
Route::group([ 'prefix' => 'consumables', 'middleware'=>'authorize:consumables.view' ], function () {
Route::get('create', [ 'as' => 'create/consumable','middleware'=>'authorize:consumables.create', 'uses' => 'ConsumablesController@getCreate' ]);
Route::post('create', [ 'as' => 'create/consumable','middleware'=>'authorize:consumables.create', 'uses' => 'ConsumablesController@postCreate' ]);
Route::get(
'{consumableID}/edit',
[ 'as' => 'update/consumable', 'middleware'=>'authorize:consumables.edit', 'uses' => 'ConsumablesController@getEdit' ]
);
Route::post(
'{consumableID}/edit',
[ 'as' => 'update/consumable', 'middleware'=>'authorize:consumables.edit', 'uses' => 'ConsumablesController@postEdit' ]
);
Route::get(
'{consumableID}/delete',
[ 'as' => 'delete/consumable', 'middleware'=>'authorize:consumables.delete','uses' => 'ConsumablesController@getDelete' ]
);
Route::get(
'{consumableID}/view',
[ 'as' => 'view/consumable', 'middleware'=>'authorize:consumables.view','uses' => 'ConsumablesController@getView' ]
);
Route::get(
'{consumableID}/checkout',
[ 'as' => 'checkout/consumable', 'middleware'=>'authorize:consumables.checkout','uses' => 'ConsumablesController@getCheckout' ]
);
Route::post(
'{consumableID}/checkout',
[ 'as' => 'checkout/consumable', 'middleware'=>'authorize:consumables.checkout','uses' => 'ConsumablesController@postCheckout' ]
);
Route::get('/', [ 'as' => 'consumables', 'middleware'=>'authorize:consumables.view','uses' => 'ConsumablesController@getIndex' ]);
});
# Components
Route::group([ 'prefix' => 'components', 'middleware'=>'authorize:components.view' ], function () {
Route::get('create', [ 'as' => 'create/component', 'middleware'=>'authorize:components.create','uses' => 'ComponentsController@getCreate' ]);
Route::post('create', [ 'as' => 'create/component', 'middleware'=>'authorize:components.create','uses' => 'ComponentsController@postCreate' ]);
Route::get(
'{componentID}/edit',
[ 'as' => 'update/component', 'middleware'=>'authorize:components.edit','uses' => 'ComponentsController@getEdit' ]
);
Route::post(
'{componentID}/edit',
[ 'as' => 'update/component', 'middleware'=>'authorize:components.edit','uses' => 'ComponentsController@postEdit' ]
);
Route::get(
'{componentID}/delete',
[ 'as' => 'delete/component', 'middleware'=>'authorize:components.delete','uses' => 'ComponentsController@getDelete' ]
);
Route::get(
'{componentID}/view',
[ 'as' => 'view/component', 'middleware'=>'authorize:components.view','uses' => 'ComponentsController@getView' ]
);
Route::get(
'{componentID}/checkout',
[ 'as' => 'checkout/component', 'middleware'=>'authorize:components.checkout','uses' => 'ComponentsController@getCheckout' ]
);
Route::post(
'{componentID}/checkout',
[ 'as' => 'checkout/component', 'middleware'=>'authorize:components.checkout','uses' => 'ComponentsController@postCheckout' ]
);
Route::post('bulk', [ 'as' => 'component/bulk-form', 'middleware'=>'authorize:components.checkout','uses' => 'ComponentsController@postBulk' ]);
Route::post('bulksave', [ 'as' => 'component/bulk-save', 'middleware'=>'authorize:components.edit','uses' => 'ComponentsController@postBulkSave' ]);
Route::get('/', [ 'as' => 'components', 'middleware'=>'authorize:components.view','uses' => 'ComponentsController@getIndex' ]);
});
# Admin Settings Routes (for categories, maufactureres, etc)
Route::group([ 'prefix' => 'settings', '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::get('custom_fields/{field_id}/{fieldset_id}/disassociate', ['uses' => 'CustomFieldsController@deleteFieldFromFieldset','as' => 'admin.custom_fields.disassociate']);
Route::match(['DELETE'], 'custom_fields/delete-field/{id}', ['uses' => 'CustomFieldsController@deleteField','as' => 'admin.custom_fields.delete-field']);
Route::resource('custom_fields', 'CustomFieldsController');
# User Management
Route::group([ 'prefix' => 'users', 'middleware' => ['web','auth','authorize:users.view']], function () {
Route::get('ldap', ['as' => 'ldap/user', 'uses' => 'UsersController@getLDAP', 'middleware' => ['authorize:users.edit'] ]);
Route::post('ldap', 'UsersController@postLDAP');
Route::get('create', [ 'as' => 'create/user', 'uses' => 'UsersController@getCreate', 'middleware' => ['authorize:users.edit'] ]);
Route::post('create', [ 'uses' => 'UsersController@postCreate', 'middleware' => ['authorize:users.edit'] ]);
Route::get('import', [ 'as' => 'import/user', 'uses' => 'UsersController@getImport', 'middleware' => ['authorize:users.edit'] ]);
Route::post('import', [ 'uses' => 'UsersController@postImport', 'middleware' => ['authorize:users.edit'] ]);
Route::get('{userId}/edit', [ 'as' => 'update/user', 'uses' => 'UsersController@getEdit', 'middleware' => ['authorize:users.edit'] ]);
Route::post('{userId}/edit', [ 'uses' => 'UsersController@postEdit', 'middleware' => ['authorize:users.edit'] ]);
Route::get('{userId}/clone', [ 'as' => 'clone/user', 'uses' => 'UsersController@getClone', 'middleware' => ['authorize:users.edit'] ]);
Route::post('{userId}/clone', [ 'uses' => 'UsersController@postCreate', 'middleware' => ['authorize:users.edit'] ]);
Route::get('{userId}/delete', [ 'as' => 'delete/user', 'uses' => 'UsersController@getDelete', 'middleware' => ['authorize:users.edit'] ]);
Route::get('{userId}/restore', [ 'as' => 'restore/user', 'uses' => 'UsersController@getRestore', 'middleware' => ['authorize:users.edit'] ]);
Route::get('{userId}/view', [ 'as' => 'view/user', 'uses' => 'UsersController@getView' , 'middleware' => ['authorize:users.view'] ]);
Route::get('{userId}/unsuspend', [ 'as' => 'unsuspend/user', 'uses' => 'UsersController@getUnsuspend', 'middleware' => ['authorize:users.edit'] ]);
Route::get(
'{userId}/deletefile/{fileId}',
[ 'as' => 'delete/userfile', 'uses' => 'UsersController@getDeleteFile' ]
);
Route::get(
'{userId}/showfile/{fileId}',
[ 'as' => 'show/userfile', 'uses' => 'UsersController@displayFile' ]
);
Route::post(
'bulkedit',
[
'as' => 'users/bulkedit',
'uses' => 'UsersController@postBulkEdit',
'middleware' => ['authorize:users.edit'],
]
);
Route::post(
'bulksave',
[
'as' => 'users/bulksave',
'uses' => 'UsersController@postBulkSave',
'middleware' => ['authorize:users.edit'],
]
);
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('/');
});
-21
View File
@@ -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;
}
-193
View File
@@ -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);
}
}
-184
View File
@@ -1,184 +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 userasassetlog()
{
return $this->belongsTo('\App\Models\User', 'asset_id')
->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);
}
}
-915
View File
@@ -1,915 +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 App\Http\Traits\UniqueUndeletedTrait;
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;
use UniqueUndeletedTrait;
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_undeleted',
'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->assignedUser) {
$user_name = $this->assignedUser->fullName();
} else {
$user_name = "Unassigned";
}
return $this->asset_tag . ' - ' . $this->name . ' (' . $user_name . ') ' . $this->model->name;
}
public function validationRules($id = '0')
{
return $this->rules;
}
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 Company::scopeCompanyables(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 == '') {
if ($this->model) {
return $this->model->name.' ('.$this->asset_tag.')';
}
return $this->asset_tag;
} 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');
if ($settings->zerofill_count > 0) {
return $settings->auto_increment_prefix.Asset::zerofill(($asset_tag + 1),$settings->zerofill_count);
}
return $settings->auto_increment_prefix.($asset_tag + 1);
} else {
return false;
}
}
public static function zerofill ($num, $zerofill = 3)
{
return str_pad($num, $zerofill, '0', STR_PAD_LEFT);
}
public function checkin_email()
{
return $this->model->category->checkin_email;
}
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 Company::scopeCompanyables($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);
}
}
-138
View File
@@ -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);
}
}
-164
View File
@@ -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.'%');
});
});
}
}
-145
View File
@@ -1,145 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Watson\Validating\ValidatingTrait;
use App\Http\Traits\UniqueUndeletedTrait;
/**
* Model for Categories. Categories are a higher-level group
* 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_undeleted',
'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;
use UniqueUndeletedTrait;
/**
* 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.'%');
});
}
}
-179
View File
@@ -1,179 +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;
}
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();
// Super users should be able to set a company to whatever they need
if ($current_user->isSuperUser()) {
return static::getIdFromInput($unescaped_input);
} else {
if ($current_user->company_id != null) {
return $current_user->company_id;
} else {
return static::getIdFromInput($unescaped_input);
}
}
}
}
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()->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() || (Auth::check() && Auth::user()->isSuperUser())) {
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);
}
}
}
-38
View File
@@ -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)
{
}
}
-15
View File
@@ -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);
}
}
-37
View File
@@ -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)
{
}
}
-15
View File
@@ -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);
}
}
-186
View File
@@ -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);
}
}
-227
View File
@@ -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);
}
}
-27
View File
@@ -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');
}
}
-112
View File
@@ -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;
}
}
}
-45
View File
@@ -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?
}
-83
View File
@@ -1,83 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Depreciation;
class Depreciable extends Model
{
/**
* Depreciation Relation, and associated helper methods
*/
//REQUIRES a purchase_date field
// and a purchase_cost field
//REQUIRES a get_depreciation method,
//which will return the deprecation.
//this is needed because assets get
//their depreciation from a model,
//whereas licenses have deprecations
//directly associated with them.
//assets will override the following
//two methods in order to inherit from
//their model instead of directly (like
//here)
public function depreciation()
{
return $this->belongsTo('\App\Models\Depreciation', 'depreciation_id');
}
public function get_depreciation()
{
return $this->depreciation;
}
/**
* @return float|int
*/
public function getDepreciatedValue()
{
if (!$this->get_depreciation()) { // will never happen
return $this->purchase_cost;
}
if ($this->get_depreciation()->months <= 0) {
return $this->purchase_cost;
}
// fraction of value left
$months_remaining = $this->time_until_depreciated()->m + 12*$this->time_until_depreciated()->y; //UGlY
$current_value = round(($months_remaining/ $this->get_depreciation()->months) * $this->purchase_cost, 2);
if ($current_value < 0) {
$current_value = 0;
}
return $current_value;
}
public function time_until_depreciated()
{
// @link http://www.php.net/manual/en/class.datetime.php
$d1 = new \DateTime();
$d2 = $this->depreciated_date();
// @link http://www.php.net/manual/en/class.dateinterval.php
$interval = $d1->diff($d2);
if (!$interval->invert) {
return $interval;
} else {
return new \DateInterval("PT0S"); //null interval (zero seconds from now)
}
}
public function depreciated_date()
{
$date = date_create($this->purchase_date);
date_add($date, date_interval_create_from_date_string($this->get_depreciation()->months . ' months'));
return $date; //date_format($date, 'Y-m-d'); //don't bake-in format, for internationalization
}
}
-61
View File
@@ -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.'%');
});
}
}
-40
View File
@@ -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);
}
}
-7
View File
@@ -1,7 +0,0 @@
<?php
namespace App\Models;
interface ICompanyableChild
{
public function getCompanyableParents();
}
-279
View File
@@ -1,279 +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;
$ldap_use_tls = Setting::getSettings()->ldap_tls;
// If we are ignoring the SSL cert we need to setup the environment variable
// before we create the connection
if ($ldap_server_cert_ignore=='1') {
putenv('LDAPTLS_REQCERT=never');
}
// If the user specifies where CA Certs are, make sure to use them
if(env("LDAPTLS_CACERT")) {
putenv("LDAPTLS_CACERT=".env("LDAPTLS_CACERT"));
}
$connection = @ldap_connect($ldap_host);
if (!$connection) {
throw new Exception('Could not connect to LDAP server at '.$ldap_host.'. Please check your LDAP server name and port number in your settings.');
}
// Needed for AD
ldap_set_option($connection, LDAP_OPT_REFERRALS, 0);
ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, $ldap_version);
if ($ldap_use_tls=='1') {
ldap_start_tls($connection);
}
return $connection;
}
/**
* Binds/authenticates the user to LDAP, and returns their attributes.
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0]
* @param $username
* @param $password
* @param bool|false $user
* @return bool true if the username and/or password provided are valid
* false if the username and/or password provided are invalid
* array of ldap_attributes if $user is true
*
*/
static function findAndBindUserLdap($username, $password)
{
$settings = Setting::getSettings();
$connection = Ldap::connectToLdap();
$ldap_username_field = $settings->ldap_username_field;
$baseDn = $settings->ldap_basedn;
if ($settings->is_ad =='1')
{
// 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;
}
}
-215
View File
@@ -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.'%');
});
}
}
-35
View File
@@ -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();
}
}
-170
View File
@@ -1,170 +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;
use App\Http\Traits\UniqueUndeletedTrait;
class Location extends Model
{
use SoftDeletes;
protected $dates = ['deleted_at'];
protected $table = 'locations';
protected $rules = array(
'name' => 'required|min:3|max:255|unique_undeleted',
'city' => 'min:3|max:255',
'state' => 'min:2|max:32',
'country' => 'min:2|max:2|max:2',
'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;
use UniqueUndeletedTrait;
/**
* 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);
}
}
-65
View File
@@ -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.'%');
});
}
}

Some files were not shown because too many files have changed in this diff Show More