Contents
Track and manage staff duties, schedules, and performance reports
Office Management System
Track and manage staff duties, schedules, and performance reports
Add/Edit Duty Assignment
Duty Roster
No Duty Assignments Yet
Add your first duty assignment using the form on the left
`);
printWindow.document.close();
printWindow.print();
}
function copyDuties() {
const currentUser = userManager.getCurrentUser();
let textToCopy = `OFFICE DUTY ROSTER\n`;
textToCopy += `Generated: ${new Date().toLocaleDateString()}\n`;
textToCopy += `Generated by: ${currentUser.name}\n\n`;
duties.forEach(duty => {
textToCopy += `Name: ${duty.name}\n`;
textToCopy += `Duty: ${duty.duty}\n`;
textToCopy += `Time: ${duty.customTime || duty.time}\n`;
textToCopy += `Days: ${duty.days.length} shifts\n`;
const reportCount = duty.performanceReports ? duty.performanceReports.length : 0;
textToCopy += `Performance Reports: ${reportCount}\n`;
textToCopy += `----------------------------------------\n`;
});
textToCopy += `\nTotal Persons: ${duties.length}`;
navigator.clipboard.writeText(textToCopy)
.then(() => alert('Duty roster copied to clipboard!'))
.catch(err => {
console.error('Failed to copy: ', err);
const textArea = document.createElement('textarea');
textArea.value = textToCopy;
document.body.appendChild(textArea);
textArea.select();
document.execCommand('copy');
document.body.removeChild(textArea);
alert('Duty roster copied to clipboard!');
});
}
function emailDuties() {
const currentUser = userManager.getCurrentUser();
let emailSubject = `Office Duty Roster - ${new Date().toLocaleDateString()}`;
let emailBody = `Dear Team,\n\nHere is the current duty roster:\n\n`;
emailBody += `Generated by: ${currentUser.name}\n\n`;
duties.forEach(duty => {
const reportCount = duty.performanceReports ? duty.performanceReports.length : 0;
emailBody += `• ${duty.name} - ${duty.duty} (${duty.customTime || duty.time})\n`;
emailBody += ` Shifts: ${duty.days.length}, Performance Reports: ${reportCount}\n`;
emailBody += ` ${duty.description}\n\n`;
});
emailBody += `\nTotal Persons: ${duties.length}\n\n`;
emailBody += `Best regards,\n${currentUser.name}\nOffice Management System`;
const mailtoLink = `mailto:?subject=${encodeURIComponent(emailSubject)}&body=${encodeURIComponent(emailBody)}`;
window.location.href = mailtoLink;
}
function downloadCSV() {
const currentUser = userManager.getCurrentUser();
let csvContent = "data:text/csv;charset=utf-8,";
csvContent += "Name,Duty,Time,Days,Performance Reports,Created By\n";
duties.forEach(duty => {
const formattedDates = duty.days.map(date => {
const d = new Date(date);
return d.getDate();
}).join(', ');
const reportCount = duty.performanceReports ? duty.performanceReports.length : 0;
const createdBy = duty.createdBy === currentUser.id ? 'You' : 'Other';
const row = [
`"${duty.name}"`,
`"${duty.duty}"`,
`"${duty.customTime || duty.time}"`,
`"${formattedDates}"`,
`"${reportCount}"`,
`"${createdBy}"`
].join(',');
csvContent += row + "\n";
});
const encodedUri = encodeURI(csvContent);
const link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", `duty_roster_${new Date().toISOString().slice(0,10)}.csv`);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
