pm-test / index.html
poluser's picture
Add 3 files
f31a66a verified
Raw History Blame Contribute Delete
61.5 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; } </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">ConstructTrack</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">Project Manager</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">Project 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"> </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"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Profit Margin (%)</label> <input type="number" id="profitMargin" class="w-full px-3 py-2 border rounded-md" value="0"> </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"> </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 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"> </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"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Profit Margin (%)</label> <input type="number" id="editProfitMargin" 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 Progress (%)</label> <input type="number" id="editProjectProgress" class="w-full px-3 py-2 border rounded-md"> </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 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, budget: 55000000, spent: 43750000, profitMargin: 12.0, progress: 65, startDate: "2023-06-01", endDate: "2023-09-15", daysLeft: 45, status: "On Track", statusClass: "bg-blue-100 text-blue-800", 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, budget: 40000000, spent: 36000000, profitMargin: 15.3, progress: 82, startDate: "2023-04-15", endDate: "2023-08-30", daysLeft: 22, status: "Ahead", statusClass: "bg-green-100 text-green-800", description: "Luxury condominium complex with river views" }, { id: 3, name: "Industrial Warehouse", code: "PROJ-2023-003", client: "Logistics Plus", contact: "Michael Brown", type: "industrial", contractValue: 105000000, budget: 97500000, spent: 102500000, profitMargin: 2.4, progress: 45, startDate: "2023-07-01", endDate: "2023-12-15", daysLeft: 98, status: "Delayed", statusClass: "bg-yellow-100 text-yellow-800", description: "100,000 sq ft distribution center with loading docks" }, { id: 4, name: "Community College", code: "PROJ-2023-004", client: "State Education", contact: "Robert Davis", type: "commercial", contractValue: 187500000, budget: 175000000, spent: 149000000, profitMargin: 6.7, progress: 58, startDate: "2023-05-01", endDate: "2023-11-30", daysLeft: 75, status: "On Budget", statusClass: "bg-purple-100 text-purple-800", description: "New campus building with classrooms and labs" }, { id: 5, name: "Luxury Villas", code: "PROJ-2023-005", client: "Elite Homes", contact: "Jennifer Wilson", type: "residential", contractValue: 75000000, budget: 70000000, spent: 62500000, profitMargin: 16.7, progress: 72, startDate: "2023-03-15", endDate: "2023-10-31", daysLeft: 65, status: "On Track", statusClass: "bg-blue-100 text-blue-800", description: "Gated community with 15 luxury villas" }, { id: 6, name: "Tech Park", code: "PROJ-2023-006", client: "Innovate Corp", contact: "David Lee", type: "commercial", contractValue: 95000000, budget: 90000000, spent: 82500000, profitMargin: 13.2, progress: 68, startDate: "2023-02-01", endDate: "2023-09-30", daysLeft: 42, status: "On Track", statusClass: "bg-blue-100 text-blue-800", description: "Technology office park with 5 buildings" }, { id: 7, name: "Manufacturing Plant", code: "PROJ-2023-007", client: "Industrial Solutions", contact: "Thomas Clark", type: "industrial", contractValue: 225000000, budget: 210000000, spent: 195000000, profitMargin: 13.3, progress: 55, startDate: "2023-06-15", endDate: "2024-01-15", daysLeft: 112, status: "On Budget", statusClass: "bg-purple-100 text-purple-800", description: "Automotive parts manufacturing facility" }, { id: 8, name: "Suburban Homes", code: "PROJ-2023-008", client: "Family Living", contact: "Emma Roberts", type: "residential", contractValue: 38000000, budget: 36000000, spent: 34500000, profitMargin: 9.2, progress: 88, startDate: "2023-01-10", endDate: "2023-08-15", daysLeft: 18, status: "Ahead", statusClass: "bg-green-100 text-green-800", description: "50 single-family homes in suburban development" } ]; // 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 => { const profit = project.contractValue - project.spent; const profitText = `${project.profitMargin}%`; const profitClass = project.profitMargin >= 0 ? 'profit-positive' : 'profit-negative'; 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}%</span> </div> </td> <td class="px-6 py-4 whitespace-nowrap"> <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> </td> <td class="px-6 py-4 whitespace-nowrap"> <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${project.statusClass}">${project.status}</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); // Calculate average project duration in days const totalDuration = filteredProjects.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 = Math.round(totalDuration / filteredProjects.length); // Calculate average profit margin const totalProfitMargin = filteredProjects.reduce((sum, project) => sum + project.profitMargin, 0); const avgProfitMargin = (totalProfitMargin / filteredProjects.length).toFixed(1); // Count active and completed projects (based on progress) const activeProjects = filteredProjects.filter(project => project.progress < 100).length; const completedProjects = filteredProjects.filter(project => project.progress >= 100).length; // Find highest and lowest profit margins const profitMargins = filteredProjects.map(project => project.profitMargin); const highestProfit = Math.max(...profitMargins).toFixed(1); const lowestProfit = Math.min(...profitMargins).toFixed(1); // 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 = filteredProjects.map(project => { const start = new Date(project.startDate); const end = new Date(project.endDate); return (end - start) / (1000 * 60 * 60 * 24); }); const shortestDuration = Math.min(...durations); const longestDuration = Math.max(...durations); // 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>Active</span> <span class="font-medium">${activeProjects}</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.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } function formatDate(dateString) { const options = { year: 'numeric', month: 'short', day: 'numeric' }; return new Date(dateString).toLocaleDateString('en-US', 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) { 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) { const progressRatio = progress / 100; const timeRatio = 1 - (daysLeft / originalDays); if (progressRatio > timeRatio + 0.2) { return { status: "Ahead", class: "bg-green-100 text-green-800" }; } else if (progressRatio < timeRatio - 0.2) { return { status: "Delayed", class: "bg-yellow-100 text-yellow-800" }; } else if (progressRatio >= timeRatio - 0.1 && progressRatio <= timeRatio + 0.1) { return { status: "On Track", class: "bg-blue-100 text-blue-800" }; } else { return { status: "On Budget", class: "bg-purple-100 text-purple-800" }; } } // 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 profitMargin = parseFloat(document.getElementById('profitMargin').value) || 0; const progress = parseFloat(document.getElementById('projectProgress').value) || 0; const startDate = document.getElementById('startDate').value || new Date().toISOString().split('T')[0]; const endDate = document.getElementById('endDate').value || new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString().split('T')[0]; 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 spent based on profit margin const spent = contractValue * (1 - (profitMargin / 100)); // Calculate days left const daysLeft = calculateDaysLeft(endDate); // Calculate status const originalDays = calculateDaysLeft(endDate, startDate); const statusInfo = calculateStatus(progress, daysLeft, originalDays); // 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, 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 profitMargin = parseFloat(document.getElementById('editProfitMargin').value) || 0; const progress = parseFloat(document.getElementById('editProjectProgress').value) || 0; const startDate = document.getElementById('editStartDate').value || new Date().toISOString().split('T')[0]; const endDate = document.getElementById('editEndDate').value || new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString().split('T')[0]; 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 spent based on profit margin const spent = contractValue * (1 - (profitMargin / 100)); // Calculate days left const daysLeft = calculateDaysLeft(endDate); // Calculate status const originalDays = calculateDaysLeft(endDate, startDate); const statusInfo = calculateStatus(progress, daysLeft, originalDays); // 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, 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('editProfitMargin').value = project.profitMargin; document.getElementById('editProjectProgress').value = project.progress; document.getElementById('editStartDate').value = project.startDate; document.getElementById('editEndDate').value = project.endDate; // 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/pm-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;
}
</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">ConstructTrack</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">Project Manager</div>
<div class="text-xs text-blue-200">Admin</div>
</div>
</div>