records_out.blade.php 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844
  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 uscite me-2"></i>
  5. <h2 class="primary" >@if(!$add && !$update)Uscite @else Inserimento/modifica uscita @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. <div class="title--section_addButton d-flex justify-content-end">
  17. <button type="button" class="btn--ui entrata"
  18. wire:click="openImportModal" onclick="openImportModal()">
  19. Importa
  20. </button>
  21. </div>
  22. <div class="modal fade" id="importModal" tabindex="-1" aria-labelledby="importModalLabel" aria-hidden="true"
  23. wire:ignore.self>
  24. <div class="modal-dialog">
  25. <div class="modal-content">
  26. <div class="modal-header" style="background-color: #0C6197!important;">
  27. <h5 class="modal-title" id="importModalLabel">Importa fatture passive</h5>
  28. <button type="button" class="btn-close" onclick="closeImportModal()" aria-label="Close"></button>
  29. </div>
  30. <div class="modal-body">
  31. <form wire:submit.prevent="importReceipts">
  32. <div class="mb-3" wire:ignore>
  33. <label for="selectedCausal" class="form-label">Seleziona causale uscita*</label>
  34. <select class="form-select import-causal-select" required id="selectedCausal" wire:model.defer="selectedCausal">
  35. <option value="">Seleziona una causale</option>
  36. @forelse($importCausals as $causal)
  37. <option value="{{ $causal['id'] }}">{{ $causal['name'] }}</option>
  38. @empty
  39. <option value="" disabled>Nessuna causale disponibile</option>
  40. @endforelse
  41. </select>
  42. @error('selectedCausal') <span class="text-danger">{{ $message }}</span> @enderror
  43. </div>
  44. <div class="mb-3">
  45. <label for="receiptFiles" class="form-label">Seleziona files xml</label>
  46. <input type="file" class="form-control" id="receiptFiles" wire:model="receiptFiles" multiple>
  47. @error('receiptFiles.*') <span class="text-danger">{{ $message }}</span> @enderror
  48. <small class="form-text text-muted">Massimo {{ ini_get('max_file_uploads') }} file consentiti.</small>
  49. </div>
  50. <div class="progress mb-2" wire:ignore>
  51. <div class="progress-bar" role="progressbar" style="width: 0%" aria-valuenow="0"
  52. aria-valuemin="0" aria-valuemax="100">0%
  53. </div>
  54. </div>
  55. <div class="d-flex justify-content-end">
  56. <button type="button" class="btn--ui lightGrey me-2" onclick="closeImportModal()">Annulla</button>
  57. <button type="submit" class="btn--ui" >Importa</button>
  58. </div>
  59. </form>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. <section id="subheader" class="d-flex align-items-center justify-content-between">
  65. @if(false)
  66. <form action="" class="group--action d-flex align-items-center">
  67. <select class="form-select form-select-lg me-1" aria-label=".form-select-lg example" wire:model="multipleAction">
  68. <option selected>Azione multipla</option>
  69. <option value="delete"><i class="fa-regular fa-trash-can"></i></option>
  70. </select>
  71. <button type="submit" class="btn--ui" wire:click.prevent="executeMultipleAction()">applica</button>
  72. </form>
  73. <form action="" class="compare--form d-flex align-items-center">
  74. <select class="form-select form-select-lg me-1" aria-label=".form-select-lg example" wire:model="selectedFilter">
  75. <option value="">--Seleziona--</option>
  76. <option value="0">Oggi</option>
  77. <option value="1">Questo mese: <span class="date-range">{{date("01/m/Y")}} - {{date("t/m/Y")}}</span></option>
  78. <option value="2">Questo anno: <span class="date-range">{{date("01/01/Y")}} - {{date("31/12/Y")}}</span></option>
  79. <option value="3">Tutte</option>
  80. </select>
  81. </form>
  82. @endif
  83. </section>
  84. <div class="showFilter" style="display:none">
  85. <hr size="1">
  86. <div class="row g-3">
  87. <div class="col-md-2">
  88. <div class="row">
  89. <div class="col-md-12" style="margin-bottom:10px;">
  90. <b>Periodo</b>
  91. </div>
  92. <div class="col-12">
  93. <input id="dateFrom" type="date" class="form-control filterFrom mb-2" >
  94. </div>
  95. <div class="col-12">
  96. <input id="dateTo" type="date" class="form-control filterTo" >
  97. </div>
  98. <div class="col-6 mt-2">
  99. <button class="btn--ui lightGrey todayButton" style="width:100%" onclick="setToday('{{date("Y-m-d")}}')">OGGI</button>
  100. </div>
  101. <div class="col-6 mt-2">
  102. <button class="btn--ui lightGrey yesterdayButton" style="width:100%" onclick="setYesterday('{{date("Y-m-d",strtotime("-1 days"))}}')">IERI</button>
  103. </div>
  104. </div>
  105. </div>
  106. <div class="col-md-2">
  107. <div class="row">
  108. <div class="col-md-12" style="margin-bottom:10px;">
  109. <b>Fornitore</b>
  110. </div>
  111. <div class="col-12">
  112. <select name="search_supplier_id" class="form-select filterSupplier">
  113. <option value="">--Seleziona--
  114. @foreach($suppliers as $supplier)
  115. <option value="{{$supplier->id}}">{{$supplier->name}}
  116. @endforeach
  117. </select>
  118. </div>
  119. </div>
  120. </div>
  121. <div class="col-md-2">
  122. <div class="row">
  123. <div class="col-md-12" style="margin-bottom:10px;">
  124. <b>Metodi di pagamento</b>
  125. </div>
  126. <div class="col-12">
  127. <select name="search_payment_method_id" class="form-select filterPaymentMethod" multiple="multiple">
  128. @foreach($payments as $payment)
  129. <option value="{{$payment->id}}">{{$payment->name}}
  130. @endforeach
  131. </select>
  132. </div>
  133. </div>
  134. </div>
  135. <div class="col-md-2">
  136. <div class="row">
  137. <div class="col-md-12" style="margin-bottom:10px;">
  138. <b>Causali</b>
  139. </div>
  140. <div class="col-12">
  141. <select name="search_causal_id" class="form-select filterCausals" multiple="multiple">
  142. @foreach($causals as $causal)
  143. <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
  144. @endforeach
  145. </select>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. <div class="row g-3">
  151. <div class="col-md-12" style="text-align:right">
  152. <button class="btn--ui lightGrey" onclick="reset()">Reset</button>
  153. <button class="btn--ui" onclick="loadDataTable()">FILTRA</button>
  154. </div>
  155. </div>
  156. <hr size="1">
  157. </div>
  158. <section id="resume-table">
  159. <div class="compare--chart_wrapper d-none"></div>
  160. <table class="table tablesaw tableHead tablesaw-stack table--lista_entrate tableHead" id="tablesaw-350" width="100%">
  161. <thead>
  162. <tr>
  163. <th scope="col">N° Fattura</th>
  164. <th scope="col">Data</th>
  165. <th scope="col">Importo</th>
  166. <th scope="col">Fornitore</th>
  167. <th scope="col">Causale</th>
  168. <th scope="col">Pagamento</th>
  169. <th scope="col">Stato</th>
  170. <th scope="col">...</th>
  171. </tr>
  172. </thead>
  173. <tbody id="checkall-target">
  174. </tbody>
  175. </table>
  176. <br><b class="totalDiv"></b>
  177. </section>
  178. @else
  179. <a style="margin-top:20px" class="btn--ui lightGrey" href="/{{$fromPage != '' ? ($fromPage . '?showFilters=1') : 'out'}}"><i class="fa-solid fa-arrow-left"></i></a><br><br>
  180. @if (session()->has('error'))
  181. <div class="alert alert-danger" role="alert">
  182. {{ session()->get('error') }}
  183. </div>
  184. @endif
  185. <section id="accountingExit" class="d-flex" wire:key='reload-{{$selectId}}'>
  186. <div class="accountingExit_data">
  187. <form class="form--accounting">
  188. <div class="row gx-2">
  189. <div class="col-md-12">
  190. <span class="title-form d-block w-100">Tipologia</span>
  191. <div class="input-group mb-3">
  192. <div class="check--invoice d-flex align-items-center">
  193. <div class="form-check me-3">
  194. <input class="form-check-input" type="radio" value="1" wire:model="commercial" id="commercial_1">
  195. <label class="form-check-label" for="commercial_1" style="cursor: pointer;">&nbsp;Commerciale</label>
  196. </div>
  197. <div class="form-check">
  198. <input class="form-check-input" type="radio" value="0" wire:model="commercial" id="commercial_0">
  199. <label class="form-check-label" for="commercial_0" style="cursor: pointer;">&nbsp;Non Commerciale</label>
  200. </div>
  201. </div>
  202. </div>
  203. </div>
  204. <span class="title-form d-block w-100">N° Fattura</span>
  205. <div class="input-group mb-3">
  206. <div class="col-md-6">
  207. <input class="form-control " type="text" placeholder="Numero fattura" wire:model="numero_fattura">
  208. </div>
  209. </div>
  210. <div class="col-md-6">
  211. <span class="title-form d-block w-100">Data</span>
  212. <div class="input-group mb-3">
  213. <input id="date" type="date" class="form-control" wire:model="date">
  214. </div>
  215. </div>
  216. <div class="col-md-6">
  217. <span class="title-form d-block w-100">Data Pagamento</span>
  218. <div class="input-group mb-3">
  219. <input id="datePagamento" type="date" class="form-control" wire:model="data_pagamento">
  220. </div>
  221. </div>
  222. <div class="col-12">
  223. <span class="title-form d-block w-100">Fornitore</span>
  224. <select name="supplier_id" class="form-select supplierClass @error('supplier_id') is-invalid @enderror" aria-label="Seleziona un fornitore" wire:model="supplier_id">
  225. <option value="">--Seleziona--
  226. @foreach($suppliers as $supplier)
  227. <option value="{{$supplier->id}}">{{$supplier->name}}
  228. @endforeach
  229. </select>
  230. @error('supplier_id')
  231. <div class="invalid-feedback">{{ $message }}</div>
  232. @enderror
  233. </div>
  234. </div>
  235. <div class="row gx-2 mt-5">
  236. <span class="title-form d-block w-100">Metodo di pagamento</span>
  237. <div class="col-md-6">
  238. <select name="payment_method_id" class="form-select paymentClass @error('payment_method_id') is-invalid @enderror" aria-label="Seleziona un metodo di pagamento" wire:model="payment_method_id">
  239. <option value="">--Seleziona--
  240. @foreach($payments as $payment)
  241. <option value="{{$payment->id}}">{{$payment->name}}
  242. @endforeach
  243. </select>
  244. @error('payment_method_id')
  245. <div class="invalid-feedback">{{ $message }}</div>
  246. @enderror
  247. </div>
  248. </div>
  249. <div class="row gx-2 mt-5">
  250. <span class="title-form d-block w-100">Allegato</span>
  251. <div class="col-md-12">
  252. @if ($attachment_old != '')
  253. <div class="alert alert-info d-flex align-items-center justify-content-between mb-3">
  254. <div class="d-flex align-items-center">
  255. <i class="fa-solid fa-paperclip me-2"></i>
  256. <div>
  257. <strong>Allegato presente:</strong>
  258. <a href="{{ $this->getAttachmentUrl($attachment_old) }}" target="_blank" class="ms-2 btn btn-sm btn-outline-primary">
  259. <i class="fa-regular fa-eye me-1"></i>Visualizza
  260. </a>
  261. </div>
  262. </div>
  263. <button type="button"
  264. wire:click.prevent="removeAttachment()"
  265. class="btn btn-sm btn-outline-danger"
  266. data-bs-toggle="popover"
  267. data-bs-trigger="hover focus"
  268. data-bs-placement="bottom"
  269. data-bs-content="Elimina allegato corrente">
  270. <i class="fa-regular fa-trash-can me-1"></i>Rimuovi
  271. </button>
  272. </div>
  273. @endif
  274. <div class="mb-3">
  275. <label for="attachment" class="form-label">
  276. @if ($attachment_old != '')
  277. Sostituisci allegato esistente
  278. @else
  279. Carica nuovo allegato
  280. @endif
  281. </label>
  282. <input class="form-control"
  283. type="file"
  284. id="attachment"
  285. wire:model="attachment"
  286. accept="image/*,.pdf,.doc,.docx,.xml,.txt,.csv,.xls,.xlsx">
  287. </div>
  288. @if($attachment)
  289. <div class="alert alert-success d-flex align-items-center mb-3">
  290. <i class="fa-solid fa-check-circle me-2"></i>
  291. <div>
  292. <strong>Nuovo allegato selezionato:</strong>
  293. <span class="text-muted">{{ $attachment->getClientOriginalName() }}</span>
  294. </div>
  295. </div>
  296. @endif
  297. @error('attachment')
  298. <div class="alert alert-danger">
  299. <i class="fa-solid fa-exclamation-triangle me-2"></i>{{ $message }}
  300. </div>
  301. @enderror
  302. <small class="form-text text-muted">
  303. <i class="fa-solid fa-info-circle me-1"></i>
  304. <strong>Formati supportati:</strong> Immagini, PDF, documenti Word, XML, TXT, CSV, Excel.
  305. <strong>Dimensione massima:</strong> 10MB.
  306. </small>
  307. </div>
  308. </div>
  309. @foreach($rows as $idx => $row)
  310. <div class="row gx-2 mt-5" wire:ignore.self>
  311. <span class="title-form d-block w-100">Causale</span>
  312. <div class="col-md-12">
  313. <livewire:causals :type="$typeOUT" :idx="$idx" :causal_id="$rows[$idx]['causal_id']" :wire:key="$idx" />
  314. @if(false)
  315. <select name="rows.{{$idx}}.causal_id" class="form-select causalClass @error('row.' . $idx . '.causal_id') is-invalid @enderror" aria-label="Seleziona una causale" wire:model="rows.{{$idx}}.causal_id">
  316. <option value="">--Seleziona--
  317. @foreach($causals as $causal)
  318. <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
  319. @endforeach
  320. </select>
  321. @error('causal_id')
  322. <div class="invalid-feedback">{{ $message }}</div>
  323. @enderror
  324. @endif
  325. @error('rows.'. $idx . '.causal_id')
  326. <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
  327. @enderror
  328. </div>
  329. </div>
  330. <div class="row gx-2 mt-5">
  331. <span class="title-form d-block w-100">Dettaglio causale</span>
  332. <div class="col-md-12">
  333. <textarea class="form-control" style ="background-color: #E9F0F5 !important;" placeholder="Dettaglio causale" wire:model="rows.{{$idx}}.note"></textarea>
  334. </div>
  335. </div>
  336. <div class="row gx-2 mt-5 align-items-center">
  337. <div class="col-md-6">
  338. <span class="total primary">Imponibile</span>
  339. </div>
  340. <div class="col-md-6">
  341. @if($add)
  342. <input type="text" class="form-control totalInput text-end @error('rows.{{$idx}}.imponibile') is-invalid @enderror"
  343. id="rows.{{$idx}}.imponibile" wire:model="rows.{{$idx}}.imponibile"
  344. wire:keydown.enter="store(false)" onkeyup="onlyNumberAmount(this)" placeholder="€ 0,00">
  345. @endif
  346. @if($update)
  347. <input type="text" class="form-control totalInput text-end @error('rows.{{$idx}}.imponibile') is-invalid @enderror"
  348. id="rows.{{$idx}}.imponibile" placeholder="€ 0,00" wire:model="rows.{{$idx}}.imponibile"
  349. onkeyup="onlyNumberAmount(this)" wire:keydown.enter="update(false)">
  350. @endif
  351. @error('rows.'. $idx . '.imponibile')
  352. <span style="margin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
  353. @enderror
  354. </div>
  355. </div>
  356. @if($commercial)
  357. <div class="row gx-2 mt-5 align-items-center">
  358. <div class="col-md-6">
  359. <span class="total primary">Aliquota IVA</span>
  360. </div>
  361. <div class="col-md-2 ms-auto">
  362. @if($add || $update )
  363. <select class="form-select text-end @error('rows.'.$idx.'.aliquota_iva') is-invalid @enderror"
  364. id="rows.{{$idx}}.aliquota_iva"
  365. wire:model="rows.{{$idx}}.aliquota_iva">
  366. <option value="">--Seleziona--</option>
  367. @foreach($vats as $vat)
  368. <option value="{{$vat->value}}">{{$vat->name}}</option>
  369. @endforeach
  370. </select>
  371. @error('rows.'. $idx . '.aliquota_iva')
  372. <span style="margin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
  373. @enderror
  374. @endif
  375. </div>
  376. </div>
  377. @endif
  378. <div class="row gx-2 mt-5 align-items-center">
  379. <div class="col-md-6">
  380. <span class="total primary">Importo</span>
  381. </div>
  382. <div class="col-md-6">
  383. @if($add)
  384. <input type="text" class="form-control totalInput text-end @error('amount') is-invalid @enderror" id="rows.{{$idx}}.amount" wire:model="rows.{{$idx}}.amount" wire:keydown.enter="store(false)" onkeyup="onlyNumberAmount(this)" placeholder="€ 0,00">
  385. @endif
  386. @if($update)
  387. <input type="text" class="form-control totalInput text-end @error('amount') is-invalid @enderror" id="rows.{{$idx}}.amount" placeholder="€ 0,00" wire:model="rows.{{$idx}}.amount" onkeyup="onlyNumberAmount(this)" wire:keydown.enter="update(false)">
  388. @endif
  389. @error('rows.'. $idx . '.amount')
  390. <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
  391. @enderror
  392. </div>
  393. </div>
  394. <div class="row gx-2 mt-5 align-items-center">
  395. <div class="col-md-4">
  396. <span class="total primary">Periodo</span>
  397. </div>
  398. <div class="col-md-8">
  399. @if($multiP)
  400. <div class="row">
  401. <div class="col-md-3">
  402. <span class="title-form d-block w-100">Dal mese</span>
  403. <div class="input-group mb-3">
  404. <select class="form-select form-select-lg me-1" wire:model="multiMonthFrom">
  405. @foreach(getMonthList() as $mid => $mname)
  406. <option value="{{$mid}}">{{$mname}}</option>
  407. @endforeach
  408. </select>
  409. </div>
  410. </div>
  411. <div class="col-md-3">
  412. <span class="title-form d-block w-100">Anno</span>
  413. <div class="input-group mb-3">
  414. <input type="number" class="form-control" wire:model="multiYearFrom" >
  415. </div>
  416. </div>
  417. <div class="col-md-3">
  418. <span class="title-form d-block w-100">Dal mese</span>
  419. <div class="input-group mb-3">
  420. <select class="form-select form-select-lg me-1" wire:model="multiMonthTo">
  421. @foreach(getMonthList() as $mid => $mname)
  422. <option value="{{$mid}}">{{$mname}}</option>
  423. @endforeach
  424. </select>
  425. </div>
  426. </div>
  427. <div class="col-md-3">
  428. <span class="title-form d-block w-100">Anno</span>
  429. <div class="input-group mb-3">
  430. <input type="number" class="form-control" wire:model="multiYearTo" >
  431. </div>
  432. </div>
  433. <div class="col-md-6">
  434. <button type="button" class="btn--ui primary" wire:click.prevent="multiPeriodCreate({{$idx}})" style="margin-top:20px">
  435. Crea multi periodo
  436. </button>
  437. </div>
  438. <div class="col-md-6">
  439. <button type="button" class="btn--ui lightGrey" wire:click.prevent="multiPeriodCancel()" style="margin-top:20px">
  440. Annulla multi periodo
  441. </button>
  442. </div>
  443. </div>
  444. @else
  445. <div class="row">
  446. @foreach($row["when"] as $xxx => $w)
  447. <div class="col-md-4">
  448. <span class="title-form d-block w-100">Mese</span>
  449. <div class="input-group mb-3">
  450. <select class="form-select form-select-lg me-1" wire:model="rows.{{$idx}}.when.{{$xxx}}.month">
  451. @foreach(getMonthList() as $mid => $mname)
  452. <option value="{{$mid}}">{{$mname}}</option>
  453. @endforeach
  454. </select>
  455. </div>
  456. </div>
  457. <div class="col-md-3">
  458. <span class="title-form d-block w-100">Anno</span>
  459. <div class="input-group mb-3">
  460. <input type="number" class="form-control" wire:model="rows.{{$idx}}.when.{{$xxx}}.year" >
  461. </div>
  462. </div>
  463. <div class="col-md-3">
  464. <span class="title-form d-block w-100">Valore</span>
  465. <span class="netprice_p total--wrapper_netprice"><b>{{$this->currencyToDouble($rows[$idx]["amount"]) > 0 ? formatPrice($this->currencyToDouble($rows[$idx]["amount"]) / sizeof($rows[$idx]["when"])) : ""}}</b></span>
  466. </div>
  467. <div class="col-md-2"><br>
  468. <button type="button" class="btn--ui primary" wire:click.prevent="delPeriod({{$idx}}, {{$xxx}})" style="float:right">
  469. -
  470. </button>
  471. </div>
  472. @endforeach
  473. <div class="d-flex justify-content-between mt-3">
  474. <button type="button" class="btn--ui primary order-2" wire:click.prevent="addPeriod({{$idx}})">
  475. Aggiungi periodo
  476. </button>
  477. <button type="button" class="btn--ui_tertiary primary order-1" wire:click.prevent="multiPeriod()">
  478. Imposta multi periodo
  479. </button>
  480. </div>
  481. </div>
  482. @endif
  483. </div>
  484. </div>
  485. <br><br>
  486. @if($idx > 0)
  487. <button type="button" class="btn--ui primary" wire:click.prevent="delRow({{$idx}})" style="float:right">
  488. Rimuovi causale
  489. </button>
  490. <br><br>
  491. @endif
  492. <hr size="1">
  493. @endforeach
  494. <br>
  495. <button type="button" class="btn--ui primary" wire:click.prevent="addRow()">
  496. Aggiungi causale
  497. </button>
  498. <div class="accountingExit--btn d-flex align-items-center justify-content-between">
  499. <button class="btn--ui lightGrey" onclick="annulla()">annulla</button>
  500. @if($add)
  501. <button class="btn--ui primary" type="submit" wire:click.prevent="store()">inserisci</button>
  502. @endif
  503. @if($update)
  504. <button class="btn--ui primary" type="submit" wire:click.prevent="update()">salva</button>
  505. @endif
  506. </div>
  507. </form>
  508. </div>
  509. @if(false)
  510. <div class="accountingExit_resume card--ui">
  511. <header>
  512. <div class="username d-flex align-items-start">
  513. <i class="ico--ui accountingResume me-2"></i>
  514. <div class="user--resume_name d-flex flex-column"><span class="primary">Ricevuta</span></div></div>
  515. </header>
  516. <div class="resume--body d-flex justify-content-between flex-column">
  517. <header>
  518. @if($this->supplier)
  519. <ul class="resume-item mb-4 p-0">
  520. <li><span class="evidence_name">{{$this->supplier->name}}</span></li>
  521. <li><span>P.IVA: {{$this->supplier->vat}}</span></li>
  522. </ul>
  523. @endif
  524. <ul class="resume-item date p-0">
  525. <li><strong>Data</strong></li>
  526. <li>{{ date("d/m/Y", strtotime($date)) }}</li>
  527. </ul>
  528. @if($this->causal)
  529. <ul class="resume-item date p-0">
  530. <li><strong>Causale</strong></li>
  531. <li>{{$this->causal->getTree()}}</li>
  532. </ul>
  533. @endif
  534. </header>
  535. <footer>
  536. <div class="total--wrapper">
  537. <div class="total--wrapper_amount d-flex align-items-center justify-content-between w-100 mb-3">
  538. <span class="amount_p"><strong>Importo</strong></span><span class="amount_data"><strong>{{$amount}}</strong></span>
  539. </div>
  540. <div class="total--wrapper_netprice d-flex align-items-center justify-content-between w-100">
  541. <span class="netprice_p"><strong>Totale Netto</strong></span><span class="netprice_data"><strong>{{$amount}}</strong></span>
  542. </div>
  543. </div>
  544. </footer>
  545. </div>
  546. </div>
  547. @endif
  548. </section>
  549. @endif
  550. <div class="modal fade" id="importResultModal" tabindex="-1" aria-labelledby="importResultModalLabel" aria-hidden="true">
  551. <div class="modal-dialog">
  552. <div class="modal-content">
  553. <div class="modal-header">
  554. <h5 class="modal-title" id="importResultModalLabel">Importazione Completata</h5>
  555. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  556. </div>
  557. <div class="modal-body">
  558. <div id="importResultMessage"></div>
  559. </div>
  560. <div class="modal-footer">
  561. <button type="button" class="btn--ui" data-bs-dismiss="modal">Chiudi</button>
  562. </div>
  563. </div>
  564. </div>
  565. </div>
  566. <div class="modal fade" id="recordDetailsModal" tabindex="-1" aria-labelledby="recordDetailsModalLabel" aria-hidden="true">
  567. <div class="modal-dialog modal-lg">
  568. <div class="modal-content">
  569. <div class="modal-header">
  570. <h5 class="modal-title" id="recordDetailsModalLabel">Dettaglio uscita</h5>
  571. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  572. </div>
  573. <div class="modal-body">
  574. <div class="row mb-4">
  575. <div class="col-md-6">
  576. <h6 class="primary">Informazioni generali</h6>
  577. <table class="table table-sm table-borderless">
  578. <tr>
  579. <th>Data:</th>
  580. <td id="recordDate"></td>
  581. </tr>
  582. <tr>
  583. <th>Data pagamento:</th>
  584. <td id="recordPaymentDate"></td>
  585. </tr>
  586. <tr>
  587. <th>Fornitore:</th>
  588. <td id="recordSupplier"></td>
  589. </tr>
  590. <tr>
  591. <th>Metodo di pagamento:</th>
  592. <td id="recordPaymentMethod"></td>
  593. </tr>
  594. </table>
  595. </div>
  596. <div class="col-md-6">
  597. <h6 class="primary">Importo e pagamento</h6>
  598. <table class="table table-sm table-borderless">
  599. <tr>
  600. <th>Importo totale:</th>
  601. <td id="recordTotalAmount" class="primary fw-bold"></td>
  602. </tr>
  603. <tr>
  604. <th>Stato pagamento:</th>
  605. <td><span id="recordPaymentStatus" class="badge"></span></td>
  606. </tr>
  607. </table>
  608. </div>
  609. </div>
  610. <h6 class="primary">Dettaglio causali</h6>
  611. <div class="table-responsive">
  612. <table class="table table-striped table-hover">
  613. <thead>
  614. <tr>
  615. <th scope="col">N.</th>
  616. <th scope="col">Descrizione</th>
  617. <th scope="col">Imponibile</th>
  618. <th scope="col">IVA</th>
  619. <th scope="col">Imposta</th>
  620. <th scope="col">Totale</th>
  621. </tr>
  622. </thead>
  623. <tbody id="recordRowsContainer">
  624. <!-- Rows will be inserted here dynamically -->
  625. </tbody>
  626. </table>
  627. </div>
  628. </div>
  629. <div class="modal-footer">
  630. <button type="button" class="btn--ui lightGrey" data-bs-dismiss="modal">Chiudi</button>
  631. </div>
  632. </div>
  633. </div>
  634. </div>
  635. <div id="loadingOverlay" class="loading-overlay" style="display: none;">
  636. <div class="loading-content">
  637. <div class="loading-spinner"></div>
  638. <div class="loading-text">Caricamento...</div>
  639. <div class="loading-progress">
  640. <div class="progress-bar-custom">
  641. <div class="progress-fill"></div>
  642. </div>
  643. </div>
  644. </div>
  645. </div>
  646. </div>
  647. @push('scripts')
  648. <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  649. <style>
  650. table.tableHead thead {
  651. position: sticky;
  652. z-index: 100;
  653. top: 0;
  654. }
  655. .select2-container--default .select2-selection--single{
  656. background-color: #E9F0F5;
  657. border: 0.0625rem solid #DFE5EB;
  658. font-size: 0.75rem;
  659. }
  660. .select2-selection
  661. {
  662. height: 38px !important;
  663. }
  664. .select2-selection__rendered
  665. {
  666. padding-top:3px;
  667. }
  668. .select2 {
  669. width:100% !important;
  670. }
  671. .select2-selection--multiple{
  672. overflow: hidden !important;
  673. height: auto !important;
  674. }
  675. .select2-container {
  676. box-sizing: border-box;
  677. display: inline-block;
  678. margin: 0;
  679. position: relative;
  680. vertical-align: middle;
  681. }
  682. .select2-container .select2-selection--single {
  683. box-sizing: border-box;
  684. cursor: pointer;
  685. display: block;
  686. height: 38px;
  687. user-select: none;
  688. -webkit-user-select: none;
  689. }
  690. .select2-container .select2-selection--single .select2-selection__rendered {
  691. display: block;
  692. padding-left: 8px;
  693. padding-right: 20px;
  694. overflow: hidden;
  695. text-overflow: ellipsis;
  696. white-space: nowrap;
  697. }
  698. .loading-overlay {
  699. position: fixed;
  700. top: 0;
  701. left: 0;
  702. width: 100%;
  703. height: 100%;
  704. background: rgba(0, 0, 0, 0.7);
  705. display: flex;
  706. justify-content: center;
  707. align-items: center;
  708. z-index: 9999;
  709. backdrop-filter: blur(2px);
  710. }
  711. .loading-content {
  712. background: white;
  713. padding: 30px;
  714. border-radius: 10px;
  715. text-align: center;
  716. box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  717. min-width: 300px;
  718. }
  719. .loading-spinner {
  720. width: 40px;
  721. height: 40px;
  722. border: 4px solid #f3f3f3;
  723. border-top: 4px solid #0C6197;
  724. border-radius: 50%;
  725. animation: spin 1s linear infinite;
  726. margin: 0 auto 20px;
  727. }
  728. @keyframes spin {
  729. 0% { transform: rotate(0deg); }
  730. 100% { transform: rotate(360deg); }
  731. }
  732. .loading-text {
  733. font-size: 16px;
  734. font-weight: 600;
  735. color: #333;
  736. margin-bottom: 15px;
  737. }
  738. .progress-bar-custom {
  739. width: 100%;
  740. height: 4px;
  741. background: #f0f0f0;
  742. border-radius: 2px;
  743. overflow: hidden;
  744. }
  745. .progress-fill {
  746. height: 100%;
  747. background: linear-gradient(90deg, #0C6197, #1e7bb8);
  748. width: 0%;
  749. transition: width 0.3s ease;
  750. animation: progressPulse 2s ease-in-out infinite;
  751. }
  752. @keyframes progressPulse {
  753. 0%, 100% { opacity: 1; }
  754. 50% { opacity: 0.7; }
  755. }
  756. /* Disable form during loading */
  757. .loading-active {
  758. pointer-events: none;
  759. opacity: 0.7;
  760. }
  761. </style>
  762. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  763. <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  764. @endpush
  765. @push('scripts')
  766. <script>
  767. function matchStart(params, data) {
  768. params.term = params.term || '';
  769. if (data.text.toUpperCase().indexOf(params.term.toUpperCase()) == 0) {
  770. return data;
  771. }
  772. return false;
  773. }
  774. window.livewire.on('refresh', () => {
  775. $('.causalClass').select2({
  776. matcher: function(params, data) {
  777. return matchStart(params, data);
  778. }
  779. });
  780. $('.supplierClass').select2({
  781. });
  782. $('.paymentClass').select2({
  783. matcher: function(params, data) {
  784. return matchStart(params, data);
  785. }
  786. });
  787. });
  788. $(document).ready(function(){
  789. $(document).on("keypress", $('.filterCausals'), function (e) {
  790. setTimeout(() => {
  791. $(".select2-results__option").each(function(){
  792. var txt = $(this).html();
  793. var count = (txt.match(/-/g) || []).length;
  794. $(this).addClass('paddingLeftSelect' + count);
  795. });
  796. }, 100);
  797. });
  798. });
  799. Livewire.on('load-select', () => {
  800. $('.causalClass').each(function(i, obj) {
  801. $(obj).select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  802. $(obj).on('change', function (e) {
  803. var data = $(obj).select2("val");
  804. var name = $(obj).select2().attr("name");
  805. @this.set(name, data);
  806. });
  807. });
  808. $('.supplierClass').select2({
  809. });
  810. $('.supplierClass').on('change', function (e) {
  811. var data = $('.supplierClass').select2("val");
  812. @this.set('supplier_id', data);
  813. });
  814. $('.paymentClass').select2({
  815. matcher: function(params, data) {
  816. return matchStart(params, data);
  817. }
  818. });
  819. $('.paymentClass').on('change', function (e) {
  820. var data = $('.paymentClass').select2("val");
  821. @this.set('payment_method_id', data);
  822. });
  823. $('.filterSupplier').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  824. $('.filterSupplier').on('change', function (e) {
  825. });
  826. $('.filterPaymentMethod').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  827. $('.filterPaymentMethod').on('change', function (e) {
  828. });
  829. $('.filterCausals').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  830. $('.filterCausals').on('change', function (e) {
  831. });
  832. });
  833. Livewire.on('hide-search', () => {
  834. });
  835. $('.filterSupplier').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  836. $('.filterSupplier').on('change', function (e) {
  837. });
  838. $('.filterPaymentMethod').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  839. $('.filterPaymentMethod').on('change', function (e) {
  840. });
  841. $('.filterCausals').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  842. $('.filterCausals').on('change', function (e) {
  843. });
  844. function onlyNumberAmount(input) {
  845. let v = input.value.replace(/\D+/g, '');
  846. if (v.length > 14) v = v.slice(0, 14);
  847. input.value = "€ " + v.replace(/(\d)(\d\d)$/, "$1,$2").replace(/(^\d{1,3}|\d{3})(?=(?:\d{3})+(?:,|$))/g, '$1.');
  848. }
  849. </script>
  850. <link href="/css/datatables.css" rel="stylesheet" />
  851. <script src="/assets/js/datatables.js"></script>
  852. <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
  853. <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
  854. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
  855. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
  856. <script>
  857. $(document).ready(function() {
  858. loadDataTable();
  859. } );
  860. @if(isset($_GET["showFilters"]))
  861. var filterSupplier = localStorage.getItem("filterSupplierRecordOut");
  862. if (filterSupplier && filterSupplier != "null" && filterSupplier != "undefined")
  863. {
  864. console.log("1");
  865. console.log(filterSupplier);
  866. $('.filterSupplier').val(filterSupplier);
  867. $('.filterSupplier').trigger('change');
  868. }
  869. var filterPaymentMethod = localStorage.getItem("filterPaymentMethodRecordOut");
  870. if (filterPaymentMethod && filterPaymentMethod != "null" && filterPaymentMethod != "undefined")
  871. {
  872. console.log("2");
  873. $('.filterPaymentMethod').val(filterPaymentMethod);
  874. $('.filterPaymentMethod').trigger('change');
  875. }
  876. var filterCausals = localStorage.getItem("filterCausalsRecordOut");
  877. if (filterCausals && filterCausals != "null" && filterCausals != "undefined")
  878. {
  879. console.log("3");
  880. $('.filterCausals').val(filterCausals);
  881. $('.filterCausals').trigger('change');
  882. }
  883. var filterFrom = localStorage.getItem("filterFromRecordOut");
  884. if (filterFrom && filterFrom != "" && filterFrom != "undefined")
  885. {
  886. console.log("4");
  887. $('.filterFrom').val(filterFrom);
  888. }
  889. var filterTo = localStorage.getItem("filterToRecordOut");
  890. if (filterTo && filterTo != "" && filterTo != "undefined")
  891. {
  892. console.log("5");
  893. $('.filterTo').val(filterTo);
  894. }
  895. @endif
  896. var isFilter = false;
  897. $(document).ready(function() {
  898. $(document).on("click",".showHideFilter",function() {
  899. if (isFilter)
  900. {
  901. isFilter = false;
  902. $(".showFilter").hide();
  903. }
  904. else
  905. {
  906. isFilter = true;
  907. $(".showFilter").show();
  908. }
  909. });
  910. $(document).on("select2:open",".filterCausals",function() {
  911. setTimeout(() => {
  912. $(".select2-results__option").each(function(){
  913. var txt = $(this).html();
  914. var count = (txt.match(/-/g) || []).length;
  915. $(this).addClass('paddingLeftSelect' + count);
  916. });
  917. }, 100);
  918. });
  919. } );
  920. function editData(id)
  921. {
  922. @this.edit(id);
  923. }
  924. function viewData(id)
  925. {
  926. @this.view(id);
  927. }
  928. function deleteData(id) {
  929. if (confirm('Sei sicuro?'))
  930. @this.delete(id).then(() => {
  931. window.location.reload();
  932. });
  933. }
  934. Livewire.on('load-data-table', () => {
  935. setTimeout(function() {loadDataTable()}, 100);
  936. });
  937. Livewire.on('destroy-data-table', () => {
  938. $('#tablesaw-350').DataTable().destroy();
  939. });
  940. function destroyDataTable()
  941. {
  942. $('#tablesaw-350').DataTable().destroy();
  943. }
  944. function reset()
  945. {
  946. $(".todayButton").addClass("lightGrey");
  947. $(".yesterdayButton").addClass("lightGrey");
  948. $('.filterSupplier').val('');
  949. $('.filterSupplier').trigger('change');
  950. $('.filterPaymentMethod').val('');
  951. $('.filterPaymentMethod').trigger('change');
  952. $('.filterCausals').val('');
  953. $('.filterCausals').trigger('change');
  954. $('.filterFrom').val('');
  955. $('.filterTo').val('');
  956. localStorage.clear();
  957. loadDataTable();
  958. }
  959. function loadDataTable(){
  960. if ( $.fn.DataTable.isDataTable('#tablesaw-350') ) {
  961. $('#tablesaw-350').DataTable().destroy();
  962. }
  963. var filterSupplier = $('.filterSupplier').val();
  964. var filterPaymentMethod = $('.filterPaymentMethod').val();
  965. var filterCausals = $('.filterCausals').val();
  966. var filterFrom = $('.filterFrom').val();
  967. var filterTo = $('.filterTo').val();
  968. localStorage.setItem("filterSupplierRecordOut", filterSupplier);
  969. localStorage.setItem("filterPaymentMethodRecordOut", filterPaymentMethod);
  970. localStorage.setItem("filterCausalsRecordOut", filterCausals);
  971. localStorage.setItem("filterFromRecordOut", filterFrom);
  972. localStorage.setItem("filterToRecordOut", filterTo);
  973. $('#tablesaw-350').DataTable({
  974. //searching: false,
  975. ajax: {
  976. url : "/get_record_out?filterSupplier=" + filterSupplier + "&filterPaymentMethod=" + filterPaymentMethod + "&filterCausals=" + filterCausals + "&filterFrom=" + filterFrom + "&filterTo=" + filterTo,
  977. dataSrc: function (json){
  978. if(json.totals){
  979. $(".totalDiv").html('Totale&nbsp;:&nbsp;<b>' + json.totals + '</b>');
  980. }
  981. else
  982. {
  983. $(".totalDiv").html('');
  984. }
  985. @if(Auth::user()->level != 0)
  986. $(".totalDiv").html('');
  987. @endif
  988. return json.data;
  989. }
  990. },
  991. columns: [
  992. { data: 'numero_fattura' },
  993. {
  994. data: "date",
  995. render: function (data, type){
  996. if (data == "")
  997. return " TOTALE";
  998. if (type == "sort"){
  999. return new Date(data).getTime();
  1000. }
  1001. // Split class and text
  1002. const j = data.split(" ");
  1003. const d = j[0].split("-");
  1004. var ret = d[2] + "/" + d[1] + "/" + d[0];
  1005. return ret;
  1006. }
  1007. },
  1008. { data: 'total', className: "numericCol" },
  1009. { data: 'supplier' },
  1010. { data: 'causals' },
  1011. { data: 'payment' },
  1012. {
  1013. data: 'is_paid',
  1014. render: function (data) {
  1015. if (data === true || data === 'true' || data === 1 || data === '1' || data === 'Pagato') {
  1016. return '<span class="badge bg-success">Pagato</span>';
  1017. } else {
  1018. return '<span class="badge bg-warning">Da Pagare</span>';
  1019. }
  1020. }
  1021. },
  1022. {
  1023. data: "action",
  1024. render: function (data){
  1025. if (data == "")
  1026. return "";
  1027. const j = data.split("|");
  1028. var ret = '<button type="button" class="btn" onclick="editData(' + j[0] + ')" 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>&nbsp;';
  1029. ret += '<button type="button" class="btn" onclick="viewData(' + j[0] + ')" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Info"><i class="fa-regular fa-eye"></i></button>&nbsp;';
  1030. ret += '<button type="button" class="btn" onclick="deleteData(' + j[0] + ')" 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>';
  1031. return ret;
  1032. }
  1033. },
  1034. ],
  1035. order: [[1, 'desc']],
  1036. thead: {
  1037. 'th': {'background-color': 'blue'}
  1038. },
  1039. layout: {
  1040. topStart : null,
  1041. topEnd : null,
  1042. top1A: {
  1043. buttons: [
  1044. {
  1045. extend: 'collection',
  1046. text: 'ESPORTA',
  1047. buttons: [
  1048. {
  1049. extend: 'excelHtml5',"action":newexportaction,
  1050. title: 'Uscite',
  1051. exportOptions: {
  1052. columns: ":not(':last')"
  1053. }
  1054. },
  1055. {
  1056. extend: 'pdfHtml5',"action":newexportaction,
  1057. title: 'Uscite',
  1058. exportOptions: {
  1059. columns: ":not(':last')"
  1060. }
  1061. },
  1062. {
  1063. extend: 'print',"action":newexportaction,
  1064. text: 'Stampa',
  1065. title: 'Uscite',
  1066. exportOptions: {
  1067. columns: ":not(':last')"
  1068. }
  1069. }
  1070. ],
  1071. dropup: true
  1072. }
  1073. ]
  1074. },
  1075. top1B : {
  1076. pageLength: {
  1077. menu: [[10, 25, 50, 100, 100000], [10, 25, 50, 100, "Tutti"]]
  1078. }
  1079. },
  1080. top1C :'search',
  1081. },
  1082. pagingType: 'numbers',
  1083. "language": {
  1084. "url": "/assets/js/Italian.json"
  1085. },
  1086. "fnInitComplete": function (oSettings, json) {
  1087. var html = '&nbsp;<a href="#" class="showHideFilter btn--ui"><i class="fa-solid fa-sliders"></i></a>';
  1088. html += '&nbsp;<a href="#" class="addData btn--ui"><i class="fa-solid fa-plus"></i></a>';
  1089. $(".dt-search").append(html);
  1090. }
  1091. });
  1092. $('#tablesaw-350 thead tr th').addClass('col');
  1093. $('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");
  1094. $('#tablesaw-350').on('draw.dt', function() {
  1095. $('[data-bs-toggle="popover"]').popover()
  1096. });
  1097. }
  1098. $(document).ready(function() {
  1099. $(document).on("click",".addData",function() {
  1100. $(".title--section_addButton").trigger("click")
  1101. });
  1102. } );
  1103. var isEdit = false;
  1104. Livewire.on('setEdit', (x) =>
  1105. {
  1106. isEdit = x;
  1107. console.log(isEdit);
  1108. });
  1109. function annulla()
  1110. {
  1111. window.onbeforeunload = null;
  1112. document.location.href = '/out';
  1113. }
  1114. window.onbeforeunload = function(){
  1115. if (isEdit)
  1116. return 'Cambiando pagina le eventuali modifiche andranno perse';
  1117. };
  1118. document.addEventListener('livewire:initialized', () => {
  1119. let importModalOpen = false;
  1120. const importModal = document.getElementById('importModal');
  1121. importModal.addEventListener('shown.bs.modal', function () {
  1122. importModalOpen = true;
  1123. });
  1124. importModal.addEventListener('hidden.bs.modal', function () {
  1125. importModalOpen = false;
  1126. // Ensure table is reloaded when modal is closed
  1127. setTimeout(() => {
  1128. if (!$.fn.DataTable.isDataTable('#tablesaw-350')) {
  1129. loadDataTable();
  1130. }
  1131. }, 100);
  1132. });
  1133. document.addEventListener('livewire:update', function() {
  1134. if (importModalOpen) {
  1135. const modalInstance = bootstrap.Modal.getInstance(importModal);
  1136. if (!modalInstance) {
  1137. const newModal = new bootstrap.Modal(importModal);
  1138. newModal.show();
  1139. } else if (!importModal.classList.contains('show')) {
  1140. modalInstance.show();
  1141. }
  1142. setTimeout(() => {
  1143. if (!$.fn.DataTable.isDataTable('#tablesaw-350')) {
  1144. loadDataTable();
  1145. }
  1146. }, 100);
  1147. }
  1148. });
  1149. document.querySelectorAll('.select2-container').forEach(select => {
  1150. select.addEventListener('click', function(e) {
  1151. e.stopPropagation();
  1152. });
  1153. });
  1154. });
  1155. function initImportCausalSelect() {
  1156. $('.import-causal-select').select2({
  1157. dropdownParent: $('#importModal'),
  1158. language: {
  1159. noResults: function() {
  1160. return "Nessun risultato";
  1161. }
  1162. }
  1163. });
  1164. $('.import-causal-select').on('change', function() {
  1165. let selectedValue = $(this).val();
  1166. Livewire.first().set('selectedCausal', selectedValue);
  1167. });
  1168. }
  1169. function openImportModal() {
  1170. let tableState = null;
  1171. if ($.fn.DataTable.isDataTable('#tablesaw-350')) {
  1172. tableState = $('#tablesaw-350').DataTable().state.save();
  1173. }
  1174. const importModal = new bootstrap.Modal(document.getElementById('importModal'));
  1175. importModal.show();
  1176. setTimeout(function() {
  1177. initImportCausalSelect();
  1178. if (!$.fn.DataTable.isDataTable('#tablesaw-350')) {
  1179. loadDataTable();
  1180. if (tableState) {
  1181. $('#tablesaw-350').DataTable().state.load(tableState);
  1182. }
  1183. }
  1184. }, 200);
  1185. }
  1186. document.addEventListener('DOMContentLoaded', function() {
  1187. if (document.getElementById('importModal')) {
  1188. initImportCausalSelect();
  1189. }
  1190. Livewire.on('load-select', function() {
  1191. if (document.getElementById('importModal') &&
  1192. document.getElementById('importModal').classList.contains('show')) {
  1193. initImportCausalSelect();
  1194. }
  1195. });
  1196. });
  1197. function closeImportModal() {
  1198. const importModal = bootstrap.Modal.getInstance(document.getElementById('importModal'));
  1199. if (importModal) {
  1200. importModal.hide();
  1201. }
  1202. setTimeout(function() {
  1203. if (!$.fn.DataTable.isDataTable('#tablesaw-350')) {
  1204. loadDataTable();
  1205. }
  1206. }, 100);
  1207. }
  1208. Livewire.on('update-progress', (progress) => {
  1209. const progressBar = document.querySelector('.progress-bar');
  1210. progressBar.style.width = `${progress}%`;
  1211. progressBar.setAttribute('aria-valuenow', progress);
  1212. progressBar.textContent = `${progress}%`;
  1213. progressBar.style.backgroundColor = progress === 100 ? '#0C6197' : '#0C6197';
  1214. });
  1215. function onlyNumberPercent(input) {
  1216. let v = input.value.replace(/[^\d]/g, '');
  1217. if (v.length > 3) v = v.slice(0, 3);
  1218. if (parseInt(v) > 100) v = '100';
  1219. input.value = v + "%";
  1220. }
  1221. document.addEventListener('closeModal', function() {
  1222. setTimeout(function() {
  1223. const importModal = bootstrap.Modal.getInstance(document.getElementById('importModal'));
  1224. if (importModal) {
  1225. importModal.hide();
  1226. }
  1227. setTimeout(function() {
  1228. window.location.reload();
  1229. }, 1500);
  1230. }, 1500);
  1231. });
  1232. Livewire.on('flash-error', message => {
  1233. const alert = document.createElement('div');
  1234. alert.classList.add('alert', 'alert-danger', 'alert-dismissible', 'fade', 'show');
  1235. alert.setAttribute('role', 'alert');
  1236. alert.textContent = message;
  1237. const closeButton = document.createElement('button');
  1238. closeButton.setAttribute('type', 'button');
  1239. closeButton.classList.add('btn-close');
  1240. closeButton.setAttribute('data-bs-dismiss', 'alert');
  1241. closeButton.setAttribute('aria-label', 'Close');
  1242. alert.appendChild(closeButton);
  1243. const accountingExit = document.getElementById('accountingExit');
  1244. if (accountingExit) {
  1245. accountingExit.prepend(alert);
  1246. } else {
  1247. const mainContainer = document.querySelector('.col.card--ui');
  1248. if (mainContainer) {
  1249. mainContainer.prepend(alert);
  1250. } else {
  1251. console.error('Could not find a suitable container for the alert.');
  1252. }
  1253. }
  1254. setTimeout(() => {
  1255. alert.remove();
  1256. }, 5000);
  1257. });
  1258. function closeImportModal() {
  1259. const importModal = bootstrap.Modal.getInstance(document.getElementById('importModal'));
  1260. if (importModal) {
  1261. importModal.hide();
  1262. }
  1263. }
  1264. Livewire.on('import-started', () => {
  1265. const closeButton = document.querySelector('#importModal .btn-close');
  1266. const submitButton = document.querySelector('#importModal button[type="submit"]');
  1267. if (closeButton) closeButton.disabled = true;
  1268. if (submitButton) submitButton.disabled = true;
  1269. });
  1270. Livewire.on('close-import-modal', () => {
  1271. const importModal = bootstrap.Modal.getInstance(document.getElementById('importModal'));
  1272. if (importModal) {
  1273. importModal.hide();
  1274. }
  1275. });
  1276. let transitioningToResultModal = false;
  1277. document.getElementById('importModal').addEventListener('hidden.bs.modal', function () {
  1278. if (!transitioningToResultModal) {
  1279. console.log("Modal import chiusa dall'utente: ricarica la pagina");
  1280. setTimeout(function() {
  1281. window.location.reload();
  1282. }, 500);
  1283. } else {
  1284. console.log("Transizione da importModal a resultModal: non ricaricare");
  1285. transitioningToResultModal = false;
  1286. }
  1287. });
  1288. Livewire.on('show-import-result', data => {
  1289. transitioningToResultModal = true;
  1290. const resultDiv = document.getElementById('importResultMessage');
  1291. resultDiv.innerHTML = data.message;
  1292. const importModal = bootstrap.Modal.getInstance(document.getElementById('importModal'));
  1293. if (importModal) {
  1294. importModal.hide();
  1295. }
  1296. setTimeout(() => {
  1297. const resultModal = new bootstrap.Modal(document.getElementById('importResultModal'));
  1298. resultModal.show();
  1299. }, 300);
  1300. });
  1301. document.getElementById('importResultModal').addEventListener('hidden.bs.modal', function () {
  1302. console.log("Modal result chiusa: ricarica la pagina");
  1303. window.location.reload();
  1304. });
  1305. document.addEventListener('DOMContentLoaded', function() {
  1306. function calculateAmount(rowIndex) {
  1307. const imponibileField = document.getElementById(`rows.${rowIndex}.imponibile`);
  1308. const aliquotaField = document.getElementById(`rows.${rowIndex}.aliquota_iva`);
  1309. const amountField = document.getElementById(`rows.${rowIndex}.amount`);
  1310. if (imponibileField && aliquotaField && amountField) {
  1311. let imponibile = imponibileField.value.replace('€', '').replace(/\./g, '').replace(',', '.').trim();
  1312. imponibile = parseFloat(imponibile) || 0;
  1313. let aliquota = parseFloat(aliquotaField.value) || 0;
  1314. const imposta = imponibile * (aliquota / 100);
  1315. const totalAmount = imponibile + imposta;
  1316. let formattedAmount = "€ " + totalAmount.toFixed(2).replace('.', ',').replace(/\B(?=(\d{3})+(?!\d))/g, ".");
  1317. amountField.value = formattedAmount;
  1318. const component = Livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id'));
  1319. if (component) {
  1320. component.set(`rows.${rowIndex}.amount`, formattedAmount);
  1321. }
  1322. }
  1323. }
  1324. function setupCalculationListeners() {
  1325. const rows = document.querySelectorAll('input[id^="rows."][id$=".imponibile"], input[id^="rows."][id$=".aliquota_iva"]');
  1326. rows.forEach(field => {
  1327. field.addEventListener('blur', function() {
  1328. const rowIndex = this.id.match(/rows\.(\d+)\./)[1];
  1329. calculateAmount(rowIndex);
  1330. });
  1331. });
  1332. }
  1333. setupCalculationListeners();
  1334. document.addEventListener('livewire:load', function() {
  1335. setupCalculationListeners();
  1336. });
  1337. document.addEventListener('livewire:update', function() {
  1338. setupCalculationListeners();
  1339. });
  1340. Livewire.on('load-select', function() {
  1341. $('select[id^="rows."][id$=".aliquota_iva"]').each(function(i, obj) {
  1342. $(obj).select2({
  1343. "language": {"noResults": function(){return "Nessun risultato";}}
  1344. });
  1345. $(obj).on('change', function (e) {
  1346. const data = $(obj).select2("val");
  1347. const name = $(obj).attr("id");
  1348. const rowIndex = name.match(/rows\.(\d+)\./)[1];
  1349. const component = Livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id'));
  1350. if (component) {
  1351. component.set(name, data);
  1352. }
  1353. calculateAmount(rowIndex);
  1354. });
  1355. });
  1356. setTimeout(setupCalculationListeners, 300);
  1357. });
  1358. });
  1359. document.addEventListener('DOMContentLoaded', function() {
  1360. console.log('DOMContentLoaded event fired, setting up record details modal event listener');
  1361. const recordDetailsModal = document.getElementById('recordDetailsModal');
  1362. if (recordDetailsModal) {
  1363. recordDetailsModal.addEventListener('hidden.bs.modal', function() {
  1364. console.log('Record details modal hidden, reloading page...');
  1365. setTimeout(function() {
  1366. window.location.reload();
  1367. }, 100);
  1368. });
  1369. console.log('Added hidden.bs.modal event listener to record details modal');
  1370. } else {
  1371. console.error('Record details modal not found in DOM');
  1372. }
  1373. window.addEventListener('show-record-details', function(event) {
  1374. console.log('show-record-details browser event received', event.detail);
  1375. showRecordDetailsModal(event.detail.record);
  1376. });
  1377. function showRecordDetailsModal(record) {
  1378. console.log('showRecordDetailsModal function called with record', record);
  1379. const modalElement = document.getElementById('recordDetailsModal');
  1380. if (!modalElement) {
  1381. console.error('Modal element not found in the DOM');
  1382. return;
  1383. }
  1384. try {
  1385. let recordDetailsModal = new bootstrap.Modal(modalElement);
  1386. document.getElementById('recordDate').textContent = record.formatted_date || 'N/A';
  1387. document.getElementById('recordPaymentDate').textContent = record.formatted_data_pagamento || 'N/A';
  1388. document.getElementById('recordSupplier').textContent = record.supplier_name || 'N/A';
  1389. document.getElementById('recordPaymentMethod').textContent = record.payment_method_name || 'N/A';
  1390. document.getElementById('recordTotalAmount').textContent = record.formatted_amount || 'N/A';
  1391. const paymentStatusElement = document.getElementById('recordPaymentStatus');
  1392. if (paymentStatusElement) {
  1393. paymentStatusElement.textContent = record.payment_status || 'N/A';
  1394. paymentStatusElement.className = 'badge ' + (record.is_paid ? 'bg-success' : 'bg-warning');
  1395. console.log('Payment status set to', record.payment_status);
  1396. }
  1397. const commercialTypeElement = document.getElementById('recordCommercialType');
  1398. if (commercialTypeElement) {
  1399. commercialTypeElement.textContent = record.commercial_type || 'N/A';
  1400. console.log('Commercial type set to', record.commercial_type);
  1401. }
  1402. const editButton = document.getElementById('btnEditRecord');
  1403. if (editButton) {
  1404. editButton.onclick = function() {
  1405. recordDetailsModal.hide();
  1406. Livewire.first().edit(record.id);
  1407. console.log('Edit button clicked for record', record.id);
  1408. };
  1409. }
  1410. const rowsContainer = document.getElementById('recordRowsContainer');
  1411. if (rowsContainer) {
  1412. rowsContainer.innerHTML = ''; // Clear existing rows
  1413. if (record.rows && record.rows.length > 0) {
  1414. record.rows.forEach(function(row, index) {
  1415. const tr = document.createElement('tr');
  1416. const tdNumber = document.createElement('td');
  1417. tdNumber.textContent = (index + 1);
  1418. tr.appendChild(tdNumber);
  1419. const tdDescrizione = document.createElement('td');
  1420. if (row.note && row.note.trim() !== '') {
  1421. tdDescrizione.textContent = row.note;
  1422. } else {
  1423. tdDescrizione.textContent = row.causal_name || 'N/A';
  1424. }
  1425. tr.appendChild(tdDescrizione);
  1426. const tdImponibile = document.createElement('td');
  1427. tdImponibile.textContent = row.formatted_imponibile || 'N/A';
  1428. tr.appendChild(tdImponibile);
  1429. const tdIva = document.createElement('td');
  1430. if (row.aliquota_iva) {
  1431. tdIva.textContent = row.aliquota_iva + '%';
  1432. } else {
  1433. tdIva.textContent = '-';
  1434. }
  1435. tr.appendChild(tdIva);
  1436. const tdImposta = document.createElement('td');
  1437. tdImposta.textContent = row.formatted_imposta || 'N/A';
  1438. tr.appendChild(tdImposta);
  1439. const tdAmount = document.createElement('td');
  1440. tdAmount.textContent = row.formatted_amount || 'N/A';
  1441. tdAmount.classList.add('fw-bold');
  1442. tr.appendChild(tdAmount);
  1443. rowsContainer.appendChild(tr);
  1444. });
  1445. } else {
  1446. const tr = document.createElement('tr');
  1447. const td = document.createElement('td');
  1448. td.setAttribute('colspan', '5');
  1449. td.textContent = 'Nessuna riga disponibile';
  1450. td.classList.add('text-center');
  1451. tr.appendChild(td);
  1452. rowsContainer.appendChild(tr);
  1453. }
  1454. } else {
  1455. console.error('Record rows container not found');
  1456. }
  1457. console.log('Showing modal');
  1458. recordDetailsModal.show();
  1459. console.log('Modal shown successfully');
  1460. } catch (error) {
  1461. console.error('Error displaying modal:', error);
  1462. }
  1463. }
  1464. });
  1465. function viewData(id) {
  1466. console.log('viewData function called with ID:', id);
  1467. Livewire.first().viewData(id);
  1468. setTimeout(function() {
  1469. const modalElement = document.getElementById('recordDetailsModal');
  1470. if (modalElement) {
  1471. const modal = new bootstrap.Modal(modalElement);
  1472. modal.show();
  1473. console.log('Modal shown using setTimeout approach');
  1474. const closeButton = modalElement.querySelector('.btn-close');
  1475. const closeButtonFooter = modalElement.querySelector('.modal-footer .btn--ui.lightGrey');
  1476. if (closeButton) {
  1477. closeButton.addEventListener('click', function() {
  1478. console.log('Close button clicked, reloading page...');
  1479. setTimeout(function() {
  1480. window.location.reload();
  1481. }, 100);
  1482. });
  1483. }
  1484. if (closeButtonFooter) {
  1485. closeButtonFooter.addEventListener('click', function() {
  1486. console.log('Footer close button clicked, reloading page...');
  1487. setTimeout(function() {
  1488. window.location.reload();
  1489. }, 100);
  1490. });
  1491. }
  1492. modalElement.addEventListener('hidden.bs.modal', function() {
  1493. console.log('Modal hidden event triggered, reloading page...');
  1494. setTimeout(function() {
  1495. window.location.reload();
  1496. }, 100);
  1497. });
  1498. } else {
  1499. console.error('Modal element not found!');
  1500. }
  1501. }, 300);
  1502. }
  1503. let loadingOverlay = null;
  1504. let progressInterval = null;
  1505. function showLoading(message = 'Caricamento...') {
  1506. loadingOverlay = document.getElementById('loadingOverlay');
  1507. const loadingText = loadingOverlay.querySelector('.loading-text');
  1508. const progressFill = loadingOverlay.querySelector('.progress-fill');
  1509. const form = document.getElementById('accountingExit');
  1510. if (loadingText) {
  1511. loadingText.textContent = message;
  1512. }
  1513. // Reset progress
  1514. if (progressFill) {
  1515. progressFill.style.width = '0%';
  1516. }
  1517. // Disable form interactions
  1518. if (form) {
  1519. form.classList.add('loading-active');
  1520. }
  1521. loadingOverlay.style.display = 'flex';
  1522. // Start progress animation
  1523. startProgressAnimation();
  1524. }
  1525. function updateLoading(message) {
  1526. if (loadingOverlay) {
  1527. const loadingText = loadingOverlay.querySelector('.loading-text');
  1528. if (loadingText) {
  1529. loadingText.textContent = message;
  1530. }
  1531. // Increase progress
  1532. const progressFill = loadingOverlay.querySelector('.progress-fill');
  1533. if (progressFill) {
  1534. const currentWidth = parseInt(progressFill.style.width) || 0;
  1535. const newWidth = Math.min(currentWidth + 25, 90); // Don't go to 100% until complete
  1536. progressFill.style.width = newWidth + '%';
  1537. }
  1538. }
  1539. }
  1540. function hideLoading() {
  1541. if (loadingOverlay) {
  1542. const progressFill = loadingOverlay.querySelector('.progress-fill');
  1543. const form = document.getElementById('accountingExit');
  1544. // Complete progress
  1545. if (progressFill) {
  1546. progressFill.style.width = '100%';
  1547. }
  1548. // Hide after a short delay to show completion
  1549. setTimeout(() => {
  1550. loadingOverlay.style.display = 'none';
  1551. // Re-enable form interactions
  1552. if (form) {
  1553. form.classList.remove('loading-active');
  1554. }
  1555. // Clear progress interval
  1556. if (progressInterval) {
  1557. clearInterval(progressInterval);
  1558. progressInterval = null;
  1559. }
  1560. }, 500);
  1561. }
  1562. }
  1563. function startProgressAnimation() {
  1564. const progressFill = loadingOverlay?.querySelector('.progress-fill');
  1565. if (!progressFill) return;
  1566. let progress = 0;
  1567. progressInterval = setInterval(() => {
  1568. if (progress < 20) { // Slow initial progress
  1569. progress += 1;
  1570. progressFill.style.width = progress + '%';
  1571. }
  1572. }, 100);
  1573. }
  1574. // Livewire event listeners
  1575. document.addEventListener('DOMContentLoaded', function() {
  1576. // Listen for loading events from Livewire
  1577. Livewire.on('start-loading', message => {
  1578. showLoading(message);
  1579. });
  1580. Livewire.on('update-loading', message => {
  1581. updateLoading(message);
  1582. });
  1583. Livewire.on('stop-loading', () => {
  1584. hideLoading();
  1585. });
  1586. // Show loading on form submissions
  1587. document.addEventListener('click', function(e) {
  1588. const target = e.target;
  1589. // Check if clicked element is a submit button
  1590. if ((target.textContent.includes('inserisci') || target.textContent.includes('salva')) &&
  1591. target.classList.contains('btn--ui')) {
  1592. // Small delay to let Livewire start
  1593. setTimeout(() => {
  1594. if (!loadingOverlay || loadingOverlay.style.display === 'none') {
  1595. const action = target.textContent.includes('inserisci') ? 'Salvataggio' : 'Aggiornamento';
  1596. showLoading(action + ' in corso...');
  1597. }
  1598. }, 100);
  1599. }
  1600. });
  1601. // Auto-hide loading on page errors
  1602. Livewire.on('flash-error', () => {
  1603. hideLoading();
  1604. });
  1605. // Also hide on success messages
  1606. window.addEventListener('beforeunload', function() {
  1607. hideLoading();
  1608. });
  1609. });
  1610. // Show loading during file uploads
  1611. document.addEventListener('change', function(e) {
  1612. if (e.target && e.target.type === 'file' && e.target.files.length > 0) {
  1613. const file = e.target.files[0];
  1614. const maxSize = 10 * 1024 * 1024; // 10MB
  1615. if (file.size > maxSize) {
  1616. alert('Il file è troppo grande. Dimensione massima: 10MB');
  1617. e.target.value = '';
  1618. return;
  1619. }
  1620. // Show brief loading for file processing
  1621. if (file.size > 1024 * 1024) { // Files larger than 1MB
  1622. showLoading('Elaborazione file...');
  1623. setTimeout(() => {
  1624. hideLoading();
  1625. }, 1000);
  1626. }
  1627. }
  1628. });
  1629. </script>
  1630. @endpush