Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added last check in column and filter to custom asset report #13498

Conversation

marcusmoore
Copy link
Collaborator

Description

This PR adds the Last Checkin Date column and Last Checkin Date range filter to the Custom Asset Report:

Some fields on the custom report page

The column displays the date and time the asset was last checked in and the filter allows for only returning items that were last checked in during range. Since we are only searching the last check in, an asset that was checked in during the range but then checked out and checked in outside of the range, it will not be included.

One question: Should the label be Last Checkin Date (which matches the labels below it), Last Checkin Date Range (which matches the labels above, or should I update the labels to all have Range?


Closes: Shortcut Story #23356: Add check in date range filter on the custom asset report
Follows up on #13323


Type of change

  • New feature (non-breaking change which adds functionality)

@what-the-diff
Copy link

what-the-diff bot commented Aug 21, 2023

PR Summary

  • Introduce last_checkin property to Assets
    Updated the app/Http/Controllers/Api/AssetsController.php and app/Http/Controllers/Assets/AssetCheckinController.php files to record the last check-in time for an asset. This enhancement allows for better tracking of each asset's usage and availability.

  • Filter Assets based on check-in date
    The app/Http/Controllers/ReportsController.php and resources/views/reports/custom.blade.php files were adjusted to include a new option that allows users to filter assets in the custom report form based on their last check-in dates. This allows for more precise and tailored reporting according to user needs.

  • Database and model adjustments for last_checkin
    Added a new migration file 2023_08_17_202638_add_last_checkin_to_assets.php to introduce a last_checkin column to the assets table. Also, the app/Models/Asset.php was modified to accommodate the last_checkin property. This ensures the new property is correctly stored and retrieved from the database.

  • Translate new column name
    The resources/lang/en/admin/hardware/table.php file was updated to reflect the English translation for the new "Last Checkin Date" column. This ensures consistency and clarity in the interface across the English-speaking user base.

  • Test coverage for new functionality
    Two new test files tests/Feature/Api/Assets/AssetCheckinTest.php and tests/Feature/Assets/AssetCheckinTest.php were introduced to ensure the last_checkin field functions as intended during asset check-in. An additional test case was introduced into tests/Feature/Reports/CustomReportTest.php to validate the filtering of assets by the check-in date in the custom report. This ensures the robustness and reliability of the new features added to the system.

@@ -651,6 +655,13 @@ public function postCustom(Request $request)
$assets->whereBetween('assets.last_checkout', [$checkout_start, $checkout_end]);
}

if (($request->filled('checkin_date_start')) && ($request->filled('checkin_date_end'))) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible we might want to allow no end date, or maybe default the date to today? I could see that being an annoying process, having to pick that every time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thinking.

On the frontend, the end date is selected when the user selects the start date but they are able to clear the date and skip passing checkin_date_end to the backend.

I just pushed a commit that handles that situation.

@marcusmoore marcusmoore requested a review from snipe August 21, 2023 22:55
@marcusmoore
Copy link
Collaborator Author

@snipe friendly ping to check out my changes.

@snipe snipe merged commit a62e2f0 into snipe:develop Sep 5, 2023
@marcusmoore marcusmoore deleted the feature/add-checkin-date-range-filter-to-custom-asset-report branch September 6, 2023 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants