records_in_out.blade.php 23 KB

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