Perales - Final Project Comprog 2
Perales - Final Project Comprog 2
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Employee Management System</title>
<style>
body {
background: linear-gradient(135deg, #3498db, #ffffff);
background-size: 400% 400%;
animation: gradientAnimation 10s ease infinite;
}
@keyframes gradientAnimation {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
.container {
width: 800px;
height: 500px;
margin: 20px auto;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
position: fixed;
top: 30%;
left: 30%;
transform: translate(-30%, -30%);
}
}
h1 {
text-align: center;
color: #333;
}
button {
display: block;
width: 100%;
padding: 10px;
margin: 10px 0;
font-size: 16px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0056b3;
}
.output {
margin-top: 20px;
padding: 10px;
background-color: #f7f7f7;
border: 1px solid #ccc;
border-radius: 4px;
white-space: pre-wrap;
font-size: 14px;
}
</style>
</head>
<body background="A.jpeg">
<div class="container">
<h1>Employee Management System</h1>
<button onclick="addEmployee()">Add Employee</button>
<button onclick="printAllEmployees()">Print All Employees</button>
<button onclick="manageDeduction()">Manage Deduction</button>
<button onclick="calculateSalaryAndDeduction()">Calculate Salary and
Deduction</button>
<button onclick="changeDailySalary()">Change Daily Salary</button>
<button onclick="deleteEmployee()">Delete Employee</button>
<script>
let employees = [];
function addEmployee() {
let name = prompt("Enter employee name:");
if (name === "" || name === "") return;
let department = prompt("Enter department name (SOAST, SOB, SOTE):");
if (department === "" || department === "") return;
let dailySalary = parseFloat(prompt("Enter daily salary:").replace(',', ''));
if (isNaN(dailySalary)) return;
employees.push({
name: name,
department: department,
dailySalary: dailySalary,
pagIbigDeduction: 0,
sssDeduction: 0,
philhealthDeduction: 0,
absences: 0
});
alert(`Employee ${name} added successfully.`);
updateOutput(`Employee ${name} added successfully.`);
}
function printAllEmployees() {
let printData = "Employee Records:\n";
employees.forEach(employee => {
printData += `Name: ${employee.name}, Department: ${employee.department},
Daily Salary: ₱${employee.dailySalary.toFixed(2)}, Pag-Ibig Deduction: ₱$
{employee.pagIbigDeduction.toFixed(2)}, SSS Deduction: ₱$
{employee.sssDeduction.toFixed(2)}, Philhealth Deduction: ₱$
{employee.philhealthDeduction.toFixed(2)}, Absences: ${employee.absences}\n`;
});
updateOutput(printData);
}
function manageDeduction() {
let option = prompt("Enter option:\n1. Set Deduction\n2. Back to Menu");
if (option === "" || option === "") return;
function calculateSalaryAndDeduction() {
let name = prompt("Enter employee name:");
if (name === "" || name === "") return;
let employee = employees.find(emp => emp.name === name);
if (employee) {
let totalDeduction = employee.pagIbigDeduction + employee.sssDeduction +
employee.philhealthDeduction;
let netSalary = employee.dailySalary * (30 - employee.absences) -
totalDeduction;
alert(`Employee: ${name}\nNet Salary: ₱${netSalary.toFixed(2)}\nTotal
Deduction: ₱${totalDeduction.toFixed(2)}`);
updateOutput(`Employee: ${name}\nNet Salary: ₱${netSalary.toFixed(2)}\
nTotal Deduction: ₱${totalDeduction.toFixed(2)}`);
} else {
alert("Employee not found!");
updateOutput("Employee not found!");
}
}
function changeDailySalary() {
let name = prompt("Enter employee name:");
if (name === "" || name === "") return;
let newDailySalary = parseFloat(prompt("Enter new daily
salary:").replace(',', ''));
if (isNaN(newDailySalary)) return;
let employee = employees.find(emp => emp.name === name);
if (employee) {
employee.dailySalary = newDailySalary;
alert(`${name} daily salary changed to ₱${newDailySalary.toFixed(2)}.`);
updateOutput(`${name} daily salary changed to ₱$
{newDailySalary.toFixed(2)}.`);
} else {
alert("Employee not found!");
updateOutput("Employee not found!");
}
}
function deleteEmployee() {
let name = prompt("Enter employee name to delete:");
if (name === "" || name === "") return;
let index = employees.findIndex(emp => emp.name === name);
if (index !== -1) {
employees.splice(index, 1);
alert(`Employee ${name} deleted successfully.`);
updateOutput(`Employee ${name} deleted successfully.`);
} else {
alert("Employee not found!");
updateOutput("Employee not found!");
}
}
function updateOutput(message) {
document.getElementById("output").innerText = message;
}
</script>
</body>
</html>