<?php $this->load->view('admin/includes/head'); ?>
<?php $this->load->view('admin/includes/sidebar'); ?>
<?php $this->load->view('admin/includes/topbar'); ?>
<div class="container px-2 mt-4">
	<div id="TableData" class="table-responsive">


	</div>
	<?php $cat = GetServiceCatTypes(); ?>
</div>
<!-- End Main content-->

<?php $this->load->view('admin/includes/footer'); ?>
<script type="text/javascript">



	$(document).ready(function(){
		
		


		var selectedValue = 'Rental Request Form';

	$("#filter-bookings").text("RENTALS REQUESTS FORM"); // set initial text



	$.ajax({
		url: '<?=base_url('admin/filterBookingData/')?>'+selectedValue,
		type: 'POST',
		data: {aspectType : selectedValue},
		success: function(data) {


			$("#TableData").html(data);
			$('#myBookings').DataTable( {
				order: [[ 0, 'desc' ]],
				"lengthChange": false,
				"scrollX": true,
				"ordering": false,
				"searching": true,
				language: {
					emptyTable: "No Facilities Bookings Available to show..",
					search: ''
				}
			} );

			$("#heading").text(selectedValue);
		}
	});






});
	function CancelBooking(id){

		var id = id;
		Swal.fire({
			title: 'Do you want to cancel this Booking?',
			showDenyButton: false,
			showCancelButton: true,
			confirmButtonText: 'Yes',
			denyButtonText: 'No',
		}).then((result) => {
			if (result.isConfirmed) {
				loader.on();
				$.ajax({
					url: '<?=base_url('admin/Dashboard/CancelBooking/')?>'+id,
					type: 'POST',
					dataType: "json",
					success: function(data) {
						loader.off();
						if (data['statusCode'] == 1) {
							Swal.fire({
								title: 'Booking has been cancelled',
								type: "success",
								confirmButtonText: 'OK',
								confirmButtonColor: '#008080',
							}).then((result) => {
								window.location.reload(); 
							});
						} else {
							Swal.fire({
								title: 'Something went wrong!',
								type: "alert",
								confirmButtonText: 'OK',
								confirmButtonColor: '#008080',
							}).then((result) => {
								window.location.reload(); 
							});
						}
					}
				});
			} else if (result.isDenied) {
				Swal.fire('Changes are not saved', '', 'info')
			}
		});
	}



</script>


</body>
</html>
