records_in_out.blade.php 22 KB

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