huge update

This commit is contained in:
sankalp committed 2025-04-20 17:46:30 +05:45
1 parent 8072284990
commit f2c72885a6
123 files changed
+25119 -4984

No files matched your search

@@ -0,0 +1,73 @@
{% load static %}
<!-- Add Meeting Modal -->
<div id="addMeetingModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeAddMeetingModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 600px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto;">
<div style="background-color: #3F51B5; color: white; padding: 12px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1;">
<h5 style="margin: 0; font-size: 18px;">Schedule New Meeting</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeAddMeetingModal()">&times;</button>
</div>
<div style="padding: 15px;">
<form id="addMeetingForm">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
<!-- Left Column -->
<div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;" for="meetingDate">Date</label>
<input type="date" id="meetingDate" name="meeting_date" required style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;" for="meetingTime">Time</label>
<input type="time" id="meetingTime" name="meeting_time" required style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;" for="duration">Duration (minutes)</label>
<input type="number" id="duration" name="duration" min="15" max="120" value="30" required style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
</div>
<!-- Right Column -->
<div>
<div style="margin-bottom: 12px;">
<div style="display: flex; align-items: center;">
<input type="checkbox" id="isOnline" name="is_online" style="margin-right: 8px;">
<label for="isOnline" style="font-weight: 500;">Online Meeting</label>
</div>
</div>
<div id="meetingLinkContainer" style="margin-bottom: 12px; display: none;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;" for="meetingLink">Meeting Link</label>
<input type="url" id="meetingLink" name="meeting_link" value="" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
</div>
</div>
<!-- Full Width Sections -->
<div style="margin-top: 15px;">
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;" for="agenda">Agenda</label>
<textarea id="agenda" name="agenda" rows="3" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; min-height: 60px;"></textarea>
</div>
</div>
</form>
</div>
<div style="padding: 12px; border-top: 1px solid #EEEEEE; text-align: right; position: sticky; bottom: 0; background-color: white; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;">
<button type="button" style="background-color: #9E9E9E; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-right: 8px;" onclick="closeAddMeetingModal()">Cancel</button>
<button type="button" style="background-color: #3F51B5; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px;" onclick="submitAddMeetingForm()">Schedule Meeting</button>
</div>
</div>
</div>
<script>
// Toggle meeting link field based on online/in-person selection
document.addEventListener('DOMContentLoaded', function() {
if (document.getElementById('isOnline')) {
document.getElementById('isOnline').addEventListener('change', function() {
const meetingLinkContainer = document.getElementById('meetingLinkContainer');
const meetingLinkInput = document.getElementById('meetingLink');
meetingLinkContainer.style.display = this.checked ? 'block' : 'none';
meetingLinkInput.required = this.checked;
});
}
});
</script>
+364
View File
@@ -0,0 +1,364 @@
{% load static %}
<!-- Add Routine Modal -->
<div id="addRoutineModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeAddRoutineModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 600px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Add Class Routine</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeAddRoutineModal()">&times;</button>
</div>
<form id="addRoutineForm">
{% csrf_token %}
<div style="padding: 20px;">
<div style="margin-bottom: 15px;">
<label for="periodSelect" style="display: block; margin-bottom: 8px; font-weight: 500;">{% if course.duration_type == 'Semester' %}Semester{% else %}Year{% endif %}</label>
<select id="periodSelect" name="period_select" style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;" required>
<option value="">Select {% if course.duration_type == 'Semester' %}Semester{% else %}Year{% endif %}</option>
<!-- Options will be populated dynamically via JavaScript -->
</select>
</div>
<!-- Subject list container - subjects will be added here dynamically -->
<div id="subjectsContainer" style="margin-bottom: 15px; max-height: 400px; overflow-y: auto;"></div>
<input type="hidden" id="periodOrYear" name="period_or_year">
</div>
<div style="padding: 15px; border-top: 1px solid #EEEEEE; text-align: right; display: flex; flex-wrap: wrap; justify-content: flex-end;">
<button type="button" style="background-color: #9E9E9E; color: white; border: none; padding: 8px 16px; border-radius: 4px; margin-right: 10px; margin-bottom: 10px; cursor: pointer; font-size: 14px;" onclick="closeAddRoutineModal()">Cancel</button>
<button type="button" style="background-color: #3F51B5; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-bottom: 10px;" onclick="submitAddRoutineForm()">Save</button>
</div>
</form>
</div>
</div>
<script>
// Store all subject data for use in the form
const allSubjects = [
{% for subject in subjects %}
{
id: {{ subject.id }},
name: "{{ subject.name }}",
period: "{{ subject.period_or_year }}"
},
{% endfor %}
];
function openAddRoutineModal() {
const modal = document.getElementById('addRoutineModal');
if (modal) {
// Reset form
document.getElementById('addRoutineForm').reset();
document.getElementById('subjectsContainer').innerHTML = '';
// Populate period dropdown dynamically
const periodSelect = document.getElementById('periodSelect');
const periodLabel = {% if course.duration_type == 'Semester' %}'Semester'{% else %}'Year'{% endif %};
// Try to get the course data from the page
const courseElement = document.querySelector('#routineSection');
const courseId = courseElement?.getAttribute('data-course-id') ||
window.location.pathname.match(/\/hod\/(\d+)/)?.at(1);
// Default to 3 periods if we can't determine
let totalPeriods = 3;
{% if course.total_periods %}
// If we have it from the template, use that
totalPeriods = {{ course.total_periods }};
console.log("Using course periods from template:", totalPeriods);
{% endif %}
// Clear all options
periodSelect.innerHTML = '';
// Add placeholder option
periodSelect.innerHTML = `<option value="">Select ${periodLabel}</option>`;
// Add options based on total periods
console.log(`Adding ${totalPeriods} period options`);
for (let i = 1; i <= totalPeriods; i++) {
periodSelect.innerHTML += `<option value="${i}">${periodLabel} ${i}</option>`;
}
// Setup period selection change listener
periodSelect.onchange = function() {
const selectedPeriod = this.value;
document.getElementById('periodOrYear').value = selectedPeriod;
// Clear existing subjects
const subjectsContainer = document.getElementById('subjectsContainer');
subjectsContainer.innerHTML = '';
if (selectedPeriod) {
// Filter subjects for the selected period
const periodSubjects = allSubjects.filter(subject => subject.period === selectedPeriod);
if (periodSubjects.length === 0) {
subjectsContainer.innerHTML = '<p style="text-align: center; padding: 10px;">No subjects found for this period.</p>';
return;
}
// Create a form section for each subject
periodSubjects.forEach(subject => {
const subjectDiv = document.createElement('div');
subjectDiv.className = 'subject-item';
subjectDiv.style.padding = '15px';
subjectDiv.style.marginBottom = '15px';
subjectDiv.style.border = '1px solid #EEEEEE';
subjectDiv.style.borderRadius = '4px';
// Create subject header
const subjectHeader = document.createElement('h4');
subjectHeader.textContent = subject.name;
subjectHeader.style.margin = '0 0 10px 0';
subjectHeader.style.fontSize = '16px';
subjectDiv.appendChild(subjectHeader);
// Add hidden input for subject ID
const subjectIdInput = document.createElement('input');
subjectIdInput.type = 'hidden';
subjectIdInput.name = `subject_id_${subject.id}`;
subjectIdInput.value = subject.id;
subjectDiv.appendChild(subjectIdInput);
// Create inline form row
const formRow = document.createElement('div');
formRow.style.display = 'flex';
formRow.style.flexWrap = 'wrap';
formRow.style.gap = '10px';
formRow.style.alignItems = 'flex-end';
// Create teacher dropdown
const teacherDiv = document.createElement('div');
teacherDiv.style.flex = '2';
teacherDiv.style.minWidth = '180px';
const teacherLabel = document.createElement('label');
teacherLabel.textContent = 'Teacher';
teacherLabel.style.display = 'block';
teacherLabel.style.marginBottom = '5px';
teacherLabel.style.fontWeight = '500';
teacherDiv.appendChild(teacherLabel);
const teacherSelect = document.createElement('select');
teacherSelect.name = `teacher_id_${subject.id}`;
teacherSelect.style.width = '100%';
teacherSelect.style.padding = '10px';
teacherSelect.style.border = '1px solid #BDBDBD';
teacherSelect.style.borderRadius = '4px';
teacherSelect.style.boxSizing = 'border-box';
teacherSelect.required = true;
// Add default option
const defaultOption = document.createElement('option');
defaultOption.value = '';
defaultOption.textContent = 'Select Teacher';
teacherSelect.appendChild(defaultOption);
// Add teacher options
{% for teacher in staff %}
const teacherOption_{{ teacher.id }} = document.createElement('option');
teacherOption_{{ teacher.id }}.value = '{{ teacher.id }}';
teacherOption_{{ teacher.id }}.textContent = '{{ teacher.name }}';
teacherSelect.appendChild(teacherOption_{{ teacher.id }});
{% endfor %}
teacherDiv.appendChild(teacherSelect);
formRow.appendChild(teacherDiv);
// Start time
const startTimeDiv = document.createElement('div');
startTimeDiv.style.flex = '1';
startTimeDiv.style.minWidth = '120px';
const startTimeLabel = document.createElement('label');
startTimeLabel.textContent = 'Start Time';
startTimeLabel.style.display = 'block';
startTimeLabel.style.marginBottom = '5px';
startTimeLabel.style.fontWeight = '500';
startTimeDiv.appendChild(startTimeLabel);
const startTimeInput = document.createElement('input');
startTimeInput.type = 'time';
startTimeInput.name = `start_time_${subject.id}`;
startTimeInput.style.width = '100%';
startTimeInput.style.padding = '10px';
startTimeInput.style.border = '1px solid #BDBDBD';
startTimeInput.style.borderRadius = '4px';
startTimeInput.style.boxSizing = 'border-box';
startTimeInput.required = true;
startTimeDiv.appendChild(startTimeInput);
formRow.appendChild(startTimeDiv);
// End time
const endTimeDiv = document.createElement('div');
endTimeDiv.style.flex = '1';
endTimeDiv.style.minWidth = '120px';
const endTimeLabel = document.createElement('label');
endTimeLabel.textContent = 'End Time';
endTimeLabel.style.display = 'block';
endTimeLabel.style.marginBottom = '5px';
endTimeLabel.style.fontWeight = '500';
endTimeDiv.appendChild(endTimeLabel);
const endTimeInput = document.createElement('input');
endTimeInput.type = 'time';
endTimeInput.name = `end_time_${subject.id}`;
endTimeInput.style.width = '100%';
endTimeInput.style.padding = '10px';
endTimeInput.style.border = '1px solid #BDBDBD';
endTimeInput.style.borderRadius = '4px';
endTimeInput.style.boxSizing = 'border-box';
endTimeInput.required = true;
endTimeDiv.appendChild(endTimeInput);
formRow.appendChild(endTimeDiv);
// Add the form row to the subject div
subjectDiv.appendChild(formRow);
// Add the subject div to the container
subjectsContainer.appendChild(subjectDiv);
});
}
};
// Show modal
modal.style.display = 'block';
document.body.style.overflow = 'hidden';
}
}
function closeAddRoutineModal() {
const modal = document.getElementById('addRoutineModal');
if (modal) {
modal.style.display = 'none';
document.body.style.overflow = '';
}
}
// Make functions available globally
if (typeof window !== 'undefined') {
window.openAddRoutineModal = openAddRoutineModal;
window.closeAddRoutineModal = closeAddRoutineModal;
}
// Add form submission function
function submitAddRoutineForm() {
const form = document.getElementById('addRoutineForm');
if (!form) {
console.error('Add routine form not found');
return;
}
// Get selected period
const periodSelect = document.getElementById('periodSelect');
const selectedPeriod = periodSelect.value;
if (!selectedPeriod) {
alert('Please select a period');
return;
}
// Get selected subjects
const subjectItems = document.querySelectorAll('.subject-item');
if (subjectItems.length === 0) {
alert('No subjects available for this period');
return;
}
// Check if any item has incomplete data
let hasIncompleteData = false;
subjectItems.forEach(item => {
const teacherSelect = item.querySelector('select');
const startTime = item.querySelector('input[type="time"][name^="start_time_"]');
const endTime = item.querySelector('input[type="time"][name^="end_time_"]');
if (!teacherSelect.value || !startTime.value || !endTime.value) {
hasIncompleteData = true;
}
});
if (hasIncompleteData) {
alert('Please fill in all required fields for each subject');
return;
}
// Prepare requests to be sent
const requests = [];
// Common data
const courseId = document.querySelector('#routineSection')?.getAttribute('data-course-id') ||
window.location.pathname.match(/\/hod\/(\d+)/)?.at(1);
if (!courseId) {
alert('Course ID not found');
return;
}
// Create a request for each subject
subjectItems.forEach(item => {
const subjectId = item.querySelector('input[type="hidden"]').value;
const teacherId = item.querySelector('select').value;
const startTime = item.querySelector('input[name^="start_time_"]').value;
const endTime = item.querySelector('input[name^="end_time_"]').value;
const formData = new FormData();
formData.append('course_id', courseId);
formData.append('subject_id', subjectId);
formData.append('teacher_id', teacherId);
formData.append('start_time', startTime);
formData.append('end_time', endTime);
formData.append('period_or_year', selectedPeriod);
requests.push(
fetch('/app/api/hod/routines/', {
method: 'POST',
body: formData,
headers: {
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
}
})
);
});
// Send all requests and handle responses
Promise.all(requests.map(p => p.catch(e => e)))
.then(responses => {
const allSuccessful = responses.every(res => !(res instanceof Error) && res.ok);
if (allSuccessful) {
if (typeof window.showMessageModal === 'function') {
window.showMessageModal('Success', 'All routines added successfully');
} else if (typeof window.showToast === 'function') {
window.showToast('success', 'All routines added successfully');
} else {
alert('All routines added successfully');
}
closeAddRoutineModal();
setTimeout(() => {
window.location.reload();
}, 1000);
} else {
if (typeof window.showMessageModal === 'function') {
window.showMessageModal('Error', 'Some routines could not be added');
} else if (typeof window.showToast === 'function') {
window.showToast('error', 'Some routines could not be added');
} else {
alert('Some routines could not be added');
}
}
})
.catch(error => {
console.error('Error adding routines:', error);
alert('Failed to add routines: ' + error.message);
});
}
// Make submission function globally available
if (typeof window !== 'undefined') {
window.submitAddRoutineForm = submitAddRoutineForm;
}
</script>
+126
View File
@@ -0,0 +1,126 @@
{% load static %}
<div id="addStaffModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeAddStaffModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 800px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto;">
<div style="background-color: #3F51B5; color: white; padding: 12px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1;">
<h5 style="margin: 0; font-size: 18px;">Add New Staff</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeAddStaffModal()">&times;</button>
</div>
<div style="padding: 15px;">
<form id="addStaffForm">
{% csrf_token %}
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
<!-- Left Column -->
<div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Name <span style="color: red;">*</span></label>
<input type="text" id="addStaffName" name="name" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;" required>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Phone <span style="color: red;">*</span></label>
<input type="tel" id="addStaffPhone" name="phone" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;" required pattern="[0-9]{10}" maxlength="10" title="Please enter a 10-digit phone number">
<small style="color: #666; display: block; margin-top: 2px; font-size: 11px;">This will be used as the login ID</small>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Email</label>
<input type="email" id="addStaffEmail" name="email" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Gender</label>
<select id="addStaffGender" name="gender" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
<option value="">Select Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Other">Other</option>
</select>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Birth Date</label>
<input type="date" id="addStaffBirthDate" name="birth_date" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
</div>
<!-- Right Column -->
<div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Assigned Subjects <span style="color: red;">*</span></label>
<select id="addStaffSubjects" name="subjects[]" multiple style="width: 100%; min-height: 100px; padding: 6px; border: 1px solid #ddd; border-radius: 4px;" required>
{% for subject in subjects %}
<option value="{{ subject.id }}">
{{ subject.name }} {% if course.duration_type == 'Semester' %}(Semester {{ subject.period_or_year }}){% else %}(Year {{ subject.period_or_year }}){% endif %}
</option>
{% empty %}
<option value="" disabled>No subjects available</option>
{% endfor %}
</select>
<small style="color: #666; display: block; margin-top: 2px; font-size: 11px;">Hold Ctrl/Cmd to select multiple subjects</small>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Temporary Address</label>
<input type="text" id="addStaffTempAddress" name="temporary_address" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Permanent Address</label>
<input type="text" id="addStaffPermAddress" name="permanent_address" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Marital Status</label>
<select id="addStaffMaritalStatus" name="marital_status" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
<option value="">Select Marital Status</option>
<option value="Married">Married</option>
<option value="Unmarried">Unmarried</option>
<option value="Divorced">Divorced</option>
</select>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Citizenship Number</label>
<input type="text" id="addStaffCitizenshipNo" name="citizenship_no" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
</div>
</div>
</form>
</div>
<div style="padding: 12px; border-top: 1px solid #EEEEEE; text-align: right; position: sticky; bottom: 0; background-color: white; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;">
<button type="button" style="background-color: #9E9E9E; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-right: 8px;" onclick="closeAddStaffModal()">Cancel</button>
<button type="button" style="background-color: #3F51B5; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px;" onclick="submitAddStaffForm()">Add Staff</button>
</div>
</div>
</div>
<script>
function openAddStaffModal() {
document.getElementById('addStaffModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closeAddStaffModal() {
document.getElementById('addStaffModal').style.display = 'none';
document.body.style.overflow = '';
document.getElementById('addStaffForm').reset();
}
function submitAddStaffForm() {
const formData = new FormData(document.getElementById('addStaffForm'));
fetch('/app/add-staff/', {
method: 'POST',
body: formData,
headers: {
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
closeAddStaffModal();
showMessageModal('Success', 'Staff member added successfully. Default password is: 123');
// Refresh the staff list
location.reload();
} else {
showMessageModal('Error', data.message);
}
})
.catch(error => {
showMessageModal('Error', 'Failed to add staff member.');
});
}
</script>
+145
View File
@@ -0,0 +1,145 @@
{% load static %}
<!-- Add Student Modal -->
<div id="addStudentModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeAddStudentModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 800px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto;">
<div style="background-color: #3F51B5; color: white; padding: 12px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1;">
<h5 style="margin: 0; font-size: 18px;">Add New Student</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeAddStudentModal()">&times;</button>
</div>
<div style="padding: 15px;">
<form id="addStudentForm">
{% csrf_token %}
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
<!-- Left Column -->
<div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Name <span style="color: red;">*</span></label>
<input type="text" id="addStudentName" name="name" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;" required>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Phone <span style="color: red;">*</span></label>
<input type="tel" id="addStudentPhone" name="phone" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;" required pattern="[0-9]{10}" maxlength="10" title="Please enter a 10-digit phone number">
<small style="color: #666; display: block; margin-top: 2px; font-size: 11px;">This will be used as the login ID</small>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Batch <span style="color: red;">*</span></label>
<select id="addStudentBatch" name="batch" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;" required>
<option value="">Select Batch</option>
{% for batch in batches %}
<option value="{{ batch.id }}">{{ batch.name }}</option>
{% endfor %}
</select>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Status <span style="color: red;">*</span></label>
<select id="addStudentStatus" name="status" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;" required>
<option value="">Select Status</option>
<option value="Active">Active</option>
<option value="Leave">Leave</option>
<option value="Completed">Completed</option>
</select>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Email</label>
<input type="email" id="addStudentEmail" name="email" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Gender</label>
<select id="addStudentGender" name="gender" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
<option value="">Select Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Other">Other</option>
</select>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Birth Date</label>
<input type="date" id="addStudentBirthDate" name="birth_date" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
</div>
<!-- Right Column -->
<div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Temporary Address</label>
<textarea id="addStudentTempAddress" name="temporary_address" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px; min-height: 60px;"></textarea>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Permanent Address</label>
<textarea id="addStudentPermAddress" name="permanent_address" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px; min-height: 60px;"></textarea>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Parent/Guardian Name</label>
<input type="text" id="addStudentParentName" name="parent_name" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Parent/Guardian Phone <span style="color: red;">*</span></label>
<input type="tel" id="addStudentParentPhone" name="parent_phone" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;" required pattern="[0-9]{10}" maxlength="10" title="Please enter a 10-digit phone number">
<small style="color: #666; display: block; margin-top: 2px; font-size: 11px;">This will be used to create parent account</small>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Citizenship Number</label>
<input type="text" id="addStudentCitizenshipNo" name="citizenship_no" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
</div>
</div>
</form>
</div>
<div style="padding: 12px; border-top: 1px solid #EEEEEE; text-align: right; position: sticky; bottom: 0; background-color: white; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;">
<button type="button" style="background-color: #9E9E9E; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-right: 8px;" onclick="closeAddStudentModal()">Cancel</button>
<button type="button" style="background-color: #3F51B5; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px;" onclick="submitAddStudentForm()">Add Student</button>
</div>
</div>
</div>
<script>
function openAddStudentModal() {
document.getElementById('addStudentModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closeAddStudentModal() {
document.getElementById('addStudentModal').style.display = 'none';
document.body.style.overflow = '';
document.getElementById('addStudentForm').reset();
}
function submitAddStudentForm() {
const formData = new FormData(document.getElementById('addStudentForm'));
fetch('{% url "add_student" %}', {
method: 'POST',
body: formData,
headers: {
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
}
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.text().then(text => {
try {
return JSON.parse(text);
} catch (e) {
console.error('Invalid JSON response:', text);
throw new Error('Invalid JSON response from server');
}
});
})
.then(data => {
if (data.success) {
closeAddStudentModal();
showMessageModal('Success', data.message);
// Refresh the student list
location.reload();
} else {
showMessageModal('Error', data.message || 'Failed to add student');
}
})
.catch(error => {
console.error('Error:', error);
showMessageModal('Error', error.message || 'Failed to add student. Please try again.');
});
}
</script>
+106
View File
@@ -0,0 +1,106 @@
{% load static %}
{% load app_filters %}
<!-- Add Subject Modal -->
<div id="addSubjectModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeAddSubjectModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 500px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Add New Subject</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeAddSubjectModal()">&times;</button>
</div>
<form id="addSubjectForm" action="{% url 'add_subject' %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<div style="padding: 20px;">
<div style="margin-bottom: 15px;">
<label for="subjectName" style="display: block; margin-bottom: 8px; font-weight: 500;">Subject Name</label>
<input type="text" id="subjectName" name="name" required style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
</div>
<div style="margin-bottom: 15px;">
<label for="subjectCode" style="display: block; margin-bottom: 8px; font-weight: 500;">Subject Code</label>
<input type="text" id="subjectCode" name="code" style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
</div>
<div style="margin-bottom: 15px;">
<label for="periodOrYear" style="display: block; margin-bottom: 8px; font-weight: 500;">Period/{{ course.duration_type }}</label>
<input type="number" id="periodOrYear" name="period_or_year" min="1" required style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
<small style="color: #666; display: block; margin-top: 5px;">
{% if course.duration_type == 'Semester' %}
Enter semester number (1-{{ course.duration|multiply:2 }})
{% else %}
Enter year number (1-{{ course.duration }})
{% endif %}
</small>
</div>
<div style="margin-bottom: 15px;">
<label for="syllabusPdf" style="display: block; margin-bottom: 8px; font-weight: 500;">Syllabus PDF</label>
<input type="file" id="syllabusPdf" name="syllabus_pdf" accept=".pdf" style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
<small style="color: #666; display: block; margin-top: 5px;">Upload syllabus or study material in PDF format</small>
</div>
</div>
<div style="padding: 15px; border-top: 1px solid #EEEEEE; text-align: right; display: flex; flex-wrap: wrap; justify-content: flex-end;">
<button type="button" style="background-color: #9E9E9E; color: white; border: none; padding: 8px 16px; border-radius: 4px; margin-right: 10px; margin-bottom: 10px; cursor: pointer; font-size: 14px;" onclick="closeAddSubjectModal()">Cancel</button>
<button type="submit" style="background-color: #3F51B5; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-bottom: 10px;">Add Subject</button>
</div>
</form>
</div>
</div>
<script>
function openAddSubjectModal() {
// Set max value for period/year input based on course duration
const periodInput = document.getElementById('periodOrYear');
{% if course.duration_type == 'Semester' %}
periodInput.max = {{ course.duration|multiply:2 }};
{% else %}
periodInput.max = {{ course.duration }};
{% endif %}
document.getElementById('addSubjectModal').style.display = 'block';
}
function closeAddSubjectModal() {
document.getElementById('addSubjectModal').style.display = 'none';
document.getElementById('addSubjectForm').reset();
}
// Handle form submission
document.getElementById('addSubjectForm').addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData(this);
// Validate period/year before submission
const periodInput = document.getElementById('periodOrYear');
const periodValue = parseInt(periodInput.value);
const maxPeriod = parseInt(periodInput.max);
if (periodValue > maxPeriod) {
{% if course.duration_type == 'Semester' %}
alert(`Semester number cannot exceed ${maxPeriod}`);
{% else %}
alert(`Year number cannot exceed ${maxPeriod}`);
{% endif %}
return;
}
fetch(this.action, {
method: 'POST',
body: formData,
headers: {
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
closeAddSubjectModal();
// Refresh the subjects table or add the new subject dynamically
location.reload();
} else {
alert(data.message || 'Error adding subject');
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while adding the subject');
});
});
</script>
@@ -0,0 +1,23 @@
<!-- Cancel Meeting Modal -->
<div id="cancelMeetingModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeCancelMeetingModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 600px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto;">
<div style="background-color: #3F51B5; color: white; padding: 12px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1;">
<h5 style="margin: 0; font-size: 18px;">Cancel Meeting</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeCancelMeetingModal()">&times;</button>
</div>
<div style="padding: 15px;">
<form id="cancelMeetingForm">
<input type="hidden" id="cancelMeetingId" name="meeting_id">
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;" for="cancellationReason">Reason for Cancellation</label>
<textarea id="cancellationReason" name="cancellation_reason" rows="3" required style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; min-height: 80px;"></textarea>
</div>
</form>
</div>
<div style="padding: 12px; border-top: 1px solid #EEEEEE; text-align: right; position: sticky; bottom: 0; background-color: white; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;">
<button type="button" style="background-color: #9E9E9E; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-right: 8px;" onclick="closeCancelMeetingModal()">Close</button>
<button type="button" style="background-color: #DC3545; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px;" onclick="submitCancelMeetingForm()">Cancel Meeting</button>
</div>
</div>
</div>
@@ -0,0 +1,43 @@
<!-- Cancellation Reason Modal -->
<div class="modal fade" id="cancellationReasonModal" tabindex="-1" aria-labelledby="cancellationReasonModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="cancellationReasonModalLabel">Cancellation Reason</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div id="cancellationReasonContent" class="p-3 bg-light rounded">
<!-- Cancellation reason content will be loaded here -->
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>
function viewCancellationReason(meetingId) {
fetch(`/api/meetings/${meetingId}/cancellation-reason/`)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok: ' + response.statusText);
}
return response.json();
})
.then(data => {
document.getElementById('cancellationReasonContent').innerHTML = data.reason || 'No reason provided';
new bootstrap.Modal(document.getElementById('cancellationReasonModal')).show();
})
.catch(error => {
console.error('Error fetching cancellation reason:', error);
showToast('Failed to load cancellation reason', 'error');
});
}
function closeCancellationReasonModal() {
bootstrap.Modal.getInstance(document.getElementById('cancellationReasonModal')).hide();
}
</script>
@@ -0,0 +1,79 @@
{% load static %}
<!-- Edit Meeting Modal -->
<div id="editMeetingModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeEditMeetingModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 600px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto;">
<div style="background-color: #3F51B5; color: white; padding: 12px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1;">
<h5 style="margin: 0; font-size: 18px;">Edit Meeting</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeEditMeetingModal()">&times;</button>
</div>
<div style="padding: 15px;">
<form id="editMeetingForm">
<input type="hidden" id="editMeetingId" name="meeting_id">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
<!-- Left Column -->
<div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;" for="editMeetingDate">Date</label>
<input type="date" id="editMeetingDate" name="meeting_date" required style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;" for="editMeetingTime">Time</label>
<input type="time" id="editMeetingTime" name="meeting_time" required style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;" for="editDuration">Duration (minutes)</label>
<input type="number" id="editDuration" name="duration" min="15" max="120" required style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
</div>
<!-- Right Column -->
<div>
<div style="margin-bottom: 12px;">
<div style="display: flex; align-items: center;">
<input type="checkbox" id="editIsOnline" name="is_online" style="margin-right: 8px;">
<label for="editIsOnline" style="font-weight: 500;">Online Meeting</label>
</div>
</div>
<div id="editMeetingLinkContainer" style="margin-bottom: 12px; display: none;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;" for="editMeetingLink">Meeting Link</label>
<input type="url" id="editMeetingLink" name="meeting_link" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
</div>
</div>
<!-- Full Width Sections -->
<div style="margin-top: 15px;">
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;" for="editAgenda">Agenda</label>
<textarea id="editAgenda" name="agenda" rows="3" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; min-height: 60px;"></textarea>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;" for="editNotes">Notes</label>
<textarea id="editNotes" name="notes" rows="3" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; min-height: 60px;"></textarea>
</div>
</div>
</form>
</div>
<div style="padding: 12px; border-top: 1px solid #EEEEEE; text-align: right; position: sticky; bottom: 0; background-color: white; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;">
<button type="button" style="background-color: #9E9E9E; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-right: 8px;" onclick="closeEditMeetingModal()">Cancel</button>
<button type="button" style="background-color: #3F51B5; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px;" onclick="submitEditMeetingForm()">Save Changes</button>
</div>
</div>
</div>
<script>
// Toggle meeting link field based on online/in-person selection
document.addEventListener('DOMContentLoaded', function() {
if (document.getElementById('editIsOnline')) {
document.getElementById('editIsOnline').addEventListener('change', function() {
const meetingLinkContainer = document.getElementById('editMeetingLinkContainer');
const meetingLinkInput = document.getElementById('editMeetingLink');
meetingLinkContainer.style.display = this.checked ? 'block' : 'none';
meetingLinkInput.required = this.checked;
});
}
});
</script>
@@ -0,0 +1,211 @@
{% load static %}
<!-- Edit Progress Modal -->
<div id="editProgressModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeEditProgressModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 600px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto;">
<div style="background-color: #3F51B5; color: white; padding: 12px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1;">
<h5 style="margin: 0; font-size: 18px;">Edit Student Progress</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeEditProgressModal()">&times;</button>
</div>
<div style="padding: 15px;">
<form id="editProgressForm">
{% csrf_token %}
<input type="hidden" id="edit_progress_id" name="progress_id">
<div style="margin-bottom: 15px;">
<div class="d-flex align-items-center mb-2">
<div id="student_profile_container" style="width: 40px; height: 40px; border-radius: 50%; background-color: #e0e0e0; overflow: hidden; margin-right: 10px; display: flex; align-items: center; justify-content: center;">
<img id="student_profile_image" src="{% static 'img/user.png' %}" alt="Student" style="width: 100%; height: 100%; object-fit: cover;">
</div>
<div>
<h6 id="student_name" style="margin: 0; font-weight: 600;"></h6>
<small id="student_batch" style="color: #666;"></small>
</div>
</div>
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Current Period <span style="color: red;">*</span></label>
<input type="number" id="edit_current_period" name="current_period" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;" required>
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Completion Percentage <span style="color: red;">*</span></label>
<input type="number" id="edit_completion_percentage" name="completion_percentage" min="0" max="100" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;" required>
<div style="margin-top: 10px;">
<div class="progress" style="height: 20px;">
<div id="completion_preview" class="progress-bar" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Progress Status</label>
<div>
<span id="edit_progress_status_display" class="badge bg-primary">In Progress</span>
<small class="text-muted d-block mt-1">Status is automatically determined based on completion percentage and dates</small>
</div>
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Notes</label>
<textarea id="edit_notes" name="notes" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; min-height: 100px;"></textarea>
</div>
</form>
</div>
<div style="padding: 12px; border-top: 1px solid #EEEEEE; text-align: right; position: sticky; bottom: 0; background-color: white; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;">
<button type="button" style="background-color: #9E9E9E; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-right: 8px;" onclick="closeEditProgressModal()">Cancel</button>
<button type="button" style="background-color: #3F51B5; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px;" onclick="submitEditProgressForm()">Update Progress</button>
</div>
</div>
</div>
<script>
function openEditProgressModal(progressId) {
document.getElementById('editProgressModal').style.display = 'block';
document.body.style.overflow = 'hidden';
loadProgressData(progressId);
}
function closeEditProgressModal() {
document.getElementById('editProgressModal').style.display = 'none';
document.body.style.overflow = '';
document.getElementById('editProgressForm').reset();
}
function loadProgressData(progressId) {
// Reset form
document.getElementById('edit_progress_id').value = '';
document.getElementById('student_name').textContent = '';
document.getElementById('student_batch').textContent = '';
document.getElementById('edit_current_period').value = '';
document.getElementById('edit_completion_percentage').value = '';
document.getElementById('edit_progress_status_display').textContent = 'In Progress';
document.getElementById('edit_progress_status_display').className = 'badge bg-primary';
document.getElementById('edit_notes').value = '';
document.getElementById('student_profile_image').src = "{% static 'img/user.png' %}";
// Update progress bar preview
updateCompletionPreview(0);
fetch(`/app/api/get-progress/${progressId}/`)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.success) {
const progress = data.progress;
const student = data.student;
// Set form values
document.getElementById('edit_progress_id').value = progress.id;
document.getElementById('student_name').textContent = student.name;
// Set batch information
if (student.batches && student.batches.length > 0) {
document.getElementById('student_batch').textContent = student.batches.join(', ');
} else {
document.getElementById('student_batch').textContent = 'No batch assigned';
}
// Set student image if available
if (student.image) {
document.getElementById('student_profile_image').src = student.image;
}
document.getElementById('edit_current_period').value = student.current_period || '';
document.getElementById('edit_completion_percentage').value = progress.completion_percentage || 0;
// Update status display
document.getElementById('edit_progress_status_display').textContent = progress.progress_status || 'In Progress';
// Set status badge color
const statusBadge = document.getElementById('edit_progress_status_display');
statusBadge.className = 'badge';
if (progress.progress_status === 'Completed') {
statusBadge.classList.add('bg-success');
} else if (progress.progress_status === 'In Progress') {
statusBadge.classList.add('bg-primary');
} else if (progress.progress_status === 'Not Started') {
statusBadge.classList.add('bg-secondary');
} else if (progress.progress_status === 'Dropped') {
statusBadge.classList.add('bg-danger');
} else {
statusBadge.classList.add('bg-primary');
}
document.getElementById('edit_notes').value = progress.notes || '';
// Update progress bar preview
updateCompletionPreview(progress.completion_percentage || 0);
} else {
showMessageModal('Error', data.message || 'Error loading progress data');
}
})
.catch(error => {
showMessageModal('Error', 'An error occurred while loading progress data');
});
}
function updateCompletionPreview(percentage) {
const progressBar = document.getElementById('completion_preview');
progressBar.style.width = `${percentage}%`;
progressBar.setAttribute('aria-valuenow', percentage);
// Update class based on percentage
progressBar.className = 'progress-bar';
if (percentage >= 75) {
progressBar.classList.add('bg-success');
} else if (percentage >= 40) {
progressBar.classList.add('bg-warning');
} else {
progressBar.classList.add('bg-danger');
}
}
// Add event listener to completion percentage input to update preview
document.addEventListener('DOMContentLoaded', function() {
const completionInput = document.getElementById('edit_completion_percentage');
if (completionInput) {
completionInput.addEventListener('input', function() {
updateCompletionPreview(this.value);
});
}
});
function submitEditProgressForm() {
const form = document.getElementById('editProgressForm');
const formData = new FormData(form);
const progressId = document.getElementById('edit_progress_id').value;
fetch(`/app/api/edit-progress/${progressId}/`, {
method: 'POST',
body: formData,
headers: {
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
}
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.success) {
showMessageModal('Success', 'Student progress updated successfully');
closeEditProgressModal();
location.reload();
} else {
showMessageModal('Error', data.message || 'Error updating progress');
}
})
.catch(error => {
showMessageModal('Error', 'An error occurred while updating progress');
});
}
</script>
@@ -0,0 +1,267 @@
{% load static %}
<!-- Edit Routine Modal -->
<div id="editRoutineModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeEditRoutineModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 500px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Edit Class Routine</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeEditRoutineModal()">&times;</button>
</div>
<form id="editRoutineForm">
{% csrf_token %}
<input type="hidden" id="editRoutineId" name="routine_id">
<div style="padding: 20px;">
<div style="margin-bottom: 15px;">
<label for="editSubjectId" style="display: block; margin-bottom: 8px; font-weight: 500;">Subject</label>
<select id="editSubjectId" name="subject_id" style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;" required>
<option value="">Select Subject</option>
{% for subject in subjects %}
<option value="{{ subject.id }}">{{ subject.name }} ({% if course.duration_type == 'Semester' %}Semester{% else %}Year{% endif %} {{ subject.period_or_year }})</option>
{% endfor %}
</select>
</div>
<div style="margin-bottom: 15px;">
<label for="editTeacherId" style="display: block; margin-bottom: 8px; font-weight: 500;">Teacher</label>
<select id="editTeacherId" name="teacher_id" style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;" required>
<option value="">Select Teacher</option>
{% for teacher in staff %}
<option value="{{ teacher.id }}">{{ teacher.name }}</option>
{% endfor %}
</select>
</div>
<div style="display: flex; gap: 15px; margin-bottom: 15px;">
<div style="flex: 1;">
<label for="editStartTime" style="display: block; margin-bottom: 8px; font-weight: 500;">Start Time</label>
<input type="time" id="editStartTime" name="start_time" style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;" required>
</div>
<div style="flex: 1;">
<label for="editEndTime" style="display: block; margin-bottom: 8px; font-weight: 500;">End Time</label>
<input type="time" id="editEndTime" name="end_time" style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;" required>
</div>
</div>
<input type="hidden" id="editPeriodOrYear" name="period_or_year">
</div>
<div style="padding: 15px; border-top: 1px solid #EEEEEE; text-align: right; display: flex; flex-wrap: wrap; justify-content: flex-end;">
<button type="button" style="background-color: #9E9E9E; color: white; border: none; padding: 8px 16px; border-radius: 4px; margin-right: 10px; margin-bottom: 10px; cursor: pointer; font-size: 14px;" onclick="closeEditRoutineModal()">Cancel</button>
<button type="button" style="background-color: #3F51B5; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-bottom: 10px;" onclick="submitEditRoutineForm()">Update</button>
</div>
</form>
</div>
</div>
<script>
function openEditRoutineModal(routineId) {
if (!routineId) {
console.error('No routine ID provided');
return;
}
console.log(`Fetching routine data for ID: ${routineId}`);
// Fetch routine data
fetch(`/app/api/hod/routines/${routineId}/`)
.then(response => {
if (!response.ok) {
throw new Error('Failed to fetch routine data');
}
return response.json();
})
.then(data => {
console.log('Received routine data:', data);
// Check if data has the correct structure
if (!data.success || !data.routine) {
throw new Error('Invalid data format received from server');
}
// Get routine data from the response
const routine = data.routine;
// Populate form fields
document.getElementById('editRoutineId').value = routineId;
document.getElementById('editSubjectId').value = routine.subject_id;
document.getElementById('editTeacherId').value = routine.teacher_id;
document.getElementById('editStartTime').value = routine.start_time;
document.getElementById('editEndTime').value = routine.end_time;
document.getElementById('editPeriodOrYear').value = routine.period_or_year;
console.log('Form populated with values:', {
subject_id: routine.subject_id,
teacher_id: routine.teacher_id,
start_time: routine.start_time,
end_time: routine.end_time,
period_or_year: routine.period_or_year
});
// Set default period/year based on subject selection
const subjectSelect = document.getElementById('editSubjectId');
if (subjectSelect) {
subjectSelect.addEventListener('change', function() {
const selectedOption = this.options[this.selectedIndex];
const periodOrYear = selectedOption.textContent.match(/\((?:Semester|Year) (\d+)\)/);
if (periodOrYear && periodOrYear[1]) {
document.getElementById('editPeriodOrYear').value = periodOrYear[1];
}
});
}
// Show modal
const modal = document.getElementById('editRoutineModal');
if (modal) {
modal.style.display = 'block';
document.body.style.overflow = 'hidden';
}
})
.catch(error => {
console.error('Error fetching routine data:', error);
if (typeof window.showMessageModal === 'function') {
window.showMessageModal('Error', error.message || 'Failed to fetch routine data');
} else if (typeof window.showToast === 'function') {
window.showToast('error', error.message || 'Failed to fetch routine data');
} else {
alert('Failed to fetch routine data: ' + error.message);
}
});
}
function closeEditRoutineModal() {
const modal = document.getElementById('editRoutineModal');
if (modal) {
modal.style.display = 'none';
document.body.style.overflow = '';
}
}
// Make functions available globally
if (typeof window !== 'undefined') {
window.openEditRoutineModal = openEditRoutineModal;
window.closeEditRoutineModal = closeEditRoutineModal;
}
// Add form submission function
function submitEditRoutineForm() {
const form = document.getElementById('editRoutineForm');
if (!form) {
console.error('Edit routine form not found');
return;
}
// Create form data
const formData = new FormData(form);
const routineId = formData.get('routine_id');
if (!routineId) {
console.error('No routine ID provided');
return;
}
// Validate form
const subjectId = formData.get('subject_id');
const teacherId = formData.get('teacher_id');
const startTime = formData.get('start_time');
const endTime = formData.get('end_time');
console.log('Submitting form with values:', {
routine_id: routineId,
subject_id: subjectId,
teacher_id: teacherId,
start_time: startTime,
end_time: endTime,
period_or_year: formData.get('period_or_year')
});
if (!subjectId || !teacherId || !startTime || !endTime) {
const message = 'Please fill in all required fields';
console.error(message, {
subject_id: subjectId,
teacher_id: teacherId,
start_time: startTime,
end_time: endTime
});
if (typeof window.showMessageModal === 'function') {
window.showMessageModal('Error', message);
} else if (typeof window.showToast === 'function') {
window.showToast('error', message);
} else {
alert(message);
}
return;
}
// Get CSRF token
const csrfToken = document.querySelector('[name=csrfmiddlewaretoken]').value;
console.log('Using CSRF token:', csrfToken);
// Send request to server - using POST instead of PUT to avoid potential issues
fetch(`/app/api/hod/routines/${routineId}/edit/`, {
method: 'POST', // Changed from PUT to POST
body: formData,
headers: {
'X-CSRFToken': csrfToken,
// Don't set Content-Type header when using FormData,
// browser will set it automatically with proper boundary
}
})
.then(response => {
console.log('Server response status:', response.status);
console.log('Server response headers:', Object.fromEntries([...response.headers]));
// Try to handle both JSON and text responses
const contentType = response.headers.get('content-type');
if (contentType && contentType.includes('application/json')) {
return response.json().then(data => {
if (!response.ok) {
console.error('Server error response:', data);
throw new Error(data.message || 'Failed to update routine');
}
return data;
});
} else {
return response.text().then(text => {
console.log('Server response text:', text);
if (!response.ok) {
throw new Error(text || 'Failed to update routine');
}
try {
return JSON.parse(text);
} catch (e) {
return { success: true, message: 'Routine updated successfully' };
}
});
}
})
.then(data => {
console.log('Server success response:', data);
if (typeof window.showMessageModal === 'function') {
window.showMessageModal('Success', 'Routine updated successfully');
} else if (typeof window.showToast === 'function') {
window.showToast('success', 'Routine updated successfully');
} else {
alert('Routine updated successfully');
}
closeEditRoutineModal();
setTimeout(() => {
window.location.reload();
}, 1000);
})
.catch(error => {
console.error('Error updating routine:', error);
if (typeof window.showMessageModal === 'function') {
window.showMessageModal('Error', error.message || 'Failed to update routine');
} else if (typeof window.showToast === 'function') {
window.showToast('error', error.message || 'Failed to update routine');
} else {
alert('Failed to update routine: ' + error.message);
}
});
}
// Make submission function globally available
if (typeof window !== 'undefined') {
window.submitEditRoutineForm = submitEditRoutineForm;
}
</script>
+202
View File
@@ -0,0 +1,202 @@
{% load static %}
<div id="editStaffModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeEditStaffModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 800px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto;">
<div style="background-color: #3F51B5; color: white; padding: 12px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1;">
<h5 style="margin: 0; font-size: 18px;">Edit Staff</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeEditStaffModal()">&times;</button>
</div>
<div style="padding: 15px;">
<form id="editStaffForm" enctype="multipart/form-data">
{% csrf_token %}
<input type="hidden" id="editStaffId" name="staff_id">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
<!-- Left Column -->
<div>
<div style="text-align: center; margin-bottom: 20px;">
<img id="editStaffProfilePicture" src="{% static 'img/user.png' %}" alt="Profile Picture" style="width: 120px; height: 120px; object-fit: cover; border-radius: 50%; border: 3px solid #3F51B5;">
<div style="margin-top: 10px;">
<input type="file" id="editStaffProfilePictureInput" name="image" accept="image/*" style="display: none;">
<button type="button" onclick="document.getElementById('editStaffProfilePictureInput').click()" style="background-color: #3F51B5; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px;">Change Picture</button>
</div>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Name <span style="color: red;">*</span></label>
<input type="text" id="editStaffName" name="name" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;" required>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Phone <span style="color: red;">*</span></label>
<input type="tel" id="editStaffPhone" name="phone" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;" required pattern="[0-9]{10}" maxlength="10" title="Please enter a 10-digit phone number">
<small style="color: #666; display: block; margin-top: 2px; font-size: 11px;">This will be used as the login ID</small>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Email</label>
<input type="email" id="editStaffEmail" name="email" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Gender</label>
<select id="editStaffGender" name="gender" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
<option value="">Select Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Other">Other</option>
</select>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Birth Date</label>
<input type="date" id="editStaffBirthDate" name="birth_date" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Marital Status</label>
<select id="editStaffMaritalStatus" name="marital_status" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
<option value="">Select Marital Status</option>
<option value="Married">Married</option>
<option value="Unmarried">Unmarried</option>
<option value="Divorced">Divorced</option>
</select>
</div>
</div>
<!-- Right Column -->
<div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Assigned Subjects <span style="color: red;">*</span></label>
<select id="editStaffSubjects" name="subjects[]" multiple style="width: 100%; min-height: 100px; padding: 6px; border: 1px solid #ddd; border-radius: 4px;" required>
{% for subject in subjects %}
<option value="{{ subject.id }}">
{{ subject.name }} {% if course.duration_type == 'Semester' %}(Semester {{ subject.period_or_year }}){% else %}(Year {{ subject.period_or_year }}){% endif %}
</option>
{% empty %}
<option value="" disabled>No subjects available</option>
{% endfor %}
</select>
<small style="color: #666; display: block; margin-top: 2px; font-size: 11px;">Hold Ctrl/Cmd to select multiple subjects</small>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Temporary Address</label>
<input type="text" id="editStaffTempAddress" name="temporary_address" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Permanent Address</label>
<input type="text" id="editStaffPermAddress" name="permanent_address" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Parent Name</label>
<input type="text" id="editStaffParentName" name="parent_name" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Parent Phone</label>
<input type="tel" id="editStaffParentPhone" name="parent_phone" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;" pattern="[0-9]{10}" maxlength="10" title="Please enter a 10-digit phone number">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Citizenship Number</label>
<input type="text" id="editStaffCitizenshipNo" name="citizenship_no" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Passport</label>
<input type="text" id="editStaffPassport" name="passport" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Status</label>
<select id="editStaffStatus" name="is_active" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px;" required>
<option value="true">Active</option>
<option value="false">Inactive</option>
</select>
</div>
</div>
</div>
</form>
</div>
<div style="padding: 12px; border-top: 1px solid #EEEEEE; text-align: right; position: sticky; bottom: 0; background-color: white; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;">
<button type="button" style="background-color: #9E9E9E; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-right: 8px;" onclick="closeEditStaffModal()">Cancel</button>
<button type="button" style="background-color: #3F51B5; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px;" onclick="submitEditStaffForm()">Save Changes</button>
</div>
</div>
</div>
<script>
function openEditStaffModal(staffId) {
fetch(`/app/staff/${staffId}/`)
.then(response => response.json())
.then(data => {
if (data.success) {
const staff = data.staff;
document.getElementById('editStaffId').value = staff.id;
document.getElementById('editStaffProfilePicture').src = staff.image || "{% static 'img/user.png' %}";
document.getElementById('editStaffName').value = staff.name;
document.getElementById('editStaffEmail').value = staff.email;
document.getElementById('editStaffPhone').value = staff.phone;
document.getElementById('editStaffGender').value = staff.gender;
document.getElementById('editStaffBirthDate').value = staff.birth_date;
document.getElementById('editStaffMaritalStatus').value = staff.marital_status;
document.getElementById('editStaffTempAddress').value = staff.temporary_address;
document.getElementById('editStaffPermAddress').value = staff.permanent_address;
document.getElementById('editStaffParentName').value = staff.parent_name;
document.getElementById('editStaffParentPhone').value = staff.parent_phone;
document.getElementById('editStaffCitizenshipNo').value = staff.citizenship_no;
document.getElementById('editStaffPassport').value = staff.passport;
document.getElementById('editStaffStatus').value = staff.is_active;
// Set selected subjects
const subjectsSelect = document.getElementById('editStaffSubjects');
if (staff.subjects && staff.subjects.length > 0) {
Array.from(subjectsSelect.options).forEach(option => {
option.selected = staff.subjects.some(subject => subject.id === parseInt(option.value));
});
}
document.getElementById('editStaffModal').style.display = 'block';
document.body.style.overflow = 'hidden';
} else {
showMessageModal('Error', data.message);
}
})
.catch(error => {
showMessageModal('Error', 'Failed to fetch staff details.');
});
}
function closeEditStaffModal() {
document.getElementById('editStaffModal').style.display = 'none';
document.body.style.overflow = '';
document.getElementById('editStaffForm').reset();
}
function submitEditStaffForm() {
const formData = new FormData(document.getElementById('editStaffForm'));
const staffId = document.getElementById('editStaffId').value;
fetch(`/app/staff/edit/${staffId}/`, {
method: 'POST',
body: formData,
headers: {
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
closeEditStaffModal();
showMessageModal('Success', 'Staff details updated successfully.');
// Refresh the staff list
location.reload();
} else {
showMessageModal('Error', data.message);
}
})
.catch(error => {
showMessageModal('Error', 'Failed to update staff details.');
});
}
// Handle profile picture preview
document.getElementById('editStaffProfilePictureInput').addEventListener('change', function(e) {
const file = e.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
document.getElementById('editStaffProfilePicture').src = e.target.result;
}
reader.readAsDataURL(file);
}
});
</script>
@@ -0,0 +1,206 @@
{% load static %}
<!-- Edit Student Modal -->
<div id="editStudentModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeEditStudentModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 800px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto;">
<div style="background-color: #3F51B5; color: white; padding: 12px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1;">
<h5 style="margin: 0; font-size: 18px;">Edit Student</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeEditStudentModal()">&times;</button>
</div>
<div style="padding: 15px;">
<!-- Profile Picture Preview -->
<div style="text-align: center; margin-bottom: 20px;">
<div style="position: relative; display: inline-block;">
<img id="studentEditProfilePreview" src="{% static 'img/user.png' %}" alt="Student Image" style="width: 120px; height: 120px; object-fit: cover; border-radius: 50%; border: 3px solid #3F51B5;">
<div style="position: absolute; bottom: 0; right: 0;">
<button type="button" onclick="document.getElementById('edit_profile_picture').click()" style="width: 36px; height: 36px; border-radius: 50%; background-color: #3F51B5; color: white; border: none; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 5px rgba(0,0,0,0.2);">
<i class="fas fa-camera"></i>
</button>
</div>
</div>
</div>
<form id="editStudentForm">
{% csrf_token %}
<input type="hidden" id="edit_student_id" name="student_id">
<!-- Hidden file input controlled by the camera button -->
<input type="file" id="edit_profile_picture" name="image" accept="image/*" style="display: none;" onchange="previewStudentImage(this)">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
<!-- Left Column -->
<div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Name <span style="color: red;">*</span></label>
<input type="text" id="edit_name" name="name" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;" required>
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Phone <span style="color: red;">*</span></label>
<input type="tel" id="edit_phone" name="phone" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;" required pattern="[0-9]{10}" maxlength="10" title="Please enter a 10-digit phone number">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Email</label>
<input type="email" id="edit_email" name="email" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Gender</label>
<select id="edit_gender" name="gender" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
<option value="">Select Gender</option>
<option value="M">Male</option>
<option value="F">Female</option>
<option value="O">Other</option>
</select>
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Birth Date</label>
<input type="date" id="edit_birth_date" name="birth_date" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Admission Date</label>
<input type="date" id="edit_admission_date" name="admission_date" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
</div>
<!-- Right Column -->
<div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Parent/Guardian Name</label>
<input type="text" id="edit_parent_name" name="parent_name" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Parent/Guardian Phone</label>
<input type="tel" id="edit_parent_phone" name="parent_phone" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;" pattern="[0-9]{10}" maxlength="10" title="Please enter a 10-digit phone number">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Citizenship Number</label>
<input type="text" id="edit_citizenship_no" name="citizenship_no" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Temporary Address</label>
<textarea id="edit_temporary_address" name="temporary_address" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; min-height: 80px;"></textarea>
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 6px; font-weight: 500; color: #3F51B5;">Permanent Address</label>
<textarea id="edit_permanent_address" name="permanent_address" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; min-height: 80px;"></textarea>
</div>
</div>
</div>
</form>
</div>
<div style="padding: 12px; border-top: 1px solid #EEEEEE; text-align: right; position: sticky; bottom: 0; background-color: white; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;">
<button type="button" style="background-color: #9E9E9E; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-right: 8px;" onclick="closeEditStudentModal()">Cancel</button>
<button type="button" style="background-color: #3F51B5; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px;" onclick="submitEditStudentForm()">Save Changes</button>
</div>
</div>
</div>
<script>
function previewStudentImage(input) {
if (input.files && input.files[0]) {
const reader = new FileReader();
reader.onload = function(e) {
document.getElementById('studentEditProfilePreview').src = e.target.result;
}
reader.readAsDataURL(input.files[0]);
}
}
function openEditStudentModal(studentId) {
document.getElementById('editStudentModal').style.display = 'block';
document.body.style.overflow = 'hidden';
loadStudentData(studentId);
}
function closeEditStudentModal() {
document.getElementById('editStudentModal').style.display = 'none';
document.body.style.overflow = '';
document.getElementById('editStudentForm').reset();
document.getElementById('studentEditProfilePreview').src = "{% static 'img/user.png' %}";
}
function loadStudentData(studentId) {
// Reset profile picture
document.getElementById('studentEditProfilePreview').src = "{% static 'img/user.png' %}";
// Clear previous data
document.getElementById('edit_student_id').value = '';
document.getElementById('edit_name').value = '';
document.getElementById('edit_email').value = '';
document.getElementById('edit_phone').value = '';
document.getElementById('edit_gender').value = '';
document.getElementById('edit_birth_date').value = '';
document.getElementById('edit_admission_date').value = '';
document.getElementById('edit_temporary_address').value = '';
document.getElementById('edit_permanent_address').value = '';
document.getElementById('edit_parent_name').value = '';
document.getElementById('edit_parent_phone').value = '';
document.getElementById('edit_citizenship_no').value = '';
fetch(`/app/get-student/${studentId}/`)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.success) {
const student = data.student;
// Set profile picture if available
if (student.image) {
document.getElementById('studentEditProfilePreview').src = student.image;
}
// Set form values
document.getElementById('edit_student_id').value = student.id;
document.getElementById('edit_name').value = student.name || '';
document.getElementById('edit_email').value = student.email || '';
document.getElementById('edit_phone').value = student.phone || '';
document.getElementById('edit_gender').value = student.gender || '';
document.getElementById('edit_birth_date').value = student.birth_date || '';
document.getElementById('edit_admission_date').value = student.joining_date || '';
document.getElementById('edit_temporary_address').value = student.temporary_address || '';
document.getElementById('edit_permanent_address').value = student.permanent_address || '';
document.getElementById('edit_parent_name').value = student.parent_name || '';
document.getElementById('edit_parent_phone').value = student.parent_phone || '';
document.getElementById('edit_citizenship_no').value = student.citizenship_no || '';
} else {
showMessageModal('Error', data.message || 'Error loading student data');
}
})
.catch(error => {
showMessageModal('Error', 'An error occurred while loading student data');
});
}
function submitEditStudentForm() {
const form = document.getElementById('editStudentForm');
const formData = new FormData(form);
const studentId = document.getElementById('edit_student_id').value;
fetch(`/app/edit-student/${studentId}/`, {
method: 'POST',
body: formData,
headers: {
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
}
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.success) {
showMessageModal('Success', 'Student updated successfully');
closeEditStudentModal();
location.reload();
} else {
showMessageModal('Error', data.message || 'Error updating student');
}
})
.catch(error => {
showMessageModal('Error', 'An error occurred while updating the student');
});
}
</script>
@@ -0,0 +1,128 @@
{% load static %}
{% load app_filters %}
<!-- Edit Subject Modal -->
<div id="editSubjectModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeEditSubjectModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 500px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Edit Subject</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeEditSubjectModal()">&times;</button>
</div>
<form id="editSubjectForm" method="post" enctype="multipart/form-data">
{% csrf_token %}
<input type="hidden" id="editSubjectId" name="subject_id">
<div style="padding: 20px;">
<div style="margin-bottom: 15px;">
<label for="editSubjectName" style="display: block; margin-bottom: 8px; font-weight: 500;">Subject Name</label>
<input type="text" id="editSubjectName" name="name" required style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
</div>
<div style="margin-bottom: 15px;">
<label for="editSubjectCode" style="display: block; margin-bottom: 8px; font-weight: 500;">Subject Code</label>
<input type="text" id="editSubjectCode" name="code" style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
</div>
<div style="margin-bottom: 15px;">
<label for="editSubjectPeriod" style="display: block; margin-bottom: 8px; font-weight: 500;">Period/{{ course.duration_type }}</label>
<input type="number" id="editSubjectPeriod" name="period_or_year" min="1" required style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
<small id="periodHelp" style="color: #666; display: block; margin-top: 5px;"></small>
</div>
<div style="margin-bottom: 15px;">
<label for="editSubjectSyllabus" style="display: block; margin-bottom: 8px; font-weight: 500;">Syllabus PDF</label>
<input type="file" id="editSubjectSyllabus" name="syllabus_pdf" accept=".pdf" style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
<small style="color: #666; display: block; margin-top: 5px;">Current file: <span id="currentSyllabus">No file uploaded</span></small>
</div>
</div>
<div style="padding: 15px; border-top: 1px solid #EEEEEE; text-align: right; display: flex; flex-wrap: wrap; justify-content: flex-end;">
<button type="button" style="background-color: #9E9E9E; color: white; border: none; padding: 8px 16px; border-radius: 4px; margin-right: 10px; margin-bottom: 10px; cursor: pointer; font-size: 14px;" onclick="closeEditSubjectModal()">Cancel</button>
<button type="submit" style="background-color: #3F51B5; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-bottom: 10px;">Save Changes</button>
</div>
</form>
</div>
</div>
<script>
function openEditSubjectModal(subjectId) {
// Fetch subject details from the server
fetch(`/app/subject/${subjectId}/view/`)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.success) {
const subject = data.subject;
// Populate the edit form with subject details
document.getElementById('editSubjectId').value = subject.id;
document.getElementById('editSubjectName').value = subject.name;
document.getElementById('editSubjectCode').value = subject.code || '';
document.getElementById('editSubjectPeriod').value = subject.period_or_year;
// Update period validation based on course duration type
const periodInput = document.getElementById('editSubjectPeriod');
const periodHelp = document.getElementById('periodHelp');
const maxPeriods = subject.course.duration_type === 'Semester' ?
subject.course.duration * 2 : subject.course.duration;
periodInput.max = maxPeriods;
if (subject.course.duration_type === 'Semester') {
periodHelp.textContent = `Enter semester number (1-${maxPeriods})`;
} else {
periodHelp.textContent = `Enter year number (1-${maxPeriods})`;
}
// Update syllabus file info
if (subject.syllabus_pdf) {
const filename = subject.syllabus_pdf.split('/').pop();
document.getElementById('currentSyllabus').innerHTML =
`<a href="${subject.syllabus_pdf}" target="_blank" style="color: #3F51B5; text-decoration: none;">${filename}</a>`;
} else {
document.getElementById('currentSyllabus').textContent = 'No file uploaded';
}
// Show the modal
document.getElementById('editSubjectModal').style.display = 'block';
} else {
alert(data.message || 'Failed to fetch subject details');
}
})
.catch(error => {
console.error('Error fetching subject details:', error);
alert('Failed to fetch subject details');
});
}
function closeEditSubjectModal() {
document.getElementById('editSubjectModal').style.display = 'none';
document.getElementById('editSubjectForm').reset();
}
// Handle form submission
document.getElementById('editSubjectForm').addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData(this);
const subjectId = document.getElementById('editSubjectId').value;
fetch(`/app/subject/${subjectId}/edit/`, {
method: 'POST',
body: formData,
headers: {
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
closeEditSubjectModal();
// Refresh the page to show updated data
location.reload();
} else {
alert(data.message || 'Failed to update subject');
}
})
.catch(error => {
console.error('Error updating subject:', error);
alert('Failed to update subject');
});
});
</script>
@@ -0,0 +1,43 @@
<!-- Meeting Agenda Modal -->
<div class="modal fade" id="meetingAgendaModal" tabindex="-1" aria-labelledby="meetingAgendaModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="meetingAgendaModalLabel">Meeting Agenda</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div id="meetingAgendaContent" class="p-3 bg-light rounded">
<!-- Agenda content will be loaded here -->
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>
function viewMeetingAgenda(meetingId) {
fetch(`/api/meetings/${meetingId}/agenda/`)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok: ' + response.statusText);
}
return response.json();
})
.then(data => {
document.getElementById('meetingAgendaContent').innerHTML = data.agenda || 'No agenda available';
new bootstrap.Modal(document.getElementById('meetingAgendaModal')).show();
})
.catch(error => {
console.error('Error fetching meeting agenda:', error);
showToast('Failed to load meeting agenda', 'error');
});
}
function closeMeetingAgendaModal() {
bootstrap.Modal.getInstance(document.getElementById('meetingAgendaModal')).hide();
}
</script>
@@ -0,0 +1,43 @@
<!-- Meeting Notes Modal -->
<div class="modal fade" id="meetingNotesModal" tabindex="-1" aria-labelledby="meetingNotesModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="meetingNotesModalLabel">Meeting Notes</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div id="meetingNotesContent" class="p-3 bg-light rounded">
<!-- Notes content will be loaded here -->
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>
function viewMeetingNotes(meetingId) {
fetch(`/api/meetings/${meetingId}/notes/`)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok: ' + response.statusText);
}
return response.json();
})
.then(data => {
document.getElementById('meetingNotesContent').innerHTML = data.notes || 'No notes available';
new bootstrap.Modal(document.getElementById('meetingNotesModal')).show();
})
.catch(error => {
console.error('Error fetching meeting notes:', error);
showToast('Failed to load meeting notes', 'error');
});
}
function closeMeetingNotesModal() {
bootstrap.Modal.getInstance(document.getElementById('meetingNotesModal')).hide();
}
</script>
+167
View File
@@ -0,0 +1,167 @@
{% load static %}
<!-- Add Notice Modal -->
<div id="addNoticeModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeAddNoticeModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 600px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Add New Notice</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeAddNoticeModal()">&times;</button>
</div>
<div style="padding: 20px;">
<form id="addNoticeForm" method="POST" action="{% url 'hod_add_notice' %}" enctype="multipart/form-data">
{% csrf_token %}
<div class="mb-3">
<label for="noticeTitle" class="form-label">Notice Title</label>
<input type="text" class="form-control" id="noticeTitle" name="title" required>
</div>
<div class="mb-3">
<label for="noticeMessage" class="form-label">Message</label>
<textarea class="form-control" id="noticeMessage" name="message" rows="5" required></textarea>
</div>
<div class="mb-3">
<label for="noticeFile" class="form-label">Attachment (Optional)</label>
<input type="file" class="form-control" id="noticeFile" name="file">
<small class="form-text text-muted">Upload PDF, Word, or other relevant files (max 5MB)</small>
</div>
<div class="mb-3">
<label for="noticeImage" class="form-label">Image (Optional)</label>
<input type="file" class="form-control" id="noticeImage" name="image" accept="image/*">
<small class="form-text text-muted">Upload an image if relevant to the notice</small>
</div>
<div class="d-flex justify-content-end gap-2">
<button type="button" class="btn btn-secondary" onclick="closeAddNoticeModal()">Cancel</button>
<button type="submit" class="btn btn-primary">Post Notice</button>
</div>
</form>
</div>
</div>
</div>
<!-- View Notice Modal -->
<div id="viewNoticeModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeViewNoticeModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 600px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 id="viewNoticeTitle" style="margin: 0; font-size: 18px;">Notice Title</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeViewNoticeModal()">&times;</button>
</div>
<div style="padding: 20px;">
<div id="viewNoticeImageContainer" style="text-align: center; margin-bottom: 15px; display: none;">
<img id="viewNoticeImage" src="" alt="Notice Image" style="max-width: 100%; max-height: 300px; border-radius: 4px;">
</div>
<div class="mb-3">
<h6 class="mb-2">Details</h6>
<p id="viewNoticeMessage" style="white-space: pre-wrap;"></p>
</div>
<div id="viewNoticeFileContainer" style="margin-top: 15px; display: none;">
<h6 class="mb-2">Attachment</h6>
<a id="viewNoticeFile" href="" target="_blank" class="btn btn-sm btn-outline-primary">
<i class="fas fa-download me-1"></i> Download Attachment
</a>
</div>
<div class="mt-3 text-muted">
<small>Posted: <span id="viewNoticeDate"></span></small>
</div>
</div>
</div>
</div>
<!-- Delete Notice Confirmation Modal -->
<div id="deleteNoticeModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeDeleteNoticeModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 400px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Delete Notice</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeDeleteNoticeModal()">&times;</button>
</div>
<div style="padding: 20px;">
<p style="margin-bottom: 15px;">Are you sure you want to delete this notice? This action cannot be undone.</p>
<form id="deleteNoticeForm" method="POST">
{% csrf_token %}
<input type="hidden" id="deleteNoticeId" name="notice_id">
<div class="d-flex justify-content-end gap-2">
<button type="button" class="btn btn-secondary" onclick="closeDeleteNoticeModal()">Cancel</button>
<button type="submit" class="btn btn-danger">Delete</button>
</div>
</form>
</div>
</div>
</div>
<script>
// Add Notice Modal Functions
function openAddNoticeModal() {
document.getElementById('addNoticeModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closeAddNoticeModal() {
document.getElementById('addNoticeModal').style.display = 'none';
document.body.style.overflow = '';
document.getElementById('addNoticeForm').reset();
}
// View Notice Modal Functions
function viewNotice(noticeId) {
// Fetch notice details from the server
fetch(`/app/notice/${noticeId}/`)
.then(response => response.json())
.then(data => {
if (data.success) {
const notice = data.notice;
// Set notice details in the modal
document.getElementById('viewNoticeTitle').textContent = notice.title;
document.getElementById('viewNoticeMessage').textContent = notice.message;
document.getElementById('viewNoticeDate').textContent = notice.created_at;
// Handle image if available
const imageContainer = document.getElementById('viewNoticeImageContainer');
const image = document.getElementById('viewNoticeImage');
if (notice.image) {
image.src = notice.image;
imageContainer.style.display = 'block';
} else {
imageContainer.style.display = 'none';
}
// Handle file attachment if available
const fileContainer = document.getElementById('viewNoticeFileContainer');
const fileLink = document.getElementById('viewNoticeFile');
if (notice.file) {
fileLink.href = notice.file;
fileContainer.style.display = 'block';
} else {
fileContainer.style.display = 'none';
}
// Show the modal
document.getElementById('viewNoticeModal').style.display = 'block';
document.body.style.overflow = 'hidden';
} else {
showMessageModal('Error', data.message || 'Failed to load notice details.');
}
})
.catch(error => {
showMessageModal('Error', 'An error occurred while loading notice details.');
});
}
function closeViewNoticeModal() {
document.getElementById('viewNoticeModal').style.display = 'none';
document.body.style.overflow = '';
}
// Delete Notice Modal Functions
function confirmDeleteNotice(noticeId) {
document.getElementById('deleteNoticeId').value = noticeId;
document.getElementById('deleteNoticeForm').action = `/app/delete-notice/${noticeId}/`;
document.getElementById('deleteNoticeModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closeDeleteNoticeModal() {
document.getElementById('deleteNoticeModal').style.display = 'none';
document.body.style.overflow = '';
}
</script>
+125
View File
@@ -0,0 +1,125 @@
<!-- Add Routine Modal -->
<div id="addRoutineModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h5>Add Class Routine</h5>
<span class="close" onclick="closeAddRoutineModal()">&times;</span>
</div>
<div class="modal-body">
<form id="addRoutineForm">
{% csrf_token %}
<div class="mb-3">
<label for="subjectId" class="form-label">Subject</label>
<select id="subjectId" name="subject_id" class="form-select" required>
<option value="">Select Subject</option>
{% for subject in subjects %}
<option value="{{ subject.id }}">{{ subject.name }} ({% if course.duration_type == 'Semester' %}Semester{% else %}Year{% endif %} {{ subject.period_or_year }})</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label for="teacherId" class="form-label">Teacher</label>
<select id="teacherId" name="teacher_id" class="form-select" required>
<option value="">Select Teacher</option>
{% for teacher in staff %}
<option value="{{ teacher.id }}">{{ teacher.name }}</option>
{% endfor %}
</select>
</div>
<div class="row mb-3">
<div class="col">
<label for="startTime" class="form-label">Start Time</label>
<input type="time" id="startTime" name="start_time" class="form-control" required>
</div>
<div class="col">
<label for="endTime" class="form-label">End Time</label>
<input type="time" id="endTime" name="end_time" class="form-control" required>
</div>
</div>
<input type="hidden" id="periodOrYear" name="period_or_year">
</form>
</div>
<div class="modal-footer">
<button type="button" class="modal-btn modal-btn-cancel" onclick="closeAddRoutineModal()">Cancel</button>
<button type="button" class="modal-btn modal-btn-delete" onclick="submitAddRoutineForm()">Save</button>
</div>
</div>
</div>
<!-- Edit Routine Modal -->
<div id="editRoutineModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h5>Edit Class Routine</h5>
<span class="close" onclick="closeEditRoutineModal()">&times;</span>
</div>
<div class="modal-body">
<form id="editRoutineForm">
{% csrf_token %}
<input type="hidden" id="editRoutineId" name="routine_id">
<div class="mb-3">
<label for="editSubjectId" class="form-label">Subject</label>
<select id="editSubjectId" name="subject_id" class="form-select" required>
<option value="">Select Subject</option>
{% for subject in subjects %}
<option value="{{ subject.id }}">{{ subject.name }} ({% if course.duration_type == 'Semester' %}Semester{% else %}Year{% endif %} {{ subject.period_or_year }})</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label for="editTeacherId" class="form-label">Teacher</label>
<select id="editTeacherId" name="teacher_id" class="form-select" required>
<option value="">Select Teacher</option>
{% for teacher in staff %}
<option value="{{ teacher.id }}">{{ teacher.name }}</option>
{% endfor %}
</select>
</div>
<div class="row mb-3">
<div class="col">
<label for="editStartTime" class="form-label">Start Time</label>
<input type="time" id="editStartTime" name="start_time" class="form-control" required>
</div>
<div class="col">
<label for="editEndTime" class="form-label">End Time</label>
<input type="time" id="editEndTime" name="end_time" class="form-control" required>
</div>
</div>
<input type="hidden" id="editPeriodOrYear" name="period_or_year">
</form>
</div>
<div class="modal-footer">
<button type="button" class="modal-btn modal-btn-cancel" onclick="closeEditRoutineModal()">Cancel</button>
<button type="button" class="modal-btn modal-btn-delete" onclick="submitEditRoutineForm()">Update</button>
</div>
</div>
</div>
<!-- Delete Routine Confirmation Modal -->
<div id="deleteRoutineModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h5>Confirm Delete</h5>
<span class="close" onclick="closeDeleteRoutineModal()">&times;</span>
</div>
<div class="modal-body">
<p>Are you sure you want to delete this routine? This action cannot be undone.</p>
<form id="deleteRoutineForm">
{% csrf_token %}
<input type="hidden" id="deleteRoutineId" name="routine_id">
</form>
</div>
<div class="modal-footer">
<button type="button" class="modal-btn modal-btn-cancel" onclick="closeDeleteRoutineModal()">Cancel</button>
<button type="button" class="modal-btn modal-btn-delete" onclick="submitDeleteRoutineForm()">Delete</button>
</div>
</div>
</div>
@@ -0,0 +1,74 @@
{% load static %}
<!-- View Meeting Modal -->
<div id="viewMeetingModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeViewMeetingModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 600px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto;">
<div style="background-color: #3F51B5; color: white; padding: 12px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1;">
<h5 style="margin: 0; font-size: 18px;">Meeting Details</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeViewMeetingModal()">&times;</button>
</div>
<div style="padding: 15px;">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
<!-- Left Column -->
<div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Date</label>
<p id="viewMeetingDate" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Time</label>
<p id="viewMeetingTime" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Duration</label>
<p style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"><span id="viewMeetingDuration"></span> minutes</p>
</div>
</div>
<!-- Right Column -->
<div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Status</label>
<p style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"><span id="viewMeetingStatus"></span></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Meeting Type</label>
<p id="viewMeetingType" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div id="viewMeetingLinkContainer" style="margin-bottom: 12px; display: none;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Meeting Link</label>
<p id="viewMeetingLink" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
</div>
</div>
<!-- Full Width Sections -->
<div style="margin-top: 15px;">
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Agenda</label>
<p id="viewMeetingAgenda" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px; min-height: 60px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Notes</label>
<p id="viewMeetingNotes" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px; min-height: 60px;"></p>
</div>
<div id="viewCancellationReasonContainer" style="margin-bottom: 12px; display: none;">
<label style="display: block; margin-bottom: 4px; font-weight: 500; color: #dc3545;">Cancellation Reason</label>
<p id="viewCancellationReason" style="margin: 0; padding: 6px; background-color: #fff8f8; border-radius: 4px; border-left: 3px solid #dc3545;"></p>
</div>
</div>
</div>
<div style="padding: 12px; border-top: 1px solid #EEEEEE; text-align: right; position: sticky; bottom: 0; background-color: white; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;">
<button type="button" style="background-color: #9E9E9E; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-right: 8px;" onclick="closeViewMeetingModal()">Close</button>
<button type="button" id="editMeetingBtn" style="background-color: #3F51B5; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px;">Edit Meeting</button>
</div>
</div>
</div>
<script>
function closeViewMeetingModal() {
document.getElementById('viewMeetingModal').style.display = 'none';
document.body.style.overflow = '';
}
</script>
+165
View File
@@ -0,0 +1,165 @@
{% load static %}
<div id="viewStaffModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeViewStaffModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 800px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto;">
<div style="background-color: #3F51B5; color: white; padding: 12px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1;">
<h5 style="margin: 0; font-size: 18px;">Staff Details</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeViewStaffModal()">&times;</button>
</div>
<div style="padding: 15px;">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
<!-- Left Column -->
<div>
<div style="text-align: center; margin-bottom: 20px;">
<img id="staffProfilePicture" src="{% static 'img/user.png' %}" alt="Staff Image" style="width: 120px; height: 120px; object-fit: cover; border-radius: 50%; border: 3px solid #3F51B5;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Name</label>
<p id="staffName" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Designation</label>
<p id="staffDesignation" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Email</label>
<p id="staffEmail" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Phone</label>
<p id="staffPhone" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Gender</label>
<p id="staffGender" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Birth Date</label>
<p id="staffBirthDate" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Marital Status</label>
<p id="staffMaritalStatus" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
</div>
<!-- Right Column -->
<div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Joining Date</label>
<p id="staffJoiningDate" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Status</label>
<p id="staffStatus" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Parent Name</label>
<p id="staffParentName" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Parent Phone</label>
<p id="staffParentPhone" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Citizenship No.</label>
<p id="staffCitizenshipNo" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Passport</label>
<p id="staffPassport" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
</div>
</div>
<div style="margin-top: 15px;">
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Temporary Address</label>
<p id="staffTemporaryAddress" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Permanent Address</label>
<p id="staffPermanentAddress" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
</div>
<div style="margin-top: 15px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Assigned Subjects</label>
<div id="staffSubjects" style="display: flex; flex-wrap: wrap; gap: 8px; padding: 6px; background-color: #f8f9fa; border-radius: 4px; min-height: 40px;"></div>
</div>
</div>
<div style="padding: 12px; border-top: 1px solid #EEEEEE; text-align: right; position: sticky; bottom: 0; background-color: white; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;">
<button type="button" style="background-color: #3F51B5; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px;" onclick="closeViewStaffModal()">Close</button>
</div>
</div>
</div>
<script>
function openViewStaffModal(staffId) {
fetch(`/app/staff/${staffId}/`)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.success) {
const staff = data.staff;
const profilePicture = document.getElementById('staffProfilePicture');
profilePicture.src = staff.image || "{% static 'img/user.png' %}";
// Basic Information
document.getElementById('staffName').textContent = staff.name || '-';
document.getElementById('staffDesignation').textContent = staff.designation || '-';
document.getElementById('staffEmail').textContent = staff.email || '-';
document.getElementById('staffPhone').textContent = staff.phone || '-';
document.getElementById('staffGender').textContent = staff.gender || '-';
document.getElementById('staffBirthDate').textContent = staff.birth_date || '-';
document.getElementById('staffMaritalStatus').textContent = staff.marital_status || '-';
document.getElementById('staffJoiningDate').textContent = staff.joining_date || '-';
document.getElementById('staffStatus').textContent = staff.is_active ? 'Active' : 'Inactive';
// Parent Details
document.getElementById('staffParentName').textContent = staff.parent_name || '-';
document.getElementById('staffParentPhone').textContent = staff.parent_phone || '-';
// Documents
document.getElementById('staffCitizenshipNo').textContent = staff.citizenship_no || '-';
document.getElementById('staffPassport').textContent = staff.passport || '-';
// Address Information
document.getElementById('staffTemporaryAddress').textContent = staff.temporary_address || '-';
document.getElementById('staffPermanentAddress').textContent = staff.permanent_address || '-';
// Assigned Subjects
const subjectsContainer = document.getElementById('staffSubjects');
subjectsContainer.innerHTML = '';
if (staff.subjects && staff.subjects.length > 0) {
staff.subjects.forEach(subject => {
const badge = document.createElement('span');
badge.style.cssText = 'background-color: #3F51B5; color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px;';
badge.textContent = subject.name;
subjectsContainer.appendChild(badge);
});
} else {
subjectsContainer.innerHTML = '<span style="color: #666;">No subjects assigned</span>';
}
document.getElementById('viewStaffModal').style.display = 'block';
document.body.style.overflow = 'hidden';
} else {
showMessageModal('Error', data.message);
}
})
.catch(error => {
console.error('Error:', error);
showMessageModal('Error', 'Failed to fetch staff details.');
});
}
function closeViewStaffModal() {
document.getElementById('viewStaffModal').style.display = 'none';
document.body.style.overflow = '';
}
</script>
@@ -0,0 +1,168 @@
{% load static %}
<!-- View Student Modal -->
<div id="viewStudentModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeViewStudentModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 800px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto;">
<div style="background-color: #3F51B5; color: white; padding: 12px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1;">
<h5 style="margin: 0; font-size: 18px;">Student Details</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeViewStudentModal()">&times;</button>
</div>
<div style="padding: 15px;">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
<!-- Left Column -->
<div>
<div style="text-align: center; margin-bottom: 20px;">
<img id="studentProfilePicture" src="{% static 'img/user.png' %}" alt="Student Image" style="width: 120px; height: 120px; object-fit: cover; border-radius: 50%; border: 3px solid #3F51B5;">
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Name</label>
<p id="view_name" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Email</label>
<p id="view_email" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Phone</label>
<p id="view_phone" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Gender</label>
<p id="view_gender" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Date of Birth</label>
<p id="view_birth_date" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Citizenship Number</label>
<p id="view_citizenship_no" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
</div>
<!-- Right Column -->
<div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Course</label>
<p id="view_course" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Current Period</label>
<p id="view_current_period" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Admission Date</label>
<p id="view_admission_date" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Status</label>
<p id="view_status" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Parent Name</label>
<p id="view_parent_name" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Parent Phone</label>
<p id="view_parent_phone" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
</div>
</div>
<div style="margin-top: 15px;">
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Temporary Address</label>
<p id="view_temporary_address" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; margin-bottom: 4px; font-weight: 500;">Permanent Address</label>
<p id="view_permanent_address" style="margin: 0; padding: 6px; background-color: #f8f9fa; border-radius: 4px;"></p>
</div>
</div>
</div>
<div style="padding: 12px; border-top: 1px solid #EEEEEE; text-align: right; position: sticky; bottom: 0; background-color: white; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;">
<button type="button" style="background-color: #3F51B5; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px;" onclick="closeViewStudentModal()">Close</button>
</div>
</div>
</div>
<script>
function openViewStudentModal(studentId) {
document.getElementById('viewStudentModal').style.display = 'block';
document.body.style.overflow = 'hidden';
loadStudentDataForView(studentId);
}
function closeViewStudentModal() {
document.getElementById('viewStudentModal').style.display = 'none';
document.body.style.overflow = '';
}
function loadStudentDataForView(studentId) {
// Reset profile picture
document.getElementById('studentProfilePicture').src = "{% static 'img/user.png' %}";
// Clear previous data
document.getElementById('view_name').textContent = '';
document.getElementById('view_email').textContent = '';
document.getElementById('view_phone').textContent = '';
document.getElementById('view_gender').textContent = '';
document.getElementById('view_birth_date').textContent = '';
document.getElementById('view_admission_date').textContent = '';
document.getElementById('view_temporary_address').textContent = '';
document.getElementById('view_permanent_address').textContent = '';
document.getElementById('view_parent_name').textContent = '';
document.getElementById('view_parent_phone').textContent = '';
document.getElementById('view_citizenship_no').textContent = '';
document.getElementById('view_course').textContent = '';
document.getElementById('view_current_period').textContent = '';
document.getElementById('view_status').textContent = '';
fetch(`/app/get-student/${studentId}/`)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.success) {
const student = data.student;
// Set profile picture
if (student.image) {
document.getElementById('studentProfilePicture').src = student.image;
}
// Basic information
document.getElementById('view_name').textContent = student.name || 'N/A';
document.getElementById('view_email').textContent = student.email || 'N/A';
document.getElementById('view_phone').textContent = student.phone || 'N/A';
document.getElementById('view_gender').textContent = student.gender === 'M' ? 'Male' : (student.gender === 'F' ? 'Female' : 'Other');
// Academic information
document.getElementById('view_course').textContent = student.course_name || 'N/A';
document.getElementById('view_current_period').textContent = student.current_period || 'N/A';
document.getElementById('view_status').textContent = student.is_active ? 'Active' : 'Inactive';
// Personal information
document.getElementById('view_birth_date').textContent = student.birth_date || 'N/A';
document.getElementById('view_admission_date').textContent = student.joining_date || 'N/A';
document.getElementById('view_citizenship_no').textContent = student.citizenship_no || 'N/A';
// Address information
document.getElementById('view_temporary_address').textContent = student.temporary_address || 'N/A';
document.getElementById('view_permanent_address').textContent = student.permanent_address || 'N/A';
// Parent information
document.getElementById('view_parent_name').textContent = student.parent_name || 'N/A';
document.getElementById('view_parent_phone').textContent = student.parent_phone || 'N/A';
} else {
showMessageModal('Error', data.message || 'Error loading student data');
}
})
.catch(error => {
showMessageModal('Error', 'An error occurred while loading student data');
});
}
</script>
@@ -0,0 +1,83 @@
<!-- View Subject Modal -->
<div id="viewSubjectModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeViewSubjectModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 500px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Subject Details</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeViewSubjectModal()">&times;</button>
</div>
<div style="padding: 20px;">
<div style="margin-bottom: 15px;">
<label style="font-weight: 500; display: block; margin-bottom: 5px;">Subject Name</label>
<p id="viewSubjectName" style="margin: 0; padding: 8px; background: #f5f5f5; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 15px;">
<label style="font-weight: 500; display: block; margin-bottom: 5px;">Subject Code</label>
<p id="viewSubjectCode" style="margin: 0; padding: 8px; background: #f5f5f5; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 15px;">
<label style="font-weight: 500; display: block; margin-bottom: 5px;">Course</label>
<p id="viewSubjectCourse" style="margin: 0; padding: 8px; background: #f5f5f5; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 15px;">
<label style="font-weight: 500; display: block; margin-bottom: 5px;">Period/Year</label>
<p id="viewSubjectPeriod" style="margin: 0; padding: 8px; background: #f5f5f5; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 15px;">
<label style="font-weight: 500; display: block; margin-bottom: 5px;">Assigned Teacher</label>
<p id="viewSubjectTeacher" style="margin: 0; padding: 8px; background: #f5f5f5; border-radius: 4px;"></p>
</div>
<div style="margin-bottom: 15px;">
<label style="font-weight: 500; display: block; margin-bottom: 5px;">Syllabus</label>
<p id="viewSubjectSyllabus" style="margin: 0; padding: 8px; background: #f5f5f5; border-radius: 4px;"></p>
</div>
</div>
<div style="padding: 15px; border-top: 1px solid #EEEEEE; text-align: right;">
<button style="background-color: #9E9E9E; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px;" onclick="closeViewSubjectModal()">Close</button>
</div>
</div>
</div>
<script>
function openViewSubjectModal(subjectId) {
// Fetch subject details from the server
fetch(`/app/subject/${subjectId}/view/`)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.success) {
const subject = data.subject;
// Populate the modal with subject details
document.getElementById('viewSubjectName').textContent = subject.name;
document.getElementById('viewSubjectCode').textContent = subject.code;
document.getElementById('viewSubjectCourse').textContent = `${subject.course.name} (${subject.course.duration_type})`;
document.getElementById('viewSubjectPeriod').textContent = `${subject.period_or_year} ${subject.course.duration_type}`;
document.getElementById('viewSubjectTeacher').textContent = subject.teacher ? subject.teacher.name : 'Not Assigned';
// Handle syllabus PDF
if (subject.syllabus_pdf) {
document.getElementById('viewSubjectSyllabus').innerHTML =
`<a href="${subject.syllabus_pdf}" target="_blank" style="color: #3F51B5; text-decoration: none;">View Syllabus PDF</a>`;
} else {
document.getElementById('viewSubjectSyllabus').textContent = 'No syllabus uploaded';
}
// Show the modal
document.getElementById('viewSubjectModal').style.display = 'block';
} else {
alert(data.message || 'Failed to fetch subject details');
}
})
.catch(error => {
console.error('Error fetching subject details:', error);
alert('Failed to fetch subject details');
});
}
function closeViewSubjectModal() {
document.getElementById('viewSubjectModal').style.display = 'none';
}
</script>