m_level_id) {
return '-';
}
$qualKP = (int) $userBusiness->qual_kp;
$pointsSum = (int) $userBusiness->sales_volume_points_KP_sum;
$isQual = $pointsSum >= $qualKP;
$badgeClass = $isQual ? 'badge-outline-success' : 'badge-outline-danger';
return ' KU ' . $qualKP . '';
}
/**
* Generiert QualKP Badge für User
*/
public static function generateQualKPBadgeForUser(User $user, int $month, int $year): string
{
if (!$user->user_level) {
return '-';
}
$qualKP = (int) $user->user_level->qual_kp;
$pointsSum = (int) $user->getUserSalesVolumeBy($month, $year, 'sales_volume_points_KP_sum');
$isQual = $pointsSum >= $qualKP;
$badgeClass = $isQual ? 'badge-outline-success' : 'badge-outline-warning-dark';
return ' KU ' . $qualKP . '';
}
/**
* Generiert Sales Volume Display für UserBusiness
*/
public static function generateSalesVolumeDisplay(UserBusiness $userBusiness, string $type): string
{
if ($type === 'points') {
$total = (int) $userBusiness->sales_volume_points_KP_sum;
$individual = (int) $userBusiness->sales_volume_KP_points;
$shop = (int) $userBusiness->sales_volume_points_shop;
} else {
$total = (float) $userBusiness->sales_volume_total_sum;
$individual = (float) $userBusiness->sales_volume_total;
$shop = (float) $userBusiness->sales_volume_total_shop;
$suffix = ' €';
}
$totalFormatted = $type === 'points' ? $total : formatNumber($total);
$individualFormatted = $type === 'points' ? $individual : formatNumber($individual);
$shopFormatted = $type === 'points' ? $shop : formatNumber($shop);
$suffix = $type === 'points' ? '' : ' €';
return '
' . $totalFormatted . $suffix . '
' .
'E: ' . $individualFormatted . ' | S: ' . $shopFormatted . $suffix . '';
}
/**
* Generiert Sales Volume Display für User
*/
public static function generateSalesVolumeDisplayForUser(User $user, string $type, int $month, int $year): string
{
if ($type === 'points') {
$total = (int) $user->getUserSalesVolumeBy($month, $year, 'sales_volume_points_KP_sum');
$individual = (int) $user->getUserSalesVolumeBy($month, $year, 'sales_volume_KP_points');
$shop = (int) $user->getUserSalesVolumeBy($month, $year, 'sales_volume_points_shop');
} else {
$total = (float) $user->getUserSalesVolumeBy($month, $year, 'sales_volume_total_sum');
$individual = (float) $user->getUserSalesVolumeBy($month, $year, 'sales_volume_total');
$shop = (float) $user->getUserSalesVolumeBy($month, $year, 'sales_volume_total_shop');
}
$totalFormatted = $type === 'points' ? $total : formatNumber($total);
$individualFormatted = $type === 'points' ? $individual : formatNumber($individual);
$shopFormatted = $type === 'points' ? $shop : formatNumber($shop);
$suffix = $type === 'points' ? '' : ' €';
return '' . $totalFormatted . $suffix . '
' .
'E: ' . $individualFormatted . ' | S: ' . $shopFormatted . $suffix . '';
}
/**
* Generiert Action Buttons (mit XSS-Schutz)
*/
public static function generateActionButtons($userId): string
{
$userId = (int) $userId; // Sicherheit: Nur Integer
$html = '';
if (config('app.debug') === true) {
$html .= '';
}
return $html;
}
/**
* Generiert Sponsor Display für UserBusiness
*/
public static function generateSponsorDisplay(UserBusiness $userBusiness): string
{
if (!$userBusiness->sponsor || !$userBusiness->sponsor->is_sponsor) {
return '-';
}
$sponsor = $userBusiness->sponsor;
$html = e($sponsor->first_name . ' ' . $sponsor->last_name);
$html .= '
';
$html .= '' . e($sponsor->email);
$html .= ' | ' . e($sponsor->m_account);
$html .= '';
return $html;
}
/**
* Generiert Sponsor Display für User
*/
public static function generateSponsorDisplayForUser(User $user): string
{
if (!$user->user_sponsor) {
return '-';
}
$sponsor = $user->user_sponsor;
$html = '';
if ($sponsor->account) {
$html .= e($sponsor->account->first_name . ' ' . $sponsor->account->last_name);
$html .= '
';
}
$html .= '' . e($sponsor->email);
if ($sponsor->account) {
$html .= ' | ' . e($sponsor->account->m_account);
}
$html .= '';
return $html;
}
}