sise.blade.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. @extends('views.layouts.master')
  2. @section('content')
  3. @php $today = date('Y-m-d'); @endphp
  4. <div class="sub golf">
  5. <div class="container">
  6. <div class="navi">
  7. <a href="/"><i class="fa-solid fa-house"></i> 홈</a> > {{ $title_dir }} > {{ $title }}
  8. </div>
  9. <div class="title">
  10. <h2> {{ $title }} </h2>
  11. </div>
  12. </div>
  13. <!-- 회원권 검색 시작 -->
  14. <div class="search_ticket">
  15. <div class="container">
  16. <label>회원권 검색</label>
  17. <input type="text" id="membership-name" placeholder="회원권명">
  18. <!-- <input type="date" id="date" value="{{$today}}"> -->
  19. <button type="button" class="btn" onclick="searchMemberShip()">검색</button>
  20. </div>
  21. </div>
  22. <!--// 회원권 검색 끝 -->
  23. <!-- 시세 시작 -->
  24. <div class="quote">
  25. <div class="container">
  26. <ul class="tabs nav nav-tabs">
  27. <li class="{{ request('area', 'all') === 'all' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, 'all']) }}">전체</a></li>
  28. @if($siseType === 'golf')
  29. <li class="{{ request('area', 'all') === '100' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '100']) }}">수도권/강원/충청권</a></li>
  30. <li class="{{ request('area', 'all') === '200' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '200']) }}">영남/제주권</a></li>
  31. <li class="{{ request('area', 'all') === '300' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '300']) }}">호남권</a></li>
  32. @elseif($siseType === 'condo')
  33. <li class="{{ request('area', 'all') === '400' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '400']) }}">체인형콘도</a></li>
  34. <li class="{{ request('area', 'all') === '500' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '500']) }}">스키장콘도</a></li>
  35. @else
  36. <li class="{{ request('area', 'all') === '600' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '600']) }}">강남권</a></li>
  37. <li class="{{ request('area', 'all') === '700' ? 'active' : '' }}"><a href="{{ route('sise', [$siseType, '700']) }}">강북권</a></li>
  38. @endif
  39. </ul>
  40. <div class="tabs today">
  41. <input type="date" id="search_date" value="{{$today}}" autocomplete="off">
  42. </div>
  43. <div class="tab-content">
  44. <div class="tab-pane fade in active show">
  45. <div class="tb_res tb_vertical">
  46. <table cellspacing="0" cellpadding="0">
  47. <caption>단위: 만원</caption>
  48. <thead>
  49. <tr>
  50. <th>회원권명</th>
  51. <th>금일시세</th>
  52. <th>전일시세</th>
  53. <th>등락</th>
  54. <th>상담</th>
  55. </tr>
  56. </thead>
  57. <tbody id="sise-list">
  58. @forelse($siseItems['Page'] ?? [] as $sise)
  59. <tr>
  60. <td scope="row "data-label="{{ $sise['PostTitle'] }}"> {{ $sise['PostTitle'] }} </td>
  61. <td data-label="{{$sise['Pc3']}}"> {{ number_format($sise['Pc3']) }} </td>
  62. <td data-label="{{$sise['Pc4']}}"> {{ number_format($sise['Pc4']) }} </td>
  63. <td data-label="등락" class="{{ isset($sise['fluctuation']) && $sise['fluctuation'] > 0 ? 'up' : (isset($sise['fluctuation']) && $sise['fluctuation'] < 0 ? 'down' : '') }}">
  64. @if (isset($sise['fluctuation']) && $sise['fluctuation'] != 0)
  65. <i class="fa-solid {{ $sise['fluctuation'] > 0 ? 'fa-sort-up' : 'fa-sort-down' }}"></i>
  66. {{ number_format(abs($sise['fluctuation'])) }}
  67. @else
  68. {{ number_format(abs($sise['fluctuation'])) }}
  69. @endif
  70. </td>
  71. <td data-label="상담신청">
  72. <button type="button" class="btn consult-btn"
  73. onclick="window.location.href = '{{ route('contactus-custom', [$sise['Pc5'], $sise['PostTitle']]) }}'">상담신청
  74. </button>
  75. </td>
  76. </tr>
  77. @empty
  78. <tr>
  79. <td colspan="5">회원권이 존재하지 않습니다</td>
  80. </tr>
  81. @endforelse
  82. </tbody>
  83. </table>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. <!-- 페이지네이션 -->
  89. <div class="row">
  90. <div class="col-lg-12">
  91. <div class="bottom-paginate">
  92. {{ $siseItems['Page']->appends(['limit' => request('limit'), 'sort' => request('sort')])->links() }}
  93. </div>
  94. </div>
  95. </div>
  96. <!--// 페이지네이션 끝 -->
  97. </div>
  98. <!--// 시세 끝 -->
  99. </div>
  100. @push('js')
  101. <script>
  102. var filteredSiseList = [];
  103. $(document).ready(function() {
  104. var date = dateFormat(document.getElementById('search_date').value);
  105. filteredSiseList = searchDate(date);
  106. renderSiseList(filteredSiseList);
  107. if ($('div').hasClass('chatbot') == true) {
  108. $('.main-footer').addClass('chatbot');
  109. }
  110. });
  111. document.getElementById('search_date').addEventListener('change', function() {
  112. var date = dateFormat(document.getElementById('search_date').value);
  113. filteredSiseList = searchDate(date);
  114. renderSiseList(filteredSiseList);
  115. });
  116. // 회원권 검색
  117. function searchMemberShip() {
  118. var membershipName = document.getElementById('membership-name').value.toLowerCase();
  119. var date = dateFormat(document.getElementById('search_date').value);
  120. // console.log('date : ', date);
  121. if (!membershipName) {
  122. alert('회원권명을 입력해주세요.');
  123. return;
  124. }
  125. var filteredSiseList = siseList.filter(function(sise) {
  126. var postTitleMatch = sise['PostTitle'].toLowerCase().includes(membershipName);
  127. var dateMatch = date ? (sise['Pc6'] && sise['Pc6'] === date) : true;
  128. return postTitleMatch && dateMatch;
  129. });
  130. // console.log('filteredSiseList : ', filteredSiseList);
  131. renderSiseList(filteredSiseList);
  132. }
  133. // 동적으로 tbody 생ㄱ성
  134. function renderSiseList(siseList) {
  135. var tbody = $('#sise-list');
  136. tbody.empty(); // Clear existing rows
  137. // console.log('siseList.length : ', siseList.length);
  138. if (siseList.length === 0) {
  139. tbody.html('<tr><td colspan="5">회원권이 존재하지 않습니다.</td></tr>');
  140. return;
  141. }
  142. siseList.forEach(function(sise) {
  143. var fluctuationClass = '';
  144. var fluctuationIcon = '';
  145. if (sise['fluctuation'] > 0) {
  146. fluctuationClass = 'up';
  147. fluctuationIcon = 'fa-sort-up';
  148. } else if (sise['fluctuation'] < 0) {
  149. fluctuationClass = 'down';
  150. fluctuationIcon = 'fa-sort-down';
  151. }
  152. var fluctuationText = sise['fluctuation'] !== 0 ? `
  153. <i class="fa-solid ${fluctuationIcon}"></i>
  154. ${number_format(Math.abs(sise['fluctuation']))}
  155. ` : `${number_format(sise['fluctuation'])}`;
  156. var tr = $('<tr>');
  157. tr.html(`
  158. <td scope="row" data-label="${sise['PostTitle']}">${sise['PostTitle']}</td>
  159. <td data-label="${sise['Pc3']}">${number_format(sise['Pc3'])}</td>
  160. <td data-label="${sise['Pc4']}">${number_format(sise['Pc4'])}</td>
  161. <td data-label="등락" class="${fluctuationClass}">
  162. ${fluctuationText}
  163. </td>
  164. <td data-label="상담신청">
  165. <button type="button" class="btn consult-btn"
  166. data-post-title="${sise['PostTitle']}"
  167. data-pc5="${sise['Pc5']}"
  168. onclick="window.location.href = '/contactus-custom/${sise['Pc5']}/${encodeURIComponent(sise['PostTitle'])}'">상담신청
  169. </button>
  170. </td>
  171. `);
  172. tbody.append(tr);
  173. });
  174. }
  175. function searchDate(date){
  176. return siseList.filter(function(siseFormDate) {
  177. var dateMatch = date ? (siseFormDate['Pc6'] && siseFormDate['Pc6'] === date) : true;
  178. return dateMatch;
  179. });
  180. }
  181. function number_format(number) {
  182. return new Intl.NumberFormat().format(number);
  183. }
  184. function dateFormat(date){
  185. var formattedDate = '';
  186. if (date) {
  187. var parts = date.split('-');
  188. formattedDate = parts.join('');
  189. }
  190. return formattedDate;
  191. }
  192. const siseList = {!! json_encode($siseList['Page']) !!}; // JavaScript에서 PHP 배열을 변환하여 변수에 할당
  193. </script>
  194. @endpush
  195. @endsection