mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
c5d7a1fdd6
|
@ -530,6 +530,8 @@ class AssetsController extends Controller
|
||||||
return redirect()->to('hardware')->with('error', trans('admin/hardware/message.does_not_exist'));
|
return redirect()->to('hardware')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||||
} elseif (!Company::isCurrentUserHasAccess($asset)) {
|
} elseif (!Company::isCurrentUserHasAccess($asset)) {
|
||||||
return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions'));
|
return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions'));
|
||||||
|
} elseif (!$asset->availableForCheckout()) {
|
||||||
|
return redirect()->to('hardware')->with('error', trans('admin/hardware/message.checkout.not_available'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::find(e(Input::get('assigned_to')));
|
$user = User::find(e(Input::get('assigned_to')));
|
||||||
|
@ -1725,19 +1727,17 @@ class AssetsController extends Controller
|
||||||
$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>';
|
$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>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($asset->assetstatus) {
|
if (($asset->availableForCheckout()))
|
||||||
if (($asset->assetstatus->deployable != 0) && ($asset->deleted_at=='')) {
|
{
|
||||||
if (($asset->assigned_to !='') && ($asset->assigned_to > 0)) {
|
|
||||||
if (Gate::allows('assets.checkin')) {
|
|
||||||
$inout = '<a href="' . route('checkin/hardware',
|
|
||||||
$asset->id) . '" class="btn btn-primary btn-sm" title="Checkin this asset" data-toggle="tooltip">' . trans('general.checkin') . '</a>';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (Gate::allows('assets.checkout')) {
|
if (Gate::allows('assets.checkout')) {
|
||||||
$inout = '<a href="' . route('checkout/hardware',
|
$inout = '<a href="' . route('checkout/hardware',
|
||||||
$asset->id) . '" class="btn btn-info btn-sm" title="Checkout this asset to a user" data-toggle="tooltip">' . trans('general.checkout') . '</a>';
|
$asset->id) . '" class="btn btn-info btn-sm" title="Checkout this asset to a user" data-toggle="tooltip">' . trans('general.checkout') . '</a>';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} else {
|
||||||
|
if (Gate::allows('assets.checkin')) {
|
||||||
|
$inout = '<a href="' . route('checkin/hardware',
|
||||||
|
$asset->id) . '" class="btn btn-primary btn-sm" title="Checkin this asset" data-toggle="tooltip">' . trans('general.checkin') . '</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use App\Models\Category as Category;
|
use App\Models\Category as Category;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use Auth;
|
use Auth;
|
||||||
use DB;
|
use DB;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Input;
|
use Input;
|
||||||
use Lang;
|
use Lang;
|
||||||
use Redirect;
|
use Redirect;
|
||||||
|
@ -344,13 +345,13 @@ class CategoriesController extends Controller
|
||||||
$actions = '<a href="'.route('restore/hardware', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a>';
|
$actions = '<a href="'.route('restore/hardware', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($asset->assetstatus) {
|
if ($asset->availableForCheckout()) {
|
||||||
if ($asset->assetstatus->deployable != 0) {
|
if (Gate::allows('assets.checkout')) {
|
||||||
if (($asset->assigned_to !='') && ($asset->assigned_to > 0)) {
|
|
||||||
$inout = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.trans('general.checkin').'</a>';
|
|
||||||
} else {
|
|
||||||
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.trans('general.checkout').'</a>';
|
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.trans('general.checkout').'</a>';
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (Gate::allows('assets.checkin')) {
|
||||||
|
$inout = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.trans('general.checkin').'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,15 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
|
use App\Models\Manufacturer;
|
||||||
|
use App\Models\Setting;
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Input;
|
use Input;
|
||||||
use Lang;
|
use Lang;
|
||||||
use App\Models\Manufacturer;
|
|
||||||
use Redirect;
|
use Redirect;
|
||||||
use App\Models\Setting;
|
|
||||||
use Str;
|
use Str;
|
||||||
use View;
|
use View;
|
||||||
use Auth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This controller handles all actions related to Manufacturers for
|
* This controller handles all actions related to Manufacturers for
|
||||||
|
@ -293,13 +294,13 @@ class ManufacturersController extends Controller
|
||||||
$actions = '<a href="'.route('restore/hardware', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a>';
|
$actions = '<a href="'.route('restore/hardware', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($asset->assetstatus) {
|
if ($asset->availableForCheckout()) {
|
||||||
if ($asset->assetstatus->deployable != 0) {
|
if (Gate::allows('assets.checkout')) {
|
||||||
if (($asset->assigned_to !='') && ($asset->assigned_to > 0)) {
|
|
||||||
$inout = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.trans('general.checkin').'</a>';
|
|
||||||
} else {
|
|
||||||
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.trans('general.checkout').'</a>';
|
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.trans('general.checkout').'</a>';
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (Gate::allows('assets.checkin')) {
|
||||||
|
$inout = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.trans('general.checkin').'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ class AssetRequest extends Request
|
||||||
'supplier_id' => 'integer',
|
'supplier_id' => 'integer',
|
||||||
'status' => 'integer',
|
'status' => 'integer',
|
||||||
'asset_tag' => 'required',
|
'asset_tag' => 'required',
|
||||||
|
'purchase_cost' => 'numeric',
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ class Accessory extends Model
|
||||||
'category_id' => 'required|integer',
|
'category_id' => 'required|integer',
|
||||||
'company_id' => 'integer',
|
'company_id' => 'integer',
|
||||||
'min_amt' => 'integer|min:1',
|
'min_amt' => 'integer|min:1',
|
||||||
|
'purchase_cost' => 'numeric',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ class Asset extends Depreciable
|
||||||
'supplier_id' => 'integer',
|
'supplier_id' => 'integer',
|
||||||
'asset_tag' => 'required|min:1|max:255|unique_undeleted',
|
'asset_tag' => 'required|min:1|max:255|unique_undeleted',
|
||||||
'status' => 'integer',
|
'status' => 'integer',
|
||||||
|
'purchase_cost' => 'numeric',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,16 +73,26 @@ class Asset extends Depreciable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function availableForCheckout()
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
empty($this->assigned_to) &&
|
||||||
|
$this->assetstatus->deployable == 1 &&
|
||||||
|
empty($this->deleted_at)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checkout asset
|
* Checkout asset
|
||||||
*/
|
*/
|
||||||
public function checkOutToUser($user, $admin, $checkout_at = null, $expected_checkin = null, $note = null, $name = null)
|
public function checkOutToUser($user, $admin, $checkout_at = null, $expected_checkin = null, $note = null, $name = null)
|
||||||
{
|
{
|
||||||
|
if (!$user) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($expected_checkin) {
|
if ($expected_checkin) {
|
||||||
$this->expected_checkin = $expected_checkin ;
|
$this->expected_checkin = $expected_checkin;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->last_checkout = $checkout_at;
|
$this->last_checkout = $checkout_at;
|
||||||
|
@ -95,9 +106,7 @@ class Asset extends Depreciable
|
||||||
$this->accepted="pending";
|
$this->accepted="pending";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$user) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->save()) {
|
if ($this->save()) {
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ class Component extends Model
|
||||||
'category_id' => 'required|integer',
|
'category_id' => 'required|integer',
|
||||||
'company_id' => 'integer',
|
'company_id' => 'integer',
|
||||||
'purchase_date' => 'date',
|
'purchase_date' => 'date',
|
||||||
|
'purchase_cost' => 'numeric',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,6 +29,7 @@ class Consumable extends Model
|
||||||
'category_id' => 'required|integer',
|
'category_id' => 'required|integer',
|
||||||
'company_id' => 'integer',
|
'company_id' => 'integer',
|
||||||
'min_amt' => 'integer|min:1',
|
'min_amt' => 'integer|min:1',
|
||||||
|
'purchase_cost' => 'numeric',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
return array (
|
return array (
|
||||||
'app_version' => '3.3.0-beta',
|
'app_version' => 'v3.3.0',
|
||||||
'hash_version' => '3.3.0-beta-19-g7a0843e',
|
'hash_version' => 'v3.3.0-3-g7ef4f23',
|
||||||
);
|
);
|
||||||
|
|
|
@ -52,7 +52,8 @@ return array(
|
||||||
'checkout' => array(
|
'checkout' => array(
|
||||||
'error' => 'Asset was not checked out, please try again',
|
'error' => 'Asset was not checked out, please try again',
|
||||||
'success' => 'Asset checked out successfully.',
|
'success' => 'Asset checked out successfully.',
|
||||||
'user_does_not_exist' => 'That user is invalid. Please try again.'
|
'user_does_not_exist' => 'That user is invalid. Please try again.',
|
||||||
|
'not_available' => 'That asset is not available for checkout!'
|
||||||
),
|
),
|
||||||
|
|
||||||
'checkin' => array(
|
'checkin' => array(
|
||||||
|
|
Loading…
Reference in a new issue