records.blade.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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">Prima nota</h2>
  6. </div>
  7. </header>
  8. <section id="subheader" class="">
  9. <!--
  10. <form action="" class="group--action d-flex align-items-center">
  11. <select class="form-select form-select-lg me-1" aria-label=".form-select-lg example">
  12. <option selected>Open this select menu</option>
  13. <option value="1">One</option>
  14. <option value="2">Two</option>
  15. <option value="3">Three</option>
  16. </select>
  17. <button type="submit" class="btn--ui">applica</button>
  18. </form>
  19. -->
  20. <div class="row g-3">
  21. <div class="col-md-2">
  22. Utente
  23. <select name="search_member_id" class="form-select filterMember" wire:model="filterMember">
  24. <option value="">--Seleziona--
  25. @foreach($members as $member)
  26. <option value="{{$member->id}}">{{$member->last_name}} {{$member->first_name}}
  27. @endforeach
  28. </select>
  29. </div>
  30. <div class="col-md-4">
  31. Causale
  32. <select name="search_causal_id[]" class="form-select filterCausals me-2" multiple="multiple" wire:model="filterCausals">
  33. @foreach($causals as $causal)
  34. <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
  35. @endforeach
  36. </select>
  37. </div>
  38. <div class="col-md-2">
  39. <span class="date_span">Dal</span><input type="date" wire:model="fromDate" class="form-control">
  40. </div>
  41. <div class="col-md-2">
  42. <span class="date_span ms-2">al</span><input type="date" wire:model="toDate" class="form-control">
  43. </div>
  44. <div class="col-md-2">
  45. <div class="prima--nota_buttons ms-auto " style="float:right; margin-top:25px;">
  46. <button class="btn--ui lightGrey reset reset" style="margin-left:5px;color:#10172A;" onclick="reset()">RESET</button>
  47. </div>
  48. </div>
  49. </div>
  50. <div style="float:left; margin-top:10px; margin-bottom:10px;">
  51. <div class="dropdown">
  52. <button class="btn--ui_outline light dropdown-toggle" type="button" id="exportDropdown" data-bs-toggle="dropdown" aria-expanded="false"
  53. style="color:#10172A;">
  54. ESPORTA
  55. </button>
  56. <ul class="dropdown-menu" aria-labelledby="exportDropdown">
  57. <li><a class="dropdown-item" href="#" wire:click="export()">Excel</a></li>
  58. <li><a class="dropdown-item" href="#" id="print">Stampa</a></li>
  59. </ul>
  60. </div>
  61. </div>
  62. </section>
  63. <section id="resume-table" class="scrollTable">
  64. <!--
  65. <canvas id="recordChart"></canvas>
  66. -->
  67. <table class="table tablesaw tableHead tablesaw-stack" id="tablesaw-350" width="100%">
  68. <thead>
  69. <tr>
  70. <th scope="col">Data</th>
  71. <th scope="col" style="border-left:3px solid white;">Causale</th>
  72. <th scope="col" style="border-left:3px solid white;">Dettaglio Causale</th>
  73. <th scope="col" style="border-left:3px solid white;">Stato</th>
  74. <th scope="col" style="border-left:3px solid white;">Nominativo</th>
  75. @foreach($payments as $p)
  76. <th colspan="2" scope="col" style="text-align:center; border-left:3px solid white;">{{$p->name}}</th>
  77. @endforeach
  78. </tr>
  79. <tr>
  80. <th scope="col"></th>
  81. <th scope="col" style="border-left:3px solid white;"></th>
  82. <th scope="col" style="border-left:3px solid white;"></th>
  83. <th scope="col" style="border-left:3px solid white;"></th>
  84. <th scope="col" style="border-left:3px solid white;"></th>
  85. @foreach($payments as $p)
  86. <th scope="col" style="text-align:right; border-left:3px solid white;">Entrate</th>
  87. <th scope="col" style="text-align:right">Uscite</th>
  88. @endforeach
  89. </tr>
  90. </thead>
  91. <tbody id="checkall-target">
  92. @php
  93. $count = 0;
  94. @endphp
  95. @foreach($records as $causal => $record)
  96. <tr>
  97. @php
  98. $check = strpos($causal, "$") ? explode("$", $causal)[1] : $causal;
  99. list($d, $c, $n, $det, $del) = explode("§", $check);
  100. @endphp
  101. <td style="background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{date("d/m/Y", strtotime($d))}}</td>
  102. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$c}}</td>
  103. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$det}}</td>
  104. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
  105. @if($del == 'DELETED')
  106. <span style='color:red'>Annullata</span>
  107. @endif
  108. </td>
  109. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$n}}</td>
  110. @foreach($payments as $p)
  111. @if(isset($record[$p->name]))
  112. <td style="text-align:right; border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
  113. @if(isset($record[$p->name]["IN"]))
  114. <span class="tablesaw-cell-content " style="color:green">{{formatPrice($record[$p->name]["IN"])}}</span>
  115. @endif
  116. </td>
  117. <td style="text-align:right;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
  118. @if(isset($record[$p->name]["OUT"]))
  119. <span class="tablesaw-cell-content " style="color:red">{{formatPrice($record[$p->name]["OUT"])}}</span>
  120. @endif
  121. </td>
  122. @else
  123. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}"></td>
  124. <td style="background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}"></td>
  125. @endif
  126. @endforeach
  127. </tr>
  128. @php
  129. $count++;
  130. @endphp
  131. @endforeach
  132. </tbody>
  133. <tfoot>
  134. <tr>
  135. <td></td>
  136. <td></td>
  137. <td></td>
  138. <td></td>
  139. <td><b>Totale</b></td>
  140. @foreach($payments as $p)
  141. @if(isset($totals[$p->name]))
  142. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:green; font-size:18px;"><b>{{formatPrice($totals[$p->name]["IN"])}}</b></span></td>
  143. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:red; font-size:18px;"><b>{{formatPrice($totals[$p->name]["OUT"])}}</b></span></td>
  144. @else
  145. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:green; font-size:18px;"><b>{{formatPrice(0)}}</b></span></td>
  146. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:red; font-size:18px;"><b>{{formatPrice(0)}}</b></span></td>
  147. @endif
  148. @endforeach
  149. </tr>
  150. <tr style="display:none">
  151. <td></td>
  152. <td><b>Differenza</b></td>
  153. @foreach($payments as $p)
  154. @if(isset($totals[$p->name]))
  155. @php
  156. $diff = $totals[$p->name]["IN"] - $totals[$p->name]["OUT"];
  157. @endphp
  158. @if($diff < 0)
  159. <td></td>
  160. @endif
  161. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:{{$diff > 0 ? 'green' : 'red'}}; font-size:18px;"><b>{{formatPrice($diff)}}</b></span></td>
  162. @if($diff > 0)
  163. <td></td>
  164. @endif
  165. @else
  166. <td colspan="2" style="text-align:right"><b>{{formatPrice(0)}}</b></td>
  167. @endif
  168. @endforeach
  169. </tr>
  170. </tfoot>
  171. </table>
  172. <!--
  173. <div class="paginator d-flex justify-content-center">
  174. <nav aria-label="Page navigation example">
  175. <ul class="pagination">
  176. <li class="page-item">
  177. <a class="page-link" href="#" aria-label="Previous">
  178. <span aria-hidden="true"></span>
  179. </a>
  180. </li>
  181. <li class="page-item"><a class="page-link" href="#">1</a></li>
  182. <li class="page-item"><a class="page-link" href="#">2</a></li>
  183. <li class="page-item"><a class="page-link" href="#">3</a></li>
  184. <li class="page-item"><a class="page-link" href="#">3</a></li>
  185. <li class="page-item"><span class="more-page">...</span></li>
  186. <li class="page-item">
  187. <a class="page-link" href="#" aria-label="Next">
  188. <span aria-hidden="true"></span>
  189. </a>
  190. </li>
  191. </ul>
  192. </nav>
  193. </div>
  194. -->
  195. <button type="button" class="btn btn-floating btn-lg" id="btn-back-to-bottom" ><i class="fas fa-arrow-down"></i></button>
  196. <button type="button" class="btn btn-floating btn-lg" id="btn-back-to-top" ><i class="fas fa-arrow-up"></i></button>
  197. </section>
  198. </div>
  199. @push('scripts')
  200. <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
  201. @endpush
  202. @push('scripts')
  203. <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  204. <style>
  205. #btn-back-to-top {
  206. background-color: #0C6197;
  207. color: white;
  208. position: fixed;
  209. bottom: 20px;
  210. right: 20px;
  211. display: none;
  212. }
  213. #btn-back-to-bottom {
  214. background-color: #0C6197;
  215. color: white;
  216. position: fixed;
  217. top: 120px;
  218. right: 20px;
  219. z-index: 9999;
  220. display: none;
  221. }
  222. .scrollTable {
  223. margin-left: 0px ;
  224. margin-right: 0px ;
  225. padding: 15px;
  226. /*max-width: 800px !important;*/
  227. overflow-x: auto;
  228. overflow-y: auto;
  229. white-space: nowrap;
  230. border: 1px solid #ddd;
  231. }
  232. ::-webkit-scrollbar-thumb {
  233. background: #e4e4e4;
  234. border-radius: 10px;
  235. }
  236. table thead {
  237. /* Important */
  238. position: sticky;
  239. z-index: 100;
  240. top: 0;
  241. }
  242. .select2-container--default .select2-selection--single{
  243. background-color: #E9F0F5;
  244. border: 0.0625rem solid #DFE5EB;
  245. font-size: 0.75rem;
  246. }
  247. .select2-selection
  248. {
  249. height: 38px !important;
  250. }
  251. .select2-selection__rendered
  252. {
  253. padding-top:3px;
  254. }
  255. .select2 {
  256. width:100% !important;
  257. }
  258. .i{
  259. font-size:16px;
  260. font-weight:bold;
  261. }
  262. .cellBorder
  263. {
  264. border-left: 1px solid grey;
  265. }
  266. .select2-selection--multiple{
  267. overflow: hidden !important;
  268. height: auto !important;
  269. }
  270. .select2-container {
  271. box-sizing: border-box;
  272. display: inline-block;
  273. margin: 0;
  274. position: relative;
  275. vertical-align: middle;
  276. }
  277. .select2-container .select2-selection--single {
  278. box-sizing: border-box;
  279. cursor: pointer;
  280. display: block;
  281. height: 38px;
  282. user-select: none;
  283. -webkit-user-select: none;
  284. }
  285. .select2-container .select2-selection--single .select2-selection__rendered {
  286. display: block;
  287. padding-left: 8px;
  288. padding-right: 20px;
  289. overflow: hidden;
  290. text-overflow: ellipsis;
  291. white-space: nowrap;
  292. }
  293. button#exportDropdown.btn--ui_outline.light {
  294. font-weight: normal !important;
  295. }
  296. .btn--ui_outline.light.dropdown-toggle:active,
  297. .btn--ui_outline.light.dropdown-toggle:focus,
  298. .btn--ui_outline.light.dropdown-toggle.show {
  299. background-color: transparent !important;
  300. color: #10172A !important;
  301. box-shadow: none !important;
  302. }
  303. .btn--ui_outline.light.dropdown-toggle:hover {
  304. background-color: transparent !important;
  305. color: #10172A !important;
  306. }
  307. </style>
  308. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  309. <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  310. <script src="/assets/js/aCollapTable.js"></script>
  311. @endpush
  312. @push('scripts')
  313. <script>
  314. Livewire.on('load-table', () => {
  315. load();
  316. });
  317. function load()
  318. {
  319. $(document).ready(function(){
  320. $(document).on("keypress", $('.filterCausals'), function (e) {
  321. setTimeout(() => {
  322. $(".select2-results__option").each(function(){
  323. var txt = $(this).html();
  324. var count = (txt.match(/-/g) || []).length;
  325. $(this).addClass('paddingLeftSelect' + count);
  326. });
  327. }, 100);
  328. });
  329. $('.filterCausals').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  330. $('.filterCausals').on('change', function (e) {
  331. var data = $('.filterCausals').select2("val");
  332. @this.set('filterCausals', data);
  333. });
  334. $('.filterCausals').on('select2:open', function (e) {
  335. setTimeout(() => {
  336. $(".select2-results__option").each(function(){
  337. var txt = $(this).html();
  338. var count = (txt.match(/-/g) || []).length;
  339. $(this).addClass('paddingLeftSelect' + count);
  340. });
  341. }, 100);
  342. });
  343. $('.filterMember').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  344. $('.filterMember').on('change', function (e) {
  345. var data = $('.filterMember').select2("val");
  346. @this.set('filterMember', data);
  347. });
  348. });
  349. }
  350. Livewire.on('load-select', () => {
  351. $('.filterCausals').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  352. $('.filterCausals').on('change', function (e) {
  353. var data = $('.filterCausals').select2("val");
  354. @this.set('filterCausals', data);
  355. });
  356. $('.filterMember').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  357. $('.filterMember').on('change', function (e) {
  358. var data = $('.filterMember').select2("val");
  359. @this.set('filterMember', data);
  360. });
  361. setMaxWidth();
  362. setMaxHeight();
  363. });
  364. load();
  365. </script>
  366. @endpush
  367. @push('scripts')
  368. <script>
  369. function printData()
  370. {
  371. var divToPrint=document.getElementById("tablesaw-350");
  372. newWin= window.open("");
  373. var htmlToPrint = '' +
  374. '<style type="text/css">' +
  375. 'table th, table td {' +
  376. 'border:1px solid #000;' +
  377. 'padding:0.5em;' +
  378. '}' +
  379. '</style>';
  380. htmlToPrint += divToPrint.outerHTML;
  381. newWin.document.write(htmlToPrint);
  382. newWin.document.close();
  383. newWin.print();
  384. newWin.close();
  385. }
  386. document.querySelector("#print").addEventListener("click", function(){
  387. printData();
  388. });
  389. $( document ).ready( function(){
  390. setMaxWidth();
  391. setMaxHeight();
  392. $( window ).bind( "resize", setMaxWidth ); //Remove this if it's not needed. It will react when window changes size.
  393. $( window ).bind( "resize", setMaxHeight );
  394. $(".open-filter").click(function(){
  395. setMaxWidth();
  396. setMaxHeight();
  397. });
  398. });
  399. function setMaxWidth() {
  400. $("#resume-table").width( Math.round( $(window ).width() - size ) ) ;
  401. }
  402. function setMaxHeight() {
  403. $("#resume-table").height( Math.round( $(window ).height() - 300 ) ) ;
  404. }
  405. let mybuttonBottom = document.getElementById("btn-back-to-bottom");
  406. let mybutton = document.getElementById("btn-back-to-top");
  407. // When the user scrolls down 20px from the top of the document, show the button
  408. window.onscroll = function () {
  409. scrollFunction();
  410. };
  411. const element = document.getElementById('resume-table');
  412. element.onscroll = (e)=>{
  413. scrollFunction();
  414. };
  415. /*if (element.scrollTop < lastScrollTop){
  416. // upscroll
  417. return;
  418. }
  419. lastScrollTop = element.scrollTop <= 0 ? 0 : element.scrollTop;
  420. if (element.scrollTop + element.offsetHeight>= element.scrollHeight ){
  421. console.log("End");
  422. }
  423. }*/
  424. function scrollFunction() {
  425. if (
  426. element.scrollTop > 20
  427. ) {
  428. mybutton.style.display = "block";
  429. mybuttonBottom.style.display = "block";
  430. } else {
  431. mybutton.style.display = "none";
  432. mybuttonBottom.style.display = "none";
  433. }
  434. }
  435. function scrollFunctionOld() {
  436. if (
  437. document.body.scrollTop > 20 ||
  438. document.documentElement.scrollTop > 20
  439. ) {
  440. mybutton.style.display = "block";
  441. mybuttonBottom.style.display = "block";
  442. } else {
  443. mybutton.style.display = "none";
  444. mybuttonBottom.style.display = "none";
  445. }
  446. }
  447. // When the user clicks on the button, scroll to the top of the document
  448. mybutton.addEventListener("click", backToTop);
  449. mybuttonBottom.addEventListener("click", backToBottom);
  450. function backToTop() {
  451. $('#resume-table').scrollTop(0);
  452. /*document.body.scrollTop = 0;
  453. document.documentElement.scrollTop = 0;*/
  454. }
  455. function backToBottom() {
  456. $('#resume-table').scrollTop($('#resume-table')[0].scrollHeight);
  457. //window.scrollTo(0, document.body.scrollHeight);
  458. }
  459. function reset()
  460. {
  461. $('.filterMember').val('');
  462. $('.filterMember').trigger('change');
  463. $('.filterCausals').val('');
  464. $('.filterCausals').trigger('change');
  465. var today = new Date().toISOString().split('T')[0];
  466. window.livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id')).set('fromDate', today);
  467. window.livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id')).set('toDate', today);
  468. }
  469. </script>
  470. @endpush