-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Adds #9557 Expiring Items Report to GUI: Assets and Licenses #18723
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
Open
Godmartinz
wants to merge
13
commits into
grokability:develop
Choose a base branch
from
Godmartinz:expiring-reports-in-gui
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
91fc13b
add getExpiringAssetsReport method
Godmartinz 90420d8
add route and blade for expiring items
Godmartinz 3339223
add report to sidebar menu
Godmartinz c04e89b
add translations, fix breadcrumbs, add expiring asset and licenses tabs
Godmartinz 7b37a73
able to export assets
Godmartinz aadcebd
add licenses to csv download
Godmartinz e6bb647
adds api method, routes, adds transformer and presenter, adjusts expi…
Godmartinz fea92bd
clean up unused and commented out code
Godmartinz ba58abd
remove unnecessary csv export method
Godmartinz 6c7e7b6
remove unnecessary route
Godmartinz 084eee4
Merge branch 'develop' into expiring-reports-in-gui
Godmartinz 2896b74
adds tests, repurpose queries to count
Godmartinz e7bf398
change get to input change eol_rate in transformer
Godmartinz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Transformers; | ||
|
|
||
| use App\Helpers\Helper; | ||
| use Carbon\Carbon; | ||
|
|
||
| class ExpiringItemsTransformer | ||
| { | ||
| public function transformAssets($assets, $total) | ||
| { | ||
| $rows = []; | ||
|
|
||
| foreach ($assets as $asset) { | ||
| $rows[] = [ | ||
| 'id' => $asset->id, | ||
| 'asset_tag' => $asset->asset_tag, | ||
| 'model' => $asset->model->name ?? '', | ||
| 'model_number' => $asset->model->model_number ?? '', | ||
| 'purchase_date' => Helper::getFormattedDateObject($asset->purchase_date, 'date'), | ||
| 'eol_rate' => (($asset->asset_eol_date != '') && ($asset->purchase_date != '')) ? (int)Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date, true) . ' months' : null, | ||
| 'eol_date' => Helper::getFormattedDateObject($asset->eol_date, 'date'), | ||
| 'warranty_expires' => $asset->warranty_expires ? $asset->warranty_expires_formatted_date .' ('.$asset->warranty_expires_diff_for_humans.')' : '', | ||
| ]; | ||
| } | ||
|
|
||
| return [ | ||
| 'total' => $total, | ||
| 'rows' => $rows, | ||
| ]; | ||
| } | ||
|
|
||
| public function transformLicenses($licenses, $total) | ||
| { | ||
| $rows = []; | ||
|
|
||
| foreach ($licenses as $license) { | ||
|
|
||
| $rows[] = [ | ||
| 'id' => $license->id, | ||
| 'name' => $license->name, | ||
| 'purchase_date' => $license->purchase_date_formatted ?? null, | ||
| 'expiration' => $license->expires_formatted_date ? $license->expires_formatted_date . ($license->expires_diff_for_humans ? ' ('.$license->expires_diff_for_humans.')' : '') : null, | ||
| 'termination_date' => $license->terminates_formatted_date ? $license->terminates_formatted_date . ($license->terminates_diff_for_humans ? ' ('.$license->terminates_diff_for_humans.')' : '') : null, | ||
| ]; | ||
| } | ||
|
|
||
| return [ | ||
| 'total' => $total, | ||
| 'rows' => $rows, | ||
| ]; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| <?php | ||
|
|
||
| namespace App\Presenters; | ||
|
|
||
| /** | ||
| * Class ExpiringAssetsLicensesReportPresenter | ||
| * | ||
| * @package App\Presenters | ||
| */ | ||
| class ExpiringItemsPresenter extends Presenter | ||
| { | ||
| /** | ||
| * JSON column layout for expiring assets table. | ||
| * | ||
| * @return string | ||
| */ | ||
| public static function assetsDataTableLayout() | ||
| { | ||
| $layout = [ | ||
| [ | ||
| 'field' => 'id', | ||
| 'searchable' => true, | ||
| 'sortable' => true, | ||
| 'title' => trans('general.id'), | ||
| 'visible' => true, | ||
| ], | ||
| [ | ||
| 'field' => 'asset_tag', | ||
| 'searchable' => true, | ||
| 'sortable' => true, | ||
| 'title' => trans('admin/hardware/form.tag'), | ||
| 'visible' => true, | ||
| ], | ||
| [ | ||
| 'field' => 'model', | ||
| 'searchable' => true, | ||
| 'sortable' => true, | ||
| 'title' => trans('admin/hardware/form.model'), | ||
| 'visible' => true, | ||
| ], | ||
| [ | ||
| 'field' => 'model_number', | ||
| 'searchable' => true, | ||
| 'sortable' => true, | ||
| 'title' => trans('general.model_no'), | ||
| 'visible' => true, | ||
| ], | ||
| [ | ||
| 'field' => 'purchase_date', | ||
| 'searchable' => true, | ||
| 'sortable' => true, | ||
| 'title' => trans('general.purchase_date'), | ||
| 'visible' => true, | ||
| 'formatter' => 'dateDisplayFormatter', | ||
| ], | ||
| [ | ||
| 'field' => 'eol_rate', | ||
| 'searchable' => true, | ||
| 'sortable' => true, | ||
| 'title' => trans('admin/hardware/form.eol_rate'), | ||
| 'visible' => true, | ||
| ], | ||
| [ | ||
| 'field' => 'eol_date', | ||
| 'searchable' => true, | ||
| 'sortable' => true, | ||
| 'title' => trans('admin/hardware/form.eol_date'), | ||
| 'visible' => true, | ||
| 'formatter' => 'dateDisplayFormatter', | ||
| ], | ||
| [ | ||
| 'field' => 'warranty_expires', | ||
| 'searchable' => true, | ||
| 'sortable' => true, | ||
| 'title' => trans('admin/hardware/form.warranty_expires'), | ||
| 'visible' => true, | ||
| ], | ||
| ]; | ||
|
|
||
| return json_encode($layout); | ||
| } | ||
|
|
||
| /** | ||
| * JSON column layout for expiring licenses table. | ||
| * | ||
| * @return string | ||
| */ | ||
| public static function licensesDataTableLayout() | ||
| { | ||
| $layout = [ | ||
| [ | ||
| 'field' => 'id', | ||
| 'searchable' => true, | ||
| 'sortable' => true, | ||
| 'title' => trans('general.id'), | ||
| 'visible' => true, | ||
| ], | ||
| [ | ||
| 'field' => 'name', | ||
| 'searchable' => true, | ||
| 'sortable' => true, | ||
| 'title' => trans('general.name'), | ||
| 'visible' => true, | ||
| ], | ||
| [ | ||
| 'field' => 'purchase_date', | ||
| 'searchable' => true, | ||
| 'sortable' => true, | ||
| 'title' => trans('general.purchase_date'), | ||
| 'visible' => true, | ||
| ], | ||
| [ | ||
| 'field' => 'expiration', | ||
| 'searchable' => true, | ||
| 'sortable' => true, | ||
| 'title' => trans('admin/licenses/form.expiration'), | ||
| 'visible' => true, | ||
| ], | ||
| [ | ||
| 'field' => 'termination_date', | ||
| 'searchable' => true, | ||
| 'sortable' => true, | ||
| 'title' => trans('admin/licenses/form.termination_date'), | ||
| 'visible' => true, | ||
| ], | ||
| ]; | ||
|
|
||
| return json_encode($layout); | ||
| } | ||
|
|
||
| /** | ||
| * Combined report payload. | ||
| * | ||
| * @param array $assets | ||
| * @param array $licenses | ||
| * @param int $days | ||
| * @param bool $includeExpired | ||
| * @return array | ||
| */ | ||
| public static function reportData(array $assets, array $licenses, int $days, bool $includeExpired) | ||
| { | ||
| return [ | ||
| 'assets' => $assets, | ||
| 'licenses' => $licenses, | ||
| 'meta' => [ | ||
| 'days' => $days, | ||
| 'include_expired' => $includeExpired, | ||
| 'asset_count' => count($assets), | ||
| 'license_count' => count($licenses), | ||
| ], | ||
| 'table_layouts' => [ | ||
| 'assets' => json_decode(self::assetsDataTableLayout(), true), | ||
| 'licenses' => json_decode(self::licensesDataTableLayout(), true), | ||
| ], | ||
| ]; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.