PlayerManagement.blade.php 8.9KB

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