records.blade.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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. </style>
  297. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  298. <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  299. <script src="/assets/js/aCollapTable.js"></script>
  300. @endpush
  301. @push('scripts')
  302. <script>
  303. Livewire.on('load-table', () => {
  304. load();
  305. });
  306. function load()
  307. {
  308. $(document).ready(function(){
  309. $(document).on("keypress", $('.filterCausals'), 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. $('.filterCausals').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  319. $('.filterCausals').on('change', function (e) {
  320. var data = $('.filterCausals').select2("val");
  321. @this.set('filterCausals', data);
  322. });
  323. $('.filterCausals').on('select2:open', function (e) {
  324. setTimeout(() => {
  325. $(".select2-results__option").each(function(){
  326. var txt = $(this).html();
  327. var count = (txt.match(/-/g) || []).length;
  328. $(this).addClass('paddingLeftSelect' + count);
  329. });
  330. }, 100);
  331. });
  332. $('.filterMember').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  333. $('.filterMember').on('change', function (e) {
  334. var data = $('.filterMember').select2("val");
  335. @this.set('filterMember', data);
  336. });
  337. });
  338. }
  339. Livewire.on('load-select', () => {
  340. $('.filterCausals').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  341. $('.filterCausals').on('change', function (e) {
  342. var data = $('.filterCausals').select2("val");
  343. @this.set('filterCausals', data);
  344. });
  345. $('.filterMember').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
  346. $('.filterMember').on('change', function (e) {
  347. var data = $('.filterMember').select2("val");
  348. @this.set('filterMember', data);
  349. });
  350. setMaxWidth();
  351. setMaxHeight();
  352. });
  353. load();
  354. </script>
  355. @endpush
  356. @push('scripts')
  357. <script>
  358. function printData()
  359. {
  360. var divToPrint=document.getElementById("tablesaw-350");
  361. newWin= window.open("");
  362. var htmlToPrint = '' +
  363. '<style type="text/css">' +
  364. 'table th, table td {' +
  365. 'border:1px solid #000;' +
  366. 'padding:0.5em;' +
  367. '}' +
  368. '</style>';
  369. htmlToPrint += divToPrint.outerHTML;
  370. newWin.document.write(htmlToPrint);
  371. newWin.document.close();
  372. newWin.print();
  373. newWin.close();
  374. }
  375. document.querySelector("#print").addEventListener("click", function(){
  376. printData();
  377. });
  378. $( document ).ready( function(){
  379. setMaxWidth();
  380. setMaxHeight();
  381. $( window ).bind( "resize", setMaxWidth ); //Remove this if it's not needed. It will react when window changes size.
  382. $( window ).bind( "resize", setMaxHeight );
  383. $(".open-filter").click(function(){
  384. setMaxWidth();
  385. setMaxHeight();
  386. });
  387. });
  388. function setMaxWidth() {
  389. $("#resume-table").width( Math.round( $(window ).width() - size ) ) ;
  390. }
  391. function setMaxHeight() {
  392. $("#resume-table").height( Math.round( $(window ).height() - 300 ) ) ;
  393. }
  394. let mybuttonBottom = document.getElementById("btn-back-to-bottom");
  395. let mybutton = document.getElementById("btn-back-to-top");
  396. // When the user scrolls down 20px from the top of the document, show the button
  397. window.onscroll = function () {
  398. scrollFunction();
  399. };
  400. const element = document.getElementById('resume-table');
  401. element.onscroll = (e)=>{
  402. scrollFunction();
  403. };
  404. /*if (element.scrollTop < lastScrollTop){
  405. // upscroll
  406. return;
  407. }
  408. lastScrollTop = element.scrollTop <= 0 ? 0 : element.scrollTop;
  409. if (element.scrollTop + element.offsetHeight>= element.scrollHeight ){
  410. console.log("End");
  411. }
  412. }*/
  413. function scrollFunction() {
  414. if (
  415. element.scrollTop > 20
  416. ) {
  417. mybutton.style.display = "block";
  418. mybuttonBottom.style.display = "block";
  419. } else {
  420. mybutton.style.display = "none";
  421. mybuttonBottom.style.display = "none";
  422. }
  423. }
  424. function scrollFunctionOld() {
  425. if (
  426. document.body.scrollTop > 20 ||
  427. document.documentElement.scrollTop > 20
  428. ) {
  429. mybutton.style.display = "block";
  430. mybuttonBottom.style.display = "block";
  431. } else {
  432. mybutton.style.display = "none";
  433. mybuttonBottom.style.display = "none";
  434. }
  435. }
  436. // When the user clicks on the button, scroll to the top of the document
  437. mybutton.addEventListener("click", backToTop);
  438. mybuttonBottom.addEventListener("click", backToBottom);
  439. function backToTop() {
  440. $('#resume-table').scrollTop(0);
  441. /*document.body.scrollTop = 0;
  442. document.documentElement.scrollTop = 0;*/
  443. }
  444. function backToBottom() {
  445. $('#resume-table').scrollTop($('#resume-table')[0].scrollHeight);
  446. //window.scrollTo(0, document.body.scrollHeight);
  447. }
  448. function reset()
  449. {
  450. $('.filterMember').val('');
  451. $('.filterMember').trigger('change');
  452. $('.filterCausals').val('');
  453. $('.filterCausals').trigger('change');
  454. var today = new Date().toISOString().split('T')[0];
  455. window.livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id')).set('fromDate', today);
  456. window.livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id')).set('toDate', today);
  457. }
  458. </script>
  459. @endpush