records.blade.php 20 KB

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