supplier.blade.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  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)Fornitori @else Inserimento/modifica fornitore @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. <section id="resume-table">
  17. <div class="compare--chart_wrapper d-none"></div>
  18. <table class="table tablesaw tablesaw-stack" width="100%" id="tablesaw-350" width="100%">
  19. <thead>
  20. <tr>
  21. <th scope="col">Nome</th>
  22. <th scope="col">Indirizzo</th>
  23. <th scope="col">Email</th>
  24. <th scope="col">Abilitato</th>
  25. <th scope="col">...</th>
  26. </tr>
  27. </thead>
  28. <tbody id="checkall-target">
  29. @foreach($records as $record)
  30. <tr>
  31. <td>{{$record->name}}</td>
  32. <td>{{$record->address}}</td>
  33. <td>{{$record->email}}</td>
  34. <td> <span class="tablesaw-cell-content"><span class="badge tessera-badge {{$record->enabled ? 'active' : 'suspended'}}">{{$record->enabled ? 'attivo' : 'disattivo'}}</span></span></td>
  35. <td>
  36. <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>
  37. <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>
  38. </td>
  39. </tr>
  40. @endforeach
  41. </tbody>
  42. </table>
  43. <!--
  44. <div class="paginator d-flex justify-content-center">
  45. <nav aria-label="Page navigation example">
  46. <ul class="pagination">
  47. <li class="page-item">
  48. <a class="page-link" href="#" aria-label="Previous">
  49. <span aria-hidden="true"></span>
  50. </a>
  51. </li>
  52. <li class="page-item"><a class="page-link" href="#">1</a></li>
  53. <li class="page-item"><a class="page-link" href="#">2</a></li>
  54. <li class="page-item"><a class="page-link" href="#">3</a></li>
  55. <li class="page-item"><a class="page-link" href="#">3</a></li>
  56. <li class="page-item"><span class="more-page">...</span></li>
  57. <li class="page-item">
  58. <a class="page-link" href="#" aria-label="Next">
  59. <span aria-hidden="true"></span>
  60. </a>
  61. </li>
  62. </ul>
  63. </nav>
  64. </div>
  65. -->
  66. </section>
  67. @else
  68. <div class="container">
  69. @if (session()->has('error'))
  70. <div class="alert alert-danger" role="alert">
  71. {{ session()->get('error') }}
  72. </div>
  73. @endif
  74. <div class="row">
  75. <div class="col">
  76. <form action="">
  77. <div class="row mb-3">
  78. <div class="col">
  79. <div class="form--item">
  80. <label for="inputName" class="form-label">Nome</label>
  81. <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Nome" wire:model="name">
  82. @error('name')
  83. <div class="invalid-feedback">{{ $message }}</div>
  84. @enderror
  85. </div>
  86. </div>
  87. </div>
  88. <div class="row mb-3">
  89. <div class="col">
  90. <div class="form--item">
  91. <label for="address" class="form-label">Indirizzo</label>
  92. <input class="form-control" type="text" id="address" placeholder="Indirizzo" wire:model="address">
  93. </div>
  94. </div>
  95. <div class="col">
  96. <div class="form--item">
  97. <label for="zip_code" class="form-label">CAP</label>
  98. <input class="form-control" id="zip_code" placeholder="CAP" wire:model="zip_code" maxlength="5">
  99. </div>
  100. </div>
  101. </div>
  102. <div class="row mb-3">
  103. <div class="col-md-6 mb-3">
  104. <label for="nation_id" class="form-label">Nazione</label>
  105. <select name="nation_id" class="form-select nationClass" aria-label="Seleziona una nazione" wire:model="nation_id">
  106. <option value="{{$nation_id}}">{{$this->getNation($nation_id)}}
  107. </select>
  108. </div>
  109. @if($isItaly)
  110. <div class="col-md-6 mb-3">
  111. <label for="province_id" class="form-label">Provincia</label>
  112. <select name="province_id" class="form-select provinceClass" aria-label="Seleziona una provincia" wire:model="province_id">
  113. <option value="{{$province_id}}">{{$this->getProvince($province_id)}}
  114. </select>
  115. </div>
  116. <div class="col-md-6 mb-3">
  117. <label for="city_id" class="form-label">Comune</label>
  118. <select name="city_id" class="form-select cityClass" aria-label="Seleziona un comune" wire:model="city_id">
  119. <option value="{{$city_id}}">{{$this->getCity($city_id)}}
  120. </select>
  121. </div>
  122. @else
  123. <div class="col"></div>
  124. <div class="col"></div>
  125. @endif
  126. </div>
  127. <div class="row mb-3">
  128. <div class="col">
  129. <div class="form--item">
  130. <label for="fiscal_code" class="form-label">Codice fiscale</label>
  131. <input class="form-control" type="text" id="fiscal_code" placeholder="Codice fiscale" wire:model="fiscal_code" maxlength="16">
  132. </div>
  133. </div>
  134. <div class="col">
  135. <div class="form--item">
  136. <label for="vat" class="form-label">Partita iva</label>
  137. <input class="form-control" type="text" id="vat" placeholder="Partita iva" wire:model="vat" maxlength="11">
  138. </div>
  139. </div>
  140. </div>
  141. <div class="row mb-3">
  142. <div class="col">
  143. <div class="form--item">
  144. <label for="website" class="form-label">Sito web</label>
  145. <input class="form-control" type="text" id="website" placeholder="Sito web" wire:model="website">
  146. </div>
  147. </div>
  148. <div class="col"></div>
  149. </div>
  150. <div class="row mb-3">
  151. <div class="col">
  152. <div class="form--item">
  153. <label for="email" class="form-label">Email</label>
  154. <input class="form-control" type="text" id="email" placeholder="Email" wire:model="email">
  155. </div>
  156. </div>
  157. <div class="col">
  158. <div class="form--item">
  159. <label for="phone" class="form-label">Telefono</label>
  160. <input class="form-control" type="text" id="phone" placeholder="Telefono" wire:model="phone">
  161. </div>
  162. </div>
  163. </div>
  164. <span class="title-form primary d-block w-100">Referente</span>
  165. <div class="row mb-3">
  166. <div class="col">
  167. <div class="form--item">
  168. <label for="referent_first_name" class="form-label">Nome</label>
  169. <input class="form-control" type="text" id="referent_first_name" placeholder="Nome" wire:model="referent_first_name">
  170. </div>
  171. </div>
  172. <div class="col">
  173. <div class="form--item">
  174. <label for="referent_last_name" class="form-label">Cognome</label>
  175. <input class="form-control" type="text" id="referent_last_name" placeholder="Cognome" wire:model="referent_last_name">
  176. </div>
  177. </div>
  178. </div>
  179. <div class="row mb-3">
  180. <div class="col">
  181. <div class="form--item">
  182. <label for="referent_phone" class="form-label">Telefono</label>
  183. <input class="form-control" type="text" id="referent_phone" placeholder="Telefono" wire:model="referent_phone">
  184. </div>
  185. </div>
  186. <div class="col">
  187. <div class="form--item">
  188. <label for="referent_mobile" class="form-label">Cellulare</label>
  189. <input class="form-control" type="text" id="referent_mobile" placeholder="Cellulare" wire:model="referent_mobile">
  190. </div>
  191. </div>
  192. </div>
  193. <div class="row mb-3">
  194. <div class="col">
  195. <div class="form--item">
  196. <label for="referent_email" class="form-label">Email</label>
  197. <input class="form-control" type="text" id="referent_email" placeholder="Email" wire:model="referent_email">
  198. </div>
  199. </div>
  200. <div class="col"></div>
  201. </div>
  202. <div class="row mb-3">
  203. <div class="col">
  204. <div class="form--item">
  205. <div class="form-check form-check-inline">
  206. <input class="form-check-input" type="checkbox" id="enabled" wire:model="enabled">
  207. <label class="form-check-label" for="enabled">Abilitato</label>
  208. </div>
  209. </div>
  210. </div>
  211. </div>
  212. <!-- // inline input field -->
  213. <div class="form--item">
  214. @if($add)
  215. <button type="submit" class="btn--ui" wire:click.prevent="store()">Salva</button>
  216. @endif
  217. @if($update)
  218. <button type="submit" class="btn--ui" wire:click.prevent="update()">Salva</button>
  219. @endif
  220. <button type="button" class="btn--ui lightGrey" wire:click="cancel()">Annulla</button>
  221. </div>
  222. </form>
  223. </div>
  224. </div>
  225. </div>
  226. @endif
  227. </div>
  228. @push('scripts')
  229. <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  230. <style>
  231. .select2-container--default .select2-selection--single{
  232. background-color: #E9F0F5;
  233. border: 0.0625rem solid #DFE5EB;
  234. font-size: 0.75rem;
  235. }
  236. .select2-selection
  237. {
  238. height: 38px !important;
  239. }
  240. .select2-selection__rendered
  241. {
  242. padding-top:3px;
  243. }
  244. </style>
  245. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  246. <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  247. @endpush
  248. @push('scripts')
  249. <script>
  250. function matchStart(params, data) {
  251. params.term = params.term || '';
  252. if (data.text.toUpperCase().indexOf(params.term.toUpperCase()) == 0) {
  253. return data;
  254. }
  255. return false;
  256. }
  257. var nation_id = 0;
  258. var province_id = 0;
  259. Livewire.on('load-select', () => {
  260. $('.nationClass').select2({
  261. ajax: {
  262. url: '/nations',
  263. dataType: 'json'
  264. }
  265. });
  266. $('.nationClass').on('change', function (e) {
  267. nation_id = $('.nationClass').select2("val");
  268. province_id = 0;
  269. @this.set('nation_id', nation_id);
  270. @this.set('province_id', 0);
  271. @this.set('city_id', 0);
  272. @this.checkIsItaly();
  273. });
  274. $('.provinceClass').select2({
  275. ajax: {
  276. url: '/provinces/' + nation_id,
  277. dataType: 'json'
  278. }
  279. });
  280. $('.provinceClass').on('change', function (e) {
  281. province_id = $('.provinceClass').select2("val");
  282. @this.set('province_id', province_id);
  283. @this.set('city_id', 0);
  284. });
  285. $('.cityClass').select2({
  286. ajax: {
  287. url: '/cities/' + province_id,
  288. dataType: 'json'
  289. }
  290. });
  291. $('.cityClass').on('change', function (e) {
  292. var data = $('.cityClass').select2("val");
  293. @this.set('city_id', data);
  294. });
  295. $('.nationBirthClass').select2({
  296. ajax: {
  297. url: '/nations',
  298. dataType: 'json'
  299. }
  300. });
  301. });
  302. Livewire.on('load-provinces', (nation_id, element) => {
  303. $('.' + element).select2({
  304. ajax: {
  305. url: '/provinces/' + nation_id,
  306. dataType: 'json'
  307. }
  308. });
  309. });
  310. Livewire.on('load-cities', (province_id, element) => {
  311. $('.' + element).select2({
  312. ajax: {
  313. url: '/cities/' + province_id,
  314. dataType: 'json'
  315. }
  316. });
  317. });
  318. </script>
  319. <link href="/css/datatables.css" rel="stylesheet" />
  320. <script src="/assets/js/datatables.js"></script>
  321. <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
  322. <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
  323. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
  324. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
  325. <script>
  326. $(document).ready(function() {
  327. loadDataTable();
  328. } );
  329. Livewire.on('load-data-table', () => {
  330. loadDataTable();
  331. });
  332. function loadDataTable(){
  333. $('#tablesaw-350').DataTable({
  334. fixedHeader: true,
  335. thead: {
  336. 'th': {'background-color': 'blue'}
  337. },
  338. layout: {
  339. topStart : null,
  340. topEnd : null,
  341. top1A: {
  342. buttons: [
  343. {
  344. extend: 'collection',
  345. text: 'Esporta',
  346. buttons: [
  347. {
  348. extend: 'excelHtml5',
  349. title: 'Fornitori',
  350. exportOptions: {
  351. columns: ":not(':last')"
  352. }
  353. },
  354. {
  355. extend: 'pdfHtml5',
  356. title: 'Fornitori',
  357. exportOptions: {
  358. columns: ":not(':last')"
  359. }
  360. },
  361. {
  362. extend: 'print',
  363. text: 'Stampa',
  364. title: 'Fornitori',
  365. exportOptions: {
  366. columns: ":not(':last')"
  367. }
  368. }
  369. ],
  370. dropup: true
  371. }
  372. ]
  373. },
  374. top1B : {
  375. pageLength: {
  376. menu: [[10, 25, 50, 100, 100000], [10, 25, 50, 100, "Tutti"]]
  377. }
  378. },
  379. top1C :'search',
  380. },
  381. pagingType: 'numbers',
  382. "language": {
  383. "url": "/assets/js/Italian.json"
  384. },
  385. "fnInitComplete": function (oSettings, json) {
  386. var html = '&nbsp;<a href="#" class="addData btn--ui"><i class="fa-solid fa-plus"></i></a>';
  387. $(".dt-search").append(html);
  388. }
  389. });
  390. $('#tablesaw-350 thead tr th').addClass('col');
  391. $('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");
  392. $(document).ready(function() {
  393. $(document).on("click",".addData",function() {
  394. $(".title--section_addButton").trigger("click")
  395. });
  396. } );
  397. }
  398. </script>
  399. @endpush