mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Added routes, language
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
3469e49470
commit
891b5b2882
|
@ -3,7 +3,10 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\ImageUploadRequest;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Notifications\CurrentInventory;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Gate;
|
||||
use Illuminate\Http\Request;
|
||||
|
@ -216,4 +219,49 @@ class ProfileController extends Controller
|
|||
$request->session()->put('menu_state', 'closed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print inventory
|
||||
*
|
||||
* @author A. Gianotto
|
||||
* @since [v6.0.12]
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function printInventory()
|
||||
{
|
||||
$show_user = User::where('id', Auth::user()->id)->withTrashed()->first();
|
||||
$assets = Asset::where('assigned_to', Auth::user()->id)->where('assigned_type', User::class)->with('model', 'model.category')->get();
|
||||
$accessories = $show_user->accessories()->get();
|
||||
$consumables = $show_user->consumables()->get();
|
||||
|
||||
return view('users/print')->with('assets', $assets)
|
||||
->with('licenses', $show_user->licenses()->get())
|
||||
->with('accessories', $accessories)
|
||||
->with('consumables', $consumables)
|
||||
->with('show_user', $show_user)
|
||||
->with('settings', Setting::getSettings());
|
||||
}
|
||||
|
||||
/**
|
||||
* Emails user a list of assigned assets
|
||||
*
|
||||
* @author A. Gianotto
|
||||
* @since [v6.0.12]
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function emailAssetList()
|
||||
{
|
||||
|
||||
if (!$user = User::find(Auth::user()->id)) {
|
||||
return redirect()->back()
|
||||
->with('error', trans('admin/users/message.user_not_found', ['id' => $id]));
|
||||
}
|
||||
if (empty($user->email)) {
|
||||
return redirect()->back()->with('error', trans('admin/users/message.user_has_no_email'));
|
||||
}
|
||||
|
||||
$user->notify((new CurrentInventory($user)));
|
||||
return redirect()->back()->with('success', trans('admin/users/general.user_notified'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -594,7 +594,7 @@ class UsersController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* LDAP form processing.
|
||||
* Print inventory
|
||||
*
|
||||
* @author Aladin Alaily
|
||||
* @since [v1.8]
|
||||
|
|
|
@ -376,6 +376,7 @@ return [
|
|||
'assets_by_status' => 'Assets by Status',
|
||||
'assets_by_status_type' => 'Assets by Status Type',
|
||||
'pie_chart_type' => 'Dashboard Pie Chart Type',
|
||||
'hello_name' => 'Hello, :name!',
|
||||
|
||||
|
||||
];
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{{-- Page title --}}
|
||||
@section('title')
|
||||
{{ trans('general.viewassetsfor', array('name' => $user->present()->fullName())) }}
|
||||
{{ trans('general.hello_name', array('name' => $user->present()->fullName())) }}
|
||||
@parent
|
||||
@stop
|
||||
|
||||
|
@ -83,36 +83,42 @@
|
|||
|
||||
<div class="col-md-12 text-center">
|
||||
|
||||
@if (($user->isSuperUser()) || ($user->hasAccess('admin')))
|
||||
<i class="fas fa-crown fa-2x{{ ($user->isSuperUser()) ? ' text-danger' : ' text-orange'}}"></i>
|
||||
<div class="{{ ($user->isSuperUser()) ? 'text-danger' : 'text-orange'}}" style="font-weight: bold">{{ ($user->isSuperUser()) ? 'superadmin' : 'admin'}}</div>
|
||||
@endif
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-md-12 text-center">
|
||||
<img src="{{ $user->present()->gravatar() }}" class=" img-thumbnail hidden-print" style="margin-bottom: 20px;" alt="{{ $user->present()->fullName() }}">
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@can('update', $user)
|
||||
<div class="col-md-12">
|
||||
<a href="{{ route('users.edit', $user->id) }}" style="width: 100%;" class="btn btn-sm btn-primary hidden-print">{{ trans('admin/users/general.edit') }}</a>
|
||||
<a href="{{ route('profile') }}" style="width: 100%;" class="btn btn-sm btn-primary hidden-print">
|
||||
{{ trans('general.editprofile') }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12" style="padding-top: 5px;">
|
||||
<a href="{{ route('account.password.index') }}" style="width: 100%;" class="btn btn-sm btn-primary hidden-print" target="_blank" rel="noopener">
|
||||
{{ trans('general.changepassword') }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@can('self.api')
|
||||
<div class="col-md-12" style="padding-top: 5px;">
|
||||
<a href="{{ route('user.api') }}" style="width: 100%;" class="btn btn-sm btn-primary hidden-print" target="_blank" rel="noopener">
|
||||
{{ trans('general.manage_api_keys') }}
|
||||
</a>
|
||||
</div>
|
||||
@endcan
|
||||
|
||||
|
||||
@can('view', $user)
|
||||
<div class="col-md-12" style="padding-top: 5px;">
|
||||
<a href="{{ route('users.print', $user->id) }}" style="width: 100%;" class="btn btn-sm btn-primary hidden-print" target="_blank" rel="noopener">{{ trans('admin/users/general.print_assigned') }}</a>
|
||||
<a href="{{ route('profile.print') }}" style="width: 100%;" class="btn btn-sm btn-primary hidden-print" target="_blank" rel="noopener">
|
||||
{{ trans('admin/users/general.print_assigned') }}
|
||||
</a>
|
||||
</div>
|
||||
@endcan
|
||||
|
||||
@can('view', $user)
|
||||
|
||||
<div class="col-md-12" style="padding-top: 5px;">
|
||||
@if(!empty($user->email))
|
||||
<form action="{{ route('users.email',['userId'=> $user->id]) }}" method="POST">
|
||||
<form action="{{ route('profile.email_assets') }}" method="POST">
|
||||
{{ csrf_field() }}
|
||||
<button style="width: 100%;" class="btn btn-sm btn-primary hidden-print" rel="noopener">{{ trans('admin/users/general.email_assigned') }}</button>
|
||||
</form>
|
||||
|
@ -120,8 +126,6 @@
|
|||
<button style="width: 100%;" class="btn btn-sm btn-primary hidden-print" rel="noopener" disabled title="{{ trans('admin/users/message.user_has_no_email') }}">{{ trans('admin/users/general.email_assigned') }}</button>
|
||||
@endif
|
||||
</div>
|
||||
@endcan
|
||||
|
||||
|
||||
<br><br>
|
||||
</div>
|
||||
|
|
|
@ -279,6 +279,23 @@ Route::group(['prefix' => 'account', 'middleware' => ['auth']], function () {
|
|||
->name('account.accept.item');
|
||||
|
||||
Route::post('accept/{id}', [Account\AcceptanceController::class, 'store']);
|
||||
|
||||
Route::get(
|
||||
'print',
|
||||
[
|
||||
ProfileController::class,
|
||||
'printInventory'
|
||||
]
|
||||
)->name('profile.print');
|
||||
|
||||
Route::post(
|
||||
'email',
|
||||
[
|
||||
ProfileController::class,
|
||||
'emailAssetList'
|
||||
]
|
||||
)->name('profile.email_assets');
|
||||
|
||||
});
|
||||
|
||||
Route::group(['middleware' => ['auth']], function () {
|
||||
|
|
Loading…
Reference in a new issue