tstat_be/app/Views/home.php

89 lines
2.2 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Trip Approval</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body {
margin: 0;
font-family: Arial, sans-serif;
background-color: #eaeaea;
display: flex;
flex-direction: column;
align-items: center;
height: 100vh;
}
header {
width: 100%;
background-color: #007bff;
color: white;
padding: 10px 20px;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
header h1 {
margin: 7px;
font-size: 24px;
}
.logout-button {
padding: 8px 15px;
font-size: 14px;
color: #fff;
background-color: #dc3545;
border: none;
border-radius: 5px;
cursor: pointer;
text-transform: uppercase;
margin: 7px;
}
.logout-button:hover {
background-color: #b02a37;
}
.welcome-message {
flex-grow: 1;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
color: #333;
text-align: center;
}
</style>
</head>
<body>
<header>
<h1>Trip Approval</h1>
<a class="logout-button" >Logout</a>
</header>
<div class="welcome-message">
Welcome , <?= $userName ?> !
</div>
<script>
$(document).on('click', '.logout-button', function (e) {
e.preventDefault();
$.ajax({
url: '<?= base_url('logout'); ?>',
type: 'POST',
success: function (response) {
// if (response.status === 'success') {
// window.location.href = '<?= base_url('login'); ?>'; // Redirect to login page
// }
},
error: function (xhr, status, error) {
console.error('Logout failed:', error);
alert('Failed to logout. Please try again.');
}
});
});
</script>
</body>
</html>