mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 13:57:41 -08:00
Added slightly friendlier error handling for assets without models
This scenario should never happen, barring someone manually editing their data, but better to handle that scenario in a more user-friendly way.
This commit is contained in:
parent
943cf40247
commit
88fb1370f0
|
@ -604,20 +604,26 @@ class Asset extends Depreciable
|
|||
|
||||
public 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -395,7 +395,7 @@ class AssetPresenter extends Presenter
|
|||
public 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');
|
||||
|
|
|
@ -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' : '' }}">
|
||||
|
|
|
@ -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' : '' }}">
|
||||
|
|
Loading…
Reference in a new issue