records_out.blade.php 97 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141
  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" data-bs-dismiss="alert" 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. @if($commercial == 1)
  205. <span class="title-form d-block w-100">N° Fattura</span>
  206. <div class="input-group mb-3">
  207. <div class="col-md-6">
  208. <input class="form-control " type="text" placeholder="Numero fattura" wire:model="numero_fattura">
  209. </div>
  210. </div>
  211. @endif
  212. <div class="col-md-6">
  213. <span class="title-form d-block w-100">Data</span>
  214. <div class="input-group mb-3">
  215. <input id="date" type="date" class="form-control" wire:model="date">
  216. </div>
  217. </div>
  218. <div class="col-md-6">
  219. <span class="title-form d-block w-100">Data Pagamento</span>
  220. <div class="input-group mb-3">
  221. <input id="datePagamento" type="date" class="form-control" wire:model="data_pagamento">
  222. </div>
  223. </div>
  224. <div class="col-12">
  225. <span class="title-form d-block w-100">Fornitore</span>
  226. <select name="supplier_id" class="form-select supplierClass @error('supplier_id') is-invalid @enderror" aria-label="Seleziona un fornitore" wire:model="supplier_id">
  227. <option value="">--Seleziona--
  228. @foreach($suppliers as $supplier)
  229. <option value="{{$supplier->id}}">{{$supplier->name}}
  230. @endforeach
  231. </select>
  232. @error('supplier_id')
  233. <div class="invalid-feedback">{{ $message }}</div>
  234. @enderror
  235. </div>
  236. </div>
  237. <div class="row gx-2 mt-5">
  238. <span class="title-form d-block w-100">Metodo di pagamento</span>
  239. <div class="col-md-6">
  240. <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">
  241. <option value="">--Seleziona--
  242. @foreach($payments as $payment)
  243. <option value="{{$payment->id}}">{{$payment->name}}
  244. @endforeach
  245. </select>
  246. @error('payment_method_id')
  247. <div class="invalid-feedback">{{ $message }}</div>
  248. @enderror
  249. </div>
  250. </div>
  251. <div class="row gx-2 mt-5">
  252. <span class="title-form d-block w-100">
  253. Allegato
  254. </span>
  255. <div class="col-md-12">
  256. @if ($attachment_old != '')
  257. <div class="alert alert-info d-flex align-items-center justify-content-between mb-3">
  258. <div class="d-flex align-items-center">
  259. <i class="fa-solid fa-file-check me-2"></i>
  260. <div>
  261. <strong>Allegato presente:</strong>
  262. <a href="{{ $this->getAttachmentUrl($attachment_old) }}" target="_blank" class="ms-2 btn btn-sm btn-outline-primary">
  263. <i class="fa-regular fa-eye me-1"></i>Visualizza
  264. </a>
  265. </div>
  266. </div>
  267. <button type="button"
  268. wire:click.prevent="removeAttachment()"
  269. class="btn btn-sm btn-outline-danger"
  270. data-bs-toggle="popover"
  271. data-bs-trigger="hover focus"
  272. data-bs-placement="bottom"
  273. data-bs-content="Elimina allegato corrente">
  274. <i class="fa-regular fa-trash-can me-1"></i>Rimuovi
  275. </button>
  276. </div>
  277. @endif
  278. <div class="mb-3">
  279. <label for="attachment" class="form-label d-flex align-items-center">
  280. <i class="fa-solid fa-cloud-upload-alt me-2"></i>
  281. @if ($attachment_old != '')
  282. Sostituisci allegato esistente
  283. @else
  284. Carica nuovo allegato
  285. @endif
  286. </label>
  287. <div class="file-upload-container position-relative">
  288. <input class="form-control file-input"
  289. type="file"
  290. id="attachment"
  291. wire:model="attachment"
  292. accept="image/*,.pdf,.doc,.docx,.xml,.txt,.csv,.xls,.xlsx"
  293. style="opacity: 0; position: absolute; top: 0; left: 0; width: 100%; height: 100%; cursor: pointer; z-index: 2;">
  294. <div class="file-drop-zone border-2 border-dashed rounded p-4 text-center position-relative"
  295. id="file-drop-zone"
  296. style="border-color: #dee2e6; background-color: #f8f9fa; min-height: 120px; display: flex; flex-direction: column; justify-content: center;">
  297. <div class="file-drop-content">
  298. <i class="fa-solid fa-cloud-upload-alt fa-2x text-muted mb-2"></i>
  299. <p class="mb-1"><strong>Clicca per selezionare</strong> o trascina qui il file</p>
  300. <small class="text-muted">
  301. Formati: Immagini, PDF, Word, XML, TXT, CSV, Excel<br>
  302. Dimensione massima: 10MB
  303. </small>
  304. </div>
  305. </div>
  306. </div>
  307. </div>
  308. <div id="upload-progress" class="mb-3" style="display: none;">
  309. <div class="d-flex justify-content-between mb-1">
  310. <span class="upload-status">
  311. <i class="fa-solid fa-spinner fa-spin me-2"></i>
  312. Caricamento in corso...
  313. </span>
  314. <span class="upload-percentage">0%</span>
  315. </div>
  316. <div class="progress" style="height: 8px;">
  317. <div class="progress-bar bg-primary progress-bar-striped progress-bar-animated"
  318. role="progressbar" style="width: 0%"></div>
  319. </div>
  320. <small class="text-muted mt-1 d-block upload-details"></small>
  321. </div>
  322. @if($attachment)
  323. <div class="alert alert-success d-flex align-items-center mb-3 file-selected-info">
  324. <i class="fa-solid fa-check-circle me-2"></i>
  325. <div class="flex-grow-1">
  326. <strong>Nuovo allegato selezionato:</strong>
  327. <span class="text-muted">{{ $attachment->getClientOriginalName() }}</span>
  328. <br><small class="text-muted">
  329. Dimensione: <span class="file-size-display">{{ number_format($attachment->getSize() / 1024, 1) }} KB</span>
  330. @if($attachment->getSize() > 10 * 1024 * 1024)
  331. <span class="badge bg-warning ms-2">
  332. <i class="fa-solid fa-exclamation-triangle me-1"></i>
  333. File di grandi dimensioni
  334. </span>
  335. @endif
  336. </small>
  337. </div>
  338. <button type="button" class="btn btn-sm btn-outline-secondary" onclick="clearFileSelection()">
  339. <i class="fa-solid fa-times"></i>
  340. </button>
  341. </div>
  342. @endif
  343. @error('attachment')
  344. <div class="alert alert-danger">
  345. <i class="fa-solid fa-exclamation-triangle me-2"></i>{{ $message }}
  346. </div>
  347. @enderror
  348. </div>
  349. </div>
  350. @foreach($rows as $idx => $row)
  351. <div class="row gx-2 mt-5" wire:ignore.self>
  352. <span class="title-form d-block w-100">Causale</span>
  353. <div class="col-md-12">
  354. <livewire:causals :type="$typeOUT" :idx="$idx" :causal_id="$rows[$idx]['causal_id']" :wire:key="$idx" />
  355. @if(false)
  356. <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">
  357. <option value="">--Seleziona--
  358. @foreach($causals as $causal)
  359. <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
  360. @endforeach
  361. </select>
  362. @error('causal_id')
  363. <div class="invalid-feedback">{{ $message }}</div>
  364. @enderror
  365. @endif
  366. @error('rows.'. $idx . '.causal_id')
  367. <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
  368. @enderror
  369. </div>
  370. </div>
  371. <div class="row gx-2 mt-5">
  372. <span class="title-form d-block w-100">Dettaglio causale</span>
  373. <div class="col-md-12">
  374. <textarea class="form-control" style ="background-color: #E9F0F5 !important;" placeholder="Dettaglio causale" wire:model="rows.{{$idx}}.note"></textarea>
  375. </div>
  376. </div>
  377. <div class="row gx-2 mt-5 align-items-center">
  378. <div class="col-md-6">
  379. <span class="total primary">Imponibile</span>
  380. </div>
  381. <div class="col-md-6">
  382. @if($add)
  383. <input type="text" class="form-control totalInput text-end @error('rows.{{$idx}}.imponibile') is-invalid @enderror"
  384. id="rows.{{$idx}}.imponibile" wire:model="rows.{{$idx}}.imponibile"
  385. wire:keydown.enter="store(false)" onkeyup="onlyNumberAmount(this)" placeholder="€ 0,00">
  386. @endif
  387. @if($update)
  388. <input type="text" class="form-control totalInput text-end @error('rows.{{$idx}}.imponibile') is-invalid @enderror"
  389. id="rows.{{$idx}}.imponibile" placeholder="€ 0,00" wire:model="rows.{{$idx}}.imponibile"
  390. onkeyup="onlyNumberAmount(this)" wire:keydown.enter="update(false)">
  391. @endif
  392. @error('rows.'. $idx . '.imponibile')
  393. <span style="margin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
  394. @enderror
  395. </div>
  396. </div>
  397. @if($commercial)
  398. <div class="row gx-2 mt-5 align-items-center">
  399. <div class="col-md-6">
  400. <span class="total primary">Aliquota IVA</span>
  401. </div>
  402. <div class="col-md-2 ms-auto">
  403. @if($add || $update )
  404. <select class="form-select text-end @error('rows.'.$idx.'.aliquota_iva') is-invalid @enderror"
  405. id="rows.{{$idx}}.aliquota_iva"
  406. wire:model="rows.{{$idx}}.aliquota_iva">
  407. <option value="">--Seleziona--</option>
  408. @foreach($vats as $vat)
  409. <option value="{{$vat->value}}">{{$vat->name}}</option>
  410. @endforeach
  411. </select>
  412. @error('rows.'. $idx . '.aliquota_iva')
  413. <span style="margin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
  414. @enderror
  415. @endif
  416. </div>
  417. </div>
  418. @endif
  419. <div class="row gx-2 mt-5 align-items-center">
  420. <div class="col-md-6">
  421. <span class="total primary">Importo</span>
  422. </div>
  423. <div class="col-md-6">
  424. @if($add)
  425. <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">
  426. @endif
  427. @if($update)
  428. <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)">
  429. @endif
  430. @error('rows.'. $idx . '.amount')
  431. <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
  432. @enderror
  433. </div>
  434. </div>
  435. <div class="row gx-2 mt-5 align-items-center">
  436. <div class="col-md-4">
  437. <span class="total primary">Periodo</span>
  438. </div>
  439. <div class="col-md-8">
  440. @if($multiP)
  441. <div class="row">
  442. <div class="col-md-3">
  443. <span class="title-form d-block w-100">Dal mese</span>
  444. <div class="input-group mb-3">
  445. <select class="form-select form-select-lg me-1" wire:model="multiMonthFrom">
  446. @foreach(getMonthList() as $mid => $mname)
  447. <option value="{{$mid}}">{{$mname}}</option>
  448. @endforeach
  449. </select>
  450. </div>
  451. </div>
  452. <div class="col-md-3">
  453. <span class="title-form d-block w-100">Anno</span>
  454. <div class="input-group mb-3">
  455. <input type="number" class="form-control" wire:model="multiYearFrom" >
  456. </div>
  457. </div>
  458. <div class="col-md-3">
  459. <span class="title-form d-block w-100">Dal mese</span>
  460. <div class="input-group mb-3">
  461. <select class="form-select form-select-lg me-1" wire:model="multiMonthTo">
  462. @foreach(getMonthList() as $mid => $mname)
  463. <option value="{{$mid}}">{{$mname}}</option>
  464. @endforeach
  465. </select>
  466. </div>
  467. </div>
  468. <div class="col-md-3">
  469. <span class="title-form d-block w-100">Anno</span>
  470. <div class="input-group mb-3">
  471. <input type="number" class="form-control" wire:model="multiYearTo" >
  472. </div>
  473. </div>
  474. <div class="col-md-6">
  475. <button type="button" class="btn--ui primary" wire:click.prevent="multiPeriodCreate({{$idx}})" style="margin-top:20px">
  476. Crea multi periodo
  477. </button>
  478. </div>
  479. <div class="col-md-6">
  480. <button type="button" class="btn--ui lightGrey" wire:click.prevent="multiPeriodCancel()" style="margin-top:20px">
  481. Annulla multi periodo
  482. </button>
  483. </div>
  484. </div>
  485. @else
  486. <div class="row">
  487. @foreach($row["when"] as $xxx => $w)
  488. <div class="col-md-4">
  489. <span class="title-form d-block w-100">Mese</span>
  490. <div class="input-group mb-3">
  491. <select class="form-select form-select-lg me-1" wire:model="rows.{{$idx}}.when.{{$xxx}}.month">
  492. @foreach(getMonthList() as $mid => $mname)
  493. <option value="{{$mid}}">{{$mname}}</option>
  494. @endforeach
  495. </select>
  496. </div>
  497. </div>
  498. <div class="col-md-3">
  499. <span class="title-form d-block w-100">Anno</span>
  500. <div class="input-group mb-3">
  501. <input type="number" class="form-control" wire:model="rows.{{$idx}}.when.{{$xxx}}.year" >
  502. </div>
  503. </div>
  504. <div class="col-md-3">
  505. <span class="title-form d-block w-100">Valore</span>
  506. <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>
  507. </div>
  508. <div class="col-md-2"><br>
  509. <button type="button" class="btn--ui primary" wire:click.prevent="delPeriod({{$idx}}, {{$xxx}})" style="float:right">
  510. -
  511. </button>
  512. </div>
  513. @endforeach
  514. <div class="d-flex justify-content-between mt-3">
  515. <button type="button" class="btn--ui primary order-2" wire:click.prevent="addPeriod({{$idx}})">
  516. Aggiungi periodo
  517. </button>
  518. <button type="button" class="btn--ui_tertiary primary order-1" wire:click.prevent="multiPeriod()">
  519. Imposta multi periodo
  520. </button>
  521. </div>
  522. </div>
  523. @endif
  524. </div>
  525. </div>
  526. <br><br>
  527. @if($idx > 0)
  528. <button type="button" class="btn--ui primary" wire:click.prevent="delRow({{$idx}})" style="float:right">
  529. Rimuovi causale
  530. </button>
  531. <br><br>
  532. @endif
  533. <hr size="1">
  534. @endforeach
  535. <br>
  536. <button type="button" class="btn--ui primary" wire:click.prevent="addRow()">
  537. Aggiungi causale
  538. </button>
  539. <div class="accountingExit--btn d-flex align-items-center justify-content-between">
  540. <button class="btn--ui lightGrey" onclick="annulla()">annulla</button>
  541. @if($add)
  542. <button class="btn--ui primary" type="submit" wire:click.prevent="store()">inserisci</button>
  543. @endif
  544. @if($update)
  545. <button class="btn--ui primary" type="submit" wire:click.prevent="update()">salva</button>
  546. @endif
  547. </div>
  548. </form>
  549. </div>
  550. </section>
  551. @endif
  552. <div class="modal fade" id="importResultModal" tabindex="-1" aria-labelledby="importResultModalLabel" aria-hidden="true">
  553. <div class="modal-dialog">
  554. <div class="modal-content">
  555. <div class="modal-header" style="background-color: #0C6197!important;">
  556. <h5 class="modal-title" id="importResultModalLabel" >Importazione Completata</h5>
  557. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  558. </div>
  559. <div class="modal-body">
  560. <div id="importResultMessage"></div>
  561. </div>
  562. <div class="modal-footer" style="background-color: #FFF!important;">
  563. <button type="button" class="btn--ui lightGrey" data-bs-dismiss="modal">Chiudi</button>
  564. </div>
  565. </div>
  566. </div>
  567. </div>
  568. <div class="modal fade" id="recordDetailsModal" tabindex="-1" aria-labelledby="recordDetailsModalLabel" aria-hidden="true">
  569. <div class="modal-dialog modal-lg">
  570. <div class="modal-content">
  571. <div class="modal-header" style="background-color: #0C6197!important;">
  572. <h5 class="modal-title" id="recordDetailsModalLabel">Dettaglio uscita</h5>
  573. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  574. </div>
  575. <div class="modal-body">
  576. <div class="row mb-4">
  577. <div class="col-md-6">
  578. <h6 class="primary">Informazioni generali</h6>
  579. <table class="table table-sm table-borderless">
  580. <tr>
  581. <th>Data:</th>
  582. <td id="recordDate"></td>
  583. </tr>
  584. <tr>
  585. <th>Data pagamento:</th>
  586. <td id="recordPaymentDate"></td>
  587. </tr>
  588. <tr>
  589. <th>Fornitore:</th>
  590. <td id="recordSupplier"></td>
  591. </tr>
  592. <tr>
  593. <th>Metodo di pagamento:</th>
  594. <td id="recordPaymentMethod"></td>
  595. </tr>
  596. </table>
  597. </div>
  598. <div class="col-md-6">
  599. <h6 class="primary">Importo e pagamento</h6>
  600. <table class="table table-sm table-borderless">
  601. <tr>
  602. <th>Importo totale:</th>
  603. <td id="recordTotalAmount" class="primary fw-bold"></td>
  604. </tr>
  605. <tr>
  606. <th>Stato pagamento:</th>
  607. <td><span id="recordPaymentStatus" class="badge"></span></td>
  608. </tr>
  609. </table>
  610. <h6 class="primary mt-3">Allegato</h6>
  611. <div id="recordAttachmentSection">
  612. <div id="recordAttachmentPresent" style="display: none;">
  613. <div class="d-flex align-items-center">
  614. <i class="fa-solid fa-file-pdf me-2 text-danger"></i>
  615. <div>
  616. <a id="recordAttachmentLink" href="#" target="_blank" class="btn btn-sm btn-outline-primary">
  617. <i class="fa-regular fa-eye me-1"></i>
  618. <span id="recordAttachmentName">Visualizza allegato</span>
  619. </a>
  620. </div>
  621. </div>
  622. </div>
  623. <div id="recordAttachmentMissing" style="display: none;">
  624. <span class="text-muted">
  625. <i class="fa-regular fa-file me-2"></i>
  626. Nessun allegato presente
  627. </span>
  628. </div>
  629. </div>
  630. </div>
  631. </div>
  632. <h6 class="primary">Dettaglio causali</h6>
  633. <div class="table-responsive">
  634. <table class="table table-striped table-hover">
  635. <thead>
  636. <tr>
  637. <th scope="col">N.</th>
  638. <th scope="col">Descrizione</th>
  639. <th scope="col">Imponibile</th>
  640. <th scope="col">IVA</th>
  641. <th scope="col">Imposta</th>
  642. <th scope="col">Totale</th>
  643. </tr>
  644. </thead>
  645. <tbody id="recordRowsContainer">
  646. </tbody>
  647. </table>
  648. </div>
  649. </div>
  650. <div class="modal-footer" style="background-color: #FFF!important;">
  651. <button type="button" class="btn--ui lightGrey" data-bs-dismiss="modal">Chiudi</button>
  652. </div>
  653. </div>
  654. </div>
  655. </div>
  656. <div id="loadingOverlay" class="loading-overlay" style="display: none;">
  657. <div class="loading-content">
  658. <div class="loading-spinner"></div>
  659. <div class="loading-text">Caricamento...</div>
  660. <div class="loading-progress">
  661. <div class="progress-bar-custom">
  662. <div class="progress-fill"></div>
  663. </div>
  664. <div class="progress-details mt-2">
  665. <small class="text-muted d-block loading-details"></small>
  666. </div>
  667. </div>
  668. </div>
  669. </div>
  670. </div>
  671. @push('scripts')
  672. <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  673. <style>
  674. table.tableHead thead {
  675. position: sticky;
  676. z-index: 100;
  677. top: 0;
  678. }
  679. .select2-container--default .select2-selection--single{
  680. background-color: #E9F0F5;
  681. border: 0.0625rem solid #DFE5EB;
  682. font-size: 0.75rem;
  683. }
  684. .select2-selection {
  685. height: 38px !important;
  686. }
  687. .select2-selection__rendered {
  688. padding-top:3px;
  689. }
  690. .select2 {
  691. width:100% !important;
  692. }
  693. .select2-selection--multiple{
  694. overflow: hidden !important;
  695. height: auto !important;
  696. }
  697. .file-upload-container {
  698. position: relative;
  699. }
  700. .file-drop-zone {
  701. transition: all 0.3s ease;
  702. cursor: pointer;
  703. }
  704. .file-drop-zone:hover {
  705. border-color: #0C6197 !important;
  706. background-color: #f0f8ff !important;
  707. transform: translateY(-2px);
  708. box-shadow: 0 4px 12px rgba(12, 97, 151, 0.15);
  709. }
  710. .file-drop-zone.dragover {
  711. border-color: #0C6197 !important;
  712. background-color: #e6f3ff !important;
  713. transform: scale(1.02);
  714. box-shadow: 0 8px 25px rgba(12, 97, 151, 0.25);
  715. }
  716. .file-input:focus + .file-drop-zone {
  717. border-color: #0C6197 !important;
  718. box-shadow: 0 0 0 0.25rem rgba(12, 97, 151, 0.25);
  719. }
  720. .file-requirements ul {
  721. list-style-type: none;
  722. padding-left: 1rem;
  723. }
  724. .file-requirements li:before {
  725. content: "•";
  726. color: #6c757d;
  727. margin-right: 0.5rem;
  728. }
  729. .loading-overlay {
  730. position: fixed;
  731. top: 0;
  732. left: 0;
  733. width: 100%;
  734. height: 100%;
  735. background: rgba(0, 0, 0, 0.8);
  736. display: flex;
  737. justify-content: center;
  738. align-items: center;
  739. z-index: 9999;
  740. backdrop-filter: blur(3px);
  741. }
  742. .loading-content {
  743. background: white;
  744. padding: 40px;
  745. border-radius: 15px;
  746. text-align: center;
  747. box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  748. min-width: 350px;
  749. max-width: 90vw;
  750. }
  751. .loading-spinner {
  752. width: 50px;
  753. height: 50px;
  754. border: 5px solid #f3f3f3;
  755. border-top: 5px solid #0C6197;
  756. border-radius: 50%;
  757. animation: spin 1s linear infinite;
  758. margin: 0 auto 25px;
  759. }
  760. @keyframes spin {
  761. 0% { transform: rotate(0deg); }
  762. 100% { transform: rotate(360deg); }
  763. }
  764. .loading-text {
  765. font-size: 18px;
  766. font-weight: 600;
  767. color: #333;
  768. margin-bottom: 20px;
  769. }
  770. .progress-bar-custom {
  771. width: 100%;
  772. height: 6px;
  773. background: #f0f0f0;
  774. border-radius: 3px;
  775. overflow: hidden;
  776. margin-bottom: 10px;
  777. }
  778. .progress-fill {
  779. height: 100%;
  780. background: linear-gradient(90deg, #0C6197, #1e7bb8, #0C6197);
  781. width: 0%;
  782. transition: width 0.5s ease;
  783. animation: progressShimmer 2s ease-in-out infinite;
  784. }
  785. @keyframes progressShimmer {
  786. 0%, 100% { opacity: 1; }
  787. 50% { opacity: 0.8; }
  788. }
  789. .loading-details {
  790. color: #666;
  791. font-size: 0.9em;
  792. min-height: 1.2em;
  793. }
  794. #upload-progress {
  795. background: #f8f9fa;
  796. border: 1px solid #dee2e6;
  797. border-radius: 8px;
  798. padding: 15px;
  799. }
  800. #upload-progress .progress {
  801. height: 10px;
  802. border-radius: 5px;
  803. overflow: hidden;
  804. }
  805. #upload-progress .progress-bar {
  806. transition: width 0.3s ease;
  807. }
  808. .upload-status {
  809. font-weight: 600;
  810. color: #0C6197;
  811. }
  812. .upload-percentage {
  813. font-weight: bold;
  814. color: #28a745;
  815. }
  816. .loading-active {
  817. pointer-events: none;
  818. opacity: 0.7;
  819. transition: opacity 0.3s ease;
  820. }
  821. .file-selected-info {
  822. border-left: 4px solid #28a745;
  823. background-color: #f8fff9;
  824. }
  825. .file-size-display {
  826. font-weight: 600;
  827. }
  828. @media (max-width: 768px) {
  829. .loading-content {
  830. padding: 30px 20px;
  831. min-width: 300px;
  832. }
  833. .file-drop-zone {
  834. min-height: 100px;
  835. padding: 20px 15px;
  836. }
  837. }
  838. @keyframes fileUploadSuccess {
  839. 0% { transform: scale(0.8); opacity: 0; }
  840. 50% { transform: scale(1.05); }
  841. 100% { transform: scale(1); opacity: 1; }
  842. }
  843. .file-selected-info {
  844. animation: fileUploadSuccess 0.5s ease-out;
  845. }
  846. #recordAttachmentSection {
  847. min-height: 50px;
  848. }
  849. #recordAttachmentPresent {
  850. background-color: #f8f9fa;
  851. padding: 10px;
  852. border-radius: 6px;
  853. border-left: 4px solid #28a745;
  854. }
  855. #recordAttachmentMissing {
  856. background-color: #f8f9fa;
  857. padding: 10px;
  858. border-radius: 6px;
  859. border-left: 4px solid #6c757d;
  860. }
  861. #recordAttachmentLink {
  862. text-decoration: none;
  863. transition: all 0.2s ease;
  864. }
  865. #recordAttachmentLink:hover {
  866. transform: translateY(-1px);
  867. box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  868. }
  869. /* Stili per i diversi tipi di file */
  870. .fa-file-pdf {
  871. color: #dc3545 !important;
  872. }
  873. .fa-file-code {
  874. color: #17a2b8 !important;
  875. }
  876. .fa-file-image {
  877. color: #28a745 !important;
  878. }
  879. .fa-file-word {
  880. color: #007bff !important;
  881. }
  882. .fa-file-excel {
  883. color: #28a745 !important;
  884. }
  885. .fa-file {
  886. color: #6c757d !important;
  887. }
  888. /* Animazione per la transizione del campo numero fattura */
  889. .numero-fattura-field {
  890. transition: all 0.3s ease;
  891. overflow: hidden;
  892. }
  893. .numero-fattura-field.hidden {
  894. max-height: 0;
  895. opacity: 0;
  896. margin-bottom: 0 !important;
  897. }
  898. .numero-fattura-field.visible {
  899. max-height: 100px;
  900. opacity: 1;
  901. }
  902. /* Miglioramenti per i radio button */
  903. .check--invoice .form-check-input:checked {
  904. background-color: #0C6197;
  905. border-color: #0C6197;
  906. }
  907. .check--invoice .form-check-label {
  908. font-weight: 500;
  909. transition: color 0.2s ease;
  910. }
  911. .check--invoice .form-check-input:checked + .form-check-label {
  912. color: #0C6197;
  913. }
  914. /* Responsive per mobile */
  915. @media (max-width: 768px) {
  916. #recordAttachmentSection {
  917. margin-top: 15px;
  918. }
  919. #recordAttachmentPresent,
  920. #recordAttachmentMissing {
  921. padding: 8px;
  922. }
  923. #recordAttachmentName {
  924. font-size: 0.9em;
  925. }
  926. }
  927. </style>
  928. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  929. <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  930. @endpush
  931. @push('scripts')
  932. <script>
  933. function matchStart(params, data) {
  934. params.term = params.term || '';
  935. if (data.text.toUpperCase().indexOf(params.term.toUpperCase()) == 0) {
  936. return data;
  937. }
  938. return false;
  939. }
  940. function onlyNumberAmount(input) {
  941. let v = input.value.replace(/\D+/g, '');
  942. if (v.length > 14) v = v.slice(0, 14);
  943. input.value = "€ " + v.replace(/(\d)(\d\d)$/, "$1,$2").replace(/(^\d{1,3}|\d{3})(?=(?:\d{3})+(?:,|$))/g, '$1.');
  944. }
  945. let selectedFileInfo = null;
  946. let fileUploadProgressInterval = null;
  947. function formatFileSize(bytes) {
  948. if (bytes === 0) return '0 Bytes';
  949. const k = 1024;
  950. const sizes = ['Bytes', 'KB', 'MB', 'GB'];
  951. const i = Math.floor(Math.log(bytes) / Math.log(k));
  952. return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
  953. }
  954. function getFileTypeDescription(mimeType) {
  955. const typeMap = {
  956. 'image/jpeg': 'Immagine JPEG',
  957. 'image/jpg': 'Immagine JPG',
  958. 'image/png': 'Immagine PNG',
  959. 'image/gif': 'Immagine GIF',
  960. 'application/pdf': 'Documento PDF',
  961. 'application/msword': 'Documento Word',
  962. 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'Documento Word',
  963. 'text/xml': 'File XML',
  964. 'application/xml': 'File XML',
  965. 'text/plain': 'File di testo',
  966. 'text/csv': 'File CSV',
  967. 'application/vnd.ms-excel': 'File Excel',
  968. 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'File Excel'
  969. };
  970. return typeMap[mimeType] || 'Documento';
  971. }
  972. function validateFile(file) {
  973. const maxSize = 50 * 1024 * 1024;
  974. if (file.size > maxSize) {
  975. alert('File troppo grande. Dimensione massima: 50MB');
  976. return false;
  977. }
  978. const allowedTypes = [
  979. 'image/jpeg', 'image/jpg', 'image/png', 'image/gif', 'image/webp',
  980. 'application/pdf',
  981. 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  982. 'text/xml', 'application/xml', 'text/plain', 'text/csv',
  983. 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  984. ];
  985. if (!allowedTypes.includes(file.type)) {
  986. alert('Tipo di file non supportato. Formati consentiti: immagini, PDF, documenti Word, XML, TXT, CSV, Excel');
  987. return false;
  988. }
  989. return true;
  990. }
  991. function clearFileSelection() {
  992. const attachmentInput = document.getElementById('attachment');
  993. if (attachmentInput) {
  994. attachmentInput.value = '';
  995. }
  996. const fileInfo = document.querySelector('.file-selected-info');
  997. if (fileInfo) {
  998. fileInfo.remove();
  999. }
  1000. selectedFileInfo = null;
  1001. if (window.Livewire) {
  1002. Livewire.first().set('attachment', null);
  1003. }
  1004. }
  1005. function showLoading(message = 'Caricamento...', details = '') {
  1006. const loadingOverlay = document.getElementById('loadingOverlay');
  1007. const loadingText = loadingOverlay.querySelector('.loading-text');
  1008. const loadingDetails = loadingOverlay.querySelector('.loading-details');
  1009. const progressFill = loadingOverlay.querySelector('.progress-fill');
  1010. const form = document.getElementById('accountingExit');
  1011. if (loadingText) {
  1012. loadingText.textContent = message;
  1013. }
  1014. if (loadingDetails) {
  1015. loadingDetails.textContent = details;
  1016. }
  1017. if (progressFill) {
  1018. progressFill.style.width = '0%';
  1019. }
  1020. if (form) {
  1021. form.classList.add('loading-active');
  1022. }
  1023. loadingOverlay.style.display = 'flex';
  1024. startProgressAnimation();
  1025. }
  1026. function showFileUploadLoading(fileName, fileSize) {
  1027. const estimatedTime = Math.max(3, Math.floor(fileSize / (1024 * 1024)) * 2);
  1028. const details = `File: ${fileName} (${formatFileSize(fileSize)})`;
  1029. showLoading('Caricamento allegato in corso...', details);
  1030. startFileUploadProgress(estimatedTime);
  1031. }
  1032. function updateLoading(message, details = '') {
  1033. const loadingOverlay = document.getElementById('loadingOverlay');
  1034. if (!loadingOverlay || loadingOverlay.style.display === 'none') return;
  1035. const loadingText = loadingOverlay.querySelector('.loading-text');
  1036. const loadingDetails = loadingOverlay.querySelector('.loading-details');
  1037. const progressFill = loadingOverlay.querySelector('.progress-fill');
  1038. if (loadingText) {
  1039. loadingText.textContent = message;
  1040. }
  1041. if (loadingDetails && details) {
  1042. loadingDetails.textContent = details;
  1043. }
  1044. // Increase progress
  1045. if (progressFill) {
  1046. const currentWidth = parseInt(progressFill.style.width) || 0;
  1047. const newWidth = Math.min(currentWidth + 20, 90);
  1048. progressFill.style.width = newWidth + '%';
  1049. }
  1050. }
  1051. function hideLoading() {
  1052. const loadingOverlay = document.getElementById('loadingOverlay');
  1053. if (!loadingOverlay) return;
  1054. const progressFill = loadingOverlay.querySelector('.progress-fill');
  1055. const form = document.getElementById('accountingExit');
  1056. if (progressFill) {
  1057. progressFill.style.width = '100%';
  1058. }
  1059. setTimeout(() => {
  1060. loadingOverlay.style.display = 'none';
  1061. if (form) {
  1062. form.classList.remove('loading-active');
  1063. }
  1064. if (fileUploadProgressInterval) {
  1065. clearInterval(fileUploadProgressInterval);
  1066. fileUploadProgressInterval = null;
  1067. }
  1068. }, 500);
  1069. }
  1070. function startProgressAnimation() {
  1071. const progressFill = document.querySelector('#loadingOverlay .progress-fill');
  1072. if (!progressFill) return;
  1073. let progress = 0;
  1074. const interval = setInterval(() => {
  1075. if (progress < 15) {
  1076. progress += 1;
  1077. progressFill.style.width = progress + '%';
  1078. }
  1079. }, 200);
  1080. window.baseProgressInterval = interval;
  1081. }
  1082. function startFileUploadProgress(estimatedSeconds) {
  1083. const progressFill = document.querySelector('#loadingOverlay .progress-fill');
  1084. if (!progressFill) return;
  1085. let progress = 15;
  1086. const increment = 75 / (estimatedSeconds * 10);
  1087. fileUploadProgressInterval = setInterval(() => {
  1088. if (progress < 90) {
  1089. progress += increment;
  1090. progressFill.style.width = Math.min(progress, 90) + '%';
  1091. }
  1092. }, 100);
  1093. }
  1094. function setupDragAndDrop() {
  1095. const fileDropZone = document.getElementById('file-drop-zone');
  1096. const fileInput = document.getElementById('attachment');
  1097. if (!fileDropZone || !fileInput) return;
  1098. ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
  1099. fileDropZone.addEventListener(eventName, preventDefaults, false);
  1100. document.body.addEventListener(eventName, preventDefaults, false);
  1101. });
  1102. ['dragenter', 'dragover'].forEach(eventName => {
  1103. fileDropZone.addEventListener(eventName, highlight, false);
  1104. });
  1105. ['dragleave', 'drop'].forEach(eventName => {
  1106. fileDropZone.addEventListener(eventName, unhighlight, false);
  1107. });
  1108. fileDropZone.addEventListener('drop', handleDrop, false);
  1109. function preventDefaults(e) {
  1110. e.preventDefault();
  1111. e.stopPropagation();
  1112. }
  1113. function highlight(e) {
  1114. fileDropZone.classList.add('dragover');
  1115. }
  1116. function unhighlight(e) {
  1117. fileDropZone.classList.remove('dragover');
  1118. }
  1119. function handleDrop(e) {
  1120. const dt = e.dataTransfer;
  1121. const files = dt.files;
  1122. if (files.length > 0) {
  1123. const file = files[0];
  1124. if (validateFile(file)) {
  1125. fileInput.files = files;
  1126. const event = new Event('change', { bubbles: true });
  1127. fileInput.dispatchEvent(event);
  1128. }
  1129. }
  1130. }
  1131. }
  1132. $(document).ready(function() {
  1133. setupDragAndDrop();
  1134. const attachmentInput = document.getElementById('attachment');
  1135. if (attachmentInput) {
  1136. attachmentInput.addEventListener('change', function(e) {
  1137. const file = e.target.files[0];
  1138. if (!file) return;
  1139. if (!validateFile(file)) {
  1140. e.target.value = '';
  1141. return;
  1142. }
  1143. selectedFileInfo = {
  1144. name: file.name,
  1145. size: file.size,
  1146. type: file.type
  1147. };
  1148. if (file.size > 10 * 1024 * 1024) {
  1149. const warning = document.createElement('div');
  1150. warning.className = 'alert alert-warning mt-2 large-file-warning';
  1151. warning.innerHTML = `
  1152. <i class="fa-solid fa-exclamation-triangle me-2"></i>
  1153. <strong>File di grandi dimensioni:</strong> ${file.name} (${formatFileSize(file.size)})
  1154. <br><small>Il caricamento richiederà tempo aggiuntivo. Assicurati di avere una connessione stabile.</small>
  1155. `;
  1156. const existingWarning = document.querySelector('.large-file-warning');
  1157. if (existingWarning) {
  1158. existingWarning.remove();
  1159. }
  1160. const container = attachmentInput.closest('.col-md-12');
  1161. container.appendChild(warning);
  1162. setTimeout(() => {
  1163. warning.remove();
  1164. }, 5000);
  1165. }
  1166. });
  1167. }
  1168. });
  1169. document.addEventListener('click', function(e) {
  1170. const target = e.target;
  1171. if ((target.textContent.includes('inserisci') || target.textContent.includes('salva')) &&
  1172. target.classList.contains('btn--ui')) {
  1173. const fileInput = document.getElementById('attachment');
  1174. const hasFile = fileInput && fileInput.files.length > 0;
  1175. if (hasFile && selectedFileInfo) {
  1176. setTimeout(() => {
  1177. showFileUploadLoading(selectedFileInfo.name, selectedFileInfo.size);
  1178. }, 100);
  1179. } else {
  1180. setTimeout(() => {
  1181. const action = target.textContent.includes('inserisci') ? 'Salvataggio' : 'Aggiornamento';
  1182. showLoading(action + ' in corso...');
  1183. }, 100);
  1184. }
  1185. }
  1186. });
  1187. window.livewire.on('refresh', () => {
  1188. $('.causalClass').select2({
  1189. matcher: function(params, data) {
  1190. return matchStart(params, data);
  1191. }
  1192. });
  1193. $('.supplierClass').select2({});
  1194. $('.paymentClass').select2({
  1195. matcher: function(params, data) {
  1196. return matchStart(params, data);
  1197. }
  1198. });
  1199. });
  1200. Livewire.on('load-select', () => {
  1201. $('.causalClass').each(function(i, obj) {
  1202. $(obj).select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  1203. $(obj).on('change', function (e) {
  1204. var data = $(obj).select2("val");
  1205. var name = $(obj).select2().attr("name");
  1206. @this.set(name, data);
  1207. });
  1208. });
  1209. $('.supplierClass').select2({});
  1210. $('.supplierClass').on('change', function (e) {
  1211. var data = $('.supplierClass').select2("val");
  1212. @this.set('supplier_id', data);
  1213. });
  1214. $('.paymentClass').select2({
  1215. matcher: function(params, data) {
  1216. return matchStart(params, data);
  1217. }
  1218. });
  1219. $('.paymentClass').on('change', function (e) {
  1220. var data = $('.paymentClass').select2("val");
  1221. @this.set('payment_method_id', data);
  1222. });
  1223. $('.filterSupplier').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  1224. $('.filterPaymentMethod').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  1225. $('.filterCausals').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  1226. setTimeout(setupDragAndDrop, 100);
  1227. });
  1228. Livewire.on('start-loading', message => {
  1229. showLoading(message);
  1230. });
  1231. Livewire.on('update-loading', message => {
  1232. updateLoading(message);
  1233. });
  1234. Livewire.on('stop-loading', () => {
  1235. hideLoading();
  1236. });
  1237. Livewire.on('flash-error', message => {
  1238. hideLoading();
  1239. const alert = document.createElement('div');
  1240. alert.classList.add('alert', 'alert-danger', 'alert-dismissible', 'fade', 'show');
  1241. alert.setAttribute('role', 'alert');
  1242. alert.innerHTML = `
  1243. <i class="fa-solid fa-exclamation-triangle me-2"></i>
  1244. ${message}
  1245. <button type="button" class="btn-close"`;
  1246. const accountingExit = document.getElementById('accountingExit');
  1247. if (accountingExit) {
  1248. accountingExit.prepend(alert);
  1249. } else {
  1250. const mainContainer = document.querySelector('.col.card--ui');
  1251. if (mainContainer) {
  1252. mainContainer.prepend(alert);
  1253. }
  1254. }
  1255. setTimeout(() => {
  1256. alert.remove();
  1257. }, 7000);
  1258. });
  1259. Livewire.on('hide-search', () => {
  1260. });
  1261. var isEdit = false;
  1262. Livewire.on('setEdit', (x) => {
  1263. isEdit = x;
  1264. });
  1265. function annulla() {
  1266. window.onbeforeunload = null;
  1267. document.location.href = '/out';
  1268. }
  1269. window.onbeforeunload = function() {
  1270. if (isEdit)
  1271. return 'Cambiando pagina le eventuali modifiche andranno perse';
  1272. };
  1273. function initImportCausalSelect() {
  1274. $('.import-causal-select').select2({
  1275. dropdownParent: $('#importModal .modal-content'),
  1276. language: {
  1277. noResults: function() {
  1278. return "Nessun risultato";
  1279. }
  1280. }
  1281. });
  1282. $('.import-causal-select').on('change', function() {
  1283. let selectedValue = $(this).val();
  1284. Livewire.first().set('selectedCausal', selectedValue);
  1285. });
  1286. }
  1287. function openImportModal() {
  1288. let tableState = null;
  1289. if ($.fn.DataTable.isDataTable('#tablesaw-350')) {
  1290. tableState = $('#tablesaw-350').DataTable().state.save();
  1291. }
  1292. const importModal = new bootstrap.Modal(document.getElementById('importModal'));
  1293. importModal.show();
  1294. setTimeout(function() {
  1295. initImportCausalSelect();
  1296. if (!$.fn.DataTable.isDataTable('#tablesaw-350')) {
  1297. loadDataTable();
  1298. if (tableState) {
  1299. $('#tablesaw-350').DataTable().state.load(tableState);
  1300. }
  1301. }
  1302. }, 200);
  1303. }
  1304. function closeImportModal() {
  1305. const importModal = bootstrap.Modal.getInstance(document.getElementById('importModal'));
  1306. if (importModal) {
  1307. importModal.hide();
  1308. }
  1309. setTimeout(function() {
  1310. if (!$.fn.DataTable.isDataTable('#tablesaw-350')) {
  1311. loadDataTable();
  1312. }
  1313. }, 100);
  1314. }
  1315. // IMPORT PROGRESS AND RESULTS
  1316. Livewire.on('update-progress', (progress) => {
  1317. const progressBar = document.querySelector('.progress-bar');
  1318. if (progressBar) {
  1319. progressBar.style.width = `${progress}%`;
  1320. progressBar.setAttribute('aria-valuenow', progress);
  1321. progressBar.textContent = `${Math.round(progress)}%`;
  1322. }
  1323. });
  1324. Livewire.on('import-started', () => {
  1325. const closeButton = document.querySelector('#importModal .btn-close');
  1326. const submitButton = document.querySelector('#importModal button[type="submit"]');
  1327. if (closeButton) closeButton.disabled = true;
  1328. if (submitButton) submitButton.disabled = true;
  1329. });
  1330. let transitioningToResultModal = false;
  1331. Livewire.on('show-import-result', data => {
  1332. transitioningToResultModal = true;
  1333. const resultDiv = document.getElementById('importResultMessage');
  1334. resultDiv.innerHTML = data.message;
  1335. const importModal = bootstrap.Modal.getInstance(document.getElementById('importModal'));
  1336. if (importModal) {
  1337. importModal.hide();
  1338. }
  1339. setTimeout(() => {
  1340. const resultModal = new bootstrap.Modal(document.getElementById('importResultModal'));
  1341. resultModal.show();
  1342. }, 300);
  1343. });
  1344. document.getElementById('importModal').addEventListener('hidden.bs.modal', function () {
  1345. if (!transitioningToResultModal) {
  1346. setTimeout(function() {
  1347. window.location.reload();
  1348. }, 500);
  1349. } else {
  1350. transitioningToResultModal = false;
  1351. }
  1352. });
  1353. document.getElementById('importResultModal').addEventListener('hidden.bs.modal', function () {
  1354. window.location.reload();
  1355. });
  1356. function calculateAmount(rowIndex) {
  1357. const imponibileField = document.getElementById(`rows.${rowIndex}.imponibile`);
  1358. const aliquotaField = document.getElementById(`rows.${rowIndex}.aliquota_iva`);
  1359. const amountField = document.getElementById(`rows.${rowIndex}.amount`);
  1360. if (imponibileField && aliquotaField && amountField) {
  1361. let imponibile = imponibileField.value.replace('€', '').replace(/\./g, '').replace(',', '.').trim();
  1362. imponibile = parseFloat(imponibile) || 0;
  1363. let aliquota = parseFloat(aliquotaField.value) || 0;
  1364. const imposta = imponibile * (aliquota / 100);
  1365. const totalAmount = imponibile + imposta;
  1366. let formattedAmount = "€ " + totalAmount.toFixed(2).replace('.', ',').replace(/\B(?=(\d{3})+(?!\d))/g, ".");
  1367. amountField.value = formattedAmount;
  1368. const component = Livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id'));
  1369. if (component) {
  1370. component.set(`rows.${rowIndex}.amount`, formattedAmount);
  1371. }
  1372. }
  1373. }
  1374. function setupCalculationListeners() {
  1375. const rows = document.querySelectorAll('input[id^="rows."][id$=".imponibile"], select[id^="rows."][id$=".aliquota_iva"]');
  1376. rows.forEach(field => {
  1377. field.addEventListener('blur', function() {
  1378. const match = this.id.match(/rows\.(\d+)\./);
  1379. if (match) {
  1380. const rowIndex = match[1];
  1381. calculateAmount(rowIndex);
  1382. }
  1383. });
  1384. field.addEventListener('change', function() {
  1385. const match = this.id.match(/rows\.(\d+)\./);
  1386. if (match) {
  1387. const rowIndex = match[1];
  1388. calculateAmount(rowIndex);
  1389. }
  1390. });
  1391. });
  1392. }
  1393. document.addEventListener('livewire:load', setupCalculationListeners);
  1394. document.addEventListener('livewire:update', setupCalculationListeners);
  1395. Livewire.on('load-select', function() {
  1396. setTimeout(setupCalculationListeners, 300);
  1397. });
  1398. function viewData(id) {
  1399. Livewire.first().viewData(id);
  1400. setTimeout(function() {
  1401. const modalElement = document.getElementById('recordDetailsModal');
  1402. if (modalElement) {
  1403. const modal = new bootstrap.Modal(modalElement);
  1404. modal.show();
  1405. modalElement.addEventListener('hidden.bs.modal', function() {
  1406. setTimeout(function() {
  1407. window.location.reload();
  1408. }, 100);
  1409. });
  1410. }
  1411. }, 300);
  1412. }
  1413. window.addEventListener('show-record-details', function(event) {
  1414. showRecordDetailsModal(event.detail.record);
  1415. });
  1416. function showRecordDetailsModal(record) {
  1417. const modalElement = document.getElementById('recordDetailsModal');
  1418. if (!modalElement) return;
  1419. try {
  1420. let recordDetailsModal = new bootstrap.Modal(modalElement);
  1421. document.getElementById('recordDate').textContent = record.formatted_date || 'N/A';
  1422. document.getElementById('recordPaymentDate').textContent = record.formatted_data_pagamento || 'N/A';
  1423. document.getElementById('recordSupplier').textContent = record.supplier_name || 'N/A';
  1424. document.getElementById('recordPaymentMethod').textContent = record.payment_method_name || 'N/A';
  1425. document.getElementById('recordTotalAmount').textContent = record.formatted_amount || 'N/A';
  1426. const paymentStatusElement = document.getElementById('recordPaymentStatus');
  1427. if (paymentStatusElement) {
  1428. paymentStatusElement.textContent = record.payment_status || 'N/A';
  1429. paymentStatusElement.className = 'badge ' + (record.is_paid ? 'bg-success' : 'bg-warning');
  1430. }
  1431. const rowsContainer = document.getElementById('recordRowsContainer');
  1432. if (rowsContainer) {
  1433. rowsContainer.innerHTML = '';
  1434. if (record.rows && record.rows.length > 0) {
  1435. record.rows.forEach(function(row, index) {
  1436. const tr = document.createElement('tr');
  1437. tr.innerHTML = `
  1438. <td>${index + 1}</td>
  1439. <td>${row.note && row.note.trim() !== '' ? row.note : (row.causal_name || 'N/A')}</td>
  1440. <td>${row.formatted_imponibile || 'N/A'}</td>
  1441. <td>${row.aliquota_iva ? row.aliquota_iva + '%' : '-'}</td>
  1442. <td>${row.formatted_imposta || 'N/A'}</td>
  1443. <td class="fw-bold">${row.formatted_amount || 'N/A'}</td>
  1444. `;
  1445. rowsContainer.appendChild(tr);
  1446. });
  1447. } else {
  1448. const tr = document.createElement('tr');
  1449. tr.innerHTML = '<td colspan="6" class="text-center">Nessuna riga disponibile</td>';
  1450. rowsContainer.appendChild(tr);
  1451. }
  1452. }
  1453. recordDetailsModal.show();
  1454. } catch (error) {
  1455. console.error('Error displaying modal:', error);
  1456. }
  1457. }
  1458. window.addEventListener('beforeunload', function() {
  1459. hideLoading();
  1460. if (fileUploadProgressInterval) {
  1461. clearInterval(fileUploadProgressInterval);
  1462. }
  1463. if (window.baseProgressInterval) {
  1464. clearInterval(window.baseProgressInterval);
  1465. }
  1466. });
  1467. </script>
  1468. <link href="/css/datatables.css" rel="stylesheet" />
  1469. <script src="/assets/js/datatables.js"></script>
  1470. <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
  1471. <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
  1472. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
  1473. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
  1474. <script>
  1475. $(document).ready(function() {
  1476. loadDataTable();
  1477. });
  1478. @if(isset($_GET["showFilters"]))
  1479. var filterSupplier = localStorage.getItem("filterSupplierRecordOut");
  1480. if (filterSupplier && filterSupplier != "null" && filterSupplier != "undefined") {
  1481. $('.filterSupplier').val(filterSupplier);
  1482. $('.filterSupplier').trigger('change');
  1483. }
  1484. var filterPaymentMethod = localStorage.getItem("filterPaymentMethodRecordOut");
  1485. if (filterPaymentMethod && filterPaymentMethod != "null" && filterPaymentMethod != "undefined") {
  1486. $('.filterPaymentMethod').val(filterPaymentMethod);
  1487. $('.filterPaymentMethod').trigger('change');
  1488. }
  1489. var filterCausals = localStorage.getItem("filterCausalsRecordOut");
  1490. if (filterCausals && filterCausals != "null" && filterCausals != "undefined") {
  1491. $('.filterCausals').val(filterCausals);
  1492. $('.filterCausals').trigger('change');
  1493. }
  1494. var filterFrom = localStorage.getItem("filterFromRecordOut");
  1495. if (filterFrom && filterFrom != "" && filterFrom != "undefined") {
  1496. $('.filterFrom').val(filterFrom);
  1497. }
  1498. var filterTo = localStorage.getItem("filterToRecordOut");
  1499. if (filterTo && filterTo != "" && filterTo != "undefined") {
  1500. $('.filterTo').val(filterTo);
  1501. }
  1502. @endif
  1503. var isFilter = false;
  1504. $(document).ready(function() {
  1505. $(document).on("click",".showHideFilter",function() {
  1506. if (isFilter) {
  1507. isFilter = false;
  1508. $(".showFilter").hide();
  1509. } else {
  1510. isFilter = true;
  1511. $(".showFilter").show();
  1512. }
  1513. });
  1514. $(document).on("select2:open",".filterCausals",function() {
  1515. setTimeout(() => {
  1516. $(".select2-results__option").each(function(){
  1517. var txt = $(this).html();
  1518. var count = (txt.match(/-/g) || []).length;
  1519. $(this).addClass('paddingLeftSelect' + count);
  1520. });
  1521. }, 100);
  1522. });
  1523. $(document).on("click",".addData",function() {
  1524. $(".title--section_addButton").trigger("click")
  1525. });
  1526. });
  1527. function editData(id) {
  1528. @this.edit(id);
  1529. }
  1530. function deleteData(id) {
  1531. if (confirm('Sei sicuro?'))
  1532. @this.delete(id).then(() => {
  1533. window.location.reload();
  1534. });
  1535. }
  1536. Livewire.on('load-data-table', () => {
  1537. setTimeout(function() { loadDataTable() }, 100);
  1538. });
  1539. Livewire.on('destroy-data-table', () => {
  1540. $('#tablesaw-350').DataTable().destroy();
  1541. });
  1542. function destroyDataTable() {
  1543. $('#tablesaw-350').DataTable().destroy();
  1544. }
  1545. function reset() {
  1546. $(".todayButton").addClass("lightGrey");
  1547. $(".yesterdayButton").addClass("lightGrey");
  1548. $('.filterSupplier').val('');
  1549. $('.filterSupplier').trigger('change');
  1550. $('.filterPaymentMethod').val('');
  1551. $('.filterPaymentMethod').trigger('change');
  1552. $('.filterCausals').val('');
  1553. $('.filterCausals').trigger('change');
  1554. $('.filterFrom').val('');
  1555. $('.filterTo').val('');
  1556. localStorage.clear();
  1557. loadDataTable();
  1558. }
  1559. function loadDataTable() {
  1560. if ($.fn.DataTable.isDataTable('#tablesaw-350')) {
  1561. $('#tablesaw-350').DataTable().destroy();
  1562. }
  1563. var filterSupplier = $('.filterSupplier').val();
  1564. var filterPaymentMethod = $('.filterPaymentMethod').val();
  1565. var filterCausals = $('.filterCausals').val();
  1566. var filterFrom = $('.filterFrom').val();
  1567. var filterTo = $('.filterTo').val();
  1568. localStorage.setItem("filterSupplierRecordOut", filterSupplier);
  1569. localStorage.setItem("filterPaymentMethodRecordOut", filterPaymentMethod);
  1570. localStorage.setItem("filterCausalsRecordOut", filterCausals);
  1571. localStorage.setItem("filterFromRecordOut", filterFrom);
  1572. localStorage.setItem("filterToRecordOut", filterTo);
  1573. $('#tablesaw-350').DataTable({
  1574. ajax: {
  1575. url : "/get_record_out?filterSupplier=" + filterSupplier + "&filterPaymentMethod=" + filterPaymentMethod + "&filterCausals=" + filterCausals + "&filterFrom=" + filterFrom + "&filterTo=" + filterTo,
  1576. dataSrc: function (json){
  1577. if(json.totals){
  1578. $(".totalDiv").html('Totale&nbsp;:&nbsp;<b>' + json.totals + '</b>');
  1579. } else {
  1580. $(".totalDiv").html('');
  1581. }
  1582. @if(Auth::user()->level != 0)
  1583. $(".totalDiv").html('');
  1584. @endif
  1585. return json.data;
  1586. }
  1587. },
  1588. columns: [
  1589. { data: 'numero_fattura' },
  1590. {
  1591. data: "date",
  1592. render: function (data, type){
  1593. if (data == "") return " TOTALE";
  1594. if (type == "sort"){
  1595. return new Date(data).getTime();
  1596. }
  1597. const j = data.split(" ");
  1598. const d = j[0].split("-");
  1599. var ret = d[2] + "/" + d[1] + "/" + d[0];
  1600. return ret;
  1601. }
  1602. },
  1603. { data: 'total', className: "numericCol" },
  1604. { data: 'supplier' },
  1605. { data: 'causals' },
  1606. { data: 'payment' },
  1607. {
  1608. data: 'is_paid',
  1609. render: function (data) {
  1610. if (data === true || data === 'true' || data === 1 || data === '1' || data === 'Pagato') {
  1611. return '<span class="badge bg-success">Pagato</span>';
  1612. } else {
  1613. return '<span class="badge bg-warning">Da Pagare</span>';
  1614. }
  1615. }
  1616. },
  1617. {
  1618. data: "action",
  1619. render: function (data){
  1620. if (data == "") return "";
  1621. const j = data.split("|");
  1622. 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;';
  1623. 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;';
  1624. 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>';
  1625. return ret;
  1626. }
  1627. },
  1628. ],
  1629. order: [[1, 'desc']],
  1630. thead: {
  1631. 'th': {'background-color': 'blue'}
  1632. },
  1633. layout: {
  1634. topStart : null,
  1635. topEnd : null,
  1636. top1A: {
  1637. buttons: [
  1638. {
  1639. extend: 'collection',
  1640. text: 'ESPORTA',
  1641. buttons: [
  1642. {
  1643. extend: 'excelHtml5',"action":newexportaction,
  1644. title: 'Uscite',
  1645. exportOptions: {
  1646. columns: ":not(':last')"
  1647. }
  1648. },
  1649. {
  1650. extend: 'pdfHtml5',"action":newexportaction,
  1651. title: 'Uscite',
  1652. exportOptions: {
  1653. columns: ":not(':last')"
  1654. }
  1655. },
  1656. {
  1657. extend: 'print',"action":newexportaction,
  1658. text: 'Stampa',
  1659. title: 'Uscite',
  1660. exportOptions: {
  1661. columns: ":not(':last')"
  1662. }
  1663. }
  1664. ],
  1665. dropup: true
  1666. }
  1667. ]
  1668. },
  1669. top1B : {
  1670. pageLength: {
  1671. menu: [[10, 25, 50, 100, 100000], [10, 25, 50, 100, "Tutti"]]
  1672. }
  1673. },
  1674. top1C :'search',
  1675. },
  1676. pagingType: 'numbers',
  1677. "language": {
  1678. "url": "/assets/js/Italian.json"
  1679. },
  1680. "fnInitComplete": function (oSettings, json) {
  1681. var html = '&nbsp;<a href="#" class="showHideFilter btn--ui"><i class="fa-solid fa-sliders"></i></a>';
  1682. html += '&nbsp;<a href="#" class="addData btn--ui"><i class="fa-solid fa-plus"></i></a>';
  1683. $(".dt-search").append(html);
  1684. }
  1685. });
  1686. $('#tablesaw-350 thead tr th').addClass('col');
  1687. $('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");
  1688. $('#tablesaw-350').on('draw.dt', function() {
  1689. $('[data-bs-toggle="popover"]').popover()
  1690. });
  1691. }
  1692. document.addEventListener('livewire:initialized', () => {
  1693. let importModalOpen = false;
  1694. const importModal = document.getElementById('importModal');
  1695. importModal.addEventListener('shown.bs.modal', function () {
  1696. importModalOpen = true;
  1697. });
  1698. importModal.addEventListener('hidden.bs.modal', function () {
  1699. importModalOpen = false;
  1700. setTimeout(() => {
  1701. if (!$.fn.DataTable.isDataTable('#tablesaw-350')) {
  1702. loadDataTable();
  1703. }
  1704. }, 100);
  1705. });
  1706. document.addEventListener('livewire:update', function() {
  1707. if (importModalOpen) {
  1708. const modalInstance = bootstrap.Modal.getInstance(importModal);
  1709. if (!modalInstance) {
  1710. const newModal = new bootstrap.Modal(importModal);
  1711. newModal.show();
  1712. } else if (!importModal.classList.contains('show')) {
  1713. modalInstance.show();
  1714. }
  1715. setTimeout(() => {
  1716. if (!$.fn.DataTable.isDataTable('#tablesaw-350')) {
  1717. loadDataTable();
  1718. }
  1719. }, 100);
  1720. }
  1721. });
  1722. document.querySelectorAll('.select2-container').forEach(select => {
  1723. select.addEventListener('click', function(e) {
  1724. e.stopPropagation();
  1725. });
  1726. });
  1727. });
  1728. document.addEventListener('DOMContentLoaded', function() {
  1729. if (document.getElementById('importModal')) {
  1730. initImportCausalSelect();
  1731. }
  1732. Livewire.on('load-select', function() {
  1733. if (document.getElementById('importModal') &&
  1734. document.getElementById('importModal').classList.contains('show')) {
  1735. initImportCausalSelect();
  1736. }
  1737. });
  1738. setupCalculationListeners();
  1739. setupDragAndDrop();
  1740. const recordDetailsModal = document.getElementById('recordDetailsModal');
  1741. if (recordDetailsModal) {
  1742. recordDetailsModal.addEventListener('hidden.bs.modal', function() {
  1743. setTimeout(function() {
  1744. window.location.reload();
  1745. }, 100);
  1746. });
  1747. }
  1748. });
  1749. function pollAttachmentStatus(recordId) {
  1750. const pollInterval = setInterval(function() {
  1751. fetch(`/check-attachment-status/${recordId}`)
  1752. .then(response => response.json())
  1753. .then(data => {
  1754. if (data.status === 'completed') {
  1755. clearInterval(pollInterval);
  1756. showSuccess('Allegato caricato con successo!');
  1757. } else if (data.status === 'failed') {
  1758. clearInterval(pollInterval);
  1759. showError('Caricamento allegato fallito');
  1760. }
  1761. });
  1762. }, 2000);
  1763. setTimeout(() => clearInterval(pollInterval), 300000);
  1764. }
  1765. function showRecordDetailsModal(record) {
  1766. const modalElement = document.getElementById('recordDetailsModal');
  1767. if (!modalElement) return;
  1768. try {
  1769. let recordDetailsModal = new bootstrap.Modal(modalElement);
  1770. document.getElementById('recordDate').textContent = record.formatted_date || 'N/A';
  1771. document.getElementById('recordPaymentDate').textContent = record.formatted_data_pagamento || 'N/A';
  1772. document.getElementById('recordSupplier').textContent = record.supplier_name || 'N/A';
  1773. document.getElementById('recordPaymentMethod').textContent = record.payment_method_name || 'N/A';
  1774. document.getElementById('recordTotalAmount').textContent = record.formatted_amount || 'N/A';
  1775. const paymentStatusElement = document.getElementById('recordPaymentStatus');
  1776. if (paymentStatusElement) {
  1777. paymentStatusElement.textContent = record.payment_status || 'N/A';
  1778. paymentStatusElement.className = 'badge ' + (record.is_paid ? 'bg-success' : 'bg-warning');
  1779. }
  1780. const attachmentPresentDiv = document.getElementById('recordAttachmentPresent');
  1781. const attachmentMissingDiv = document.getElementById('recordAttachmentMissing');
  1782. const attachmentLink = document.getElementById('recordAttachmentLink');
  1783. const attachmentName = document.getElementById('recordAttachmentName');
  1784. if (record.attachment && record.attachment_url) {
  1785. attachmentPresentDiv.style.display = 'block';
  1786. attachmentMissingDiv.style.display = 'none';
  1787. // Configura il link per l'allegato
  1788. attachmentLink.href = record.attachment_url;
  1789. // Estrai il nome del file dal percorso
  1790. let fileName = record.attachment;
  1791. if (fileName.includes('/')) {
  1792. fileName = fileName.split('/').pop();
  1793. }
  1794. if (fileName.includes('\\')) {
  1795. fileName = fileName.split('\\').pop();
  1796. }
  1797. // Se il nome è troppo lungo, troncalo
  1798. if (fileName.length > 30) {
  1799. const extension = fileName.substring(fileName.lastIndexOf('.'));
  1800. const baseName = fileName.substring(0, fileName.lastIndexOf('.'));
  1801. fileName = baseName.substring(0, 25) + '...' + extension;
  1802. }
  1803. attachmentName.textContent = fileName;
  1804. // Aggiorna l'icona in base al tipo di file
  1805. const iconElement = attachmentPresentDiv.querySelector('i.fa-file-pdf');
  1806. if (fileName.toLowerCase().includes('.pdf')) {
  1807. iconElement.className = 'fa-solid fa-file-pdf me-2 text-danger';
  1808. } else if (fileName.toLowerCase().includes('.xml')) {
  1809. iconElement.className = 'fa-solid fa-file-code me-2 text-info';
  1810. } else if (fileName.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/)) {
  1811. iconElement.className = 'fa-solid fa-file-image me-2 text-success';
  1812. } else if (fileName.toLowerCase().match(/\.(doc|docx)$/)) {
  1813. iconElement.className = 'fa-solid fa-file-word me-2 text-primary';
  1814. } else if (fileName.toLowerCase().match(/\.(xls|xlsx|csv)$/)) {
  1815. iconElement.className = 'fa-solid fa-file-excel me-2 text-success';
  1816. } else {
  1817. iconElement.className = 'fa-solid fa-file me-2 text-secondary';
  1818. }
  1819. } else {
  1820. // Mostra la sezione senza allegato
  1821. attachmentPresentDiv.style.display = 'none';
  1822. attachmentMissingDiv.style.display = 'block';
  1823. }
  1824. // Popola le righe come prima
  1825. const rowsContainer = document.getElementById('recordRowsContainer');
  1826. if (rowsContainer) {
  1827. rowsContainer.innerHTML = '';
  1828. if (record.rows && record.rows.length > 0) {
  1829. record.rows.forEach(function(row, index) {
  1830. const tr = document.createElement('tr');
  1831. tr.innerHTML = `
  1832. <td>${index + 1}</td>
  1833. <td>${row.note && row.note.trim() !== '' ? row.note : (row.causal_name || 'N/A')}</td>
  1834. <td>${row.formatted_imponibile || 'N/A'}</td>
  1835. <td>${row.aliquota_iva ? row.aliquota_iva + '%' : '-'}</td>
  1836. <td>${row.formatted_imposta || 'N/A'}</td>
  1837. <td class="fw-bold">${row.formatted_amount || 'N/A'}</td>
  1838. `;
  1839. rowsContainer.appendChild(tr);
  1840. });
  1841. } else {
  1842. const tr = document.createElement('tr');
  1843. tr.innerHTML = '<td colspan="6" class="text-center">Nessuna riga disponibile</td>';
  1844. rowsContainer.appendChild(tr);
  1845. }
  1846. }
  1847. recordDetailsModal.show();
  1848. } catch (error) {
  1849. console.error('Error displaying modal:', error);
  1850. }
  1851. }
  1852. // Aggiungere questo listener per gestire i cambi di stato del campo commercial
  1853. document.addEventListener('livewire:load', function() {
  1854. // Listener per il cambio del radio button commerciale/non commerciale
  1855. const commercialRadios = document.querySelectorAll('input[name="commercial"]');
  1856. commercialRadios.forEach(radio => {
  1857. radio.addEventListener('change', function() {
  1858. console.log('Commercial value changed to:', this.value);
  1859. // Il campo numero fattura sarà nascosto/mostrato automaticamente da Livewire
  1860. });
  1861. });
  1862. });
  1863. // Listener per gli aggiornamenti di Livewire
  1864. document.addEventListener('livewire:update', function() {
  1865. // Re-attach listeners dopo gli aggiornamenti di Livewire
  1866. const commercialRadios = document.querySelectorAll('input[name="commercial"]');
  1867. commercialRadios.forEach(radio => {
  1868. radio.addEventListener('change', function() {
  1869. console.log('Commercial value changed to:', this.value);
  1870. });
  1871. });
  1872. });
  1873. </script>
  1874. @endpush