Spaces:
Running
Running
File size: 81,988 Bytes
46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 225a864 46b7201 |
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 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 |
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Samfact - Gestion Freelance Data Analyse</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
colors: {
primary: {
DEFAULT: '#0A84FF',
dark: '#0984FF'
},
secondary: {
DEFAULT: '#5E5CE6',
dark: '#5E5CE6'
},
background: {
DEFAULT: '#FFFFFF',
dark: '#1C1C1E'
},
surface: {
DEFAULT: '#F2F2F7',
dark: '#2C2C2E'
},
card: {
DEFAULT: '#FFFFFF',
dark: '#2C2C2E'
},
border: {
DEFAULT: '#D1D1D6',
dark: '#38383A'
},
text: {
DEFAULT: '#1C1C1E',
dark: '#FFFFFF'
},
subtitle: {
DEFAULT: '#636366',
dark: '#8E8E93'
}
},
fontFamily: {
sans: ['-apple-system', 'BlinkMacSystemFont', 'Segoe UI', 'Roboto', 'Helvetica Neue', 'Arial', 'sans-serif']
}
}
}
}
</script>
<style>
body {
@apply bg-background dark:bg-background-dark text-text dark:text-text-dark font-sans;
-webkit-font-smoothing: antialiased;
}
.sidebar {
transition: all 0.3s;
@apply bg-surface dark:bg-surface-dark border-r border-border dark:border-border-dark;
}
@media (max-width: 768px) {
.sidebar {
transform: translateX(-100%);
}
.sidebar.open {
transform: translateX(0);
}
}
.invoice-preview {
width: 210mm;
min-height: 297mm;
margin: auto;
padding: 20mm;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
@apply bg-card dark:bg-card-dark;
}
/* iOS-like elements */
.ios-card {
@apply rounded-xl shadow-sm overflow-hidden border border-border dark:border-border-dark;
}
.ios-button {
@apply rounded-full px-4 py-2 text-center font-medium text-white bg-primary dark:bg-primary-dark;
}
.ios-segmented-control {
@apply inline-flex rounded-full p-1 bg-surface dark:bg-surface-dark;
}
.ios-segmented-control button {
@apply px-4 py-1 rounded-full text-sm font-medium;
}
.ios-segmented-control button.active {
@apply bg-primary dark:bg-primary-dark text-white;
}
.ios-table-cell {
@apply px-4 py-3 border-b border-border dark:border-border-dark;
}
.ios-badge {
@apply rounded-full px-2 py-0.5 text-xs font-medium;
}
/* Dark mode toggle */
.dark-mode-toggle {
@apply w-12 h-6 rounded-full p-1 bg-gray-300 dark:bg-gray-600 flex items-center transition duration-300;
}
.dark-mode-toggle span {
@apply w-4 h-4 rounded-full bg-white dark:bg-gray-800 shadow-md transform transition duration-300 translate-x-0 dark:translate-x-6;
}
</style>
</head>
<body class="dark:bg-background-dark">
<!-- Dark Mode Toggle -->
<div class="fixed top-4 right-4 z-50">
<button id="darkModeToggle" class="dark-mode-toggle">
<span></span>
</button>
</div>
<!-- Mobile Menu Button -->
<button id="mobileMenuButton" class="md:hidden fixed top-4 left-4 z-40 bg-primary dark:bg-primary-dark text-white p-2 rounded-full">
<i class="fas fa-bars"></i>
</button>
<!-- Sidebar -->
<div id="sidebar" class="sidebar fixed top-0 left-0 h-full w-64 p-4 z-30">
<div class="flex items-center mb-8">
<div class="bg-primary dark:bg-primary-dark text-white rounded-xl p-3 mr-3">
<i class="fas fa-chart-line text-xl"></i>
</div>
<h1 class="text-2xl font-bold">Samfact</h1>
</div>
<nav>
<ul class="space-y-1">
<li>
<a href="#" id="dashboardLink" class="flex items-center p-3 rounded-lg hover:bg-surface dark:hover:bg-surface-dark transition active:bg-surface dark:active:bg-surface-dark">
<i class="fas fa-home mr-3 text-subtitle dark:text-subtitle-dark"></i> Tableau de bord
</a>
</li>
<li>
<a href="#" id="projectsLink" class="flex items-center p-3 rounded-lg hover:bg-surface dark:hover:bg-surface-dark transition active:bg-surface dark:active:bg-surface-dark">
<i class="fas fa-project-diagram mr-3 text-subtitle dark:text-subtitle-dark"></i> Projets
</a>
</li>
<li>
<a href="#" id="clientsLink" class="flex items-center p-3 rounded-lg hover:bg-surface dark:hover:bg-surface-dark transition active:bg-surface dark:active:bg-surface-dark">
<i class="fas fa-users mr-3 text-subtitle dark:text-subtitle-dark"></i> Clients
</a>
</li>
<li>
<a href="#" id="invoicesLink" class="flex items-center p-3 rounded-lg hover:bg-surface dark:hover:bg-surface-dark transition active:bg-surface dark:active:bg-surface-dark">
<i class="fas fa-file-invoice-dollar mr-3 text-subtitle dark:text-subtitle-dark"></i> Factures & Devis
</a>
</li>
<li>
<a href="#" id="settingsLink" class="flex items-center p-3 rounded-lg hover:bg-surface dark:hover:bg-surface-dark transition active:bg-surface dark:active:bg-surface-dark">
<i class="fas fa-cog mr-3 text-subtitle dark:text-subtitle-dark"></i> Paramètres
</a>
</li>
</ul>
</nav>
<div class="absolute bottom-0 left-0 w-full p-4">
<div class="bg-surface dark:bg-surface-dark p-3 rounded-xl">
<p class="text-sm text-subtitle dark:text-subtitle-dark">Auto-entrepreneur</p>
<p class="font-semibold">Data Analyse</p>
</div>
</div>
</div>
<!-- Main Content -->
<div class="ml-0 md:ml-64 transition-all duration-300">
<!-- Header -->
<header class="bg-card dark:bg-card-dark border-b border-border dark:border-border-dark p-4 flex justify-between items-center">
<h2 id="pageTitle" class="text-xl font-semibold">Tableau de bord</h2>
<div class="flex items-center space-x-4">
<div class="relative">
<button class="bg-surface dark:bg-surface-dark p-2 rounded-full hover:bg-surface dark:hover:bg-surface-dark transition">
<i class="fas fa-bell text-subtitle dark:text-subtitle-dark"></i>
</button>
<span class="absolute top-0 right-0 w-2 h-2 bg-red-500 rounded-full"></span>
</div>
<div class="flex items-center">
<div class="w-8 h-8 rounded-full bg-primary dark:bg-primary-dark flex items-center justify-center text-white">
<i class="fas fa-user"></i>
</div>
<span class="ml-2 font-medium hidden md:inline">Sam</span>
</div>
</div>
</header>
<!-- Dashboard Content -->
<main class="p-4">
<!-- Dashboard Section -->
<section id="dashboardSection">
<!-- Stats Cards -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
<div class="ios-card">
<div class="flex items-center p-4">
<div class="p-3 rounded-lg bg-blue-100 dark:bg-blue-900 text-blue-600 dark:text-blue-400 mr-4">
<i class="fas fa-project-diagram"></i>
</div>
<div>
<p class="text-subtitle dark:text-subtitle-dark">Projets en cours</p>
<h3 id="activeProjectsCount" class="text-2xl font-bold">0</h3>
</div>
</div>
</div>
<div class="ios-card">
<div class="flex items-center p-4">
<div class="p-3 rounded-lg bg-green-100 dark:bg-green-900 text-green-600 dark:text-green-400 mr-4">
<i class="fas fa-calendar-day"></i>
</div>
<div>
<p class="text-subtitle dark:text-subtitle-dark">Jours travaillés</p>
<h3 id="daysWorkedCount" class="text-2xl font-bold">0</h3>
</div>
</div>
</div>
<div class="ios-card">
<div class="flex items-center p-4">
<div class="p-3 rounded-lg bg-purple-100 dark:bg-purple-900 text-purple-600 dark:text-purple-400 mr-4">
<i class="fas fa-euro-sign"></i>
</div>
<div>
<p class="text-subtitle dark:text-subtitle-dark">Revenus HT</p>
<h3 id="totalRevenue" class="text-2xl font-bold">0€</h3>
</div>
</div>
</div>
</div>
<!-- Chart -->
<div class="ios-card p-4 mb-6">
<div class="flex justify-between items-center mb-4">
<h3 class="font-semibold">Revenus par mois</h3>
<select id="chartRange" class="border border-border dark:border-border-dark rounded-full px-3 py-1 text-sm bg-card dark:bg-card-dark">
<option value="3">3 mois</option>
<option value="6">6 mois</option>
<option value="12">12 mois</option>
</select>
</div>
<canvas id="revenueChart" height="300"></canvas>
</div>
<!-- Projects Table -->
<div class="ios-card overflow-hidden">
<div class="flex justify-between items-center p-4 border-b border-border dark:border-border-dark">
<h3 class="font-semibold">Mes projets</h3>
<button id="addProjectBtn" class="ios-button flex items-center">
<i class="fas fa-plus mr-2"></i> Nouveau projet
</button>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-border dark:divide-border-dark">
<thead class="bg-surface dark:bg-surface-dark">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Projet</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Client</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Jours</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Forfait</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Total HT</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody id="projectsTableBody" class="divide-y divide-border dark:divide-border-dark">
<!-- Projects will be added here dynamically -->
</tbody>
</table>
</div>
</div>
</section>
<!-- Projects Section -->
<section id="projectsSection" class="hidden">
<div class="ios-card overflow-hidden mb-6">
<div class="flex justify-between items-center p-4 border-b border-border dark:border-border-dark">
<h3 class="font-semibold">Tous les projets</h3>
<button id="addProjectBtn2" class="ios-button flex items-center">
<i class="fas fa-plus mr-2"></i> Nouveau projet
</button>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-border dark:divide-border-dark">
<thead class="bg-surface dark:bg-surface-dark">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Projet</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Client</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Date début</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Date fin</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Jours</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Total HT</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Statut</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody id="allProjectsTableBody" class="divide-y divide-border dark:divide-border-dark">
<!-- All projects will be added here dynamically -->
</tbody>
</table>
</div>
</div>
</section>
<!-- Clients Section -->
<section id="clientsSection" class="hidden">
<div class="ios-card overflow-hidden mb-6">
<div class="flex justify-between items-center p-4 border-b border-border dark:border-border-dark">
<h3 class="font-semibold">Mes clients</h3>
<button id="addClientBtn" class="ios-button flex items-center">
<i class="fas fa-plus mr-2"></i> Nouveau client
</button>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-border dark:divide-border-dark">
<thead class="bg-surface dark:bg-surface-dark">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Nom</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Email</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Adresse</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">SIRET</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody id="clientsTableBody" class="divide-y divide-border dark:divide-border-dark">
<!-- Clients will be added here dynamically -->
</tbody>
</table>
</div>
</div>
</section>
<!-- Invoices Section -->
<section id="invoicesSection" class="hidden">
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
<button id="allInvoicesBtn" class="ios-card p-4 text-left hover:bg-surface dark:hover:bg-surface-dark transition active:bg-surface dark:active:bg-surface-dark">
<p class="text-sm text-subtitle dark:text-subtitle-dark">Toutes</p>
<h3 id="allInvoicesCount" class="text-2xl font-bold">0</h3>
</button>
<button id="draftInvoicesBtn" class="ios-card p-4 text-left hover:bg-surface dark:hover:bg-surface-dark transition active:bg-surface dark:active:bg-surface-dark">
<p class="text-sm text-subtitle dark:text-subtitle-dark">Brouillons</p>
<h3 id="draftInvoicesCount" class="text-2xl font-bold">0</h3>
</button>
<button id="sentInvoicesBtn" class="ios-card p-4 text-left hover:bg-surface dark:hover:bg-surface-dark transition active:bg-surface dark:active:bg-surface-dark">
<p class="text-sm text-subtitle dark:text-subtitle-dark">Envoyées</p>
<h3 id="sentInvoicesCount" class="text-2xl font-bold">0</h3>
</button>
<button id="paidInvoicesBtn" class="ios-card p-4 text-left hover:bg-surface dark:hover:bg-surface-dark transition active:bg-surface dark:active:bg-surface-dark">
<p class="text-sm text-subtitle dark:text-subtitle-dark">Payées</p>
<h3 id="paidInvoicesCount" class="text-2xl font-bold">0</h3>
</button>
</div>
<div class="ios-card overflow-hidden">
<div class="flex justify-between items-center p-4 border-b border-border dark:border-border-dark">
<h3 class="font-semibold">Factures & Devis</h3>
<div class="flex space-x-2">
<button id="addInvoiceBtn" class="ios-button flex items-center">
<i class="fas fa-file-invoice-dollar mr-2"></i> Nouvelle facture
</button>
<button id="addQuoteBtn" class="bg-secondary dark:bg-secondary-dark text-white px-4 py-2 rounded-full hover:bg-opacity-90 transition flex items-center">
<i class="fas fa-file-signature mr-2"></i> Nouveau devis
</button>
</div>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-border dark:divide-border-dark">
<thead class="bg-surface dark:bg-surface-dark">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Numéro</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Client</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Date</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Échéance</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Total HT</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Statut</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Type</th>
<th class="px-6 py-3 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody id="invoicesTableBody" class="divide-y divide-border dark:divide-border-dark">
<!-- Invoices will be added here dynamically -->
</tbody>
</table>
</div>
</div>
</section>
<!-- Settings Section -->
<section id="settingsSection" class="hidden">
<div class="ios-card overflow-hidden p-6">
<h3 class="font-semibold text-lg mb-6">Paramètres</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Personal Info -->
<div class="ios-card p-4">
<h4 class="font-medium mb-4">Informations personnelles</h4>
<div class="space-y-4">
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Nom complet</label>
<input type="text" id="userName" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark">
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Email</label>
<input type="email" id="userEmail" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark">
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Adresse</label>
<textarea id="userAddress" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark"></textarea>
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">SIRET</label>
<input type="text" id="userSiret" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark">
</div>
<button id="savePersonalInfoBtn" class="ios-button w-full">
Enregistrer
</button>
</div>
</div>
<!-- Business Settings -->
<div class="ios-card p-4">
<h4 class="font-medium mb-4">Paramètres professionnels</h4>
<div class="space-y-4">
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Forfait journalier par défaut (€)</label>
<input type="number" id="defaultRate" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark">
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Conditions de paiement</label>
<input type="text" id="paymentTerms" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark" placeholder="Ex: 30 jours net">
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Logo</label>
<div class="flex items-center space-x-4">
<div class="w-16 h-16 bg-surface dark:bg-surface-dark rounded-lg flex items-center justify-center overflow-hidden">
<img id="logoPreview" src="" alt="Logo" class="hidden max-w-full max-h-full">
<i class="fas fa-camera text-subtitle dark:text-subtitle-dark"></i>
</div>
<div>
<input type="file" id="logoUpload" class="hidden" accept="image/*">
<button id="uploadLogoBtn" class="text-sm bg-surface dark:bg-surface-dark hover:bg-opacity-80 px-3 py-1 rounded-lg">
Choisir un logo
</button>
</div>
</div>
</div>
<button id="saveBusinessSettingsBtn" class="ios-button w-full">
Enregistrer
</button>
</div>
</div>
</div>
</div>
</section>
</main>
</div>
<!-- Modals -->
<!-- Add Project Modal -->
<div id="projectModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="ios-card w-full max-w-md">
<div class="flex justify-between items-center p-4 border-b border-border dark:border-border-dark">
<h3 class="font-semibold text-lg">Nouveau projet</h3>
<button id="closeProjectModal" class="text-subtitle dark:text-subtitle-dark hover:text-text dark:hover:text-text-dark">
<i class="fas fa-times"></i>
</button>
</div>
<div class="p-4">
<form id="projectForm">
<div class="space-y-4">
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Nom du projet*</label>
<input type="text" id="projectName" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark" required>
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Client*</label>
<select id="projectClient" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark" required>
<option value="">Sélectionner un client</option>
<!-- Clients will be added here dynamically -->
</select>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Date de début*</label>
<input type="date" id="projectStartDate" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark" required>
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Date de fin</label>
<input type="date" id="projectEndDate" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark">
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Jours travaillés*</label>
<input type="number" id="projectDays" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark" required>
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Forfait journalier (€)*</label>
<input type="number" id="projectRate" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark" required>
</div>
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Description</label>
<textarea id="projectDescription" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark"></textarea>
</div>
</div>
<div class="flex justify-end space-x-2 mt-6">
<button type="button" id="cancelProjectBtn" class="px-4 py-2 border border-border dark:border-border-dark rounded-lg hover:bg-surface dark:hover:bg-surface-dark">
Annuler
</button>
<button type="submit" class="ios-button">
Enregistrer
</button>
</div>
</form>
</div>
</div>
</div>
<!-- Add Client Modal -->
<div id="clientModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="ios-card w-full max-w-md">
<div class="flex justify-between items-center p-4 border-b border-border dark:border-border-dark">
<h3 class="font-semibold text-lg">Nouveau client</h3>
<button id="closeClientModal" class="text-subtitle dark:text-subtitle-dark hover:text-text dark:hover:text-text-dark">
<i class="fas fa-times"></i>
</button>
</div>
<div class="p-4">
<form id="clientForm">
<div class="space-y-4">
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Nom*</label>
<input type="text" id="clientName" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark" required>
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Email*</label>
<input type="email" id="clientEmail" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark" required>
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Adresse</label>
<textarea id="clientAddress" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark"></textarea>
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">SIRET</label>
<input type="text" id="clientSiret" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark">
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Téléphone</label>
<input type="tel" id="clientPhone" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark">
</div>
</div>
<div class="flex justify-end space-x-2 mt-6">
<button type="button" id="cancelClientBtn" class="px-4 py-2 border border-border dark:border-border-dark rounded-lg hover:bg-surface dark:hover:bg-surface-dark">
Annuler
</button>
<button type="submit" class="ios-button">
Enregistrer
</button>
</div>
</form>
</div>
</div>
</div>
<!-- Add Invoice/Quote Modal -->
<div id="invoiceModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="ios-card w-full max-w-4xl">
<div class="flex justify-between items-center p-4 border-b border-border dark:border-border-dark">
<h3 id="invoiceModalTitle" class="font-semibold text-lg">Nouvelle facture</h3>
<button id="closeInvoiceModal" class="text-subtitle dark:text-subtitle-dark hover:text-text dark:hover:text-text-dark">
<i class="fas fa-times"></i>
</button>
</div>
<div class="p-4">
<form id="invoiceForm">
<input type="hidden" id="invoiceType">
<input type="hidden" id="invoiceId">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<div class="space-y-4">
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Client*</label>
<select id="invoiceClient" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark" required>
<option value="">Sélectionner un client</option>
<!-- Clients will be added here dynamically -->
</select>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Date*</label>
<input type="date" id="invoiceDate" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark" required>
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Échéance</label>
<input type="date" id="invoiceDueDate" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark">
</div>
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Numéro</label>
<input type="text" id="invoiceNumber" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark" readonly>
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Statut</label>
<select id="invoiceStatus" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark">
<option value="draft">Brouillon</option>
<option value="sent">Envoyé</option>
<option value="paid">Payé</option>
</select>
</div>
</div>
</div>
<div>
<div class="space-y-4">
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Projet associé</label>
<select id="invoiceProject" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark">
<option value="">Aucun projet</option>
<!-- Projects will be added here dynamically -->
</select>
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Conditions de paiement</label>
<input type="text" id="invoicePaymentTerms" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark" placeholder="Ex: 30 jours net">
</div>
<div>
<label class="block text-sm text-subtitle dark:text-subtitle-dark mb-1">Notes</label>
<textarea id="invoiceNotes" class="w-full border border-border dark:border-border-dark rounded-lg px-3 py-2 bg-card dark:bg-card-dark"></textarea>
</div>
</div>
</div>
</div>
<div class="mt-6">
<h4 class="font-medium mb-2">Services</h4>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-border dark:divide-border-dark">
<thead class="bg-surface dark:bg-surface-dark">
<tr>
<th class="px-4 py-2 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Description</th>
<th class="px-4 py-2 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Jours</th>
<th class="px-4 py-2 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Forfait</th>
<th class="px-4 py-2 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider">Total</th>
<th class="px-4 py-2 text-left text-xs font-medium text-subtitle dark:text-subtitle-dark uppercase tracking-wider"></th>
</tr>
</thead>
<tbody id="invoiceItemsTable" class="divide-y divide-border dark:divide-border-dark">
<tr>
<td class="px-4 py-2"><input type="text" class="w-full border border-border dark:border-border-dark rounded-lg px-2 py-1 bg-card dark:bg-card-dark invoice-item-desc" placeholder="Description"></td>
<td class="px-4 py-2"><input type="number" class="w-full border border-border dark:border-border-dark rounded-lg px-2 py-1 bg-card dark:bg-card-dark invoice-item-days" placeholder="Jours"></td>
<td class="px-4 py-2"><input type="number" class="w-full border border-border dark:border-border-dark rounded-lg px-2 py-1 bg-card dark:bg-card-dark invoice-item-rate" placeholder="Forfait"></td>
<td class="px-4 py-2"><input type="text" class="w-full border border-border dark:border-border-dark rounded-lg px-2 py-1 bg-card dark:bg-card-dark invoice-item-total" placeholder="0.00" readonly></td>
<td class="px-4 py-2"><button type="button" class="text-red-500 hover:text-red-700 remove-item-btn"><i class="fas fa-trash"></i></button></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="5" class="px-4 py-2">
<button type="button" id="addInvoiceItemBtn" class="text-primary dark:text-primary-dark hover:text-opacity-80 text-sm">
<i class="fas fa-plus mr-1"></i> Ajouter un service
</button>
</td>
</tr>
<tr>
<td colspan="3" class="px-4 py-2 text-right font-medium">Total HT</td>
<td colspan="2" class="px-4 py-2"><input type="text" id="invoiceSubtotal" class="w-full border border-border dark:border-border-dark rounded-lg px-2 py-1 bg-card dark:bg-card-dark" value="0.00" readonly></td>
</tr>
</tfoot>
</table>
</div>
</div>
<div class="flex justify-end space-x-2 mt-6">
<button type="button" id="cancelInvoiceBtn" class="px-4 py-2 border border-border dark:border-border-dark rounded-lg hover:bg-surface dark:hover:bg-surface-dark">
Annuler
</button>
<button type="submit" class="ios-button">
Enregistrer
</button>
</div>
</form>
</div>
</div>
</div>
<!-- Invoice Preview Modal -->
<div id="invoicePreviewModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden overflow-y-auto">
<div class="ios-card w-full max-w-4xl m-4">
<div class="flex justify-between items-center p-4 border-b border-border dark:border-border-dark">
<h3 id="invoicePreviewTitle" class="font-semibold text-lg">Aperçu</h3>
<div class="flex space-x-2">
<button id="printInvoiceBtn" class="bg-surface dark:bg-surface-dark hover:bg-opacity-80 px-3 py-1 rounded-lg flex items-center">
<i class="fas fa-print mr-2"></i> Imprimer
</button>
<button id="downloadPdfBtn" class="ios-button px-3 py-1 flex items-center">
<i class="fas fa-file-pdf mr-2"></i> PDF
</button>
<button id="closeInvoicePreview" class="text-subtitle dark:text-subtitle-dark hover:text-text dark:hover:text-text-dark">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<div class="p-4 overflow-auto">
<div id="invoicePreviewContent" class="invoice-preview">
<!-- Invoice content will be generated here -->
</div>
</div>
</div>
</div>
<!-- CSV Import Modal -->
<div id="csvImportModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="ios-card w-full max-w-md">
<div class="flex justify-between items-center p-4 border-b border-border dark:border-border-dark">
<h3 class="font-semibold text-lg">Importer des données</h3>
<button id="closeCsvImportModal" class="text-subtitle dark:text-subtitle-dark hover:text-text dark:hover:text-text-dark">
<i class="fas fa-times"></i>
</button>
</div>
<div class="p-4">
<div class="mb-4">
<p class="text-sm text-subtitle dark:text-subtitle-dark">Sélectionnez un fichier CSV contenant vos projets existants.</p>
<p class="text-xs text-subtitle dark:text-subtitle-dark mt-1">Colonnes attendues: Projet, Client, Jours travaillés, Forfait journalier</p>
</div>
<div class="border-2 border-dashed border-border dark:border-border-dark rounded-lg p-6 text-center">
<input type="file" id="csvFileInput" class="hidden" accept=".csv">
<label for="csvFileInput" class="cursor-pointer">
<i class="fas fa-file-csv text-4xl text-subtitle dark:text-subtitle-dark mb-2"></i>
<p class="text-sm text-subtitle dark:text-subtitle-dark">Glissez-déposez un fichier ou cliquez pour sélectionner</p>
<p id="csvFileName" class="text-xs text-subtitle dark:text-subtitle-dark mt-2 hidden"></p>
</label>
</div>
<div class="flex justify-end space-x-2 mt-6">
<button type="button" id="cancelCsvImportBtn" class="px-4 py-2 border border-border dark:border-border-dark rounded-lg hover:bg-surface dark:hover:bg-surface-dark">
Annuler
</button>
<button type="button" id="confirmCsvImportBtn" class="ios-button disabled:opacity-50" disabled>
Importer
</button>
</div>
</div>
</div>
</div>
<script>
// Initialize the application when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
// Dark mode toggle
const darkModeToggle = document.getElementById('darkModeToggle');
const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)');
// Check localStorage for dark mode preference
if (localStorage.getItem('darkMode') === 'enabled' ||
(!localStorage.getItem('darkMode') && prefersDarkScheme.matches)) {
document.documentElement.classList.add('dark');
darkModeToggle.classList.add('bg-primary-dark');
}
darkModeToggle.addEventListener('click', function() {
document.documentElement.classList.toggle('dark');
if (document.documentElement.classList.contains('dark')) {
localStorage.setItem('darkMode', 'enabled');
darkModeToggle.classList.add('bg-primary-dark');
} else {
localStorage.setItem('darkMode', 'disabled');
darkModeToggle.classList.remove('bg-primary-dark');
}
});
// Mobile menu toggle
const mobileMenuButton = document.getElementById('mobileMenuButton');
const sidebar = document.getElementById('sidebar');
mobileMenuButton.addEventListener('click', function() {
sidebar.classList.toggle('open');
});
// Navigation links
const navLinks = {
dashboardLink: document.getElementById('dashboardLink'),
projectsLink: document.getElementById('projectsLink'),
clientsLink: document.getElementById('clientsLink'),
invoicesLink: document.getElementById('invoicesLink'),
settingsLink: document.getElementById('settingsLink')
};
const sections = {
dashboardSection: document.getElementById('dashboardSection'),
projectsSection: document.getElementById('projectsSection'),
clientsSection: document.getElementById('clientsSection'),
invoicesSection: document.getElementById('invoicesSection'),
settingsSection: document.getElementById('settingsSection')
};
const pageTitle = document.getElementById('pageTitle');
// Show section and hide others
function showSection(sectionId, title) {
Object.values(sections).forEach(section => {
section.classList.add('hidden');
});
document.getElementById(sectionId).classList.remove('hidden');
pageTitle.textContent = title;
// Close sidebar on mobile after navigation
if (window.innerWidth <= 768) {
sidebar.classList.remove('open');
}
}
// Add event listeners to navigation links
navLinks.dashboardLink.addEventListener('click', function(e) {
e.preventDefault();
showSection('dashboardSection', 'Tableau de bord');
updateDashboardStats();
});
navLinks.projectsLink.addEventListener('click', function(e) {
e.preventDefault();
showSection('projectsSection', 'Mes projets');
renderAllProjectsTable();
});
navLinks.clientsLink.addEventListener('click', function(e) {
e.preventDefault();
showSection('clientsSection', 'Mes clients');
renderClientsTable();
});
navLinks.invoicesLink.addEventListener('click', function(e) {
e.preventDefault();
showSection('invoicesSection', 'Factures & Devis');
renderInvoicesTable();
});
navLinks.settingsLink.addEventListener('click', function(e) {
e.preventDefault();
showSection('settingsSection', 'Paramètres');
loadSettings();
});
// Initialize data storage
let appData = {
projects: [],
clients: [],
invoices: [],
settings: {
userName: "Sam Freelance",
userEmail: "sam@data-analyse.fr",
userAddress: "123 Rue des Entrepreneurs, 75000 Paris",
userSiret: "12345678900012",
defaultRate: 400,
paymentTerms: "30 jours net",
logo: ""
},
nextInvoiceNumber: 1,
nextQuoteNumber: 1
};
// Try to load data from localStorage
const savedData = localStorage.getItem('samfactData');
if (savedData) {
appData = JSON.parse(savedData);
} else {
// Add some sample data if no saved data exists
appData.clients = [
{ id: 1, name: "Entreprise A", email: "contact@entreprise-a.fr", address: "1 Rue des Exemples, Paris", siret: "12345678900001", phone: "0123456789" },
{ id: 2, name: "Startup B", email: "hello@startup-b.com", address: "5 Avenue des Tests, Lyon", siret: "98765432100001", phone: "0987654321" }
];
appData.projects = [
{ id: 1, name: "Analyse données marketing", clientId: 1, startDate: "2023-05-01", endDate: "2023-05-15", days: 10, rate: 400, description: "Analyse des campagnes marketing", status: "completed" },
{ id: 2, name: "Dashboard analytics", clientId: 2, startDate: "2023-06-01", endDate: "", days: 5, rate: 450, description: "Création de dashboard pour suivi KPI", status: "active" }
];
appData.invoices = [
{ id: 1, number: "F2023-001", type: "invoice", clientId: 1, date: "2023-05-16", dueDate: "2023-06-16", status: "paid", projectId: 1, paymentTerms: "30 jours net", notes: "", items: [
{ description: "Analyse données marketing", days: 10, rate: 400, total: 4000 }
]},
{ id: 2, number: "D2023-001", type: "quote", clientId: 2, date: "2023-05-20", dueDate: "", status: "sent", projectId: 2, paymentTerms: "30 jours net", notes: "Valable 30 jours", items: [
{ description: "Dashboard analytics", days: 5, rate: 450, total: 2250 }
]}
];
appData.nextInvoiceNumber = 3;
appData.nextQuoteNumber = 2;
saveData();
}
// Save data to localStorage
function saveData() {
localStorage.setItem('samfactData', JSON.stringify(appData));
}
// Dashboard functions
function updateDashboardStats() {
const activeProjects = appData.projects.filter(p => p.status === 'active').length;
const daysWorked = appData.projects.reduce((sum, project) => sum + (project.days || 0), 0);
const totalRevenue = appData.projects.reduce((sum, project) => sum + (project.days * project.rate || 0), 0);
document.getElementById('activeProjectsCount').textContent = activeProjects;
document.getElementById('daysWorkedCount').textContent = daysWorked;
document.getElementById('totalRevenue').textContent = totalRevenue.toLocaleString('fr-FR') + '€';
renderProjectsTable();
updateRevenueChart();
}
function renderProjectsTable() {
const tableBody = document.getElementById('projectsTableBody');
tableBody.innerHTML = '';
// Show only active projects on dashboard
const activeProjects = appData.projects.filter(p => p.status === 'active');
activeProjects.forEach(project => {
const client = appData.clients.find(c => c.id === project.clientId) || {};
const total = project.days * project.rate;
const row = document.createElement('tr');
row.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap">
<div class="font-medium">${project.name}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div>${client.name || '-'}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div>${project.days}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div>${project.rate.toLocaleString('fr-FR')}€</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="font-medium">${total.toLocaleString('fr-FR')}€</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<button class="text-primary dark:text-primary-dark hover:text-opacity-80 mr-2 edit-project-btn" data-id="${project.id}">
<i class="fas fa-edit"></i>
</button>
<button class="text-red-500 hover:text-red-700 delete-project-btn" data-id="${project.id}">
<i class="fas fa-trash"></i>
</button>
</td>
`;
tableBody.appendChild(row);
});
// Add event listeners to buttons
document.querySelectorAll('.edit-project-btn').forEach(btn => {
btn.addEventListener('click', function() {
openEditProjectModal(parseInt(this.getAttribute('data-id')));
});
});
document.querySelectorAll('.delete-project-btn').forEach(btn => {
btn.addEventListener('click', function() {
if (confirm('Voulez-vous vraiment supprimer ce projet ?')) {
deleteProject(parseInt(this.getAttribute('data-id')));
}
});
});
}
function updateRevenueChart() {
const range = parseInt(document.getElementById('chartRange').value);
const now = new Date();
const months = [];
for (let i = range - 1; i >= 0; i--) {
const date = new Date(now.getFullYear(), now.getMonth() - i, 1);
months.push(date.toLocaleDateString('fr-FR', { month: 'short', year: 'numeric' }));
}
const revenueData = new Array(range).fill(0);
appData.projects.forEach(project => {
const projectDate = new Date(project.startDate);
const monthDiff = (now.getFullYear() - projectDate.getFullYear()) * 12 + now.getMonth() - projectDate.getMonth();
if (monthDiff >= 0 && monthDiff < range) {
revenueData[range - 1 - monthDiff] += project.days * project.rate;
}
});
const ctx = document.getElementById('revenueChart').getContext('2d');
if (window.revenueChart) {
window.revenueChart.destroy();
}
// Set chart colors based on dark mode
const isDarkMode = document.documentElement.classList.contains('dark');
const bgColor = isDarkMode ? 'rgba(59, 130, 246, 0.5)' : 'rgba(10, 132, 255, 0.5)';
const borderColor = isDarkMode ? 'rgba(59, 130, 246, 1)' : 'rgba(10, 132, 255, 1)';
const textColor = isDarkMode ? '#FFFFFF' : '#1C1C1E';
const gridColor = isDarkMode ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)';
window.revenueChart = new Chart(ctx, {
type: 'bar',
data: {
labels: months,
datasets: [{
label: 'Revenus HT (€)',
data: revenueData,
backgroundColor: bgColor,
borderColor: borderColor,
borderWidth: 1
}]
},
options: {
responsive: true,
scales: {
y: {
beginAtZero: true,
ticks: {
callback: function(value) {
return value.toLocaleString('fr-FR') + '€';
},
color: textColor
},
grid: {
color: gridColor
}
},
x: {
ticks: {
color: textColor
},
grid: {
color: gridColor
}
}
},
plugins: {
tooltip: {
callbacks: {
label: function(context) {
return context.dataset.label + ': ' + context.raw.toLocaleString('fr-FR') + '€';
}
}
},
legend: {
labels: {
color: textColor
}
}
}
}
});
document.getElementById('chartRange').addEventListener('change', updateRevenueChart);
}
// Projects functions
function renderAllProjectsTable() {
const tableBody = document.getElementById('allProjectsTableBody');
tableBody.innerHTML = '';
appData.projects.forEach(project => {
const client = appData.clients.find(c => c.id === project.clientId) || {};
const total = project.days * project.rate;
const statusClass = project.status === 'active' ? 'bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200' : 'bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-200';
const statusText = project.status === 'active' ? 'Actif' : 'Terminé';
const row = document.createElement('tr');
row.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap">
<div class="font-medium">${project.name}</div>
<div class="text-sm text-subtitle dark:text-subtitle-dark">${project.description || ''}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div>${client.name || '-'}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div>${project.startDate ? new Date(project.startDate).toLocaleDateString('fr-FR') : '-'}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div>${project.endDate ? new Date(project.endDate).toLocaleDateString('fr-FR') : '-'}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div>${project.days}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="font-medium">${total.toLocaleString('fr-FR')}€</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 py-1 text-xs rounded-full ${statusClass}">${statusText}</span>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<button class="text-primary dark:text-primary-dark hover:text-opacity-80 mr-2 edit-project-btn" data-id="${project.id}">
<i class="fas fa-edit"></i>
</button>
<button class="text-red-500 hover:text-red-700 delete-project-btn" data-id="${project.id}">
<i class="fas fa-trash"></i>
</button>
</td>
`;
tableBody.appendChild(row);
});
// Add event listeners to buttons
document.querySelectorAll('.edit-project-btn').forEach(btn => {
btn.addEventListener('click', function() {
openEditProjectModal(parseInt(this.getAttribute('data-id')));
});
});
document.querySelectorAll('.delete-project-btn').forEach(btn => {
btn.addEventListener('click', function() {
if (confirm('Voulez-vous vraiment supprimer ce projet ?')) {
deleteProject(parseInt(this.getAttribute('data-id')));
}
});
});
}
// Project modal functions
const projectModal = document.getElementById('projectModal');
const projectForm = document.getElementById('projectForm');
const closeProjectModal = document.getElementById('closeProjectModal');
const cancelProjectBtn = document.getElementById('cancelProjectBtn');
// Open modal for new project
document.getElementById('addProjectBtn').addEventListener('click', openNewProjectModal);
document.getElementById('addProjectBtn2').addEventListener('click', openNewProjectModal);
function openNewProjectModal() {
document.getElementById('projectForm').reset();
document.getElementById('projectModal').querySelector('h3').textContent = 'Nouveau projet';
// Populate client dropdown
const clientSelect = document.getElementById('projectClient');
clientSelect.innerHTML = '<option value="">Sélectionner un client</option>';
appData.clients.forEach(client => {
const option = document.createElement('option');
option.value = client.id;
option.textContent = client.name;
clientSelect.appendChild(option);
});
// Set default rate from settings
document.getElementById('projectRate').value = appData.settings.defaultRate || '';
projectModal.classList.remove('hidden');
}
function openEditProjectModal(projectId) {
const project = appData.projects.find(p => p.id === projectId);
if (!project) return;
document.getElementById('projectModal').querySelector('h3').textContent = 'Modifier projet';
// Populate client dropdown
const clientSelect = document.getElementById('projectClient');
clientSelect.innerHTML = '<option value="">Sélectionner un client</option>';
appData.clients.forEach(client => {
const option = document.createElement('option');
option.value = client.id;
option.textContent = client.name;
option.selected = client.id === project.clientId;
clientSelect.appendChild(option);
});
// Fill form with project data
document.getElementById('projectName').value = project.name || '';
document.getElementById('projectStartDate').value = project.startDate || '';
document.getElementById('projectEndDate').value = project.endDate || '';
document.getElementById('projectDays').value = project.days || '';
document.getElementById('projectRate').value = project.rate || '';
document.getElementById('projectDescription').value = project.description || '';
// Store project ID in form
projectForm.setAttribute('data-project-id', projectId);
projectModal.classList.remove('hidden');
}
// Close modal
closeProjectModal.addEventListener('click', function() {
projectModal.classList.add('hidden');
});
cancelProjectBtn.addEventListener('click', function() {
projectModal.classList.add('hidden');
});
// Handle form submission
projectForm.addEventListener('submit', function(e) {
e.preventDefault();
const projectId = parseInt(this.getAttribute('data-project-id')) || null;
const isEdit = !!projectId;
const projectData = {
name: document.getElementById('projectName').value,
clientId: parseInt(document.getElementById('projectClient').value),
startDate: document.getElementById('projectStartDate').value,
endDate: document.getElementById('projectEndDate').value || null,
days: parseInt(document.getElementById('projectDays').value),
rate: parseFloat(document.getElementById('projectRate').value),
description: document.getElementById('projectDescription').value,
status: 'active'
};
if (isEdit) {
// Update existing project
const index = appData.projects.findIndex(p => p.id === projectId);
if (index !== -1) {
appData.projects[index] = { ...appData.projects[index], ...projectData };
}
} else {
// Add new project
const newId = appData.projects.length > 0 ? Math.max(...appData.projects.map(p => p.id)) + 1 : 1;
appData.projects.push({ id: newId, ...projectData });
}
saveData();
projectModal.classList.add('hidden');
// Update UI
if (isEdit) {
renderProjectsTable();
renderAllProjectsTable();
} else {
updateDashboardStats();
renderAllProjectsTable();
}
});
function deleteProject(projectId) {
appData.projects = appData.projects.filter(p => p.id !== projectId);
saveData();
// Update UI
updateDashboardStats();
renderAllProjectsTable();
}
// Clients functions
function renderClientsTable() {
const tableBody = document.getElementById('clientsTableBody');
tableBody.innerHTML = '';
appData.clients.forEach(client => {
const row = document.createElement('tr');
row.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap">
<div class="font-medium">${client.name}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div>${client.email}</div>
</td>
<td class="px-6 py-4">
<div>${client.address || '-'}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div>${client.siret || '-'}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<button class="text-primary dark:text-primary-dark hover:text-opacity-80 mr-2 edit-client-btn" data-id="${client.id}">
<i class="fas fa-edit"></i>
</button>
<button class="text-red-500 hover:text-red-700 delete-client-btn" data-id="${client.id}">
<i class="fas fa-trash"></i>
</button>
</td>
`;
tableBody.appendChild(row);
});
// Add event listeners to buttons
document.querySelectorAll('.edit-client-btn').forEach(btn => {
btn.addEventListener('click', function() {
openEditClientModal(parseInt(this.getAttribute('data-id')));
});
});
document.querySelectorAll('.delete-client-btn').forEach(btn => {
btn.addEventListener('click', function() {
if (confirm('Voulez-vous vraiment supprimer ce client ?')) {
deleteClient(parseInt(this.getAttribute('data-id')));
}
});
});
}
// Client modal functions
const clientModal = document.getElementById('clientModal');
const clientForm = document.getElementById('clientForm');
const closeClientModal = document.getElementById('closeClientModal');
const cancelClientBtn = document.getElementById('cancelClientBtn');
// Open modal for new client
document.getElementById('addClientBtn').addEventListener('click', openNewClientModal);
function openNewClientModal() {
document.getElementById('clientForm').reset();
document.getElementById('clientModal').querySelector('h3').textContent = 'Nouveau client';
clientForm.removeAttribute('data-client-id');
clientModal.classList.remove('hidden');
}
function openEditClientModal(clientId) {
const client = appData.clients.find(c => c.id === clientId);
if (!client) return;
document.getElementById('clientModal').querySelector('h3').textContent = 'Modifier client';
// Fill form with client data
document.getElementById('clientName').value = client.name || '';
document.getElementById('clientEmail').value = client.email || '';
document.getElementById('clientAddress').value = client.address || '';
document.getElementById('clientSiret').value = client.siret || '';
document.getElementById('clientPhone').value = client.phone || '';
// Store client ID in form
clientForm.setAttribute('data-client-id', clientId);
clientModal.classList.remove('hidden');
}
// Close modal
closeClientModal.addEventListener('click', function() {
clientModal.classList.add('hidden');
});
cancelClientBtn.addEventListener('click', function() {
clientModal.classList.add('hidden');
});
// Handle form submission
clientForm.addEventListener('submit', function(e) {
e.preventDefault();
const clientId = parseInt(this.getAttribute('data-client-id')) || null;
const isEdit = !!clientId;
const clientData = {
name: document.getElementById('clientName').value,
email: document.getElementById('clientEmail').value,
address: document.getElementById('clientAddress').value,
siret: document.getElementById('clientSiret').value,
phone: document.getElementById('clientPhone').value
};
if (isEdit) {
// Update existing client
const index = appData.clients.findIndex(c => c.id === clientId);
if (index !== -1) {
appData.clients[index] = { ...appData.clients[index], ...clientData };
}
} else {
// Add new client
const newId = appData.clients.length > 0 ? Math.max(...appData.clients.map(c => c.id)) + 1 : 1;
appData.clients.push({ id: newId, ...clientData });
}
saveData();
clientModal.classList.add('hidden');
// Update UI
renderClientsTable();
// Also update client dropdowns in other forms
if (!isEdit) {
updateDashboardStats();
renderAllProjectsTable();
}
});
function deleteClient(clientId) {
// Check if client is used in any projects or invoices
const hasProjects = appData.projects.some(p => p.clientId === clientId);
const hasInvoices = appData.invoices.some(i => i.clientId === clientId);
if (hasProjects || hasInvoices) {
alert('Ce client est associé à des projets ou factures et ne peut pas être supprimé.');
return;
}
appData.clients = appData.clients.filter(c => c.id !== clientId);
saveData();
// Update UI
renderClientsTable();
}
// Invoices functions
function renderInvoicesTable(filter = null) {
const tableBody = document.getElementById('invoicesTableBody');
tableBody.innerHTML = '';
// Update counters
const allInvoices = appData.invoices.length;
const draftInvoices = appData.invoices.filter(i => i.status === 'draft').length;
const sentInvoices = appData.invoices.filter(i => i.status === 'sent').length;
const paidInvoices = appData.invoices.filter(i => i.status === 'paid').length;
document.getElementById('allInvoicesCount').textContent = allInvoices;
document.getElementById('draftInvoicesCount').textContent = draftInvoices;
document.getElementById('sentInvoicesCount').textContent = sentInvoices;
document.getElementById('paidInvoicesCount').textContent = paidInvoices;
// Filter invoices if needed
let invoicesToShow = appData.invoices;
if (filter === 'draft') {
invoicesToShow = appData.invoices.filter(i => i.status === 'draft');
} else if (filter === 'sent') {
invoicesToShow = appData.invoices.filter(i => i.status === 'sent');
} else if (filter === 'paid') {
invoicesToShow
</html> |