snipe-it
snipe-it copied to clipboard
Last Checkin Date added to Hardware View and Index
Description
We were not showing the last_checkin
date on the hardware view or index. This is a field in the hardware table and this PR adds in being able to see that data.
- [x] Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
tested locally via test instance
Checklist:
- [x] I have read the Contributing documentation available here: https://snipe-it.readme.io/docs/contributing-overview
- [x] I have formatted this PR according to the project guidelines: https://snipe-it.readme.io/docs/contributing-overview#pull-request-guidelines
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
This pull request has been linked to Shortcut Story #24812: Show Last Check In date on Hardware Index view.
PR Summary
-
Change in 'AssetsController.php' & 'AssetCheckinController.php' The last check-out date is no longer cleared upon performing actions in these files. This is due to the commenting out of the line that previously cleared it.
-
Update in 'ReportsController.php' The system now processes the start and end dates using a more efficient approach ('Carbon'). It then applies the updated condition for filtering assets based on their last check-in dates.
-
Addition in 'AssetsTransformer.php' There's an addition of a new line responsible for managing the last check-in date of the asset objects in the data transformation process.
-
New Feature in 'AssetPresenter.php' In the data table layout, there is a new column for showcasing the date of the last check-ins.
-
Enhancement in 'view.blade.php' Now it includes an additional row displaying the last check-in date, provided that the date exists. This makes tracking last check-ins easier.
I commented out the nulling out of thelast_checkout
date. But I can revert that easy for this PR.
@akemidx can you resolve those conflicts for me?
@akemidx Make sure you test the sorting and searching in the UI and API on changes like this.
Sorting isn't working currently. I'll fix it, but it's something to keep in mind while testing changes moving forward.
@akemidx see #14516 for the fix. If we want to allow sorting on a DB field that's actually on the table itself (not a relation), it needs to be added to the $allowed_columns
array so we know it's a straightforward sort with no complicated relationships going on. That $allowed_columns
array exists to "allow list" known columns so people can't cause 500s by trying to sort on an asset table field that doesn't exist.