records_in_out.blade.php 23 KB

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