updatePricesView.php 2.7 KB

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