Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- $(".se-pre-con").fadeOut("slow");
- });
- function filterColumn ( i ) {
- $('#transaction_table').DataTable().column( i ).search(
- "^"+$('#col'+i+'_filter').val()+"",
- true,
- false,
- true
- ).draw();
- $('#position_table').DataTable().column( i ).search(
- "^"+$('#col'+i+'_filter').val()+"",
- true,
- false,
- true
- ).draw();
- };
- function currencyFormat (num) {
- return num.toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
- };
- $(document).ready(function() {
- $('#transaction_table').DataTable({
- "ajax": {
- "url": "http://localhost:8080/newreport/index.php/reports/loaddata",
- "dataSrc": ""
- },
- "columns": [
- { "data": "insertDate" },
- { "data": "accountNumber" },
- { "data": "fullSymbol" },
- { "data": "securityName" },
- { "data": "transactionCode" },
- { "data": "quantity" },
- { "data": "priceFill1" },
- { "data": "amount" },
- { "data": "commission" },
- { "data": "currencyOfPrice" },
- { "data": "settlementDate" }
- ],
- "deferRender": true,
- fixedHeader: {
- header: true,
- footer: true
- },
- "pageLength": 25,
- "lengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
- dom: "<'row'<'col-sm-3'l><'col-sm-3'B><'col-sm-6'f>>" +
- "<'row'<'col-sm-12'tr>>" +
- "<'row'<'col-sm-5'i><'col-sm-7'p>>",
- buttons: [
- 'excelHtml5',
- 'csvHtml5',
- ],
- initComplete: function () {
- this.api().columns([1]).every( function () {
- var column = this;
- var select = $('<select id="filter_dropdown"><option value="">Show All</option></select>')
- .appendTo( $('#account_filter_label') )
- .on( 'change', function () {
- var val = $.fn.dataTable.util.escapeRegex(
- $(this).val()
- );
- column
- .search( val ? '^'+val+'$' : '', true, false )
- .draw();
- } );
- column.data().unique().sort().each( function ( d, j ) {
- select.append( '<option value="'+d+'">'+d+'</option>' )
- } );
- } );
- }
- });
- $('#position_table').DataTable({
- fixedHeader: {
- header: true,
- footer: true
- },
- "pageLength": 25,
- "lengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
- dom: "<'row'<'col-sm-3'l><'col-sm-3'B><'col-sm-6'f>>" +
- "<'row'<'col-sm-12'tr>>" +
- "<'row'<'col-sm-5'i><'col-sm-7'p>>",
- buttons: [
- 'excelHtml5',
- 'csvHtml5',
- ],
- initComplete: function () {
- this.api().columns([1]).every( function () {
- var column = this;
- var select = $('<select id="filter_dropdown"><option value="">Show All</option></select>')
- .appendTo( $('#account_filter_label') )
- .on( 'change', function () {
- var val = $.fn.dataTable.util.escapeRegex(
- $(this).val()
- );
- column
- .search( val ? '^'+val+'$' : '', true, false )
- .draw();
- } );
- column.data().unique().sort().each( function ( d, j ) {
- select.append( '<option value="'+d+'">'+d+'</option>' )
- } );
- } );
- },
- "footerCallback": function ( row, data, start, end, display ) {
- //console.log('in footer callback');
- var api = this.api(), data;
- // Remove the formatting to get integer data for summation
- var intVal = function ( i ) {
- return typeof i === 'string' ?
- i.replace(/[\$,]/g, '')*1 :
- typeof i === 'number' ?
- i : 0;
- };
- // Total over all pages
- total = api
- .column( 9 )
- .data()
- .reduce( function (a, b) {
- return intVal(a) + intVal(b);
- }, 0 );
- //console.log(total);
- // Total over this page
- pageTotal = api
- .column( 9, { page: 'current'} )
- .data()
- .reduce( function (a, b) {
- return intVal(a) + intVal(b);
- }, 0 );
- var searchTotalData = api.column(9, {'filter': 'applied'}).data();
- var searchTotal = searchTotalData.reduce(function(a,b){return intVal(a) + intVal(b);}, 0);
- //console.log(searchTotal);
- // Update footer
- $( api.column( 9 ).footer() ).html(
- '$ '+ currencyFormat(searchTotal)
- );
- }
- });
- $("#datepicker").datepicker({
- dateFormat: 'yy-mm-dd',
- changeMonth: true,
- changeYear: true
- });
- $('input.column_filter').on( 'keyup click', function () {
- filterColumn( $(this).parents('div').attr('data-column') );
- });
- $('input.col_filter').on( 'keyup click', function () {
- filterColumn( $(this).parents('div').attr('data-column') );
- });
- $("#admin_form_add").validate({
- // Specify validation rules
- rules: {
- // The key name on the left side is the name attribute
- // of an input field. Validation rules are defined
- // on the right side
- username: "required",
- first_name: "required",
- family_name: "required",
- accounts: "required",
- email: {
- required: true,
- // Specify that email should be validated
- // by the built-in "email" rule
- email: true
- },
- password: {
- required: true,
- minlength: 6
- },
- phone: {
- required: true,
- minlength: 12
- }
- },
- // Specify validation error messages
- messages: {
- username: "Please enter username",
- first_name: "Please enter firstname",
- family_name: "Please enter family name",
- accounts: "Please enter accounts",
- password: {
- required: "Please provide a password",
- minlength: "Your password must be at least 6 characters long"
- },
- phone: {
- required: "Please provide a phone number",
- minlength: "Please add the country code +1 and check the number again "
- },
- email: "Please enter a valid email address"
- },
- // Make sure the form is submitted to the destination defined
- // in the "action" attribute of the form when valid
- submitHandler: function(form) {
- form.submit();
- }
- });
- } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement