Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.84 KB | None | 0 0
  1. <script>
  2. $(document).ready(function() {
  3. function format_date(oObj) {
  4. //var sValue = oObj.aData[oObj.iDataColumn];
  5. var aDate = oObj.split('-');
  6. <?php if(JS_DATE == 'dd-mm-yyyy') { ?>
  7. return aDate[2] + "-" + aDate[1] + "-" + aDate[0];
  8. <?php } elseif(JS_DATE == 'dd/mm/yyyy') { ?>
  9. return aDate[2] + "/" + aDate[1] + "/" + aDate[0];
  10. <?php } elseif(JS_DATE == 'mm/dd/yyyy') { ?>
  11. return aDate[1] + "/" + aDate[2] + "/" + aDate[0];
  12. <?php } elseif(JS_DATE == 'mm-dd-yyyy') { ?>
  13. return aDate[1] + "-" + aDate[2] + "-" + aDate[0];
  14. <?php } else { ?>
  15. return sValue;
  16. <?php } ?>
  17. }
  18. function currencyFormate(x) {
  19. var parts = x.toString().split(".");
  20. return parts[0].replace(/B(?=(d{3})+(?!d))/g, ".")+(parts[1] ? "," + parts[1] : ".00");
  21.  
  22. }
  23. $('#fileData').dataTable( {
  24. "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
  25. "aaSorting": [[ 1, "desc" ]],
  26. "iDisplayLength": <?php echo ROWS_PER_PAGE; ?>,
  27. 'bProcessing' : true,
  28. 'bServerSide' : true,
  29. 'sAjaxSource' : '<?php echo base_url(); ?>index.php?module=entradaesaida&view=getdatatableajax',
  30. 'fnServerData': function(sSource, aoData, fnCallback, fnFooterCallback)
  31. {
  32. aoData.push( { "name": "<?php echo $this->security->get_csrf_token_name(); ?>", "value": "<?php echo $this->security->get_csrf_hash() ?>" } );
  33. $.ajax
  34. ({
  35. 'dataType': 'json',
  36. 'type' : 'POST',
  37. 'url' : sSource,
  38. 'data' : aoData,
  39. 'success' : fnCallback
  40. });
  41. },
  42. "oTableTools": {
  43. "sSwfPath": "assets/media/swf/copy_csv_xls_pdf.swf",
  44. "aButtons": [
  45.  
  46. ]
  47. },
  48. "aoColumns": [
  49. { "mRender": format_date }, null, null, null, null,
  50. { "mRender": currencyFormate },
  51. ],
  52.  
  53. "fnFooterCallback": function ( nRow, Entradas, iStart, iEnd, aiDisplay ) {
  54. var row_total = 0;
  55. for ( var i=0; i<Entradas.length; i++ )
  56. {
  57. row_total += parseFloat(Entradas[ aiDisplay[i] ][3]);
  58. }
  59.  
  60. var nCells = nRow.getElementsByTagName('th');
  61. nCells[3].innerHTML = currencyFormate(parseFloat(row_total).toFixed(3));
  62.  
  63.  
  64. }
  65.  
  66. } ).columnFilter({ aoColumns: [
  67.  
  68. { type: "text", bRegex:true },
  69. { type: "text", bRegex:true },
  70. { type: "text", bRegex:true },
  71. { type: "text", bRegex:true },
  72. null, null, null, null
  73. ]});
  74.  
  75. } );
  76.  
  77. </script>
  78.  
  79. <?php if($message) { echo "<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">&times;</button>" . $message . "</div>"; } ?>
  80. <?php if($success_message) { echo "<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">&times;</button>" . $success_message . "</div>"; } ?>
  81.  
  82. <h3 class="title"><?php echo $page_title; ?></h3>
  83. <table id="fileData" class="table table-bordered table-hover table-striped table-condensed" style="margin-bottom: 5px;">
  84. <thead>
  85. <tr>
  86. <th><?php echo $this->lang->line("data"); ?></th>
  87. <th><?php echo $this->lang->line("clientes"); ?></th>
  88. <th><?php echo $this->lang->line("products"); ?></th>
  89. <th><?php echo $this->lang->line("entradas"); ?></th>
  90. <th><?php echo $this->lang->line("saidas"); ?></th>
  91. <th><?php echo $this->lang->line("saldoanterior"); ?></th>
  92. </tr>
  93. </thead>
  94. <tbody>
  95. <tr>
  96. <td colspan="8" class="dataTables_empty"><?php echo $this->lang->line("loading_data"); ?></td>
  97. </tr>
  98. </tbody>
  99. <tfoot>
  100. <tr>
  101. <th>[<?php echo $this->lang->line("data"); ?>]</th>
  102. <th>[<?php echo $this->lang->line("clientes"); ?>]</th>
  103. <th>[<?php echo $this->lang->line("products"); ?>]</th>
  104. <th>[<?php echo $this->lang->line("entradas"); ?>]</th>
  105. <th><?php echo $this->lang->line("saidas"); ?></th>
  106. <th><?php echo $this->lang->line("saldoanterior"); ?></th>
  107. </tr>
  108. </tfoot>
  109. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement