File size: 65,885 Bytes
015a2d4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 | <!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> |