Guest User

Untitled

a guest
Feb 27th, 2018
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. $(document).ready(function() {
  2.  
  3. $(function() {
  4. var start = moment("2017-01-01 12:34:16");
  5. var end = moment("2018-03-03 10:08:07");
  6.  
  7. function cb(start, end) {
  8. $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
  9. }
  10.  
  11. $('#reportrange').daterangepicker({
  12. startDate: start,
  13. endDate: end,
  14. ranges: {
  15. 'Today': [moment(), moment()],
  16. 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
  17. 'Last 7 Days': [moment().subtract(6, 'days'), moment()],
  18. 'Last 30 Days': [moment().subtract(29, 'days'), moment()],
  19. 'This Month': [moment().startOf('month'), moment().endOf('month')],
  20. 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
  21. }
  22. }, cb);
  23.  
  24. cb(start, end);
  25.  
  26. });
  27.  
  28.  
  29. $('#reportrange').on('apply.daterangepicker', function(ev, picker) {
  30. var start = picker.startDate.format('YYYY-MM-DD');
  31. var end = picker.endDate.format('YYYY-MM-DD');
  32.  
  33.  
  34.  
  35. $.fn.dataTable.ext.search.push(
  36. function(settings, data, dataIndex) {
  37. var min = start;
  38. var max = end;
  39. var startDate = new Date(data[1]);
  40. if (min == null && max == null) {
  41. return true;
  42. }
  43. if (min == null && startDate <= max) {
  44. return true;
  45. }
  46. if (max == null && startDate >= min) {
  47. return true;
  48. }
  49. if (startDate <= max && startDate >= min) {
  50. return true;
  51. }
  52. return false;
  53. }
  54. );
  55. table.draw();
  56. });
  57.  
  58. var dataSet = [
  59. ['2093',
  60. 'Feb 23, 2018',
  61. 'asd asd ',
  62. 'asd@hotmail.com',
  63. '£ 50',
  64. '£0.00',
  65. "Feb 23, 2019",
  66. ],
  67. ['2092',
  68. 'Feb 23, 2018',
  69. 'asddd asddd',
  70. 'dddd@hotmail.com',
  71. '£ 50',
  72. '£0.00',
  73. "Feb 23, 2019",
  74. ],
  75. ['2050',
  76. 'Feb 20, 2018',
  77. 'Angus Fret',
  78. 'angus@fgf.co.uk',
  79. '£ 50',
  80. '£0.00',
  81. "Feb 20, 2019",
  82. ],
  83. ['2048',
  84. 'Feb 19, 2018',
  85. 'John Smith',
  86. 'john@smith.com',
  87. '£ 50',
  88. '£0.00',
  89. "Feb 19, 2019",
  90. ],
  91.  
  92. ['2046',
  93. 'Feb 19, 2018',
  94. 'Ana Ana',
  95. 'ana@talktalk.net',
  96. '£ 50',
  97. '£0.00',
  98. "Feb 19, 2019",
  99. ],
  100. ['2045',
  101. 'Feb 19, 2018',
  102. 'Ray N',
  103. 'rayn@nn.com',
  104. '£ 50',
  105. '£0.00',
  106. "Feb 19, 2019",
  107. ],
  108. ['2044',
  109. 'Feb 16, 2018',
  110. 'Paul N',
  111. 'paul@gmail.com',
  112. '£ 200',
  113. '£0.00',
  114. "Feb 16, 2019",
  115. ],
  116. ['2042',
  117. 'Feb 13, 2018',
  118. 'Bradley New',
  119. 'new-marden@hotmail.com',
  120. '£ 100',
  121. '£0.00',
  122. "Feb 13, 2019",
  123. ],
  124.  
  125. ['2012',
  126. 'Jan 27, 2018',
  127. 'Mark Zuckenberg',
  128. 'markzeg@me.com',
  129. '£ 150',
  130. '£0.00',
  131. "Jan 27, 2019",
  132. ],
  133.  
  134. ];
  135. var table = $('#example').DataTable({
  136. "order": [
  137. [0, "desc"]
  138. ],
  139. lengthChange: false,
  140. data: dataSet,
  141. columns: [{
  142. title: "ORDER ID"
  143. },
  144. {
  145. title: "ORDER DATE"
  146. },
  147. {
  148. title: "PURCHASED BY"
  149. },
  150. {
  151. title: "RECIPIENT"
  152. },
  153. {
  154. title: "ORDER TOTAL"
  155. },
  156. {
  157. title: "VAT"
  158. },
  159. {
  160. title: "EXPIRY"
  161. }
  162.  
  163. ]
  164. });
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171. });
Add Comment
Please, Sign In to add comment