records_out.blade.php 99 KB

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