Skip to content

A free open source IT asset/license management system

Added ability to upload favicon and email logo

snipe09c4dd4891ab
diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php
index c1f4c9cedf..78fb759bde 100755
--- a/app/Http/Controllers/SettingsController.php
+++ b/app/Http/Controllers/SettingsController.php
@@ -433,6 +433,60 @@ class SettingsController extends Controller
}
}
+ // If the user wants to clear the email logo...
+ if ('1' == $request->input('clear_email_logo')) {
+ Storage::disk('public')->delete($setting->email_logo);
+ $setting->email_logo = null;
+
+ // If they are uploading an image, validate it and upload it
+ } elseif ($request->hasFile('email_logo')) {
+ $email_image = $request->file('email_logo');
+ $email_ext = $image->getClientOriginalExtension();
+ $setting->email_logo = $email_file_name = 'email_logo.' . $email_ext;
+
+ if ('svg' != $email_image->getClientOriginalExtension()) {
+ $email_upload = Image::make($email_image->getRealPath())->resize(null, 100, function($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ });
+ }
+
+ // This requires a string instead of an object, so we use ($string)
+ Storage::disk('public')->put($email_file_name, (string) $email_upload->encode());
+
+ // Remove Current image if exists
+ if (($setting->email_logo) && (file_exists($email_file_name))) {
+ Storage::disk('public')->delete($email_file_name);
+ }
+ }
+
+ // If the user wants to clear the favicon...
+ if ('1' == $request->input('clear_favicon')) {
+ Storage::disk('public')->delete($setting->clear_favicon);
+ $setting->favicon = null;
+
+ // If they are uploading an image, validate it and upload it
+ } elseif ($request->hasFile('favicon')) {
+ $favicon_image = $request->file('favicon');
+ $favicon_ext = $favicon_image->getClientOriginalExtension();
+ $setting->favicon = $favicon_file_name = 'favicon.' . $favicon_ext;
+
+ if ('svg' != $favicon_image->getClientOriginalExtension()) {
+ $favicon_upload = Image::make($favicon_image->getRealPath())->resize(null, 16, function($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ });
+ }
+
+ // This requires a string instead of an object, so we use ($string)
+ Storage::disk('public')->put($favicon_file_name, (string) $favicon_upload->encode());
+
+ // Remove Current image if exists
+ if (($setting->favicon) && (file_exists($favicon_file_name))) {
+ Storage::disk('public')->delete($favicon_file_name);
+ }
+ }
+
if ($setting->save()) {
return redirect()->route('settings.index')
->with('success', trans('admin/settings/message.update.success'));
diff --git a/database/migrations/2018_12_05_211936_add_favicon_to_settings.php b/database/migrations/2018_12_05_211936_add_favicon_to_settings.php
new file mode 100644
index 0000000000..570eb53926
--- /dev/null
+++ b/database/migrations/2018_12_05_211936_add_favicon_to_settings.php
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddFaviconToSettings extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('settings', function (Blueprint $table) {
+ $table->char('favicon')->nullable()->default(null);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('settings', function (Blueprint $table) {
+ $table->dropColumn('favicon');
+ });
+ }
+}
diff --git a/database/migrations/2018_12_05_212119_add_email_logo_to_settings.php b/database/migrations/2018_12_05_212119_add_email_logo_to_settings.php
new file mode 100644
index 0000000000..fd3a89170d
--- /dev/null
+++ b/database/migrations/2018_12_05_212119_add_email_logo_to_settings.php
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddEmailLogoToSettings extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('settings', function (Blueprint $table) {
+ $table->char('email_logo')->nullable()->default(null);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('settings', function (Blueprint $table) {
+ $table->dropColumn('email_logo');
+ });
+ }
+}
diff --git a/resources/lang/en/admin/settings/general.php b/resources/lang/en/admin/settings/general.php
index 252589705d..6df5fc4ba1 100644
--- a/resources/lang/en/admin/settings/general.php
+++ b/resources/lang/en/admin/settings/general.php
@@ -31,17 +31,22 @@ return array(
'dashboard_message_help' => 'This text will appear on the dashboard for anyone with permission to view the dashboard.',
'default_currency' => 'Default Currency',
'default_eula_text' => 'Default EULA',
- 'default_language' => 'Default Language',
+ 'default_language' => 'Default Language',
'default_eula_help_text' => 'You can also associate custom EULAs to specific asset categories.',
'display_asset_name' => 'Display Asset Name',
'display_checkout_date' => 'Display Checkout Date',
'display_eol' => 'Display EOL in table view',
'display_qr' => 'Display Square Codes',
'display_alt_barcode' => 'Display 1D barcode',
+ 'email_logo' => 'Email Logo',
'barcode_type' => '2D Barcode Type',
'alt_barcode_type' => '1D barcode type',
+ 'email_logo_size' => 'Square logos in email look best.',
'eula_settings' => 'EULA Settings',
'eula_markdown' => 'This EULA allows <a href="https://help.github.com/articles/github-flavored-markdown/">Github flavored markdown</a>.',
+ 'favicon' => 'Favicon',
+ 'favicon_format' => 'Accepted filetypes are ico, png, and gif. Other image formats may not work in all browsers.',
+ 'favicon_size' => 'Favicons should be square images, 16x16 pixels.',
'footer_text' => 'Additional Footer Text ',
'footer_text_help' => 'This text will appear in the right-side footer. Links are allowed using <a href="https://help.github.com/articles/github-flavored-markdown/">Github flavored markdown</a>. Line breaks, headers, images, etc may result in unpredictable results.',
'general_settings' => 'General Settings',
diff --git a/resources/views/layouts/basic.blade.php b/resources/views/layouts/basic.blade.php
index 4942c24041..0825e71fb4 100644
--- a/resources/views/layouts/basic.blade.php
+++ b/resources/views/layouts/basic.blade.php
@@ -8,10 +8,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ ($snipeSettings) && ($snipeSettings->site_name) ? $snipeSettings->site_name : 'Snipe-IT' }}</title>
-
+ <link rel="shortcut icon" type="image/ico" href="{{ ($snipeSettings) && ($snipeSettings->favicon!='') ? Storage::disk('public')->url('').e($snipeSettings->favicon) : 'favicon.ico' }} ">
{{-- stylesheets --}}
<link rel="stylesheet" href="{{ mix('css/all.css') }}">
- <link rel="shortcut icon" type="image/ico" href="{{ url(asset('favicon.ico')) }}">
+
@if (($snipeSettings) && ($snipeSettings->header_color))
diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php
index 169033ed73..d819020b83 100644
--- a/resources/views/layouts/default.blade.php
+++ b/resources/views/layouts/default.blade.php
@@ -11,7 +11,7 @@
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<meta name="csrf-token" content="{{ csrf_token() }}">
- <link rel="shortcut icon" type="image/ico" href="{{ url(asset('favicon.ico')) }}">
+ <link rel="shortcut icon" type="image/ico" href="{{ ($snipeSettings) && ($snipeSettings->favicon!='') ? Storage::disk('public')->url('').e($snipeSettings->favicon) : 'favicon.ico' }} ">
<script nonce="{{ csrf_token() }}">
window.Laravel = { csrfToken: '{{ csrf_token() }}' };
diff --git a/resources/views/settings/branding.blade.php b/resources/views/settings/branding.blade.php
index f23a1b1467..a478824212 100644
--- a/resources/views/settings/branding.blade.php
+++ b/resources/views/settings/branding.blade.php
@@ -57,6 +57,18 @@
</div>
+
+ <!-- Branding -->
+ <div class="form-group {{ $errors->has('brand') ? 'error' : '' }}">
+ <div class="col-md-3">
+ {{ Form::label('brand', trans('admin/settings/general.brand')) }}
+ </div>
+ <div class="col-md-9">
+ {!! Form::select('brand', array('1'=>'Text','2'=>'Logo','3'=>'Logo + Text'), Input::old('brand', $setting->brand), array('class' => 'form-control select2', 'style'=>'width: 150px ;')) !!}
+ {!! $errors->first('brand', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
+
<!-- Logo -->
<div class="form-group {{ $errors->has('image') ? 'has-error' : '' }}">
@@ -70,7 +82,10 @@
</label>
<span class='label label-default' id="upload-file-info"></span>
- <p class="help-block" id="upload-file-status">{{ trans('general.image_filetypes_help', ['size' => \App\Helpers\Helper::file_upload_max_size_readable()]) }} {{ trans('general.logo_size') }}</p>
+ <p class="help-block" id="upload-file-status">
+ {{ trans('general.logo_size') }}
+ {{ trans('general.image_filetypes_help', ['size' => \App\Helpers\Helper::file_upload_max_size_readable()]) }}
+ </p>
{!! $errors->first('image', '<span class="alert-msg">:message</span>') !!}
</div>
@@ -87,18 +102,63 @@
@endif
</div>
+ <!-- Email Logo -->
+ <div class="form-group {{ $errors->has('email_logo') ? 'has-error' : '' }}">
+ <label class="col-md-3" for="image">
+ {{ Form::label('email_logo', trans('admin/settings/general.email_logo')) }}</label>
+
+ <div class="col-md-9">
+ <label class="btn btn-default">
+ {{ trans('button.select_file') }}
+ <input type="file" name="email_logo" data-maxsize="{{ \App\Helpers\Helper::file_upload_max_size() }}" accept="image/gif,image/jpeg,image/png,image/svg" style="display:none; max-width: 90%">
+ </label>
+ <span class='label label-default' id="email-upload-file-info"></span>
+
+ <p class="help-block">
+ {{ trans('admin/settings/general.email_logo_size') }}
+ {{ trans('general.image_filetypes_help', ['size' => \App\Helpers\Helper::file_upload_max_size_readable()]) }} </p>
+ {!! $errors->first('image', '<span class="alert-msg">:message</span>') !!}
- <!-- Branding -->
- <div class="form-group {{ $errors->has('brand') ? 'error' : '' }}">
- <div class="col-md-3">
- {{ Form::label('brand', trans('admin/settings/general.brand')) }}
</div>
+
+ @if ($setting->email_logo!='')
+ <div class="col-md-9 col-md-offset-3">
+
+ {{ Form::checkbox('clear_email_logo', '1', Input::old('clear_email_logo'),array('class' => 'minimal')) }} Remove current image
+
+ </div>
+ @endif
+ </div>
+
+ <!-- Favicon -->
+ <div class="form-group {{ $errors->has('favicon') ? 'has-error' : '' }}">
+ <label class="col-md-3" for="image">
+ {{ Form::label('favicon', trans('admin/settings/general.favicon')) }}</label>
+
<div class="col-md-9">
- {!! Form::select('brand', array('1'=>'Text','2'=>'Logo','3'=>'Logo + Text'), Input::old('brand', $setting->brand), array('class' => 'form-control select2', 'style'=>'width: 150px ;')) !!}
- {!! $errors->first('brand', '<span class="alert-msg">:message</span>') !!}
+ <label class="btn btn-default">
+ {{ trans('button.select_file') }}
+ <input type="file" name="favicon" data-maxsize="1000" accept="image/x-icon,image/gif,image/jpeg,image/png,image/svg" style="display:none; max-width: 90%">
+ </label>
+ <span class='label label-default' id="favicon-upload-file-info"></span>
+
+ <p class="help-block">{{ trans('admin/settings/general.favicon_size') }}
+ {{ trans('admin/settings/general.favicon_format') }} </p>
+ {!! $errors->first('favicon', '<span class="alert-msg">:message</span>') !!}
+
</div>
+
+ @if ($setting->email_logo!='')
+ <div class="col-md-9 col-md-offset-3">
+
+ {{ Form::checkbox('clear_favicon', '1', Input::old('clear_favicon'),array('class' => 'minimal')) }} Remove current favicon
+
+ </div>
+ @endif
</div>
+
+
<!-- Include logo in print assets -->
<div class="form-group">
<div class="col-md-3">
diff --git a/resources/views/vendor/mail/html/header.blade.php b/resources/views/vendor/mail/html/header.blade.php
index fe93f44a99..7e884285bd 100644
--- a/resources/views/vendor/mail/html/header.blade.php
+++ b/resources/views/vendor/mail/html/header.blade.php
@@ -1,22 +1,35 @@
<tr>
<td class="header"{!! ($snipeSettings->header_color!='') ? ' style="background-color: '.e($snipeSettings->header_color).'"' : '' !!}>
+
@if (($snipeSettings->show_images_in_email=='1' ) && ($snipeSettings::setupCompleted()))
+ <!-- show text and logo -->
@if ($snipeSettings->brand == '3')
- @if ($snipeSettings->logo!='')
- <img class="navbar-brand-img logo" src="{{ Storage::disk('public')->url('').e($snipeSettings->logo) }}"alt="{{ $snipeSettings->site_name }}">
+ @if ($snipeSettings->email_logo!='')
+ <img class="logo-text" src="{{ Storage::disk('public')->url('').e($snipeSettings->email_logo) }}"alt="{{ $snipeSettings->site_name }}">
+ @elseif ($snipeSettings->logo!='')
+ <img class="logo-text" src="{{ Storage::disk('public')->url('').e($snipeSettings->logo) }}"alt="{{ $snipeSettings->site_name }}">
@endif
- {{ $snipeSettings->site_name }}
+ {{ $snipeSettings->site_name }}
+
+
+ <!-- show only logo -->
@elseif ($snipeSettings->brand == '2')
- @if ($snipeSettings->logo!='')
- <img class="navbar-brand-img logo" src="{{ Storage::disk('public')->url('').e($snipeSettings->logo) }}" alt="{{ $snipeSettings->site_name }}">
+ @if ($snipeSettings->email_logo!='')
+ <img class="logo-only" style="float:left" src="{{ Storage::disk('public')->url('').e($snipeSettings->email_logo) }}" alt="{{ $snipeSettings->site_name }}">
+ @elseif ($snipeSettings->logo!='')
+ <img class="logo-only" src="{{ Storage::disk('public')->url('').e($snipeSettings->logo) }}" alt="{{ $snipeSettings->site_name }}">
@endif
+
+ <!-- show only text -->
@else
{{ $snipeSettings->site_name }}
@endif
+
+
@else
- Snipe-IT
+ {{ $snipeSettings->site_name }}
@endif
</td>
</tr>
diff --git a/resources/views/vendor/mail/html/themes/default.css b/resources/views/vendor/mail/html/themes/default.css
index 1949363b08..bcd1d5c7cc 100644
--- a/resources/views/vendor/mail/html/themes/default.css
+++ b/resources/views/vendor/mail/html/themes/default.css
@@ -105,6 +105,7 @@ img {
.header {
padding: 25px 0;
text-align: center;
+ font-size: 20px;
}
.header a {
@@ -282,3 +283,16 @@ img {
font-size: 15px;
text-align: center;
}
+
+.logo-text {
+ max-width: 150px;
+ max-height: 150px;
+ vertical-align:middle;
+}
+
+.logo-only {
+ max-width: 640px;
+ max-height: 150px;
+ vertical-align:middle;
+}
+