A free open source IT asset/license management system
Updated helper to use datetime instead of date
snipee57abdbcb7bd
diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.phpindex b8dc9d4a14..504a2655ad 100644--- a/app/Http/Transformers/AssetsTransformer.php+++ b/app/Http/Transformers/AssetsTransformer.php@@ -118,7 +118,7 @@ class AssetsTransformer'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'),- 'expected_checkin' => Helper::getFormattedDateObject($asset->expected_checkin, 'date'),+ 'expected_checkin' => Helper::getFormattedDateObject($asset->expected_checkin, 'datetime'),'purchase_cost' => Helper::formatCurrencyOutput($asset->purchase_cost),'checkin_counter' => (int) $asset->checkin_counter,'checkout_counter' => (int) $asset->checkout_counter,@@ -135,9 +135,9 @@ class AssetsTransformer$decrypted = Helper::gracefulDecrypt($field, $asset->{$field->db_column});$value = (Gate::allows('assets.view.encrypted_custom_fields')) ? $decrypted : strtoupper(trans('admin/custom_fields/general.encrypted'));- if ($field->format == 'DATE') {+ if ($field->format == 'DATE' || $field->format == 'DATETIME') {if (Gate::allows('assets.view.encrypted_custom_fields')) {- $value = Helper::getFormattedDateObject($value, 'date', false);+ $value = Helper::getFormattedDateObject($value, $field->format == 'DATETIME' ? 'datetime' : 'date', false);} else {$value = strtoupper(trans('admin/custom_fields/general.encrypted'));}@@ -153,8 +153,8 @@ class AssetsTransformer} else {$value = $asset->{$field->db_column};- if (($field->format == 'DATE') && (! is_null($value)) && ($value != '')) {- $value = Helper::getFormattedDateObject($value, 'date', false);+ if ((in_array($field->format, ['DATE', 'DATETIME'])) && (! is_null($value)) && ($value != '')) {+ $value = Helper::getFormattedDateObject($value, $field->format == 'DATETIME' ? 'datetime' : 'date', false);}$fields_array[$field->name] = [@@ -256,7 +256,7 @@ class AssetsTransformer'image' => ($asset->getImageUrl()) ? $asset->getImageUrl() : null,'model' => ($asset->model) ? e($asset->model->name) : null,'model_number' => (($asset->model) && ($asset->model->model_number)) ? e($asset->model->model_number) : null,- 'expected_checkin' => Helper::getFormattedDateObject($asset->expected_checkin, 'date'),+ 'expected_checkin' => Helper::getFormattedDateObject($asset->expected_checkin, 'datetime'),'location' => ($asset->location) ? e($asset->location->name) : null,'status' => ($asset->status) ? $asset->present()->statusMeta : null,'assigned_to_self' => ($asset->assigned_to == auth()->id()),@@ -271,8 +271,8 @@ class AssetsTransformerif (($field->field_encrypted == '0') && ($field->show_in_requestable_list == '1')) {$value = $asset->{$field->db_column};- if (($field->format == 'DATE') && (! is_null($value)) && ($value != '')) {- $value = Helper::getFormattedDateObject($value, 'date', false);+ if ((in_array($field->format, ['DATE', 'DATETIME'])) && (! is_null($value)) && ($value != '')) {+ $value = Helper::getFormattedDateObject($value, $field->format == 'DATETIME' ? 'datetime' : 'date', false);}$fields_array[$field->db_column] = ($field->element == 'markdown-textarea') ? Helper::renderMarkdown($value) : e($value);diff --git a/app/Mail/CheckinAssetMail.php b/app/Mail/CheckinAssetMail.phpindex 2c086cd89e..f709084281 100644--- a/app/Mail/CheckinAssetMail.php+++ b/app/Mail/CheckinAssetMail.php@@ -31,7 +31,7 @@ class CheckinAssetMail extends BaseMailable$this->expected_checkin = '';if ($this->item->expected_checkin) {- $this->expected_checkin = Helper::getFormattedDateObject($this->item->expected_checkin, 'date',+ $this->expected_checkin = Helper::getFormattedDateObject($this->item->expected_checkin, 'datetime',false);}}diff --git a/app/Mail/CheckoutAssetMail.php b/app/Mail/CheckoutAssetMail.phpindex 0396d41da2..dcd26eaeec 100644--- a/app/Mail/CheckoutAssetMail.php+++ b/app/Mail/CheckoutAssetMail.php@@ -46,7 +46,7 @@ class CheckoutAssetMail extends BaseMailable}if ($this->item->expected_checkin) {- $this->expected_checkin = Helper::getFormattedDateObject($this->item->expected_checkin, 'date',+ $this->expected_checkin = Helper::getFormattedDateObject($this->item->expected_checkin, 'datetime',false);}}diff --git a/app/Notifications/CheckoutAssetNotification.php b/app/Notifications/CheckoutAssetNotification.phpindex fbd4a931bf..947a5f89aa 100644--- a/app/Notifications/CheckoutAssetNotification.php+++ b/app/Notifications/CheckoutAssetNotification.php@@ -46,7 +46,7 @@ class CheckoutAssetNotification extends Notification}if ($this->item->expected_checkin) {- $this->expected_checkin = Helper::getFormattedDateObject($this->item->expected_checkin, 'date',+ $this->expected_checkin = Helper::getFormattedDateObject($this->item->expected_checkin, 'datetime',false);}}diff --git a/app/Notifications/ExpectedCheckinNotification.php b/app/Notifications/ExpectedCheckinNotification.phpindex 7b8d446774..68c6ab679e 100644--- a/app/Notifications/ExpectedCheckinNotification.php+++ b/app/Notifications/ExpectedCheckinNotification.php@@ -56,7 +56,7 @@ class ExpectedCheckinNotification extends Notification$message = (new MailMessage)->markdown('notifications.markdown.expected-checkin',['expected_checkin_date' => $this->params->expected_checkin,- 'date' => Helper::getFormattedDateObject($this->params->expected_checkin, 'date', false),+ 'date' => Helper::getFormattedDateObject($this->params->expected_checkin, 'datetime', false),'asset' => $this->params->display_name,'serial' => $this->params->serial,'asset_tag' => $this->params->asset_tag,diff --git a/resources/views/mail/markdown/bulk-asset-checkout-mail.blade.php b/resources/views/mail/markdown/bulk-asset-checkout-mail.blade.phpindex 716abf99dd..52aa4ef052 100644--- a/resources/views/mail/markdown/bulk-asset-checkout-mail.blade.php+++ b/resources/views/mail/markdown/bulk-asset-checkout-mail.blade.php@@ -24,7 +24,7 @@@endif@if ((isset($expected_checkin)) && ($expected_checkin!=''))-**{{ trans('mail.expecting_checkin_date') }}**: {{ Helper::getFormattedDateObject($expected_checkin, 'date', false) }}+**{{ trans('mail.expecting_checkin_date') }}**: {{ Helper::getFormattedDateObject($expected_checkin, 'datetime', false) }}@endif@if ($note)diff --git a/resources/views/maintenances/edit.blade.php b/resources/views/maintenances/edit.blade.phpindex db43dc469b..9387e26c38 100644--- a/resources/views/maintenances/edit.blade.php+++ b/resources/views/maintenances/edit.blade.php@@ -89,10 +89,9 @@input_div_class="col-md-4"><x-slot:input>- <x-input.datepicker+ <x-input.datetimepickername="start_date"- :value="old('start_date', $item->start_date)"- :placeholder="trans('general.select_date')"+ :value="old('start_date', $item->start_date?->format('Y-m-d H:i:s'))":required="Helper::checkIfRequired($item, 'start_date')"/></x-slot:input>@@ -104,10 +103,9 @@input_div_class="col-md-4"><x-slot:input>- <x-input.datepicker+ <x-input.datetimepickername="completion_date"- :value="old('completion_date', $item->completion_date)"- :placeholder="trans('general.select_date')"+ :value="old('completion_date', $item->completion_date?->format('Y-m-d H:i:s'))":required="Helper::checkIfRequired($item, 'completion_date')"/></x-slot:input>diff --git a/resources/views/maintenances/view.blade.php b/resources/views/maintenances/view.blade.phpindex 6fe8614552..838364975f 100644--- a/resources/views/maintenances/view.blade.php+++ b/resources/views/maintenances/view.blade.php@@ -83,12 +83,12 @@ use Carbon\Carbon;</x-data-row><x-data-row :label="trans('general.start_date')" copy_what="start_date">- {{ Helper::getFormattedDateObject($maintenance->start_date, 'date', false) }}+ {{ Helper::getFormattedDateObject($maintenance->start_date, 'datetime', false) }}</x-data-row><x-data-row :label="trans('admin/maintenances/form.completion_date')" copy_what="completion_date">@if ($maintenance->completion_date)- {{ Helper::getFormattedDateObject($maintenance->completion_date, 'date', false) }}+ {{ Helper::getFormattedDateObject($maintenance->completion_date, 'datetime', false) }}@else{{ trans('admin/maintenances/message.asset_maintenance_incomplete') }}@endifdiff --git a/resources/views/models/custom_fields_form.blade.php b/resources/views/models/custom_fields_form.blade.phpindex ac75f378af..0cddecdc8c 100644--- a/resources/views/models/custom_fields_form.blade.php+++ b/resources/views/models/custom_fields_form.blade.php@@ -86,6 +86,18 @@</div>+ @elseif ($field->format=='DATETIME')++ <x-input.datetimepicker+ id="{{ $field->db_column_name() }}"+ name="{{ $field->db_column_name() }}"+ :value="old($field->db_column_name(), isset($item) ? Helper::gracefulDecrypt($field, $item->{$field->db_column_name()}) : $field->defaultValue($model->id))"+ col_size_class="col-md-5"+ required="{{ ($field->pivot->required=='1') ? '1' : '' }}"+ :default_now="false"+ />++@else@if (($field->field_encrypted=='0') || (Gate::allows('assets.view.encrypted_custom_fields')))<input type="text" value="{{ old($field->db_column_name(),(isset($item) ? Helper::gracefulDecrypt($field, $item->{$field->db_column_name()}) : $field->defaultValue($model->id))) }}" id="{{ $field->db_column_name() }}" class="form-control" name="{{ $field->db_column_name() }}" placeholder="Enter {{ strtolower($field->format) }} text"{{ ($field->pivot->required=='1') ? ' required' : '' }}>diff --git a/resources/views/notifications/markdown/report-expected-checkins.blade.php b/resources/views/notifications/markdown/report-expected-checkins.blade.phpindex 9e5259e12e..ff43dda1ec 100644--- a/resources/views/notifications/markdown/report-expected-checkins.blade.php+++ b/resources/views/notifications/markdown/report-expected-checkins.blade.php@@ -8,7 +8,7 @@| ------------- | ------------- | ------------- |@foreach ($assets as $asset)@php-$checkin = Helper::getFormattedDateObject($asset->expected_checkin, 'date');+$checkin = Helper::getFormattedDateObject($asset->expected_checkin, 'datetime');$assignedToName = $asset->assignedTo ? $asset->assignedTo->present()->fullName : trans('general.unknown_user');$assignedToRoute = $asset->assignedTo ? route($asset->targetShowRoute().'.show', [$asset->assignedTo->id]) : '';