allegati-modal.blade.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <div wire:ignore.self class="modal fade" id="allegatiModal" tabindex="-1" aria-labelledby="allegatiModalLabel" aria-hidden="true" data-keyboard="false" data-backdrop="static">
  2. <div class="modal-dialog modal-xl">
  3. <div class="modal-content">
  4. <div class="modal-header">
  5. <h5 class="modal-title" id="allegatiModalLabel">
  6. @if($allegatoId > 0)
  7. Modifica allegato
  8. @else
  9. Nuovo allegato
  10. @endif
  11. </h5>
  12. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  13. <span aria-hidden="true">&times;</span>
  14. </button>
  15. </div>
  16. <div class="modal-body">
  17. <div class="row mt-3">
  18. <div class="col-md-4">
  19. <label for="allegatoName" class="form-label">Nome</label>
  20. </div>
  21. <div class="col-md-8">
  22. <input class="form-control @error('allegatoName') is-invalid @enderror" type="text" id="allegatoName" placeholder="Nome" wire:model="allegatoName">
  23. @error('allegatoName')
  24. <div class="invalid-feedback">{{ $message }}</div>
  25. @enderror
  26. </div>
  27. </div>
  28. <div class="row mt-3">
  29. <div class="col-md-4">
  30. <label for="allegatoGallery" class="form-label">Tipologia</label>
  31. </div>
  32. <div class="col-md-8">
  33. <select class="form-control @error('allegatoGallery') is-invalid @enderror" style="width:100%" wire:model="allegatoGallery" id="allegatoGallery">
  34. <option value="">Seleziona...</option>
  35. @foreach ($allegatiType as $t)
  36. <option value="{{ $t->id }}">{{ $t->name }}</option>
  37. @endforeach
  38. </select>
  39. @error('allegatoGallery')
  40. <div class="invalid-feedback">{{ $message }}</div>
  41. @enderror
  42. </div>
  43. </div>
  44. <div class="row mt-3">
  45. <div class="col-md-4">
  46. <label for="allegatoFotoSinistri" class="form-label">Foto sinistri</label>
  47. </div>
  48. <div class="col-md-8">
  49. <select class="form-control @error('allegatoFotoSinistri') is-invalid @enderror" style="width:100%" wire:model="allegatoFotoSinistri" id="allegatoFotoSinistri">
  50. <option value="">Seleziona...</option>
  51. <option value="1">Valore 1</option>
  52. <option value="2">Valore 2</option>
  53. </select>
  54. @error('allegatoFotoSinistri')
  55. <div class="invalid-feedback">{{ $message }}</div>
  56. @enderror
  57. </div>
  58. </div>
  59. <div class="row mt-3">
  60. <div class="col-md-4">
  61. <label for="allegatoDidascalia" class="form-label">Didascalia</label>
  62. </div>
  63. <div class="col-md-8">
  64. <input class="form-control" type="text" id="allegatoDidascalia" placeholder="Didascalia" wire:model="allegatoDidascalia">
  65. </div>
  66. </div>
  67. <div class="row mt-3">
  68. <div class="col-md-4">
  69. <label for="allegati" class="form-label">Files</label>
  70. </div>
  71. <div class="col-md-8">
  72. <div class="form-group">
  73. <input wire:model="allegati" type="file" class="form-control-file" id="allegati" multiple>
  74. <span id="fileSize" style="color:red"></span>
  75. <span id="fileUpload" style="display:none">Upload in corso...</span>
  76. </div>
  77. <div id="files-container" class="mt-2">
  78. @if(!empty($allegatiFiles) && count($allegatiFiles) > 0)
  79. <div class="card">
  80. <div class="card-header bg-light d-flex justify-content-between align-items-center">
  81. <strong>File caricati ({{ count($allegatiFiles) }})</strong>
  82. </div>
  83. <div class="card-body p-2">
  84. <ul class="list-group list-group-flush">
  85. @foreach ($allegatiFiles as $a)
  86. <li class="list-group-item d-flex justify-content-between align-items-center py-2">
  87. <span>{{ $a }}</span>
  88. <button class="btn btn-sm btn-outline-danger"
  89. wire:click.prevent="removeFile('{{ $a }}')">
  90. <i class="fa fa-times"></i>
  91. </button>
  92. </li>
  93. @endforeach
  94. </ul>
  95. </div>
  96. </div>
  97. @endif
  98. </div>
  99. </div>
  100. </div>
  101. <div class="row mt-3">
  102. <div class="col-md-4">
  103. <label for="allegatoVisible" class="form-label">Visibile in stampa</label>
  104. </div>
  105. <div class="col-md-8">
  106. <div class="custom-control custom-switch custom-switch-md">
  107. <input type="checkbox" class="custom-control-input" id="allegatoVisible" wire:model="allegatoVisible">
  108. <label class="custom-control-label" for="allegatoVisible">&nbsp;</label>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <div class="modal-footer">
  114. <button type="button" class="btn btn-secondary" data-dismiss="modal">Annulla</button>
  115. @if (!$this->validated)
  116. <button type="button" class="btn btn-primary" wire:click.prevent="saveAllegato()" id="btSaveAllegato">Salva</button>
  117. @endif
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. @push('scripts')
  123. <script>
  124. document.addEventListener('livewire:load', function () {
  125. window.livewire.on('open-allegati-modal', function () {
  126. $('#allegatiModal').modal('show');
  127. console.log('Modal opened');
  128. });
  129. window.livewire.on('close-modal', function () {
  130. $('#allegatiModal').modal('hide');
  131. });
  132. window.livewire.on('attachments', function (files) {
  133. console.log('Attachments updated:', files);
  134. setTimeout(function() {
  135. window.livewire.emit('refresh');
  136. }, 200);
  137. });
  138. window.livewire.on('fileSize', function (txt) {
  139. setTimeout(function() {
  140. if (txt == "")
  141. {
  142. $("#btSaveAllegato").show();
  143. }
  144. else
  145. {
  146. $("#btSaveAllegato").hide();
  147. $("#fileSize").html(txt);
  148. }
  149. }, 200);
  150. });
  151. });
  152. </script>
  153. @endpush