Emptimesheet
Emptimesheet
php
// Start the session to access logged-in user details
session_start();
if (!isset($_SESSION['username'])) {
die("You must be logged in to view this page.");
}
include_once "../config/dbconnect.php";
?>
<script src="https://kit.fontawesome.com/a076d05399.js"
crossorigin="anonymous"></script>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<script
src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js"
></script>
<script src="https://smtpjs.com/v3/smtp.js"></script> <!-- Correct placement of the
SMTP.js script -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Professional Timesheet</title>
<style>
/* Styling the submit button */
button {
background-color: lightgreen; /* Light green color */
color: white; /* Text color */
border: none; /* Remove border */
padding: 10px 20px; /* Increase padding for width and height */
font-size: 16px; /* Font size */
cursor: pointer; /* Change cursor to pointer on hover */
width: 100px; /* Set button width */
}
<style>
/* General Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Roboto', sans-serif;
background: #ffffff;
color: #1e1d1d;
padding: 20px;
}
.timesheet-container {
max-width: 1200px;
margin: 0 auto;
background: #ffffff;
border: 1px solid #ccc;
border-radius: 5px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
padding: 20px;
overflow-y:auto;
}
h2 {
text-align: left;
font-weight: 700;
color:rgb(8, 2, 92);
margin-bottom: 20px;
}
/* Header Inputs */
.header {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 15px;
margin-bottom: 20px;
}
.header label {
display: flex;
flex-direction: column;
font-size: 14px;
font-weight: 500;
color: #555;
}
table th {
background-color:rgb(24, 30, 102);
color: #ffffff;
text-transform: uppercase;
font-size: 12px;
font-weight: 500;
padding: 10px;
border: 1px solid #ddd;
}
table td {
padding: 10px;
border: 1px solid #ddd;
font-size: 14px;
background-color: #fefefe;
}
table tr:nth-child(even) td {
background-color: #f7f7f7;
}
.weekend td {
background-color:rgb(156, 255, 164);
}
.input-box {
width: 30%;
margin-right: 10px;
padding: 6px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 12px;
}
.add-button {
background-color: #4CAF50;
color: white;
border: none;
padding: 5px 8px;
border-radius: 4px;
cursor: pointer;
font-size: 12px;
}
.add-button:hover {
background-color: #45a049;
}
.totals {
margin-top: 20px;
display: flex;
justify-content: flex-end;
font-size: 14px;
font-weight: 500;
color: #333;
}
.totals div {
margin-left: 20px;
}
.project-container .entry-row {
display: flex;
align-items: center;
margin-bottom: 5px;
}
</style>
</head>
<body>
<div class="timesheet-container">
<th>
Month:
<input type="month" id="month" onchange="updateDates()">
</th>
</div>
<script>
function updateDates() {
const monthInput = document.getElementById('month').value;
if (!monthInput) return;
function generateEntryRow() {
return `
<div class="entry-row">
<input type="text" class="input-box" placeholder="Enter
project">
<input type="text" class="input-box" placeholder="Enter task">
<input type="number" class="input-box hours-input"
placeholder="Enter no of hours worked" min="0" onchange="updateTotalHours()">
<button class="add-button" onclick="addRow(this)">+</button>
</div>
`;
}
function addRow(button) {
const projectContainer = button.closest('.project-container');
projectContainer.insertAdjacentHTML('beforeend', generateEntryRow());
}
function updateTotalHours() {
let totalHours = 0;
document.querySelectorAll('.hours-input').forEach(input => {
totalHours += Number(input.value) || 0;
});
document.getElementById('total-hours').textContent = totalHours;
}
</script>
</form>
</body>
</html>