Spaces:
Running
Running
Download index.html from mohamedelazzouzi/techinter: direct link, hf CLI and curl.
- Browser
- Download file 82.6 kB
-
https://huggingface.co/spaces/mohamedelazzouzi/techinter/resolve/main/index.html
- Command line
-
hf download hf://spaces/mohamedelazzouzi/techinter/index.html
-
curl -L -o index.html https://huggingface.co/spaces/mohamedelazzouzi/techinter/resolve/main/index.html
82.6 kB
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gestion Interventions IT</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="manifest" href="/manifest.json">
<style>
/* Custom styles for the offline indicator */
.offline-indicator {
position: fixed;
bottom: 20px;
right: 20px;
z-index: 1000;
display: none;
}
/* Animation for notifications */
@keyframes slideIn {
from { transform: translateX(100%); }
to { transform: translateX(0); }
}
.notification {
animation: slideIn 0.3s ease-out;
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Print styles */
@media print {
.no-print {
display: none !important;
}
body {
padding: 0;
margin: 0;
background: white;
color: black;
}
.print-table {
width: 100%;
border-collapse: collapse;
}
.print-table th, .print-table td {
border: 1px solid #ddd;
padding: 8px;
}
}
</style>
</head>
<body class="bg-gray-100 font-sans">
<!-- Offline Indicator -->
<div id="offlineIndicator" class="offline-indicator bg-yellow-500 text-white px-4 py-2 rounded-lg shadow-lg">
<i class="fas fa-wifi-slash mr-2"></i> Mode hors ligne activé
</div>
<!-- Notification Area -->
<div id="notificationArea" class="fixed top-4 right-4 z-50 space-y-2"></div>
<!-- Main Container -->
<div class="container mx-auto px-4 py-6 max-w-6xl">
<!-- Header -->
<header class="bg-blue-600 text-white rounded-lg shadow-md p-4 mb-6">
<div class="flex justify-between items-center">
<div>
<h1 class="text-2xl md:text-3xl font-bold">
<i class="fas fa-laptop-medical mr-2"></i> Gestion Interventions IT
</h1>
<p class="text-blue-100 text-sm mt-1">Suivi des interventions informatiques</p>
</div>
<div class="flex space-x-2">
<button id="installBtn" class="bg-blue-700 hover:bg-blue-800 px-3 py-1 rounded-lg text-sm hidden">
<i class="fas fa-download mr-1"></i> Installer
</button>
<button id="exportBtn" class="bg-green-600 hover:bg-green-700 px-3 py-1 rounded-lg text-sm">
<i class="fas fa-file-export mr-1"></i> Exporter
</button>
<button id="importBtn" class="bg-purple-600 hover:bg-purple-700 px-3 py-1 rounded-lg text-sm">
<i class="fas fa-file-import mr-1"></i> Importer
</button>
<input type="file" id="importFile" class="hidden" accept=".json">
</div>
</div>
</header>
<!-- Main Content -->
<div class="grid grid-cols-1 lg:grid-cols-4 gap-6">
<!-- Sidebar -->
<div class="lg:col-span-1 bg-white rounded-lg shadow-md p-4">
<nav>
<ul class="space-y-2">
<li>
<button id="dashboardTab" class="w-full text-left px-4 py-2 rounded-lg bg-blue-100 text-blue-700 font-medium flex items-center">
<i class="fas fa-tachometer-alt mr-2"></i> Tableau de bord
</button>
</li>
<li>
<button id="interventionsTab" class="w-full text-left px-4 py-2 rounded-lg hover:bg-gray-100 flex items-center">
<i class="fas fa-tools mr-2"></i> Interventions
</button>
</li>
<li>
<button id="clientsTab" class="w-full text-left px-4 py-2 rounded-lg hover:bg-gray-100 flex items-center">
<i class="fas fa-users mr-2"></i> Clients
</button>
</li>
<li>
<button id="techniciensTab" class="w-full text-left px-4 py-2 rounded-lg hover:bg-gray-100 flex items-center">
<i class="fas fa-user-tie mr-2"></i> Techniciens
</button>
</li>
<li>
<button id="reportsTab" class="w-full text-left px-4 py-2 rounded-lg hover:bg-gray-100 flex items-center">
<i class="fas fa-chart-bar mr-2"></i> Rapports
</button>
</li>
<li>
<button id="settingsTab" class="w-full text-left px-4 py-2 rounded-lg hover:bg-gray-100 flex items-center">
<i class="fas fa-cog mr-2"></i> Paramètres
</button>
</li>
</ul>
</nav>
<div class="mt-8 pt-4 border-t border-gray-200">
<div class="text-center">
<div class="text-gray-500 text-sm mb-1">Stockage utilisé</div>
<div class="w-full bg-gray-200 rounded-full h-2.5">
<div id="storageUsed" class="bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div>
</div>
<div id="storageText" class="text-gray-500 text-xs mt-1">0 KB / 0 KB</div>
</div>
</div>
</div>
<!-- Main Panel -->
<div class="lg:col-span-3">
<!-- Dashboard Panel -->
<div id="dashboardPanel" class="bg-white rounded-lg shadow-md p-4">
<h2 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
<i class="fas fa-tachometer-alt mr-2 text-blue-600"></i> Tableau de bord
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
<div class="bg-blue-50 rounded-lg p-4 border-l-4 border-blue-500">
<div class="text-blue-800 font-medium">Interventions en cours</div>
<div id="ongoingCount" class="text-2xl font-bold text-blue-600">0</div>
</div>
<div class="bg-green-50 rounded-lg p-4 border-l-4 border-green-500">
<div class="text-green-800 font-medium">Interventions terminées</div>
<div id="completedCount" class="text-2xl font-bold text-green-600">0</div>
</div>
<div class="bg-purple-50 rounded-lg p-4 border-l-4 border-purple-500">
<div class="text-purple-800 font-medium">Clients</div>
<div id="clientsCount" class="text-2xl font-bold text-purple-600">0</div>
</div>
<div class="bg-yellow-50 rounded-lg p-4 border-l-4 border-yellow-500">
<div class="text-yellow-800 font-medium">Retards</div>
<div id="lateCount" class="text-2xl font-bold text-yellow-600">0</div>
</div>
</div>
<div class="mb-6">
<h3 class="text-lg font-semibold text-gray-700 mb-3">Interventions récentes</h3>
<div id="recentInterventions" class="bg-gray-50 rounded-lg p-3 max-h-64 overflow-y-auto">
<p class="text-gray-500 text-center py-4">Aucune intervention récente</p>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<h3 class="text-lg font-semibold text-gray-700 mb-3">Statut des interventions</h3>
<div class="bg-white p-4 rounded-lg shadow-inner">
<canvas id="statusChart" height="200"></canvas>
</div>
</div>
<div>
<h3 class="text-lg font-semibold text-gray-700 mb-3">Types d'interventions</h3>
<div class="bg-white p-4 rounded-lg shadow-inner">
<canvas id="typeChart" height="200"></canvas>
</div>
</div>
</div>
</div>
<!-- Interventions Panel -->
<div id="interventionsPanel" class="bg-white rounded-lg shadow-md p-4 hidden">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-bold text-gray-800 flex items-center">
<i class="fas fa-tools mr-2 text-blue-600"></i> Gestion des interventions
</h2>
<button id="addInterventionBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded-lg text-sm">
<i class="fas fa-plus mr-1"></i> Nouvelle intervention
</button>
</div>
<div class="mb-4 flex flex-wrap gap-2">
<select id="interventionFilter" class="border rounded-lg px-3 py-1 text-sm">
<option value="all">Toutes les interventions</option>
<option value="ongoing">En cours</option>
<option value="completed">Terminées</option>
<option value="late">En retard</option>
</select>
<input type="text" id="interventionSearch" placeholder="Rechercher..." class="border rounded-lg px-3 py-1 text-sm flex-grow max-w-xs">
</div>
<div class="overflow-x-auto">
<table class="min-w-full bg-white rounded-lg overflow-hidden">
<thead class="bg-gray-100">
<tr>
<th class="py-2 px-4 text-left">ID</th>
<th class="py-2 px-4 text-left">Client</th>
<th class="py-2 px-4 text-left">Description</th>
<th class="py-2 px-4 text-left">Date</th>
<th class="py-2 px-4 text-left">Statut</th>
<th class="py-2 px-4 text-left">Actions</th>
</tr>
</thead>
<tbody id="interventionsTableBody" class="divide-y divide-gray-200">
<tr>
<td colspan="6" class="py-4 text-center text-gray-500">Aucune intervention trouvée</td>
</tr>
</tbody>
</table>
</div>
<div class="mt-4 flex justify-between items-center text-sm text-gray-600">
<div id="interventionsCount">0 interventions</div>
<div class="flex space-x-2">
<button id="prevInterventions" class="px-3 py-1 border rounded-lg disabled:opacity-50" disabled>
<i class="fas fa-chevron-left"></i>
</button>
<span id="interventionsPage">1/1</span>
<button id="nextInterventions" class="px-3 py-1 border rounded-lg disabled:opacity-50" disabled>
<i class="fas fa-chevron-right"></i>
</button>
</div>
</div>
</div>
<!-- Clients Panel -->
<div id="clientsPanel" class="bg-white rounded-lg shadow-md p-4 hidden">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-bold text-gray-800 flex items-center">
<i class="fas fa-users mr-2 text-blue-600"></i> Gestion des clients
</h2>
<button id="addClientBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded-lg text-sm">
<i class="fas fa-plus mr-1"></i> Nouveau client
</button>
</div>
<div class="mb-4">
<input type="text" id="clientSearch" placeholder="Rechercher un client..." class="border rounded-lg px-3 py-1 text-sm w-full max-w-xs">
</div>
<div class="overflow-x-auto">
<table class="min-w-full bg-white rounded-lg overflow-hidden">
<thead class="bg-gray-100">
<tr>
<th class="py-2 px-4 text-left">Nom</th>
<th class="py-2 px-4 text-left">Email</th>
<th class="py-2 px-4 text-left">Téléphone</th>
<th class="py-2 px-4 text-left">Adresse</th>
<th class="py-2 px-4 text-left">Actions</th>
</tr>
</thead>
<tbody id="clientsTableBody" class="divide-y divide-gray-200">
<tr>
<td colspan="5" class="py-4 text-center text-gray-500">Aucun client trouvé</td>
</tr>
</tbody>
</table>
</div>
<div class="mt-4 flex justify-between items-center text-sm text-gray-600">
<div id="clientsTableCount">0 clients</div>
<div class="flex space-x-2">
<button id="prevClients" class="px-3 py-1 border rounded-lg disabled:opacity-50" disabled>
<i class="fas fa-chevron-left"></i>
</button>
<span id="clientsPage">1/1</span>
<button id="nextClients" class="px-3 py-1 border rounded-lg disabled:opacity-50" disabled>
<i class="fas fa-chevron-right"></i>
</button>
</div>
</div>
</div>
<!-- Techniciens Panel -->
<div id="techniciensPanel" class="bg-white rounded-lg shadow-md p-4 hidden">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-bold text-gray-800 flex items-center">
<i class="fas fa-user-tie mr-2 text-blue-600"></i> Gestion des techniciens
</h2>
<button id="addTechnicienBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded-lg text-sm">
<i class="fas fa-plus mr-1"></i> Nouveau technicien
</button>
</div>
<div class="mb-4">
<input type="text" id="technicienSearch" placeholder="Rechercher un technicien..." class="border rounded-lg px-3 py-1 text-sm w-full max-w-xs">
</div>
<div class="overflow-x-auto">
<table class="min-w-full bg-white rounded-lg overflow-hidden">
<thead class="bg-gray-100">
<tr>
<th class="py-2 px-4 text-left">Nom</th>
<th class="py-2 px-4 text-left">Email</th>
<th class="py-2 px-4 text-left">Téléphone</th>
<th class="py-2 px-4 text-left">Spécialité</th>
<th class="py-2 px-4 text-left">Actions</th>
</tr>
</thead>
<tbody id="techniciensTableBody" class="divide-y divide-gray-200">
<tr>
<td colspan="5" class="py-4 text-center text-gray-500">Aucun technicien trouvé</td>
</tr>
</tbody>
</table>
</div>
<div class="mt-4 flex justify-between items-center text-sm text-gray-600">
<div id="techniciensCount">0 techniciens</div>
<div class="flex space-x-2">
<button id="prevTechniciens" class="px-3 py-1 border rounded-lg disabled:opacity-50" disabled>
<i class="fas fa-chevron-left"></i>
</button>
<span id="techniciensPage">1/1</span>
<button id="nextTechniciens" class="px-3 py-1 border rounded-lg disabled:opacity-50" disabled>
<i class="fas fa-chevron-right"></i>
</button>
</div>
</div>
</div>
<!-- Reports Panel -->
<div id="reportsPanel" class="bg-white rounded-lg shadow-md p-4 hidden">
<h2 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
<i class="fas fa-chart-bar mr-2 text-blue-600"></i> Rapports et statistiques
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
<div class="bg-white p-4 rounded-lg shadow-inner border">
<h3 class="text-lg font-semibold text-gray-700 mb-3">Interventions par mois</h3>
<canvas id="monthlyChart" height="200"></canvas>
</div>
<div class="bg-white p-4 rounded-lg shadow-inner border">
<h3 class="text-lg font-semibold text-gray-700 mb-3">Interventions par technicien</h3>
<canvas id="technicienChart" height="200"></canvas>
</div>
</div>
<div class="mb-6">
<div class="flex justify-between items-center mb-3">
<h3 class="text-lg font-semibold text-gray-700">Rapport détaillé</h3>
<div class="flex space-x-2">
<select id="reportType" class="border rounded-lg px-3 py-1 text-sm">
<option value="interventions">Interventions</option>
<option value="clients">Clients</option>
<option value="techniciens">Techniciens</option>
</select>
<button id="generateReportBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded-lg text-sm">
<i class="fas fa-sync-alt mr-1"></i> Générer
</button>
<button id="printReportBtn" class="bg-green-600 hover:bg-green-700 text-white px-3 py-1 rounded-lg text-sm">
<i class="fas fa-print mr-1"></i> Imprimer
</button>
</div>
</div>
<div id="reportContent" class="bg-gray-50 rounded-lg p-4 max-h-96 overflow-y-auto">
<p class="text-gray-500 text-center py-4">Sélectionnez un type de rapport et cliquez sur "Générer"</p>
</div>
</div>
</div>
<!-- Settings Panel -->
<div id="settingsPanel" class="bg-white rounded-lg shadow-md p-4 hidden">
<h2 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
<i class="fas fa-cog mr-2 text-blue-600"></i> Paramètres
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<h3 class="text-lg font-semibold text-gray-700 mb-3">Paramètres généraux</h3>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Nom de l'entreprise</label>
<input type="text" id="companyName" class="w-full border rounded-lg px-3 py-2">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Adresse email</label>
<input type="email" id="companyEmail" class="w-full border rounded-lg px-3 py-2">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Téléphone</label>
<input type="tel" id="companyPhone" class="w-full border rounded-lg px-3 py-2">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Adresse</label>
<textarea id="companyAddress" rows="3" class="w-full border rounded-lg px-3 py-2"></textarea>
</div>
</div>
</div>
<div>
<h3 class="text-lg font-semibold text-gray-700 mb-3">Sauvegarde et restauration</h3>
<div class="space-y-4">
<div>
<p class="text-sm text-gray-600 mb-2">Sauvegardez toutes vos données dans un fichier JSON que vous pouvez importer ultérieurement.</p>
<div class="flex space-x-2">
<button id="backupAllBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-3 py-2 rounded-lg text-sm">
<i class="fas fa-database mr-1"></i> Sauvegarder tout
</button>
<button id="restoreAllBtn" class="bg-purple-600 hover:bg-purple-700 text-white px-3 py-2 rounded-lg text-sm">
<i class="fas fa-upload mr-1"></i> Restaurer tout
</button>
</div>
</div>
<div class="pt-4 border-t border-gray-200">
<h4 class="font-medium text-gray-700 mb-2">Réinitialisation</h4>
<p class="text-sm text-gray-600 mb-3">Attention: Ces actions sont irréversibles.</p>
<div class="flex flex-wrap gap-2">
<button id="resetInterventionsBtn" class="bg-red-100 hover:bg-red-200 text-red-700 px-3 py-2 rounded-lg text-sm">
<i class="fas fa-trash mr-1"></i> Réinit. interventions
</button>
<button id="resetClientsBtn" class="bg-red-100 hover:bg-red-200 text-red-700 px-3 py-2 rounded-lg text-sm">
<i class="fas fa-trash mr-1"></i> Réinit. clients
</button>
<button id="resetTechniciensBtn" class="bg-red-100 hover:bg-red-200 text-red-700 px-3 py-2 rounded-lg text-sm">
<i class="fas fa-trash mr-1"></i> Réinit. techniciens
</button>
<button id="resetAllBtn" class="bg-red-600 hover:bg-red-700 text-white px-3 py-2 rounded-lg text-sm">
<i class="fas fa-bomb mr-1"></i> Tout réinitialiser
</button>
</div>
</div>
</div>
</div>
</div>
<div class="mt-6 pt-4 border-t border-gray-200">
<button id="saveSettingsBtn" class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg">
<i class="fas fa-save mr-1"></i> Enregistrer les paramètres
</button>
</div>
</div>
</div>
</div>
</div>
<!-- Modals -->
<!-- Add Intervention Modal -->
<div id="interventionModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] overflow-y-auto">
<div class="border-b px-6 py-4 flex justify-between items-center">
<h3 class="text-lg font-semibold" id="interventionModalTitle">Nouvelle intervention</h3>
<button class="text-gray-500 hover:text-gray-700" id="closeInterventionModal">
<i class="fas fa-times"></i>
</button>
</div>
<div class="p-6">
<form id="interventionForm">
<input type="hidden" id="interventionId">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label for="interventionClient" class="block text-sm font-medium text-gray-700 mb-1">Client*</label>
<select id="interventionClient" class="w-full border rounded-lg px-3 py-2" required>
<option value="">Sélectionnez un client</option>
</select>
</div>
<div>
<label for="interventionTechnicien" class="block text-sm font-medium text-gray-700 mb-1">Technicien*</label>
<select id="interventionTechnicien" class="w-full border rounded-lg px-3 py-2" required>
<option value="">Sélectionnez un technicien</option>
</select>
</div>
</div>
<div class="mb-4">
<label for="interventionType" class="block text-sm font-medium text-gray-700 mb-1">Type d'intervention*</label>
<select id="interventionType" class="w-full border rounded-lg px-3 py-2" required>
<option value="">Sélectionnez un type</option>
<option value="Maintenance">Maintenance</option>
<option value="Réparation">Réparation</option>
<option value="Installation">Installation</option>
<option value="Formation">Formation</option>
<option value="Audit">Audit</option>
<option value="Autre">Autre</option>
</select>
</div>
<div class="mb-4">
<label for="interventionDescription" class="block text-sm font-medium text-gray-700 mb-1">Description*</label>
<textarea id="interventionDescription" rows="3" class="w-full border rounded-lg px-3 py-2" required></textarea>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label for="interventionDate" class="block text-sm font-medium text-gray-700 mb-1">Date prévue*</label>
<input type="date" id="interventionDate" class="w-full border rounded-lg px-3 py-2" required>
</div>
<div>
<label for="interventionStatus" class="block text-sm font-medium text-gray-700 mb-1">Statut*</label>
<select id="interventionStatus" class="w-full border rounded-lg px-3 py-2" required>
<option value="Planifiée">Planifiée</option>
<option value="En cours">En cours</option>
<option value="Terminée">Terminée</option>
<option value="Annulée">Annulée</option>
</select>
</div>
</div>
<div class="mb-4">
<label for="interventionNotes" class="block text-sm font-medium text-gray-700 mb-1">Notes supplémentaires</label>
<textarea id="interventionNotes" rows="2" class="w-full border rounded-lg px-3 py-2"></textarea>
</div>
<div class="flex justify-end space-x-3 pt-4 border-t">
<button type="button" id="cancelInterventionBtn" class="px-4 py-2 border rounded-lg text-gray-700 hover:bg-gray-100">
Annuler
</button>
<button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg">
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="bg-white rounded-lg shadow-xl w-full max-w-md max-h-[90vh] overflow-y-auto">
<div class="border-b px-6 py-4 flex justify-between items-center">
<h3 class="text-lg font-semibold" id="clientModalTitle">Nouveau client</h3>
<button class="text-gray-500 hover:text-gray-700" id="closeClientModal">
<i class="fas fa-times"></i>
</button>
</div>
<div class="p-6">
<form id="clientForm">
<input type="hidden" id="clientId">
<div class="mb-4">
<label for="clientName" class="block text-sm font-medium text-gray-700 mb-1">Nom complet*</label>
<input type="text" id="clientName" class="w-full border rounded-lg px-3 py-2" required>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label for="clientEmail" class="block text-sm font-medium text-gray-700 mb-1">Email</label>
<input type="email" id="clientEmail" class="w-full border rounded-lg px-3 py-2">
</div>
<div>
<label for="clientPhone" class="block text-sm font-medium text-gray-700 mb-1">Téléphone*</label>
<input type="tel" id="clientPhone" class="w-full border rounded-lg px-3 py-2" required>
</div>
</div>
<div class="mb-4">
<label for="clientAddress" class="block text-sm font-medium text-gray-700 mb-1">Adresse</label>
<textarea id="clientAddress" rows="2" class="w-full border rounded-lg px-3 py-2"></textarea>
</div>
<div class="mb-4">
<label for="clientCompany" class="block text-sm font-medium text-gray-700 mb-1">Entreprise</label>
<input type="text" id="clientCompany" class="w-full border rounded-lg px-3 py-2">
</div>
<div class="flex justify-end space-x-3 pt-4 border-t">
<button type="button" id="cancelClientBtn" class="px-4 py-2 border rounded-lg text-gray-700 hover:bg-gray-100">
Annuler
</button>
<button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg">
Enregistrer
</button>
</div>
</form>
</div>
</div>
</div>
<!-- Add Technicien Modal -->
<div id="technicienModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-lg shadow-xl w-full max-w-md max-h-[90vh] overflow-y-auto">
<div class="border-b px-6 py-4 flex justify-between items-center">
<h3 class="text-lg font-semibold" id="technicienModalTitle">Nouveau technicien</h3>
<button class="text-gray-500 hover:text-gray-700" id="closeTechnicienModal">
<i class="fas fa-times"></i>
</button>
</div>
<div class="p-6">
<form id="technicienForm">
<input type="hidden" id="technicienId">
<div class="mb-4">
<label for="technicienName" class="block text-sm font-medium text-gray-700 mb-1">Nom complet*</label>
<input type="text" id="technicienName" class="w-full border rounded-lg px-3 py-2" required>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label for="technicienEmail" class="block text-sm font-medium text-gray-700 mb-1">Email*</label>
<input type="email" id="technicienEmail" class="w-full border rounded-lg px-3 py-2" required>
</div>
<div>
<label for="technicienPhone" class="block text-sm font-medium text-gray-700 mb-1">Téléphone*</label>
<input type="tel" id="technicienPhone" class="w-full border rounded-lg px-3 py-2" required>
</div>
</div>
<div class="mb-4">
<label for="technicienSpecialite" class="block text-sm font-medium text-gray-700 mb-1">Spécialité*</label>
<select id="technicienSpecialite" class="w-full border rounded-lg px-3 py-2" required>
<option value="">Sélectionnez une spécialité</option>
<option value="Matériel">Matériel</option>
<option value="Logiciel">Logiciel</option>
<option value="Réseau">Réseau</option>
<option value="Sécurité">Sécurité</option>
<option value="Systèmes">Systèmes</option>
<option value="Autre">Autre</option>
</select>
</div>
<div class="flex justify-end space-x-3 pt-4 border-t">
<button type="button" id="cancelTechnicienBtn" class="px-4 py-2 border rounded-lg text-gray-700 hover:bg-gray-100">
Annuler
</button>
<button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg">
Enregistrer
</button>
</div>
</form>
</div>
</div>
</div>
<!-- Confirmation Modal -->
<div id="confirmModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-lg shadow-xl w-full max-w-md">
<div class="border-b px-6 py-4">
<h3 class="text-lg font-semibold" id="confirmModalTitle">Confirmation</h3>
</div>
<div class="p-6">
<p id="confirmModalMessage">Êtes-vous sûr de vouloir effectuer cette action ?</p>
<div class="flex justify-end space-x-3 pt-4 mt-4">
<button type="button" id="confirmCancelBtn" class="px-4 py-2 border rounded-lg text-gray-700 hover:bg-gray-100">
Annuler
</button>
<button type="button" id="confirmActionBtn" class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg">
Confirmer
</button>
</div>
</div>
</div>
</div>
<!-- Export Modal -->
<div id="exportModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] overflow-y-auto">
<div class="border-b px-6 py-4 flex justify-between items-center">
<h3 class="text-lg font-semibold">Exporter les données</h3>
<button class="text-gray-500 hover:text-gray-700" id="closeExportModal">
<i class="fas fa-times"></i>
</button>
</div>
<div class="p-6">
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-2">Sélectionnez les données à exporter</label>
<div class="space-y-2">
<label class="flex items-center space-x-2">
<input type="checkbox" class="rounded text-blue-600" id="exportInterventions" checked>
<span>Interventions</span>
</label>
<label class="flex items-center space-x-2">
<input type="checkbox" class="rounded text-blue-600" id="exportClients" checked>
<span>Clients</span>
</label>
<label class="flex items-center space-x-2">
<input type="checkbox" class="rounded text-blue-600" id="exportTechniciens" checked>
<span>Techniciens</span>
</label>
<label class="flex items-center space-x-2">
<input type="checkbox" class="rounded text-blue-600" id="exportSettings" checked>
<span>Paramètres</span>
</label>
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">Format d'export</label>
<select id="exportFormat" class="w-full border rounded-lg px-3 py-2">
<option value="json">JSON (Recommandé)</option>
<option value="csv">CSV (Pour Excel)</option>
</select>
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">Nom du fichier</label>
<input type="text" id="exportFilename" class="w-full border rounded-lg px-3 py-2" value="backup_interventions">
</div>
<div class="pt-4 border-t mt-4">
<div class="flex justify-between">
<button id="copyExportBtn" class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-4 py-2 rounded-lg">
<i class="fas fa-copy mr-1"></i> Copier
</button>
<button id="downloadExportBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg">
<i class="fas fa-download mr-1"></i> Télécharger
</button>
</div>
</div>
<div class="mt-4 bg-gray-50 p-3 rounded-lg">
<label class="block text-sm font-medium text-gray-700 mb-1">Données exportées</label>
<textarea id="exportDataPreview" rows="6" class="w-full border rounded-lg px-3 py-2 font-mono text-xs" readonly></textarea>
</div>
</div>
</div>
</div>
<!-- Footer -->
<footer class="mt-8 py-4 border-t border-gray-200 text-center text-gray-600 text-sm">
<p>Gestion Interventions IT © <span id="currentYear"></span> - Tous droits réservés</p>
<p class="mt-1">Version 1.0.0</p>
</footer>
<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
// Current year for footer
document.getElementById('currentYear').textContent = new Date().getFullYear();
// Database setup
let db;
const DB_NAME = 'interventionsDB';
const DB_VERSION = 1;
// Object stores
const INTERVENTIONS_STORE = 'interventions';
const CLIENTS_STORE = 'clients';
const TECHNICIENS_STORE = 'techniciens';
const SETTINGS_STORE = 'settings';
// Initialize database
function initDB() {
return new Promise((resolve, reject) => {
const request = indexedDB.open(DB_NAME, DB_VERSION);
request.onerror = function(event) {
console.error('Database error:', event.target.error);
reject('Database error');
showNotification('Erreur de base de données', 'error');
};
request.onsuccess = function(event) {
db = event.target.result;
console.log('Database opened successfully');
updateStorageUsage();
resolve(db);
// Check if we need to show install prompt
checkInstallPrompt();
};
request.onupgradeneeded = function(event) {
const db = event.target.result;
// Create object stores if they don't exist
if (!db.objectStoreNames.contains(INTERVENTIONS_STORE)) {
const interventionsStore = db.createObjectStore(INTERVENTIONS_STORE, { keyPath: 'id', autoIncrement: true });
interventionsStore.createIndex('clientId', 'clientId', { unique: false });
interventionsStore.createIndex('technicienId', 'technicienId', { unique: false });
interventionsStore.createIndex('status', 'status', { unique: false });
interventionsStore.createIndex('date', 'date', { unique: false });
}
if (!db.objectStoreNames.contains(CLIENTS_STORE)) {
const clientsStore = db.createObjectStore(CLIENTS_STORE, { keyPath: 'id', autoIncrement: true });
clientsStore.createIndex('name', 'name', { unique: false });
}
if (!db.objectStoreNames.contains(TECHNICIENS_STORE)) {
const techniciensStore = db.createObjectStore(TECHNICIENS_STORE, { keyPath: 'id', autoIncrement: true });
techniciensStore.createIndex('name', 'name', { unique: false });
}
if (!db.objectStoreNames.contains(SETTINGS_STORE)) {
db.createObjectStore(SETTINGS_STORE, { keyPath: 'id' });
}
console.log('Database upgrade complete');
};
});
}
// Check if app is installed
function checkInstallPrompt() {
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
const installBtn = document.getElementById('installBtn');
installBtn.classList.remove('hidden');
installBtn.addEventListener('click', () => {
e.prompt();
e.userChoice.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
installBtn.classList.add('hidden');
showNotification('Application installée avec succès', 'success');
}
});
});
});
}
// Check online status
function updateOnlineStatus() {
const offlineIndicator = document.getElementById('offlineIndicator');
if (!navigator.onLine) {
offlineIndicator.style.display = 'block';
} else {
offlineIndicator.style.display = 'none';
}
}
window.addEventListener('online', updateOnlineStatus);
window.addEventListener('offline', updateOnlineStatus);
updateOnlineStatus();
// Show notification
function showNotification(message, type = 'info') {
const notificationArea = document.getElementById('notificationArea');
const notification = document.createElement('div');
let bgColor = 'bg-blue-100 border-blue-400 text-blue-700';
if (type === 'error') bgColor = 'bg-red-100 border-red-400 text-red-700';
if (type === 'success') bgColor = 'bg-green-100 border-green-400 text-green-700';
if (type === 'warning') bgColor = 'bg-yellow-100 border-yellow-400 text-yellow-700';
notification.className = `notification px-4 py-3 border rounded-lg ${bgColor} flex items-center justify-between`;
notification.innerHTML = `
<span>${message}</span>
<button class="ml-2 text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
`;
notification.querySelector('button').addEventListener('click', () => {
notification.remove();
});
notificationArea.appendChild(notification);
setTimeout(() => {
notification.remove();
}, 5000);
}
// Update storage usage display
function updateStorageUsage() {
if (!navigator.storage || !navigator.storage.estimate) {
console.log('StorageManager API not available');
return;
}
navigator.storage.estimate().then(estimate => {
const percentUsed = (estimate.usage / estimate.quota * 100).toFixed(1);
const usageMB = (estimate.usage / (1024 * 1024)).toFixed(2);
const quotaMB = (estimate.quota / (1024 * 1024)).toFixed(2);
document.getElementById('storageUsed').style.width = `${percentUsed}%`;
document.getElementById('storageText').textContent = `${usageMB} MB / ${quotaMB} MB (${percentUsed}%)`;
if (percentUsed > 80) {
document.getElementById('storageUsed').classList.add('bg-red-600');
document.getElementById('storageUsed').classList.remove('bg-blue-600');
} else {
document.getElementById('storageUsed').classList.add('bg-blue-600');
document.getElementById('storageUsed').classList.remove('bg-red-600');
}
});
}
// Tab switching
function setupTabs() {
const tabs = {
dashboardTab: 'dashboardPanel',
interventionsTab: 'interventionsPanel',
clientsTab: 'clientsPanel',
techniciensTab: 'techniciensPanel',
reportsTab: 'reportsPanel',
settingsTab: 'settingsPanel'
};
Object.entries(tabs).forEach(([tabId, panelId]) => {
document.getElementById(tabId).addEventListener('click', () => {
// Hide all panels
Object.values(tabs).forEach(id => {
document.getElementById(id).classList.add('hidden');
});
// Remove active class from all tabs
Object.keys(tabs).forEach(id => {
document.getElementById(id).classList.remove('bg-blue-100', 'text-blue-700');
document.getElementById(id).classList.add('hover:bg-gray-100');
});
// Show selected panel
document.getElementById(panelId).classList.remove('hidden');
// Add active class to selected tab
document.getElementById(tabId).classList.add('bg-blue-100', 'text-blue-700');
document.getElementById(tabId).classList.remove('hover:bg-gray-100');
// Load data if needed
if (panelId === 'interventionsPanel') {
loadInterventions();
} else if (panelId === 'clientsPanel') {
loadClients();
} else if (panelId === 'techniciensPanel') {
loadTechniciens();
} else if (panelId === 'reportsPanel') {
loadReports();
} else if (panelId === 'dashboardPanel') {
updateDashboard();
} else if (panelId === 'settingsPanel') {
loadSettings();
}
});
});
// Start with dashboard
document.getElementById('dashboardTab').click();
}
// CRUD Operations for Interventions
function loadInterventions(filter = 'all', search = '', page = 1, pageSize = 10) {
return new Promise((resolve, reject) => {
const transaction = db.transaction([INTERVENTIONS_STORE], 'readonly');
const store = transaction.objectStore(INTERVENTIONS_STORE);
const request = store.getAll();
request.onsuccess = function(event) {
let interventions = event.target.result;
// Apply filter
if (filter === 'ongoing') {
interventions = interventions.filter(i => i.status === 'En cours');
} else if (filter === 'completed') {
interventions = interventions.filter(i => i.status === 'Terminée');
} else if (filter === 'late') {
const today = new Date().toISOString().split('T')[0];
interventions = interventions.filter(i => i.status !== 'Terminée' && i.date < today);
}
// Apply search
if (search) {
const searchLower = search.toLowerCase();
interventions = interventions.filter(i =>
i.description.toLowerCase().includes(searchLower) ||
(i.clientName && i.clientName.toLowerCase().includes(searchLower)) ||
(i.technicienName && i.technicienName.toLowerCase().includes(searchLower))
);
}
// Sort by date (newest first)
interventions.sort((a, b) => new Date(b.date) - new Date(a.date));
// Pagination
const total = interventions.length;
const totalPages = Math.ceil(total / pageSize);
const start = (page - 1) * pageSize;
const end = start + pageSize;
const paginatedInterventions = interventions.slice(start, end);
// Update UI
const tbody = document.getElementById('interventionsTableBody');
tbody.innerHTML = '';
if (paginatedInterventions.length === 0) {
tbody.innerHTML = `
<tr>
<td colspan="6" class="py-4 text-center text-gray-500">Aucune intervention trouvée</td>
</tr>
`;
} else {
paginatedInterventions.forEach(intervention => {
const row = document.createElement('tr');
// Determine status color
let statusColor = 'bg-gray-100 text-gray-800';
if (intervention.status === 'En cours') statusColor = 'bg-blue-100 text-blue-800';
if (intervention.status === 'Terminée') statusColor = 'bg-green-100 text-green-800';
if (intervention.status === 'Annulée') statusColor = 'bg-red-100 text-red-800';
// Check if late
const today = new Date().toISOString().split('T')[0];
const isLate = intervention.status !== 'Terminée' && intervention.date < today;
if (isLate) statusColor = 'bg-yellow-100 text-yellow-800';
row.innerHTML = `
<td class="py-2 px-4">INT-${intervention.id.toString().padStart(4, '0')}</td>
<td class="py-2 px-4">${intervention.clientName || 'N/A'}</td>
<td class="py-2 px-4">${intervention.description.substring(0, 30)}${intervention.description.length > 30 ? '...' : ''}</td>
<td class="py-2 px-4">${formatDate(intervention.date)}</td>
<td class="py-2 px-4">
<span class="px-2 py-1 rounded-full text-xs font-medium ${statusColor}">
${intervention.status}${isLate ? ' (Retard)' : ''}
</span>
</td>
<td class="py-2 px-4">
<div class="flex space-x-1">
<button class="edit-intervention p-1 text-blue-600 hover:text-blue-800" data-id="${intervention.id}">
<i class="fas fa-edit"></i>
</button>
<button class="view-intervention p-1 text-green-600 hover:text-green-800" data-id="${intervention.id}">
<i class="fas fa-eye"></i>
</button>
<button class="delete-intervention p-1 text-red-600 hover:text-red-800" data-id="${intervention.id}">
<i class="fas fa-trash"></i>
</button>
</div>
</td>
`;
tbody.appendChild(row);
});
}
// Update pagination info
document.getElementById('interventionsCount').textContent = `${total} intervention${total !== 1 ? 's' : ''}`;
document.getElementById('interventionsPage').textContent = `${page}/${totalPages}`;
// Enable/disable pagination buttons
document.getElementById('prevInterventions').disabled = page <= 1;
document.getElementById('nextInterventions').disabled = page >= totalPages;
// Add event listeners to buttons
document.querySelectorAll('.edit-intervention').forEach(btn => {
btn.addEventListener('click', () => editIntervention(btn.dataset.id));
});
document.querySelectorAll('.delete-intervention').forEach(btn => {
btn.addEventListener('click', () => confirmDeleteIntervention(btn.dataset.id));
});
document.querySelectorAll('.view-intervention').forEach(btn => {
btn.addEventListener('click', () => viewIntervention(btn.dataset.id));
});
resolve(interventions);
};
request.onerror = function(event) {
console.error('Error loading interventions:', event.target.error);
reject('Error loading interventions');
showNotification('Erreur lors du chargement des interventions', 'error');
};
});
}
function addIntervention(intervention) {
return new Promise((resolve, reject) => {
const transaction = db.transaction([INTERVENTIONS_STORE], 'readwrite');
const store = transaction.objectStore(INTERVENTIONS_STORE);
// Get client and technicien names
Promise.all([
getClientName(intervention.clientId),
getTechnicienName(intervention.technicienId)
]).then(([clientName, technicienName]) => {
intervention.clientName = clientName;
intervention.technicienName = technicienName;
const request = store.add(intervention);
request.onsuccess = function(event) {
resolve(event.target.result);
showNotification('Intervention ajoutée avec succès', 'success');
updateDashboard();
};
request.onerror = function(event) {
console.error('Error adding intervention:', event.target.error);
reject('Error adding intervention');
showNotification('Erreur lors de l\'ajout de l\'intervention', 'error');
};
}).catch(error => {
console.error('Error getting names:', error);
reject('Error getting names');
});
});
}
function updateIntervention(intervention) {
return new Promise((resolve, reject) => {
const transaction = db.transaction([INTERVENTIONS_STORE], 'readwrite');
const store = transaction.objectStore(INTERVENTIONS_STORE);
// Get client and technicien names
Promise.all([
getClientName(intervention.clientId),
getTechnicienName(intervention.technicienId)
]).then(([clientName, technicienName]) => {
intervention.clientName = clientName;
intervention.technicienName = technicienName;
const request = store.put(intervention);
request.onsuccess = function(event) {
resolve(event.target.result);
showNotification('Intervention mise à jour avec succès', 'success');
updateDashboard();
};
request.onerror = function(event) {
console.error('Error updating intervention:', event.target.error);
reject('Error updating intervention');
showNotification('Erreur lors de la mise à jour de l\'intervention', 'error');
};
}).catch(error => {
console.error('Error getting names:', error);
reject('Error getting names');
});
});
}
function deleteIntervention(id) {
return new Promise((resolve, reject) => {
const transaction = db.transaction([INTERVENTIONS_STORE], 'readwrite');
const store = transaction.objectStore(INTERVENTIONS_STORE);
const request = store.delete(Number(id));
request.onsuccess = function(event) {
resolve(event.target.result);
showNotification('Intervention supprimée avec succès', 'success');
updateDashboard();
};
request.onerror = function(event) {
console.error('Error deleting intervention:', event.target.error);
reject('Error deleting intervention');
showNotification('Erreur lors de la suppression de l\'intervention', 'error');
};
});
}
function getIntervention(id) {
return new Promise((resolve, reject) => {
const transaction = db.transaction([INTERVENTIONS_STORE], 'readonly');
const store = transaction.objectStore(INTERVENTIONS_STORE);
const request = store.get(Number(id));
request.onsuccess = function(event) {
resolve(event.target.result);
};
request.onerror = function(event) {
console.error('Error getting intervention:', event.target.error);
reject('Error getting intervention');
};
});
}
function getClientName(id) {
return new Promise((resolve, reject) => {
if (!id) resolve(null);
const transaction = db.transaction([CLIENTS_STORE], 'readonly');
const store = transaction.objectStore(CLIENTS_STORE);
const request = store.get(Number(id));
request.onsuccess = function(event) {
resolve(event.target.result ? event.target.result.name : null);
};
request.onerror = function(event) {
console.error('Error getting client name:', event.target.error);
reject('Error getting client name');
};
});
}
function getTechnicienName(id) {
return new Promise((resolve, reject) => {
if (!id) resolve(null);
const transaction = db.transaction([TECHNICIENS_STORE], 'readonly');
const store = transaction.objectStore(TECHNICIENS_STORE);
const request = store.get(Number(id));
request.onsuccess = function(event) {
resolve(event.target.result ? event.target.result.name : null);
};
request.onerror = function(event) {
console.error('Error getting technicien name:', event.target.error);
reject('Error getting technicien name');
};
});
}
// CRUD Operations for Clients
function loadClients(search = '', page = 1, pageSize = 10) {
return new Promise((resolve, reject) => {
const transaction = db.transaction([CLIENTS_STORE], 'readonly');
const store = transaction.objectStore(CLIENTS_STORE);
const request = store.getAll();
request.onsuccess = function(event) {
let clients = event.target.result;
// Apply search
if (search) {
const searchLower = search.toLowerCase();
clients = clients.filter(c =>
c.name.toLowerCase().includes(searchLower) ||
(c.email && c.email.toLowerCase().includes(searchLower)) ||
(c.phone && c.phone.toLowerCase().includes(searchLower))
);
}
// Sort by name
clients.sort((a, b) => a.name.localeCompare(b.name));
// Pagination
const total = clients.length;
const totalPages = Math.ceil(total / pageSize);
const start = (page - 1) * pageSize;
const end = start + pageSize;
const paginatedClients = clients.slice(start, end);
// Update UI
const tbody = document.getElementById('clientsTableBody');
tbody.innerHTML = '';
if (paginatedClients.length === 0) {
tbody.innerHTML = `
<tr>
<td colspan="5" class="py-4 text-center text-gray-500">Aucun client trouvé</td>
</tr>
`;
} else {
paginatedClients.forEach(client => {
const row = document.createElement('tr');
row.innerHTML = `
<td class="py-2 px-4">${client.name}</td>
<td class="py-2 px-4">${client.email || 'N/A'}</td>
<td class="py-2 px-4">${client.phone || 'N/A'}</td>
<td class="py-2 px-4">${client.address ? client.address.substring(0, 20) + (client.address.length > 20 ? '...' : '') : 'N/A'}</td>
<td class="py-2 px-4">
<div class="flex space-x-1">
<button class="edit-client p-1 text-blue-600 hover:text-blue-800" data-id="${client.id}">
<i class="fas fa-edit"></i>
</button>
<button class="delete-client p-1 text-red-600 hover:text-red-800" data-id="${client.id}">
<i class="fas fa-trash"></i>
</button>
</div>
</td>
`;
tbody.appendChild(row);
});
}
// Update pagination info
document.getElementById('clientsTableCount').textContent = `${total} client${total !== 1 ? 's' : ''}`;
document.getElementById('clientsPage').textContent = `${page}/${totalPages}`;
// Enable/disable pagination buttons
document.getElementById('prevClients').disabled = page <= 1;
document.getElementById('nextClients').disabled = page >= totalPages;
// Add event listeners to buttons
document.querySelectorAll('.edit-client').forEach(btn => {
btn.addEventListener('click', () => editClient(btn.dataset.id));
});
document.querySelectorAll('.delete-client').forEach(btn => {
btn.addEventListener('click', () => confirmDeleteClient(btn.dataset.id));
});
resolve(clients);
};
request.onerror = function(event) {
console.error('Error loading clients:', event.target.error);
reject('Error loading clients');
showNotification('Erreur lors du chargement des clients', 'error');
};
});
}
function addClient(client) {
return new Promise((resolve, reject) => {
const transaction = db.transaction([CLIENTS_STORE], 'readwrite');
const store = transaction.objectStore(CLIENTS_STORE);
const request = store.add(client);
request.onsuccess = function(event) {
resolve(event.target.result);
showNotification('Client ajouté avec succès', 'success');
updateDashboard();
};
request.onerror = function(event) {
console.error('Error adding client:', event.target.error);
reject('Error adding client');
showNotification('Erreur lors de l\'ajout du client', 'error');
};
});
}
function updateClient(client) {
return new Promise((resolve, reject) => {
const transaction = db.transaction([CLIENTS_STORE], 'readwrite');
const store = transaction.objectStore(CLIENTS_STORE);
const request = store.put(client);
request.onsuccess = function(event) {
resolve(event.target.result);
showNotification('Client mis à jour avec succès', 'success');
// Update client name in interventions
updateClientNameInInterventions(client.id, client.name);
};
request.onerror = function(event) {
console.error('Error updating client:', event.target.error);
reject('Error updating client');
showNotification('Erreur lors de la mise à jour du client', 'error');
};
});
}
function deleteClient(id) {
return new Promise((resolve, reject) => {
const transaction = db.transaction([CLIENTS_STORE], 'readwrite');
const store = transaction.objectStore(CLIENTS_STORE);
const request = store.delete(Number(id));
request.onsuccess = function(event) {
resolve(event.target.result);
showNotification('Client supprimé avec succès', 'success');
updateDashboard();
};
request.onerror = function(event) {
console.error('Error deleting client:', event.target.error);
reject('Error deleting client');
showNotification('Erreur lors de la suppression du client', 'error');
};
});
}
function getClient(id) {
return new Promise((resolve, reject) => {
const transaction = db.transaction([CLIENTS_STORE], 'readonly');
const store = transaction.objectStore(CLIENTS_STORE);
const request = store.get(Number(id));
request.onsuccess = function(event) {
resolve(event.target.result);
};
request.onerror = function(event) {
console.error('Error getting client:', event.target.error);
reject('Error getting client');
};
});
}
function updateClientNameInInterventions(clientId, clientName) {
return new Promise((resolve, reject) => {
const transaction = db.transaction([INTERVENTIONS_STORE], 'readwrite');
const store = transaction.objectStore(INTERVENTIONS_STORE);
const index = store.index('clientId');
const request = index.getAll(clientId);
request.onsuccess = function(event) {
const interventions = event.target.result;
if (interventions.length === 0) {
resolve();
return;
}
interventions.forEach(intervention => {
intervention.clientName = clientName;
store.put(intervention);
});
resolve();
};
request.onerror = function(event) {
console.error('Error updating client name in interventions:', event.target.error);
reject('Error updating client name in interventions');
};
});
}
// CRUD Operations for Techniciens
function loadTechniciens(search = '', page = 1, pageSize = 10) {
return new Promise((resolve, reject) => {
const transaction = db.transaction([TECHNICIENS_STORE], 'readonly');
const store = transaction.objectStore(TECHNICIENS_STORE);
const request = store.getAll();
request.onsuccess = function(event) {
let techniciens = event.target.result;
// Apply search
if (search) {
const searchLower = search.toLowerCase();
techniciens = techniciens.filter(t =>
t.name.toLowerCase().includes(searchLower) ||
(t.email && t.email.toLowerCase().includes(searchLower)) ||
(t.phone && t.phone.toLowerCase().includes(searchLower))
);
}
// Sort by name
techniciens.sort((a, b) => a.name.localeCompare(b.name));
// Pagination
const total = techniciens.length;
const totalPages = Math.ceil(total / pageSize);
const start = (page - 1) * pageSize;
const end = start + pageSize;
const paginatedTechniciens = techniciens.slice(start, end);
// Update UI
const tbody = document.getElementById('techniciensTableBody');
tbody.innerHTML = '';
if (paginatedTechniciens.length === 0) {
tbody.innerHTML = `
<tr>
<td colspan="5" class="py-4 text-center text-gray-500">Aucun technicien trouvé</td>
</tr>
`;
} else {
paginatedTechniciens.forEach(technicien => {
const row = document.createElement('tr');
row.innerHTML = `
<td class="py-2 px-4">${technicien.name}</td>
<td class="py-2 px-4">${technicien.email || 'N/A'}</td>
<td class="py-2 px-4">${technicien.phone || 'N/A'}</td>
<td class="py-2 px-4">
<span class="px-2 py-1 rounded-full text-xs font-medium bg-purple-100 text-purple-800">
${technicien.specialite}
</span>
</td>
<td class="py-2 px-4">
<div class="flex space-x-1">
<button class="edit-technicien p-1 text-blue-600 hover:text-blue-800" data-id="${technicien.id}">
<i class="fas fa-edit"></i>
</button>
<button class="delete-technicien p-1 text-red-600 hover:text-red-800" data-id="${technicien.id}">
<i class="fas fa-trash"></i>
</button>
</div>
</td>
`;
tbody.appendChild(row);
});
}
// Update pagination info
document.getElementById('techniciensCount').textContent = `${total} technicien${total !== 1 ? 's' : ''}`;
document.getElementById('techniciensPage').textContent = `${page}/${totalPages}`;
// Enable/disable pagination buttons
document.getElementById('prevTechniciens').disabled = page <= 1;
document.getElementById('nextTechniciens').disabled = page >= totalPages;
// Add event listeners to buttons
document.querySelectorAll('.edit-technicien').forEach(btn => {
btn.addEventListener('click', () => editTechnicien(btn.dataset.id));
});
document.querySelectorAll('.delete-technicien').forEach(btn => {
btn.addEventListener('click', () => confirmDeleteTechnicien(btn.dataset.id));
});
resolve(techniciens);
};
request.onerror = function(event) {
console.error('Error loading techniciens:', event.target.error);
reject('Error loading techniciens');
showNotification('Erreur lors du chargement des techniciens', 'error');
};
});
}
function
<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=mohamedelazzouzi/techinter" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gestion Interventions IT</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="manifest" href="/manifest.json">
<style>
/* Custom styles for the offline indicator */
.offline-indicator {
position: fixed;
bottom: 20px;
right: 20px;
z-index: 1000;
display: none;
}
/* Animation for notifications */
@keyframes slideIn {
from { transform: translateX(100%); }
to { transform: translateX(0); }
}
.notification {
animation: slideIn 0.3s ease-out;
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Print styles */
@media print {
.no-print {
display: none ;
}
body {
padding: 0;
margin: 0;
background: white;
color: black;
}
.print-table {
width: 100%;
border-collapse: collapse;
}
.print-table th, .print-table td {
border: 1px solid #ddd;
padding: 8px;
}
}
</style>
</head>
<body class="bg-gray-100 font-sans">
<!-- Offline Indicator -->
<div id="offlineIndicator" class="offline-indicator bg-yellow-500 text-white px-4 py-2 rounded-lg shadow-lg">
<i class="fas fa-wifi-slash mr-2"></i> Mode hors ligne activé
</div>
<!-- Notification Area -->
<div id="notificationArea" class="fixed top-4 right-4 z-50 space-y-2"></div>
<!-- Main Container -->
<div class="container mx-auto px-4 py-6 max-w-6xl">
<!-- Header -->
<header class="bg-blue-600 text-white rounded-lg shadow-md p-4 mb-6">
<div class="flex justify-between items-center">
<div>
<h1 class="text-2xl md:text-3xl font-bold">
<i class="fas fa-laptop-medical mr-2"></i> Gestion Interventions IT
</h1>
<p class="text-blue-100 text-sm mt-1">Suivi des interventions informatiques</p>
</div>
<div class="flex space-x-2">
<button id="installBtn" class="bg-blue-700 hover:bg-blue-800 px-3 py-1 rounded-lg text-sm hidden">
<i class="fas fa-download mr-1"></i> Installer
</button>
<button id="exportBtn" class="bg-green-600 hover:bg-green-700 px-3 py-1 rounded-lg text-sm">
<i class="fas fa-file-export mr-1"></i> Exporter
</button>
<button id="importBtn" class="bg-purple-600 hover:bg-purple-700 px-3 py-1 rounded-lg text-sm">