<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
</head>
       
         <div class="d-flex justify-content-center" style="width:100%">
         	
         	<form id="promotion_form" action="">

         		<button class="btn btn-primary" id="promotions-delete-button">Delete</button>

	    		<table class="table table-striped m-3" style="width:90%;" >
				  <thead>
				    <tr>
				     <th>Bulk Delete</th>
				      <th scope="col">Name</th>
				      <th scope="col">Start Date</th>
				      <th scope="col">End Date</th>
				      <th scope="col">Status</th>
				      <th scope="col">Action</th>
				    </tr>
				  </thead>
				  <tbody id="all_promotion">
				  	
				  </tbody>
			  </table>
			</form>
	    </div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.js"></script>

<script>

$(document).ready(function() {


	// get all promotions
	all_promotions();

	function all_promotions()
	{
	   $.ajax({
	          type: 'get',
	          url: 'get_all_promotions.php', // Replace with the actual path to your PHP script
	          data: {promotions_ids:selectedPromotions,store_hash:store_hash,store_access_token:store_access_token},
	          success: function(response) {
	                $('#all_promotion').html(response);
	          }
	      });

	}

	// delete promotions
	 $("#promotion_form").submit(function() {
	 	
	 	 event.preventDefault();
	 	 var store_hash="<?php echo $store_hash; ?>";
	 	 var store_access_token="<?php echo $access_token; ?>";
	 	 console.log(store_hash);


	 	  var selectedPromotions = $('input[name="promtion_ids[]"]:checked').map(function() {
            return $(this).val();
        }).get();
	       
	        $.ajax({
	            type: 'POST',
	            url: 'bulk_delete_promotions.php', // Replace with the actual path to your PHP script
	            data: {promotions_ids:selectedPromotions,store_hash:store_hash,store_access_token:store_access_token},
	            success: function(response) {
	                //$('#result').html(response);
	            }
	        });
	    
	});
	 // delete promotions end
});

</script>    