From 2d8269ddcdf09cc066db6a4abfaf4b7d84667108 Mon Sep 17 00:00:00 2001 From: Daniel Meltzer Date: Thu, 15 Sep 2016 21:58:27 -0500 Subject: [PATCH] Checkout Improvements, and initial support for requesting an asset model (#2573) * Create a new action_log table to replace asset_log. Use Polymorphism to generalize class and targets. Port everything I can find to use it. Add a migration to port the asset_logs table to action_logs. * Initial work on requestable asset models * Backend work for polymorphic requests table to store checkout requests. * Add missing files * Add a record to the db when requesting items. Build up a testing route for interfacing with this. * Users can now toggle requests of items on the request page. Reformat page to use the same tab layout we use elsewhere * Polymorphic request function. Implement requesting of asset models. Need to port mail/slack to notifications still. * Implement requesting of asset models. Build up emails and notifications to support it. Allow specifying a quantity of model to request. * Add view to show currently requested assets. Needs some work and cleanup, but it isn't accessible from anywhere yet. --- .../Controllers/AssetModelsController.php | 23 +- app/Http/Controllers/AssetsController.php | 4 - .../Controllers/ConsumablesController.php | 2 +- app/Http/Controllers/ViewAssetsController.php | 145 ++++++++++++- app/Http/routes.php | 16 +- app/Models/Actionlog.php | 7 +- app/Models/Asset.php | 2 + app/Models/AssetModel.php | 18 ++ app/Models/CheckoutRequest.php | 59 ++++++ app/Models/Loggable.php | 1 - app/Models/Requestable.php | 45 ++++ app/Models/User.php | 8 + ..._141051_add_requestable_to_asset_model.php | 33 +++ ..._001448_create_checkout_requests_table.php | 36 ++++ resources/lang/en/admin/hardware/general.php | 3 +- resources/lang/en/admin/hardware/message.php | 1 + resources/lang/en/admin/models/general.php | 1 + resources/lang/en/general.php | 1 + .../account/requestable-assets.blade.php | 200 ++++++++++++------ resources/views/account/view-assets.blade.php | 13 +- .../views/admin/requested-assets.blade.php | 84 ++++++++ resources/views/dashboard.blade.php | 3 +- .../views/emails/asset-canceled.blade.php | 12 ++ .../views/emails/asset-requested.blade.php | 7 +- resources/views/hardware/view.blade.php | 1 - resources/views/models/edit.blade.php | 9 + 26 files changed, 631 insertions(+), 103 deletions(-) create mode 100644 app/Models/CheckoutRequest.php create mode 100644 app/Models/Requestable.php create mode 100644 database/migrations/2016_09_01_141051_add_requestable_to_asset_model.php create mode 100644 database/migrations/2016_09_02_001448_create_checkout_requests_table.php create mode 100644 resources/views/admin/requested-assets.blade.php create mode 100644 resources/views/emails/asset-canceled.blade.php diff --git a/app/Http/Controllers/AssetModelsController.php b/app/Http/Controllers/AssetModelsController.php index 1fadcaa3a6..971e98498d 100755 --- a/app/Http/Controllers/AssetModelsController.php +++ b/app/Http/Controllers/AssetModelsController.php @@ -92,19 +92,19 @@ class AssetModelsController extends Controller $model->eol = e(Input::get('eol')); } - // Save the model data - $model->name = e(Input::get('name')); - $model->modelno = e(Input::get('modelno')); - $model->manufacturer_id = e(Input::get('manufacturer_id')); - $model->category_id = e(Input::get('category_id')); - $model->note = e(Input::get('note')); - $model->user_id = Auth::user()->id; + // Save the model data + $model->name = e(Input::get('name')); + $model->modelno = e(Input::get('modelno')); + $model->manufacturer_id = e(Input::get('manufacturer_id')); + $model->category_id = e(Input::get('category_id')); + $model->note = e(Input::get('note')); + $model->user_id = Auth::user()->id; + $model->requestable = Input::has('requestable'); + if (Input::get('custom_fieldset')!='') { $model->fieldset_id = e(Input::get('custom_fieldset')); } - //$model->show_mac_address = e(Input::get('show_mac_address', '0')); - if (Input::file('image')) { $image = Input::file('image'); @@ -227,7 +227,10 @@ class AssetModelsController extends Controller $model->modelno = e(Input::get('modelno')); $model->manufacturer_id = e(Input::get('manufacturer_id')); $model->category_id = e(Input::get('category_id')); - $model->note = e(Input::get('note')); + $model->note = e(Input::get('note')); + + $model->requestable = Input::has('requestable'); + if (Input::get('custom_fieldset')=='') { $model->fieldset_id = null; } else { diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php index ed27edaaf7..1c5fef1996 100755 --- a/app/Http/Controllers/AssetsController.php +++ b/app/Http/Controllers/AssetsController.php @@ -1670,10 +1670,6 @@ class AssetsController extends Controller case 'Deployed': $assets->Deployed(); break; - default: - $assets->NotArchived(); - break; - } if ($request->has('status_id')) { diff --git a/app/Http/Controllers/ConsumablesController.php b/app/Http/Controllers/ConsumablesController.php index feb75f5d4c..9557837f77 100644 --- a/app/Http/Controllers/ConsumablesController.php +++ b/app/Http/Controllers/ConsumablesController.php @@ -336,7 +336,7 @@ class ConsumablesController extends Controller 'fields' => [ [ 'title' => 'Checked Out:', - 'value' => strtoupper($logaction->item_type).' <'.config('app.url').'/admin/consumables/'.$consumable->id.'/view'.'|'.$consumable->name.'> checked out to <'.config('app.url').'/admin/users/'.$user->id.'/view|'.$user->fullName().'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.' + 'value' => 'Consumable <'.config('app.url').'/admin/consumables/'.$consumable->id.'/view'.'|'.$consumable->name.'> checked out to <'.config('app.url').'/admin/users/'.$user->id.'/view|'.$user->fullName().'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.' ], [ 'title' => 'Note:', diff --git a/app/Http/Controllers/ViewAssetsController.php b/app/Http/Controllers/ViewAssetsController.php index aec7794c4a..7687291ed7 100755 --- a/app/Http/Controllers/ViewAssetsController.php +++ b/app/Http/Controllers/ViewAssetsController.php @@ -4,12 +4,14 @@ namespace App\Http\Controllers; use App\Models\Accessory; use App\Models\Actionlog; use App\Models\Asset; +use App\Models\AssetModel; +use App\Models\CheckoutRequest; use App\Models\Company; -use App\Models\Consumable; use App\Models\Component; +use App\Models\Consumable; +use App\Models\License; use App\Models\Setting; use App\Models\User; -use App\Models\License; use Auth; use Config; use DB; @@ -39,9 +41,7 @@ class ViewAssetsController extends Controller $user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find(Auth::user()->id); - $userlog = $user->userlog->load('item', 'item.model', 'user', 'target'); - - + $userlog = $user->userlog->load('item', 'user', 'target'); if (isset($user->id)) { return View::make('account/view-assets', compact('user', 'userlog')); @@ -60,11 +60,130 @@ class ViewAssetsController extends Controller { $assets = Asset::with('model', 'defaultLoc', 'assetloc', 'assigneduser')->Hardware()->RequestableAssets()->get(); + $models = AssetModel::with('category')->RequestableModels()->get(); - return View::make('account/requestable-assets', compact('user', 'assets')); + return View::make('account/requestable-assets', compact('user', 'assets', 'models')); + } + + public function getRequestedIndex() + { + $requestedItems = CheckoutRequest::with('user', 'requestedItem')->get(); + return View::make('admin/requested-assets', compact('requestedItems')); } + public function getRequestItem($itemType, $itemId = null) + { + $item = null; + $fullItemType = 'App\\Models\\' . studly_case($itemType); + if($itemType == "asset_model") { + $itemType = "model"; + } + $item = call_user_func(array($fullItemType, 'find'), $itemId); + $user = Auth::user(); + $quantity = $data['item_quantity'] = Input::has('request-quantity') ? e(Input::get('request-quantity')) : 1; + + $logaction = new Actionlog(); + $logaction->item_id = $data['asset_id'] = $item->id; + $logaction->item_type = $fullItemType; + $logaction->created_at = $data['requested_date'] = date("Y-m-d h:i:s"); + if ($user->location_id) { + $logaction->location_id = $user->location_id; + } + $logaction->target_id = $data['user_id'] = Auth::user()->id; + $logaction->target_type = User::class; + + $data['requested_by'] = $user->fullName(); + $data['item_name'] = $item->name; + $data['item_type'] = $itemType; + + if ($fullItemType == Asset::class) { + $data['item_url'] = route('view/hardware', $item->id); + $slackMessage = ' Asset <'.config('app.url').'/hardware/'.$item->id.'/view'.'|'.$item->showAssetName().'> requested by <'.config('app.url').'/users/'.$item->user_id.'/view'.'|'.$user->fullName().'>.'; + } else { + $data['item_url'] = route("view/${itemType}", $item->id); + $slackMessage = $quantity. ' ' . class_basename(strtoupper($logaction->item_type)).' <'.$data['item_url'].'|'.$item->name.'> requested by <'.config('app.url').'/user/'.$item->id.'/view'.'|'.$user->fullName().'>.'; + } + + $settings = Setting::getSettings(); + + if ($settings->slack_endpoint) { + + $slack_settings = [ + 'username' => $settings->botname, + 'channel' => $settings->slack_channel, + 'link_names' => true + ]; + + $slackClient = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings); + } + + if ($item->isRequestedBy($user)) { + + $item->cancelRequest(); + $log = $logaction->logaction('request_canceled'); + + if (($settings->alert_email!='') && ($settings->alerts_enabled=='1') && (!config('app.lock_passwords'))) { + Mail::send('emails.asset-canceled', $data, function ($m) use ($user, $settings) { + $m->to(explode(',', $settings->alert_email), $settings->site_name); + $m->subject('Item Request Canceled'); + }); + } + + if ($settings->slack_endpoint) { + try { + $slackClient->attach([ + 'color' => 'good', + 'fields' => [ + [ + 'title' => 'CANCELED:', + 'value' => $slackMessage + ] + + ] + ])->send('Item Request Canceled'); + + } catch (Exception $e) { + + } + } + + return redirect()->route('requestable-assets')->with('success')->with('success', trans('admin/hardware/message.requests.canceled')); + + } else { + $item->request(); + + $log = $logaction->logaction('requested'); + + + if (($settings->alert_email!='') && ($settings->alerts_enabled=='1') && (!config('app.lock_passwords'))) { + Mail::send('emails.asset-requested', $data, function ($m) use ($user, $settings) { + $m->to(explode(',', $settings->alert_email), $settings->site_name); + $m->subject('Item Requested'); + }); + } + + if ($settings->slack_endpoint) { + try { + $slackClient->attach([ + 'color' => 'good', + 'fields' => [ + [ + 'title' => 'REQUESTED:', + 'value' => $slackMessage + ] + + ] + ])->send('Item Requested'); + + } catch (Exception $e) { + + } + } + + return redirect()->route('requestable-assets')->with('success')->with('success', trans('admin/hardware/message.requests.success')); + } + } public function getRequestAsset($assetId = null) { @@ -76,6 +195,11 @@ class ViewAssetsController extends Controller return redirect()->route('requestable-assets')->with('error', trans('admin/hardware/message.does_not_exist_or_not_requestable')); } elseif (!Company::isCurrentUserHasAccess($asset)) { return redirect()->route('requestable-assets')->with('error', trans('general.insufficient_permissions')); + } + // If it's requested, cancel the request. + if ($asset->isRequestedBy(Auth::user())) { + $asset->cancelRequest(); + return redirect()->route('requestable-assets')->with('success')->with('success', trans('admin/hardware/message.requests.success')); } else { $logaction = new Actionlog(); @@ -102,6 +226,8 @@ class ViewAssetsController extends Controller }); } + $asset->request(); + if ($settings->slack_endpoint) { @@ -138,6 +264,13 @@ class ViewAssetsController extends Controller } + public function getRequestedAssets() + { + $checkoutrequests = CheckoutRequest::all(); + + return View::make('account/requested-items', compact($checkoutrequests)); + } + // Get the acceptance screen diff --git a/app/Http/routes.php b/app/Http/routes.php index f23c098723..c8655f41dc 100755 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -1,6 +1,7 @@ 'admin','middleware' => ['web','auth']], function () { + Route::get('requests', + // foreach( CheckoutRequest::with('user')->get() as $requestedItem) { + // echo $requestedItem->user->username . ' requested ' . $requestedItem->requestedItem->name; + [ + 'as' => 'requests', + 'middleware' => 'authorize:admin', + 'uses' => 'ViewAssetsController@getRequestedIndex' + ]); # Licenses Route::group([ 'prefix' => 'licenses', 'middleware'=>'authorize:licenses.view' ], function () { @@ -858,6 +867,11 @@ Route::group([ 'prefix' => 'account', 'middleware' => ['web', 'auth']], function [ 'as' => 'account/request-asset', 'uses' => 'ViewAssetsController@getRequestAsset' ] ); + Route::post( + 'request/{itemType}/{itemId}', + [ 'as' => 'account/request-item', 'uses' => 'ViewAssetsController@getRequestItem'] + ); + # Account Dashboard Route::get('/', [ 'as' => 'account', 'uses' => 'ViewAssetsController@getIndex' ]); diff --git a/app/Models/Actionlog.php b/app/Models/Actionlog.php index b824883b5b..346fb9143d 100755 --- a/app/Models/Actionlog.php +++ b/app/Models/Actionlog.php @@ -37,6 +37,9 @@ class Actionlog extends Model implements ICompanyableChild public function itemType() { // dd($this); + if($this->item_type == AssetModel::class) { + return "model"; + } return camel_case(class_basename($this->item_type)); } @@ -50,8 +53,6 @@ class Actionlog extends Model implements ICompanyableChild public function userlog() { - - // return $this->belongsTo(User::class, 'target_id') return $this->target(); } @@ -68,13 +69,11 @@ class Actionlog extends Model implements ICompanyableChild public function childlogs() { - return $this->hasMany('\App\Models\ActionLog', 'thread_id'); } public function parentlog() { - return $this->belongsTo('\App\Models\ActionLog', 'thread_id'); } diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 8c857b507c..5820d43197 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -7,6 +7,7 @@ use App\Models\Actionlog; use App\Models\Company; use App\Models\Location; use App\Models\Loggable; +use App\Models\Requestable; use App\Models\Setting; use Auth; use Config; @@ -26,6 +27,7 @@ class Asset extends Depreciable { use Loggable; use SoftDeletes; + use Requestable; /** * The database table used by the model. diff --git a/app/Models/AssetModel.php b/app/Models/AssetModel.php index dec9244d9a..2c2594807b 100755 --- a/app/Models/AssetModel.php +++ b/app/Models/AssetModel.php @@ -1,6 +1,7 @@ whereIn('category_id', $categoryIdListing); } + /** + * scopeRequestable + * Get all models that are requestable by a user. + * + * @param $query + * + * @return $query + * @author Daniel Meltzer where('requestable', '1'); + } + /** * Query builder scope to search on text * diff --git a/app/Models/CheckoutRequest.php b/app/Models/CheckoutRequest.php new file mode 100644 index 0000000000..a3e5fb6139 --- /dev/null +++ b/app/Models/CheckoutRequest.php @@ -0,0 +1,59 @@ +belongsTo(User::class); + } + + public function requestingUser() + { + return $this->user()->first(); + } + + public function requestedItem() + { + return $this->morphTo('requestable'); + } + + public function itemRequested() // Workaround for laravel polymorphic issue that's not being solved :( + { + return $this->requestedItem()->first(); + } + + public function itemType() + { + return snake_case(class_basename($this->requestable_type)); + } + + public function location() + { + if ($this->itemType() == "asset") { + $asset = $this->itemRequested(); + if ($asset->assigneduser && $asset->assetloc) { + return $asset->assetloc; + } elseif ($asset->defaultLoc) { + return $asset->defaultLoc; + } + } + return $this->itemRequested()->location; + } + + public function name() + { + if ($this->itemType() == "asset") { + return $this->itemRequested()->showAssetName(); + } + return $this->itemRequested()->name; + + } +} diff --git a/app/Models/Loggable.php b/app/Models/Loggable.php index fcbf0648f5..02024c8176 100644 --- a/app/Models/Loggable.php +++ b/app/Models/Loggable.php @@ -80,5 +80,4 @@ trait Loggable return $log; } - } diff --git a/app/Models/Requestable.php b/app/Models/Requestable.php new file mode 100644 index 0000000000..3781cbadeb --- /dev/null +++ b/app/Models/Requestable.php @@ -0,0 +1,45 @@ +requests +// $asset->isRequestedBy($user) +// $asset->whereRequestedBy($user) +trait Requestable +{ + + public function requests() + { + return $this->morphMany(CheckoutRequest::class, 'requestable'); + } + + public function isRequestedBy(User $user) + { + return $this->requests() + ->where('user_id', $user->id) + ->exists(); + } + + public function scopeRequestedBy($query, User $user) + { + return $query->whereHas('requests', function ($query) use ($user) { + $query->where('user_id', $user->id); + }); + } + + public function request() + { + $this->requests()->save( + new CheckoutRequest(['user_id' => Auth::id()]) + ); + } + + public function cancelRequest() + { + $this->requests()->where('user_id', Auth::id())->delete(); + } +} diff --git a/app/Models/User.php b/app/Models/User.php index 9a5180a698..2c78224dc5 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -261,6 +261,14 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon ->orderBy('created_at', 'desc'); } + /** + * Fetch Items User has requested + */ + public function checkoutRequests() + { + return $this->belongsToMany(Asset::class, 'checkout_requests'); + } + public function throttle() { return $this->hasOne('\App\Models\Throttle'); diff --git a/database/migrations/2016_09_01_141051_add_requestable_to_asset_model.php b/database/migrations/2016_09_01_141051_add_requestable_to_asset_model.php new file mode 100644 index 0000000000..6fc16b9cdf --- /dev/null +++ b/database/migrations/2016_09_01_141051_add_requestable_to_asset_model.php @@ -0,0 +1,33 @@ +tinyInteger('requestable')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + Schema::table('models', function ($table) { + $table->dropColumn('requestable'); + }); + } +} diff --git a/database/migrations/2016_09_02_001448_create_checkout_requests_table.php b/database/migrations/2016_09_02_001448_create_checkout_requests_table.php new file mode 100644 index 0000000000..364da70a8b --- /dev/null +++ b/database/migrations/2016_09_02_001448_create_checkout_requests_table.php @@ -0,0 +1,36 @@ +increments('id'); + $table->integer('user_id'); + $table->integer('requestable_id'); + $table->string('requestable_type'); + $table->integer('quantity')->default(1); + $table->timestamps(); + + $table->unique(['user_id', 'requestable_id', 'requestable_type']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('checkout_requests'); + } +} diff --git a/resources/lang/en/admin/hardware/general.php b/resources/lang/en/admin/hardware/general.php index 65b6d77477..6674ea0c9d 100644 --- a/resources/lang/en/admin/hardware/general.php +++ b/resources/lang/en/admin/hardware/general.php @@ -12,7 +12,8 @@ return array( 'edit' => 'Edit Asset', 'filetype_info' => 'Allowed filetypes are png, gif, jpg, jpeg, doc, docx, pdf, txt, zip, and rar.', 'model_deleted' => 'This Assets model has been deleted. You must restore the model before you can restore the Asset.
Click here to restore the model.', - 'requestable' => 'Requestable', + 'requestable' => 'Requestable', + 'requested' => 'Requested', 'restore' => 'Restore Asset', 'pending' => 'Pending', 'undeployable' => 'Undeployable', diff --git a/resources/lang/en/admin/hardware/message.php b/resources/lang/en/admin/hardware/message.php index 8a170db8bf..d27ca91573 100644 --- a/resources/lang/en/admin/hardware/message.php +++ b/resources/lang/en/admin/hardware/message.php @@ -69,6 +69,7 @@ return array( 'requests' => array( 'error' => 'Asset was not requested, please try again', 'success' => 'Asset requested successfully.', + 'canceled' => 'Checkout request successfully canceled' ) ); diff --git a/resources/lang/en/admin/models/general.php b/resources/lang/en/admin/models/general.php index ccd36607ce..08677c5532 100644 --- a/resources/lang/en/admin/models/general.php +++ b/resources/lang/en/admin/models/general.php @@ -4,6 +4,7 @@ return array( 'deleted' => 'This model has been deleted. Click here to restore it.', 'restore' => 'Restore Model', + 'requestable' => 'Users may request this model', 'show_mac_address' => 'Show MAC address field in assets in this model', 'view_deleted' => 'View Deleted', 'view_models' => 'View Models', diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 0b6ef1fcb9..7125234bde 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -127,6 +127,7 @@ 'remove_company' => 'Remove Company Association', 'reports' => 'Reports', 'requested' => 'Requested', + 'request_canceled' => 'Request Canceled', 'save' => 'Save', 'select' => 'Select', 'search' => 'Search', diff --git a/resources/views/account/requestable-assets.blade.php b/resources/views/account/requestable-assets.blade.php index 78c099249c..14e1cffe37 100644 --- a/resources/views/account/requestable-assets.blade.php +++ b/resources/views/account/requestable-assets.blade.php @@ -13,86 +13,160 @@ {{-- Page content --}} @section('content') -
-
-
+ +@stop +@section('moar_scripts') + @stop diff --git a/resources/views/account/view-assets.blade.php b/resources/views/account/view-assets.blade.php index 43736277f3..b51fe62164 100755 --- a/resources/views/account/view-assets.blade.php +++ b/resources/views/account/view-assets.blade.php @@ -231,7 +231,7 @@ View Assets for {{ $user->fullName() }} @endif
- @if (count($user->userlog) > 0) + @if (count($userlog) > 0)
@@ -244,7 +244,7 @@ View Assets for {{ $user->fullName() }} - @foreach ($user->userlog as $log) + @foreach ($userlog as $log) - + diff --git a/resources/views/emails/asset-canceled.blade.php b/resources/views/emails/asset-canceled.blade.php new file mode 100644 index 0000000000..fd1baf3b70 --- /dev/null +++ b/resources/views/emails/asset-canceled.blade.php @@ -0,0 +1,12 @@ +@extends('emails/layouts/default') + +@section('content') + +

A user has canceled an item request on the {{ \App\Models\Setting::getSettings()->site_name }} website.

+ +

User: {{ $requested_by }}
+Item: {{ $item_name }} ({{ $item_type }})
+Canceled: {{ $requested_date }} +

+ +@stop diff --git a/resources/views/emails/asset-requested.blade.php b/resources/views/emails/asset-requested.blade.php index 06da6fe556..9b7d03a23c 100644 --- a/resources/views/emails/asset-requested.blade.php +++ b/resources/views/emails/asset-requested.blade.php @@ -2,11 +2,14 @@ @section('content') -

A user has requested an asset on the {{ \App\Models\Setting::getSettings()->site_name }} website.

+

A user has requested an item on the {{ \App\Models\Setting::getSettings()->site_name }} website.

User: {{ $requested_by }}
-Asset: {{ $asset_name }} ({{ $asset_type }})
+Item: {{ $item_name }} ({{ $item_type }})
Requested: {{ $requested_date }} +@if ($item_quantity > 1) +Quantity: {{ $item_quantity}} +@endif

@stop diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 4c1b7c09b1..5aad0b8c2e 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -523,7 +523,6 @@
@if ($log->itemType()=="asset") @@ -260,14 +260,13 @@ View Assets for {{ $user->fullName() }} @endif {{ $log->action_type }} - + {{ strtolower(trans('general.'.str_replace(' ','_',$log->action_type))) }} + @if ($log->itemType()=="asset") @if ($log->item->deleted_at=='') - - {{ $log->item->showAssetName() }} - + {{ $log->item->showAssetName() }} @else {{ $log->item->showAssetName() }} (deleted) @endif diff --git a/resources/views/admin/requested-assets.blade.php b/resources/views/admin/requested-assets.blade.php new file mode 100644 index 0000000000..3c7b568431 --- /dev/null +++ b/resources/views/admin/requested-assets.blade.php @@ -0,0 +1,84 @@ +@extends('layouts/default') + +@section('title0') + {{ trans('admin/hardware/general.requested') }} + {{ trans('general.assets') }} +@stop + +{{-- Page title --}} +@section('title') + @yield('title0') @parent +@stop + +{{-- Page content --}} +@section('content') + +
+
+ + @if ($requestedItems->count() > 0) + +
+ + + + + + + + + + + + + + @foreach ($requestedItems as $request) + + + + + {{ csrf_field() }} + + + @if ($request->location()) + + @else + + @endif + + + + + + + + @endforeach + +
Item TypeItem Name{{ trans('admin/hardware/table.location') }}{{ trans('admin/hardware/form.expected_checkin') }}Requesting UserRequested Date{{ trans('table.actions') }}
{{ $request->itemType() }}{{ $request->name() }}{{ $request->location()->name }} + @if ($request->itemType() == "asset") + {{ $request->itemRequested()->expected_checkin }} + @else + "N/A" + @endif + {{ $request->requestingUser()->fullName() }}{{$request->created_at}} +
+
+ + + @else +
+
+ + {{ trans('general.no_results') }} +
+
+ + + @endif +
+
+ + + + +@stop diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 4571d68cb3..4301a47730 100755 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -127,7 +127,7 @@
{{ date("M d, Y g:iA", strtotime($activity->created_at)) }} - @if ($activity->action_type!='requested') + @if (($activity->action_type!='requested') && ($activity->action_type!="request_canceled")) @if ($activity->user) {{ $activity->user->fullName() }} @else @@ -157,7 +157,6 @@ {{ $activity->target->fullName() }} @elseif ($activity->action_type=='requested') {{ $activity->user->fullName() }} - @endif {{ $log->action_type }} - @if ($log->action_type=='uploaded') {{ $log->filename }} diff --git a/resources/views/models/edit.blade.php b/resources/views/models/edit.blade.php index 9dfde7afca..03ea1592db 100755 --- a/resources/views/models/edit.blade.php +++ b/resources/views/models/edit.blade.php @@ -118,6 +118,15 @@ + +
+
+ +
+
+ @if ($model->image)