records_in_out.blade.php 22 KB

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