<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="robots" content="noindex, nofollow">
    <title>Toolbox par DZIT</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        table, th, td {
            border: 1px solid black;
        }
        th, td {
            padding: 10px;
            text-align: center;
        }
        th {
            background-color: #f4f4f4;
        }
        input[type="number"] {
            width: 100px;
        }
    </style>
</head>
<body>
    <h1>Calcul d'amortissement achat Véhicule par DZITSTRATEGY</h1>
    <label for="kmParAn">Nombre de kilomètres parcourus par an :</label>
    <input type="number" id="kmParAn" value="30000" onchange="updateCalculations()">
    <table>
        <thead>
            <tr>
                <th>Critères</th>
                <th class="editable" id="vehiculeCibleHeader" onclick="editLabel('vehiculeCibleHeader')">Golf 8</th>
                <th class="editable" id="vehiculeCompareHeader" onclick="editLabel('vehiculeCompareHeader')">Tesla Model 3</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>Prix d'achat neuf (€)</td>
                <td><input type="number" id="prixNeufCible" value="30000" onchange="updateCalculations()"></td>
                <td><input type="number" id="prixNeufCompare" value="43000" onchange="updateCalculations()"></td>
            </tr>
            <tr>
                <td>Prix d'achat d'occasion (€)</td>
                <td><input type="number" id="prixOccasionCible" value="20000" onchange="updateCalculations()"></td>
                <td><input type="number" id="prixOccasionCompare" value="37000" onchange="updateCalculations()"></td>
            </tr>
            <tr>
                <td>Consommation (L ou kWh/100 km)</td>
                <td><input type="number" id="consommationCible" value="7.5" onchange="updateCalculations()"></td>
                <td><input type="number" id="consommationCompare" value="15" onchange="updateCalculations()"></td>
            </tr>
            <tr>
                <td>Prix carburant (€/L ou €/kWh)</td>
                <td><input type="number" id="prixCarburantCible" value="1.62" step="0.01" onchange="updateCalculations()"></td>
                <td><input type="number" id="prixCarburantCompare" value="0.25" step="0.01" onchange="updateCalculations()"></td>
            </tr>
            <tr>
                <td>Prix carburant au 100 km (€/100 km)</td>
                <td id="prixCarburant100kmCible">0</td>
                <td id="prixCarburant100kmCompare">0</td>
            </tr>
            <tr>
                <td>Coût d'entretien par km (€/km)</td>
                <td><input type="number" id="entretienEkmCible" value="0.020" step="0.01" onchange="updateCalculations()"></td>
                <td><input type="number" id="entretienEkmCompare" value="0.015" step="0.01" onchange="updateCalculations()"></td>
            </tr>
            <tr>
                <td>Prix carburant annuel (€)</td>
                <td id="prixCarburantAnnuelCible">0</td>
                <td id="prixCarburantAnnuelCompare">0</td>
            </tr>
            <tr>
                <td>Entretien annuel (€)</td>
                <td id="entretienAnnuelCible">0</td>
                <td id="entretienAnnuelCompare">0</td>
            </tr>
            <tr>
                <td>Dépenses d'exploitation (€)</td>
                <td id="depensesExploitationCible">0</td>
                <td id="depensesExploitationCompare">0</td>
            </tr>
            <tr>
                <td>Économie d'exploitation annuelle (€)</td>
                <td colspan="2" id="economieExploitation">0</td>
            </tr>
            <tr>
                <td>Facteur d'économie</td>
                <td colspan="2" id="facteurEconomie">1</td>
            </tr>
            <tr>
                <td>Amortissement neuf (années)</td>
                <td colspan="2" id="amortissementNeuf">0</td>
            </tr>
            <tr>
                <td>Amortissement occasion (années)</td>
                <td colspan="2" id="amortissementOccasion">0</td>
            </tr>
        </tbody>
    </table>

<script>
    // Fonction de calculs
    function updateCalculations() {
        const kmParAn = parseFloat(document.getElementById("kmParAn").value);
        const cible = {
            prixNeuf: parseFloat(document.getElementById("prixNeufCible").value),
            prixOccasion: parseFloat(document.getElementById("prixOccasionCible").value),
            consommation: parseFloat(document.getElementById("consommationCible").value),
            prixCarburant: parseFloat(document.getElementById("prixCarburantCible").value),
            entretienEkm: parseFloat(document.getElementById("entretienEkmCible").value)
        };
        const compare = {
            prixNeuf: parseFloat(document.getElementById("prixNeufCompare").value),
            prixOccasion: parseFloat(document.getElementById("prixOccasionCompare").value),
            consommation: parseFloat(document.getElementById("consommationCompare").value),
            prixCarburant: parseFloat(document.getElementById("prixCarburantCompare").value),
            entretienEkm: parseFloat(document.getElementById("entretienEkmCompare").value)
        };

        // Calculs
        const prixCarburant100kmCible = (cible.consommation * cible.prixCarburant).toFixed(2);
        const prixCarburant100kmCompare = (compare.consommation * compare.prixCarburant).toFixed(2);

        const prixCarburantAnnuelCible = (cible.consommation * cible.prixCarburant * kmParAn) / 100;
        const prixCarburantAnnuelCompare = (compare.consommation * compare.prixCarburant * kmParAn) / 100;

        const entretienAnnuelCible = cible.entretienEkm * kmParAn;
        const entretienAnnuelCompare = compare.entretienEkm * kmParAn;

        const depensesExploitationCible = prixCarburantAnnuelCible + entretienAnnuelCible;
        const depensesExploitationCompare = prixCarburantAnnuelCompare + entretienAnnuelCompare;

        const economieExploitation = depensesExploitationCible - depensesExploitationCompare;
        const facteurEconomie = depensesExploitationCible / depensesExploitationCompare;

        const amortissementNeuf = Math.abs(compare.prixNeuf - cible.prixOccasion) / Math.abs(depensesExploitationCompare - depensesExploitationCible);
        const amortissementOccasion = Math.abs(compare.prixOccasion - cible.prixOccasion) / Math.abs(depensesExploitationCompare - depensesExploitationCible);

        // Affichage des résultats
        document.getElementById("prixCarburant100kmCible").textContent = prixCarburant100kmCible;
        document.getElementById("prixCarburant100kmCompare").textContent = prixCarburant100kmCompare;
        document.getElementById("prixCarburantAnnuelCible").textContent = prixCarburantAnnuelCible.toFixed(2);
        document.getElementById("prixCarburantAnnuelCompare").textContent = prixCarburantAnnuelCompare.toFixed(2);
        document.getElementById("entretienAnnuelCible").textContent = entretienAnnuelCible.toFixed(2);
        document.getElementById("entretienAnnuelCompare").textContent = entretienAnnuelCompare.toFixed(2);
        document.getElementById("depensesExploitationCible").textContent = depensesExploitationCible.toFixed(2);
        document.getElementById("depensesExploitationCompare").textContent = depensesExploitationCompare.toFixed(2);
        document.getElementById("economieExploitation").textContent = economieExploitation.toFixed(2);
        document.getElementById("facteurEconomie").textContent = facteurEconomie.toFixed(2);
        document.getElementById("amortissementNeuf").textContent = amortissementNeuf.toFixed(2);
        document.getElementById("amortissementOccasion").textContent = amortissementOccasion.toFixed(2);
    }

    // Désactivation du clic droit
    document.addEventListener('DOMContentLoaded', function() {
        document.addEventListener('contextmenu', function (e) {
            e.preventDefault();
            alert('Le clic droit est désactivé sur cette page.');
        });
        updateCalculations(); // Effectue les calculs au chargement de la page
    });

    function editLabel(elementId) {
        const newLabel = prompt("Entrez le nouveau nom du véhicule :");
        if (newLabel) {
            document.getElementById(elementId).textContent = newLabel;
        }
    }
</script>

</body>
</html>
