ソースを参照

Nuoo model Impostazioni, fix EndpointControler, fix PagamentoObserver, fix ElaboraStampaJob

marcofalabretti 11時間前
コミット
20ba344120

+ 18
- 14
app/Http/Controllers/EndpointController.php ファイルの表示

@@ -94,19 +94,23 @@ class EndpointController extends Controller
94 94
         foreach($stampanti_da_registrare as $key => $stampante){
95 95
 
96 96
                 Dispositivo::FirstOrCreate(
97
-                    ['url_stampante' => $stampante['url_stampante']],
98
-                [
99
-                    'nome' => $stampante['nome'],
100
-                    'url_stampante' => $stampante['url_stampante'],
101
-                    'endpoint_id' => $request->endpoint->id,
102
-                    'tipo' => Dispositivo::STAMPANTE,
103
-                    'attivita_id' => $request->endpoint->attivita_id,
104
-                    'licenza' => null,
105
-                    'ubicazione' => $endpoint->ubicazione,
106
-                    'note' => null,
107
-                    'is_attivo' => true,
108
-                    'pin_sblocco' => null,
109
-                ]);
97
+                    [
98
+                        'url_stampante' => $stampante['url_stampante'],
99
+                        'endpoint_id' => $request->endpoint->id
100
+                    ],
101
+                    
102
+                    [
103
+                        'nome' => $stampante['nome'],
104
+                        'url_stampante' => $stampante['url_stampante'],
105
+                        'endpoint_id' => $request->endpoint->id,
106
+                        'tipo' => Dispositivo::STAMPANTE,
107
+                        'attivita_id' => $request->endpoint->attivita_id,
108
+                        'licenza' => null,
109
+                        'ubicazione' => $endpoint->ubicazione,
110
+                        'note' => null,
111
+                        'is_attivo' => true,
112
+                        'pin_sblocco' => null,
113
+                    ]);
110 114
             // }
111 115
         }
112 116
 
@@ -114,7 +118,7 @@ class EndpointController extends Controller
114 118
             'message' => 'Stampanti registrate con successo',
115 119
             'status' => 'success',
116 120
             'success' => true,
117
-            'stampanti' => $endpoint->stampanti,
121
+            'stampanti' => $endpoint->fresh()->stampanti,
118 122
         ]);
119 123
 
120 124
     }

+ 53
- 0
app/Http/Controllers/ImpostazioniController.php ファイルの表示

@@ -0,0 +1,53 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers;
4
+
5
+use Illuminate\Http\Request;
6
+use App\DataTables\ImpostazioniDataTable;
7
+use App\Models\Impostazioni;
8
+use Illuminate\Support\Facades\Session;
9
+
10
+class ImpostazioniController extends Controller
11
+{
12
+    public static $permission_group = "Impostazioni";
13
+    public static $permissions = [
14
+        'view-impostazioni' => 'Vedi',
15
+        'create-impostazioni' => 'Crea',
16
+        'edit-impostazioni' => 'Modifica',
17
+        'delete-impostazioni' => 'Elimina',
18
+    ];
19
+    
20
+    public static function middleware(): array
21
+    {
22
+        return [
23
+            new Middleware('permission:view-impostazioni', only: ['index']),
24
+            new Middleware('permission:create-impostazioni|edit-impostazioni|delete-impostazioni', only: ['store']),
25
+        ];
26
+    }
27
+    
28
+    public function index(ImpostazioniDataTable $dataTable)
29
+    {
30
+        $dataTable->attivita_id = Session::get('attivita_attuale');
31
+        return $dataTable->render('impostazioni.index');
32
+    }
33
+
34
+    public function store(ImpostazioniDataTableEditor $editor)
35
+    {
36
+        $request = request();
37
+        $input = $request->all();
38
+        if($request->has('action')){
39
+            switch($input['action']){
40
+                case 'create':
41
+                    if(!Auth::user()->can('create-impostazioni')) return;
42
+                    break;
43
+                case 'edit':
44
+                    if(!Auth::user()->can('edit-impostazioni')) return;
45
+                    break;
46
+                case 'delete':
47
+                    if(!Auth::user()->can('delete-impostazioni')) return;
48
+                    break;
49
+            }
50
+        }
51
+        return $editor->process($request);
52
+    }
53
+}

+ 4
- 1
app/Jobs/ElaboraJobStampa.php ファイルの表示

@@ -22,7 +22,10 @@ class ElaboraJobStampa implements ShouldQueue
22 22
 
23 23
     public int $tries = 3;
24 24
 
25
-    public function __construct(public int $printJobId) {}
25
+    public function __construct(public int $printJobId) {
26
+        $this->onConnection('redis');
27
+        $this->onQueue('default');
28
+    }
26 29
 
27 30
     public function handle(): void
28 31
     {

+ 5
- 0
app/Models/AbstractModels/AbstractAttivita.php ファイルの表示

@@ -136,4 +136,9 @@ abstract class AbstractAttivita extends \Illuminate\Foundation\Auth\User
136 136
     {
137 137
         return $this->hasMany('\App\Models\Categoriacontabile', 'attivita_id', 'id');
138 138
     }
139
+    public function impostazioni()
140
+    {
141
+        return $this->hasMany('\App\Models\Impostazioni', 'attivita_id', 'id');
142
+    }
143
+    
139 144
 }

+ 75
- 0
app/Models/AbstractModels/AbstractImpostazioni.php ファイルの表示

@@ -0,0 +1,75 @@
1
+<?php
2
+/**
3
+ * Model object generated by: Skipper (http://www.skipper18.com)
4
+ * Do not modify this file manually.
5
+ */
6
+
7
+namespace App\Models\AbstractModels;
8
+
9
+abstract class AbstractImpostazioni extends \Illuminate\Foundation\Auth\User
10
+{
11
+    /**  
12
+     * The table associated with the model.
13
+     * 
14
+     * @var string
15
+     */
16
+    protected $table = 'impostazioni';
17
+    
18
+    /**  
19
+     * Primary key type.
20
+     * 
21
+     * @var string
22
+     */
23
+    protected $keyType = 'bigInteger';
24
+    
25
+    /**  
26
+     * The model's default values for attributes.
27
+     * 
28
+     * @var array
29
+     */
30
+    // protected $attributes = ['is_gruppo' => 0];
31
+    
32
+    /**  
33
+     * The attributes that should be cast to native types.
34
+     * 
35
+     * @var array
36
+     */
37
+    protected $casts = [
38
+        'id' => 'integer',
39
+        'attivita_id' => 'integer',
40
+        'gruppo' => 'string',
41
+        'chiave' => 'string',
42
+        'label' => 'string',
43
+        'descrizione' => 'string',
44
+        'tipo' => 'string',
45
+        'valore' => 'string',
46
+        'opzioni' => 'json',
47
+        'created_at' => 'datetime',
48
+        'updated_at' => 'datetime'
49
+    ];
50
+    
51
+    /**  
52
+     * The attributes that are mass assignable.
53
+     * 
54
+     * @var array
55
+     */
56
+    protected $fillable = [
57
+        'id',
58
+        'attivita_id',
59
+        'gruppo',
60
+        'chiave',
61
+        'label',
62
+        'descrizione',
63
+        'tipo',
64
+        'valore',
65
+        'opzioni',
66
+        'created_at',
67
+        'updated_at'
68
+    ];
69
+    
70
+    public function attivita()
71
+    {
72
+        return $this->belongsTo('\App\Models\Attivita', 'attivita_id', 'id');
73
+    }
74
+
75
+}

+ 30
- 0
app/Models/Impostazioni.php ファイルの表示

@@ -0,0 +1,30 @@
1
+<?php
2
+
3
+namespace App\Models;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Impostazioni extends \App\Models\AbstractModels\AbstractImpostazioni
8
+{
9
+    public static function getImpostazione($chiave)
10
+    {
11
+        return self::where('chiave', $chiave)->first();
12
+    }
13
+
14
+    public static function getTipi()
15
+    {
16
+        return [
17
+            'text' => 'Testo',
18
+            'number' => 'Numero',
19
+            'boolean' => 'Booleano',
20
+            'select' => 'Selezione',
21
+            'textarea' => 'Testo lungo',
22
+            'date' => 'Data',
23
+            'time' => 'Ora',
24
+            'datetime' => 'Data e ora',
25
+            'file' => 'File',
26
+            'image' => 'Immagine',
27
+            'video' => 'Video',
28
+        ];
29
+    }
30
+}

+ 3
- 3
app/Observers/PagamentoObserver.php ファイルの表示

@@ -4,7 +4,7 @@ namespace App\Observers;
4 4
 
5 5
 use App\Models\Pagamento;
6 6
 use App\Models\PrimaNota;
7
-use App\Models\CategoriaContabile;
7
+use App\Models\Categoriacontabile;
8 8
 use App\Models\MetodoPagamento;
9 9
 use Illuminate\Support\Facades\Log;
10 10
 
@@ -25,9 +25,9 @@ class PagamentoObserver
25 25
         ]);
26 26
         //Assegna categoria contabile
27 27
         if($pagamento->metodo_pagamento->tipo == MetodoPagamento::STAFF){
28
-            $primaNota->categoria_contabile_id = CategoriaContabile::staff()->id??null;
28
+            $primaNota->categoria_contabile_id = Categoriacontabile::staff()->id??null;
29 29
         }else{
30
-            $primaNota->categoria_contabile_id = CategoriaContabile::vendita()->id??null;
30
+            $primaNota->categoria_contabile_id = Categoriacontabile::vendita()->id??null;
31 31
         }
32 32
         //Assegna tipo movimento
33 33
         if($pagamento->metodo_pagamento->escludi_contabilita){

+ 38
- 0
database/migrations/2026_06_20_133936_impostazioni.php ファイルの表示

@@ -0,0 +1,38 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+return new class extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     */
12
+    public function up(): void
13
+    {
14
+        Schema::create('impostazioni', function (Blueprint $table) {
15
+            $table->id();
16
+            $table->bigInteger('attivita_id')->unsigned()->nullable();
17
+            $table->string('gruppo')->nullable();
18
+            $table->string('chiave')->nullable();
19
+            $table->string('label')->nullable();
20
+            $table->text('descrizione')->nullable();
21
+            $table->string('tipo')->nullable();
22
+            $table->string('valore')->nullable();
23
+            $table->json('opzioni')->nullable();
24
+            $table->timestamps();
25
+        });
26
+        Schema::table('impostazioni', function (Blueprint $table) {
27
+            $table->foreign('attivita_id')->references('id')->on('attivita')->onDelete('set null');
28
+        });
29
+    }
30
+
31
+    /**
32
+     * Reverse the migrations.
33
+     */
34
+    public function down(): void
35
+    {
36
+        Schema::dropIfExists('impostazioni');
37
+    }
38
+};

+ 7
- 0
resources/menu/verticalMenu.json ファイルの表示

@@ -292,6 +292,13 @@
292 292
           "url": "admin/fornitore",
293 293
           "can": "permission:view-fornitore"
294 294
         },
295
+        {
296
+          "name": "Impostazioni",
297
+          "icon": "menu-icon icon-base bx bx-cog",
298
+          "slug": "impostazioni.index",
299
+          "url": "admin/impostazioni",
300
+          "can": "permission:view-impostazioni"
301
+        },
295 302
         {
296 303
           "name": "Metodi di pagamento",
297 304
           "icon": "menu-icon icon-base bx bx-money",

+ 127
- 0
resources/views/impostazioni/index.blade.php ファイルの表示

@@ -0,0 +1,127 @@
1
+<?php
2
+use App\Models\Role;
3
+use Illuminate\Support\Facades\Auth;
4
+?>
5
+@php
6
+$configData = Helper::appClasses();
7
+@endphp
8
+
9
+@extends('layouts/layoutMaster')
10
+
11
+@section('title', 'Impostazioni')
12
+
13
+@section('vendor-style')
14
+@vite([
15
+'resources/assets/vendor/libs/datatables-bs5/datatables.bootstrap5.scss',
16
+'resources/assets/vendor/libs/datatables-responsive-bs5/responsive.bootstrap5.scss',
17
+'resources/assets/vendor/libs/datatables-buttons-bs5/buttons.bootstrap5.scss',
18
+'resources/assets/vendor/libs/flatpickr/flatpickr.scss',
19
+'resources/assets/vendor/libs/@form-validation/form-validation.scss'
20
+])
21
+@endsection
22
+
23
+<!-- Vendor Scripts -->
24
+@section('vendor-script')
25
+@vite([
26
+'resources/assets/vendor/libs/moment/moment.js',
27
+'resources/assets/vendor/libs/flatpickr/flatpickr.js',
28
+'resources/assets/vendor/libs/@form-validation/popular.js',
29
+'resources/assets/vendor/libs/@form-validation/bootstrap5.js',
30
+'resources/assets/vendor/libs/@form-validation/auto-focus.js',
31
+'resources/assets/vendor/libs/@form-validation/popular.js',
32
+'resources/assets/vendor/libs/@form-validation/bootstrap5.js',
33
+'resources/assets/vendor/libs/@form-validation/auto-focus.js',
34
+'resources/assets/vendor/libs/datatables-bs5/datatables-bootstrap5.js'
35
+])
36
+@endsection
37
+
38
+@section('pageTitle')
39
+<div class="d-flex flex-column">
40
+  <h4 class="mb-1 text-sm-small mt-md-4 mt-lg-4"> 
41
+    <i class="bx bx-cog d-none d-md-inline-flex d-lg-inline-flex"></i> Impostazioni</h4>
42
+    <nav aria-label="breadcrumb" style="font-size: smaller;" class="d-none d-md-block d-lg-block">
43
+            <ol class="breadcrumb breadcrumb-custom-icon">
44
+      
45
+              <li class="breadcrumb-item">
46
+                <a href="#">Configurazioni</a>
47
+                <i class="breadcrumb-icon icon-base bx bx-chevron-right align-middle"></i>
48
+              </li>
49
+              <li class="breadcrumb-item active text-primary">
50
+                <a href="{{ route('impostazioni.index') }}">Impostazioni</a>
51
+              </li>
52
+            </ol>
53
+          </nav>
54
+</div>
55
+@endsection
56
+
57
+@section('content')
58
+<style>
59
+  div.upload button:first-child{
60
+    display: none !important;
61
+  }
62
+
63
+.bx-chef-hat{
64
+  --svg: url("data:image/svg+xml,%3csvg width='24' height='24' fill='currentColor' viewBox='0 0 24 24' transform='' xmlns='http://www.w3.org/2000/svg'%3e%3c!--Boxicons v3.0.8 https://boxicons.com %7c License https://docs.boxicons.com/free--%3e%3cpath d='M17.13 5.54C16.33 3.42 14.32 2 12 2S7.67 3.42 6.87 5.54A5.506 5.506 0 0 0 2 11c0 2.07 1.18 3.95 3 4.88V18c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-2.12c1.82-.93 3-2.81 3-4.88 0-2.82-2.13-5.15-4.87-5.46m.53 8.75c-.4.14-.67.52-.67.94v1.78H7v-1.78c0-.42-.27-.8-.67-.94-1.4-.5-2.33-1.82-2.33-3.28 0-1.93 1.57-3.5 3.42-3.5.04 0 .14.01.18.02.49 0 .9-.31 1-.78.36-1.61 1.76-2.73 3.41-2.73s3.05 1.12 3.41 2.73c.1.47.51.81 1 .78.06 0 .12 0 .09-.01 1.93 0 3.5 1.57 3.5 3.5 0 1.47-.94 2.79-2.33 3.28ZM5 20h14v2H5z'%3e%3c/path%3e%3c/svg%3e");
65
+}
66
+</style>
67
+
68
+@include('_partials.status')
69
+
70
+<div class="row justify-content-center">
71
+  <div class="col-xxl mb-4 mt-2">
72
+    <div class="card">
73
+      <div class="card-body">
74
+        {{ $dataTable_impostazioni->table(['class' => 'table table-bordered']) }}
75
+      </div>
76
+    </div>
77
+  </div>
78
+</div>
79
+
80
+@endsection
81
+
82
+@section('page-script')
83
+
84
+{{$dataTable_impostazioni->scripts(attributes: ['type' => 'module'])}}
85
+
86
+
87
+<script type="module">
88
+  $(document).ready(function(){
89
+    // Editor edit
90
+    $("#dataTable_impostazioni").on('click', 'a.editor_edit', function (e) {
91
+      e.preventDefault();
92
+      window.LaravelDataTables["dataTable_impostazioni-editor"].edit( $(this).closest('tr'), {
93
+        title: 'Modifica',
94
+        buttons: 'Aggiorna',
95
+      });
96
+    });
97
+
98
+    // Editor delete
99
+    $("#dataTable_impostazioni").on('click', 'a.editor_delete', function (e) {
100
+      e.preventDefault();
101
+      window.LaravelDataTables["dataTable_impostazioni-editor"].remove($(this).closest('tr'), {
102
+        title: 'Cancella record',
103
+        message: 'Sei sicuro di voler eliminare il record selezionato?',
104
+        buttons: 'Cancella record'
105
+      });
106
+    } );
107
+
108
+    $("#dataTable_impostazioni").on('dblclick', 'tbody td', function (e) {
109
+      window.LaravelDataTables["dataTable_impostazioni-editor"].edit( $(this).closest('tr'), {
110
+        title: 'Modifica',
111
+        buttons: 'Aggiorna',
112
+      });
113
+    });
114
+
115
+  });
116
+
117
+</script>
118
+
119
+<script>
120
+  function initComplete_impostazioni(){
121
+    $('div.dt-buttons button').removeClass('btn-secondary');
122
+    $('div.dt-search').addClass('mt-0 mb-4');
123
+  }
124
+
125
+
126
+</script>
127
+@endsection

+ 21
- 0
resources/views/impostazioni/menu.blade.php ファイルの表示

@@ -0,0 +1,21 @@
1
+<?php
2
+use Illuminate\Support\Facades\Auth;
3
+?>
4
+
5
+<div class="dropdown">
6
+    <button type="button" class="btn p-0 dropdown-toggle hide-arrow" data-bs-toggle="dropdown" aria-expanded="false">
7
+        <i class="bx bx-dots-vertical-rounded fs-large"></i>
8
+    </button>
9
+    <div class="dropdown-menu">
10
+    @if(Auth::user()->hasRole('superadmin') || Auth::user()->can('edit-impostazioni'))
11
+        <a href="#" class="dropdown-item editor_edit">
12
+            <i class="bx bx-edit-alt me-1"></i> Modifica
13
+        </a>
14
+        @endif
15
+        @if(Auth::user()->hasRole('superadmin'))
16
+        <a href="#" class="dropdown-item editor_delete text-danger">
17
+            <i class="bx bx-trash me-1"></i> Elimina
18
+        </a>
19
+        @endif
20
+    </div>
21
+</div>

+ 6
- 1
routes/web.php ファイルの表示

@@ -42,6 +42,7 @@ use App\Http\Controllers\RigaOrdineNotificaController;
42 42
 use App\Http\Controllers\OperatoreController;
43 43
 use App\Http\Controllers\TombolaController;
44 44
 use App\Http\Controllers\ChiusuraServizioController;
45
+use App\Http\Controllers\ImpostazioniController;
45 46
 
46 47
 Route::get('/', [HomePageController::class, 'welcome'])->name('welcome');
47 48
 
@@ -58,7 +59,7 @@ Route::middleware(['auth:sanctum', AttivitaMiddleware::class, config('jetstream.
58 59
   Route::get('user/{user_id}/edit_profilo', [UserController::class, 'edit_profilo'])->name('user.edit_profilo');
59 60
   Route::post('user/updateProfile', [UserController::class, 'updateProfile'])->name('user.updateProfile');
60 61
   Route::get('user/create', [UserController::class, 'create'])->name('user.create');
61
-  Route::post('user/store', [UserController::class, 'storeUser'])->name('user.store');
62
+  // Route::post('user/store', [UserController::class, 'storeUser'])->name('user.store');
62 63
   Route::post('user/upload_foto_profilo', [UserController::class, 'upload_foto_profilo'])->name('user.upload_foto_profilo');
63 64
   Route::get('user/showCropImage', [UserController::class, 'showCropImage'])->name('user.showCropImage');
64 65
   Route::post('user/cropImage', [UserController::class, 'cropImage'])->name('user.cropImage');
@@ -71,6 +72,10 @@ Route::middleware(['auth:sanctum', AttivitaMiddleware::class, config('jetstream.
71 72
   Route::post('role/createRole', [RoleController::class, 'createRole'])->name('role.createRole');
72 73
   Route::get('ruoli/permessi', [RoleController::class, 'getPermissions'])->name('role.getPermissions');
73 74
 
75
+
76
+  // Impostazioni
77
+  Route::resource('impostazioni', ImpostazioniController::class, ['only' => ['index', 'store']]);
78
+  
74 79
   // Operatore
75 80
   Route::resource('operatore', OperatoreController::class, ['only' => ['index', 'store']]);
76 81
   Route::get('operatore/show', [OperatoreController::class, 'show'])->name('operatore.show');

読み込み中…
キャンセル
保存