| Server IP : 172.67.201.108 / Your IP : 216.73.216.11 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/home2/cgny/public_html/newadmin/ |
Upload File : |
<cfinclude template="header.cfm">
<link href="../plugins/bower_components/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.datatables.net/buttons/1.2.2/css/buttons.dataTables.min.css" rel="stylesheet" type="text/css" />
<div id="page-wrapper">
<div class="container-fluid">
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">HotelStats</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /row -->
<div class="row">
<div class="col-sm-12">
<div class="white-box">
<!--- Include the necessary scripts and stylesheets for DataTables --->
<head>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.2/css/jquery.dataTables.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.datatables.net/1.11.2/js/jquery.dataTables.min.js"></script>
</head>
<body>
<cfparam name="form.action" default="">
<cfif parameterexists(url.add)>
<!--- Add new hotel --->asd
<cfquery name="addHotel" datasource="#ds#">
INSERT INTO gtehotels (hotelname) VALUES ('#form.hotelname#')
</cfquery>
<cfelseif parameterexists(url.delete)>
<!--- Delete hotel --->
<cfquery name="deleteHotel" datasource="#ds#">
DELETE FROM gtehotels WHERE id = #url.delete#
</cfquery>
</cfif>
<form id="hotelForm" method="post" action="hotels.cfm?add=on">
<input type="hidden" name="action" value="">
<input type="hidden" name="id" value="">
<input type="text" name="hotelname" placeholder="Hotel Name">
<button id="btnAddEdit" type="submit">Add</button>
</form>
<table id="hotelTable" class="display">
<thead>
<tr>
<th>Hotel ID</th>
<th>Hotel Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<cfquery name="getHotels" datasource="#ds#">
SELECT * FROM gtehotels
</cfquery>
<cfoutput query="getHotels">
<tr>
<td>#id#</td>
<td>#hotelname#</td>
<td>
<a href="hotels.cfm?delete=#id#" onclick="return confirm('Are you sure?');">Delete</a>
</td>
</tr>
</cfoutput>
</tbody>
</table>
<script>
$(document).ready(function() {
$('#hotelTable').DataTable();
});
// Edit hotel function
function editHotel(id, hotelname) {
$('#hotelForm').attr('action', 'editHotel.cfm');
$('#hotelForm input[name="action"]').val('edit');
$('#hotelForm input[name="id"]').val(id);
$('#hotelForm input[name="hotelname"]').val(hotelname);
$('#btnAddEdit').text('Update');
}
// Delete hotel function
function deleteHotel(id) {
if (confirm('Are you sure you want to delete this hotel?')) {
$('#hotelForm').attr('action', 'deleteHotel.cfm');
$('#hotelForm input[name="action"]').val('delete');
$('#hotelForm input[name="id"]').val(id);
$('#hotelForm').submit();
}
// Add event listener to the form submit button
$('#hotelForm').submit(function(e) {
e.preventDefault(); // Prevent the form from submitting normally
var action = $('#hotelForm input[name="action"]').val();
if (action === 'edit') {
// Perform edit operation
$.ajax({
url: 'editHotel.cfm',
type: 'POST',
data: $('#hotelForm').serialize(),
success: function(response) {
// Reload the page after successful edit
location.reload();
},
error: function(xhr, status, error) {
console.log(error); // Handle the error accordingly
}
});
} else if (action === 'delete') {
// Perform delete operation
$.ajax({
url: 'deleteHotel.cfm',
type: 'POST',
data: $('#hotelForm').serialize(),
success: function(response) {
// Reload the page after successful delete
location.reload();
},
error: function(xhr, status, error) {
console.log(error); // Handle the error accordingly
}
});
} else {
// Perform add operation
$.ajax({
url: 'addHotel.cfm',
type: 'POST',
data: $('#hotelForm').serialize(),
success: function(response) {
// Reload the page after successful add
location.reload();
},
error: function(xhr, status, error) {
console.log(error); // Handle the error accordingly
}
});
}
});
</script>
</body>
</div></div>
</div>
</div>
<cfinclude template="footer.cfm">