document.addEventListener('DOMContentLoaded', function () {
const sidebarToggler = document.getElementById('sidebar-toggler');
if (sidebarToggler) {
sidebarToggler.addEventListener('click', function () {
const isCollapsed = document.body.classList.toggle('sidebar-collapsed');
localStorage.setItem('sidebarCollapsed', isCollapsed);
sidebarToggler.setAttribute('aria-expanded', !isCollapsed);
});
// Set initial aria-expanded state
const isInitiallyCollapsed = localStorage.getItem('sidebarCollapsed') === 'true';
sidebarToggler.setAttribute('aria-expanded', !isInitiallyCollapsed);
}
// --- The rest of your original main.js --- //
$(document).ready(function() {
// Handler for showing the edit person modal
$('#editPersonModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget); // Button that triggered the modal
var personId = button.data('person-id'); // Extract info from data-* attributes
var modal = $(this);
// Clear previous data
modal.find('form').trigger('reset');
modal.find('#editPersonId').val('');
modal.find('#editRoles').empty();
modal.find('#followUpSummaryContainer').empty(); // Clear summary container
// Clear file paths
modal.find('#editCompanyLogoPath, #editPersonPhotoPath, #editGainsSheetPath, #editTopWantedPath, #editTopOwnedPath').text('');
if (personId) {
// AJAX request to get person details
$.ajax({
url: '_get_person_details.php',
type: 'GET',
data: { id: personId },
dataType: 'json',
success: function(response) {
if (response.error) {
alert('Error fetching person details: ' + response.error);
return;
}
var person = response.person;
var all_functions = response.all_functions;
var person_functions = response.person_functions;
var followUpSummary = response.follow_up_summary;
if (!person) {
alert('Could not find person data.');
return;
}
// Populate the Follow-up Summary
var summaryContainer = modal.find('#followUpSummaryContainer');
if (followUpSummary) {
let summaryHtml = '
Follow-up Process Summary
';
summaryHtml += '
';
if (followUpSummary.last_call_outcome) {
summaryHtml += `