records_in_out.blade.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <div class="col card--ui" id="card--dashboard">
  2. <header id="title--section" style="display:none !important" class="d-flex align-items-center justify-content-between">
  3. <div class="title--section_name d-flex align-items-center justify-content-between">
  4. <i class="ico--ui title_section utenti me-2"></i>
  5. <h2 class="primary">Gestionale</h2>
  6. </div>
  7. </header>
  8. <section id="subheader" class="d-flex align-items-center ">
  9. <form action="" class=" d-flex align-items-center ">
  10. <select class="form-select form-select-lg me-1 " id="month" style="width:150px !important;">
  11. <option value="x" {{$month == "x" ? 'selected' : ""}}>Anno completo</option>
  12. <option value="1" {{$month == "1" ? 'selected' : ""}}>Gennaio</option>
  13. <option value="2" {{$month == "2" ? 'selected' : ""}}>Febbraio</option>
  14. <option value="3" {{$month == "3" ? 'selected' : ""}}>Marzo</option>
  15. <option value="4" {{$month == "4" ? 'selected' : ""}}>Aprile</option>
  16. <option value="5" {{$month == "5" ? 'selected' : ""}}>Maggio</option>
  17. <option value="6" {{$month == "6" ? 'selected' : ""}}>Giugno</option>
  18. <option value="7" {{$month == "7" ? 'selected' : ""}}>Luglio</option>
  19. <option value="8" {{$month == "8" ? 'selected' : ""}}>Agosto</option>
  20. <option value="9" {{$month == "9" ? 'selected' : ""}}>Settembre</option>
  21. <option value="10" {{$month == "10" ? 'selected' : ""}}>Ottobre</option>
  22. <option value="11" {{$month == "11" ? 'selected' : ""}}>Novembre</option>
  23. <option value="12" {{$month == "12" ? 'selected' : ""}}>Dicembre</option>
  24. </select>
  25. <select class="form-select " style="width:100px !important;" id="year">
  26. @for($y=date("Y") + 5; $y>date("Y") - 2; $y--)
  27. <option value="{{$y}}" {{$y == date("Y") ? 'selected' : ''}}>{{$y}}</option>
  28. @endfor
  29. </select>
  30. </form>
  31. @if(sizeof($columns) < 6)
  32. <button class="btn--ui show" style="margin-left:5px;">aggiungi</button>
  33. @endif
  34. <button class="btn--ui lightGrey reset reset" onClick="window.location.reload();" style="margin-left:5px;">reset</button>
  35. @if($showData)
  36. <div class="export--button ms-auto">
  37. <button class="btn--ui lightGrey reset" wire:click="export()"><i class="fa-solid fa-download me-2"></i>esporta selezione</button>
  38. <button class="btn--ui lightGrey reset exportYear" style="margin-left:5px;">esporta anno fiscale</button>
  39. </div>
  40. @endif
  41. </section>
  42. <section id="resume-table">
  43. <div class="compare--chart_wrapper d-none"></div>
  44. <div class="row ">
  45. <div class="col-md-12">
  46. <h1>Entrate</h1>
  47. <div class="row ">
  48. <div class="col-md-2">
  49. Filtra per causale
  50. </div>
  51. <div class="col-md-12 m-1">
  52. <select name="search_causal_id[]" class="form-select filterCausalsIn filterCausals" multiple="multiple" wire:model="filterCausalsIn">
  53. @foreach($causalsIn as $causal)
  54. <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
  55. @endforeach
  56. </select>
  57. </div>
  58. </div>
  59. <table class="table tablesaw tableHead tablesaw-stack collaptableIN" >
  60. <thead>
  61. <tr>
  62. <th scope="col" style="width:20%;text-align:left"></th>
  63. @foreach($columns as $idx => $column)
  64. <th scope="col cellBorder" style="width:13%;text-align:center">{{$this->getMonth($column)}} <br><a href="#" wire:click="remove({{$idx}})"><i class="fa fa-trash" aria-hidden="true" style="color:red"></i></a></th>
  65. @endforeach
  66. @for($j=sizeof($columns);$j<6;$j++)
  67. <th scope="col cellBorder" style="width:13%;text-align:center">&nbsp;</th>
  68. @endfor
  69. </tr>
  70. </thead>
  71. <tbody id="checkall-target">
  72. @php
  73. $aScritto = array();
  74. @endphp
  75. @foreach($rows_in as $in)
  76. @if($filterCausalsIn == null || (sizeof($filterCausalsIn) == 0 || in_array($in["id"], $filterCausalsIn) || in_array($in["parent_id"], $filterCausalsIn) || in_array($in["first_parent_id"], $filterCausalsIn)))
  77. @if($in["first_parent_name"] != "" && $filterCausalsIn != null && !in_array($in["first_parent_id"], $filterCausalsIn) && !in_array($in["first_parent_id"] . "_" . $in["parent_id"], $aScritto))
  78. @php
  79. $aScritto[] = $in["first_parent_id"] . "_" . $in["parent_id"];
  80. @endphp
  81. <tr>
  82. <td>
  83. <b>{{$in["first_parent_name"]}} - {{$in["parent_name"]}}</b>
  84. </td>
  85. @foreach($columns as $column)
  86. <td class="cellBorder" style="text-align:right">
  87. @if(isset($records_in[$column][$in["parent_id"]]))
  88. <span class="tablesaw-cell-content {{$in["level"] == 0 ? 'primary' : ''}}" {{$in["level"] == 0 ? 'style="font-weight:bold;' : ''}}>
  89. {{formatPrice($records_in[$column][$in["parent_id"]])}}
  90. </span>
  91. @else
  92. &nbsp;
  93. @endif
  94. </td>
  95. @endforeach
  96. </tr>
  97. @endif
  98. <tr data-id="{{$in["id"]}}" data-parent="{{$filterCausalsIn == null || in_array($in["parent_id"], $filterCausalsIn) ? $in["parent_id"] : ''}}">
  99. <td>
  100. <span class="spaces">{!!str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $in["level"])!!}</span>
  101. @if($filterCausalsIn != null && !in_array($in["first_parent_id"], $filterCausalsIn))
  102. <span style="padding-left:20px">{!!str_repeat(" ", 5)!!}</span>
  103. @endif
  104. {{$in["name"]}}
  105. </td>
  106. @foreach($columns as $column)
  107. <td class="cellBorder" style="text-align:right">
  108. @if(isset($records_in[$column][$in["id"]]))
  109. <span class="tablesaw-cell-content {{$in["level"] == 0 ? 'primary' : ''}}" {{$in["level"] == 0 ? 'style="font-weight:bold;' : ''}}>
  110. {{formatPrice($records_in[$column][$in["id"]])}}
  111. </span>
  112. @else
  113. &nbsp;
  114. @endif
  115. </td>
  116. @endforeach
  117. @for($j=sizeof($columns);$j<6;$j++)
  118. <td class="cellBorder">&nbsp;</th>
  119. @endfor
  120. </tr>
  121. @endif
  122. @endforeach
  123. <tr>
  124. <td><b>Totale entrate mensili</b></td>
  125. @foreach($columns as $column)
  126. <td class="cellBorder" style="text-align:right">
  127. @php
  128. $total = 0;
  129. $existIn = [];
  130. @endphp
  131. @foreach($rows_in as $in)
  132. @if($filterCausalsIn == null || (sizeof($filterCausalsIn) == 0 || in_array($in["id"], $filterCausalsIn)))
  133. @if(isset($records_in[$column][$in["id"]]))
  134. @php
  135. if($in["level"] == 0)
  136. {
  137. $total += $records_in[$column][$in["id"]];
  138. $existIn[] = $in["id"];
  139. }
  140. else
  141. {
  142. if (!in_array($in["parent_id"], $existIn))
  143. {
  144. $total += $records_in[$column][$in["id"]];
  145. }
  146. $existIn[] = $in["id"];
  147. }
  148. @endphp
  149. @endif
  150. @endif
  151. @endforeach
  152. <span class="tablesaw-cell-content primary" style="color:green; font-size:18px;"><b>{{formatPrice($total)}}</b></span>
  153. </td>
  154. @endforeach
  155. @for($j=sizeof($columns);$j<6;$j++)
  156. <td class="cellBorder">&nbsp;</th>
  157. @endfor
  158. </tr>
  159. </tbody>
  160. <tfoot>
  161. </tfoot>
  162. </table>
  163. </div>
  164. </div>
  165. <div class="row ">
  166. <div class="col-md-12">
  167. <h1>Uscite</h1>
  168. <div class="row ">
  169. <div class="col-md-2">
  170. <label class="form-label">Filtra per causale</label>
  171. </div>
  172. <div class="col-md-12 m-1">
  173. <select name="search_causal_id_x[]" class="form-select filterCausalsOut filterCausals" multiple="multiple" wire:model="filterCausalsOut">
  174. @foreach($causalsOut as $causal)
  175. <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
  176. @endforeach
  177. </select>
  178. </div>
  179. </div>
  180. <table class="table tablesaw tableHead tablesaw-stack collaptableOUT">
  181. <thead>
  182. <tr>
  183. <th scope="col" style="width:20%;text-align:left"></th>
  184. @foreach($columns as $idx => $column)
  185. <th scope="col cellBorder" style="width:13%;text-align:center">{{$this->getMonth($column)}} <br><a href="#" wire:click="remove({{$idx}})"><i class="fa fa-trash" aria-hidden="true" style="color:red"></i></a></th>
  186. @endforeach
  187. @for($j=sizeof($columns);$j<6;$j++)
  188. <th scope="col cellBorder" style="width:13%;text-align:center">&nbsp;</th>
  189. @endfor
  190. </tr>
  191. </thead>
  192. <tbody id="checkall-target">
  193. @php
  194. $aScrittoX = array();
  195. @endphp
  196. @foreach($rows_out as $out)
  197. @if($filterCausalsOut == null || (sizeof($filterCausalsOut) == 0 || in_array($out["id"], $filterCausalsOut) || in_array($out["parent_id"], $filterCausalsOut) || in_array($out["first_parent_id"], $filterCausalsOut)))
  198. @if($filterCausalsOut != null && !in_array($out["first_parent_id"], $filterCausalsOut) && !in_array($out["first_parent_id"] . "_" . $out["parent_id"], $aScrittoX))
  199. @php
  200. $aScrittoX[] = $out["first_parent_id"] . "_" . $out["parent_id"];
  201. @endphp
  202. <tr>
  203. <td colspan="20">
  204. <b>{{$out["first_parent_name"]}} - {{$out["parent_name"]}}</b>
  205. </td>
  206. </tr>
  207. @endif
  208. <tr data-id="{{$out["id"] + 1000}}" data-parent="{{$out["parent_id"] != null ? ($out["parent_id"] + 1000) : 0}}">
  209. <td>{!!str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $out["level"])!!}{{$out["name"]}}</td>
  210. @foreach($columns as $column)
  211. <td class="cellBorder" style="text-align:right">
  212. @if(isset($records_out[$column][$out["id"]]))
  213. <span class="tablesaw-cell-content {{$out["level"] == 0 ? 'primary' : ''}}" {{$out["level"] == 0 ? 'style="font-weight:bold;' : ''}}>
  214. {{formatPrice($records_out[$column][$out["id"]])}}
  215. </span>
  216. @else
  217. &nbsp;
  218. @endif
  219. </td>
  220. @endforeach
  221. @for($j=sizeof($columns);$j<6;$j++)
  222. <td class="cellBorder">&nbsp;</th>
  223. @endfor
  224. </tr>
  225. @endif
  226. @endforeach
  227. <tr>
  228. <td><b>Totale uscite mensili</b></td>
  229. @foreach($columns as $column)
  230. <td class="cellBorder" style="text-align:right">
  231. @php
  232. $total = 0;
  233. $existOut = [];
  234. @endphp
  235. @foreach($rows_out as $out)
  236. @if($filterCausalsOut == null || (sizeof($filterCausalsOut) == 0 || in_array($out["id"], $filterCausalsOut)))
  237. @if(isset($records_out[$column][$out["id"]]))
  238. @php
  239. if($out["level"] == 0)
  240. {
  241. $total += $records_out[$column][$out["id"]];
  242. $existOut[] = $out["id"];
  243. }
  244. else
  245. {
  246. if (!in_array($out["parent_id"], $existOut))
  247. {
  248. $total += $records_out[$column][$out["id"]];
  249. }
  250. $existOut[] = $out["id"];
  251. }
  252. @endphp
  253. @endif
  254. @endif
  255. @endforeach
  256. <span class="tablesaw-cell-content primary" style="color:red; font-size:18px;"><b>{{formatPrice($total)}}</b></span>
  257. </td>
  258. @endforeach
  259. @for($j=sizeof($columns);$j<6;$j++)
  260. <td class="cellBorder">&nbsp;</th>
  261. @endfor
  262. </tr>
  263. </tbody>
  264. <tfoot>
  265. </tfoot>
  266. </table>
  267. </div>
  268. </div>
  269. </section>
  270. <a style="display:none" href="javascript:void(0);" id="collapseAll" class="act-button-collapse-all">Collapse All</a>
  271. </div>
  272. @push('scripts')
  273. <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  274. <style>
  275. .select2-container--default .select2-selection--single{
  276. background-color: #E9F0F5;
  277. border: 0.0625rem solid #DFE5EB;
  278. font-size: 0.75rem;
  279. }
  280. .select2-selection
  281. {
  282. height: 38px !important;
  283. }
  284. .select2-selection__rendered
  285. {
  286. padding-top:3px;
  287. }
  288. .select2 {
  289. width:100% !important;
  290. }
  291. .i{
  292. font-size:16px;
  293. font-weight:bold;
  294. }
  295. .cellBorder
  296. {
  297. border-left: 1px solid grey;
  298. }
  299. .select2-selection--multiple{
  300. overflow: hidden !important;
  301. height: auto !important;
  302. }
  303. .select2-container {
  304. box-sizing: border-box;
  305. display: inline-block;
  306. margin: 0;
  307. position: relative;
  308. vertical-align: middle;
  309. }
  310. .select2-container .select2-selection--single {
  311. box-sizing: border-box;
  312. cursor: pointer;
  313. display: block;
  314. height: 38px;
  315. user-select: none;
  316. -webkit-user-select: none;
  317. }
  318. .select2-container .select2-selection--single .select2-selection__rendered {
  319. display: block;
  320. padding-left: 8px;
  321. padding-right: 20px;
  322. overflow: hidden;
  323. text-overflow: ellipsis;
  324. white-space: nowrap;
  325. }
  326. </style>
  327. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  328. <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  329. <script src="/assets/js/aCollapTable.js"></script>
  330. @endpush
  331. @push('scripts')
  332. <script>
  333. Livewire.on('load-table', () => {
  334. load();
  335. });
  336. function load()
  337. {
  338. $(document).ready(function(){
  339. $(document).on("keypress", $('.filterCausals'), function (e) {
  340. setTimeout(() => {
  341. $(".select2-results__option").each(function(){
  342. var txt = $(this).html();
  343. var count = (txt.match(/-/g) || []).length;
  344. $(this).addClass('paddingLeftSelect' + count);
  345. });
  346. }, 100);
  347. });
  348. $('.filterCausalsIn').select2();
  349. $('.filterCausalsIn').on('change', function (e) {
  350. var data = $('.filterCausalsIn').select2("val");
  351. setTimeout(function() {createCollapse();}, 1000);
  352. @this.set('filterCausalsIn', data);
  353. });
  354. $('.filterCausalsOut').select2();
  355. $('.filterCausalsOut').on('change', function (e) {
  356. var data = $('.filterCausalsOut').select2("val");
  357. setTimeout(function() {createCollapse();}, 1000);
  358. @this.set('filterCausalsOut', data);
  359. });
  360. $('.filterCausals').on('select2:open', function (e) {
  361. setTimeout(() => {
  362. $(".select2-results__option").each(function(){
  363. var txt = $(this).html();
  364. var count = (txt.match(/-/g) || []).length;
  365. $(this).addClass('paddingLeftSelect' + count);
  366. });
  367. }, 100);
  368. });
  369. createCollapse();
  370. });
  371. }
  372. function createCollapse()
  373. {
  374. $(".act-more").remove();
  375. $(".spaces").remove();
  376. //$("#checkall-target > tr").removeAttr("data-level");
  377. //$("#checkall-target > tr").removeAttr("class");
  378. $('.collaptableIN').aCollapTable({
  379. startCollapsed: true,
  380. addColumn: false,
  381. plusButton: '<span class="i"> + </span>',
  382. minusButton: '<span class="i"> - </span>'
  383. });
  384. $('.collaptableOUT').aCollapTable({
  385. startCollapsed: true,
  386. addColumn: false,
  387. plusButton: '<span class="i"> + </span>',
  388. minusButton: '<span class="i"> - </span>'
  389. });
  390. $("#collapseAll").trigger("click");
  391. }
  392. Livewire.on('reset-collapse', () => {
  393. createCollapse();
  394. });
  395. Livewire.on('load-select', () => {
  396. $('.filterCausalsIn').select2();
  397. $('.filterCausalsIn').on('change', function (e) {
  398. var data = $('.filterCausalsIn').select2("val");
  399. setTimeout(function() {createCollapse();}, 1000);
  400. @this.set('filterCausalsIn', data);
  401. });
  402. $('.filterCausalsOut').select2();
  403. $('.filterCausalsOut').on('change', function (e) {
  404. var data = $('.filterCausalsOut').select2("val");
  405. setTimeout(function() {createCollapse();}, 1000);
  406. @this.set('filterCausalsOut', data);
  407. });
  408. });
  409. load();
  410. $(document).on("click", ".show", function () {
  411. var m = $('#month').val();
  412. var y = $('#year').val();
  413. @this.show(m, y);
  414. });
  415. $(document).on("click", ".exportYear", function () {
  416. var y = $('#year').val();
  417. @this.exportYear(y);
  418. });
  419. </script>
  420. @endpush