records_in_out.blade.php 24 KB

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