Skip to content

A free open source IT asset/license management system

added front end barcodes to labels

Godfrey Mce987b4f6d17
diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php
index 31b4179b4a..685e91e30e 100755
--- a/app/Http/Controllers/SettingsController.php
+++ b/app/Http/Controllers/SettingsController.php
@@ -769,8 +769,11 @@ class SettingsController extends Controller
*/
public function getLabels() : View
{
+ $is_gd_installed = extension_loaded('gd');
+
return view('settings.labels')
->with('setting', Setting::getSettings())
+ ->with('is_gd_installed', $is_gd_installed)
->with('customFields', CustomField::where('field_encrypted', '=', 0)->get());
}
diff --git a/resources/views/settings/index.blade.php b/resources/views/settings/index.blade.php
index ecaf6daaa7..8834b21d90 100755
--- a/resources/views/settings/index.blade.php
+++ b/resources/views/settings/index.blade.php
@@ -186,7 +186,7 @@
</div>
</div>
</div>
- @if($settings->label2_enable == 0)
+
<div class="col-md-4 col-lg-3 col-sm-6 col-xl-1">
<div class="admin box box-default">
<div class="box-body text-center">
@@ -201,7 +201,7 @@
</div>
</div>
</div>
- @endif
+
<div class="col-md-4 col-lg-3 col-sm-6 col-xl-1">
<div class="admin box box-default">
diff --git a/resources/views/settings/labels.blade.php b/resources/views/settings/labels.blade.php
index 33640edbf2..e7f352c01b 100644
--- a/resources/views/settings/labels.blade.php
+++ b/resources/views/settings/labels.blade.php
@@ -138,7 +138,7 @@
</div>
</div>
-
+ @endif
<!-- 1D Barcode Type -->
<div class="form-group{{ $errors->has('label2_1d_type') ? ' has-error' : '' }}">
<div class="col-md-3 text-right">
@@ -197,7 +197,52 @@
</p>
</div>
</div>
+ @if($setting->label2_enable == 0)
+ <!-- QR Text -->
+ <div class="form-group{{ $errors->has('qr_text') ? ' has-error' : '' }}">
+ <div class="col-md-3 text-right">
+ {{ Form::label('qr_text', trans('admin/settings/general.qr_text'), ['class'=>'control-label']) }}
+ </div>
+ <div class="col-md-7">
+ @if ($setting->qr_code == 1)
+ {{ Form::text('qr_text', old('qr_text', $setting->qr_text), array(
+ 'class' => 'form-control',
+ 'placeholder' => 'Property of Your Company',
+ 'rel' => 'txtTooltip',
+ 'title' =>'Extra text that you would like to display on your labels.',
+ 'data-toggle' =>'tooltip',
+ 'data-placement'=>'top'
+ )) }}
+ @else
+ {{ Form::text('qr_text', old('qr_text', $setting->qr_text), array(
+ 'class' => 'form-control',
+ 'disabled' => 'disabled',
+ 'placeholder' => 'Property of Your Company'
+ )) }}
+ <p class="help-block">{{ trans('admin/settings/general.qr_help') }}</p>
+ @endif
+ {!! $errors->first('qr_text', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
+ </div>
+ </div>
+ <!-- Nuke barcode cache -->
+ <div class="form-group">
+ <div class="col-md-3 text-right">
+ {{ Form::label('purge_barcodes', 'Purge Barcodes', ['class'=>'control-label']) }}
+ </div>
+ <div class="col-md-7">
+ <a class="btn btn-default btn-sm pull-left" id="purgebarcodes" style="margin-right: 10px;">
+ {{ trans('admin/settings/general.barcode_delete_cache') }}
+ </a>
+ <span id="purgebarcodesicon"></span>
+ <span id="purgebarcodesresult"></span>
+ <span id="purgebarcodesstatus"></span>
+ {!! $errors->first('purgebarcodes', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
+ <p class="help-block">{{ trans('admin/settings/general.barcodes_help') }}</p>
+ </div>
+ </div>
+ @endif
+ @if ($setting->label2_enable)
<!-- 2D Barcode Target -->
<div class="form-group{{ $errors->has('label2_2d_target') ? ' has-error' : '' }}">
<div class="col-md-3 text-right">
@@ -227,6 +272,7 @@
@include('partials.bootstrap-table')
@else
+
<!-- Hidden version of new settings -->
{{ Form::hidden('label2_template', old('label2_template', $setting->label2_template)) }}
{{ Form::hidden('label2_title', old('label2_title', $setting->label2_title)) }}
@@ -258,6 +304,17 @@
{{ Form::hidden('labels_display_company_name', old('labels_display_company_name', $setting->labels_display_company_name)) }}
@else
<!-- Legacy settings -->
+ <style>
+ .checkbox label {
+ padding-right: 40px;
+ }
+ </style>
+
+
+ {{ Form::open(['method' => 'POST', 'files' => false, 'autocomplete' => 'off', 'class' => 'form-horizontal', 'role' => 'form' ]) }}
+ <!-- CSRF Token -->
+ {{csrf_field()}}
+
<div class="form-group{{ $errors->has('labels_per_page') ? ' has-error' : '' }}">
<div class="col-md-3 text-right">
{{ Form::label('labels_per_page', trans('admin/settings/general.labels_per_page'), ['class'=>'control-label']) }}
@@ -430,6 +487,59 @@
@stop
@push('js')
+ <script nonce="{{ csrf_token() }}">
+ // Delete barcodes
+ $("#purgebarcodes").click(function(){
+ $("#purgebarcodesrow").removeClass('text-success');
+ $("#purgebarcodesrow").removeClass('text-danger');
+ $("#purgebarcodesicon").html('');
+ $("#purgebarcodesstatus").html('');
+ $('#purgebarcodesstatus-error').html('');
+ $("#purgebarcodesicon").html('<i class="fas fa-spinner spin"></i> {{ trans('admin/settings/general.barcodes_spinner') }}');
+ $.ajax({
+ url: '{{ route('api.settings.purgebarcodes') }}',
+ type: 'POST',
+ headers: {
+ "X-Requested-With": 'XMLHttpRequest',
+ "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')
+ },
+ data: {},
+ dataType: 'json',
+
+ success: function (data) {
+ console.dir(data);
+ $("#purgebarcodesicon").html('');
+ $("#purgebarcodesstatus").html('');
+ $('#purgebarcodesstatus-error').html('');
+ $("#purgebarcodesstatus").removeClass('text-danger');
+ $("#purgebarcodesstatus").addClass('text-success');
+ if (data.message) {
+ $("#purgebarcodesstatus").html('<i class="fas fa-check text-success"></i> ' + data.message);
+ }
+ },
+
+ error: function (data) {
+
+ $("#purgebarcodesicon").html('');
+ $("#purgebarcodesstatus").html('');
+ $('#purgebarcodesstatus-error').html('');
+ $("#purgebarcodesstatus").removeClass('text-success');
+ $("#purgebarcodesstatus").addClass('text-danger');
+ $("#purgebarcodesicon").html('<i class="fas fa-exclamation-triangle text-danger"></i>');
+ $('#purgebarcodesstatus').html('Files could not be deleted.');
+ if (data.responseJSON) {
+ $('#purgebarcodesstatus-error').html('Error: ' + data.responseJSON.messages);
+ } else {
+ console.dir(data);
+ }
+
+ }
+
+
+ });
+ });
+
+ </script>
{{-- Can't use @script here because we're not in a livewire component so let's manually load --}}
@livewireScripts
@endpush
diff --git a/routes/web.php b/routes/web.php
index f3ba8350f2..a05b7aba63 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -204,7 +204,7 @@ Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuser
Route::get('barcodes', [SettingsController::class, 'getBarcodes'])->name('settings.barcodes.index');
Route::post('barcodes', [SettingsController::class, 'postBarcodes'])->name('settings.barcodes.save');
- Route::get('labels', [SettingsController::class, 'getLabels'])->name('settings.labels.index');
+ Route::get('labels', [SettingsController::class, 'getLabels', 'getBarcodes'])->name('settings.labels.index');
Route::post('labels', [SettingsController::class, 'postLabels'])->name('settings.labels.save');
Route::get('ldap', [SettingsController::class, 'getLdapSettings'])->name('settings.ldap.index');