sponsor.blade.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <div class="col card--ui" id="card--dashboard">
  2. <header id="title--section" 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)Elenco Sponsor @else Inserimento/modifica sponsor @endif</h2>
  6. </div>
  7. @if(!$add && !$update)
  8. <div class="title--section_addButton" wire:click="add()" style="cursor: pointer;">
  9. <div class="card--ui card--ui_btnAddHeaderUser entrata d-flex justify-items-between">
  10. <header class="d-flex justify-content-between"><div class="card-title d-flex align-items-start"><h2>Aggiungi&nbsp;&nbsp;&nbsp;</h2></div><a href="#" wire:click="add()"><i class="ico--ui big add primary"></i></a></header>
  11. </div>
  12. </div>
  13. @endif
  14. </header>
  15. @if(!$add && !$update)
  16. <section id="subheader" class="d-flex align-items-center justify-content-between">
  17. <form action="" class="search--form d-flex align-items-center">
  18. <div class="input-group mb-3">
  19. <input type="text" class="form-control" placeholder="Cerca sponsor" aria-label="cerca utent" aria-describedby="button-addon2" wire:model="search">
  20. @if(false)
  21. @if($showReset)
  22. <button class="btn--ui" type="button" id="button-addon2" wire:click="resetSearch()"><i class="ico--ui search"></i>Reset</button>
  23. @else
  24. <button class="btn--ui" type="button" id="button-addon2" wire:click="search()"><i class="ico--ui search"></i>Cerca</button>
  25. @endif
  26. @endif
  27. </div>
  28. </form>
  29. </section>
  30. <section id="resume-table">
  31. <div class="compare--chart_wrapper d-none"></div>
  32. <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
  33. <thead>
  34. <tr>
  35. <th scope="col">Ragione sociale</th>
  36. <th scope="col">Indirizzo</th>
  37. <th scope="col">Email</th>
  38. <th scope="col">Telefono</th>
  39. <th scope="col">Partita IVA</th>
  40. <th scope="col">Abilitato</th>
  41. <th scope="col">...</th>
  42. </tr>
  43. </thead>
  44. <tbody id="checkall-target">
  45. @foreach($records as $record)
  46. <tr>
  47. <td>{{$record->name}}</td>
  48. <td>{{$record->address}}</td>
  49. <td>{{$record->email}}</td>
  50. <td>{{$record->phone}}</td>
  51. <td>{{$record->vat}}</td>
  52. <td> <span class="tablesaw-cell-content"><span class="badge tessera-badge {{$record->enabled ? 'active' : 'suspended'}}">{{$record->enabled ? 'attivo' : 'disattivo'}}</span></span></td>
  53. <td>
  54. <button type="button" class="btn btn-outline-primary btn-sm" wire:click="edit({{ $record->id }})">Modifica</button>
  55. <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="delete({{ $record->id }})">Elimina</button>
  56. </td>
  57. </tr>
  58. @endforeach
  59. </tbody>
  60. </table>
  61. <!--
  62. <div class="paginator d-flex justify-content-center">
  63. <nav aria-label="Page navigation example">
  64. <ul class="pagination">
  65. <li class="page-item">
  66. <a class="page-link" href="#" aria-label="Previous">
  67. <span aria-hidden="true"></span>
  68. </a>
  69. </li>
  70. <li class="page-item"><a class="page-link" href="#">1</a></li>
  71. <li class="page-item"><a class="page-link" href="#">2</a></li>
  72. <li class="page-item"><a class="page-link" href="#">3</a></li>
  73. <li class="page-item"><a class="page-link" href="#">3</a></li>
  74. <li class="page-item"><span class="more-page">...</span></li>
  75. <li class="page-item">
  76. <a class="page-link" href="#" aria-label="Next">
  77. <span aria-hidden="true"></span>
  78. </a>
  79. </li>
  80. </ul>
  81. </nav>
  82. </div>
  83. -->
  84. </section>
  85. @else
  86. @if (session()->has('error'))
  87. <div class="alert alert-danger" role="alert">
  88. {{ session()->get('error') }}
  89. </div>
  90. @endif
  91. <section id="card--container" class="">
  92. <div id="card--nuovoUtente">
  93. <ul class="nav nav-tabs" id="myTab" role="tablist">
  94. <li class="nav-item" role="presentation">
  95. <button wire:ignore.self class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home-tab-pane" type="button" role="tab" aria-controls="home-tab-pane" aria-selected="true">INFO GENERICHE</button>
  96. </li>
  97. <li class="nav-item" role="presentation">
  98. <button wire:ignore.self class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile-tab-pane" type="button" role="tab" aria-controls="profile-tab-pane" aria-selected="false">CONTRATTI</button>
  99. </li>
  100. </ul>
  101. <div class="tab-content card--ui" id="myTabContent">
  102. <!-- TAB INFO GENERICHE -->
  103. <div class="tab-pane fade show active info-tab" id="home-tab-pane" role="tabpanel" aria-labelledby="home-tab" tabindex="0" wire:ignore.self>
  104. <div class="form--wrapper">
  105. <form class="form--utente">
  106. <div class="">
  107. <div class="row g-3">
  108. <div class="col">
  109. <div class="form--item">
  110. <label for="inputName" class="form-label">Ragione sociale</label>
  111. <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Ragione sociale" wire:model="name">
  112. @error('name')
  113. <div class="invalid-feedback">{{ $message }}</div>
  114. @enderror
  115. </div>
  116. </div>
  117. </div>
  118. <div class="row mb-3">
  119. <div class="col">
  120. <div class="form--item">
  121. <label for="first_name" class="form-label">Nome</label>
  122. <input class="form-control" type="text" id="first_name" placeholder="Nome" wire:model="first_name">
  123. </div>
  124. </div>
  125. <div class="col">
  126. <div class="form--item">
  127. <label for="last_name" class="form-label">Cognome</label>
  128. <input class="form-control" type="text" id="last_name" placeholder="Cognome" wire:model="last_name">
  129. </div>
  130. </div>
  131. </div>
  132. <div class="row mb-3">
  133. <div class="col">
  134. <div class="form--item">
  135. <label for="address" class="form-label">Indirizzo</label>
  136. <input class="form-control" type="text" id="address" placeholder="Indirizzo" wire:model="address">
  137. </div>
  138. </div>
  139. <div class="col">
  140. <div class="form--item">
  141. <label for="zip_code" class="form-label">CAP</label>
  142. <input class="form-control" type="text" id="zip_code" placeholder="CAP" wire:model="zip_code" maxlength="5">
  143. </div>
  144. </div>
  145. </div>
  146. <div class="row mb-3">
  147. <div class="col">
  148. <label for="nation_id" class="form-label">Nazione</label>
  149. <select name="nation_id" class="form-select nationClass" aria-label="Seleziona una nazione" wire:model="nation_id">
  150. <option value="{{$nation_id}}">{{$this->getNation($nation_id)}}
  151. </select>
  152. </div>
  153. @if($isItaly)
  154. <div class="col">
  155. <label for="province_id" class="form-label">Provincia</label>
  156. <select name="province_id" class="form-select provinceClass" aria-label="Seleziona una provincia" wire:model="province_id">
  157. <option value="{{$province_id}}">{{$this->getProvince($province_id)}}
  158. </select>
  159. </div>
  160. <div class="col">
  161. <label for="city_id" class="form-label">Comune</label>
  162. <select name="city_id" class="form-select cityClass" aria-label="Seleziona un comune" wire:model="city_id">
  163. <option value="{{$city_id}}">{{$this->getCity($city_id)}}
  164. </select>
  165. </div>
  166. @else
  167. <div class="col"></div>
  168. <div class="col"></div>
  169. @endif
  170. </div>
  171. <div class="row mb-3">
  172. <div class="col">
  173. <div class="form--item">
  174. <label for="fiscal_code" class="form-label">Codice fiscale</label>
  175. <input class="form-control" type="text" id="fiscal_code" placeholder="Codice fiscale" wire:model="fiscal_code" maxlength="16">
  176. </div>
  177. </div>
  178. <div class="col">
  179. <div class="form--item">
  180. <label for="vat" class="form-label">Partita iva</label>
  181. <input class="form-control" type="text" id="vat" placeholder="Partita iva" wire:model="vat" maxlength="11">
  182. </div>
  183. </div>
  184. </div>
  185. <div class="row mb-3">
  186. <div class="col">
  187. <div class="form--item">
  188. <label for="phone" class="form-label">Telefono</label>
  189. <input class="form-control" type="text" id="phone" placeholder="Telefono" wire:model="phone">
  190. </div>
  191. </div>
  192. <div class="col">
  193. <div class="form--item">
  194. <label for="email" class="form-label">Email</label>
  195. <input class="form-control" type="text" id="email" placeholder="Email" wire:model="email">
  196. </div>
  197. </div>
  198. </div>
  199. <span class="title-form primary d-block w-100">Contratti</span>
  200. <div class="row mb-3">
  201. <div class="col">
  202. <div class="form--item">
  203. <div class="form-check form-check-inline">
  204. <input class="form-check-input" type="checkbox" id="enabled" wire:model="enabled">
  205. <label class="form-check-label" for="enabled">Abilitato</label>
  206. </div>
  207. </div>
  208. </div>
  209. </div>
  210. </div>
  211. </form>
  212. </div>
  213. </div>
  214. <div class="tab-pane fade tasseramento-tab" id="profile-tab-pane" role="tabpanel" aria-labelledby="profile-tab" tabindex="0" wire:ignore.self>
  215. @if(!$addContract && !$updateContract)
  216. <section id="resume-table">
  217. <div class="compare--chart_wrapper d-none"></div>
  218. <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350-1">
  219. <thead>
  220. <tr>
  221. <th scope="col">Data inizio</th>
  222. <th scope="col">Data fine</th>
  223. <th scope="col">Data sottoscrizione</th>
  224. <th scope="col">Valore</th>
  225. <th scope="col">Contratto</th>
  226. <th scope="col">...</th>
  227. </tr>
  228. </thead>
  229. <tbody id="checkall-target">
  230. @foreach($contracts as $contract)
  231. <tr>
  232. <td>{{date("d/m/Y", strtotime($contract->from_date))}}</td>
  233. <td>{{date("d/m/Y", strtotime($contract->to_date))}}</td>
  234. <td>{{date("d/m/Y", strtotime($contract->subscription_date))}}</td>
  235. <td>{{$contract->amount}}</td>
  236. <td>{!!$contract->file != '' ? '<a href="/storage/app/public/' . $contract->file . '" target="_blank">Visualizza</a>' : ''!!}</td>
  237. <td>
  238. <button type="button" class="btn btn-outline-primary btn-sm" wire:click="editContract({{ $contract->id }})">Modifica</button>
  239. <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="deleteContract({{ $contract->id }})">Elimina</button>
  240. </td>
  241. </tr>
  242. @endforeach
  243. </tbody>
  244. </table>
  245. <button type="submit" class="btn--ui" wire:click.prevent="addContract()">Aggiungi</button>
  246. </section>
  247. @else
  248. <div class="container">
  249. <div class="row">
  250. <div class="col">
  251. <form action="">
  252. <div class="row mb-3">
  253. <div class="col">
  254. <div class="form--item">
  255. <label class="form-label">Data inizio</label>
  256. <input class="form-control @error('from_date') is-invalid @enderror" type="date" wire:model="from_date">
  257. @error('from_date')
  258. <div class="invalid-feedback">{{ $message }}</div>
  259. @enderror
  260. </div>
  261. </div>
  262. <div class="col">
  263. <div class="form--item">
  264. <label class="form-label">Data fine</label>
  265. <input class="form-control js-keyupTitle @error('to_date') is-invalid @enderror" type="date" placeholder="Data fine" wire:model="to_date">
  266. @error('to_date')
  267. <div class="invalid-feedback">{{ $message }}</div>
  268. @enderror
  269. </div>
  270. </div>
  271. <div class="col">
  272. <div class="form--item">
  273. <label class="form-label">Data sottoscrizione</label>
  274. <input class="form-control js-keyupTitle @error('subscription_date') is-invalid @enderror" type="date" id="subscription_date" placeholder="Data sottoscrizione" wire:model="subscription_date">
  275. @error('subscription_date')
  276. <div class="invalid-feedback">{{ $message }}</div>
  277. @enderror
  278. </div>
  279. </div>
  280. <div class="col">
  281. <div class="form--item">
  282. <label class="form-label">Importo</label>
  283. <input class="form-control js-keyupTitle @error('amount') is-invalid @enderror" type="text" id="amount" placeholder="Importo" wire:model="amount">
  284. @error('amount')
  285. <div class="invalid-feedback">{{ $message }}</div>
  286. @enderror
  287. </div>
  288. </div>
  289. <div class="col">
  290. <div class="form--item">
  291. <label class="form-label">Contratto</label>
  292. <input class="form-control" type="file" wire:model="file">
  293. {!!$file_old != '' ? '<br><a href="/storage/app/public/' . $file_old . '" target="_blank">Visualizza</a>' : ''!!}
  294. </div>
  295. </div>
  296. </div>
  297. <div class="form--item">
  298. @if($addContract)
  299. <button type="submit" class="btn--ui" wire:click.prevent="storeContract()">Salva</button>
  300. @endif
  301. @if($updateContract)
  302. <button type="submit" class="btn--ui" wire:click.prevent="updateContract()">Salva</button>
  303. @endif
  304. <button type="button" class="btn--ui lightGrey" wire:click="cancelContract()">Annulla</button>
  305. </div>
  306. </form>
  307. </div>
  308. </div>
  309. </div>
  310. @endif
  311. </div>
  312. </div>
  313. </div>
  314. </section>
  315. <section class="save--section d-flex justify-content-start">
  316. @if($add)
  317. <button type="submit" class="btn--ui" wire:click.prevent="store()">Salva</button>
  318. @endif
  319. @if($update)
  320. <button type="submit" class="btn--ui" wire:click.prevent="update()">Salva</button>
  321. @endif
  322. <button type="button" class="btn--ui lightGrey" wire:click="cancel()">Annulla</button>
  323. </section>
  324. @endif
  325. </div>
  326. @push('scripts')
  327. <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  328. <style>
  329. .select2-container--default .select2-selection--single{
  330. background-color: #E9F0F5;
  331. border: 0.0625rem solid #DFE5EB;
  332. font-size: 0.75rem;
  333. }
  334. .select2-selection
  335. {
  336. height: 38px !important;
  337. }
  338. .select2-selection__rendered
  339. {
  340. padding-top:3px;
  341. }
  342. </style>
  343. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  344. <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  345. @endpush
  346. @push('scripts')
  347. <script>
  348. function matchStart(params, data) {
  349. params.term = params.term || '';
  350. if (data.text.toUpperCase().indexOf(params.term.toUpperCase()) == 0) {
  351. return data;
  352. }
  353. return false;
  354. }
  355. var nation_id = 0;
  356. var province_id = 0;
  357. Livewire.on('load-select', () => {
  358. $('.nationClass').select2({
  359. ajax: {
  360. url: '/nations',
  361. dataType: 'json'
  362. }
  363. });
  364. $('.nationClass').on('change', function (e) {
  365. nation_id = $('.nationClass').select2("val");
  366. province_id = 0;
  367. @this.set('nation_id', nation_id);
  368. @this.set('province_id', 0);
  369. @this.set('city_id', 0);
  370. @this.checkIsItaly();
  371. });
  372. $('.provinceClass').select2({
  373. ajax: {
  374. url: '/provinces/' + nation_id,
  375. dataType: 'json'
  376. }
  377. });
  378. $('.provinceClass').on('change', function (e) {
  379. province_id = $('.provinceClass').select2("val");
  380. @this.set('province_id', province_id);
  381. @this.set('city_id', 0);
  382. });
  383. $('.cityClass').select2({
  384. ajax: {
  385. url: '/cities/' + province_id,
  386. dataType: 'json'
  387. }
  388. });
  389. $('.cityClass').on('change', function (e) {
  390. var data = $('.cityClass').select2("val");
  391. @this.set('city_id', data);
  392. });
  393. $('.nationBirthClass').select2({
  394. ajax: {
  395. url: '/nations',
  396. dataType: 'json'
  397. }
  398. });
  399. });
  400. Livewire.on('load-provinces', (nation_id, element) => {
  401. $('.' + element).select2({
  402. ajax: {
  403. url: '/provinces/' + nation_id,
  404. dataType: 'json'
  405. }
  406. });
  407. });
  408. Livewire.on('load-cities', (province_id, element) => {
  409. $('.' + element).select2({
  410. ajax: {
  411. url: '/cities/' + province_id,
  412. dataType: 'json'
  413. }
  414. });
  415. });
  416. </script>
  417. <script>
  418. $(document).ready(function() {
  419. loadDataTable();
  420. } );
  421. Livewire.on('load-data-table', () => {
  422. loadDataTable();
  423. });
  424. function loadDataTable(){
  425. $('#tablesaw-350').DataTable({
  426. fixedHeader: true,
  427. thead: {
  428. 'th': {'background-color': 'blue'}
  429. },
  430. layout: {
  431. topStart: {
  432. buttons: ['csv', 'excel', 'pdf', 'print']
  433. }
  434. },
  435. pagingType: 'numbers',
  436. "language": {
  437. "url": "/assets/js/Italian.json"
  438. }
  439. });
  440. $('#tablesaw-350 thead tr th').addClass('col');
  441. $('#tablesaw-350 thead tr th').css("background-color", "#EDF0F2");
  442. }
  443. </script>
  444. @endpush