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.

commercial-admin.blade.php 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. @extends('master')
  2. @section('title', 'Admin')
  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 commercial property?");
  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-commercial-admin" accept-charset="UTF-8" enctype="multipart/form-data">
  104. @csrf
  105. <div class="form-row">
  106. <div class="col-md-5 offset-md-3">
  107. <input class="form-control" name="search" type="text">
  108. </div>
  109. <div class="col-md-2">
  110. <button class="btn btn-blue" type="submit">
  111. <i class="fas fa-search-plus"></i>
  112. SEARCH
  113. </button>
  114. </div>
  115. </div>
  116. </form>
  117. </div>
  118. </div>
  119. <div class="row">
  120. <div class="col-md-10 offset-md-1 table-responsive">
  121. <table class="table table-bordered table-hover table-striped">
  122. <thead>
  123. <tr>
  124. <th>Owner</th>
  125. <th>Reference</th>
  126. <th>Property</th>
  127. <th>Unit</th>
  128. <th>Size</th>
  129. <th>Price ex VAT</th>
  130. <th>Region</th>
  131. <th>Town</th>
  132. <th>Suburb</th>
  133. <th>Status</th>
  134. <th>Type</th>
  135. <th>Published</th>
  136. <th>Edit</th>
  137. <th>Delete</th>
  138. </tr>
  139. </thead>
  140. <tbody>
  141. @foreach($commercials as $commercial)
  142. <tr>
  143. <td>{{ $commercial->contact_person }}</td>
  144. <td>{{ $commercial->ref }}</td>
  145. <td>{{ $commercial->name }}</td>
  146. <td>{{ $commercial->unit }}</td>
  147. <td>{{ $commercial->size }}</td>
  148. <td>{{ number_format($commercial->price, 2) }}</td>
  149. <td>{{ ucfirst(trans($commercial->region)) }}</td>
  150. <td>{{ $commercial->town }}</td>
  151. <td>{{ $commercial->surburb }}</td>
  152. <td>{{ $commercial->status2 }}</td>
  153. <td>{{ $commercial->propertType }}</td>
  154. @if($commercial->published==1)
  155. <td class="text-center">
  156. <a href="/publishCommercial/{{ $commercial->id }}">
  157. <i class="fas fa-cloud-upload-alt fa-2x text-success"></i>
  158. </a>
  159. </td>
  160. @else
  161. <td class="text-center">
  162. <a href="/publishCommercial/{{ $commercial->id }}">
  163. <i class="fas fa-cloud-upload-alt fa-2x text-danger"></i>
  164. </a>
  165. </td>
  166. @endif
  167. <td class="text-center">
  168. <a href="/edit-commercial/{{ $commercial->id }}">
  169. <i class="far fa-edit blue-text fa-2x"></i>
  170. </a>
  171. </td>
  172. <td class="text-center">
  173. <a onclick="return Conform_Delete()" href="/deleteCommercial/{{ $commercial->id }}">
  174. <i class="fas fa-times fa-2x text-danger"></i>
  175. </a>
  176. </td>
  177. </tr>
  178. @endforeach
  179. </tbody>
  180. </table>
  181. </div>
  182. <div class="col-md-6 offset-md-3 mb-4 d-flex justify-content-center">
  183. <?php echo $commercials->links(); ?>
  184. </div>
  185. </div>
  186. </div>
  187. @stop