course.blade.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <div class="col card--ui" id="card--dashboard">
  2. <header id="title--section" style="display:none !important" class="d-flex align-items-center justify-content-between">
  3. <div class="title--section_name d-flex align-items-center justify-content-between">
  4. <i class="ico--ui title_section utenti me-2"></i>
  5. <h2 class="primary">@if(!$add && !$update)Corsi @else Inserimento/modifica corso @endif</h2>
  6. </div>
  7. @if(!$add && !$update)
  8. <div class="title--section_addButton" wire:click="add()" style="cursor: pointer;">
  9. <div class="btn--ui entrata d-flex justify-items-between">
  10. <a href="#" wire:click="add()" style="color:white">Aggiungi</a>
  11. </div>
  12. </div>
  13. @endif
  14. </header>
  15. @if(!$add && !$update)
  16. <a class="btn--ui lightGrey" href="/settings?type=corsi"><i class="fa-solid fa-arrow-left"></i></a><br>
  17. <div class="row mt-3" style="margin-bottom:2rem !important;">
  18. <div class="col-1 mt-4">
  19. <h4>Anno</h4>
  20. </div>
  21. <div class="col-2 mt-4">
  22. <select class="form-select filterYear" onchange="reload()">
  23. <option value="">--Seleziona--
  24. @foreach($course_years as $c)
  25. @php
  26. $selected = '';
  27. if (!isset($_GET["year"]))
  28. {
  29. try
  30. {
  31. list($f, $t) = explode("-", $c);
  32. if ($f == date("Y"))
  33. $selected = 'selected';
  34. } catch (Exception $e) {
  35. }
  36. }
  37. else
  38. {
  39. if ($_GET["year"] == $c)
  40. $selected = 'selected';
  41. }
  42. @endphp
  43. <option value="{{$c}}" {{$selected}}>{{$c}}
  44. @endforeach
  45. </select>
  46. </div>
  47. </div>
  48. <section id="resume-table">
  49. <div class="compare--chart_wrapper d-none"></div>
  50. <table class="table tablesaw tableHead tablesaw-stack" id="tablesaw-350" width="100%">
  51. <thead>
  52. <tr>
  53. <th style="text-align:center" scope="col"><input type="checkbox" class="checkAll"></th>
  54. <th scope="col">Anno</th>
  55. <th scope="col">Tipo</th>
  56. <th scope="col">Nome</th>
  57. <th scope="col">Livello</th>
  58. <th scope="col">Frequenza</th>
  59. <th scope="col">N° partecipanti</th>
  60. <th scope="col">...</th>
  61. </tr>
  62. </thead>
  63. <tbody id="checkall-target">
  64. @foreach($records as $record)
  65. <tr>
  66. <td style="text-align:center"><input type="checkbox" class="chkCourse" name="{{$record->id}}"></td>
  67. <td>{{$record->year}}</td>
  68. <td>{{$record->type == 'standard' ? 'Singolo' : 'Personalizzato'}}</td>
  69. <td>{{$record->name}}</td>
  70. <td>{{$record->level->name ?? ""}}</td>
  71. <td>{{$record->frequency->name ?? ""}}</td>
  72. <td style="padding-right: 50px">{{$record->getCount()}}</td>
  73. <td>
  74. <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>
  75. <button type="button" class="btn" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="delete({{ $record->id }})" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Elimina"><i class="fa-regular fa-trash-can"></i></button>
  76. <button type="button" class="btn" wire:click="duplicate({{ $record->id }}, false)" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Duplica"><i class="fa-regular fa-copy"></i></button>
  77. </td>
  78. </tr>
  79. @endforeach
  80. </tbody>
  81. </table>
  82. </section>
  83. @else
  84. <a class="btn--ui lightGrey" href="/courses?showFilters=1"><i class="fa-solid fa-arrow-left"></i></a><br>
  85. <div class="container">
  86. @if (session()->has('error'))
  87. <div class="alert alert-danger" role="alert">
  88. {{ session()->get('error') }}
  89. </div>
  90. @endif
  91. <div class="row">
  92. <div class="col">
  93. <form action="">
  94. <div class="row mb-3 ">
  95. <div class="col-12 mt-2">
  96. <input type="radio" name="chkType" value="standard" wire:model="type">&nbsp;Singolo
  97. &nbsp;&nbsp;&nbsp;
  98. <input type="radio" name="chkType" value="custom" wire:model="type">&nbsp;Personalizzato
  99. </div>
  100. <div class="col-6 mt-2">
  101. <div class="form--item">
  102. <label for="inputName" class="form-label">Nome</label>
  103. <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Nome" wire:model="name">
  104. @error('name')
  105. <div class="invalid-feedback">{{ $message }}</div>
  106. @enderror
  107. </div>
  108. </div>
  109. @if(false)
  110. {{-- <div class="col-6 mt-2">
  111. <div class="form--item">
  112. <label for="inputName" class="form-label">Tipologia</label>
  113. <select class="form-select form-select-lg me-1 @error('course_type_id') is-invalid @enderror" wire:model="course_type_id">
  114. <option value="">
  115. @foreach($course_types as $c)
  116. <option value="{{$c["id"]}}">{{$c["name"]}}</option>
  117. @endforeach
  118. </select>
  119. </div>
  120. </div> --}}
  121. <div class="col-6 mt-2">
  122. <div class="form--item">
  123. <label for="inputName" class="form-label">Durata</label>
  124. <select class="form-select form-select-lg me-1 @error('course_duration_id') is-invalid @enderror" wire:model="course_duration_id">
  125. <option value="">
  126. @foreach($course_durations as $c)
  127. <option value="{{$c["id"]}}">{{$c["name"]}}</option>
  128. @endforeach
  129. </select>
  130. </div>
  131. </div>
  132. @endif
  133. <div class="col-6 mt-2">
  134. <div class="form--item">
  135. <label for="inputName" class="form-label">Frequenza</label>
  136. <select class="form-select form-select-lg me-1 @error('course_frequency_id') is-invalid @enderror" wire:model="course_frequency_id">
  137. <option value="">
  138. @foreach($course_frequencies as $c)
  139. <option value="{{$c["id"]}}">{{$c["name"]}}</option>
  140. @endforeach
  141. </select>
  142. </div>
  143. </div>
  144. <div class="col-6 mt-2">
  145. <div class="form--item">
  146. <label for="inputName" class="form-label">Livello</label>
  147. <select class="form-select form-select-lg me-1 @error('course_level_id') is-invalid @enderror" wire:model="course_level_id">
  148. <option value="">
  149. @foreach($course_levels as $c)
  150. <option value="{{$c["id"]}}">{{$c["name"]}}</option>
  151. @endforeach
  152. </select>
  153. </div>
  154. </div>
  155. <div class="col-3 mt-2">
  156. <div class="form--item">
  157. <label for="inputName" class="form-label">Data inizio</label>
  158. <input class="form-control @error('date_from') is-invalid @enderror" type="date" placeholder="Data inizio" wire:model="date_from">
  159. </div>
  160. </div>
  161. <div class="col-3 mt-2">
  162. <div class="form--item">
  163. <label for="inputName" class="form-label">Data fine</label>
  164. <input class="form-control @error('date_to') is-invalid @enderror" type="date" placeholder="Data fine" wire:model="date_to">
  165. </div>
  166. </div>
  167. @if(false)
  168. <div class="col-6 mt-2">
  169. <div class="form--item">
  170. <label for="inputName" class="form-label">Prezzo mensile</label>
  171. <input class="form-control js-keyupTitle @error('price') is-invalid @enderror" type="text" id="price" onkeyup="onlyNumberAmount(this)" placeholder="€ 0,00" wire:model="price">
  172. @error('price')
  173. <div class="invalid-feedback">{{ $message }}</div>
  174. @enderror
  175. </div>
  176. </div>
  177. <div class="col-6 mt-2">
  178. <div class="form--item">
  179. <label for="inputName" class="form-label">Prezzo iscrizione</label>
  180. <input class="form-control js-keyupTitle @error('subscription_price') is-invalid @enderror" type="text" id="subscription_price" onkeyup="onlyNumberAmount(this)" placeholder="€ 0,00" wire:model="subscription_price">
  181. @error('subscription_price')
  182. <div class="invalid-feedback">{{ $message }}</div>
  183. @enderror
  184. </div>
  185. </div>
  186. <div class="col-6 mt-2">
  187. <div class="form--item">
  188. <label for="inputName" class="form-label">Causale</label>
  189. <livewire:causals :type="$typeIN" :idx="0" :show_hidden=0 :causal_id="$causal_id" :wire:key="0" />
  190. @error('causal_id')
  191. <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
  192. @enderror
  193. </div>
  194. </div>
  195. <div class="col-6 mt-2">
  196. <div class="form--item">
  197. <label for="inputName" class="form-label">Causale iscrizione</label>
  198. <livewire:causals :type="$typeIN" :idx="0" :show_hidden=0 :causal_id="$sub_causal_id" :wire:key="0" :emit="$setSubscriptionCausal" />
  199. @error('sub_causal_id')
  200. <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
  201. @enderror
  202. </div>
  203. </div>
  204. @endif
  205. <div class="col-6 mt-2">
  206. <div class="form--item">
  207. <label for="inputName" class="form-label">Causale</label>
  208. <livewire:causals :type="$typeIN" :idx="0" :show_hidden=0 :causal_id="$causal_id" :wire:key="0" />
  209. @error('causal_id')
  210. <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
  211. @enderror
  212. </div>
  213. </div>
  214. <div class="col-6 mt-2">
  215. <div class="form--item">
  216. <label for="inputName" class="form-label">Causale iscrizione</label>
  217. <livewire:causals :type="$typeIN" :idx="0" :show_hidden=0 :causal_id="$sub_causal_id" :wire:key="0" :emit="$setSubscriptionCausal" />
  218. @error('sub_causal_id')
  219. <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
  220. @enderror
  221. </div>
  222. </div>
  223. <div class="col-6 mt-2">
  224. <div class="form--item">
  225. <label for="inputName" class="form-label">N° partecipanti</label>
  226. <input class="form-control js-keyupTitle @error('max_members') is-invalid @enderror" type="text" id="max_members" placeholder="Numero massimo partecipanti" wire:model="max_members">
  227. @error('max_members')
  228. <div class="invalid-feedback">{{ $message }}</div>
  229. @enderror
  230. </div>
  231. </div>
  232. <div class="col-6 mt-2">
  233. <div class="form--item">
  234. <label for="inputName" class="form-label">Istruttore</label>
  235. <select class="form-select form-select-lg" wire:model="instructor_id">
  236. <option value="">
  237. @foreach($instructors as $ins)
  238. <option value="{{$ins["id"]}}">{{$ins["name"]}} {{$ins["cognome"]}}</option>
  239. @endforeach
  240. </select>
  241. </div>
  242. </div>
  243. <div class="col-6 mt-2">
  244. <div class="form--item">
  245. <label for="inputName" class="form-label">Gruppo di interesse</label>
  246. <select class="form-select form-select-lg me-1 @error('category_id') is-invalid @enderror" wire:model="category_id">
  247. <option value="">
  248. @foreach($categories as $category)
  249. <option value="{{$category["id"]}}">{{str_repeat(' ', $category["indentation"])}}{{$category["name"]}}
  250. @endforeach
  251. </select>
  252. </div>
  253. </div>
  254. <div class="col-6 mt-2">
  255. <div class="form--item">
  256. <label for="inputName" class="form-label">Anno</label>
  257. <select class="form-control @error('year') is-invalid @enderror" wire:model="year">
  258. <option value=""></option>
  259. @for($i=2024; $i<=date("Y") + 1; $i++)
  260. <option value="{{$i . "-" . $i + 1}}">{{$i . "/" . $i + 1}}
  261. @endfor
  262. </select>
  263. </div>
  264. </div>
  265. <div class="col-6 mt-2">
  266. <div class="form--item">
  267. <label for="inputName" class="form-label">Prezzo iscrizione</label>
  268. <input class="form-control js-keyupTitle @error('subscription_price') is-invalid @enderror" type="text" id="subscription_price" onkeyup="onlyNumberAmount(this)" placeholder="€ 0,00" wire:model="subscription_price">
  269. @error('subscription_price')
  270. <div class="invalid-feedback">{{ $message }}</div>
  271. @enderror
  272. </div>
  273. </div>
  274. <div class="col-6"></div>
  275. <div class="col-6 mt-2">
  276. @foreach($prices as $idP => $p)
  277. <div class="row mt-2 ">
  278. <div class="col-6">
  279. <label for="abb" class="form-label">Pagamento</label>
  280. <select class="form-control" wire:model="prices.{{$idP}}.course_subscription_id">
  281. <option value=""></option>
  282. @foreach($course_subscriptions as $s)
  283. <option value="{{$s["id"]}}">{{$s["name"]}}
  284. @endforeach
  285. </select>
  286. </div>
  287. <div class="col-4">
  288. <label for="price" class="form-label">Prezzo</label>
  289. <input class="form-control " type="text" onkeyup="onlyNumberAmount(this)" placeholder="€ 0,00" wire:model="prices.{{$idP}}.price">
  290. </div>
  291. <div class="col-2">
  292. @if($idP == 0)
  293. <br><button class="btn--ui primary add--daye" wire:click.prevent="addPrice()"><i class="fa-solid fa-plus"></i></button>
  294. @endif
  295. @if($idP > 0)
  296. <br><button class="btn--ui primary add--daye" wire:click.prevent="delPrice({{$idP}})"><i class="fa-solid fa-minus"></i></button>
  297. @endif
  298. </div>
  299. <div class="col-12">
  300. <span style="color:red">{{$msgPrices}}</span>
  301. </div>
  302. </div>
  303. @endforeach
  304. </div>
  305. @if($type == 'standard')
  306. @foreach($when as $idW => $w)
  307. @if ($idW > 0)
  308. <div class="col-6"></div>
  309. @endif
  310. <div class="col-6 mt-4">
  311. <div class="day durata--corso d-flex">
  312. <label for="" class="form-label">Giorno</label>
  313. <div class="durata--corso_days mb-3">
  314. <a class="{{in_array('lun', $when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'lun')">Lun</a>
  315. <a class="{{in_array('mar', $when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'mar')">Mar</a>
  316. <a class="{{in_array('mer', $when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'mer')">Mer</a>
  317. <a class="{{in_array('gio', $when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'gio')">Gio</a>
  318. <a class="{{in_array('ven', $when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'ven')">Ven</a>
  319. <a class="{{in_array('sab', $when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'sab')">Sab</a>
  320. <a class="{{in_array('dom', $when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'dom')">Dom</a>
  321. </div>
  322. <div class="durata--corso_select">
  323. <div class="from--h me-3">
  324. <label for="" class="form-label">Dalle</label>
  325. <select class="form-select" wire:model="when.{{$idW}}.from">
  326. <option value="">--Seleziona--
  327. @for($c=6;$c<=23;$c++)
  328. <option value="{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:00">{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:00
  329. <option value="{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:30">{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:30
  330. @endfor
  331. </select>
  332. </div>
  333. <div class="to--h">
  334. <label for="" class="form-label">Alle</label>
  335. <select class="form-select" wire:model="when.{{$idW}}.to">
  336. <option value="">--Seleziona--
  337. @for($c=6;$c<=23;$c++)
  338. <option value="{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:00">{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:00
  339. <option value="{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:30">{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:30
  340. @endfor
  341. </select>
  342. </div>
  343. </div>
  344. <button class="btn--ui primary remove--day position-absolute" wire:click.prevent="delRow({{$idW}})"><i class="fa-solid fa-minus"></i></button>
  345. <button class="btn--ui primary add--day position-absolute" wire:click.prevent="addRow()"><i class="fa-solid fa-plus"></i></button>
  346. </div>
  347. <div class="col-12">
  348. <span style="color:red">{{$msgWhen}}</span>
  349. </div>
  350. </div>
  351. @endforeach
  352. @endif
  353. </div>
  354. <div class="row">
  355. <div class="col-6">
  356. <div class="form--item">
  357. <label for="enabled" class="form-label">Abilitato</label>
  358. <input class="form-check-input form-control" style="width:22px; height:22px;" type="checkbox" id="enabled" wire:model="enabled">
  359. </div>
  360. </div>
  361. </div>
  362. <div class="form--item mt-4">
  363. <button type="button" class="btn--ui lightGrey" onclick="annulla()">Annulla</button>
  364. @if($add)
  365. <button type="submit" class="btn--ui" wire:click.prevent="store()">Salva</button>
  366. @endif
  367. @if($update)
  368. <button type="submit" class="btn--ui" wire:click.prevent="update()">Salva</button>
  369. @endif
  370. </div>
  371. </form>
  372. </div>
  373. </div>
  374. </div>
  375. @endif
  376. </div>
  377. @push('scripts')
  378. <link href="/css/datatables.css" rel="stylesheet" />
  379. <style>
  380. a.notSelected
  381. {
  382. display: flex;
  383. margin-right:10px;
  384. float:left;
  385. height: 2.5rem !important;
  386. width:50px;
  387. align-items: center;
  388. justify-content: center;
  389. color: var(--color-blu);
  390. background-color: #d3dce1 !important;
  391. padding: 0 1.25rem;
  392. font-size: 0.875rem;
  393. font-family: greycliff-cf, sans-serif;
  394. border-radius: 1.875rem !important;
  395. -webkit-border-radius: 1.875rem !important;
  396. -moz-border-radius: 1.875rem !important;
  397. -webkit-transition: all 0.3s ease-in-out;
  398. -moz-transition: all 0.3s ease-in-out;
  399. -o-transition: all 0.3s ease-in-out;
  400. transition: all 0.3s ease-in-out;
  401. border: none;
  402. }
  403. a.selected
  404. {
  405. display: flex;
  406. margin-right:10px;
  407. float:left;
  408. height: 2.5rem !important;
  409. width:50px;
  410. align-items: center;
  411. justify-content: center;
  412. color: #fff;
  413. background-color: var(--color-blu) !important;
  414. padding: 0 1.25rem;
  415. font-size: 0.875rem;
  416. font-family: greycliff-cf, sans-serif;
  417. border-radius: 1.875rem !important;
  418. -webkit-border-radius: 1.875rem !important;
  419. -moz-border-radius: 1.875rem !important;
  420. -webkit-transition: all 0.3s ease-in-out;
  421. -moz-transition: all 0.3s ease-in-out;
  422. -o-transition: all 0.3s ease-in-out;
  423. transition: all 0.3s ease-in-out;
  424. border: none;
  425. }
  426. div.day
  427. {
  428. margin-top:20px;
  429. color: var(--color-blu);
  430. background-color: #ffffff !important;
  431. padding: 20px;
  432. border-radius: 1.875rem !important;
  433. -webkit-border-radius: 1.875rem !important;
  434. -moz-border-radius: 1.875rem !important;
  435. -webkit-transition: all 0.3s ease-in-out;
  436. -moz-transition: all 0.3s ease-in-out;
  437. -o-transition: all 0.3s ease-in-out;
  438. transition: all 0.3s ease-in-out;
  439. border: 2px solid #d3dce1;
  440. }
  441. </style>
  442. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  443. <script src="/assets/js/datatables.js"></script>
  444. <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
  445. <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
  446. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
  447. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
  448. @endpush
  449. @push('scripts')
  450. <script>
  451. function onlyNumberAmount(input) {
  452. let v = input.value.replace(/\D+/g, '');
  453. if (v.length > 14) v = v.slice(0, 14);
  454. input.value = "€ " + v.replace(/(\d)(\d\d)$/, "$1,$2").replace(/(^\d{1,3}|\d{3})(?=(?:\d{3})+(?:,|$))/g, '$1.');
  455. }
  456. var isEdit = false;
  457. Livewire.on('setEdit', (x) =>
  458. {
  459. isEdit = x;
  460. console.log(isEdit);
  461. });
  462. function annulla()
  463. {
  464. window.onbeforeunload = null;
  465. document.location.href = '/courses';
  466. }
  467. window.onbeforeunload = function(){
  468. if (isEdit)
  469. return 'Cambiando pagina le eventuali modifiche andranno perse';
  470. };
  471. $(document).ready(function() {
  472. loadDataTable();
  473. } );
  474. Livewire.on('load-data-table', () => {
  475. loadDataTable();
  476. });
  477. function reload()
  478. {
  479. console.log($(".filterYear").val());
  480. window.location.href = '/courses?year=' + $(".filterYear").val();
  481. }
  482. function loadDataTable(){
  483. let date = new Date();
  484. let date_export = `${date.getFullYear()}${date.getMonth()}${date.getDate()}_`;
  485. if ( $.fn.DataTable.isDataTable('#tablesaw-350') ) {
  486. $('#tablesaw-350').DataTable().destroy();
  487. }
  488. $('#tablesaw-350').DataTable({
  489. processing: true,
  490. thead: {
  491. 'th': {'background-color': 'blue'}
  492. },
  493. layout: {
  494. topStart : null,
  495. topEnd : null,
  496. top1A: {
  497. // buttons: [
  498. // {
  499. // extend: 'collection',
  500. // text: 'ESPORTA',
  501. buttons: [
  502. {
  503. extend: 'excelHtml5',
  504. text: '<i class="fa-solid fa-file-excel"></i>',
  505. action: newexportaction,
  506. title: date_export + 'Corsi',
  507. exportOptions: {
  508. columns: ":not(':last')"
  509. }
  510. },
  511. {
  512. extend: 'pdfHtml5',
  513. text: '<i class="fa-solid fa-file-pdf"></i>',
  514. action: newexportaction,
  515. title: date_export + 'Corsi',
  516. exportOptions: {
  517. columns: ":not(':last')"
  518. }
  519. },
  520. {
  521. extend: 'print',
  522. action: newexportaction,
  523. text: '<i class="fa-solid fa-print"></i>',
  524. title: date_export + 'Corsi',
  525. exportOptions: {
  526. columns: ":not(':last')"
  527. }
  528. }
  529. ],
  530. // dropup: true
  531. // }
  532. // ]
  533. },
  534. top1B : {
  535. pageLength: {
  536. menu: [[10, 25, 50, 100, 100000], [10, 25, 50, 100, "Tutti"]]
  537. }
  538. },
  539. top1C :'search',
  540. },
  541. "columnDefs": [ {
  542. "targets": 0,
  543. "orderable": false
  544. } ],
  545. pagingType: 'numbers',
  546. "language": {
  547. "url": "/assets/js/Italian.json"
  548. },
  549. "fnInitComplete": function (oSettings, json) {
  550. var html = '&nbsp;<a href="#" class="addData btn--ui"><i class="fa-solid fa-plus"></i></a>';
  551. $(".dt-search").append(html);
  552. html = '&nbsp;<a href="#" class="duplicateData btn--ui" style="display:none"><i class="fa-solid fa-copy fa-lg" style="height:5px;"></i></a>';
  553. $(".dt-buttons").after(html);
  554. }
  555. });
  556. $('#tablesaw-350 thead tr th').addClass('col');
  557. $('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");
  558. var courses = [];
  559. $(".chkCourse").click(function(){
  560. var id = $(this).attr('name');
  561. if(!courses.includes(id)){
  562. courses.push(id);
  563. }else{
  564. courses.splice(courses.indexOf(id), 1); //deleting
  565. }
  566. if (courses.length > 0)
  567. $(".duplicateData").show();
  568. else
  569. $(".duplicateData").hide();
  570. console.log(courses);
  571. });
  572. $(document).ready(function() {
  573. $(document).on("click",".addData",function() {
  574. $(".title--section_addButton").trigger("click");
  575. });
  576. $(document).on("click",".duplicateData",function() {
  577. @this.duplicateMultiple(courses);
  578. });
  579. } );
  580. var all = false;
  581. $(".checkAll").click(function(){
  582. all = !all;
  583. courses = [];
  584. $('.chkCourse').each(function(){
  585. $(this).prop('checked', all);
  586. if (all)
  587. courses.push($(this).attr('name'));
  588. });
  589. if (courses.length > 0)
  590. $(".duplicateData").show();
  591. else
  592. $(".duplicateData").hide();
  593. console.log(courses);
  594. });
  595. }
  596. </script>
  597. @endpush