Skip to content

Commit c5d7a1f

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 8232cef + 29c4189 commit c5d7a1f

File tree

10 files changed

+60
-44
lines changed

10 files changed

+60
-44
lines changed

app/Http/Controllers/AssetsController.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ public function postCheckout(AssetCheckoutRequest $request, $assetId)
530530
return redirect()->to('hardware')->with('error', trans('admin/hardware/message.does_not_exist'));
531531
} elseif (!Company::isCurrentUserHasAccess($asset)) {
532532
return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions'));
533+
} elseif (!$asset->availableForCheckout()) {
534+
return redirect()->to('hardware')->with('error', trans('admin/hardware/message.checkout.not_available'));
533535
}
534536

535537
$user = User::find(e(Input::get('assigned_to')));
@@ -1725,19 +1727,17 @@ public function getDatatable($status = null)
17251727
$actions = '<a href="'.route('restore/hardware', $asset->id).'" title="Restore asset" data-toggle="tooltip" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a>';
17261728
}
17271729

1728-
if ($asset->assetstatus) {
1729-
if (($asset->assetstatus->deployable != 0) && ($asset->deleted_at=='')) {
1730-
if (($asset->assigned_to !='') && ($asset->assigned_to > 0)) {
1731-
if (Gate::allows('assets.checkin')) {
1732-
$inout = '<a href="' . route('checkin/hardware',
1733-
$asset->id) . '" class="btn btn-primary btn-sm" title="Checkin this asset" data-toggle="tooltip">' . trans('general.checkin') . '</a>';
1734-
}
1735-
} else {
1736-
if (Gate::allows('assets.checkout')) {
1737-
$inout = '<a href="' . route('checkout/hardware',
1738-
$asset->id) . '" class="btn btn-info btn-sm" title="Checkout this asset to a user" data-toggle="tooltip">' . trans('general.checkout') . '</a>';
1739-
}
1740-
}
1730+
if (($asset->availableForCheckout()))
1731+
{
1732+
if (Gate::allows('assets.checkout')) {
1733+
$inout = '<a href="' . route('checkout/hardware',
1734+
$asset->id) . '" class="btn btn-info btn-sm" title="Checkout this asset to a user" data-toggle="tooltip">' . trans('general.checkout') . '</a>';
1735+
}
1736+
1737+
} else {
1738+
if (Gate::allows('assets.checkin')) {
1739+
$inout = '<a href="' . route('checkin/hardware',
1740+
$asset->id) . '" class="btn btn-primary btn-sm" title="Checkin this asset" data-toggle="tooltip">' . trans('general.checkin') . '</a>';
17411741
}
17421742
}
17431743

app/Http/Controllers/CategoriesController.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
22
namespace App\Http\Controllers;
33

4-
use Illuminate\Http\Request;
54
use App\Helpers\Helper;
65
use App\Models\Category as Category;
76
use App\Models\Company;
87
use App\Models\Setting;
98
use Auth;
109
use DB;
10+
use Illuminate\Http\Request;
11+
use Illuminate\Support\Facades\Gate;
1112
use Input;
1213
use Lang;
1314
use Redirect;
@@ -344,13 +345,13 @@ public function getDataViewAssets($categoryID)
344345
$actions = '<a href="'.route('restore/hardware', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a>';
345346
}
346347

347-
if ($asset->assetstatus) {
348-
if ($asset->assetstatus->deployable != 0) {
349-
if (($asset->assigned_to !='') && ($asset->assigned_to > 0)) {
350-
$inout = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.trans('general.checkin').'</a>';
351-
} else {
352-
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.trans('general.checkout').'</a>';
353-
}
348+
if ($asset->availableForCheckout()) {
349+
if (Gate::allows('assets.checkout')) {
350+
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.trans('general.checkout').'</a>';
351+
}
352+
} else {
353+
if (Gate::allows('assets.checkin')) {
354+
$inout = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.trans('general.checkin').'</a>';
354355
}
355356
}
356357

app/Http/Controllers/ManufacturersController.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
namespace App\Http\Controllers;
33

44
use App\Models\Company;
5+
use App\Models\Manufacturer;
6+
use App\Models\Setting;
7+
use Auth;
8+
use Illuminate\Support\Facades\Gate;
59
use Input;
610
use Lang;
7-
use App\Models\Manufacturer;
811
use Redirect;
9-
use App\Models\Setting;
1012
use Str;
1113
use View;
12-
use Auth;
1314

1415
/**
1516
* This controller handles all actions related to Manufacturers for
@@ -293,13 +294,13 @@ public function getDataView($manufacturerId)
293294
$actions = '<a href="'.route('restore/hardware', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a>';
294295
}
295296

296-
if ($asset->assetstatus) {
297-
if ($asset->assetstatus->deployable != 0) {
298-
if (($asset->assigned_to !='') && ($asset->assigned_to > 0)) {
299-
$inout = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.trans('general.checkin').'</a>';
300-
} else {
301-
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.trans('general.checkout').'</a>';
302-
}
297+
if ($asset->availableForCheckout()) {
298+
if (Gate::allows('assets.checkout')) {
299+
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.trans('general.checkout').'</a>';
300+
}
301+
} else {
302+
if (Gate::allows('assets.checkin')) {
303+
$inout = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.trans('general.checkin').'</a>';
303304
}
304305
}
305306

app/Http/Requests/AssetRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function rules()
3737
'supplier_id' => 'integer',
3838
'status' => 'integer',
3939
'asset_tag' => 'required',
40+
'purchase_cost' => 'numeric',
4041

4142
];
4243

app/Models/Accessory.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ class Accessory extends Model
2222
* Accessory validation rules
2323
*/
2424
public $rules = array(
25-
'name' => 'required|min:3|max:255',
26-
'qty' => 'required|integer|min:1',
27-
'category_id' => 'required|integer',
28-
'company_id' => 'integer',
29-
'min_amt' => 'integer|min:1',
25+
'name' => 'required|min:3|max:255',
26+
'qty' => 'required|integer|min:1',
27+
'category_id' => 'required|integer',
28+
'company_id' => 'integer',
29+
'min_amt' => 'integer|min:1',
30+
'purchase_cost' => 'numeric',
3031
);
3132

3233

app/Models/Asset.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class Asset extends Depreciable
5555
'supplier_id' => 'integer',
5656
'asset_tag' => 'required|min:1|max:255|unique_undeleted',
5757
'status' => 'integer',
58+
'purchase_cost' => 'numeric',
5859
];
5960

6061

@@ -72,16 +73,26 @@ public function company()
7273
}
7374

7475

75-
76+
public function availableForCheckout()
77+
{
78+
return (
79+
empty($this->assigned_to) &&
80+
$this->assetstatus->deployable == 1 &&
81+
empty($this->deleted_at)
82+
);
83+
}
7684

7785
/**
7886
* Checkout asset
7987
*/
8088
public function checkOutToUser($user, $admin, $checkout_at = null, $expected_checkin = null, $note = null, $name = null)
8189
{
90+
if (!$user) {
91+
return false;
92+
}
8293

8394
if ($expected_checkin) {
84-
$this->expected_checkin = $expected_checkin ;
95+
$this->expected_checkin = $expected_checkin;
8596
}
8697

8798
$this->last_checkout = $checkout_at;
@@ -95,9 +106,7 @@ public function checkOutToUser($user, $admin, $checkout_at = null, $expected_che
95106
$this->accepted="pending";
96107
}
97108

98-
if (!$user) {
99-
return false;
100-
}
109+
101110

102111
if ($this->save()) {
103112

app/Models/Component.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Component extends Model
3434
'category_id' => 'required|integer',
3535
'company_id' => 'integer',
3636
'purchase_date' => 'date',
37+
'purchase_cost' => 'numeric',
3738
);
3839

3940
/**

app/Models/Consumable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Consumable extends Model
2929
'category_id' => 'required|integer',
3030
'company_id' => 'integer',
3131
'min_amt' => 'integer|min:1',
32+
'purchase_cost' => 'numeric',
3233
);
3334

3435
/**

config/version.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22
return array (
3-
'app_version' => '3.3.0-beta',
4-
'hash_version' => '3.3.0-beta-19-g7a0843e',
3+
'app_version' => 'v3.3.0',
4+
'hash_version' => 'v3.3.0-3-g7ef4f23',
55
);

resources/lang/en/admin/hardware/message.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
'checkout' => array(
5353
'error' => 'Asset was not checked out, please try again',
5454
'success' => 'Asset checked out successfully.',
55-
'user_does_not_exist' => 'That user is invalid. Please try again.'
55+
'user_does_not_exist' => 'That user is invalid. Please try again.',
56+
'not_available' => 'That asset is not available for checkout!'
5657
),
5758

5859
'checkin' => array(

0 commit comments

Comments
 (0)