records_in_out.blade.php 23 KB

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