Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Helpers;
use App\Models\Accessory;
use App\Models\Actionlog;
use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Component;
Expand Down Expand Up @@ -1569,6 +1570,19 @@ public static function determineLanguageDirection() {
'he-IL'
]) ? 'rtl' : 'ltr';
}
public static function getAssetFirstCheckout($assetId) {

if (!$assetId) {
return null;
}
$first_checkout = Actionlog::where('item_id', $assetId)
->where('item_type', Asset::class)
->where('action_type', 'checkout')
->oldest('created_at')
->first();

return self::getFormattedDateObject($first_checkout?->created_at, 'datetime');
}


static public function getRedirectOption($request, $id, $table, $item_id = null) : RedirectResponse
Expand Down
1 change: 1 addition & 0 deletions app/Http/Transformers/AssetsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public function transformAsset(Asset $asset)
'next_audit_date' => Helper::getFormattedDateObject($asset->next_audit_date, 'date'),
'deleted_at' => Helper::getFormattedDateObject($asset->deleted_at, 'datetime'),
'purchase_date' => Helper::getFormattedDateObject($asset->purchase_date, 'date'),
'first_checkout' => Helper::getAssetFirstCheckout($asset->id),
'age' => $asset->purchase_date ? $asset->purchase_date->locale(app()->getLocale())->diffForHumans() : '',
'last_checkout' => Helper::getFormattedDateObject($asset->last_checkout, 'datetime'),
'last_checkin' => Helper::getFormattedDateObject($asset->last_checkin, 'datetime'),
Expand Down
7 changes: 7 additions & 0 deletions app/Presenters/AssetPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ public static function dataTableLayout()
'visible' => false,
'title' => trans('general.purchase_date'),
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'first_checkout',
'searchable' => true,
'sortable' => true,
'visible' => false,
'title' => trans('general.first_checkout'),
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'age',
'searchable' => false,
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/en-US/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@
'exclude_archived' => 'Exclude Archived Assets',
'exclude_deleted' => 'Exclude Deleted Assets',
'example' => 'Example: ',

'files' => 'Files',
'file_name' => 'File Name',
'file_type' => 'File Type',
'filesize' => 'File Size',
'file_uploads' => 'File Uploads',
'file_upload' => 'File Upload',
'first_checkout' => '1<sup>st</sup> Checkout',
'generate' => 'Generate',
'generate_labels' => 'Generate Labels',
'github_markdown' => 'This field accepts <a href="https://help.github.com/articles/github-flavored-markdown/">Github flavored markdown</a>.',
Expand Down
12 changes: 12 additions & 0 deletions resources/views/hardware/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,18 @@ class="form-inline"
</div>
@endif

<div class="row">
<div class="col-md-3">
<strong>
{!! trans('general.first_checkout') !!}
</strong>
</div>
<div class="col-md-9">
{{ Helper::getAssetFirstCheckout($asset->id)['formatted'] ?? '' }}
</div>
</div>


@if ($asset->last_checkin!='')
<div class="row">
<div class="col-md-3">
Expand Down
Loading