Skip to content

Commit 185629b

Browse files
authored
Merge pull request #17338 from grokability/small-depreciation-tweaks
Fixed #1909 - Small depreciation tweaks
2 parents 526a7dd + 30ebea4 commit 185629b

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

app/Http/Transformers/DepreciationsTransformer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ public function transformDepreciation(Depreciation $depreciation)
2626
$array = [
2727
'id' => (int) $depreciation->id,
2828
'name' => e($depreciation->name),
29-
'months' => $depreciation->months.' '.trans('general.months'),
29+
'months' => trans_choice('general.months_plural', $depreciation->months),
3030
'depreciation_min' => $depreciation->depreciation_type === 'percent' ? $depreciation->depreciation_min.'%' : $depreciation->depreciation_min,
31-
'assets_count' => $depreciation->assets_count,
32-
'models_count' => $depreciation->models_count,
33-
'licenses_count' => $depreciation->licenses_count,
31+
'assets_count' => ($depreciation->assets_count > 0) ? (int) $depreciation->assets_count : 0,
32+
'models_count' => ($depreciation->models_count > 0) ? (int) $depreciation->models_count : 0,
33+
'licenses_count' => ($depreciation->licenses_count > 0) ? (int) $depreciation->licenses_count : 0,
3434
'created_by' => ($depreciation->adminuser) ? [
3535
'id' => (int) $depreciation->adminuser->id,
3636
'name'=> e($depreciation->adminuser->present()->fullName()),

app/Models/Depreciation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Depreciation extends SnipeModel
1616
// Declare the rules for the form validation
1717
protected $rules = [
1818
'name' => 'required|min:3|max:255|unique:depreciations,name',
19-
'months' => 'required|max:3600|integer|gt:0',
19+
'months' => 'required|max:3600|integer',
2020
];
2121

2222
/**

resources/lang/en-US/general.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,5 +659,12 @@
659659
'confirm_delete' => 'Are you sure you want to delete this file?',
660660
],
661661

662+
'depreciation_options' => [
663+
'amount' => 'Amount',
664+
'percent' => 'Percentage',
665+
],
666+
667+
'months_plural' => '1 month|:count months',
668+
662669

663670
];

resources/views/depreciations/edit.blade.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
<label for="months" class="col-md-3 control-label">
1616
{{ trans('admin/depreciations/general.number_of_months') }}
1717
</label>
18-
<div class="col-md-7 col-sm-12">
19-
<div class="col-md-7" style="padding-left:0px">
20-
<input class="form-control" type="number" min="0" max="3600" name="months" id="months" value="{{ old('months', $item->months) }}" style="width: 80px;"{!! (\App\Helpers\Helper::checkIfRequired($item, 'months')) ? ' required' : '' !!} />
21-
{!! $errors->first('months', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
22-
</div>
18+
<div class="col-md-9 col-sm-12">
19+
<input class="form-control" type="number" min="0" max="3600" name="months" id="months" value="{{ old('months', $item->months) }}" style="width: 90px;"{!! (\App\Helpers\Helper::checkIfRequired($item, 'months')) ? ' required' : '' !!} />
20+
{!! $errors->first('months', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
2321
</div>
2422
</div>
2523

@@ -28,13 +26,14 @@
2826
<label for="depreciation_min" class="col-md-3 control-label">
2927
{{ trans('admin/depreciations/general.depreciation_min') }}
3028
</label>
31-
<div class="col-md-2" style="display: flex;">
32-
<input class="form-control" name="depreciation_min" id="depreciation_min" required type="number" value="{{ old('depreciation_min', $item->depreciation_min) }}" style="width: 80px; margin-right: 15px; display: inline-block;" />
29+
<div class="col-md-9" style="display: flex;">
30+
<input class="form-control" name="depreciation_min" id="depreciation_min" required type="number" value="{{ old('depreciation_min', $item->depreciation_min) }}" style="width: 90px; margin-right: 15px; display: inline-block;" />
3331
<select class="form-control select2" name="depreciation_type" id="depreciation_type" data-minimum-results-for-search="Infinity" style="width: 150px; display: inline-block;">
34-
<option value="amount" {{ old('depreciation_type', $item->depreciation_type) == 'amount' ? 'selected' : '' }}>Amount</option>
35-
<option value="percent" {{ old('depreciation_type', $item->depreciation_type) == 'percent' ? 'selected' : '' }}>Percentage</option>
32+
<option value="amount" {{ old('depreciation_type', $item->depreciation_type) == 'amount' ? 'selected' : '' }}>{{ trans('general.depreciation_options.amount') }}</option>
33+
<option value="percent" {{ old('depreciation_type', $item->depreciation_type) == 'percent' ? 'selected' : '' }}>{{ trans('general.depreciation_options.percent') }}</option>
3634
</select>
35+
{!! $errors->first('depreciation_min', '<span class="col-md-7 col-md-offset-3 alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
3736
</div>
38-
{!! $errors->first('depreciation_min', '<span class="col-md-7 col-md-offset-3 alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
37+
3938
</div>
4039
@stop

resources/views/hardware/view.blade.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -903,9 +903,7 @@ class="form-inline"
903903
</strong>
904904
</div>
905905
<div class="col-md-9">
906-
{{ $asset->warranty_months }}
907-
{{ trans('admin/hardware/form.months') }}
908-
906+
{{ trans_choice('general.months_plural', $asset->warranty_months) }}
909907
@if (($asset->model) && ($asset->model->manufacturer) && ($asset->model->manufacturer->warranty_lookup_url!=''))
910908
<a href="{{ $asset->present()->dynamicUrl($asset->model->manufacturer->warranty_lookup_url) }}" target="_blank">
911909
<x-icon type="external-link" />
@@ -947,8 +945,7 @@ class="form-inline"
947945
</div>
948946
<div class="col-md-9">
949947
{{ $asset->depreciation->name }}
950-
({{ $asset->depreciation->months }}
951-
{{ trans('admin/hardware/form.months') }})
948+
({{ trans_choice('general.months_plural', $asset->depreciation->months) }})
952949
</div>
953950
</div>
954951
<div class="row">

0 commit comments

Comments
 (0)