Advertisement
Guest User

js

a guest
Jun 30th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.39 KB | None | 0 0
  1. $(document).ready(function() {
  2.  
  3.  
  4. $(".se-pre-con").fadeOut("slow");
  5.  
  6.  
  7. });
  8.  
  9. function filterColumn ( i ) {
  10. $('#transaction_table').DataTable().column( i ).search(
  11. "^"+$('#col'+i+'_filter').val()+"",
  12. true,
  13. false,
  14. true
  15.  
  16. ).draw();
  17.  
  18. $('#position_table').DataTable().column( i ).search(
  19. "^"+$('#col'+i+'_filter').val()+"",
  20. true,
  21. false,
  22. true
  23.  
  24. ).draw();
  25. };
  26.  
  27. function currencyFormat (num) {
  28. return num.toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
  29. };
  30.  
  31. $(document).ready(function() {
  32.  
  33.  
  34. $('#transaction_table').DataTable({
  35. "ajax": {
  36. "url": "http://localhost:8080/newreport/index.php/reports/loaddata",
  37. "dataSrc": ""
  38. },
  39. "columns": [
  40. { "data": "insertDate" },
  41. { "data": "accountNumber" },
  42. { "data": "fullSymbol" },
  43. { "data": "securityName" },
  44. { "data": "transactionCode" },
  45. { "data": "quantity" },
  46. { "data": "priceFill1" },
  47. { "data": "amount" },
  48. { "data": "commission" },
  49. { "data": "currencyOfPrice" },
  50. { "data": "settlementDate" }
  51.  
  52. ],
  53. "deferRender": true,
  54. fixedHeader: {
  55. header: true,
  56. footer: true
  57. },
  58. "pageLength": 25,
  59. "lengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
  60. dom: "<'row'<'col-sm-3'l><'col-sm-3'B><'col-sm-6'f>>" +
  61. "<'row'<'col-sm-12'tr>>" +
  62. "<'row'<'col-sm-5'i><'col-sm-7'p>>",
  63. buttons: [
  64. 'excelHtml5',
  65. 'csvHtml5',
  66. ],
  67.  
  68. initComplete: function () {
  69. this.api().columns([1]).every( function () {
  70. var column = this;
  71. var select = $('<select id="filter_dropdown"><option value="">Show All</option></select>')
  72. .appendTo( $('#account_filter_label') )
  73. .on( 'change', function () {
  74. var val = $.fn.dataTable.util.escapeRegex(
  75. $(this).val()
  76. );
  77.  
  78. column
  79. .search( val ? '^'+val+'$' : '', true, false )
  80. .draw();
  81. } );
  82.  
  83. column.data().unique().sort().each( function ( d, j ) {
  84. select.append( '<option value="'+d+'">'+d+'</option>' )
  85. } );
  86. } );
  87. }
  88.  
  89.  
  90.  
  91.  
  92. });
  93.  
  94.  
  95.  
  96. $('#position_table').DataTable({
  97. fixedHeader: {
  98. header: true,
  99. footer: true
  100. },
  101. "pageLength": 25,
  102. "lengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
  103. dom: "<'row'<'col-sm-3'l><'col-sm-3'B><'col-sm-6'f>>" +
  104. "<'row'<'col-sm-12'tr>>" +
  105. "<'row'<'col-sm-5'i><'col-sm-7'p>>",
  106. buttons: [
  107. 'excelHtml5',
  108. 'csvHtml5',
  109. ],
  110.  
  111. initComplete: function () {
  112. this.api().columns([1]).every( function () {
  113. var column = this;
  114. var select = $('<select id="filter_dropdown"><option value="">Show All</option></select>')
  115. .appendTo( $('#account_filter_label') )
  116. .on( 'change', function () {
  117. var val = $.fn.dataTable.util.escapeRegex(
  118. $(this).val()
  119. );
  120.  
  121. column
  122. .search( val ? '^'+val+'$' : '', true, false )
  123. .draw();
  124. } );
  125.  
  126. column.data().unique().sort().each( function ( d, j ) {
  127. select.append( '<option value="'+d+'">'+d+'</option>' )
  128. } );
  129. } );
  130. },
  131.  
  132. "footerCallback": function ( row, data, start, end, display ) {
  133. //console.log('in footer callback');
  134. var api = this.api(), data;
  135.  
  136. // Remove the formatting to get integer data for summation
  137. var intVal = function ( i ) {
  138. return typeof i === 'string' ?
  139. i.replace(/[\$,]/g, '')*1 :
  140. typeof i === 'number' ?
  141. i : 0;
  142. };
  143.  
  144.  
  145. // Total over all pages
  146. total = api
  147. .column( 9 )
  148. .data()
  149. .reduce( function (a, b) {
  150. return intVal(a) + intVal(b);
  151. }, 0 );
  152.  
  153. //console.log(total);
  154.  
  155. // Total over this page
  156. pageTotal = api
  157. .column( 9, { page: 'current'} )
  158. .data()
  159. .reduce( function (a, b) {
  160. return intVal(a) + intVal(b);
  161. }, 0 );
  162.  
  163.  
  164. var searchTotalData = api.column(9, {'filter': 'applied'}).data();
  165. var searchTotal = searchTotalData.reduce(function(a,b){return intVal(a) + intVal(b);}, 0);
  166.  
  167. //console.log(searchTotal);
  168.  
  169. // Update footer
  170. $( api.column( 9 ).footer() ).html(
  171. '$ '+ currencyFormat(searchTotal)
  172. );
  173. }
  174.  
  175.  
  176. });
  177.  
  178. $("#datepicker").datepicker({
  179. dateFormat: 'yy-mm-dd',
  180. changeMonth: true,
  181. changeYear: true
  182.  
  183. });
  184.  
  185. $('input.column_filter').on( 'keyup click', function () {
  186. filterColumn( $(this).parents('div').attr('data-column') );
  187. });
  188.  
  189. $('input.col_filter').on( 'keyup click', function () {
  190. filterColumn( $(this).parents('div').attr('data-column') );
  191. });
  192.  
  193. $("#admin_form_add").validate({
  194. // Specify validation rules
  195. rules: {
  196. // The key name on the left side is the name attribute
  197. // of an input field. Validation rules are defined
  198. // on the right side
  199. username: "required",
  200. first_name: "required",
  201. family_name: "required",
  202. accounts: "required",
  203. email: {
  204. required: true,
  205. // Specify that email should be validated
  206. // by the built-in "email" rule
  207. email: true
  208. },
  209. password: {
  210. required: true,
  211. minlength: 6
  212. },
  213. phone: {
  214. required: true,
  215. minlength: 12
  216. }
  217. },
  218. // Specify validation error messages
  219. messages: {
  220. username: "Please enter username",
  221. first_name: "Please enter firstname",
  222. family_name: "Please enter family name",
  223. accounts: "Please enter accounts",
  224. password: {
  225. required: "Please provide a password",
  226. minlength: "Your password must be at least 6 characters long"
  227. },
  228. phone: {
  229. required: "Please provide a phone number",
  230. minlength: "Please add the country code +1 and check the number again "
  231. },
  232. email: "Please enter a valid email address"
  233. },
  234. // Make sure the form is submitted to the destination defined
  235. // in the "action" attribute of the form when valid
  236. submitHandler: function(form) {
  237. form.submit();
  238. }
  239. });
  240.  
  241. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement