A free open source IT asset/license management system
Added slightly friendlier error handling for assets without models
snipe88fb1370f0e2
diff --git a/app/Models/Asset.php b/app/Models/Asset.phpindex d885b5819c..817e773d20 100644--- a/app/Models/Asset.php+++ b/app/Models/Asset.php@@ -604,20 +604,26 @@ class Asset extends Depreciablepublic function requireAcceptance(){- return $this->model->category->require_acceptance;+ if (($this->model) && ($this->model->category)) {+ return $this->model->category->require_acceptance;+ }+}public function getEula(){$Parsedown = new \Parsedown();-- if ($this->model->category->eula_text) {- return $Parsedown->text(e($this->model->category->eula_text));- } elseif ($this->model->category->use_default_eula == '1') {- return $Parsedown->text(e(Setting::getSettings()->default_eula_text));- } else {- return false;++ if (($this->model) && ($this->model->category)) {+ if ($this->model->category->eula_text) {+ return $Parsedown->text(e($this->model->category->eula_text));+ } elseif ($this->model->category->use_default_eula == '1') {+ return $Parsedown->text(e(Setting::getSettings()->default_eula_text));+ } else {+ return false;+ }}+ return false;}/**diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.phpindex eeb5a8704d..88d9d26dba 100644--- a/app/Presenters/AssetPresenter.php+++ b/app/Presenters/AssetPresenter.php@@ -395,7 +395,7 @@ class AssetPresenter extends Presenterpublic function eol_date(){- if (( $this->purchase_date ) && ( $this->model ) && ($this->model->model->eol) ) {+ if (( $this->purchase_date ) && ( $this->model->model ) && ($this->model->model->eol) ) {$date = date_create($this->purchase_date);date_add($date, date_interval_create_from_date_string($this->model->model->eol . ' months'));return date_format($date, 'Y-m-d');diff --git a/resources/views/hardware/checkin.blade.php b/resources/views/hardware/checkin.blade.phpindex 9d2a790c44..cb84016e8d 100755--- a/resources/views/hardware/checkin.blade.php+++ b/resources/views/hardware/checkin.blade.php@@ -35,15 +35,24 @@action="{{ route('checkin/hardware', $asset->id) }}" autocomplete="off">@endif{{csrf_field()}}- @if ($asset->model->name)- <!-- AssetModel name -->++ <!-- AssetModel name --><div class="form-group">{{ Form::label('name', trans('admin/hardware/form.model'), array('class' => 'col-md-3 control-label')) }}<div class="col-md-8">- <p class="form-control-static">{{ $asset->model->name }}</p>+ <p class="form-control-static">+ @if (($asset->model) && ($asset->model->name))+ {{ $asset->model->name }}++ @else+ <span class="text-danger text-bold">+ <i class="fa fa-exclamation-triangle"></i>This asset's model is invalid!+ The asset <a href="{{ route('hardware.edit', $asset->id) }}">should be edited</a> to correct this before attempting to check it in or out.</span>+ @endif+ </p></div></div>- @endif+<!-- Asset Name --><div class="form-group {{ $errors->has('name') ? 'error' : '' }}">diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.phpindex 4a5203c36d..9f6980271a 100755--- a/resources/views/hardware/checkout.blade.php+++ b/resources/views/hardware/checkout.blade.php@@ -26,15 +26,22 @@</div><div class="box-body">{{csrf_field()}}- @if ($asset->model->name)- <!-- Model name -->- <div class="form-group {{ $errors->has('name') ? 'error' : '' }}">+ <!-- AssetModel name -->+ <div class="form-group">{{ Form::label('name', trans('admin/hardware/form.model'), array('class' => 'col-md-3 control-label')) }}- <div class="col-md-8">- <p class="form-control-static">{{ $asset->model->name }}</p>- </div>+ <div class="col-md-8">+ <p class="form-control-static">+ @if (($asset->model) && ($asset->model->name))+ {{ $asset->model->name }}++ @else+ <span class="text-danger text-bold">+ <i class="fa fa-exclamation-triangle"></i>This asset's model is invalid!+ The asset <a href="{{ route('hardware.edit', $asset->id) }}">should be edited</a> to correct this before attempting to check it in or out.</span>+ @endif+ </p>+ </div></div>- @endif<!-- Asset Name --><div class="form-group {{ $errors->has('name') ? 'error' : '' }}">