email_comunications.blade.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <div class="col card--ui" id="card--dashboard">
  2. @if(!$add && !$update)
  3. <header id="title--section" style="display:none !important" class="d-flex align-items-center justify-content-between">
  4. <div class="title--section_name d-flex align-items-center justify-content-between">
  5. <i class="ico--ui title_section utenti me-2"></i>
  6. <h2 class="primary">@if(!$add && !$update)Email Templates @else Inserimento/modifica template Email @endif</h2>
  7. </div>
  8. @if(!$add && !$update)
  9. <div class="title--section_addButton" wire:click="add()" style="cursor: pointer;">
  10. <div class="btn--ui entrata d-flex justify-items-between">
  11. <a href="#" wire:click="add()" style="color:white">Aggiungi</a>
  12. </div>
  13. </div>
  14. @endif
  15. </header>
  16. <a class="btn--ui lightGrey" href="/settings?type=comunicazioni"><i class="fa-solid fa-arrow-left"></i></a><br>
  17. <section id="resume-table">
  18. <div class="compare--chart_wrapper d-none"></div>
  19. <table class="table tablesaw tableHead tablesaw-stack" id="tablesaw-350" width="100%">
  20. <thead>
  21. <tr>
  22. <th scope="col">Oggetto</th>
  23. <th scope="col">Messaggio</th>
  24. <th scope="col">Parole</th>
  25. <th scope="col">Data Creazione</th>
  26. <th scope="col">...</th>
  27. </tr>
  28. </thead>
  29. <tbody id="checkall-target">
  30. @foreach($records as $record)
  31. <tr>
  32. <td>
  33. <strong>{{$record->name}}</strong>
  34. </td>
  35. <td>
  36. {{ Str::limit(strip_tags($record->content), 80) }}
  37. </td>
  38. <td>
  39. @php
  40. $wordCount = str_word_count(strip_tags($record->content));
  41. $badgeClass = $wordCount > 500 ? 'bg-warning' : 'bg-info';
  42. @endphp
  43. <span class="badge {{ $badgeClass }}">{{ $wordCount }} parole</span>
  44. </td>
  45. <td>{{ $record->created_at->format('d/m/Y H:i') }}</td>
  46. <td>
  47. <button type="button" class="btn" wire:click="sendTemplate({{ $record->id }})" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Invia Email"><i class="fa-solid fa-envelope"></i></button>
  48. <button type="button" class="btn" wire:click="edit({{ $record->id }})" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Modifica"><i class="fa-regular fa-pen-to-square"></i></button>
  49. </td>
  50. </tr>
  51. @endforeach
  52. </tbody>
  53. </table>
  54. </section>
  55. @else
  56. <div class="container">
  57. <a class="btn--ui lightGrey" href="/email_comunications"><i class="fa-solid fa-arrow-left"></i></a><br><br>
  58. @if (session()->has('error'))
  59. <div class="alert alert-danger" role="alert">
  60. {{ session()->get('error') }}
  61. </div>
  62. @endif
  63. <div class="row">
  64. <div class="col">
  65. <form action="">
  66. <div class="row mb-3">
  67. <div class="col">
  68. <div class="form--item">
  69. <label for="subject" class="form-label">Oggetto</label>
  70. <input type="text" class="form-control @error('subject') is-invalid @enderror" id="subject" wire:model="subject" placeholder="Inserisci l'oggetto del template">
  71. @error('subject')
  72. <div class="invalid-feedback">{{ $message }}</div>
  73. @enderror
  74. </div>
  75. </div>
  76. </div>
  77. <div class="row mb-3">
  78. <div class="col">
  79. <div class="form--item">
  80. <label for="message" class="form-label">Messaggio</label>
  81. <textarea class="form-control @error('message') is-invalid @enderror" id="message" wire:model="message" rows="10" placeholder="Inserisci il contenuto del messaggio (supporta HTML)"></textarea>
  82. <div class="form-text">
  83. <small class="text-muted">Puoi utilizzare HTML per formattare il messaggio. Parole: <span class="fw-bold">{{ str_word_count(strip_tags($message)) }}</span></small>
  84. </div>
  85. @error('message')
  86. <div class="invalid-feedback">{{ $message }}</div>
  87. @enderror
  88. </div>
  89. </div>
  90. </div>
  91. @if($add)
  92. <div class="row mb-3">
  93. <div class="col">
  94. <label class="form-label">Destinatari</label>
  95. <div class="mb-2">
  96. <button type="button" class="btn btn-outline-primary btn-sm" onclick="selectAllUsers()">
  97. <i class="fas fa-users me-1"></i>Seleziona Tutti
  98. </button>
  99. <button type="button" class="btn btn-outline-secondary btn-sm ms-2" onclick="deselectAllUsers()">
  100. <i class="fas fa-times me-1"></i>Deseleziona Tutti
  101. </button>
  102. </div>
  103. <div style="max-height: 200px; overflow-y: auto; border: 1px solid #dee2e6; border-radius: 0.375rem; padding: 10px;">
  104. @foreach($users as $user)
  105. <div class="form-check mb-1">
  106. <input class="form-check-input" type="checkbox" value="{{ $user->id }}" wire:model="selectedRecipients" id="recipient_{{ $user->id }}">
  107. <label class="form-check-label" for="recipient_{{ $user->id }}">
  108. <strong>{{ $user->name }}</strong>
  109. @if($user->email)
  110. <small class="text-muted">({{ $user->email }})</small>
  111. @else
  112. <small class="text-danger">(no email)</small>
  113. @endif
  114. </label>
  115. </div>
  116. @endforeach
  117. </div>
  118. <div class="form-text">
  119. <small class="text-muted">Selezionati: <span id="selectedCount">{{ count($selectedRecipients) }}</span> utenti</small>
  120. </div>
  121. @error('selectedRecipients')
  122. <div class="text-danger">{{ $message }}</div>
  123. @enderror
  124. </div>
  125. </div>
  126. <div class="row mb-3">
  127. <div class="col">
  128. <label class="form-label">Opzioni di Invio</label>
  129. <div class="form-check">
  130. <input class="form-check-input" type="radio" name="sendOption" id="sendNow" wire:model="sendNow" value="true">
  131. <label class="form-check-label" for="sendNow">
  132. <i class="fas fa-envelope me-2"></i>Invia Immediatamente
  133. </label>
  134. </div>
  135. <div class="form-check mt-2">
  136. <input class="form-check-input" type="radio" name="sendOption" id="scheduleFor" wire:model="sendNow" value="false">
  137. <label class="form-check-label" for="scheduleFor">
  138. <i class="fas fa-clock me-2"></i>Programma per dopo
  139. </label>
  140. </div>
  141. </div>
  142. </div>
  143. @if(!$sendNow)
  144. <div class="row mb-3">
  145. <div class="col-md-6">
  146. <label for="scheduledDateTime" class="form-label">Data e Ora di Invio</label>
  147. <input type="datetime-local" class="form-control @error('scheduledDateTime') is-invalid @enderror" id="scheduledDateTime" wire:model="scheduledDateTime">
  148. @error('scheduledDateTime')
  149. <div class="invalid-feedback">{{ $message }}</div>
  150. @enderror
  151. </div>
  152. </div>
  153. @endif
  154. @endif
  155. <div class="form--item">
  156. <button type="button" class="btn--ui lightGrey" wire:click="cancel()">Annulla</button>
  157. @if($add)
  158. <button type="submit" class="btn--ui" wire:click.prevent="store()">
  159. @if($sendNow)
  160. Salva e Invia
  161. @else
  162. Salva e Programma
  163. @endif
  164. </button>
  165. @endif
  166. @if($update)
  167. <button type="submit" class="btn--ui" wire:click.prevent="update()">Salva</button>
  168. @endif
  169. </div>
  170. </form>
  171. </div>
  172. </div>
  173. </div>
  174. @endif
  175. </div>
  176. @if (session()->has('success'))
  177. <div class="alert alert-success alert-dismissible fade show mt-3" role="alert">
  178. {{ session()->get('success') }}
  179. <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
  180. </div>
  181. @endif
  182. @if (session()->has('error'))
  183. <div class="alert alert-danger alert-dismissible fade show mt-3" role="alert">
  184. {{ session()->get('error') }}
  185. <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
  186. </div>
  187. @endif
  188. @push('scripts')
  189. <link href="/css/datatables.css" rel="stylesheet" />
  190. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  191. <script src="/assets/js/datatables.js"></script>
  192. <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
  193. <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
  194. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
  195. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
  196. @endpush
  197. @push('scripts')
  198. <script>
  199. $(document).ready(function() {
  200. loadDataTable();
  201. });
  202. Livewire.on('load-data-table', () => {
  203. loadDataTable();
  204. });
  205. function loadDataTable(){
  206. if ($.fn.DataTable.isDataTable('#tablesaw-350')) {
  207. $('#tablesaw-350').DataTable().destroy();
  208. }
  209. $('#tablesaw-350').DataTable({
  210. thead: {
  211. 'th': {'background-color': 'blue'}
  212. },
  213. layout: {
  214. topStart : null,
  215. topEnd : null,
  216. top1A: {
  217. buttons: [
  218. {
  219. extend: 'collection',
  220. text: 'ESPORTA',
  221. buttons: [
  222. {
  223. extend: 'excelHtml5',
  224. title: 'Templates Email',
  225. exportOptions: {
  226. columns: ":not(':last')"
  227. }
  228. },
  229. {
  230. extend: 'pdfHtml5',
  231. title: 'Templates Email',
  232. exportOptions: {
  233. columns: ":not(':last')"
  234. }
  235. },
  236. {
  237. extend: 'print',
  238. text: 'Stampa',
  239. title: 'Templates Email',
  240. exportOptions: {
  241. columns: ":not(':last')"
  242. }
  243. }
  244. ],
  245. dropup: true
  246. }
  247. ]
  248. },
  249. top1B : {
  250. pageLength: {
  251. menu: [[10, 25, 50, 100, 100000], [10, 25, 50, 100, "Tutti"]]
  252. }
  253. },
  254. top1C :'search',
  255. },
  256. pagingType: 'numbers',
  257. "language": {
  258. "url": "/assets/js/Italian.json"
  259. },
  260. "fnInitComplete": function (oSettings, json) {
  261. var html = '&nbsp;<a href="#" class="addData btn--ui"><i class="fa-solid fa-plus"></i></a>';
  262. $(".dt-search").append(html);
  263. }
  264. });
  265. $('#tablesaw-350 thead tr th').addClass('col');
  266. $('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");
  267. $(document).ready(function() {
  268. $(document).on("click",".addData",function() {
  269. $(".title--section_addButton").trigger("click")
  270. });
  271. });
  272. }
  273. </script>
  274. @endpush