eps-test / index.html
poluser's picture
Add 3 files
015a2d4 verified
Raw History Blame Contribute Delete
65.9 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>ConstructTrack - Construction Project Cost Tracker</title> <script src="https://cdn.tailwindcss.com"></script> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> .sidebar { transition: all 0.3s; } .sidebar.collapsed { width: 80px; } .sidebar.collapsed .nav-text { display: none; } .sidebar.collapsed .logo-text { display: none; } .main-content { transition: all 0.3s; } .sidebar.collapsed + .main-content { margin-left: 80px; } .progress-bar { transition: width 0.6s ease; } .chart-container { position: relative; height: 300px; width: 100%; } .custom-scrollbar::-webkit-scrollbar { width: 6px; height: 6px; } .custom-scrollbar::-webkit-scrollbar-track { background: #f1f1f1; } .custom-scrollbar::-webkit-scrollbar-thumb { background: #888; border-radius: 3px; } .custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #555; } .editable-field { border-bottom: 1px dashed #ccc; cursor: pointer; min-width: 80px; } .editable-field:hover { background-color: #f0f9ff; } .editable-field:focus { outline: none; border-bottom: 2px solid #3b82f6; background-color: white; } [contenteditable="true"] { padding: 2px 4px; } .profit-positive { color: #10B981; } .profit-negative { color: #EF4444; } .modal { transition: opacity 0.3s ease, visibility 0.3s ease; } .status-budget { background-color: #EFF6FF; color: #1D4ED8; } .status-time { background-color: #ECFDF5; color: #047857; } .status-budget-time { background-color: #FEF3C7; color: #92400E; } .status-over { background-color: #FEE2E2; color: #B91C1C; } .status-proposal { background-color: #F5F3FF; color: #6D28D9; } .status-awarded { background-color: #ECFDF5; color: #059669; } .status-not-started { background-color: #F3F4F6; color: #4B5563; } .status-completed { background-color: #F0FDF4; color: #16A34A; } </style> </head> <body class="bg-gray-100 font-sans"> <div class="flex h-screen overflow-hidden"> <!-- Sidebar --> <div class="sidebar bg-blue-800 text-white w-64 flex flex-col"> <div class="p-4 flex items-center justify-between border-b border-blue-700"> <div class="flex items-center"> <i class="fas fa-hard-hat text-2xl mr-3"></i> <span class="logo-text text-xl font-bold">CKI Builders</span> </div> <button id="toggleSidebar" class="text-white focus:outline-none"> <i class="fas fa-bars"></i> </button> </div> <div class="p-4 border-b border-blue-700"> <div class="flex items-center"> <div class="w-10 h-10 rounded-full bg-blue-600 flex items-center justify-center"> <i class="fas fa-user"></i> </div> <div class="ml-3 nav-text"> <div class="font-medium">Administrator</div> <div class="text-xs text-blue-200">Admin</div> </div> </div> </div> <nav class="flex-1 overflow-y-auto"> <div class="p-2"> <a href="#" class="flex items-center p-2 rounded hover:bg-blue-700"> <i class="fas fa-tachometer-alt mr-3"></i> <span class="nav-text">Dashboard</span> </a> <a href="#projects" class="flex items-center p-2 rounded bg-blue-700"> <i class="fas fa-project-diagram mr-3"></i> <span class="nav-text">Projects</span> </a> <a href="#" class="flex items-center p-2 rounded hover:bg-blue-700"> <i class="fas fa-dollar-sign mr-3"></i> <span class="nav-text">Cost Tracking</span> </a> <a href="#" class="flex items-center p-2 rounded hover:bg-blue-700"> <i class="fas fa-chart-bar mr-3"></i> <span class="nav-text">Reports</span> </a> <a href="#" class="flex items-center p-2 rounded hover:bg-blue-700"> <i class="fas fa-users mr-3"></i> <span class="nav-text">Contractors</span> </a> <a href="#" class="flex items-center p-2 rounded hover:bg-blue-700"> <i class="fas fa-truck mr-3"></i> <span class="nav-text">Materials</span> </a> <a href="#" class="flex items-center p-2 rounded hover:bg-blue-700"> <i class="fas fa-calendar-alt mr-3"></i> <span class="nav-text">Schedule</span> </a> </div> <div class="p-2 border-t border-blue-700"> <a href="#" class="flex items-center p-2 rounded hover:bg-blue-700"> <i class="fas fa-cog mr-3"></i> <span class="nav-text">Settings</span> </a> <a href="#" class="flex items-center p-2 rounded hover:bg-blue-700"> <i class="fas fa-sign-out-alt mr-3"></i> <span class="nav-text">Logout</span> </a> </div> </nav> </div> <!-- Main Content --> <div class="main-content flex-1 overflow-auto"> <header class="bg-white shadow-sm p-4 flex justify-between items-center"> <h1 class="text-2xl font-bold text-gray-800">Portfolio Management</h1> <div class="flex items-center space-x-4"> <button class="p-2 rounded-full hover:bg-gray-100 relative"> <i class="fas fa-bell text-gray-600"></i> <span class="absolute top-0 right-0 h-2 w-2 rounded-full bg-red-500"></span> </button> <div class="flex items-center"> <i class="fas fa-peso-sign mr-1 text-gray-600"></i> <span class="text-sm font-medium">PHP</span> </div> </div> </header> <main class="p-6" id="projects"> <!-- Projects Header --> <div class="flex justify-between items-center mb-6"> <div> <h2 class="text-xl font-semibold text-gray-800">All Projects</h2> <p class="text-gray-600">Overview of all active and completed construction projects</p> </div> <button id="newProjectBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center"> <i class="fas fa-plus mr-2"></i> New Project </button> </div> <!-- Projects Summary Cards --> <div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-6" id="summaryCards"> <!-- Cards will be updated dynamically --> </div> <!-- Projects Table --> <div class="bg-white rounded-lg shadow overflow-hidden mb-6"> <div class="p-4 border-b flex justify-between items-center"> <div class="flex items-center space-x-4"> <h2 class="text-lg font-semibold">Active Projects</h2> <div class="relative"> <input type="text" id="projectSearch" placeholder="Search projects..." class="pl-10 pr-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 w-64"> <i class="fas fa-search absolute left-3 top-3 text-gray-400"></i> </div> </div> <div class="flex space-x-2"> <button id="allFilter" class="px-3 py-1 text-xs bg-blue-100 text-blue-600 rounded">All</button> <button id="commercialFilter" class="px-3 py-1 text-xs bg-gray-100 text-gray-600 rounded">Commercial</button> <button id="residentialFilter" class="px-3 py-1 text-xs bg-gray-100 text-gray-600 rounded">Residential</button> <button id="industrialFilter" class="px-3 py-1 text-xs bg-gray-100 text-gray-600 rounded">Industrial</button> <button id="customFilter" class="px-3 py-1 text-xs bg-gray-100 text-gray-600 rounded">Custom</button> </div> </div> <div class="overflow-x-auto custom-scrollbar"> <table class="min-w-full divide-y divide-gray-200"> <thead class="bg-gray-50"> <tr> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Project</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Client</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Contract Value</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Budget</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Spent</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Profit %</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Progress</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Timeline</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th> </tr> </thead> <tbody class="bg-white divide-y divide-gray-200" id="projectsTableBody"> <!-- Projects will be loaded here by JavaScript --> </tbody> </table> </div> </div> </main> </div> </div> <!-- New Project Modal --> <div id="newProjectModal" class="modal fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full hidden"> <div class="relative top-20 mx-auto p-5 border w-11/12 max-w-2xl shadow-lg rounded-md bg-white"> <div class="flex justify-between items-center mb-4"> <h3 class="text-xl font-semibold">Add New Project</h3> <button id="closeModal" class="text-gray-500 hover:text-gray-700"> <i class="fas fa-times"></i> </button> </div> <form id="projectForm"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4"> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Project Name</label> <input type="text" id="projectName" class="w-full px-3 py-2 border rounded-md"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Project Code</label> <input type="text" id="projectCode" class="w-full px-3 py-2 border rounded-md"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Client Name</label> <input type="text" id="clientName" class="w-full px-3 py-2 border rounded-md"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Client Contact</label> <input type="text" id="clientContact" class="w-full px-3 py-2 border rounded-md"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Contract Value (₱)</label> <input type="number" id="contractValue" class="w-full px-3 py-2 border rounded-md" value="0" step="0.01"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Project Budget (₱)</label> <input type="number" id="projectBudget" class="w-full px-3 py-2 border rounded-md" value="0" step="0.01"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Amount Spent (₱)</label> <input type="number" id="projectSpent" class="w-full px-3 py-2 border rounded-md" value="0" step="0.01"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Project Progress (%)</label> <input type="number" id="projectProgress" class="w-full px-3 py-2 border rounded-md" value="0" step="0.01"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Start Date</label> <input type="date" id="startDate" class="w-full px-3 py-2 border rounded-md"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">End Date</label> <input type="date" id="endDate" class="w-full px-3 py-2 border rounded-md"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Project Phase</label> <select id="projectPhase" class="w-full px-3 py-2 border rounded-md"> <option value="proposal">Proposal</option> <option value="awarded">Awarded (Not Started)</option> <option value="ongoing" selected>On-going</option> <option value="completed">Completed</option> </select> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Award Date</label> <input type="date" id="awardDate" class="w-full px-3 py-2 border rounded-md"> </div> <div class="md:col-span-2"> <label class="block text-sm font-medium text-gray-700 mb-1">Project Type</label> <div class="flex items-center"> <select id="projectType" class="w-full px-3 py-2 border rounded-md mr-2"> <option value="">Select project type</option> <option value="commercial">Commercial</option> <option value="residential">Residential</option> <option value="industrial">Industrial</option> <option value="custom">Custom</option> </select> <input type="text" id="customProjectType" class="w-full px-3 py-2 border rounded-md hidden" placeholder="Enter custom type"> </div> </div> <div class="md:col-span-2"> <label class="block text-sm font-medium text-gray-700 mb-1">Project Description</label> <textarea id="projectDescription" class="w-full px-3 py-2 border rounded-md" rows="3"></textarea> </div> </div> <div class="flex justify-end space-x-3"> <button type="button" id="cancelProject" class="px-4 py-2 border rounded-md hover:bg-gray-100">Cancel</button> <button type="submit" class="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700">Save Project</button> </div> </form> </div> </div> <!-- Edit Project Modal --> <div id="editProjectModal" class="modal fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full hidden"> <div class="relative top-20 mx-auto p-5 border w-11/12 max-w-2xl shadow-lg rounded-md bg-white"> <div class="flex justify-between items-center mb-4"> <h3 class="text-xl font-semibold">Edit Project</h3> <button id="closeEditModal" class="text-gray-500 hover:text-gray-700"> <i class="fas fa-times"></i> </button> </div> <form id="editProjectForm"> <input type="hidden" id="editProjectId"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4"> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Project Name</label> <input type="text" id="editProjectName" class="w-full px-3 py-2 border rounded-md"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Project Code</label> <input type="text" id="editProjectCode" class="w-full px-3 py-2 border rounded-md"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Client Name</label> <input type="text" id="editClientName" class="w-full px-3 py-2 border rounded-md"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Client Contact</label> <input type="text" id="editClientContact" class="w-full px-3 py-2 border rounded-md"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Contract Value (₱)</label> <input type="number" id="editContractValue" class="w-full px-3 py-2 border rounded-md" step="0.01"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Project Budget (₱)</label> <input type="number" id="editProjectBudget" class="w-full px-3 py-2 border rounded-md" step="0.01"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Amount Spent (₱)</label> <input type="number" id="editProjectSpent" class="w-full px-3 py-2 border rounded-md" step="0.01"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Project Progress (%)</label> <input type="number" id="editProjectProgress" class="w-full px-3 py-2 border rounded-md" step="0.01"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Start Date</label> <input type="date" id="editStartDate" class="w-full px-3 py-2 border rounded-md"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">End Date</label> <input type="date" id="editEndDate" class="w-full px-3 py-2 border rounded-md"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Project Phase</label> <select id="editProjectPhase" class="w-full px-3 py-2 border rounded-md"> <option value="proposal">Proposal</option> <option value="awarded">Awarded (Not Started)</option> <option value="ongoing">On-going</option> <option value="completed">Completed</option> </select> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Award Date</label> <input type="date" id="editAwardDate" class="w-full px-3 py-2 border rounded-md"> </div> <div class="md:col-span-2"> <label class="block text-sm font-medium text-gray-700 mb-1">Project Type</label> <div class="flex items-center"> <select id="editProjectType" class="w-full px-3 py-2 border rounded-md mr-2"> <option value="">Select project type</option> <option value="commercial">Commercial</option> <option value="residential">Residential</option> <option value="industrial">Industrial</option> <option value="custom">Custom</option> </select> <input type="text" id="editCustomProjectType" class="w-full px-3 py-2 border rounded-md hidden" placeholder="Enter custom type"> </div> </div> <div class="md:col-span-2"> <label class="block text-sm font-medium text-gray-700 mb-1">Project Description</label> <textarea id="editProjectDescription" class="w-full px-3 py-2 border rounded-md" rows="3"></textarea> </div> </div> <div class="flex justify-end space-x-3"> <button type="button" id="cancelEditProject" class="px-4 py-2 border rounded-md hover:bg-gray-100">Cancel</button> <button type="submit" class="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700">Update Project</button> </div> </form> </div> </div> <!-- Delete Confirmation Modal --> <div id="deleteProjectModal" class="modal fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full hidden"> <div class="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white"> <div class="flex justify-between items-center mb-4"> <h3 class="text-xl font-semibold">Confirm Deletion</h3> <button id="closeDeleteModal" class="text-gray-500 hover:text-gray-700"> <i class="fas fa-times"></i> </button> </div> <div class="mb-6"> <p>Are you sure you want to delete this project? This action cannot be undone.</p> <p class="font-semibold mt-2" id="projectToDeleteName"></p> </div> <div class="flex justify-end space-x-3"> <button type="button" id="cancelDeleteProject" class="px-4 py-2 border rounded-md hover:bg-gray-100">Cancel</button> <button type="button" id="confirmDeleteProject" class="px-4 py-2 bg-red-600 text-white rounded-md hover:bg-red-700">Delete Project</button> </div> </div> </div> <script> // Sample project data let projects = [ { id: 1, name: "Downtown Office Tower", code: "PROJ-2023-001", client: "Global Corp", contact: "John Smith", type: "commercial", contractValue: 62500000.50, budget: 55000000.75, spent: 43750000.25, profitMargin: 12.5, progress: 65.5, startDate: "2023-06-01", endDate: "2023-09-15", phase: "ongoing", awardDate: "2023-05-15", daysLeft: 45, status: "On Budget", statusClass: "status-budget", description: "35-story office building in downtown business district" }, { id: 2, name: "Riverside Condos", code: "PROJ-2023-002", client: "Urban Living", contact: "Sarah Johnson", type: "residential", contractValue: 42500000.00, budget: 40000000.00, spent: 36000000.00, profitMargin: 15.3, progress: 82.0, startDate: "2023-04-15", endDate: "2023-08-30", phase: "ongoing", awardDate: "2023-03-01", daysLeft: 22, status: "Ahead of Time", statusClass: "status-time", description: "Luxury condominium complex with river views" } ]; // Custom project types let customProjectTypes = ["commercial", "residential", "industrial"]; // Filter variables let filteredProjects = [...projects]; let currentFilter = "all"; let projectToDelete = null; // DOM elements const projectsTableBody = document.getElementById('projectsTableBody'); const projectSearch = document.getElementById('projectSearch'); const allFilter = document.getElementById('allFilter'); const commercialFilter = document.getElementById('commercialFilter'); const residentialFilter = document.getElementById('residentialFilter'); const industrialFilter = document.getElementById('industrialFilter'); const customFilter = document.getElementById('customFilter'); const summaryCards = document.getElementById('summaryCards'); // Modal elements const newProjectModal = document.getElementById('newProjectModal'); const editProjectModal = document.getElementById('editProjectModal'); const deleteProjectModal = document.getElementById('deleteProjectModal'); // Initialize the page document.addEventListener('DOMContentLoaded', function() { renderProjects(); updateSummaryCards(); setupEventListeners(); }); // Render all projects function renderProjects() { // Clear existing rows projectsTableBody.innerHTML = ''; // Add rows for each project filteredProjects.forEach(project => { // Calculate profit margin if not already set if (project.profitMargin === undefined || isNaN(project.profitMargin)) { project.profitMargin = ((project.contractValue - project.spent) / project.contractValue) * 100; } const profitText = `${project.profitMargin.toFixed(2)}%`; const profitClass = project.profitMargin >= 0 ? 'profit-positive' : 'profit-negative'; // Determine phase status let phaseStatus = ""; let phaseClass = ""; if (project.phase === "proposal") { phaseStatus = "Proposal"; phaseClass = "status-proposal"; } else if (project.phase === "awarded") { phaseStatus = "Awarded (Not Started)"; phaseClass = "status-awarded"; } else if (project.phase === "ongoing") { // For ongoing projects, show the budget/time status phaseStatus = project.status; phaseClass = project.statusClass; } else if (project.phase === "completed") { phaseStatus = "Completed"; phaseClass = "status-completed"; } const row = document.createElement('tr'); row.innerHTML = ` <td class="px-6 py-4 whitespace-nowrap"> <div class="flex items-center"> <div class="flex-shrink-0 h-10 w-10 rounded-full ${getProjectIconClass(project.type)} flex items-center justify-center"> <i class="${getProjectIcon(project.type)}"></i> </div> <div class="ml-4"> <div class="text-sm font-medium text-gray-900">${project.name}</div> <div class="text-sm text-gray-500">${project.code}</div> </div> </div> </td> <td class="px-6 py-4 whitespace-nowrap"> <div class="text-sm font-medium text-gray-900">${project.client}</div> <div class="text-sm text-gray-500">${project.contact}</div> </td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">₱${formatNumber(project.contractValue)}</td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">₱${formatNumber(project.budget)}</td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">₱${formatNumber(project.spent)}</td> <td class="px-6 py-4 whitespace-nowrap text-sm font-medium ${profitClass}">${profitText}</td> <td class="px-6 py-4 whitespace-nowrap"> <div class="flex items-center"> <div class="w-16 mr-2"> <div class="w-full bg-gray-200 rounded-full h-2"> <div class="${getProgressBarColor(project.progress)} h-2 rounded-full" style="width: ${project.progress}%"></div> </div> </div> <span class="text-sm text-gray-900">${project.progress.toFixed(2)}%</span> </div> </td> <td class="px-6 py-4 whitespace-nowrap"> ${project.startDate ? ` <div class="text-sm text-gray-900">${formatDate(project.startDate)} - ${formatDate(project.endDate)}</div> <div class="text-sm text-gray-500">${project.daysLeft} days left</div> ` : ` <div class="text-sm text-gray-500">Not started</div> `} </td> <td class="px-6 py-4 whitespace-nowrap"> <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${phaseClass}">${phaseStatus}</span> </td> <td class="px-6 py-4 whitespace-nowrap text-sm font-medium"> <button class="text-blue-600 hover:text-blue-900 mr-3 edit-project" data-id="${project.id}"><i class="fas fa-edit"></i></button> <button class="text-red-600 hover:text-red-900 delete-project" data-id="${project.id}"><i class="fas fa-trash-alt"></i></button> </td> `; projectsTableBody.appendChild(row); }); // Update summary cards after rendering projects updateSummaryCards(); } // Update summary cards based on filtered projects function updateSummaryCards() { if (filteredProjects.length === 0) { summaryCards.innerHTML = '<p class="text-gray-500">No projects match the current filter</p>'; return; } // Calculate summary statistics const totalProjects = filteredProjects.length; const totalContractValue = filteredProjects.reduce((sum, project) => sum + project.contractValue, 0); // Count projects by phase const proposalProjects = filteredProjects.filter(p => p.phase === "proposal").length; const awardedProjects = filteredProjects.filter(p => p.phase === "awarded").length; const ongoingProjects = filteredProjects.filter(p => p.phase === "ongoing").length; const completedProjects = filteredProjects.filter(p => p.phase === "completed").length; // Calculate average project duration in days (only for ongoing/completed projects) const projectsWithDates = filteredProjects.filter(p => p.startDate && p.endDate); const totalDuration = projectsWithDates.reduce((sum, project) => { const start = new Date(project.startDate); const end = new Date(project.endDate); const duration = (end - start) / (1000 * 60 * 60 * 24); return sum + duration; }, 0); const avgDuration = projectsWithDates.length > 0 ? Math.round(totalDuration / projectsWithDates.length) : 0; // Calculate average profit margin (only for ongoing/completed projects) const projectsWithProfit = filteredProjects.filter(p => p.phase === "ongoing" || p.phase === "completed"); const totalProfitMargin = projectsWithProfit.reduce((sum, project) => sum + project.profitMargin, 0); const avgProfitMargin = projectsWithProfit.length > 0 ? (totalProfitMargin / projectsWithProfit.length).toFixed(2) : 0; // Find highest and lowest profit margins const profitMargins = projectsWithProfit.map(project => project.profitMargin); const highestProfit = profitMargins.length > 0 ? Math.max(...profitMargins).toFixed(2) : 0; const lowestProfit = profitMargins.length > 0 ? Math.min(...profitMargins).toFixed(2) : 0; // Find highest and lowest invoiced amounts const invoicedAmounts = filteredProjects.map(project => project.contractValue); const highestInvoiced = Math.max(...invoicedAmounts); const lowestInvoiced = Math.min(...invoicedAmounts); // Find shortest and longest durations const durations = projectsWithDates.map(project => { const start = new Date(project.startDate); const end = new Date(project.endDate); return (end - start) / (1000 * 60 * 60 * 24); }); const shortestDuration = durations.length > 0 ? Math.min(...durations) : 0; const longestDuration = durations.length > 0 ? Math.max(...durations) : 0; // Update the summary cards summaryCards.innerHTML = ` <div class="bg-white rounded-lg shadow p-6"> <div class="flex justify-between items-start"> <div> <p class="text-gray-500">Total Projects</p> <h3 class="text-2xl font-bold">${totalProjects}</h3> </div> <div class="p-3 rounded-full bg-blue-100 text-blue-600"> <i class="fas fa-project-diagram text-xl"></i> </div> </div> <div class="mt-4"> <div class="flex justify-between text-sm text-gray-500"> <span>Proposals</span> <span class="font-medium">${proposalProjects}</span> </div> <div class="flex justify-between text-sm text-gray-500"> <span>Awarded</span> <span class="font-medium">${awardedProjects}</span> </div> <div class="flex justify-between text-sm text-gray-500"> <span>On-going</span> <span class="font-medium">${ongoingProjects}</span> </div> <div class="flex justify-between text-sm text-gray-500"> <span>Completed</span> <span class="font-medium">${completedProjects}</span> </div> </div> </div> <div class="bg-white rounded-lg shadow p-6"> <div class="flex justify-between items-start"> <div> <p class="text-gray-500">Total Contract Value</p> <h3 class="text-2xl font-bold">₱${formatNumber(totalContractValue)}</h3> </div> <div class="p-3 rounded-full bg-green-100 text-green-600"> <i class="fas fa-file-contract text-xl"></i> </div> </div> <div class="mt-4"> <div class="flex justify-between text-sm text-gray-500"> <span>Highest</span> <span class="font-medium">₱${formatNumber(highestInvoiced)}</span> </div> <div class="flex justify-between text-sm text-gray-500"> <span>Lowest</span> <span class="font-medium">₱${formatNumber(lowestInvoiced)}</span> </div> </div> </div> <div class="bg-white rounded-lg shadow p-6"> <div class="flex justify-between items-start"> <div> <p class="text-gray-500">Avg. Project Duration</p> <h3 class="text-2xl font-bold">${avgDuration} days</h3> </div> <div class="p-3 rounded-full bg-purple-100 text-purple-600"> <i class="fas fa-calendar-alt text-xl"></i> </div> </div> <div class="mt-4"> <div class="flex justify-between text-sm text-gray-500"> <span>Shortest</span> <span class="font-medium">${shortestDuration} days</span> </div> <div class="flex justify-between text-sm text-gray-500"> <span>Longest</span> <span class="font-medium">${longestDuration} days</span> </div> </div> </div> <div class="bg-white rounded-lg shadow p-6"> <div class="flex justify-between items-start"> <div> <p class="text-gray-500">Avg. Profit Margin</p> <h3 class="text-2xl font-bold">${avgProfitMargin}%</h3> </div> <div class="p-3 rounded-full bg-orange-100 text-orange-600"> <i class="fas fa-chart-pie text-xl"></i> </div> </div> <div class="mt-4"> <div class="flex justify-between text-sm text-gray-500"> <span>Highest</span> <span class="font-medium profit-positive">${highestProfit}%</span> </div> <div class="flex justify-between text-sm text-gray-500"> <span>Lowest</span> <span class="font-medium profit-negative">${lowestProfit}%</span> </div> </div> </div> `; } // Filter projects based on search term function filterProjects(searchTerm = '', filterType = currentFilter) { currentFilter = filterType; filteredProjects = projects.filter(project => { // Apply type filter const typeMatch = filterType === 'all' || (filterType === 'custom' ? !['commercial', 'residential', 'industrial'].includes(project.type) : project.type === filterType); // Apply search term filter const searchMatch = project.name.toLowerCase().includes(searchTerm.toLowerCase()) || project.code.toLowerCase().includes(searchTerm.toLowerCase()) || project.client.toLowerCase().includes(searchTerm.toLowerCase()) || project.contact.toLowerCase().includes(searchTerm.toLowerCase()); return typeMatch && searchMatch; }); renderProjects(); } // Helper functions function formatNumber(num) { return num.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ","); } function formatDate(dateString) { if (!dateString) return ""; const options = { year: 'numeric', month: 'short', day: 'numeric' }; return new Date(dateString).toLocaleDateString(undefined, options); } function getProjectIcon(type) { switch(type) { case 'commercial': return 'fas fa-building'; case 'residential': return 'fas fa-home'; case 'industrial': return 'fas fa-warehouse'; default: return 'fas fa-project-diagram'; } } function getProjectIconClass(type) { switch(type) { case 'commercial': return 'bg-blue-100 text-blue-600'; case 'residential': return 'bg-green-100 text-green-600'; case 'industrial': return 'bg-yellow-100 text-yellow-600'; default: return 'bg-gray-100 text-gray-600'; } } function getProgressBarColor(progress) { if (progress >= 80) return 'bg-green-500'; if (progress >= 50) return 'bg-blue-500'; return 'bg-yellow-500'; } function calculateDaysLeft(endDate) { if (!endDate) return 0; const today = new Date(); const end = new Date(endDate); const diffTime = end - today; const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); return diffDays > 0 ? diffDays : 0; } function calculateStatus(progress, daysLeft, originalDays, spent, budget) { // Only calculate status for ongoing projects if (progress <= 0) return { status: "Not Started", class: "status-not-started" }; if (progress >= 100) return { status: "Completed", class: "status-completed" }; // Calculate time status const progressRatio = progress / 100; const timeRatio = 1 - (daysLeft / originalDays); let timeStatus = ""; if (progressRatio > timeRatio + 0.2) { timeStatus = "Ahead of Time"; } else if (progressRatio < timeRatio - 0.2) { timeStatus = "Behind Time"; } else { timeStatus = "On Time"; } // Calculate budget status let budgetStatus = ""; if (spent > budget * 1.1) { // 10% over budget budgetStatus = "Over Budget"; } else if (spent < budget * 0.9) { // 10% under budget budgetStatus = "Under Budget"; } else { budgetStatus = "On Budget"; } // Combine statuses if (budgetStatus === "On Budget" && timeStatus === "On Time") { return { status: "On Budget & Time", class: "status-budget-time" }; } else if (budgetStatus === "Over Budget" && timeStatus === "Behind Time") { return { status: "Over Budget & Time", class: "status-over" }; } else if (budgetStatus === "On Budget") { return { status: timeStatus, class: timeStatus === "Ahead of Time" ? "status-time" : "status-budget" }; } else if (timeStatus === "On Time") { return { status: budgetStatus, class: "status-budget" }; } else { return { status: `${budgetStatus}, ${timeStatus}`, class: "status-budget-time" }; } } // Set up event listeners function setupEventListeners() { // Toggle sidebar document.getElementById('toggleSidebar').addEventListener('click', function() { document.querySelector('.sidebar').classList.toggle('collapsed'); }); // Search input projectSearch.addEventListener('input', (e) => { filterProjects(e.target.value, currentFilter); }); // Filter buttons allFilter.addEventListener('click', () => { currentFilter = 'all'; updateFilterButtons(); filterProjects(projectSearch.value, 'all'); }); commercialFilter.addEventListener('click', () => { currentFilter = 'commercial'; updateFilterButtons(); filterProjects(projectSearch.value, 'commercial'); }); residentialFilter.addEventListener('click', () => { currentFilter = 'residential'; updateFilterButtons(); filterProjects(projectSearch.value, 'residential'); }); industrialFilter.addEventListener('click', () => { currentFilter = 'industrial'; updateFilterButtons(); filterProjects(projectSearch.value, 'industrial'); }); customFilter.addEventListener('click', () => { currentFilter = 'custom'; updateFilterButtons(); filterProjects(projectSearch.value, 'custom'); }); // New Project Modal const newProjectBtn = document.getElementById('newProjectBtn'); const closeModal = document.getElementById('closeModal'); const cancelProject = document.getElementById('cancelProject'); const projectForm = document.getElementById('projectForm'); const projectTypeSelect = document.getElementById('projectType'); const customProjectTypeInput = document.getElementById('customProjectType'); // Show/hide custom project type input based on selection projectTypeSelect.addEventListener('change', function() { if (this.value === 'custom') { customProjectTypeInput.classList.remove('hidden'); customProjectTypeInput.required = true; } else { customProjectTypeInput.classList.add('hidden'); customProjectTypeInput.required = false; } }); newProjectBtn.addEventListener('click', () => { newProjectModal.classList.remove('hidden'); }); closeModal.addEventListener('click', () => { newProjectModal.classList.add('hidden'); }); cancelProject.addEventListener('click', () => { newProjectModal.classList.add('hidden'); }); projectForm.addEventListener('submit', (e) => { e.preventDefault(); // Get form values with defaults for empty fields const name = document.getElementById('projectName').value || 'Unnamed Project'; const code = document.getElementById('projectCode').value || 'PROJ-' + new Date().getFullYear() + '-' + (projects.length + 1).toString().padStart(3, '0'); const client = document.getElementById('clientName').value || 'Unknown Client'; const contact = document.getElementById('clientContact').value || 'N/A'; const contractValue = parseFloat(document.getElementById('contractValue').value) || 0; const budget = parseFloat(document.getElementById('projectBudget').value) || 0; const spent = parseFloat(document.getElementById('projectSpent').value) || 0; const progress = parseFloat(document.getElementById('projectProgress').value) || 0; const startDate = document.getElementById('startDate').value || ''; const endDate = document.getElementById('endDate').value || ''; const phase = document.getElementById('projectPhase').value || 'proposal'; const awardDate = document.getElementById('awardDate').value || ''; let type = document.getElementById('projectType').value || 'commercial'; const description = document.getElementById('projectDescription').value || 'No description provided'; // If custom type is selected, use the custom input value if (type === 'custom') { type = document.getElementById('customProjectType').value || 'custom'; // Add to custom project types if not already there if (!customProjectTypes.includes(type)) { customProjectTypes.push(type); } } // Calculate profit margin const profitMargin = ((contractValue - spent) / contractValue) * 100; // Calculate days left const daysLeft = calculateDaysLeft(endDate); // Calculate original duration if dates are available let originalDays = 0; if (startDate && endDate) { const start = new Date(startDate); const end = new Date(endDate); originalDays = (end - start) / (1000 * 60 * 60 * 24); } // Determine status based on phase let statusInfo; if (phase === "proposal") { statusInfo = { status: "Proposal", class: "status-proposal" }; } else if (phase === "awarded") { statusInfo = { status: "Awarded (Not Started)", class: "status-awarded" }; } else if (phase === "completed") { statusInfo = { status: "Completed", class: "status-completed" }; } else { // For ongoing projects, calculate budget/time status statusInfo = calculateStatus(progress, daysLeft, originalDays, spent, budget); } // Create new project const newProject = { id: projects.length > 0 ? Math.max(...projects.map(p => p.id)) + 1 : 1, name, code, client, contact, type, contractValue, budget, spent, profitMargin, progress, startDate, endDate, phase, awardDate, daysLeft, status: statusInfo.status, statusClass: statusInfo.class, description }; // Add to projects array projects.push(newProject); // Reset form and close modal projectForm.reset(); newProjectModal.classList.add('hidden'); // Re-render projects filterProjects(projectSearch.value, currentFilter); }); // Edit Project Modal const closeEditModal = document.getElementById('closeEditModal'); const cancelEditProject = document.getElementById('cancelEditProject'); const editProjectForm = document.getElementById('editProjectForm'); const editProjectTypeSelect = document.getElementById('editProjectType'); const editCustomProjectTypeInput = document.getElementById('editCustomProjectType'); // Show/hide custom project type input based on selection editProjectTypeSelect.addEventListener('change', function() { if (this.value === 'custom') { editCustomProjectTypeInput.classList.remove('hidden'); editCustomProjectTypeInput.required = true; } else { editCustomProjectTypeInput.classList.add('hidden'); editCustomProjectTypeInput.required = false; } }); closeEditModal.addEventListener('click', () => { editProjectModal.classList.add('hidden'); }); cancelEditProject.addEventListener('click', () => { editProjectModal.classList.add('hidden'); }); editProjectForm.addEventListener('submit', (e) => { e.preventDefault(); // Get form values with defaults const id = parseInt(document.getElementById('editProjectId').value); const name = document.getElementById('editProjectName').value || 'Unnamed Project'; const code = document.getElementById('editProjectCode').value || 'PROJ-' + new Date().getFullYear() + '-' + id.toString().padStart(3, '0'); const client = document.getElementById('editClientName').value || 'Unknown Client'; const contact = document.getElementById('editClientContact').value || 'N/A'; const contractValue = parseFloat(document.getElementById('editContractValue').value) || 0; const budget = parseFloat(document.getElementById('editProjectBudget').value) || 0; const spent = parseFloat(document.getElementById('editProjectSpent').value) || 0; const progress = parseFloat(document.getElementById('editProjectProgress').value) || 0; const startDate = document.getElementById('editStartDate').value || ''; const endDate = document.getElementById('editEndDate').value || ''; const phase = document.getElementById('editProjectPhase').value || 'proposal'; const awardDate = document.getElementById('editAwardDate').value || ''; let type = document.getElementById('editProjectType').value || 'commercial'; const description = document.getElementById('editProjectDescription').value || 'No description provided'; // If custom type is selected, use the custom input value if (type === 'custom') { type = document.getElementById('editCustomProjectType').value || 'custom'; // Add to custom project types if not already there if (!customProjectTypes.includes(type)) { customProjectTypes.push(type); } } // Calculate profit margin const profitMargin = ((contractValue - spent) / contractValue) * 100; // Calculate days left const daysLeft = calculateDaysLeft(endDate); // Calculate original duration if dates are available let originalDays = 0; if (startDate && endDate) { const start = new Date(startDate); const end = new Date(endDate); originalDays = (end - start) / (1000 * 60 * 60 * 24); } // Determine status based on phase let statusInfo; if (phase === "proposal") { statusInfo = { status: "Proposal", class: "status-proposal" }; } else if (phase === "awarded") { statusInfo = { status: "Awarded (Not Started)", class: "status-awarded" }; } else if (phase === "completed") { statusInfo = { status: "Completed", class: "status-completed" }; } else { // For ongoing projects, calculate budget/time status statusInfo = calculateStatus(progress, daysLeft, originalDays, spent, budget); } // Find and update project const projectIndex = projects.findIndex(p => p.id === id); if (projectIndex !== -1) { projects[projectIndex] = { ...projects[projectIndex], name, code, client, contact, type, contractValue, budget, spent, profitMargin, progress, startDate, endDate, phase, awardDate, daysLeft, status: statusInfo.status, statusClass: statusInfo.class, description }; } // Close modal editProjectModal.classList.add('hidden'); // Re-render projects filterProjects(projectSearch.value, currentFilter); }); // Delete Project Modal const closeDeleteModal = document.getElementById('closeDeleteModal'); const cancelDeleteProject = document.getElementById('cancelDeleteProject'); const confirmDeleteProject = document.getElementById('confirmDeleteProject'); closeDeleteModal.addEventListener('click', () => { deleteProjectModal.classList.add('hidden'); }); cancelDeleteProject.addEventListener('click', () => { deleteProjectModal.classList.add('hidden'); }); confirmDeleteProject.addEventListener('click', () => { if (projectToDelete) { // Remove project from array projects = projects.filter(p => p.id !== projectToDelete.id); // Close modal deleteProjectModal.classList.add('hidden'); // Re-render projects filterProjects(projectSearch.value, currentFilter); } }); // Edit and Delete buttons (delegated since rows are dynamic) projectsTableBody.addEventListener('click', (e) => { if (e.target.closest('.edit-project')) { const projectId = parseInt(e.target.closest('.edit-project').getAttribute('data-id')); const project = projects.find(p => p.id === projectId); // Fill edit form with project data document.getElementById('editProjectId').value = project.id; document.getElementById('editProjectName').value = project.name; document.getElementById('editProjectCode').value = project.code; document.getElementById('editClientName').value = project.client; document.getElementById('editClientContact').value = project.contact; document.getElementById('editContractValue').value = project.contractValue; document.getElementById('editProjectBudget').value = project.budget; document.getElementById('editProjectSpent').value = project.spent; document.getElementById('editProjectProgress').value = project.progress; document.getElementById('editStartDate').value = project.startDate; document.getElementById('editEndDate').value = project.endDate; document.getElementById('editProjectPhase').value = project.phase; document.getElementById('editAwardDate').value = project.awardDate; // Handle project type (check if it's custom) if (['commercial', 'residential', 'industrial'].includes(project.type)) { document.getElementById('editProjectType').value = project.type; document.getElementById('editCustomProjectType').classList.add('hidden'); } else { document.getElementById('editProjectType').value = 'custom'; document.getElementById('editCustomProjectType').value = project.type; document.getElementById('editCustomProjectType').classList.remove('hidden'); } document.getElementById('editProjectDescription').value = project.description || ''; // Show edit modal editProjectModal.classList.remove('hidden'); } if (e.target.closest('.delete-project')) { const projectId = parseInt(e.target.closest('.delete-project').getAttribute('data-id')); projectToDelete = projects.find(p => p.id === projectId); // Set project name in confirmation modal document.getElementById('projectToDeleteName').textContent = projectToDelete.name; // Show delete modal deleteProjectModal.classList.remove('hidden'); } }); } // Update filter button styles function updateFilterButtons() { allFilter.className = `px-3 py-1 text-xs rounded ${currentFilter === 'all' ? 'bg-blue-100 text-blue-600' : 'bg-gray-100 text-gray-600'}`; commercialFilter.className = `px-3 py-1 text-xs rounded ${currentFilter === 'commercial' ? 'bg-blue-100 text-blue-600' : 'bg-gray-100 text-gray-600'}`; residentialFilter.className = `px-3 py-1 text-xs rounded ${currentFilter === 'residential' ? 'bg-blue-100 text-blue-600' : 'bg-gray-100 text-gray-600'}`; industrialFilter.className = `px-3 py-1 text-xs rounded ${currentFilter === 'industrial' ? 'bg-blue-100 text-blue-600' : 'bg-gray-100 text-gray-600'}`; customFilter.className = `px-3 py-1 text-xs rounded ${currentFilter === 'custom' ? 'bg-blue-100 text-blue-600' : 'bg-gray-100 text-gray-600'}`; } </script> <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=poluser/eps-test" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> </html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ConstructTrack - Construction Project Cost Tracker</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.sidebar {
transition: all 0.3s;
}
.sidebar.collapsed {
width: 80px;
}
.sidebar.collapsed .nav-text {
display: none;
}
.sidebar.collapsed .logo-text {
display: none;
}
.main-content {
transition: all 0.3s;
}
.sidebar.collapsed + .main-content {
margin-left: 80px;
}
.progress-bar {
transition: width 0.6s ease;
}
.chart-container {
position: relative;
height: 300px;
width: 100%;
}
.custom-scrollbar::-webkit-scrollbar {
width: 6px;
height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
background: #f1f1f1;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
background: #888;
border-radius: 3px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
background: #555;
}
.editable-field {
border-bottom: 1px dashed #ccc;
cursor: pointer;
min-width: 80px;
}
.editable-field:hover {
background-color: #f0f9ff;
}
.editable-field:focus {
outline: none;
border-bottom: 2px solid #3b82f6;
background-color: white;
}
[contenteditable="true"] {
padding: 2px 4px;
}
.profit-positive {
color: #10B981;
}
.profit-negative {
color: #EF4444;
}
.modal {
transition: opacity 0.3s ease, visibility 0.3s ease;
}
.status-budget {
background-color: #EFF6FF;
color: #1D4ED8;
}
.status-time {
background-color: #ECFDF5;
color: #047857;
}
.status-budget-time {
background-color: #FEF3C7;
color: #92400E;
}
.status-over {
background-color: #FEE2E2;
color: #B91C1C;
}
.status-proposal {
background-color: #F5F3FF;
color: #6D28D9;
}
.status-awarded {
background-color: #ECFDF5;
color: #059669;
}
.status-not-started {