v2
This commit is contained in:
parent
c9d7992d5d
commit
917cff3e7d
106
assets/css/custom.css
Normal file
106
assets/css/custom.css
Normal file
@ -0,0 +1,106 @@
|
||||
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
background-color: #F4F7F9;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: linear-gradient(135deg, #4A90E2 0%, #50E3C2 100%);
|
||||
color: white;
|
||||
padding: 2rem 0;
|
||||
margin-bottom: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-weight: 700;
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
|
||||
padding: 2rem;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-weight: 600;
|
||||
margin-bottom: 1.5rem;
|
||||
color: #4A90E2;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.card-title i {
|
||||
margin-right: 0.75rem;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.form-control, .form-select {
|
||||
border-radius: 8px;
|
||||
border: 1px solid #ced4da;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
.form-control:focus {
|
||||
border-color: #4A90E2;
|
||||
box-shadow: 0 0 0 0.25rem rgba(74, 144, 226, 0.25);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #4A90E2;
|
||||
border-color: #4A90E2;
|
||||
border-radius: 8px;
|
||||
padding: 0.75rem 1.5rem;
|
||||
font-weight: 600;
|
||||
transition: background-color 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: #357ABD;
|
||||
border-color: #357ABD;
|
||||
}
|
||||
|
||||
.results-card h3 {
|
||||
text-align: center;
|
||||
color: #aaa;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.result-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 1rem 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.result-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
.result-item span {
|
||||
font-weight: 500;
|
||||
}
|
||||
.result-item .value {
|
||||
font-weight: 700;
|
||||
color: #4A90E2;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.total-value {
|
||||
background-color: #4A90E2;
|
||||
color: white;
|
||||
padding: 1rem;
|
||||
border-radius: 8px;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
.total-value .result-item .value {
|
||||
color: white;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
485
index.php
485
index.php
@ -1,131 +1,370 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
$results = null;
|
||||
$simulation_results = null;
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
// Helper function to generate a random value based on variability
|
||||
function get_random_value($base, $variability) {
|
||||
if ($variability <= 0) {
|
||||
return $base;
|
||||
}
|
||||
$min = $base * (1 - ($variability / 100));
|
||||
$max = $base * (1 + ($variability / 100));
|
||||
// Generate a random float between $min and $max
|
||||
return $min + mt_rand() / mt_getrandmax() * ($max - $min);
|
||||
}
|
||||
|
||||
// ECDF data generation
|
||||
function generate_ecdf_data($data_array) {
|
||||
sort($data_array);
|
||||
$count = count($data_array);
|
||||
$ecdf = [];
|
||||
if ($count == 0) return $ecdf;
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$ecdf[] = ['x' => $data_array[$i], 'y' => ($i + 1) / $count];
|
||||
}
|
||||
return $ecdf;
|
||||
}
|
||||
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// --- GET INPUTS ---
|
||||
|
||||
$valor_veiculo = (float)($_POST['valor_veiculo'] ?? 500000);
|
||||
$rota = (float)($_POST['rota'] ?? 100);
|
||||
$n_dias = (int)($_POST['n_dias'] ?? 22);
|
||||
$diesel = (float)($_POST['diesel'] ?? 5.50);
|
||||
$oleo = (float)($_POST['oleo'] ?? 500);
|
||||
$pecas = (float)($_POST['pecas'] ?? 0.5);
|
||||
$pneu_novo = (float)($_POST['pneu_novo'] ?? 2000);
|
||||
$pneu_recap = (float)($_POST['pneu_recap'] ?? 800);
|
||||
$motorista = (float)($_POST['motorista'] ?? 3000);
|
||||
$n_motorista = (int)($_POST['n_motorista'] ?? 2);
|
||||
$escritorio = (float)($_POST['escritorio'] ?? 5000);
|
||||
$taxas = (float)($_POST['taxas'] ?? 1000);
|
||||
$impostos = (float)($_POST['impostos'] ?? 2000);
|
||||
$pedagio = (float)($_POST['pedagio'] ?? 50);
|
||||
$duracao_contrato = (int)($_POST['duracao_contrato'] ?? 12);
|
||||
|
||||
// --- SIMULATION INPUTS ---
|
||||
|
||||
$valor_contrato_manual = (float)($_POST['valor_contrato_manual'] ?? 0);
|
||||
$n_simulacoes = (int)($_POST['n_simulacoes'] ?? 0);
|
||||
$variabilidade = (float)($_POST['variabilidade'] ?? 0);
|
||||
|
||||
// --- CALCULATION FUNCTIONS ---
|
||||
|
||||
function custo_onibus($diesel, $oleo, $pneu_novo, $pneu_recap, $pecas) {
|
||||
return ($diesel * 0.33) + ($oleo / 15000) + ($pneu_novo / 50000 * 2) + ($pneu_recap / 50000 * 4) + $pecas;
|
||||
}
|
||||
|
||||
function custo_fixo($motorista, $escritorio, $taxas, $impostos, $pedagio, $valor_veiculo, $n_motorista, $n_dias) {
|
||||
return ($motorista * $n_motorista) + $escritorio + $taxas + $impostos + ($pedagio * $n_dias) + ($valor_veiculo * 0.031);
|
||||
}
|
||||
|
||||
function custo_variavel($custo_onibus_val, $n_dias, $rota) {
|
||||
return $custo_onibus_val * $n_dias * $rota;
|
||||
}
|
||||
|
||||
// --- PROCESS BASE DATA ---
|
||||
|
||||
$custo_onibus_B = custo_onibus($diesel, $oleo, $pneu_novo, $pneu_recap, $pecas);
|
||||
$custo_fixo_B = custo_fixo($motorista, $escritorio, $taxas, $impostos, $pedagio, $valor_veiculo, $n_motorista, $n_dias);
|
||||
$custo_variavel_B = custo_variavel($custo_onibus_B, $n_dias, $rota);
|
||||
$custo_total_B = $custo_fixo_B + $custo_variavel_B;
|
||||
$valor_contrato_sugerido = $custo_total_B * 1.06;
|
||||
|
||||
$results = [
|
||||
'custo_por_km' => $custo_onibus_B,
|
||||
'custo_fixo_mensal' => $custo_fixo_B,
|
||||
'custo_variavel_mensal' => $custo_variavel_B,
|
||||
'custo_total_mensal' => $custo_total_B,
|
||||
'valor_contrato_sugerido' => $valor_contrato_sugerido,
|
||||
];
|
||||
|
||||
// --- RUN SIMULATION ---
|
||||
|
||||
if ($n_simulacoes > 0 && $valor_contrato_manual > 0) {
|
||||
$custos_simulados = [];
|
||||
$lucros_simulados = [];
|
||||
|
||||
for ($i = 0; $i < $n_simulacoes; $i++) {
|
||||
// Get random values for variables
|
||||
$diesel_sim = get_random_value($diesel, $variabilidade);
|
||||
$pecas_sim = get_random_value($pecas, $variabilidade);
|
||||
$rota_sim = get_random_value($rota, $variabilidade);
|
||||
|
||||
// Recalculate costs with simulated values
|
||||
$custo_onibus_sim = custo_onibus($diesel_sim, $oleo, $pneu_novo, $pneu_recap, $pecas_sim);
|
||||
$custo_variavel_sim = custo_variavel($custo_onibus_sim, $n_dias, $rota_sim);
|
||||
$custo_total_sim = $custo_fixo_B + $custo_variavel_sim; // Assuming fixed costs don't vary
|
||||
|
||||
$lucro_sim = $valor_contrato_manual - $custo_total_sim;
|
||||
|
||||
$custos_simulados[] = $custo_total_sim;
|
||||
$lucros_simulados[] = $lucro_sim;
|
||||
}
|
||||
|
||||
$simulation_results = [
|
||||
'ecdf_custo' => generate_ecdf_data($custos_simulados),
|
||||
'ecdf_lucro' => generate_ecdf_data($lucros_simulados),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
function format_currency($value) {
|
||||
return 'R$ ' . number_format($value, 2, ',', '.');
|
||||
}
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<!DOCTYPE html>
|
||||
<html lang="pt-BR">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
}
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.loader {
|
||||
margin: 1.25rem auto 1.25rem;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.hint {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin: 0 0 1rem;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
code {
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Análise de Custos de Veículo</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script src="https://unpkg.com/feather-icons"></script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your website…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
</div>
|
||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWiZZy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
|
||||
<header class="header">
|
||||
<h1>🚌 Análise de Custos de Veículo</h1>
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-7 mb-4">
|
||||
<div class="card">
|
||||
<h2 class="card-title"><i data-feather="edit"></i>Entrada de Dados</h2>
|
||||
<form action="/" method="POST">
|
||||
|
||||
<h5 class="mt-4 mb-3">Informações do Contrato e Veículo</h5>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="valor_veiculo" class="form-label">Valor do Veículo (R$)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="valor_veiculo" name="valor_veiculo" value="<?= $_POST['valor_veiculo'] ?? 500000 ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="duracao_contrato" class="form-label">Duração do Contrato (meses)</label>
|
||||
<input type="number" class="form-control" id="duracao_contrato" name="duracao_contrato" value="<?= $_POST['duracao_contrato'] ?? 12 ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="rota" class="form-label">Rota diária (km)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="rota" name="rota" value="<?= $_POST['rota'] ?? 100 ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="n_dias" class="form-label">Dias de operação por mês</label>
|
||||
<input type="number" class="form-control" id="n_dias" name="n_dias" value="<?= $_POST['n_dias'] ?? 22 ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h5 class="mt-4 mb-3">Custos de Operação (por KM)</h5>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="diesel" class="form-label">Preço do Diesel (R$/litro)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="diesel" name="diesel" value="<?= $_POST['diesel'] ?? 5.50 ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="oleo" class="form-label">Custo do Óleo (R$/troca)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="oleo" name="oleo" value="<?= $_POST['oleo'] ?? 500 ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="pecas" class="form-label">Custo de Peças (R$/km)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="pecas" name="pecas" value="<?= $_POST['pecas'] ?? 0.5 ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="pneu_novo" class="form-label">Preço Pneu Novo (R$)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="pneu_novo" name="pneu_novo" value="<?= $_POST['pneu_novo'] ?? 2000 ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="pneu_recap" class="form-label">Preço Pneu Recapado (R$)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="pneu_recap" name="pneu_recap" value="<?= $_POST['pneu_recap'] ?? 800 ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h5 class="mt-4 mb-3">Custos Fixos Mensais</h5>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="motorista" class="form-label">Salário do Motorista (R$)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="motorista" name="motorista" value="<?= $_POST['motorista'] ?? 3000 ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="n_motorista" class="form-label">Número de Motoristas</label>
|
||||
<input type="number" class="form-control" id="n_motorista" name="n_motorista" value="<?= $_POST['n_motorista'] ?? 2 ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="escritorio" class="form-label">Custo do Escritório (R$)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="escritorio" name="escritorio" value="<?= $_POST['escritorio'] ?? 5000 ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="taxas" class="form-label">Taxas (R$)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="taxas" name="taxas" value="<?= $_POST['taxas'] ?? 1000 ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="impostos" class="form-label">Impostos (R$)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="impostos" name="impostos" value="<?= $_POST['impostos'] ?? 2000 ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="pedagio" class="form-label">Pedágio (R$/dia)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="pedagio" name="pedagio" value="<?= $_POST['pedagio'] ?? 50 ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h5 class="mt-4 mb-3">Parâmetros da Simulação</h5>
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3">
|
||||
<label for="valor_contrato_manual" class="form-label">Valor Mensal do Contrato (R$)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="valor_contrato_manual" name="valor_contrato_manual" value="<?= $_POST['valor_contrato_manual'] ?? '' ?>" placeholder="Ex: 25000">
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label for="n_simulacoes" class="form-label">Número de Simulações</label>
|
||||
<input type="number" class="form-control" id="n_simulacoes" name="n_simulacoes" value="<?= $_POST['n_simulacoes'] ?? '' ?>" placeholder="Ex: 1000">
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label for="variabilidade" class="form-label">Variabilidade dos Custos (%)</label>
|
||||
<input type="number" step="0.1" class="form-control" id="variabilidade" name="variabilidade" value="<?= $_POST['variabilidade'] ?? '' ?>" placeholder="Ex: 10">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary w-100 mt-4">Calcular Custos e Simular</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-5 mb-4">
|
||||
<div class="card results-card">
|
||||
<h2 class="card-title"><i data-feather="bar-chart-2"></i>Resultados</h2>
|
||||
<?php if ($results): ?>
|
||||
<div class="result-item">
|
||||
<span>Custo por KM:</span>
|
||||
<span class="value"><?= format_currency($results['custo_por_km']) ?></span>
|
||||
</div>
|
||||
<div class="result-item">
|
||||
<span>Custo Fixo Mensal:</span>
|
||||
<span class="value"><?= format_currency($results['custo_fixo_mensal']) ?></span>
|
||||
</div>
|
||||
<div class="result-item">
|
||||
<span>Custo Variável Mensal:</span>
|
||||
<span class="value"><?= format_currency($results['custo_variavel_mensal']) ?></span>
|
||||
</div>
|
||||
<div class="result-item">
|
||||
<span>Custo Total Mensal:</span>
|
||||
<span class="value"><?= format_currency($results['custo_total_mensal']) ?></span>
|
||||
</div>
|
||||
<div class="total-value mt-3">
|
||||
<div class="result-item">
|
||||
<span><b>Valor Sugerido do Contrato:</b></span>
|
||||
<span class="value"><b><?= format_currency($results['valor_contrato_sugerido']) ?></b></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($simulation_results): ?>
|
||||
<hr class="my-4">
|
||||
<h4 class="mb-3">Análise de Simulação</h4>
|
||||
<div class="mb-4">
|
||||
<canvas id="ecdfCustoChart"></canvas>
|
||||
</div>
|
||||
<div>
|
||||
<canvas id="ecdfLucroChart"></canvas>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php else: ?>
|
||||
<h3 class="text-center text-muted d-flex align-items-center justify-content-center h-100">Preencha os dados para ver os resultados.</h3>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="text-center py-4">
|
||||
<p class="text-muted">© <?= date('Y') ?> Análise de Custos. Todos os direitos reservados.</p>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
feather.replace()
|
||||
</script>
|
||||
|
||||
<?php if ($simulation_results): ?>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const ecdfCustoData = <?= json_encode($simulation_results['ecdf_custo']) ?>;
|
||||
const ecdfLucroData = <?= json_encode($simulation_results['ecdf_lucro']) ?>;
|
||||
|
||||
const formatAsCurrency = (value) => new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(value);
|
||||
|
||||
const createEcdfChart = (ctx, data, label, color) => {
|
||||
new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
datasets: [{
|
||||
label: label,
|
||||
data: data,
|
||||
borderColor: color,
|
||||
backgroundColor: color + '33', // 33 = 20% opacity
|
||||
fill: true,
|
||||
pointRadius: 0,
|
||||
borderWidth: 2
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
scales: {
|
||||
x: {
|
||||
type: 'linear',
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Valor (R$)'
|
||||
},
|
||||
ticks: {
|
||||
callback: value => formatAsCurrency(value)
|
||||
}
|
||||
},
|
||||
y: {
|
||||
min: 0,
|
||||
max: 1,
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Probabilidade Acumulada'
|
||||
},
|
||||
ticks: {
|
||||
callback: value => (value * 100).toFixed(0) + '%'
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
tooltip: {
|
||||
callbacks: {
|
||||
title: function (context) {
|
||||
return 'Probabilidade: ' + (context[0].parsed.y * 100).toFixed(2) + '%';
|
||||
},
|
||||
label: function (context) {
|
||||
return 'Valor <= ' + formatAsCurrency(context.parsed.x);
|
||||
}
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
display: true,
|
||||
position: 'top'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const ctxCusto = document.getElementById('ecdfCustoChart').getContext('2d');
|
||||
createEcdfChart(ctxCusto, ecdfCustoData, 'ECDF Custo Total Mensal', '#E67E22');
|
||||
|
||||
const ctxLucro = document.getElementById('ecdfLucroChart').getContext('2d');
|
||||
createEcdfChart(ctxLucro, ecdfLucroData, 'ECDF Lucro do Contrato', '#2ECC71');
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user