Old UniVate Website

search-results.blade.php 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. @extends('master')
  2. @section('title', 'Search Results')
  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. <form id="mainForm" method="POST" action="/search-admin-timeshares" accept-charset="UTF-8" enctype="multipart/form-data">
  104. @csrf
  105. <div class="form-row">
  106. <div class="col-md-3">
  107. <label>Resort name</label>
  108. <select class="form-control" id="resort" name="resort">
  109. <option value="select">Please Select</option>
  110. @foreach($resorts as $resort)
  111. <option value="{{ $resort->resort }}" {{ old('resort') == $resort->resort ? 'selected' : '' }}>{{ $resort->resort }}</option>
  112. @endforeach
  113. </select>
  114. </div>
  115. <div class="col-md-3">
  116. <label>Status</label>
  117. <select class="form-control" id="status" name="status">
  118. <option value="select">Select</option>
  119. <option value="0">Unpublished Weeks</option>
  120. <option value="1">Published Weeks</option>
  121. </select>
  122. </div>
  123. <div class="col-md-3">
  124. <label>Season</label>
  125. <select class="form-control" name="season">
  126. <option value="select"><span style="color:white;">Season</span></option>
  127. <option value="Peak" {{ old('season') == 'Peak' ? 'selected' : '' }}>Peak</option>
  128. <option value="Peak 1" {{ old('season') == 'Peak 1' ? 'selected' : '' }}>Peak 1</option>
  129. <option value="Peak 2" {{ old('season') == 'Peak 2' ? 'selected' : '' }}>Peak 2</option>
  130. <option value="Peak 3" {{ old('season') == 'Peak 3' ? 'selected' : '' }}>Peak 3</option>
  131. <option value="Peak 4" {{ old('season') == 'Peak 4' ? 'selected' : '' }}>Peak 4</option>
  132. <option value="Red" {{ old('season') == 'Red' ? 'selected' : '' }}>Red</option>
  133. <option value="White" {{ old('season') == 'White' ? 'selected' : '' }}>White</option>
  134. <option value="Blue" {{ old('season') == 'Blue' ? 'selected' : '' }}>Blue</option>
  135. <option value="Flexi" {{ old('season') == 'Flexi' ? 'selected' : '' }}>Flexi</option>
  136. </select>
  137. </div>
  138. <div class="col-md-3">
  139. <button class="btn btn-blue" style="margin-top: 2rem;" type="submit">
  140. FILTER
  141. </button>
  142. </form>
  143. <a class="btn btn-blue" style="margin-top: 2rem;" href="/admin">SHOW ALL</a>
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. <div class="row">
  149. <div class="col-md-10 offset-md-1 table-responsive">
  150. <table class="table table-bordered table-hover table-striped">
  151. <thead>
  152. <tr>
  153. <th>Owner</th>
  154. <th>Agent</th>
  155. <th>Resort</th>
  156. <th>Week</th>
  157. <th>Module</th>
  158. <th>Unit</th>
  159. <th>Beds</th>
  160. <th>Season</th>
  161. <th>Region</th>
  162. <th>Amount</th>
  163. <th>Submitted</th>
  164. <th>Publish</th>
  165. <th>Status</th>
  166. <th>Edit</th>
  167. <th>Delete</th>
  168. </tr>
  169. </thead>
  170. <tbody>
  171. @foreach($timeshares as $timeshare)
  172. <tr>
  173. <td>{{ $timeshare->owner }}</td>
  174. <th>{{ $timeshare->agent }}</th>
  175. <td>{{ $timeshare->resort }}</td>
  176. <td>{{ $timeshare->week }}</td>
  177. <td>{{ $timeshare->module }}</td>
  178. <td>{{ $timeshare->unit }}</td>
  179. <td>{{ $timeshare->bedrooms }}</td>
  180. <td>{{ ucfirst(trans($timeshare->season)) }}</td>
  181. <td>{{ ucfirst(trans($timeshare->region)) }}</td>
  182. <td>R {{ $timeshare->price }}</td>
  183. <td>{{ $timeshare->created_at }}</td>
  184. @if($timeshare->published==1)
  185. <td class="text-center">
  186. <a href="/publishTimeshare/{{ $timeshare->id }}">
  187. <i class="fas fa-cloud-upload-alt fa-2x text-success"></i>
  188. </a>
  189. </td>
  190. @else
  191. <td class="text-center">
  192. <a href="/publishTimeshare/{{ $timeshare->id }}">
  193. <i class="fas fa-cloud-upload-alt fa-2x text-danger"></i>
  194. </a>
  195. </td>
  196. @endif
  197. <td>{{ $timeshare->status }}</td>
  198. <td class="text-center">
  199. <a href="/edit-timeshare/{{ $timeshare->id }}">
  200. <i class="far fa-edit blue-text fa-2x"></i>
  201. </a>
  202. </td>
  203. <td class="text-center">
  204. <a onclick="return Conform_Delete()" href="/deleteTimeshare/{{ $timeshare->id }}">
  205. <i class="fas fa-times fa-2x text-danger"></i>
  206. </a>
  207. </td>
  208. </tr>
  209. @endforeach
  210. </tbody>
  211. </table>
  212. </div>
  213. <div class="col-md-6 offset-md-3 mb-4 d-flex justify-content-center">
  214. </div>
  215. </div>
  216. </div>
  217. @stop