36741-vm/ReportGenerator.php
Flatlogic Bot 12e97ab387 version1
2025-12-08 10:49:50 +00:00

133 lines
5.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
class ReportGenerator
{
private $answers;
private $score = 0;
private $recommendations = [];
public function __construct($answers)
{
$this->answers = $answers;
}
public function generate()
{
$this->calculateScore();
$this->generateRecommendations();
// For now, let's just return the data
return [
'score' => $this->score,
'recommendations' => $this->recommendations,
'answers' => $this->answers
];
}
private function calculateScore()
{
// Simple scoring logic - this can be made more complex
// We will just assign points for certain answers
$this->score = 0;
// Q4 - Main Goal
if (isset($this->answers['q4']) && in_array('⏱️ Zeit sparen durch Automatisierung', $this->answers['q4'])) {
$this->score += 20;
}
if (isset($this->answers['q4']) && in_array('🚀 Skalierung vorbereiten', $this->answers['q4'])) {
$this->score += 10;
}
// Q5 - Digital Maturity
if (isset($this->answers['q5'])) {
$this->score += (5 - intval($this->answers['q5'][0])) * 5; // Less digital = more potential = higher score
}
// Q8 - Weekly Admin Time
$admin_time_scores = ['⏱️ 0-5 Stunden' => 0, '⏰ 6-10 Stunden' => 10, '🕐 11-15 Stunden' => 20, '🕑 16-20 Stunden' => 30, '🕒 Über 20 Stunden' => 40];
if (isset($this->answers['q8']) && isset($admin_time_scores[$this->answers['q8'][0]])) {
$this->score += $admin_time_scores[$this->answers['q8'][0]];
}
// Q10 - Time Saving Goal
$saving_goal_scores = ['⏱️ 25 Stunden' => 5, '⏰ 610 Stunden' => 10, '🕐 1115 Stunden' => 15, '🕑 1620 Stunden' => 20, '🚀 Mehr als 20 Stunden' => 25];
if (isset($this->answers['q10']) && isset($saving_goal_scores[$this->answers['q10'][0]])){
$this->score += $saving_goal_scores[$this->answers['q10'][0]];
}
// Q12 - Technology Openness
if (isset($this->answers['q12'])) {
$this->score += intval($this->answers['q12'][0]) * 2; // More open = higher score
}
// Clamp score between 0 and 100
$this->score = max(0, min($this->score, 100));
}
private function generateRecommendations()
{
$this->recommendations = [];
if ($this->score >= 75) {
$this->recommendations[] = [
'title' => 'Ihr Automatisierungspotenzial ist SEHR HOCH!',
'text' => 'Ihre Antworten deuten auf ein enormes Potenzial für Effizienzsteigerung durch KI und Automatisierung hin. Sie sind bereit, die nächsten Schritte zu gehen und könnten schnell signifikante Ergebnisse sehen.',
'type' => 'high'
];
} elseif ($this->score >= 50) {
$this->recommendations[] = [
'title' => 'Ihr Automatisierungspotenzial ist HOCH.',
'text' => 'Sie haben bereits einige digitale Prozesse, aber es gibt noch viel Raum für Optimierung. Eine gezielte Automatisierungsstrategie könnte Ihnen helfen, wertvolle Zeit zu sparen und Ihr Geschäft zu skalieren.',
'type' => 'medium'
];
} else {
$this->recommendations[] = [
'title' => 'Guter Start, aber es gibt noch Potenzial.',
'text' => 'Ihre aktuellen Prozesse sind teilweise digitalisiert, aber es gibt noch viele Möglichkeiten, manuelle Aufgaben zu reduzieren. Fangen Sie mit kleinen, gezielten Automatisierungen an, um den größten Nutzen zu erzielen.',
'type' => 'low'
];
}
// Add recommendations based on specific answers
if (isset($this->answers['q6']) && in_array('📧 E-Mails & Nachrichten beantworten', $this->answers['q6'])) {
$this->recommendations[] = [
'title' => 'E-Mail Flut bändigen',
'text' => 'Ein KI-gestützter Assistent kann Ihre E-Mails vorsortieren, Standardanfragen automatisch beantworten und Ihnen helfen, den Überblick zu behalten.',
'type' => 'specific'
];
}
if (isset($this->answers['q9']) && in_array('🤖 Kundenservice (Chatbot, FAQ)', $this->answers['q9'])) {
$this->recommendations[] = [
'title' => 'Kundenservice automatisieren',
'text' => 'Ein Chatbot kann häufig gestellte Fragen rund um die Uhr beantworten und Anfragen an die richtigen Mitarbeiter weiterleiten, was Ihr Team entlastet.',
'type' => 'specific'
];
}
}
public function sendEmail($recipientEmail)
{
require_once __DIR__ . '/mail/MailService.php';
// Generate the HTML body
$htmlBody = $this->getHtmlEmailBody();
$textBody = strip_tags($htmlBody);
// Send the email
$subject = 'Ihr persönlicher KI-Fit Check Report';
return MailService::sendMail($recipientEmail, $subject, $htmlBody, $textBody);
}
private function getHtmlEmailBody()
{
// Make report data available to the template
$score = $this->score;
$recommendations = $this->recommendations;
$answers = $this->answers;
ob_start();
include __DIR__ . '/email_template.php';
return ob_get_clean();
}
}