08 2024
This commit is contained in:
parent
04d677d37a
commit
bfa3bb1df4
1191 changed files with 637397 additions and 10619 deletions
|
|
@ -7,6 +7,130 @@ use App\Models\UserSalesVolume;
|
|||
|
||||
class SalesPointsVolumeHelper
|
||||
{
|
||||
|
||||
|
||||
//protected static $business_users_table = [];
|
||||
/*
|
||||
$sort = 'structur' || 'line'
|
||||
structur: nach baumstruktur sortiert, wird übergeben
|
||||
line: nach reihenfolge sortiert,
|
||||
*/
|
||||
private static $business_users_line = [];
|
||||
|
||||
private static $cbot = null;
|
||||
|
||||
|
||||
public static function getBusinessUsersTable($cbot, $sort = 'structur'){
|
||||
|
||||
self::$cbot = $cbot;
|
||||
if($sort == 'structur'){
|
||||
return self::getBusinessUsersTableStructur();
|
||||
}
|
||||
if($sort == 'line'){
|
||||
return self::getBusinessUsersTableLine();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/* getBusinessUsersTableStructur */
|
||||
private static function getBusinessUsersTableStructur(){
|
||||
$deep = 0;
|
||||
$ret = "";
|
||||
foreach(self::$cbot->business_users as $business_user){
|
||||
|
||||
$ret .= self::addTableItemStructur($business_user, $deep);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private static function addTableItemStructur($item, $deep) {
|
||||
$ret = self::setTableHTMLItemStructur($item, $deep);
|
||||
if($item->businessUserItems){
|
||||
foreach($item->businessUserItems as $parent){
|
||||
$ret .= self::addTableItemStructur($parent, $deep+1);
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private static function setTableHTMLItemStructur($item, $deep){
|
||||
|
||||
$pp = '';
|
||||
$margin = 0;
|
||||
$points = $item->sales_volume_points_KP_sum;
|
||||
$commission = 0;
|
||||
if($deep > 0){
|
||||
$pp = str_repeat(' ', $deep-1).'<div class=" line-height-1 my-2 badge badge-outline-success text-dark font-weight-bolder">'.$deep.'. '.__('team.PP').'</div>';
|
||||
$margin = self::$cbot->getKeybyLine($deep, 'margin');
|
||||
$commission = $points / 100 * $margin;
|
||||
}
|
||||
|
||||
$ret = '<tr>
|
||||
<td><div class="no-line-break">'.$pp.'</div></td>
|
||||
<td><span class="mr-1 ion ion-ios-contact '.($item->active_account ? 'text-primary' : 'text-danger').'"></span>'.$item->first_name.' '.$item->last_name.'
|
||||
</td>
|
||||
<td><div class="no-line-break">'.formatNumber($points, 0).' €</span></td>
|
||||
<td>'.formatNumber($margin, 1).' %</td>
|
||||
<td><div class="no-line-break">'.formatNumber($commission, 2).' €</span></td>
|
||||
<td><span class="small">'.$item->user_level_name.'</span></td>
|
||||
</tr>';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private static function getBusinessUsersTableLine(){
|
||||
$deep = 0;
|
||||
$ret = "";
|
||||
foreach(self::$cbot->business_users as $business_user){
|
||||
self::addTableItemLine($business_user, $deep);
|
||||
}
|
||||
foreach(self::$business_users_line as $deep => $items){
|
||||
foreach($items as $item){
|
||||
$ret .= self::setTableHTMLItemLine($item, $deep);
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private static function addTableItemLine($item, $deep) {
|
||||
$item->deep = $deep;
|
||||
self::$business_users_line[$deep][] = $item;
|
||||
if($item->businessUserItems){
|
||||
foreach($item->businessUserItems as $parent){
|
||||
self::addTableItemLine($parent, $deep+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function setTableHTMLItemLine($item, $deep){
|
||||
|
||||
$pp = '';
|
||||
$margin = 0;
|
||||
$points = $item->sales_volume_points_KP_sum;
|
||||
$commission = 0;
|
||||
if($deep > 0){
|
||||
$pp = '<div class=" line-height-1 my-2 badge badge-outline-success text-dark font-weight-bolder">'.$deep.'. '.__('team.PP').'</div>';
|
||||
$margin = self::$cbot->getKeybyLine($deep, 'margin');
|
||||
$commission = $points / 100 * $margin;
|
||||
}
|
||||
//
|
||||
/*
|
||||
<th>{{__('tables.line')}}</th>
|
||||
<th>{{ __('shop.name') }}</th>
|
||||
<th>{{__('tables.points')}}</th>
|
||||
<th>{{__('tables.commission')}} %</th>
|
||||
<th>{{__('tables.commission')}} €</th>
|
||||
<th>{{ __('tables.level') }}</th>
|
||||
*/
|
||||
$ret = '<tr>
|
||||
<td><div class="no-line-break">'.$pp.'</div></td>
|
||||
<td><span class="mr-1 ion ion-ios-contact '.($item->active_account ? 'text-primary' : 'text-danger').'"></span>'.$item->first_name.' '.$item->last_name.'
|
||||
</td>
|
||||
<td><div class="no-line-break">'.formatNumber($points, 0).' €</span></td>
|
||||
<td>'.formatNumber($margin, 1).' %</td>
|
||||
<td><div class="no-line-break">'.formatNumber($commission, 2).' €</span></td>
|
||||
<td><span class="small">'.$item->user_level_name.'</span></td>
|
||||
</tr>';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue