Old UniVate Website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

log-search-results.blade.php 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. @extends('master')
  2. @section('title', 'Timeshare change logs')
  3. @section('description', '')
  4. @section('keywords', '')
  5. @section('content')
  6. <script>
  7. let rt = {};
  8. rt.adjustCount = 0;
  9. rt.firstRowValues = [];
  10. rt.MOBILE_SCREEN_WIDTH = 480;
  11. function reset() {
  12. rt.tableContainer = document.querySelector(".table-container");
  13. rt.initialState = rt.tableContainer.innerHTML;
  14. rt.table = document.querySelector(".responsive-table > tbody");
  15. rt.tableTitle = document.querySelector(".table-title");
  16. rt.firstRow = document.querySelector(".responsive-table tr:first-of-type");
  17. rt.firstRowValues = [];
  18. }
  19. reset();
  20. function getFirstRowValues() {
  21. for (let cell = 0; cell < rt.firstRow.children.length; cell++) {
  22. rt.firstRowValues.push(rt.firstRow.children[cell].textContent);
  23. }
  24. }
  25. function concatFirstRowValuesWithMainValues() {
  26. for (let row = 1; row < rt.table.children.length; row++) {
  27. for (let cell = 0; cell < rt.table.children[row].children.length; cell++) {
  28. rt.table.children[row].children[cell].textContent =
  29. rt.firstRowValues[cell] +
  30. ": " +
  31. rt.table.children[row].children[cell].textContent;
  32. }
  33. }
  34. }
  35. function consolidateCells() {
  36. for (let row = 1; row < rt.table.children.length; row++) {
  37. let rowValues = [];
  38. for (let cell = 0; cell < rt.table.children[row].children.length; cell++) {
  39. // Saving row values.
  40. rowValues.push(rt.table.children[row].children[cell].textContent);
  41. }
  42. rt.table.children[row].children[0].innerHTML = "";
  43. for (let value = 0; value < rowValues.length; value++) {
  44. // Inserting row values into first cell.
  45. let newValueFragment = document.createElement("div");
  46. let newValueFragmentContent = document.createTextNode(rowValues[value]);
  47. newValueFragment.appendChild(newValueFragmentContent);
  48. rt.table.children[row].children[0].appendChild(newValueFragment);
  49. }
  50. }
  51. }
  52. function removeExtraCells() {
  53. for (let row = 1; row < rt.table.children.length; row++) {
  54. for (let cell = 0; cell < rt.table.children[row].children.length; cell++) {
  55. // rt.table.children[row].children[cell].remove();
  56. }
  57. while (rt.table.children[row].children.length > 1) {
  58. rt.table.children[row].lastElementChild.remove();
  59. }
  60. }
  61. }
  62. function addTitleToTable() {
  63. rt.table.children[0].innerHTML = "<th>" + rt.tableTitle.textContent + "</th>";
  64. rt.tableTitle.remove();
  65. }
  66. function adjustTable() {
  67. rt.table.parentElement.classList.add("mobile");
  68. getFirstRowValues();
  69. concatFirstRowValuesWithMainValues();
  70. consolidateCells();
  71. removeExtraCells();
  72. addTitleToTable();
  73. }
  74. function restoreTable() {
  75. rt.tableContainer.innerHTML = rt.initialState;
  76. reset(); // Rebinding newly drawn elements.
  77. rt.table.parentElement.classList.remove("mobile");
  78. }
  79. document.addEventListener("DOMContentLoaded", () => {
  80. if (window.innerWidth <= rt.MOBILE_SCREEN_WIDTH) {
  81. rt.adjustCount++;
  82. adjustTable();
  83. }
  84. });
  85. window.addEventListener("resize", () => {
  86. if (window.innerWidth < rt.MOBILE_SCREEN_WIDTH) {
  87. if (!rt.adjustCount) {
  88. rt.adjustCount++;
  89. adjustTable();
  90. }
  91. } else {
  92. restoreTable();
  93. rt.adjustCount = 0;
  94. }
  95. });
  96. function Conform_Delete() {
  97. return confirm("Are you sure want to delete this timeshare?");
  98. }
  99. </script>
  100. <div class="container-fluid">
  101. <div class="row mb-4 mt-5">
  102. <div class="col-md-10 offset-md-1">
  103. <h1 style="text-align: center;">Timeshare change logs</h1><br>
  104. <form id="mainForm" method="POST" action="/search-log" accept-charset="UTF-8" enctype="multipart/form-data">
  105. @csrf
  106. <div class="form-row">
  107. <div class="col-md-5 offset-md-3">
  108. <input class="form-control" name="search" placeholder="serach by username, resort, unit or module" type="text">
  109. </div>
  110. <div class="col-md-2">
  111. <button class="btn btn-blue" type="submit">
  112. <i class="fas fa-search-plus"></i>
  113. SEARCH
  114. </button>
  115. </div>
  116. </div>
  117. </form>
  118. <hr>
  119. <a style="margin-left:auto;margin-right:auto;display:block;width: 15%;" class="btn btn-blue" href="/timeshare-change-logs">All logs</a>
  120. </div>
  121. </div>
  122. <div class="row">
  123. <div class="col-md-10 offset-md-1 table-responsive">
  124. <table class="table table-bordered table-hover table-striped">
  125. <thead>
  126. <tr>
  127. <th>Username</th>
  128. <th>Resort</th>
  129. <th>Module</th>
  130. <th>Unit</th>
  131. <th>Change</th>
  132. <th>Timeshare</th>
  133. <th>Date</th>
  134. </tr>
  135. </thead>
  136. <tbody>
  137. @foreach($logs as $log)
  138. <tr>
  139. <td><a href="/view-user/{{ $log->user_id }}">{{ $log->name }}</i></td>
  140. <td>{{ $log->resort }}</td>
  141. <td>{{ $log->module }}</td>
  142. <td>{{ $log->unit }}</td>
  143. <td>{{ $log->change }}</td>
  144. <td><a href="/view-timeshare/{{ $log->timeshare_id }}"><i class="fa fa-file" aria-hidden="true"> View full details</i></td>
  145. <td>{{ \Carbon\Carbon::parse($log->created_at)->format('jS F Y') }}</td>
  146. </tr>
  147. @endforeach
  148. </tbody>
  149. </table>
  150. </div>
  151. </div>
  152. </div>
  153. @stop