fuelPointsView.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <button class="btn btn-primary" onclick="document.getElementById('editStatus').style.display = 'none';"> Add Prices Update </button>
  2. <table id="updatePrices" class="table display table-striped table-bordered table-hover table-sm" cellspacing="0" width="100%">
  3. <thead>
  4. <tr>
  5. <th></th>
  6. <th>Id</th>
  7. <!-- <th>Create At</th>
  8. <th>Update At</th> -->
  9. <th>Auto Clear</th>
  10. <!-- <th>Status</th> -->
  11. <th>Tanks</th>
  12. </tr>
  13. </thead>
  14. <!-- <tfoot>
  15. <tr>
  16. <th></th>
  17. <th>Id</th>
  18. <th>Status</th>
  19. <th>Timing</th>
  20. <th>Create At</th>
  21. <th>Update At</th>
  22. </tr>
  23. </tfoot> -->
  24. </table>
  25. <?php include "EditStatus.php" ?>
  26. <script type="text/javascript">
  27. $(document).ready(function() {
  28. var table = $('#updatePrices').DataTable( {
  29. //"buttons": true,
  30. "ajax": "api/v1/FuelPoints/fuelPointsData.txt",
  31. "columns": [
  32. {
  33. "className": 'edit',
  34. "orderable": false,
  35. "data": null,
  36. "defaultContent": 'Edit'
  37. },
  38. { "data": "Id"},
  39. // { "data": "Create_At" },
  40. // { "data": "Update_At" },
  41. { "data": "Auto_Clear_Transaction" },
  42. // { "data": "Status" },
  43. { "data": "TankIds" },
  44. ],
  45. "order": [[1, 'asc']],
  46. select: true
  47. } );
  48. // Add event listener for opening and closing details
  49. $('#updatePrices tbody').on('click', 'tr td.edit', function () {
  50. var tr = $(this).closest('tr');
  51. var row = table.row( tr );
  52. var id = row.data()['Id'];
  53. var status= row.data()['Status'];
  54. // var id = table.row( this ).data()['Id'];
  55. document.getElementById('id').value = id;
  56. document.getElementById('status').value = status;
  57. document.getElementById('editStatus').style.display = 'block';
  58. } );
  59. $('#updatePrices tbody').on('click', 'tr', function () {
  60. var tr = $(this).closest('tr');
  61. var row = table.row( tr );
  62. alert(row.data()['Id']);
  63. document.cookie = "updatePricesId="+row.data()['Id'];
  64. // document.cookie = "customerName="+row.data()['Id'];
  65. //window.location.href = 'index.php';
  66. open_script();
  67. } );
  68. } );
  69. function open_script(){
  70. window.location.assign('/updatePricesData.php');//there are many ways to do this
  71. }
  72. </script>