pdf_a4.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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: #4b5563; font-size: 12px; background: #fff; }
  24. h1 { font-size: 18px; margin: 0 0 4px 0; color: #374151; }
  25. .muted { color: #9ca3af; }
  26. .row { display: block; }
  27. .card { border: 1px solid #e5e7eb; border-radius: 10px; padding: 10px 12px; margin: 10px 0; background: #fafafa; }
  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; color: #374151; }
  31. .badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-weight: 700; background: #f3f4f6; color: #4b5563; }
  32. .bar { height: 8px; background: #e0f2fe; border-radius: 999px; overflow: hidden; }
  33. .bar > span { display: block; height: 100%; background: #00BEF3; }
  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: 16px; padding: 14px 16px; background: #f0f9ff; border-radius: 8px; border-left: 4px solid #00BEF3; }
  46. .cta-title { font-weight: 700; font-size: 13px; color: #2F506D; margin-bottom: 4px; }
  47. .cta-desc { color: #6b7280; }
  48. .link { color: #2F506D; text-decoration: none; font-weight: 600; }
  49. .hr { border-top: 1px solid #e5e7eb; margin: 10px 0; }
  50. </style>
  51. </head>
  52. <body>
  53. <h1><?= $esc("Contrôle technique du process : " . $packTitle) ?></h1>
  54. <div class="muted small">
  55. Réalisé le : <?= $esc($date) ?> · Confiance du diagnostic : <?= $esc($confidenceLabel) ?>
  56. </div>
  57. <div class="card score">
  58. <div class="left">
  59. <div class="muted">Score global</div>
  60. <div class="big"><?= $esc((string)$score) ?>/100</div>
  61. <div class="badge"><?= $esc($level . " — " . $levelLabel) ?></div>
  62. </div>
  63. <div class="right">
  64. <div class="pillars">
  65. <?php foreach ($pillars as $p):
  66. $pScore = (int) ($p['score'] ?? 0);
  67. $pMax = (int) ($p['max'] ?? 20);
  68. $pct = $pMax > 0 ? (int) round(($pScore / $pMax) * 100) : 0;
  69. ?>
  70. <div class="pillar">
  71. <div class="top">
  72. <div class="name"><?= $esc((string) ($p['label'] ?? $p['id'] ?? '')) ?></div>
  73. <div class="val"><?= $esc((string)$pScore) ?>/<?= $esc((string)$pMax) ?></div>
  74. </div>
  75. <div class="bar"><span style="width: <?= $esc((string)$pct) ?>%"></span></div>
  76. </div>
  77. <?php endforeach; ?>
  78. </div>
  79. </div>
  80. </div>
  81. <div class="two">
  82. <div class="col">
  83. <div class="card">
  84. <strong>Top 3 risques probables</strong>
  85. <ol class="list">
  86. <?php foreach ($risks as $r): ?>
  87. <li>
  88. <strong><?= $esc((string) ($r['title'] ?? '')) ?></strong><br/>
  89. <span class="small"><?= $esc((string) ($r['what_happens'] ?? '')) ?></span>
  90. </li>
  91. <?php endforeach; ?>
  92. </ol>
  93. </div>
  94. </div>
  95. <div class="col">
  96. <div class="card">
  97. <strong>Actions prioritaires (30 jours)</strong>
  98. <ol class="list">
  99. <?php foreach ($wins as $w): ?>
  100. <li>
  101. <strong><?= $esc((string) ($w['title'] ?? '')) ?></strong><br/>
  102. <span class="small"><?= $esc((string) ($w['effect'] ?? '')) ?></span>
  103. </li>
  104. <?php endforeach; ?>
  105. </ol>
  106. </div>
  107. </div>
  108. </div>
  109. <div class="card">
  110. <strong>Coût caché estimé</strong>
  111. <div class="small muted">Estimation indicative, à valider par mesure réelle.</div>
  112. <div class="hr"></div>
  113. <?php if (is_array($cost)): ?>
  114. <div>Temps perdu estimé : <strong><?= $esc((string) ($cost['hours_per_month'] ?? '')) ?> h/mois</strong></div>
  115. <div>Estimation : <strong><?= $esc((string) ($cost['eur_per_month'] ?? '')) ?> €/mois</strong></div>
  116. <div class="small muted">Hypothèses : volume <?= $esc((string) ($cost['volume_per_month'] ?? '')) ?>/mois, coût horaire <?= $esc((string) ($cost['assumptions']['hourly_cost'] ?? '')) ?>€.</div>
  117. <?php else: ?>
  118. <div class="muted small">Non calculé (volume/cout horaire non renseignés).</div>
  119. <?php endif; ?>
  120. </div>
  121. <?php if ($bookingUrl !== ''): ?>
  122. <div class="cta">
  123. <div class="cta-title">Découvrir les opportunités suite à mon audit</div>
  124. <div class="cta-desc small">Entretien de 30 min offert avec un consultant — prioriser vos opportunités et définir votre plan d'action.</div>
  125. <div style="margin-top: 8px;">Réserver : <span class="link"><?= $esc($bookingUrl) ?></span></div>
  126. </div>
  127. <?php endif; ?>
  128. </body>
  129. </html>