diff --git a/app/Http/Controllers/AssetModelsController.php b/app/Http/Controllers/AssetModelsController.php index d7a135dd76..1783b33921 100755 --- a/app/Http/Controllers/AssetModelsController.php +++ b/app/Http/Controllers/AssetModelsController.php @@ -179,9 +179,14 @@ class AssetModelsController extends Controller if ($model->save()) { if ($model->wasChanged('eol')) { - $newEol = $model->eol; - $model->assets()->whereNotNull('purchase_date')->where('eol_explicit', false) - ->update(['asset_eol_date' => DB::raw('DATE_ADD(purchase_date, INTERVAL ' . $newEol . ' MONTH)')]); + if ($model->eol > 0) { + $newEol = $model->eol; + $model->assets()->whereNotNull('purchase_date')->where('eol_explicit', false) + ->update(['asset_eol_date' => DB::raw('DATE_ADD(purchase_date, INTERVAL ' . $newEol . ' MONTH)')]); + } elseif ($model->eol == 0) { + $model->assets()->whereNotNull('purchase_date')->where('eol_explicit', false) + ->update(['asset_eol_date' => DB::raw('null')]); + } } return redirect()->route('models.index')->with('success', trans('admin/models/message.update.success')); } diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 92922c4cdf..8a12d744ae 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -137,7 +137,7 @@ class AssetsController extends Controller $asset->warranty_months = request('warranty_months', null); $asset->purchase_cost = request('purchase_cost'); $asset->purchase_date = request('purchase_date', null); - $asset->asset_eol_date = request('asset_eol_date', $asset->present()->eol_date()); + $asset->asset_eol_date = request('asset_eol_date', null); $asset->assigned_to = request('assigned_to', null); $asset->supplier_id = request('supplier_id', null); $asset->requestable = request('requestable', 0); @@ -309,14 +309,15 @@ class AssetsController extends Controller $asset->warranty_months = $request->input('warranty_months', null); $asset->purchase_cost = $request->input('purchase_cost', null); $asset->purchase_date = $request->input('purchase_date', null); - if ($request->filled('purchase_date') && !$request->filled('asset_eol_date') && $asset->model->eol) { + if ($request->filled('purchase_date') && !$request->filled('asset_eol_date') && ($asset->model->eol > 0)) { $asset->purchase_date = $request->input('purchase_date', null); $asset->asset_eol_date = Carbon::parse($request->input('purchase_date'))->addMonths($asset->model->eol)->format('Y-m-d'); + $asset->eol_explicit = false; } elseif ($request->filled('asset_eol_date')) { $asset->asset_eol_date = $request->input('asset_eol_date', null); $months = Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date); if($asset->model->eol) { - if($months != $asset->model->eol) { + if($months != $asset->model->eol > 0) { $asset->eol_explicit = true; } else { $asset->eol_explicit = false; @@ -324,6 +325,9 @@ class AssetsController extends Controller } else { $asset->eol_explicit = true; } + } elseif (!$request->filled('asset_eol_date') && (($asset->model->eol) == 0)) { + $asset->asset_eol_date = null; + $asset->eol_explicit = false; } $asset->supplier_id = $request->input('supplier_id', null); $asset->expected_checkin = $request->input('expected_checkin', null); diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index bd234cb9a6..45ca5bab7c 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -112,7 +112,8 @@ class BulkAssetsController extends Controller public function update(Request $request) { $this->authorize('update', Asset::class); - $error_bag = []; + $has_errors = 0; + $error_array = array(); // Get the back url from the session and then destroy the session $bulk_back_url = route('hardware.index'); @@ -120,10 +121,9 @@ class BulkAssetsController extends Controller $bulk_back_url = $request->session()->pull('bulk_back_url'); } - - $custom_field_columns = CustomField::all()->pluck('db_column')->toArray(); + $custom_field_columns = CustomField::all()->pluck('db_column')->toArray(); - if(Session::exists('ids')) { + if (Session::exists('ids')) { $assets = Session::get('ids'); } elseif (! $request->filled('ids') || count($request->input('ids')) <= 0) { return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.update.no_assets_selected')); @@ -160,7 +160,6 @@ class BulkAssetsController extends Controller $this->conditionallyAddItem('purchase_date') ->conditionallyAddItem('expected_checkin') - ->conditionallyAddItem('model_id') ->conditionallyAddItem('order_number') ->conditionallyAddItem('requestable') ->conditionallyAddItem('status_id') @@ -187,6 +186,7 @@ class BulkAssetsController extends Controller $this->update_array['purchase_cost'] = $request->input('purchase_cost'); } + if ($request->filled('company_id')) { $this->update_array['company_id'] = $request->input('company_id'); if ($request->input('company_id') == 'clear') { @@ -208,61 +208,95 @@ class BulkAssetsController extends Controller } $changed = []; - $assetCollection = Asset::where('id' ,$assetId)->get(); + $asset = Asset::find($assetId); foreach ($this->update_array as $key => $value) { - if ($this->update_array[$key] != $assetCollection->toArray()[0][$key]) { - $changed[$key]['old'] = $assetCollection->toArray()[0][$key]; + if ($this->update_array[$key] != $asset->{$key}) { + $changed[$key]['old'] = $asset->{$key}; $changed[$key]['new'] = $this->update_array[$key]; } } - - $logAction = new Actionlog(); - $logAction->item_type = Asset::class; - $logAction->item_id = $assetId; - $logAction->created_at = date("Y-m-d H:i:s"); - $logAction->user_id = Auth::id(); - $logAction->log_meta = json_encode($changed); - $logAction->logaction('update'); - if($custom_fields_present) { - $asset = Asset::find($assetId); - $assetCustomFields = $asset->model()->first()->fieldset; - if($assetCustomFields && $assetCustomFields->fields) { - foreach ($assetCustomFields->fields as $field) { - if (array_key_exists($field->db_column, $this->update_array)) { - $asset->{$field->db_column} = $this->update_array[$field->db_column]; - $saved = $asset->save(); - if(!$saved) { - $error_bag[] = $asset->getErrors(); - } - continue; - } else { - $array = $this->update_array; - array_except($array, $field->db_column); - $asset->save($array); - } - if (!$asset->save()) { - $error_bag[] = $asset->getErrors(); - } - } - } - } else { - Asset::find($assetId)->update($this->update_array); - } - } - if(!empty($error_bag)) { - $errors = []; - //find the customfield name from the name of the messagebag items - foreach ($error_bag as $key => $bag) { - foreach($bag->keys() as $key => $value) { - CustomField::where('db_column', $value)->get()->map(function($item) use (&$errors) { - $errors[] = $item->name; - }); + if ($custom_fields_present) { + + $model = $asset->model()->first(); + + // Use the rules of the new model fieldsets if the model changed + if ($request->filled('model_id')) { + $this->update_array['model_id'] = $request->input('model_id'); + $model = \App\Models\AssetModel::find($request->input('model_id')); } - } - return redirect($bulk_back_url)->with('bulk_errors', array_unique($errors)); - } + + + // Make sure this model is valid + $assetCustomFields = ($model) ? $model->fieldset : null; + + if ($assetCustomFields && $assetCustomFields->fields) { + + foreach ($assetCustomFields->fields as $field) { + + if ((array_key_exists($field->db_column, $this->update_array)) && ($field->field_encrypted=='1')) { + $decrypted_old = Helper::gracefulDecrypt($field, $asset->{$field->db_column}); + + /* + * Check if the decrypted existing value is different from one we just submitted + * and if not, pull it out of the object since it shouldn't really be updating at all. + * If we don't do this, it will try to re-encrypt it, and the same value encrypted two + * different times will have different values, so it will *look* like it was updated + * but it wasn't. + */ + if ($decrypted_old != $this->update_array[$field->db_column]) { + $asset->{$field->db_column} = \Crypt::encrypt($this->update_array[$field->db_column]); + } else { + /* + * Remove the encrypted custom field from the update_array, since nothing changed + */ + unset($this->update_array[$field->db_column]); + unset($asset->{$field->db_column}); + } + + /* + * These custom fields aren't encrypted, just carry on as usual + */ + } else { + + + if ((array_key_exists($field->db_column, $this->update_array)) && ($asset->{$field->db_column} != $this->update_array[$field->db_column])) { + + // Check if this is an array, and if so, flatten it + if (is_array($this->update_array[$field->db_column])) { + $asset->{$field->db_column} = implode(', ', $this->update_array[$field->db_column]); + } else { + $asset->{$field->db_column} = $this->update_array[$field->db_column]; + } + } + } + + } // endforeach + } // end custom field check + } // end custom fields handler + + + + // Check if it passes validation, and then try to save + if (!$asset->update($this->update_array)) { + + // Build the error array + foreach ($asset->getErrors()->toArray() as $key => $message) { + for ($x = 0; $x < count($message); $x++) { + $error_array[$key][] = trans('general.asset') . ' ' . $asset->id . ': ' . $message[$x]; + $has_errors++; + } + } + + } // end if saved + + } // end asset foreach + + if ($has_errors > 0) { + return redirect($bulk_back_url)->with('bulk_asset_errors', $error_array); + } + return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.update.success')); } // no values given, nothing to update diff --git a/app/Http/Transformers/ActionlogsTransformer.php b/app/Http/Transformers/ActionlogsTransformer.php index d3af3bb753..1de9143329 100644 --- a/app/Http/Transformers/ActionlogsTransformer.php +++ b/app/Http/Transformers/ActionlogsTransformer.php @@ -3,6 +3,7 @@ namespace App\Http\Transformers; use App\Helpers\Helper; use App\Models\Actionlog; +use App\Models\Asset; use App\Models\CustomField; use App\Models\Setting; use App\Models\Company; @@ -12,6 +13,7 @@ use App\Models\AssetModel; use Illuminate\Database\Eloquent\Collection; use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Support\Facades\Crypt; +use Illuminate\Support\Facades\Gate; class ActionlogsTransformer { @@ -98,6 +100,13 @@ class ActionlogsTransformer \Log::debug('custom fields do not match'); $clean_meta[$fieldname]['old'] = "************"; $clean_meta[$fieldname]['new'] = "************"; + + // Display the changes if the user is an admin or superadmin + if (Gate::allows('admin')) { + $clean_meta[$fieldname]['old'] = ($enc_old) ? unserialize($enc_old): ''; + $clean_meta[$fieldname]['new'] = ($enc_new) ? unserialize($enc_new): ''; + } + } diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php index e1d98a5200..d38eac2419 100644 --- a/app/Http/Transformers/AssetsTransformer.php +++ b/app/Http/Transformers/AssetsTransformer.php @@ -7,6 +7,7 @@ use App\Models\Asset; use App\Models\Setting; use Illuminate\Support\Facades\Gate; use Illuminate\Database\Eloquent\Collection; +use Carbon\Carbon; use Auth; class AssetsTransformer @@ -38,7 +39,7 @@ class AssetsTransformer 'byod' => ($asset->byod ? true : false), 'model_number' => (($asset->model) && ($asset->model->model_number)) ? e($asset->model->model_number) : null, - 'eol' => (($asset->model) && ($asset->model->eol != '')) ? $asset->model->eol : null, + 'eol' => (($asset->asset_eol_date != '') && ($asset->purchase_date != '')) ? Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date).' months' : null, 'asset_eol_date' => ($asset->asset_eol_date != '') ? Helper::getFormattedDateObject($asset->asset_eol_date, 'date') : null, 'status_label' => ($asset->assetstatus) ? [ 'id' => (int) $asset->assetstatus->id, diff --git a/app/Importer/AssetImporter.php b/app/Importer/AssetImporter.php index 76eae0739a..5014efac12 100644 --- a/app/Importer/AssetImporter.php +++ b/app/Importer/AssetImporter.php @@ -5,6 +5,9 @@ namespace App\Importer; use App\Models\Asset; use App\Models\AssetModel; use App\Models\Statuslabel; +use App\Models\User; +use App\Events\CheckoutableCheckedIn; +use Illuminate\Support\Facades\Auth; use Carbon\Carbon; class AssetImporter extends ItemImporter @@ -142,6 +145,12 @@ class AssetImporter extends ItemImporter //-- user_id is a property of the abstract class Importer, which this class inherits from and it's setted by //-- the class that needs to use it (command importer or GUI importer inside the project). if (isset($target)) { + if (!is_null($asset->assigned_to)){ + if ($asset->assigned_to != $target->id){ + event(new CheckoutableCheckedIn($asset, User::find($asset->assigned_to), Auth::user(), $asset->notes, date('Y-m-d H:i:s'))); + } + } + $asset->fresh()->checkOut($target, $this->user_id, date('Y-m-d H:i:s'), null, $asset->notes, $asset->name); } diff --git a/app/Observers/AssetObserver.php b/app/Observers/AssetObserver.php index c15c54a568..f42b041fad 100644 --- a/app/Observers/AssetObserver.php +++ b/app/Observers/AssetObserver.php @@ -11,7 +11,7 @@ use Carbon\Carbon; class AssetObserver { /** - * Listen to the User created event. + * Listen to the Asset updating event. This fires automatically every time an existing asset is saved. * * @param Asset $asset * @return void @@ -137,14 +137,14 @@ class AssetObserver public function saving(Asset $asset) { // determine if calculated eol and then calculate it - this should only happen on a new asset - if (is_null($asset->asset_eol_date) && !is_null($asset->purchase_date) && !is_null($asset->model->eol)){ + if (is_null($asset->asset_eol_date) && !is_null($asset->purchase_date) && ($asset->model->eol > 0)){ $asset->asset_eol_date = $asset->purchase_date->addMonths($asset->model->eol)->format('Y-m-d'); $asset->eol_explicit = false; } // determine if explicit and set eol_explicit to true if (!is_null($asset->asset_eol_date) && !is_null($asset->purchase_date)) { - if($asset->model->eol) { + if($asset->model->eol > 0) { $months = Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date); if($months != $asset->model->eol) { $asset->eol_explicit = true; @@ -153,7 +153,7 @@ class AssetObserver } elseif (!is_null($asset->asset_eol_date) && is_null($asset->purchase_date)) { $asset->eol_explicit = true; } - if ((!is_null($asset->asset_eol_date)) && (!is_null($asset->purchase_date)) && (is_null($asset->model->eol))) { + if ((!is_null($asset->asset_eol_date)) && (!is_null($asset->purchase_date)) && (is_null($asset->model->eol) || ($asset->model->eol == 0))) { $asset->eol_explicit = true; } diff --git a/app/Presenters/AssetModelPresenter.php b/app/Presenters/AssetModelPresenter.php index e661b1ab80..85a0fa58ec 100644 --- a/app/Presenters/AssetModelPresenter.php +++ b/app/Presenters/AssetModelPresenter.php @@ -104,7 +104,7 @@ class AssetModelPresenter extends Presenter 'searchable' => false, 'sortable' => true, 'switchable' => true, - 'title' => trans('general.eol'), + 'title' => trans('admin/hardware/form.eol_rate'), 'visible' => true, ], [ diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.php index c570c568da..de7c2c7709 100644 --- a/app/Presenters/AssetPresenter.php +++ b/app/Presenters/AssetPresenter.php @@ -173,7 +173,7 @@ class AssetPresenter extends Presenter 'searchable' => false, 'sortable' => true, 'visible' => false, - 'title' => trans('general.eol'), + 'title' => trans('admin/hardware/form.eol_rate'), ], [ 'field' => 'asset_eol_date', diff --git a/database/factories/ActionlogFactory.php b/database/factories/ActionlogFactory.php index c25fdcc70a..1a4007888c 100644 --- a/database/factories/ActionlogFactory.php +++ b/database/factories/ActionlogFactory.php @@ -38,7 +38,7 @@ class ActionlogFactory extends Factory { return $this->state(function () { $target = User::inRandomOrder()->first(); - $asset = Asset::RTD()->inRandomOrder()->first(); + $asset = Asset::inRandomOrder()->RTD()->first(); $asset->update( [ diff --git a/database/factories/CustomFieldFactory.php b/database/factories/CustomFieldFactory.php index 2dfa07d61a..7cbc2210c9 100644 --- a/database/factories/CustomFieldFactory.php +++ b/database/factories/CustomFieldFactory.php @@ -26,6 +26,7 @@ class CustomFieldFactory extends Factory 'format' => '', 'element' => 'text', 'auto_add_to_fieldsets' => '0', + 'show_in_requestable_list' => '0', ]; } @@ -66,6 +67,7 @@ class CustomFieldFactory extends Factory return [ 'name' => 'CPU', 'help_text' => 'The speed of the processor on this device.', + 'show_in_requestable_list' => '1', ]; }); } @@ -79,4 +81,37 @@ class CustomFieldFactory extends Factory ]; }); } + + public function testEncrypted() + { + return $this->state(function () { + return [ + 'name' => 'Test Encrypted', + 'field_encrypted' => '1', + 'help_text' => 'This is a sample encrypted field.', + ]; + }); + } + + public function testCheckbox() + { + return $this->state(function () { + return [ + 'name' => 'Test Checkbox', + 'help_text' => 'This is a sample checkbox.', + 'field_values' => "One\nTwo\nThree", + 'element' => 'checkbox', + ]; + }); + } + + public function testRequired() + { + return $this->state(function () { + return [ + 'name' => 'Test Required', + 'help_text' => 'This is a sample required field.', + ]; + }); + } } diff --git a/database/seeders/CustomFieldSeeder.php b/database/seeders/CustomFieldSeeder.php index 551e05f40f..5d8d44e4b8 100644 --- a/database/seeders/CustomFieldSeeder.php +++ b/database/seeders/CustomFieldSeeder.php @@ -33,6 +33,10 @@ class CustomFieldSeeder extends Seeder CustomField::factory()->count(1)->ram()->create(); CustomField::factory()->count(1)->cpu()->create(); CustomField::factory()->count(1)->macAddress()->create(); + CustomField::factory()->count(1)->testEncrypted()->create(); + CustomField::factory()->count(1)->testCheckbox()->create(); + CustomField::factory()->count(1)->testRequired()->create(); + DB::table('custom_field_custom_fieldset')->insert([ [ @@ -66,6 +70,40 @@ class CustomFieldSeeder extends Seeder 'required' => 0, ], + [ + 'custom_field_id' => '6', + 'custom_fieldset_id' => '2', + 'order' => 0, + 'required' => 0, + ], + + [ + 'custom_field_id' => '6', + 'custom_fieldset_id' => '1', + 'order' => 0, + 'required' => 0, + ], + + [ + 'custom_field_id' => '7', + 'custom_fieldset_id' => '2', + 'order' => 0, + 'required' => 0, + ], + [ + 'custom_field_id' => '7', + 'custom_fieldset_id' => '1', + 'order' => 0, + 'required' => 0, + ], + + [ + 'custom_field_id' => '8', + 'custom_fieldset_id' => '1', + 'order' => 0, + 'required' => 1, + ], + ]); } } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 1429604139..5e26a9a257 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -38,12 +38,13 @@ class DatabaseSeeder extends Seeder $this->call(DepreciationSeeder::class); $this->call(StatuslabelSeeder::class); $this->call(AccessorySeeder::class); + $this->call(CustomFieldSeeder::class); $this->call(AssetSeeder::class); $this->call(LicenseSeeder::class); $this->call(ComponentSeeder::class); $this->call(ConsumableSeeder::class); $this->call(ActionlogSeeder::class); - $this->call(CustomFieldSeeder::class); + Artisan::call('snipeit:sync-asset-locations', ['--output' => 'all']); $output = Artisan::output(); diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index e1a5cc0e7a..fba828839f 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -368,7 +368,7 @@ return [ 'consumables_count' => 'Consumables Count', 'components_count' => 'Components Count', 'licenses_count' => 'Licenses Count', - 'notification_error' => 'Error:', + 'notification_error' => 'Error', 'notification_error_hint' => 'Please check the form below for errors', 'notification_bulk_error_hint' => 'The following fields had validation errors and were not edited:', 'notification_success' => 'Success', diff --git a/resources/views/custom_fields/index.blade.php b/resources/views/custom_fields/index.blade.php index 7b0c4965d8..08f2fb3845 100644 --- a/resources/views/custom_fields/index.blade.php +++ b/resources/views/custom_fields/index.blade.php @@ -151,6 +151,7 @@ + {{ trans('admin/custom_fields/general.unique') }} {{ trans('admin/custom_fields/general.field_element_short') }} {{ trans('admin/custom_fields/general.fieldsets') }} {{ trans('button.actions') }} @@ -176,6 +177,7 @@ {!! ($field->display_in_user_view=='1' ? '' : '') !!} {!! ($field->show_in_email=='1') ? '' : '' !!} {!! ($field->show_in_requestable_list=='1') ? '' : '' !!} + {!! ($field->is_unique=='1') ? '' : '' !!} {{ $field->element }} @foreach($field->fieldset as $fieldset) diff --git a/resources/views/hardware/bulk.blade.php b/resources/views/hardware/bulk.blade.php index e26b957057..a7e52dfa56 100755 --- a/resources/views/hardware/bulk.blade.php +++ b/resources/views/hardware/bulk.blade.php @@ -62,7 +62,7 @@
diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 7609feb35f..5a043ffc40 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -631,7 +631,7 @@ @endif - @if (($asset->model) && ($asset->model->eol)) + @if (($asset->asset_eol_date) && ($asset->purchase_date))
@@ -639,7 +639,7 @@
- {{ $asset->model->eol }} + {{ Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date) }} {{ trans('admin/hardware/form.months') }}
@@ -650,6 +650,9 @@
{{ trans('admin/hardware/form.eol_date') }} + @if ($asset->purchase_date) + {!! $asset->asset_eol_date < date("Y-m-d") ? '' : '' !!} + @endif
diff --git a/resources/views/models/custom_fields_form_bulk_edit.blade.php b/resources/views/models/custom_fields_form_bulk_edit.blade.php index e974c3f6eb..f30c60d331 100644 --- a/resources/views/models/custom_fields_form_bulk_edit.blade.php +++ b/resources/views/models/custom_fields_form_bulk_edit.blade.php @@ -37,21 +37,20 @@ @elseif ($field->element=='checkbox') @foreach ($field->formatFieldValuesAsArray() as $key => $value) -
- -
+ + @endforeach @elseif ($field->element=='radio') @foreach ($field->formatFieldValuesAsArray() as $value) -
-
+ @endforeach @endif diff --git a/resources/views/notifications.blade.php b/resources/views/notifications.blade.php index eca773e219..9dbb547515 100755 --- a/resources/views/notifications.blade.php +++ b/resources/views/notifications.blade.php @@ -115,17 +115,19 @@ @endif -@if ($messages = Session::get('bulk_errors')) +@if ($messages = Session::get('bulk_asset_errors'))
{{ trans('general.notification_error') }}: {{ trans('general.notification_bulk_error_hint') }} - @foreach($messages as $message) + @foreach($messages as $key => $message) + @for ($x = 0; $x < count($message); $x++)
    -
  • {{ $message }}
  • -
+
  • {{ $message[$x] }}
  • + + @endfor @endforeach
    diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 78f3d152d2..0122096f80 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -530,15 +530,37 @@ function changeLogFormatter(value) { + var result = ''; + var pretty_index = ''; + for (var index in value) { - result += index + ': ' + value[index].old + ' ' + value[index].new + '
    ' + + + // Check if it's a custom field + if (index.startsWith('_snipeit_')) { + pretty_index = index.replace("_snipeit_", "Custom:_"); + } else { + pretty_index = index; + } + + extra_pretty_index = prettyLog(pretty_index); + + result += extra_pretty_index + ': ' + value[index].old + ' ' + value[index].new + '
    ' } return result; } + function prettyLog(str) { + let frags = str.split('_'); + for (let i = 0; i < frags.length; i++) { + frags[i] = frags[i].charAt(0).toUpperCase() + frags[i].slice(1); + } + return frags.join(' '); + } + // Create a linked phone number in the table list function phoneFormatter(value) { diff --git a/resources/views/partials/forms/edit/eol_date.blade.php b/resources/views/partials/forms/edit/eol_date.blade.php index 88055cfc0e..fb461cf44e 100644 --- a/resources/views/partials/forms/edit/eol_date.blade.php +++ b/resources/views/partials/forms/edit/eol_date.blade.php @@ -1,9 +1,9 @@ - +
    - +
    {!! $errors->first('asset_eol_date', '') !!}