diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 52eb751a8939..98f4b7e38e29 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -538,7 +538,7 @@ public function getQrCode($assetId = null) : Response | BinaryFileResponse | str if ($settings->qr_code == '1') { $asset = Asset::withTrashed()->find($assetId); if ($asset) { - $size = Helper::barcodeDimensions($settings->barcode_type); + $size = Helper::barcodeDimensions($settings->label2_2d_type); $qr_file = public_path().'/uploads/barcodes/qr-'.str_slug($asset->asset_tag).'-'.str_slug($asset->id).'.png'; if (isset($asset->id, $asset->asset_tag)) { @@ -548,7 +548,7 @@ public function getQrCode($assetId = null) : Response | BinaryFileResponse | str return response()->file($qr_file, $header); } else { $barcode = new \Com\Tecnick\Barcode\Barcode(); - $barcode_obj = $barcode->getBarcodeObj($settings->barcode_type, route('hardware.show', $asset->id), $size['height'], $size['width'], 'black', [-2, -2, -2, -2]); + $barcode_obj = $barcode->getBarcodeObj($settings->label2_2d_type, route('hardware.show', $asset->id), $size['height'], $size['width'], 'black', [-2, -2, -2, -2]); file_put_contents($qr_file, $barcode_obj->getPngData()); return response($barcode_obj->getPngData())->header('Content-type', 'image/png'); @@ -573,7 +573,7 @@ public function getBarCode($assetId = null) { $settings = Setting::getSettings(); if ($asset = Asset::withTrashed()->find($assetId)) { - $barcode_file = public_path().'/uploads/barcodes/'.str_slug($settings->alt_barcode).'-'.str_slug($asset->asset_tag).'.png'; + $barcode_file = public_path().'/uploads/barcodes/'.str_slug($settings->label2_1d_type).'-'.str_slug($asset->asset_tag).'.png'; if (isset($asset->id, $asset->asset_tag)) { if (file_exists($barcode_file)) { @@ -586,7 +586,7 @@ public function getBarCode($assetId = null) $barcode = new \Com\Tecnick\Barcode\Barcode(); try { - $barcode_obj = $barcode->getBarcodeObj($settings->alt_barcode, $asset->asset_tag, ($barcode_width < 300 ? $barcode_width : 300), 50); + $barcode_obj = $barcode->getBarcodeObj($settings->label2_1d_type, $asset->asset_tag, ($barcode_width < 300 ? $barcode_width : 300), 50); file_put_contents($barcode_file, $barcode_obj->getPngData()); return response($barcode_obj->getPngData())->header('Content-type', 'image/png'); diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 2186a3fc76f6..b89a221faa07 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -695,48 +695,6 @@ public function postAssetTags(Request $request) : RedirectResponse return redirect()->back()->withInput()->withErrors($setting->getErrors()); } - /** - * Return a form to allow a super admin to update settings. - * - * @author [A. Gianotto] [] - * - * @since [v1.0] - */ - public function getBarcodes() : View - { - $setting = Setting::getSettings(); - $is_gd_installed = extension_loaded('gd'); - - return view('settings.barcodes', compact('setting'))->with('is_gd_installed', $is_gd_installed); - } - - /** - * Saves settings from form. - * - * @author [A. Gianotto] [] - * - * @since [v1.0] - */ - public function postBarcodes(Request $request) : RedirectResponse - { - if (is_null($setting = Setting::getSettings())) { - return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error')); - } - - $setting->qr_code = $request->input('qr_code', '0'); - $setting->alt_barcode = $request->input('alt_barcode'); - $setting->alt_barcode_enabled = $request->input('alt_barcode_enabled', '0'); - $setting->barcode_type = $request->input('barcode_type'); - $setting->qr_text = $request->input('qr_text'); - - if ($setting->save()) { - return redirect()->route('settings.index') - ->with('success', trans('admin/settings/message.update.success')); - } - - return redirect()->back()->withInput()->withErrors($setting->getErrors()); - } - /** * Return a form to allow a super admin to update settings. * @@ -762,8 +720,11 @@ public function getPhpInfo() : View | RedirectResponse */ 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()); } @@ -799,9 +760,13 @@ public function postLabels(StoreLabelSettings $request) : RedirectResponse $setting->labels_pagewidth = $request->input('labels_pagewidth'); $setting->labels_pageheight = $request->input('labels_pageheight'); $setting->labels_display_company_name = $request->input('labels_display_company_name', '0'); - $setting->labels_display_company_name = $request->input('labels_display_company_name', '0'); - + //Barcodes + $setting->qr_code = $request->input('qr_code', '0'); + //1D-Barcode + $setting->alt_barcode_enabled = $request->input('alt_barcode_enabled', '0'); + //QR-Code + $setting->qr_text = $request->input('qr_text'); if ($request->filled('labels_display_name')) { $setting->labels_display_name = 1; diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php index ce3299e7d160..8e9c6c25653f 100644 --- a/app/Listeners/CheckoutableListener.php +++ b/app/Listeners/CheckoutableListener.php @@ -282,7 +282,7 @@ private function getCheckoutMailType($event, $acceptance){ ]; $mailable= $lookup[get_class($event->checkoutable)]; - return new $mailable($event->checkoutable, $event->checkedOutTo, $event->checkedOutBy, $event->note, $acceptance); + return new $mailable($event->checkoutable, $event->checkedOutTo, $event->checkedOutBy, $acceptance, $event->note); } private function getCheckinMailType($event){ diff --git a/app/Mail/CheckoutAccessoryMail.php b/app/Mail/CheckoutAccessoryMail.php index f7996c543062..64c02e31ed1c 100644 --- a/app/Mail/CheckoutAccessoryMail.php +++ b/app/Mail/CheckoutAccessoryMail.php @@ -21,7 +21,7 @@ class CheckoutAccessoryMail extends Mailable /** * Create a new message instance. */ - public function __construct(Accessory $accessory, $checkedOutTo, User $checkedOutBy,$note, $acceptance) + public function __construct(Accessory $accessory, $checkedOutTo, User $checkedOutBy, $acceptance, $note) { $this->item = $accessory; $this->admin = $checkedOutBy; diff --git a/app/Mail/CheckoutAssetMail.php b/app/Mail/CheckoutAssetMail.php index 71688ecb30f8..680014dcd189 100644 --- a/app/Mail/CheckoutAssetMail.php +++ b/app/Mail/CheckoutAssetMail.php @@ -23,7 +23,7 @@ class CheckoutAssetMail extends Mailable /** * Create a new message instance. */ - public function __construct(Asset $asset, $checkedOutTo, User $checkedOutBy, $note, $acceptance) + public function __construct(Asset $asset, $checkedOutTo, User $checkedOutBy, $acceptance, $note) { $this->item = $asset; $this->admin = $checkedOutBy; diff --git a/app/Mail/CheckoutLicenseMail.php b/app/Mail/CheckoutLicenseMail.php index cc91f990e1d6..9462c6c332c4 100644 --- a/app/Mail/CheckoutLicenseMail.php +++ b/app/Mail/CheckoutLicenseMail.php @@ -27,7 +27,6 @@ public function __construct(LicenseSeat $licenseSeat, $checkedOutTo, User $check $this->note = $note; $this->target = $checkedOutTo; $this->acceptance = $acceptance; - $this->settings = Setting::getSettings(); } diff --git a/database/migrations/2024_10_31_212512_update_new_and_drop_old_barcode_settings.php b/database/migrations/2024_10_31_212512_update_new_and_drop_old_barcode_settings.php new file mode 100644 index 000000000000..a802f042909c --- /dev/null +++ b/database/migrations/2024_10_31_212512_update_new_and_drop_old_barcode_settings.php @@ -0,0 +1,46 @@ +whereNull('label2_2d_type')->orWhere('label2_2d_type', '')->update([ + 'label2_2d_type' => DB::raw('barcode_type') + ]); + + DB::table('settings')->whereNull('label2_1d_type')->orWhere('label2_1d_type', '')->update([ + 'label2_1d_type' => DB::raw('alt_barcode') + ]); + + + Schema::table('settings', function (Blueprint $table) { + $table->dropColumn(['barcode_type', 'alt_barcode']); + }); + } + + public function down() + { + Schema::table('settings', function (Blueprint $table) { + // Re-add the columns that were dropped in case of rollback + $table->string('barcode_type')->nullable(); + $table->string('alt_barcode')->nullable(); + }); + + DB::table('settings')->whereNull('barcode_type')->orWhere('barcode_type', '')->update([ + 'barcode_type' => DB::raw('label2_2d_type') + ]); + + DB::table('settings')->whereNull('alt_barcode')->orWhere('alt_barcode', '')->update([ + 'alt_barcode' => DB::raw('label2_1d_type') + ]); + } +}; diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php index db8340246367..d818bd5f85d9 100644 --- a/resources/lang/en-US/admin/settings/general.php +++ b/resources/lang/en-US/admin/settings/general.php @@ -55,7 +55,7 @@ '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_qr' => 'Display 2D barcode', 'display_alt_barcode' => 'Display 1D barcode', 'email_logo' => 'Email Logo', 'barcode_type' => '2D Barcode Type', diff --git a/resources/views/hardware/labels.blade.php b/resources/views/hardware/labels.blade.php index ab4cb5e339f3..0d675d3beb78 100644 --- a/resources/views/hardware/labels.blade.php +++ b/resources/views/hardware/labels.blade.php @@ -11,7 +11,7 @@ $settings->labels_width = $settings->labels_width - $settings->labels_display_sgutter; $settings->labels_height = $settings->labels_height - $settings->labels_display_bgutter; // Leave space on bottom for 1D barcode if necessary -$qr_size = ($settings->alt_barcode_enabled=='1') && ($settings->alt_barcode!='') ? $settings->labels_height - .3 : $settings->labels_height - 0.1; +$qr_size = ($settings->alt_barcode_enabled=='1') && ($settings->label2_1d_type!='') ? $settings->labels_height - .3 : $settings->labels_height - 0.1; ?> - - - {{ Form::open(['method' => 'POST', 'files' => false, 'autocomplete' => 'off', 'class' => 'form-horizontal', 'role' => 'form' ]) }} - - {{csrf_field()}} - -
-
- - -
-
-

- - {{ trans('admin/settings/general.barcodes') }} -

-
-
- - -
- - @if ($is_gd_installed) - -
-
- -
-
- - -
-
- {{ Form::label('barcode_type', trans('admin/settings/general.barcode_type')) }} -
-
- {!! Form::barcode_types('barcode_type', old('barcode_type', $setting->barcode_type), 'select2 col-md-4') !!} - {!! $errors->first('barcode_type', '') !!} -
-
- - -
- -
- -
-
- - -
-
- {{ Form::label('alt_barcode', trans('admin/settings/general.alt_barcode_type')) }} -
-
- {!! Form::alt_barcode_types('alt_barcode', old('alt_barcode', $setting->alt_barcode), 'select2 col-md-4') !!} - {!! $errors->first('barcode_type', '') !!} -
-
- @else - - {{ trans('admin/settings/general.php_gd_warning') }} -
- {{ trans('admin/settings/general.php_gd_info') }} -
- @endif - - -
-
- {{ Form::label('qr_text', trans('admin/settings/general.qr_text')) }} -
-
- @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')) }} - {!! $errors->first('qr_text', '') !!} - @else - {{ Form::text('qr_text', old('qr_text', $setting->qr_text), array('class' => 'form-control', 'disabled'=>'disabled','placeholder' => 'Property of Your Company')) }} -

{{ trans('admin/settings/general.qr_help') }}

- @endif -
-
- - -
-
- {{ Form::label('purge_barcodes', 'Purge Barcodes') }} -
- -
-
-
-
-

{{ trans('admin/settings/general.barcodes_help') }}

-
- -
- - -
- -
- -
-
-
- - {{Form::close()}} - -@stop - -@push('js') - - - -@endpush diff --git a/resources/views/settings/index.blade.php b/resources/views/settings/index.blade.php index fd2877774bec..40a0178649f2 100755 --- a/resources/views/settings/index.blade.php +++ b/resources/views/settings/index.blade.php @@ -187,21 +187,6 @@ -
-
-
-
- - -

- {{ trans('admin/settings/general.barcodes') }} -
-
-

{!! trans('admin/settings/general.barcodes_help_overview') !!}

-
-
-
-
diff --git a/resources/views/settings/labels.blade.php b/resources/views/settings/labels.blade.php index 33640edbf28a..46212b790daf 100644 --- a/resources/views/settings/labels.blade.php +++ b/resources/views/settings/labels.blade.php @@ -138,66 +138,141 @@ class="table table-striped snipe-table"
+ @endif + @if($setting->label2_enable == 0) + @if ($is_gd_installed) + +
- -
-
- {{ Form::label('label2_1d_type', trans('admin/settings/general.label2_1d_type'), ['class'=>'control-label']) }} -
-
- @php - $select1DValues = [ - 'C128' => 'C128', - 'C39' => 'C39', - 'EAN5' => 'EAN5', - 'EAN13' => 'EAN13', - 'UPCA' => 'UPCA', - 'UPCE' => 'UPCE', - 'none' => trans('admin/settings/general.none'), - ]; - @endphp - {{ Form::select('label2_1d_type', $select1DValues, old('label2_1d_type', $setting->label2_1d_type), [ 'class'=>'select2 col-md-4', 'aria-label'=>'label2_1d_type' ]) }} - {!! $errors->first('label2_1d_type', '') !!} -

- {{ trans('admin/settings/general.label2_1d_type_help') }}. - {!! - trans('admin/settings/general.help_default_will_use', [ - 'default' => trans('admin/settings/general.default'), - 'setting_name' => trans('admin/settings/general.barcodes').' > '.trans('admin/settings/general.alt_barcode_type'), - ]) - !!} -

+
+
+ @endif + @endif + +
+
+ {{ Form::label('label2_1d_type', trans('admin/settings/general.label2_1d_type'), ['class'=>'control-label']) }} +
+
+ @php + $select1DValues = [ + 'C128' => 'C128', + 'C39' => 'C39', + 'EAN5' => 'EAN5', + 'EAN13' => 'EAN13', + 'UPCA' => 'UPCA', + 'UPCE' => 'UPCE', + 'none' => trans('admin/settings/general.none'), + ]; + @endphp + {{ Form::select('label2_1d_type', $select1DValues, old('label2_1d_type', $setting->label2_1d_type), [ 'class'=>'select2 col-md-4', 'aria-label'=>'label2_1d_type' ]) }} + {!! $errors->first('label2_1d_type', '') !!} +

+ {{ trans('admin/settings/general.label2_1d_type_help') }}. + {!! + trans('admin/settings/general.help_default_will_use', [ + 'default' => trans('admin/settings/general.default'), + 'setting_name' => trans('admin/settings/general.barcodes').' > '.trans('admin/settings/general.alt_barcode_type'), + ]) + !!} +

+
+
+ @if($setting->label2_enable == 0) - -
-
- {{ Form::label('label2_2d_type', trans('admin/settings/general.label2_2d_type'), ['class'=>'control-label']) }} + +
+
+ +
+
+ @endif + +
+
+ {{ Form::label('label2_2d_type', trans('admin/settings/general.label2_2d_type'), ['class'=>'control-label']) }} +
+
+ @php + $select2DValues = [ + 'QRCODE' => 'QRCODE', + ]; + if ($setting->label2_enable == 1) { + $select2DValues['PDF417'] = 'PDF417'; + } + $select2DValues = array_merge($select2DValues, [ + 'DATAMATRIX' => 'DATAMATRIX', + 'none' => trans('admin/settings/general.none'), + ]); + @endphp + {{ Form::select('label2_2d_type', $select2DValues, old('label2_2d_type', $setting->label2_2d_type), [ 'class'=>'select2 col-md-4', 'aria-label'=>'label2_2d_type' ]) }} + {!! $errors->first('label2_2d_type', '') !!} +

+ {{ trans('admin/settings/general.label2_2d_type_help', ['current' => $setting->barcode_type]) }}. + {!! + trans('admin/settings/general.help_default_will_use', [ + 'default' => trans('admin/settings/general.default'), + 'setting_name' => trans('admin/settings/general.barcodes').' > '.trans('admin/settings/general.barcode_type'), + ]) + !!} +

+
-
- @php - $select2DValues = [ - 'QRCODE' => 'QRCODE', - 'DATAMATRIX' => 'DATAMATRIX', - 'PDF417' => 'PDF417', - 'none' => trans('admin/settings/general.none'), - ]; - @endphp - {{ Form::select('label2_2d_type', $select2DValues, old('label2_2d_type', $setting->label2_2d_type), [ 'class'=>'select2 col-md-4', 'aria-label'=>'label2_2d_type' ]) }} - {!! $errors->first('label2_2d_type', '') !!} -

- {{ trans('admin/settings/general.label2_2d_type_help', ['current' => $setting->barcode_type]) }}. - {!! - trans('admin/settings/general.help_default_will_use', [ - 'default' => trans('admin/settings/general.default'), - 'setting_name' => trans('admin/settings/general.barcodes').' > '.trans('admin/settings/general.barcode_type'), - ]) - !!} -

+ + @if($setting->label2_enable == 0) + +
+
+ {{ Form::label('qr_text', trans('admin/settings/general.qr_text'), ['class'=>'control-label']) }} +
+
+ @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' + )) }} +

{{ trans('admin/settings/general.qr_help') }}

+ @endif + {!! $errors->first('qr_text', '') !!} +
-
+ +
+
+ {{ Form::label('purge_barcodes', 'Purge Barcodes', ['class'=>'control-label']) }} +
+
+ + {{ trans('admin/settings/general.barcode_delete_cache') }} + + + + + {!! $errors->first('purgebarcodes', '') !!} +

{{ trans('admin/settings/general.barcodes_help') }}

+
+
+ @endif + @if ($setting->label2_enable)
@@ -227,13 +302,11 @@ class="table table-striped snipe-table" @include('partials.bootstrap-table') @else + {{ Form::hidden('label2_template', old('label2_template', $setting->label2_template)) }} {{ Form::hidden('label2_title', old('label2_title', $setting->label2_title)) }} {{ Form::hidden('label2_asset_logo', old('label2_asset_logo', $setting->label2_asset_logo)) }} - {{ Form::hidden('label2_1d_type', old('label2_1d_type', $setting->label2_1d_type)) }} - {{ Form::hidden('label2_2d_type', old('label2_2d_type', $setting->label2_2d_type)) }} - {{ Form::hidden('label2_2d_target', old('label2_2d_target', $setting->label2_2d_target)) }} {{ Form::hidden('label2_fields', old('label2_fields', $setting->label2_fields)) }} @endif @@ -258,6 +331,17 @@ class="table table-striped snipe-table" {{ Form::hidden('labels_display_company_name', old('labels_display_company_name', $setting->labels_display_company_name)) }} @else + + + + {{ Form::open(['method' => 'POST', 'files' => false, 'autocomplete' => 'off', 'class' => 'form-horizontal', 'role' => 'form' ]) }} + + {{csrf_field()}} +
{{ Form::label('labels_per_page', trans('admin/settings/general.labels_per_page'), ['class'=>'control-label']) }} @@ -430,6 +514,59 @@ class="table table-striped snipe-table" @stop @push('js') + {{-- 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 9d9d4ab21f14..18a52ced9b1c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -200,9 +200,6 @@ Route::get('asset_tags', [SettingsController::class, 'getAssetTags'])->name('settings.asset_tags.index'); Route::post('asset_tags', [SettingsController::class, 'postAssetTags'])->name('settings.asset_tags.save'); - 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::post('labels', [SettingsController::class, 'postLabels'])->name('settings.labels.save');