initFrom = $initFrom;
}
/**
* Rendert den kompletten Business-Tree als HTML
*/
public function renderTree(array $businessUsers): string
{
if (empty($businessUsers)) {
return '
Keine Business-User gefunden.
';
}
$html = '';
foreach ($businessUsers as $businessUser) {
$html .= $this->renderUserItem($businessUser, 0);
}
$html .= ' ';
return $html;
}
/**
* Rendert parentlose User als HTML
*/
public function renderParentless(array $parentless): string
{
if (empty($parentless)) {
return 'Keine parentlosen User gefunden.
';
}
$html = '';
foreach ($parentless as $item) {
$html .= $this->renderParentlessItem($item);
}
return $html;
}
/**
* Rendert Sponsor-Information als HTML
*/
public function renderSponsor($sponsor): string
{
if (!$sponsor) {
return '' . __('team.no_sponsor_assigned') . '
';
}
return '' .
'' .
$this->renderUserInfo($sponsor, false, true) .
'
' .
' ';
}
/**
* Rendert einen einzelnen User-Item mit Hierarchie
*/
private function renderUserItem($item, int $deep): string
{
$childrenHtml = '';
if (isset($item->businessUserItems) && $item->businessUserItems) {
$childrenHtml = '';
foreach ($item->businessUserItems as $child) {
$childrenHtml .= $this->renderUserItem($child, $deep + 1);
}
$childrenHtml .= ' ';
}
return '' .
'' .
$this->renderUserCardWithDepth($item, $deep) .
'
' .
$childrenHtml .
' ';
}
/**
* Rendert parentlosen User-Item
*/
private function renderParentlessItem($item): string
{
return '' .
'' .
$this->renderUserInfo($item, true, false) .
'
' .
' ';
}
/**
* Rendert User-Card mit Tiefe-Anzeige
*/
private function renderUserCardWithDepth($item, int $deep): string
{
$depthBadge = '';
if ($deep > 0) {
$depthBadge = '';
}
return '';
}
/**
* Rendert die Basis-User-Informationen
*/
private function renderUserInfo($item, bool $showSponsor = false, bool $isSponsor = false): string
{
$statusClass = $item->active_account ? '' : 'text-muted';
$iconClass = $item->active_account ? 'text-primary' : 'text-danger';
$html = '';
// User Link
$html .= 'user_id . '" data-action="business-user-show" data-back="" ' .
'data-modal="modal-md" data-init_from="' . $this->initFrom . '" data-route="' . route('modal_load') . '">' .
' ' .
'' . e($item->first_name . ' ' . $item->last_name) . ' ' .
' ';
// Email
$html .= ' ' . e($item->email) . ' ';
// Optional: Geburtstag
if (isset($item->user_birthday) && $item->user_birthday) {
$html .= ' | ' . e($item->user_birthday);
}
// Optional: Telefon
if (isset($item->user_phone) && $item->user_phone) {
$html .= ' | ' . e($item->user_phone);
}
// Level Badge
$levelName = isset($item->user_level_name) ? TranslationHelper::transUserLevelName($item->user_level_name) : '';
$account = isset($item->m_account) ? $item->m_account : '';
$html .= ' ' . e($levelName . ' | ' . $account) . ' ';
// Details für aktive Accounts
if ($item->active_account) {
$html .= '';
$html .= $this->renderAccountDetails($item);
// Action Button (außer für Sponsor-Ansicht)
if (!$isSponsor && $this->shouldShowActionButton()) {
$html .= $this->renderActionButton($item->user_id);
}
$html .= ' ';
} else {
// Inaktive Accounts
$paymentDate = isset($item->payment_account_date) ? $item->payment_account_date : '';
$html .= '' . __('team.account_to') . ': ' . e($paymentDate) . ' ';
}
// Sponsor für parentlose User
if ($showSponsor && isset($item->m_sponsor_name)) {
$html .= ' ' . e($item->m_sponsor_name);
}
$html .= ' ';
return $html;
}
/**
* Rendert Account-Details (Punkte, Umsatz)
*/
private function renderAccountDetails($item): string
{
$totalPoints = isset($item->sales_volume_points_KP_sum) ? $item->sales_volume_points_KP_sum : 0;
$ePoints = isset($item->sales_volume_KP_points) ? $item->sales_volume_KP_points : 0;
$sPoints = isset($item->sales_volume_points_shop) ? $item->sales_volume_points_shop : 0;
$totalSum = isset($item->sales_volume_total_sum) ? $item->sales_volume_total_sum : 0;
$eSum = isset($item->sales_volume_total) ? $item->sales_volume_total : 0;
$sSum = isset($item->sales_volume_total_shop) ? $item->sales_volume_total_shop : 0;
return '' . __('team.total_points') . ': ' . $totalPoints . ' | ' .
__('team.e') . ': ' . $ePoints . ' | ' .
__('team.s') . ': ' . $sPoints . ' | ' .
__('team.net_turnover') . ': ' . formatNumber($totalSum) . ' € | ' .
__('team.e') . ': ' . formatNumber($eSum) . ' € | ' .
__('team.s') . ': ' . formatNumber($sSum) . ' €';
}
/**
* Rendert Action-Button für User-Details
*/
private function renderActionButton(int $userId): string
{
return ' | initFrom . '" ' .
'data-route="' . route('modal_load') . '">' .
' ' .
' ';
}
/**
* Prüft ob Action-Button angezeigt werden soll
*/
private function shouldShowActionButton(): bool
{
return ($this->initFrom === 'admin' && \Auth::user()->isAdmin()) ||
($this->initFrom === 'member');
}
/**
* Setzt den Kontext für die Darstellung
*/
public function setInitFrom(string $initFrom): self
{
$this->initFrom = $initFrom;
return $this;
}
}