updatePricesView.php 2.4 KB

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