Przeglądaj źródła

Ajout du contenu du dossier app

augustin.podvin 9 miesięcy temu
rodzic
commit
6c02460714
5 zmienionych plików z 368 dodań i 0 usunięć
  1. 102 0
      app/client.html
  2. 43 0
      app/dashboard.html
  3. 128 0
      app/index.html
  4. 43 0
      app/quantites-clients.html
  5. 52 0
      app/top-clients.html

+ 102 - 0
app/client.html

@@ -0,0 +1,102 @@
+<!DOCTYPE html>
+<html lang="fr">
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>Détail client - dirCops</title>
+  <script src="https://cdn.tailwindcss.com"></script>
+</head>
+<body class="bg-gray-50 min-h-screen">
+  <div class="max-w-5xl mx-auto px-4 py-8">
+    <header class="flex justify-between items-center mb-8">
+      <h1 class="text-2xl font-semibold text-gray-800">dirCops</h1>
+      <nav class="space-x-4">
+        <a href="index.html" class="text-gray-600 hover:text-blue-600">Clients</a>
+        <a href="dashboard.html" class="text-gray-600 hover:text-blue-600">Tableau de bord</a>
+        <a href="top-clients.html" class="text-gray-600 hover:text-blue-600">Top clients</a>
+        <a href="quantites-clients.html" class="text-gray-600 hover:text-blue-600">Quantités</a>
+      </nav>
+    </header>
+
+    <div id="error-message" class="hidden mb-4 p-3 bg-red-100 text-red-700 rounded"></div>
+
+    <div id="client-header" class="mb-8">
+      <p class="text-gray-500">Chargement...</p>
+    </div>
+
+    <section class="bg-white rounded-lg shadow p-6 mb-8">
+      <h2 class="text-lg font-medium text-gray-800 mb-4">Factures</h2>
+      <div id="factures-list" class="overflow-x-auto -mx-2 px-2">Chargement...</div>
+    </section>
+
+    <section class="bg-white rounded-lg shadow p-6 mb-8">
+      <h2 class="text-lg font-medium text-gray-800 mb-4">Ajouter une facture (suivi)</h2>
+      <p class="text-sm text-gray-500 mb-4">La facturation provient de Pennylane ; saisir ici les données pour le suivi (même structure que l’onglet Factures Excel).</p>
+      <form id="form-facture" class="flex flex-wrap gap-4 items-end">
+        <input type="hidden" id="facture_client_id" name="client_id" value="">
+        <div><label for="n_facture" class="block text-sm text-gray-600 mb-1">N° FACTURE</label><input type="text" id="n_facture" name="n_facture" class="border border-gray-300 rounded px-3 py-2" required></div>
+        <div><label for="n_vente" class="block text-sm text-gray-600 mb-1">N° DE VENTE</label><input type="text" id="n_vente" name="n_vente" class="border border-gray-300 rounded px-3 py-2"></div>
+        <div><label for="date_facture" class="block text-sm text-gray-600 mb-1">DATE FACTUR</label><input type="date" id="date_facture" name="date_facture" class="border border-gray-300 rounded px-3 py-2" required></div>
+        <div><label for="type_produit" class="block text-sm text-gray-600 mb-1">TYPE (NEG.)</label><select id="type_produit" name="type_produit" class="border border-gray-300 rounded px-3 py-2"><option value="">—</option><option value="alevins">Alevin Bar</option><option value="larves">Larve Bar</option></select></div>
+        <div><label for="cycle" class="block text-sm text-gray-600 mb-1">CYCLE</label><input type="text" id="cycle" name="cycle" placeholder="24-25 ou 25-26" class="border border-gray-300 rounded px-3 py-2"></div>
+        <div><label for="quantites" class="block text-sm text-gray-600 mb-1">QTE FACT</label><input type="number" id="quantites" name="quantites" step="0.01" min="0" class="border border-gray-300 rounded px-3 py-2" placeholder="Qté facturée"></div>
+        <div><label for="qte_livree" class="block text-sm text-gray-600 mb-1">QTE LIVREE</label><input type="number" id="qte_livree" name="qte_livree" step="0.01" min="0" class="border border-gray-300 rounded px-3 py-2" placeholder="Qté livrée"></div>
+        <div><label for="montant_ht" class="block text-sm text-gray-600 mb-1">CA FACTURE HT (€)</label><input type="number" id="montant_ht" name="montant_ht" step="0.01" min="0.01" class="border border-gray-300 rounded px-3 py-2" required></div>
+        <button type="submit" class="px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700">Ajouter la facture</button>
+      </form>
+    </section>
+
+    <section class="bg-white rounded-lg shadow p-6 mb-8">
+      <h2 class="text-lg font-medium text-gray-800 mb-4">Écheancier de paiement</h2>
+      <p class="text-sm text-gray-500 mb-4">Associer à une facture un plan de paiement échelonné (échéances mensuelles). Le montant de l’encours sera réparti équitablement sur le nombre d’échéances.</p>
+      <div id="echeanciers-list" class="mb-4">—</div>
+      <form id="form-echeancier" class="flex flex-wrap gap-4 items-end">
+        <div>
+          <label for="echeancier_facture_id" class="block text-sm text-gray-600 mb-1">Facture</label>
+          <select id="echeancier_facture_id" name="facture_id" class="border border-gray-300 rounded px-3 py-2 min-w-[200px]" required></select>
+        </div>
+        <div>
+          <label for="nb_echeances" class="block text-sm text-gray-600 mb-1">Nombre d’échéances</label>
+          <input type="number" id="nb_echeances" name="nb_echeances" min="1" class="border border-gray-300 rounded px-3 py-2" required>
+        </div>
+        <div>
+          <label for="date_debut_echeancier" class="block text-sm text-gray-600 mb-1">Date de début</label>
+          <input type="date" id="date_debut_echeancier" name="date_debut_echeancier" class="border border-gray-300 rounded px-3 py-2" required>
+        </div>
+        <button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded hover:bg-indigo-700">Ajouter l’écheancier</button>
+      </form>
+      <div id="apercu-echeancier"></div>
+    </section>
+
+    <section class="bg-white rounded-lg shadow p-6 mb-8">
+      <h2 class="text-lg font-medium text-gray-800 mb-4">Enregistrer un paiement</h2>
+      <form id="form-paiement" class="flex flex-wrap gap-4 items-end">
+        <div>
+          <label for="facture_id" class="block text-sm text-gray-600 mb-1">Facture</label>
+          <select id="facture_id" name="facture_id" class="border border-gray-300 rounded px-3 py-2 min-w-[200px]" required></select>
+        </div>
+        <div>
+          <label for="montant" class="block text-sm text-gray-600 mb-1">Montant (€)</label>
+          <input type="number" id="montant" name="montant" step="0.01" min="0.01" class="border border-gray-300 rounded px-3 py-2" required>
+        </div>
+        <div>
+          <label for="date_paiement" class="block text-sm text-gray-600 mb-1">Date</label>
+          <input type="date" id="date_paiement" name="date_paiement" class="border border-gray-300 rounded px-3 py-2" required>
+        </div>
+        <button type="submit" class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">Enregistrer</button>
+      </form>
+    </section>
+
+    <section class="bg-white rounded-lg shadow p-6 mb-8">
+      <h2 class="text-lg font-medium text-gray-800 mb-4">Paiements</h2>
+      <div id="paiements-list">Chargement...</div>
+    </section>
+  </div>
+
+  <script src="js/utils.js"></script>
+  <script src="js/client-detail.js"></script>
+  <script src="js/facture-form.js"></script>
+  <script src="js/echeancier-form.js"></script>
+  <script src="js/paiements.js"></script>
+</body>
+</html>

+ 43 - 0
app/dashboard.html

@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html lang="fr">
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>Tableau de bord - dirCops</title>
+  <script src="https://cdn.tailwindcss.com"></script>
+</head>
+<body class="bg-gray-50 min-h-screen">
+  <div class="max-w-5xl mx-auto px-4 py-8">
+    <header class="flex justify-between items-center mb-8">
+      <h1 class="text-2xl font-semibold text-gray-800">dirCops</h1>
+      <nav class="space-x-4">
+        <a href="index.html" class="text-gray-600 hover:text-blue-600">Clients</a>
+        <a href="dashboard.html" class="text-blue-600 font-medium">Tableau de bord</a>
+        <a href="top-clients.html" class="text-gray-600 hover:text-blue-600">Top clients</a>
+        <a href="quantites-clients.html" class="text-gray-600 hover:text-blue-600">Quantités</a>
+      </nav>
+    </header>
+
+    <div id="error-message" class="hidden mb-4 p-3 bg-red-100 text-red-700 rounded"></div>
+
+    <section class="bg-white rounded-lg shadow overflow-hidden mb-8">
+      <div class="px-6 py-4 border-b border-gray-200 flex flex-wrap justify-between items-center gap-2">
+        <h2 id="titre-encours" class="text-lg font-medium text-gray-800">Encours clients au …</h2>
+        <div class="flex flex-wrap gap-3 text-sm">
+          <a href="api/reporting.php?format=csv" class="text-blue-600 hover:underline">Exporter encours CSV</a>
+          <a href="api/reporting.php?format=factures_csv" class="text-blue-600 hover:underline">Exporter l’ensemble des factures (PJ)</a>
+        </div>
+      </div>
+      <div id="encours-par-client" class="p-6 overflow-x-auto">Chargement...</div>
+      <div id="synthèse-encours" class="px-6 pb-6"></div>
+    </section>
+    <section class="bg-white rounded-lg shadow overflow-hidden mt-8">
+      <h2 class="px-6 py-4 border-b border-gray-200 text-lg font-medium text-gray-800">Échéances à venir</h2>
+      <div id="echeances" class="p-6">Chargement...</div>
+    </section>
+  </div>
+
+  <script src="js/utils.js"></script>
+  <script src="js/dashboard.js"></script>
+</body>
+</html>

+ 128 - 0
app/index.html

@@ -0,0 +1,128 @@
+<!DOCTYPE html>
+<html lang="fr">
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>Clients - dirCops</title>
+  <script src="https://cdn.tailwindcss.com"></script>
+</head>
+<body class="bg-gray-50 min-h-screen">
+  <div class="max-w-4xl mx-auto px-4 py-8">
+    <header class="flex justify-between items-center mb-8">
+      <h1 class="text-2xl font-semibold text-gray-800">dirCops</h1>
+      <nav class="space-x-4">
+        <a href="index.html" class="text-blue-600 font-medium">Clients</a>
+        <a href="dashboard.html" class="text-gray-600 hover:text-blue-600">Tableau de bord</a>
+        <a href="top-clients.html" class="text-gray-600 hover:text-blue-600">Top clients</a>
+        <a href="quantites-clients.html" class="text-gray-600 hover:text-blue-600">Quantités</a>
+      </nav>
+    </header>
+
+    <div id="error-message" class="hidden mb-4 p-3 bg-red-100 text-red-700 rounded"></div>
+
+    <section class="bg-white rounded-lg shadow p-6 mb-6">
+      <h2 class="text-lg font-medium text-gray-800 mb-4">Ajouter un client</h2>
+      <form id="form-client" class="flex gap-4 items-end">
+        <div class="flex-1">
+          <label for="nom_client" class="block text-sm text-gray-600 mb-1">Nom du client</label>
+          <input type="text" id="nom_client" name="nom" class="w-full border border-gray-300 rounded px-3 py-2" placeholder="Ex: AQUANARIA" required>
+        </div>
+        <button type="submit" class="px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700">Ajouter</button>
+      </form>
+    </section>
+
+    <div class="mb-6">
+      <label for="search" class="block text-sm font-medium text-gray-700 mb-1">Rechercher un client</label>
+      <input type="text" id="search" placeholder="Nom du client..." class="w-full max-w-md border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
+    </div>
+
+    <div id="client-list" class="bg-white rounded-lg shadow overflow-hidden">
+      <table class="min-w-full divide-y divide-gray-200">
+        <thead class="bg-gray-100">
+          <tr>
+            <th class="px-4 py-3 text-left text-xs font-medium text-gray-600 uppercase">Client</th>
+            <th class="px-4 py-3 text-right text-xs font-medium text-gray-600 uppercase">Actions</th>
+          </tr>
+        </thead>
+        <tbody id="client-list-body" class="divide-y divide-gray-200">
+          <tr><td colspan="2" class="px-4 py-6 text-center text-gray-500">Chargement...</td></tr>
+        </tbody>
+      </table>
+    </div>
+  </div>
+
+  <script src="js/utils.js"></script>
+  <script>
+    const listBody = document.getElementById('client-list-body');
+    const searchInput = document.getElementById('search');
+
+    async function loadClients(q = '') {
+      hideError();
+      try {
+        const clients = await apiGet('/clients.php', q ? { q } : {});
+        if (clients.length === 0) {
+          listBody.innerHTML = '<tr><td colspan="2" class="px-4 py-6 text-center text-gray-500">Aucun client trouvé.</td></tr>';
+          return;
+        }
+        listBody.innerHTML = clients.map(c => {
+          const nomEscaped = escapeHtml(c.nom).replace(/'/g, "\\'").replace(/"/g, '&quot;');
+          return `
+          <tr class="hover:bg-gray-50">
+            <td class="px-4 py-3 font-medium text-gray-900">${escapeHtml(c.nom)}</td>
+            <td class="px-4 py-3 text-right">
+              <a href="client.html?id=${c.id}" class="text-blue-600 hover:underline mr-4">Voir le détail</a>
+              <button onclick="deleteClient(${c.id}, ${JSON.stringify(c.nom)})" class="text-red-600 hover:text-red-800" title="Supprimer">
+                <svg class="w-4 h-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path></svg>
+              </button>
+            </td>
+          </tr>
+        `;
+        }).join('');
+      } catch (e) {
+        showError(e.message);
+        listBody.innerHTML = '<tr><td colspan="2" class="px-4 py-6 text-center text-red-500">Erreur de chargement.</td></tr>';
+      }
+    }
+
+    function escapeHtml(text) {
+      const div = document.createElement('div');
+      div.textContent = text;
+      return div.innerHTML;
+    }
+
+    searchInput.addEventListener('input', () => {
+      const q = searchInput.value.trim();
+      loadClients(q);
+    });
+
+    const formClient = document.getElementById('form-client');
+    formClient.addEventListener('submit', async (e) => {
+      e.preventDefault();
+      hideError();
+      const nom = document.getElementById('nom_client').value.trim();
+      if (!nom) return;
+      try {
+        await apiPost('/clients.php', { nom });
+        document.getElementById('nom_client').value = '';
+        loadClients(searchInput.value.trim());
+      } catch (err) {
+        showError(err.message);
+      }
+    });
+
+    window.deleteClient = async function(clientId, nomClient) {
+      if (!confirm('Êtes-vous sûr de vouloir supprimer le client "' + nomClient + '" ? Cette action supprimera également toutes les factures, paiements et écheanciers associés.')) {
+        return;
+      }
+      try {
+        await apiDelete(`/clients.php?id=${clientId}`);
+        loadClients(searchInput.value.trim());
+      } catch (err) {
+        showError(err.message);
+      }
+    };
+
+    loadClients();
+  </script>
+</body>
+</html>

+ 43 - 0
app/quantites-clients.html

@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html lang="fr">
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>Quantités par client - dirCops</title>
+  <script src="https://cdn.tailwindcss.com"></script>
+</head>
+<body class="bg-gray-50 min-h-screen">
+  <div class="max-w-5xl mx-auto px-4 py-8">
+    <header class="flex justify-between items-center mb-8">
+      <h1 class="text-2xl font-semibold text-gray-800">dirCops</h1>
+      <nav class="space-x-4">
+        <a href="index.html" class="text-gray-600 hover:text-blue-600">Clients</a>
+        <a href="dashboard.html" class="text-gray-600 hover:text-blue-600">Tableau de bord</a>
+        <a href="top-clients.html" class="text-gray-600 hover:text-blue-600">Top clients</a>
+        <a href="quantites-clients.html" class="text-blue-600 font-medium">Quantités</a>
+      </nav>
+    </header>
+
+    <div id="error-message" class="hidden mb-4 p-3 bg-red-100 text-red-700 rounded"></div>
+
+    <div class="mb-6">
+      <label for="type" class="block text-sm font-medium text-gray-700 mb-1">Filtrer par type (optionnel)</label>
+      <select id="type" class="border border-gray-300 rounded px-3 py-2">
+        <option value="">Tous</option>
+        <option value="alevins">Alevins</option>
+        <option value="larves">Larves</option>
+      </select>
+      <button type="button" id="btn-refresh" class="ml-2 px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">Actualiser</button>
+    </div>
+
+    <div class="bg-white rounded-lg shadow overflow-hidden">
+      <h2 class="px-6 py-4 border-b text-lg font-medium text-gray-800">Quantités vendues par client</h2>
+      <p class="px-6 text-sm text-gray-500">Qté facturée = quantité sur facture ; Qté livrée = déjà livré.</p>
+      <div id="quantites-list" class="p-6">Chargement...</div>
+    </div>
+  </div>
+
+  <script src="js/utils.js"></script>
+  <script src="js/quantites-clients.js"></script>
+</body>
+</html>

+ 52 - 0
app/top-clients.html

@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html lang="fr">
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>Top clients - dirCops</title>
+  <script src="https://cdn.tailwindcss.com"></script>
+</head>
+<body class="bg-gray-50 min-h-screen">
+  <div class="max-w-5xl mx-auto px-4 py-8">
+    <header class="flex justify-between items-center mb-8">
+      <h1 class="text-2xl font-semibold text-gray-800">dirCops</h1>
+      <nav class="space-x-4">
+        <a href="index.html" class="text-gray-600 hover:text-blue-600">Clients</a>
+        <a href="dashboard.html" class="text-gray-600 hover:text-blue-600">Tableau de bord</a>
+        <a href="top-clients.html" class="text-blue-600 font-medium">Top clients</a>
+        <a href="quantites-clients.html" class="text-gray-600 hover:text-blue-600">Quantités</a>
+      </nav>
+    </header>
+
+    <div id="error-message" class="hidden mb-4 p-3 bg-red-100 text-red-700 rounded"></div>
+
+    <div class="flex flex-wrap gap-4 mb-6">
+      <div>
+        <label for="type" class="block text-sm font-medium text-gray-700 mb-1">Type de produit</label>
+        <select id="type" class="border border-gray-300 rounded px-3 py-2">
+          <option value="alevins">Alevins</option>
+          <option value="larves">Larves</option>
+        </select>
+      </div>
+      <div>
+        <label for="cycle" class="block text-sm font-medium text-gray-700 mb-1">Cycle (optionnel)</label>
+        <select id="cycle" class="border border-gray-300 rounded px-3 py-2">
+          <option value="">Tous</option>
+          <option value="24-25">24-25</option>
+          <option value="25-26">25-26</option>
+        </select>
+      </div>
+      <div class="flex items-end"><button type="button" id="btn-refresh" class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">Actualiser</button></div>
+    </div>
+
+    <div class="bg-white rounded-lg shadow overflow-hidden mb-8">
+      <h2 id="title-section" class="px-6 py-4 border-b text-lg font-medium text-gray-800">Top clients Alevins</h2>
+      <div id="top-list" class="p-6">Chargement...</div>
+      <div id="totaux" class="px-6 pb-4 text-sm text-gray-600"></div>
+    </div>
+  </div>
+
+  <script src="js/utils.js"></script>
+  <script src="js/top-clients.js"></script>
+</body>
+</html>