Browse Source

pdf segnalazione

Roberto Santini 2 weeks ago
parent
commit
368a920edf
1 changed files with 94 additions and 92 deletions
  1. 94
    92
      resources/views/segnalazione/admin/show.blade.php

+ 94
- 92
resources/views/segnalazione/admin/show.blade.php View File

@@ -2128,6 +2128,100 @@ use App\Models\Config;
2128 2128
 
2129 2129
   });
2130 2130
 
2131
+  var pdfSegnalazioneCorrente = { destinatario: 'cliente' };
2132
+  var emailClienteSegnalazione = @json($segnalazione->user->email ?? '');
2133
+
2134
+  $(document).on('click', '.js-apri-pdf-segnalazione', function (e) {
2135
+    e.preventDefault();
2136
+    var $btn = $(this);
2137
+    pdfSegnalazioneCorrente.destinatario = $btn.data('destinatario') || 'cliente';
2138
+    $('#modalPdfSegnalazioneTitle').text($btn.data('title') || 'PDF');
2139
+    $('#modalPdfSegnalazioneFrame').attr('src', $btn.data('preview-url'));
2140
+    $('#btnScaricaPdfSegnalazione').attr('href', $btn.data('download-url'));
2141
+    $('#modalPdfSegnalazione').modal('show');
2142
+  });
2143
+
2144
+  $('#modalPdfSegnalazione').on('hidden.bs.modal', function () {
2145
+    $('#modalPdfSegnalazioneFrame').attr('src', 'about:blank');
2146
+  });
2147
+
2148
+  $('#btnInviaPdfSegnalazione').on('click', function () {
2149
+    Swal.fire({
2150
+      title: 'Invia per email',
2151
+      input: 'email',
2152
+      inputLabel: 'Indirizzo del cliente',
2153
+      inputValue: emailClienteSegnalazione,
2154
+      inputPlaceholder: 'cliente@example.com',
2155
+      showCancelButton: true,
2156
+      confirmButtonText: 'Invia',
2157
+      cancelButtonText: 'Annulla',
2158
+      buttonsStyling: false,
2159
+      customClass: {
2160
+        confirmButton: 'btn btn-success',
2161
+        cancelButton: 'btn btn-label-secondary ms-2'
2162
+      },
2163
+      didOpen: function () {
2164
+        var container = Swal.getContainer();
2165
+        if (container) {
2166
+          container.style.zIndex = '2000';
2167
+        }
2168
+      },
2169
+      inputValidator: function (value) {
2170
+        if (!value) {
2171
+          return 'Inserisci un indirizzo email';
2172
+        }
2173
+      }
2174
+    }).then(function (result) {
2175
+      if (!result.isConfirmed) {
2176
+        return;
2177
+      }
2178
+      Swal.fire({
2179
+        title: 'Invio in corso',
2180
+        allowOutsideClick: false,
2181
+        allowEscapeKey: false,
2182
+        didOpen: function () {
2183
+          var container = Swal.getContainer();
2184
+          if (container) {
2185
+            container.style.zIndex = '2000';
2186
+          }
2187
+          Swal.showLoading();
2188
+        }
2189
+      });
2190
+      $.ajax({
2191
+        url: @json(route('admin.segnalazione.pdf.invia', $segnalazione->id)),
2192
+        method: 'POST',
2193
+        data: {
2194
+          email: result.value,
2195
+          destinatario: pdfSegnalazioneCorrente.destinatario
2196
+        }
2197
+      }).done(function (res) {
2198
+        Swal.fire({
2199
+          icon: 'success',
2200
+          title: 'Email inviata',
2201
+          text: (res && res.message) ? res.message : 'PDF inviato.',
2202
+          customClass: { confirmButton: 'btn btn-success' },
2203
+          buttonsStyling: false
2204
+        });
2205
+      }).fail(function (xhr) {
2206
+        var msg = 'Invio non riuscito';
2207
+        if (xhr.responseJSON) {
2208
+          if (xhr.responseJSON.errors && xhr.responseJSON.errors.email && xhr.responseJSON.errors.email[0]) {
2209
+            msg = xhr.responseJSON.errors.email[0];
2210
+          } else if (xhr.responseJSON.message) {
2211
+            msg = xhr.responseJSON.message;
2212
+          }
2213
+        }
2214
+        Swal.fire({
2215
+          icon: 'error',
2216
+          title: 'Errore',
2217
+          text: msg,
2218
+          customClass: { confirmButton: 'btn btn-danger' },
2219
+          buttonsStyling: false
2220
+        });
2221
+      });
2222
+    });
2223
+  });
2224
+
2131 2225
 
2132 2226
 </script>
2133 2227
 
@@ -2318,99 +2412,7 @@ use App\Models\Config;
2318 2412
     });
2319 2413
   }
2320 2414
 
2321
-  var pdfSegnalazioneCorrente = { destinatario: 'cliente' };
2322
-  var emailClienteSegnalazione = @json($segnalazione->user->email ?? '');
2323
-
2324
-  $(document).on('click', '.js-apri-pdf-segnalazione', function (e) {
2325
-    e.preventDefault();
2326
-    var $btn = $(this);
2327
-    pdfSegnalazioneCorrente.destinatario = $btn.data('destinatario') || 'cliente';
2328
-    $('#modalPdfSegnalazioneTitle').text($btn.data('title') || 'PDF');
2329
-    $('#modalPdfSegnalazioneFrame').attr('src', $btn.data('preview-url'));
2330
-    $('#btnScaricaPdfSegnalazione').attr('href', $btn.data('download-url'));
2331
-    $('#modalPdfSegnalazione').modal('show');
2332
-  });
2333
-
2334
-  $('#modalPdfSegnalazione').on('hidden.bs.modal', function () {
2335
-    $('#modalPdfSegnalazioneFrame').attr('src', 'about:blank');
2336
-  });
2337 2415
 
2338
-  $('#btnInviaPdfSegnalazione').on('click', function () {
2339
-    Swal.fire({
2340
-      title: 'Invia per email',
2341
-      input: 'email',
2342
-      inputLabel: 'Indirizzo del cliente',
2343
-      inputValue: emailClienteSegnalazione,
2344
-      inputPlaceholder: 'cliente@example.com',
2345
-      showCancelButton: true,
2346
-      confirmButtonText: 'Invia',
2347
-      cancelButtonText: 'Annulla',
2348
-      buttonsStyling: false,
2349
-      customClass: {
2350
-        confirmButton: 'btn btn-success',
2351
-        cancelButton: 'btn btn-label-secondary ms-2'
2352
-      },
2353
-      didOpen: function () {
2354
-        var container = Swal.getContainer();
2355
-        if (container) {
2356
-          container.style.zIndex = '2000';
2357
-        }
2358
-      },
2359
-      inputValidator: function (value) {
2360
-        if (!value) {
2361
-          return 'Inserisci un indirizzo email';
2362
-        }
2363
-      }
2364
-    }).then(function (result) {
2365
-      if (!result.isConfirmed) {
2366
-        return;
2367
-      }
2368
-      Swal.fire({
2369
-        title: 'Invio in corso',
2370
-        allowOutsideClick: false,
2371
-        allowEscapeKey: false,
2372
-        didOpen: function () {
2373
-          var container = Swal.getContainer();
2374
-          if (container) {
2375
-            container.style.zIndex = '2000';
2376
-          }
2377
-          Swal.showLoading();
2378
-        }
2379
-      });
2380
-      $.ajax({
2381
-        url: @json(route('admin.segnalazione.pdf.invia', $segnalazione->id)),
2382
-        method: 'POST',
2383
-        data: {
2384
-          email: result.value,
2385
-          destinatario: pdfSegnalazioneCorrente.destinatario
2386
-        }
2387
-      }).done(function (res) {
2388
-        Swal.fire({
2389
-          icon: 'success',
2390
-          title: 'Email inviata',
2391
-          text: (res && res.message) ? res.message : 'PDF inviato.',
2392
-          customClass: { confirmButton: 'btn btn-success' },
2393
-          buttonsStyling: false
2394
-        });
2395
-      }).fail(function (xhr) {
2396
-        var msg = 'Invio non riuscito';
2397
-        if (xhr.responseJSON) {
2398
-          if (xhr.responseJSON.errors && xhr.responseJSON.errors.email && xhr.responseJSON.errors.email[0]) {
2399
-            msg = xhr.responseJSON.errors.email[0];
2400
-          } else if (xhr.responseJSON.message) {
2401
-            msg = xhr.responseJSON.message;
2402
-          }
2403
-        }
2404
-        Swal.fire({
2405
-          icon: 'error',
2406
-          title: 'Errore',
2407
-          text: msg,
2408
-          customClass: { confirmButton: 'btn btn-danger' },
2409
-          buttonsStyling: false
2410
-        });
2411
-      });
2412
-    });
2413
-  });
2414 2416
 
2415 2417
   function openModalAllegato(allegatoId) {
2416 2418
     $('#extraLargeModal .modal-content').load('{{ route("allegato_annotazione.show") }}?allegato_annotazione_id=' + allegatoId);

Loading…
Cancel
Save