!DOCTYPE html
!DOCTYPE html
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard</title>
<!-- Add Bootstrap CSS for styling -->
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
rel="stylesheet">
<style>
body {
display: flex;
min-height: 100vh;
margin: 0;
}
/* Sidebar styles */
.sidebar {
width: 250px;
background-color: #f8f9fa;
padding: 15px;
height: 100vh;
position: fixed;
}
.sidebar .admin-info {
text-align: center;
margin-bottom: 30px;
}
.sidebar .admin-info img {
width: 100px;
height: 100px;
border-radius: 50%;
margin-bottom: 15px;
}
.main-content {
margin-left: 270px; /* Adjust according to the sidebar width */
padding: 20px;
width: 100%;
}
.table-container {
margin-bottom: 40px;
}
.action-btn {
margin: 0 5px;
}
</style>
</head>
<body>
{% else %}
<!-- User Form Submission View -->
<h2>Submit an Anomaly</h2>
<form method="post" enctype="multipart/form-data" class="mb-4">
{% csrf_token %}
<div class="row mb-3">
<div class="col">
<input type="text" name="bl_number" class="form-control"
placeholder="BL Number" required>
</div>
<div class="col">
<input type="text" name="shift" class="form-control"
placeholder="Shift" required>
</div>
</div>
<div class="row mb-3">
<div class="col">
<input type="text" name="anomaly" class="form-control"
placeholder="Anomaly" required>
</div>
<div class="col">
<input type="text" name="subcategory" class="form-control"
placeholder="Subcategory">
</div>
</div>
<div class="mb-3">
<textarea name="comment" class="form-control"
placeholder="Comment"></textarea>
</div>
<div class="mb-3">
<input type="file" name="file" class="form-control">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
{% endif %}
</div>
if (editingRow) {
updateUser();
} else {
addUser();
}
});
function addUser() {
const table =
document.getElementById('userTable').getElementsByTagName('tbody')[0];
const rowCount = table.rows.length + 1; // Calculate the new row number
const firstName = document.getElementById('firstName').value;
const lastName = document.getElementById('lastName').value;
function deleteUser(button) {
const row = button.parentNode.parentNode; // Get the row to delete
row.parentNode.removeChild(row); // Remove the row from the table
updateRowNumbers(); // Update row numbers
}
function editUser(button) {
editingRow = button.parentNode.parentNode; // Get the row to edit
const cells = editingRow.getElementsByTagName('td');
document.getElementById('firstName').value = cells[0].innerText;
document.getElementById('lastName').value = cells[1].innerText;
function updateUser() {
const firstName = document.getElementById('firstName').value;
const lastName = document.getElementById('lastName').value;
function resetForm() {
document.getElementById('userForm').reset();
}
function updateRowNumbers() {
const table =
document.getElementById('userTable').getElementsByTagName('tbody')[0];
for (let i = 0; i < table.rows.length; i++) {
table.rows[i].getElementsByTagName('th')[0].innerText = i + 1;
}
}
document.getElementById('recordForm').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent form from submitting traditionally
if (editingRecord) {
updateRecord();
} else {
addRecord();
}
});
function addRecord() {
const table =
document.getElementById('recordTable').getElementsByTagName('tbody')[0];
const recordLink = document.getElementById('recordLink').value;
const userName = document.getElementById('userName').value;
const currentTime = new Date().toLocaleString();
function deleteRecord(button) {
const row = button.parentNode.parentNode; // Get the row to delete
row.parentNode.removeChild(row); // Remove the row from the table
}
function editRecord(button) {
editingRecord = button.parentNode.parentNode; // Get the row to edit
const cells = editingRecord.getElementsByTagName('td');
document.getElementById('recordLink').value = cells[0].innerText;
document.getElementById('userName').value = cells[1].innerText;
function updateRecord() {
const recordLink = document.getElementById('recordLink').value;
const userName = document.getElementById('userName').value;
const currentTime = new Date().toLocaleString();