pdf_a4.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /** @var array $data */
  3. $esc = static fn(string $s): string => htmlspecialchars($s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
  4. $result = $data['result'];
  5. $packTitle = $data['pack_title'] ?? 'Contrôle technique du process';
  6. $date = $data['date'] ?? date('Y-m-d');
  7. $bookingUrl = (string) ($data['booking_url'] ?? '');
  8. $score = (int) ($result['score_total'] ?? 0);
  9. $level = (string) ($result['level'] ?? '');
  10. $levelLabel = (string) ($result['level_label'] ?? '');
  11. $confidenceLabel = (string) ($result['confidence']['label'] ?? '');
  12. $pillars = (array) ($result['pillars'] ?? []);
  13. $risks = (array) ($result['risks_top3'] ?? []);
  14. $wins = (array) ($result['quick_wins_top5'] ?? []);
  15. $cost = $result['cost_hidden'] ?? null;
  16. ?>
  17. <!doctype html>
  18. <html lang="fr">
  19. <head>
  20. <meta charset="utf-8" />
  21. <style>
  22. @page { size: A4; margin: 18mm 16mm; }
  23. body { font-family: DejaVu Sans, Arial, sans-serif; color: #111827; font-size: 12px; }
  24. h1 { font-size: 18px; margin: 0 0 4px 0; }
  25. .muted { color: #6b7280; }
  26. .row { display: block; }
  27. .card { border: 1px solid #e5e7eb; border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
  28. .score { display: table; width: 100%; }
  29. .score .left, .score .right { display: table-cell; vertical-align: top; }
  30. .big { font-size: 28px; font-weight: 700; }
  31. .badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-weight: 700; background: #f3f4f6; }
  32. .bar { height: 8px; background: #f3f4f6; border-radius: 999px; overflow: hidden; }
  33. .bar > span { display: block; height: 100%; background: #111827; }
  34. .pillars { margin-top: 8px; }
  35. .pillar { margin: 7px 0; }
  36. .pillar .top { display: table; width: 100%; }
  37. .pillar .top .name, .pillar .top .val { display: table-cell; }
  38. .pillar .top .val { text-align: right; font-weight: 700; }
  39. .list { margin: 6px 0 0 0; padding: 0 0 0 14px; }
  40. .list li { margin: 4px 0; }
  41. .two { display: table; width: 100%; }
  42. .two .col { display: table-cell; width: 50%; vertical-align: top; padding-right: 8px; }
  43. .two .col:last-child { padding-right: 0; padding-left: 8px; }
  44. .small { font-size: 11px; }
  45. .cta { margin-top: 10px; }
  46. .link { color: #111827; text-decoration: none; }
  47. .hr { border-top: 1px solid #e5e7eb; margin: 10px 0; }
  48. </style>
  49. </head>
  50. <body>
  51. <h1><?= $esc("Contrôle technique du process : " . $packTitle) ?></h1>
  52. <div class="muted small">
  53. Réalisé le : <?= $esc($date) ?> · Confiance du diagnostic : <?= $esc($confidenceLabel) ?>
  54. </div>
  55. <div class="card score">
  56. <div class="left">
  57. <div class="muted">Score global</div>
  58. <div class="big"><?= $esc((string)$score) ?>/100</div>
  59. <div class="badge"><?= $esc($level . " — " . $levelLabel) ?></div>
  60. </div>
  61. <div class="right">
  62. <div class="pillars">
  63. <?php foreach ($pillars as $p):
  64. $pScore = (int) ($p['score'] ?? 0);
  65. $pMax = (int) ($p['max'] ?? 20);
  66. $pct = $pMax > 0 ? (int) round(($pScore / $pMax) * 100) : 0;
  67. ?>
  68. <div class="pillar">
  69. <div class="top">
  70. <div class="name"><?= $esc((string) ($p['label'] ?? $p['id'] ?? '')) ?></div>
  71. <div class="val"><?= $esc((string)$pScore) ?>/<?= $esc((string)$pMax) ?></div>
  72. </div>
  73. <div class="bar"><span style="width: <?= $esc((string)$pct) ?>%"></span></div>
  74. </div>
  75. <?php endforeach; ?>
  76. </div>
  77. </div>
  78. </div>
  79. <div class="two">
  80. <div class="col">
  81. <div class="card">
  82. <strong>Top 3 risques probables</strong>
  83. <ol class="list">
  84. <?php foreach ($risks as $r): ?>
  85. <li>
  86. <strong><?= $esc((string) ($r['title'] ?? '')) ?></strong><br/>
  87. <span class="small"><?= $esc((string) ($r['what_happens'] ?? '')) ?></span>
  88. </li>
  89. <?php endforeach; ?>
  90. </ol>
  91. </div>
  92. </div>
  93. <div class="col">
  94. <div class="card">
  95. <strong>Actions prioritaires (30 jours)</strong>
  96. <ol class="list">
  97. <?php foreach ($wins as $w): ?>
  98. <li>
  99. <strong><?= $esc((string) ($w['title'] ?? '')) ?></strong><br/>
  100. <span class="small"><?= $esc((string) ($w['effect'] ?? '')) ?></span>
  101. </li>
  102. <?php endforeach; ?>
  103. </ol>
  104. </div>
  105. </div>
  106. </div>
  107. <div class="card">
  108. <strong>Coût caché estimé</strong>
  109. <div class="small muted">Estimation indicative, à valider par mesure réelle.</div>
  110. <div class="hr"></div>
  111. <?php if (is_array($cost)): ?>
  112. <div>Temps perdu estimé : <strong><?= $esc((string) ($cost['hours_per_month'] ?? '')) ?> h/mois</strong></div>
  113. <div>Estimation : <strong><?= $esc((string) ($cost['eur_per_month'] ?? '')) ?> €/mois</strong></div>
  114. <div class="small muted">Hypothèses : volume <?= $esc((string) ($cost['volume_per_month'] ?? '')) ?>/mois, coût horaire <?= $esc((string) ($cost['assumptions']['hourly_cost'] ?? '')) ?>€.</div>
  115. <?php else: ?>
  116. <div class="muted small">Non calculé (volume/cout horaire non renseignés).</div>
  117. <?php endif; ?>
  118. </div>
  119. <?php if ($bookingUrl !== ''): ?>
  120. <div class="cta small">
  121. Prochain pas : Revue express 20 minutes — <span class="muted">valider le diagnostic, prioriser, décider du plan minimal.</span><br/>
  122. Lien : <span class="link"><?= $esc($bookingUrl) ?></span>
  123. </div>
  124. <?php endif; ?>
  125. </body>
  126. </html>