mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-11 16:14:18 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
9f291d7e4b
|
@ -69,7 +69,7 @@ class AcceptanceController extends Controller
|
|||
}
|
||||
|
||||
if (! Company::isCurrentUserHasAccess($acceptance->checkoutable)) {
|
||||
return redirect()->route('account.accept')->with('error', trans('general.insufficient_permissions'));
|
||||
return redirect()->route('account.accept')->with('error', trans('general.error_user_company'));
|
||||
}
|
||||
|
||||
return view('account/accept.create', compact('acceptance'));
|
||||
|
@ -245,6 +245,36 @@ class AcceptanceController extends Controller
|
|||
$return_msg = trans('admin/users/message.accepted');
|
||||
|
||||
} else {
|
||||
|
||||
/**
|
||||
* Check for the eula-pdfs directory
|
||||
*/
|
||||
if (! Storage::exists('private_uploads/eula-pdfs')) {
|
||||
Storage::makeDirectory('private_uploads/eula-pdfs', 775);
|
||||
}
|
||||
|
||||
if (Setting::getSettings()->require_accept_signature == '1') {
|
||||
|
||||
// Check if the signature directory exists, if not create it
|
||||
if (!Storage::exists('private_uploads/signatures')) {
|
||||
Storage::makeDirectory('private_uploads/signatures', 775);
|
||||
}
|
||||
|
||||
// The item was accepted, check for a signature
|
||||
if ($request->filled('signature_output')) {
|
||||
$sig_filename = 'siglog-' . Str::uuid() . '-' . date('Y-m-d-his') . '.png';
|
||||
$data_uri = $request->input('signature_output');
|
||||
$encoded_image = explode(',', $data_uri);
|
||||
$decoded_image = base64_decode($encoded_image[1]);
|
||||
Storage::put('private_uploads/signatures/' . $sig_filename, (string)$decoded_image);
|
||||
|
||||
// No image data is present, kick them back.
|
||||
// This mostly only applies to users on super-duper crapola browsers *cough* IE *cough*
|
||||
} else {
|
||||
return redirect()->back()->with('error', trans('general.shitty_browser'));
|
||||
}
|
||||
}
|
||||
|
||||
// Format the data to send the declined notification
|
||||
$branding_settings = SettingsController::getPDFBranding();
|
||||
|
||||
|
@ -281,11 +311,18 @@ class AcceptanceController extends Controller
|
|||
'item_model' => $display_model,
|
||||
'item_serial' => $item->serial,
|
||||
'declined_date' => Carbon::parse($acceptance->declined_at)->format('Y-m-d'),
|
||||
'signature' => ($sig_filename) ? storage_path() . '/private_uploads/signatures/' . $sig_filename : null,
|
||||
'assigned_to' => $assigned_to,
|
||||
'company_name' => $branding_settings->site_name,
|
||||
'date_settings' => $branding_settings->date_display_format,
|
||||
];
|
||||
|
||||
if ($pdf_view_route!='') {
|
||||
\Log::debug($pdf_filename.' is the filename, and the route was specified.');
|
||||
$pdf = Pdf::loadView($pdf_view_route, $data);
|
||||
Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf->output());
|
||||
}
|
||||
|
||||
$acceptance->decline($sig_filename);
|
||||
$acceptance->notify(new AcceptanceAssetDeclinedNotification($data));
|
||||
event(new CheckoutDeclined($acceptance));
|
||||
|
|
|
@ -89,6 +89,14 @@ class AssetCheckoutController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
$settings = \App\Models\Setting::getSettings();
|
||||
|
||||
if ($settings->full_multiple_companies_support){
|
||||
if ($target->company_id != $asset->company_id){
|
||||
return redirect()->to("hardware/$assetId/checkout")->with('error', trans('general.error_user_company'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e($request->get('note')), $request->get('name'))) {
|
||||
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
}
|
||||
|
|
|
@ -590,6 +590,7 @@ class SettingsController extends Controller
|
|||
$setting->date_display_format = $request->input('date_display_format');
|
||||
$setting->time_display_format = $request->input('time_display_format');
|
||||
$setting->digit_separator = $request->input('digit_separator');
|
||||
$setting->name_display_format = $request->input('name_display_format');
|
||||
|
||||
if ($setting->save()) {
|
||||
return redirect()->route('settings.index')
|
||||
|
|
|
@ -159,8 +159,8 @@ class ActionlogsTransformer
|
|||
unset($clean_meta['location_id']);
|
||||
}
|
||||
if(array_key_exists('model_id', $clean_meta)) {
|
||||
$clean_meta['model_id']['old'] = "[id: ".$clean_meta['model_id']['old']."] ".AssetModel::find($clean_meta['model_id']['old'])->name;
|
||||
$clean_meta['model_id']['new'] = "[id: ".$clean_meta['model_id']['new']."] ".AssetModel::find($clean_meta['model_id']['new'])->name; /* model is required at asset creation */
|
||||
$clean_meta['model_id']['old'] = "[id: ".$clean_meta['model_id']['old']."] ".AssetModel::withTrashed()->find($clean_meta['model_id']['old'])->name;
|
||||
$clean_meta['model_id']['new'] = "[id: ".$clean_meta['model_id']['new']."] ".AssetModel::withTrashed()->find($clean_meta['model_id']['new'])->name; /* model is required at asset creation */
|
||||
$clean_meta['Model'] = $clean_meta['model_id'];
|
||||
unset($clean_meta['model_id']);
|
||||
}
|
||||
|
@ -183,4 +183,4 @@ class ActionlogsTransformer
|
|||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class UsersTransformer
|
|||
$array = [
|
||||
'id' => (int) $user->id,
|
||||
'avatar' => e($user->present()->gravatar),
|
||||
'name' => e($user->first_name).' '.e($user->last_name),
|
||||
'name' => e($user->getFullNameAttribute()),
|
||||
'first_name' => e($user->first_name),
|
||||
'last_name' => e($user->last_name),
|
||||
'username' => e($user->username),
|
||||
|
|
|
@ -349,6 +349,22 @@ class Accessory extends SnipeModel
|
|||
return (int) $remaining;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run after the checkout acceptance was declined by the user
|
||||
*
|
||||
* @param User $acceptedBy
|
||||
* @param string $signature
|
||||
*/
|
||||
public function declinedCheckout(User $declinedBy, $signature)
|
||||
{
|
||||
if (is_null($accessory_user = \DB::table('accessories_users')->where('assigned_to', $declinedBy->id)->where('accessory_id', $this->id)->latest('created_at'))) {
|
||||
// Redirect to the accessory management page with error
|
||||
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist'));
|
||||
}
|
||||
|
||||
$accessory_user->limit(1)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on company
|
||||
*
|
||||
|
|
|
@ -247,21 +247,12 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
|||
*/
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
return $this->first_name.' '.$this->last_name;
|
||||
}
|
||||
$setting = Setting::getSettings();
|
||||
|
||||
/**
|
||||
* Returns the complete name attribute with username
|
||||
*
|
||||
* @todo refactor this so it's less repetitive and dumb
|
||||
*
|
||||
* @author A. Gianotto <snipe@snipe.net>
|
||||
* @since [v2.0]
|
||||
* @return string
|
||||
*/
|
||||
public function getCompleteNameAttribute()
|
||||
{
|
||||
return $this->last_name.', '.$this->first_name.' ('.$this->username.')';
|
||||
if ($setting->name_display_format=='last_first') {
|
||||
return ($this->last_name) ? $this->last_name.' '.$this->first_name : $this->first_name;
|
||||
}
|
||||
return $this->last_name ? $this->first_name.' '.$this->last_name : $this->first_name;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -433,7 +433,7 @@ class UserPresenter extends Presenter
|
|||
*/
|
||||
public function nameUrl()
|
||||
{
|
||||
return (string) link_to_route('users.show', $this->fullName(), $this->id);
|
||||
return (string) link_to_route('users.show', $this->getFullNameAttribute(), $this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,11 +21,7 @@ class AddLabel2Settings extends Migration
|
|||
$table->string('label2_1d_type')->default('default');
|
||||
$table->string('label2_2d_type')->default('default');
|
||||
$table->string('label2_2d_target')->default('hardware_id');
|
||||
$table->string('label2_fields')->default(
|
||||
trans('admin/hardware/form.name').'=name;'.
|
||||
trans('admin/hardware/form.serial').'=serial;'.
|
||||
trans('admin/hardware/form.model').'=model.name;'
|
||||
);
|
||||
$table->string('label2_fields')->default('name=name;serial=serial;model=model.name;');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddNameOrderingToSettings extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->string('name_display_format', 10)->after('alert_threshold')->nullable()->default('first_last');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->dropColumn('name_display_format');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -120,6 +120,9 @@ return [
|
|||
'firstname_lastname_underscore_format' => 'First Name Last Name (jane_smith@example.com)',
|
||||
'lastnamefirstinitial_format' => 'Last Name First Initial (smithj@example.com)',
|
||||
'firstintial_dot_lastname_format' => 'First Initial Last Name (j.smith@example.com)',
|
||||
'firstname_lastname_display' => 'First Name Last Name (Jane Smith)',
|
||||
'lastname_firstname_display' => 'Last Name First Name (Smith Jane)',
|
||||
'name_display_format' => 'Name Display Format',
|
||||
'first' => 'First',
|
||||
'firstnamelastname' => 'First Name Last Name (janesmith@example.com)',
|
||||
'lastname_firstinitial' => 'Last Name First Initial (smith_j@example.com)',
|
||||
|
@ -454,6 +457,8 @@ return [
|
|||
'serial_number' => 'Serial Number',
|
||||
'item_notes' => ':item Notes',
|
||||
'item_name_var' => ':item Name',
|
||||
'error_user_company' => 'User and Asset companies missmatch',
|
||||
'error_user_company_accept_view' => 'An Asset assigned to you belongs to a different company so you can\'t accept nor deny it, please check with your manager',
|
||||
'importer' => [
|
||||
'checked_out_to_fullname' => 'Checked Out to: Full Name',
|
||||
'checked_out_to_first_name' => 'Checked Out to: First Name',
|
||||
|
|
|
@ -11,7 +11,7 @@ Form::macro('locales', function ($name = 'locale', $selected = null, $class = nu
|
|||
|
||||
$idclause = (!is_null($id)) ? $id : '';
|
||||
|
||||
$select = '<select name="'.$name.'" class="'.$class.'" style="min-width:350px"'.$idclause.' aria-label="'.$name.'" data-placeholder="'.trans('localizations.select_language').'">';
|
||||
$select = '<select name="'.$name.'" class="'.$class.'" style="min-width:100%"'.$idclause.' aria-label="'.$name.'" data-placeholder="'.trans('localizations.select_language').'">';
|
||||
$select .= '<option value="" role="option">'.trans('localizations.select_language').'</option>';
|
||||
|
||||
// Pull the autoglossonym array from the localizations translation file
|
||||
|
@ -109,6 +109,23 @@ Form::macro('digit_separator', function ($name = 'digit_separator', $selected =
|
|||
return $select;
|
||||
});
|
||||
|
||||
|
||||
Form::macro('name_display_format', function ($name = 'name_display_format', $selected = null, $class = null) {
|
||||
$formats = [
|
||||
'first_last' => trans('general.firstname_lastname_display'),
|
||||
'last_first' => trans('general.lastname_firstname_display'),
|
||||
];
|
||||
|
||||
$select = '<select name="'.$name.'" class="'.$class.'" style="width: 100%" aria-label="'.$name.'">';
|
||||
foreach ($formats as $format => $label) {
|
||||
$select .= '<option value="'.$format.'"'.($selected == $format ? ' selected="selected" role="option" aria-selected="true"' : ' aria-selected="false"').'>'.$label.'</option> '."\n";
|
||||
}
|
||||
|
||||
$select .= '</select>';
|
||||
|
||||
return $select;
|
||||
});
|
||||
|
||||
/**
|
||||
* Barcode macro
|
||||
* Generates the dropdown menu of available 1D barcodes
|
||||
|
|
|
@ -41,8 +41,13 @@
|
|||
<tbody>
|
||||
@foreach ($acceptances as $acceptance)
|
||||
<tr>
|
||||
@if ($acceptance->checkoutable)
|
||||
<td>{{ ($acceptance->checkoutable) ? $acceptance->checkoutable->present()->name : '' }}</td>
|
||||
<td><a href="{{ route('account.accept.item', $acceptance) }}" class="btn btn-default btn-sm">{{ trans('general.accept_decline') }}</a></td>
|
||||
@else
|
||||
<td> ----- </td>
|
||||
<td> {{ trans('general.error_user_company_accept_view') }} </td>
|
||||
@endif
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<!-- Language -->
|
||||
<div class="form-group {{ $errors->has('locale') ? 'has-error' : '' }}">
|
||||
<label class="col-md-3 control-label" for="locale">{{ trans('general.language') }}</label>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-7">
|
||||
|
||||
@if (!config('app.lock_passwords'))
|
||||
{!! Form::locales('locale', old('locale', $user->locale), 'select2') !!}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{{-- Page title --}}
|
||||
@section('title')
|
||||
{{ trans('general.hello_name', array('name' => $user->present()->fullName())) }}
|
||||
{{ trans('general.hello_name', array('name' => $user->present()->getFullNameAttribute())) }}
|
||||
@parent
|
||||
@stop
|
||||
|
||||
|
|
|
@ -328,7 +328,7 @@
|
|||
<i class="fas fa-users" aria-hidden="true"></i>
|
||||
@endif
|
||||
|
||||
<span class="hidden-xs">{{ Auth::user()->first_name }} <strong
|
||||
<span class="hidden-xs">{{ Auth::user()->getFullNameAttribute() }} <strong
|
||||
class="caret"></strong></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
|
|
|
@ -14,11 +14,7 @@
|
|||
{{-- Page content --}}
|
||||
@section('content')
|
||||
|
||||
<style>
|
||||
.checkbox label {
|
||||
padding-right: 40px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -260,11 +256,13 @@
|
|||
trans('admin/settings/general.show_archived_in_list')) }}
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
{{ Form::checkbox('show_archived_in_list', '1', Request::old('show_archived_in_list', $setting->show_archived_in_list),array('class' => 'minimal')) }}
|
||||
{{ trans('admin/settings/general.show_archived_in_list_text') }}
|
||||
{!! $errors->first('show_archived_in_list', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||
|
||||
</div>
|
||||
<label class="form-control">
|
||||
{{ Form::checkbox('show_archived_in_list', '1', old('show_archived_in_list', $setting->show_archived_in_list),array('aria-label'=>'show_archived_in_list')) }}
|
||||
{{ trans('admin/settings/general.show_archived_in_list_text') }}
|
||||
</label>
|
||||
{!! $errors->first('show_archived_in_list', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Show assets assigned to user's assets -->
|
||||
|
@ -274,8 +272,10 @@
|
|||
trans('admin/settings/general.show_assigned_assets')) }}
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<label class="form-control">
|
||||
{{ Form::checkbox('show_assigned_assets', '1', Request::old('show_assigned_assets', $setting->show_assigned_assets),array('class' => 'minimal')) }}
|
||||
{{ trans('general.yes') }}
|
||||
</label>
|
||||
<p class="help-block">{{ trans('admin/settings/general.show_assigned_assets_help') }}</p>
|
||||
{!! $errors->first('show_assigned_assets', '<span class="alert-msg">:message</span>') !!}
|
||||
</div>
|
||||
|
|
|
@ -42,26 +42,39 @@
|
|||
|
||||
<!-- Language -->
|
||||
<div class="form-group {{ $errors->has('site_name') ? 'error' : '' }}">
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-3 col-xs-12">
|
||||
{{ Form::label('site_name', trans('admin/settings/general.default_language')) }}
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-5 col-xs-12">
|
||||
{!! Form::locales('locale', Request::old('locale', $setting->locale), 'select2') !!}
|
||||
|
||||
{!! $errors->first('locale', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- name display format -->
|
||||
<div class="form-group {{ $errors->has('name_display_format') ? 'error' : '' }}">
|
||||
<div class="col-md-3 col-xs-12">
|
||||
{{ Form::label('name_display_format', trans('general.name_display_format')) }}
|
||||
</div>
|
||||
<div class="col-md-5 col-xs-12">
|
||||
{!! Form::name_display_format('name_display_format', Request::old('name_display_format', $setting->name_display_format), 'select2') !!}
|
||||
|
||||
{!! $errors->first('name_display_format', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- Date format -->
|
||||
<div class="form-group {{ $errors->has('time_display_format') ? 'error' : '' }}">
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-3 col-xs-12">
|
||||
{{ Form::label('time_display_format', trans('general.time_and_date_display')) }}
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-5 col-xs-12">
|
||||
{!! Form::date_display_format('date_display_format', Request::old('date_display_format', $setting->date_display_format), 'select2') !!}
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-3 col-xs-12">
|
||||
{!! Form::time_display_format('time_display_format', Request::old('time_display_format', $setting->time_display_format), 'select2') !!}
|
||||
</div>
|
||||
|
||||
|
@ -71,10 +84,10 @@
|
|||
|
||||
<!-- Currency -->
|
||||
<div class="form-group {{ $errors->has('default_currency') ? 'error' : '' }}">
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-3 col-xs-12">
|
||||
{{ Form::label('default_currency', trans('admin/settings/general.default_currency')) }}
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-9 col-xs-12">
|
||||
{{ Form::text('default_currency', old('default_currency', $setting->default_currency), array('class' => 'form-control select2-container','placeholder' => 'USD', 'maxlength'=>'3', 'style'=>'width: 60px; display: inline-block; ')) }}
|
||||
|
||||
{!! Form::digit_separator('digit_separator', old('digit_separator', $setting->digit_separator), 'select2') !!}
|
||||
|
@ -84,9 +97,6 @@
|
|||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div> <!--/.box-body-->
|
||||
|
|
Loading…
Reference in a new issue