Updates to 03-2025
This commit is contained in:
parent
bfa3bb1df4
commit
9ae662f63e
243 changed files with 12580 additions and 12018 deletions
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\BusinessPlan;
|
||||
|
||||
use App\User;
|
||||
|
|
@ -15,7 +16,7 @@ class ExportBot
|
|||
public $user_list;
|
||||
|
||||
private $root_user;
|
||||
|
||||
|
||||
|
||||
public function __construct($init_from = 'member')
|
||||
{
|
||||
|
|
@ -23,26 +24,25 @@ class ExportBot
|
|||
$this->init_from = $init_from;
|
||||
}
|
||||
|
||||
public function initStructureUser(User $user, $order='list') //tree or list
|
||||
public function initStructureUser(User $user, $order = 'list') //tree or list
|
||||
{
|
||||
$line = 0;
|
||||
$this->order = $order;
|
||||
$this->root_user = $user;
|
||||
|
||||
if($this->order === 'tree'){
|
||||
$this->user_tree = $this->setUserValues($user, $line);
|
||||
$this->user_tree->childs = $this->readChildUsers($this->user_tree, $line+1);
|
||||
}
|
||||
if($this->order === 'list'){
|
||||
$this->user_list = $this->setUserValues($user, $line);
|
||||
$this->readChildUsers($this->user_list, $line+1);
|
||||
}
|
||||
|
||||
|
||||
if ($this->order === 'tree') {
|
||||
$this->user_tree = $this->setUserValues($user, $line);
|
||||
$this->user_tree->childs = $this->readChildUsers($this->user_tree, $line + 1);
|
||||
}
|
||||
if ($this->order === 'list') {
|
||||
$this->user_list = $this->setUserValues($user, $line);
|
||||
$this->readChildUsers($this->user_list, $line + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function readChildUsers($parent_user, $line){
|
||||
private function readChildUsers($parent_user, $line)
|
||||
{
|
||||
|
||||
$childUsers = [];
|
||||
$users = User::with('account')->select('users.*')
|
||||
|
|
@ -55,24 +55,25 @@ class ExportBot
|
|||
->where('users.active', "=", 1)
|
||||
->get();
|
||||
|
||||
if($users){
|
||||
foreach($users as $user){
|
||||
if ($users) {
|
||||
foreach ($users as $user) {
|
||||
$user_values = $this->setUserValues($user, $line);
|
||||
$childUsers[] = $user_values;
|
||||
if($this->order === 'list'){
|
||||
$childUsers[] = $user_values;
|
||||
if ($this->order === 'list') {
|
||||
$this->user_list->childs[] = $user_values;
|
||||
$this->readChildUsers($user_values, $line+1);
|
||||
}
|
||||
$this->readChildUsers($user_values, $line + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $childUsers;
|
||||
}
|
||||
|
||||
private function setUserValues(User $user, $line){
|
||||
private function setUserValues(User $user, $line)
|
||||
{
|
||||
|
||||
$sponsor_name = "";
|
||||
if($user->m_sponsor && $user->user_sponsor->account){
|
||||
$sponsor_name = $user->user_sponsor->account->m_first_name." ".$user->user_sponsor->account->m_last_name;
|
||||
if ($user->m_sponsor && $user->user_sponsor->account) {
|
||||
$sponsor_name = $user->user_sponsor->account->m_first_name . " " . $user->user_sponsor->account->m_last_name;
|
||||
}
|
||||
$obj = new stdClass();
|
||||
$obj->line = $line;
|
||||
|
|
@ -93,28 +94,28 @@ class ExportBot
|
|||
$obj->zipcode = $user->account->zipcode;
|
||||
$obj->city = $user->account->city;
|
||||
$obj->country_id = $user->account->country_id ? $user->account->country->getLocated() : "";
|
||||
$pre_phone = $user->account->pre_phone_id != "" ? $user->account->pre_phone->phone." " : "";
|
||||
$pre_mobil = $user->account->pre_mobil_id != "" ? $user->account->pre_mobil->phone." " : "";
|
||||
$obj->phone = $pre_phone.$user->account->phone;
|
||||
$obj->mobil = $pre_mobil.$user->account->mobil;
|
||||
$pre_phone = $user->account->pre_phone_id != "" ? $user->account->pre_phone->phone . " " : "";
|
||||
$pre_mobil = $user->account->pre_mobil_id != "" ? $user->account->pre_mobil->phone . " " : "";
|
||||
$obj->phone = $pre_phone . $user->account->phone;
|
||||
$obj->mobil = $pre_mobil . $user->account->mobil;
|
||||
$obj->birthday = $user->account->birthday;
|
||||
$obj->partner_since = $user->active_date ? $user->getActiveDateFormat(false) : "";
|
||||
|
||||
if($this->order === 'tree'){
|
||||
$obj->childs = $this->readChildUsers($obj, $line+1);
|
||||
if ($this->order === 'tree') {
|
||||
$obj->childs = $this->readChildUsers($obj, $line + 1);
|
||||
}
|
||||
if($this->order === 'list'){
|
||||
if ($this->order === 'list') {
|
||||
$obj->childs = [];
|
||||
}
|
||||
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getUser(){
|
||||
|
||||
|
||||
public function getUser()
|
||||
{
|
||||
return $this->root_user;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ class SalesPointsVolumeHelper
|
|||
line: nach reihenfolge sortiert,
|
||||
*/
|
||||
private static $business_users_line = [];
|
||||
|
||||
private static $totalcommission = [];
|
||||
private static $totalpoints = [];
|
||||
private static $cbot = null;
|
||||
|
||||
|
||||
|
|
@ -36,7 +37,6 @@ class SalesPointsVolumeHelper
|
|||
$deep = 0;
|
||||
$ret = "";
|
||||
foreach(self::$cbot->business_users as $business_user){
|
||||
|
||||
$ret .= self::addTableItemStructur($business_user, $deep);
|
||||
}
|
||||
return $ret;
|
||||
|
|
@ -68,7 +68,7 @@ class SalesPointsVolumeHelper
|
|||
<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><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>
|
||||
|
|
@ -84,10 +84,16 @@ class SalesPointsVolumeHelper
|
|||
self::addTableItemLine($business_user, $deep);
|
||||
}
|
||||
foreach(self::$business_users_line as $deep => $items){
|
||||
self::$totalcommission[$deep] = 0;
|
||||
self::$totalpoints[$deep] = 0;
|
||||
foreach($items as $item){
|
||||
$ret .= self::setTableHTMLItemLine($item, $deep);
|
||||
}
|
||||
if($deep > 0){
|
||||
$ret .= self::addTableHTMLTotalItemLine($deep, 'line');
|
||||
}
|
||||
}
|
||||
$ret .= self::addTableHTMLTotalItemLine($deep, 'end');
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
@ -100,6 +106,39 @@ class SalesPointsVolumeHelper
|
|||
}
|
||||
}
|
||||
}
|
||||
private static function addTableHTMLTotalItemLine($deep, $type){
|
||||
$points = 0;
|
||||
$commission = 0;
|
||||
if($type == 'end'){
|
||||
$pp = '<div class=" line-height-1 my-2 badge badge-outline-success text-dark font-weight-bolder">'.__('team.PP').'</div>';
|
||||
$style = ' style="background-color:#d7d700;"';
|
||||
$text = __('order.total');
|
||||
foreach(self::$totalpoints as $key => $value){
|
||||
$points += $value;
|
||||
$commission += self::$totalcommission[$key];
|
||||
}
|
||||
|
||||
}else{
|
||||
$pp = '<div class=" line-height-1 my-2 badge badge-outline-success text-dark font-weight-bolder">'.$deep.'. '.__('team.PP').'</div>';
|
||||
$style = 'style="background-color:#e5e4e4"';
|
||||
$text = __('order.sum');
|
||||
$points = self::$totalpoints[$deep];
|
||||
$commission = self::$totalcommission[$deep];
|
||||
}
|
||||
|
||||
|
||||
|
||||
$ret = '<tr '.$style.'>
|
||||
<td><div class="no-line-break">'.$pp.'</div></td>
|
||||
<td><b>'.$text.'</b></td>
|
||||
<td><div class="no-line-break"><b>'.formatNumber($points, 0).'</b></span></td>
|
||||
<td> </td>
|
||||
<td><div class="no-line-break"><b>'.formatNumber($commission, 2).' €</b></span></td>
|
||||
<td> </td>
|
||||
</tr>';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private static function setTableHTMLItemLine($item, $deep){
|
||||
|
||||
|
|
@ -111,6 +150,8 @@ class SalesPointsVolumeHelper
|
|||
$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;
|
||||
self::$totalcommission[$deep] += $commission;
|
||||
self::$totalpoints[$deep] += $points;
|
||||
}
|
||||
//
|
||||
/*
|
||||
|
|
@ -121,11 +162,12 @@ class SalesPointsVolumeHelper
|
|||
<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><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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue