Merge branch 'develop'

This commit is contained in:
snipe 2018-01-24 11:00:40 -08:00
commit 426bf3803b
12 changed files with 101 additions and 10 deletions

View file

@ -194,6 +194,7 @@ class AssetModelsController extends Controller
'models.category_id',
])->with('manufacturer','category');
$settings = \App\Models\Setting::getSettings();
if ($request->has('search')) {
$assetmodels = $assetmodels->SearchByManufacturerOrCat($request->input('search'));
@ -202,8 +203,24 @@ class AssetModelsController extends Controller
$assetmodels = $assetmodels->OrderCategory('ASC')->OrderManufacturer('ASC')->orderby('models.name', 'asc')->orderby('models.model_number', 'asc')->paginate(50);
foreach ($assetmodels as $assetmodel) {
$assetmodel->use_text = (($assetmodel->category) ? e($assetmodel->category->name) : '').': '.$assetmodel->present()->modelName;
$assetmodel->use_image = ($assetmodel->image) ? url('/').'/uploads/models/'.$assetmodel->image : null;
$assetmodel->use_text = '';
if ($settings->modellistCheckedValue('category')) {
$assetmodel->use_text .= (($assetmodel->category) ? e($assetmodel->category->name).' - ' : '');
}
if ($settings->modellistCheckedValue('manufacturer')) {
$assetmodel->use_text .= (($assetmodel->manufacturer) ? e($assetmodel->manufacturer->name).' ' : '');
}
$assetmodel->use_text .= e($assetmodel->name);
if (($settings->modellistCheckedValue('model_number')) && ($assetmodel->model_number!='')) {
$assetmodel->use_text .= ' (#'.e($assetmodel->model_number).')';
}
$assetmodel->use_image = ($settings->modellistCheckedValue('image') && ($assetmodel->image)) ? url('/').'/uploads/models/'.$assetmodel->image : null;
}
return (new SelectlistTransformer)->transformSelectlist($assetmodels);

View file

@ -575,6 +575,7 @@ class AssetsController extends Controller
$data['log_id'] = $logaction->id;
$data['first_name'] = get_class($target) == User::class ? $target->first_name : '';
$data['last_name'] = get_class($target) == User::class ? $target->last_name : '';
$data['item_name'] = $asset->present()->name();
$data['checkin_date'] = $logaction->created_at;
$data['item_tag'] = $asset->asset_tag;

View file

@ -314,6 +314,14 @@ class SettingsController extends Controller
return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error'));
}
$setting->modellist_displays = '';
if (($request->has('show_in_model_list')) && (count($request->has('show_in_model_list')) > 0))
{
$setting->modellist_displays = implode(',', $request->input('show_in_model_list'));
}
$setting->full_multiple_companies_support = $request->input('full_multiple_companies_support', '0');
$setting->load_remote = $request->input('load_remote', '0');
$setting->show_archived_in_list = $request->input('show_archived_in_list', '0');

View file

@ -86,6 +86,23 @@ class Setting extends Model
return null;
}
public function modellistCheckedValue ($element) {
// If the value is blank for some reason
if ($this->modellist_displays=='') {
return false;
}
$values = explode(',', $this->modellist_displays);
foreach ($values as $value) {
if ($value == $element) {
return true;
}
}
return false;
}
/**
* Escapes the custom CSS, and then un-escapes the greater-than symbol
* so it can work with direct descendant characters for bootstrap

View file

@ -26,7 +26,7 @@ class AddDashboardMessageToSettings extends Migration
public function down()
{
Schema::table('settings', function (Blueprint $table) {
$table->text('dashboard_message');
$table->dropColumn('dashboard_message');
});
}
}

View file

@ -27,8 +27,8 @@ class AddFooterSettingsToSettings extends Migration
public function down()
{
Schema::table('settings', function (Blueprint $table) {
$table->text('support_footer');
$table->text('footer_text');
$table->dropColumn('support_footer');
$table->dropColumn('footer_text');
});
}
}

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddModellistPreferenc extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('settings', function (Blueprint $table) {
$table->char('modellist_displays')->nullable()->default('image,category,manufacturer,model_number');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('settings', function (Blueprint $table) {
$table->dropColumn('modellist_displays');
});
}
}

View file

@ -17,7 +17,7 @@ else
fi
# create data directories
for dir in 'data/private_uploads' 'data/uploads' 'data/uploads/avatars' 'data/uploads/barcodes' 'data/uploads/models' 'data/uploads/suppliers' 'dumps'; do
for dir in 'data/private_uploads' 'data/uploads' 'data/uploads/avatars' 'data/uploads/barcodes' 'data/uploads/categories' 'data/uploads/companies' 'data/uploads/departments' 'data/uploads/locations' 'data/uploads/manufacturers' 'data/uploads/models' 'data/uploads/suppliers' 'dumps'; do
mkdir -p "/var/lib/snipeit/$dir"
done

View file

@ -81,6 +81,7 @@ return array(
'logo' => 'Logo',
'full_multiple_companies_support_help_text' => 'Restricting users (including admins) assigned to companies to their company\'s assets.',
'full_multiple_companies_support_text' => 'Full Multiple Companies Support',
'show_in_model_list' => 'Show in Model Dropdowns',
'optional' => 'optional',
'per_page' => 'Results Per Page',
'php' => 'PHP Version',

View file

@ -1,7 +1,7 @@
@extends('emails/layouts/default')
@section('content')
<p>{{ trans('mail.hello') }} {{ $first_name }},</p>
<p>{{ trans('mail.hello') }} {{ $first_name }} {{ $last_name }},</p>
<p>{{ trans('mail.the_following_item') }}

View file

@ -99,7 +99,7 @@
@if ($asset->purchase_cost > 0)
<td class="align-right">
@if ($asset->location )
@if ($asset->location && $asset->location->currency)
{{ $asset->location->currency }}
@else
{{ $snipeSettings->default_currency }}
@ -107,7 +107,7 @@
{{ \App\Helpers\Helper::formatCurrencyOutput($asset->purchase_cost) }}
</td>
<td class="align-right">
@if ($asset->location )
@if ($asset->location && $asset->location->currency)
{{ $asset->location->currency }}
@else
{{ $snipeSettings->default_currency }}
@ -116,7 +116,7 @@
{{ \App\Helpers\Helper::formatCurrencyOutput($asset->getDepreciatedValue()) }}
</td>
<td class="align-right">
@if ($asset->location)
@if ($asset->location && $asset->location->currency)
{{ $asset->location->currency }}
@else
{{ $snipeSettings->default_currency }}

View file

@ -237,6 +237,21 @@
</div>
</div>
<!-- Model List prefs -->
<div class="form-group {{ $errors->has('show_in_model_list') ? 'error' : '' }}">
<div class="col-md-3">
{{ Form::label('show_in_model_list',
trans('admin/settings/general.show_in_model_list')) }}
</div>
<div class="col-md-9">
{{ Form::checkbox('show_in_model_list[]', 'image', Input::old('show_in_model_list', $snipeSettings->modellistCheckedValue('image')),array('class' => 'minimal')) }} {{ trans('general.image') }} <br>
{{ Form::checkbox('show_in_model_list[]', 'category', Input::old('show_in_model_list', $snipeSettings->modellistCheckedValue('category')),array('class' => 'minimal')) }} {{ trans('general.category') }} <br>
{{ Form::checkbox('show_in_model_list[]', 'manufacturer', Input::old('show_in_model_list', $snipeSettings->modellistCheckedValue('manufacturer')),array('class' => 'minimal')) }} {{ trans('general.manufacturer') }} <br>
{{ Form::checkbox('show_in_model_list[]', 'model_number', Input::old('show_in_model_list', $snipeSettings->modellistCheckedValue('model_number')),array('class' => 'minimal')) }} {{ trans('general.model_no') }}<br>
</div>
</div>
<!-- /.form-group -->
</div> <!--/.box-body-->
<div class="box-footer">
<div class="text-left col-md-6">