SessionManagement.blade.php 9.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. @extends('admin.master')
  2. @section('content')
  3. <div class="row">
  4. <div class="col-lg-12">
  5. <div class="contentpanel">
  6. <form id="listForm" method="post">
  7. <!-- 功能按鈕(新增/批量處理等等) -->
  8. <div class="row" style="margin-bottom: 5px;">
  9. <div class="col-lg-12">
  10. <ol class="headermenu">
  11. <li>
  12. <button class="btn btn-darkblue btn-xs" id="export"><strong>匯出</strong></button>
  13. </li>
  14. </ol>
  15. </div>
  16. </div>
  17. <!-- 搜尋段 -->
  18. <div class="panel panel-default">
  19. <div class="panel-heading" data-toggle="collapse" data-target="#search_content">
  20. <h3 class="panel-title">事件監控</h3>
  21. </div>
  22. <div id="search_content" class="collapse in">
  23. <div class="panel-body">
  24. <!-- 建立時間範圍 from -->
  25. <div class="form-group col-xs-12 col-sm-6 col-lg-6">
  26. <label for="createDateStart">建立時間範圍(起)</label>
  27. <input type="text" class="form-control input-sm" id="createDateStart"
  28. maxlength="10">
  29. </div>
  30. <!-- 建立時間範圍 to -->
  31. <div class="form-group col-xs-12 col-sm-6 col-lg-6">
  32. <label for="createDateFinal">建立時間範圍(迄)</label>
  33. <input type="text" class="form-control input-sm" id="createDateFinal"
  34. maxlength="10">
  35. </div>
  36. <!-- 玩家 LINE ID -->
  37. <div class="form-group col-xs-12 col-sm-6 col-lg-6">
  38. <label for="lineId">玩家 LINE ID</label>
  39. <input type="text" class="form-control input-sm" id="lineId" maxlength="50">
  40. </div>
  41. <!-- 玩家名稱 -->
  42. <div class="form-group col-xs-12 col-sm-6 col-lg-6">
  43. <label for="lineUserId">玩家名稱</label>
  44. <input type="text" class="form-control input-sm" id="userName" maxlength="100">
  45. </div>
  46. <!-- 回合 -->
  47. <div class="form-group col-xs-12 col-sm-6 col-lg-6">
  48. <label for="valid">回合</label>
  49. <select class="form-control input-sm" id="round">
  50. <option value="">全部</option>
  51. @foreach($round as $data)
  52. <option value="{{ $data['id'] }}">{{ $data['roundName'] }}</option>
  53. @endforeach
  54. </select>
  55. </div>
  56. <!-- 獎項 LINE POINT -->
  57. <div class="form-group col-xs-12 col-sm-6 col-lg-6">
  58. <label for="valid">獎項 LINE POINT</label>
  59. <select class="form-control input-sm" id="good">
  60. <option value="">全部</option>
  61. @foreach($good as $data)
  62. <option value="{{ $data['id'] }}">{{ $data['lp'] }}</option>
  63. @endforeach
  64. </select>
  65. </div>
  66. <!-- Search -->
  67. <div class="form-group col-xs-12 col-sm-12 col-lg-12">
  68. <a class="btn btn-success btn-xs" onclick="javascript: custom_search();">
  69. <div class="glyphicon glyphicon-search"></div>
  70. </a>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. <hr class="search-hr"/>
  76. <!-- 列表段 -->
  77. <div class="row">
  78. <div class="col-lg-12">
  79. <table id="GridView1" class="table table-striped table-bordered" cellspacing="0">
  80. <thead>
  81. <tr>
  82. <th>ID</th>
  83. <th>玩家 LINE ID</th>
  84. <th>玩家名稱</th>
  85. <th>回合</th>
  86. <th>獎項 LINE POINT</th>
  87. <th>日期</th>
  88. <th>轉盤吉點</th>
  89. <th>簽到吉點</th>
  90. <th>本次吉點異動</th>
  91. <th>時間戳</th>
  92. </tr>
  93. </thead>
  94. </table>
  95. </div>
  96. </div>
  97. </form>
  98. <!-- row -->
  99. </div>
  100. </div>
  101. </div>
  102. @endsection
  103. @section('extjs')
  104. <script>
  105. $(document).ready(function () {
  106. var table = $('#GridView1').dataTable({
  107. "scrollX": true,
  108. "processing": true,
  109. "serverSide": true,
  110. "ajax": "sessionManagement/grid",
  111. "paging": true,
  112. "ordering": true,
  113. "info": true,
  114. "order": [[0, "desc"]],
  115. "stateSave": true,
  116. "pagingType": "full",
  117. "bFilter": true,
  118. "aoColumnDefs": [{
  119. 'bSortable': false,
  120. 'aTargets': [] //不想參加排序的欄位,可指定多個,逗號分隔
  121. }]
  122. });
  123. // 從網址參觸發搜尋
  124. custom_search();
  125. $('#GridView1_filter').hide();
  126. });
  127. //客製化搜尋欄位
  128. function custom_search() {
  129. $('#GridView1').DataTable()
  130. .column(1).search($('#lineId').val())
  131. .column(2).search($('#userName').val())
  132. .column(3).search($('#round').val())
  133. .column(4).search($('#good').val())
  134. .column(5).search($('#createDateStart').val() + "\n" + $('#createDateFinal').val())
  135. ;
  136. $('#GridView1').dataTable().fnDraw(true);
  137. }
  138. // 匯出報告
  139. $("#export").click(function () {
  140. //加個讀取中畫面
  141. $.blockUI({
  142. css: {
  143. border: 'none',
  144. padding: '15px',
  145. backgroundColor: '#000',
  146. '-webkit-border-radius': '10px',
  147. '-moz-border-radius': '10px',
  148. opacity: .5,
  149. color: '#FFF'
  150. }
  151. });
  152. var http = new XMLHttpRequest();
  153. http.responseType = 'blob';
  154. var header;
  155. var blob;
  156. var url = 'sessionManagement/export';
  157. var params =
  158. ''
  159. + 'lineId=' + $('#lineId').val()
  160. + '&userName=' + $('#userName').val()
  161. + '&round=' + $('#round').val()
  162. + '&good=' + $('#good').val()
  163. + '&createDateStart=' + $('#createDateStart').val()
  164. + '&createDateFinal=' + $('#createDateFinal').val()
  165. ;
  166. http.open("POST", url, true);
  167. http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  168. http.onreadystatechange = function () {//Call a function when the state changes.
  169. if (http.readyState == 4 && http.status == 200) {
  170. var filename = "";
  171. var disposition = http.getResponseHeader('Content-Disposition');
  172. if (disposition && disposition.indexOf('attachment') !== -1) {
  173. var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
  174. var matches = filenameRegex.exec(disposition);
  175. if (matches != null && matches[1]) filename = matches[1].replace(/['"]/g, '');
  176. }
  177. var type = http.getResponseHeader('Content-Type');
  178. blob = new Blob([http.response], {type: type, endings: 'native'});
  179. var URL = window.URL || window.webkitURL;
  180. var downloadUrl = URL.createObjectURL(blob);
  181. var a = document.createElement("a");
  182. a.href = downloadUrl;
  183. a.download = filename;
  184. document.body.appendChild(a);
  185. a.click();
  186. }
  187. //解除鎖定
  188. $.unblockUI();
  189. }
  190. http.send(params);
  191. return false;
  192. });
  193. //日期選擇器
  194. $('#createDateStart').datepicker({
  195. dateFormat: 'yy-mm-dd'
  196. });
  197. $('#createDateFinal').datepicker({
  198. dateFormat: 'yy-mm-dd'
  199. });
  200. setInterval(function () {
  201. $('[data-toggle="popover"]').popover();
  202. }, 1000);
  203. </script>
  204. @endsection