#51 Festschreiben der Points, Gutschriftenmodul
This commit is contained in:
parent
dfd049aaa9
commit
3f2fbd6d5b
63 changed files with 4610 additions and 971 deletions
|
|
@ -2,11 +2,13 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\BusinessPlan\TreeCalcBot;
|
||||
use Request;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\UserBusiness;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Models\UserBusinessStructure;
|
||||
use App\Services\BusinessPlan\TreeCalcBot;
|
||||
|
||||
|
||||
class BusinessController extends Controller
|
||||
|
|
@ -21,7 +23,6 @@ class BusinessController extends Controller
|
|||
public function show()
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::$months,
|
||||
'filter_years' => HTMLHelper::getYearRange(),
|
||||
|
|
@ -31,12 +32,15 @@ class BusinessController extends Controller
|
|||
return view('admin.business.show', $data);
|
||||
}
|
||||
|
||||
|
||||
public function structure()
|
||||
{
|
||||
$this->setFilterVars();
|
||||
$TreeCalcBot = new TreeCalcBot(session('business_user_filter_month'), session('business_user_filter_year'), 'admin');
|
||||
$TreeCalcBot->initMain();
|
||||
$this->month = session('business_user_filter_month');
|
||||
$this->year = session('business_user_filter_year');
|
||||
|
||||
$TreeCalcBot = new TreeCalcBot($this->month, $this->year, 'admin');
|
||||
$TreeCalcBot->initStructureAdmin();
|
||||
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::$months,
|
||||
'filter_years' => HTMLHelper::getYearRange(),
|
||||
|
|
@ -50,18 +54,31 @@ class BusinessController extends Controller
|
|||
$user = User::findOrFail($user_id);
|
||||
$this->setFilterVars();
|
||||
|
||||
$TreeCalcBot = new TreeCalcBot(session('business_user_filter_month'), session('business_user_filter_year'), 'admin');
|
||||
$TreeCalcBot->initDetailUser($user);
|
||||
if(!$TreeCalcBot->user){
|
||||
$data = [];
|
||||
$data['month'] = session('business_user_filter_month');
|
||||
$data['year'] = session('business_user_filter_year');
|
||||
|
||||
$TreeCalcBot = new TreeCalcBot($data['month'], $data['year'], 'admin');
|
||||
$TreeCalcBot->initBusinesslUserDetail($user);
|
||||
if(!$TreeCalcBot->business_user){
|
||||
abort(403, 'no user found');
|
||||
}
|
||||
$data = [
|
||||
'month' => HTMLHelper::getMonth(session('business_user_filter_month')),
|
||||
'year' => session('business_user_filter_year'),
|
||||
'TreeCalcBot' => $TreeCalcBot,
|
||||
'user' => $user,
|
||||
];
|
||||
return view('admin.business.user_detail', $data);
|
||||
return view('admin.business.user_detail', compact('TreeCalcBot', 'user', 'data'));
|
||||
}
|
||||
|
||||
public function userStore($user_id)
|
||||
{
|
||||
dd('function on: App\Console\Commands\BusinessStore');
|
||||
/*$data = Request::all();
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
$TreeCalcBot = new TreeCalcBot($data['month'], $data['year'], 'admin');
|
||||
$TreeCalcBot->initBusinesslUserDetail($user);
|
||||
if(!$TreeCalcBot->business_user){
|
||||
abort(403, 'no user found');
|
||||
}
|
||||
//$TreeCalcBot->storeBusinesslUser();*/
|
||||
|
||||
//return back();
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
|
|
@ -90,12 +107,123 @@ class BusinessController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
private function initSearch($archive = false, $request = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
public function userDatatable()
|
||||
{
|
||||
$this->month = Request::get('business_user_filter_month');
|
||||
$this->year = Request::get('business_user_filter_year');
|
||||
|
||||
//only the currently month get from Users -> older month from UserBusiness
|
||||
//return $this->userCurrentlyDatatable();
|
||||
if(TreeCalcBot::isFromStored($this->month, $this->year)){
|
||||
return $this->userStoredDatatable();
|
||||
}else{
|
||||
return $this->userCurrentlyDatatable();
|
||||
}
|
||||
}
|
||||
|
||||
private function initStoredSearch($archive = false, $request = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$query = UserBusiness::select('user_businesses.*')->where('month', $this->month)->where('year', $this->year);
|
||||
if(Request::get('business_user_filter_active')){
|
||||
if(Request::get('business_user_filter_active') == 1){
|
||||
$query->where('user_businesses.active_account', 1);
|
||||
}
|
||||
if(Request::get('business_user_filter_active') == 2){
|
||||
$query->where('user_businesses.active_account', 0);
|
||||
}
|
||||
if(Request::get('business_user_filter_active') == 3){
|
||||
//both -> payment_account only not null
|
||||
}
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
private function userStoredDatatable()
|
||||
{
|
||||
$query = $this->initStoredSearch();
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserBusiness $userBusiness) {
|
||||
return '<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$userBusiness->user_id.'"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button>';
|
||||
//.'<a href="' . route('admin_business_user_detail', [$userBusiness->user_id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-calculator"></span></a>';
|
||||
})
|
||||
->addColumn('m_account', function (UserBusiness $userBusiness) {
|
||||
return $userBusiness->m_account;
|
||||
})
|
||||
->addColumn('user_level', function (UserBusiness $userBusiness) {
|
||||
return $userBusiness->user_level_name;
|
||||
})
|
||||
->addColumn('is_qual_kp', function (UserBusiness $userBusiness) {
|
||||
if($userBusiness->m_level_id){
|
||||
$isQualKP = ($userBusiness->sales_volume_points_sum >= $userBusiness->qual_kp) ? true : false;
|
||||
return '<span class="badge '.($isQualKP ? 'badge-outline-success' : 'badge-outline-danger').'"> KD '.$userBusiness->qual_kp.'</span>';
|
||||
}
|
||||
return '-';
|
||||
})
|
||||
->addColumn('sales_volume_points', function (UserBusiness $userBusiness) {
|
||||
return '<div class="no-line-break">'.$userBusiness->sales_volume_points_sum.'</div>'.
|
||||
'<span class="small no-line-break">B: '.$userBusiness->sales_volume_points.' | S: '.$userBusiness->sales_volume_points_shop.'</span>';
|
||||
})
|
||||
->addColumn('sales_volume_total', function (UserBusiness $userBusiness) {
|
||||
return '<div class="no-line-break">'.formatNumber($userBusiness->sales_volume_total_sum).' €</div>'.
|
||||
'<span class="small no-line-break">B: '.formatNumber($userBusiness->sales_volume_total).' | S: '.formatNumber($userBusiness->sales_volume_total_shop).'</span>';
|
||||
})
|
||||
->addColumn('email', function (UserBusiness $userBusiness) {
|
||||
return $userBusiness->email;
|
||||
})
|
||||
->addColumn('first_name', function (UserBusiness $userBusiness) {
|
||||
return $userBusiness->first_name;
|
||||
})
|
||||
->addColumn('last_name', function (UserBusiness $userBusiness) {
|
||||
return $userBusiness->last_name;
|
||||
})
|
||||
->addColumn('sponsor', function (UserBusiness $userBusiness) {
|
||||
if($userBusiness->sponsor){
|
||||
$sponsor = "";
|
||||
if($userBusiness->sponsor->is_sponsor){
|
||||
$sponsor .= $userBusiness->sponsor->first_name." ".$userBusiness->sponsor->last_name;
|
||||
$sponsor .= " ".'<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$userBusiness->sponsor->user_id.'"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button><br>';
|
||||
|
||||
$sponsor .= '<span class="small no-line-break">'.$userBusiness->sponsor->email;
|
||||
$sponsor .= ' | '.$userBusiness->sponsor->m_account;
|
||||
$sponsor .= '</span>';
|
||||
}
|
||||
|
||||
return $sponsor;
|
||||
}
|
||||
return '-';
|
||||
})
|
||||
|
||||
->addColumn('active_account', function (UserBusiness $userBusiness) {
|
||||
return get_active_badge($userBusiness->active_account);
|
||||
})
|
||||
->addColumn('payment_account_date', function (UserBusiness $userBusiness) {
|
||||
return $userBusiness->active_date ? formatDate($userBusiness->active_date) : "-";
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('active_account', 'payment_account $1')
|
||||
->rawColumns(['id', 'is_qual_kp', 'sales_volume_points', 'sales_volume_total', 'sponsor', 'active_account'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
private function initCurrentlySearch($archive = false, $request = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$query = User::with('account')->select('users.*')
|
||||
->where('users.deleted_at', '=', null)
|
||||
->where('users.id', '!=', 1)
|
||||
|
|
@ -114,26 +242,12 @@ class BusinessController extends Controller
|
|||
//both -> payment_account only not null
|
||||
}
|
||||
}
|
||||
|
||||
if(Request::get('business_user_filter_name')){
|
||||
//$query->where('users.account.first_name', 'LIKE', '%'.Request::get('business_user_filter_name').'%');
|
||||
//$query->where('users.account.last_name', 'LIKE', '%'.Request::get('business_user_filter_name').'%');
|
||||
//$query->where('users.account.m_account', 'LIKE', '%'.Request::get('business_user_filter_name').'%');
|
||||
//$query->where('users.email', 'LIKE', '%'.Request::get('business_user_filter_name').'%');
|
||||
|
||||
}
|
||||
|
||||
//->orderBy('created_at', 'DESC');
|
||||
/* $query = FlexHour::leftJoin("flex_hour_items", function($join) {
|
||||
$join->on("flex_hour_items.flex_hour_id","=","flex_hours.id");
|
||||
$join->where("flex_hour_items.date","=", FlexHourItemBot::$date);
|
||||
})*/
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function userDatatable()
|
||||
{
|
||||
$query = $this->initSearch();
|
||||
|
||||
private function userCurrentlyDatatable()
|
||||
{
|
||||
$query = $this->initCurrentlySearch();
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (User $user) {
|
||||
return '<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
|
|
@ -142,25 +256,40 @@ class BusinessController extends Controller
|
|||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button>';
|
||||
//<a href="' . route('admin_business_user_detail', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-calculator"></span></a>
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button>'
|
||||
.'<a href="' . route('admin_business_user_detail', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-calculator"></span></a>';
|
||||
})
|
||||
->addColumn('m_account', function (User $user) {
|
||||
return $user->account ? $user->account->m_account : '';
|
||||
})
|
||||
->addColumn('user_level', function (User $user) {
|
||||
return $user->user_level ? $user->user_level->name : '';
|
||||
})
|
||||
->addColumn('active_account', function (User $user) {
|
||||
return get_active_badge($user->isActiveAccount());
|
||||
})
|
||||
->addColumn('payment_account_date', function (User $user) {
|
||||
return $user->payment_account ? $user->getPaymentAccountDateFormat(false) : "-";
|
||||
})
|
||||
->addColumn('sales_volume_points', function (User $user) {
|
||||
->addColumn('is_qual_kp', function (User $user) {
|
||||
if($user->user_level){
|
||||
$qual_kp = $user->user_level->qual_kp;
|
||||
$sales_volume_points_sum = $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_sum');
|
||||
$isQualKP = ($sales_volume_points_sum >= $qual_kp) ? true : false;
|
||||
return '<span class="badge '.($isQualKP ? 'badge-outline-success' : 'badge-outline-danger').'"> KD '.$qual_kp.'</span>';
|
||||
}
|
||||
return '-';
|
||||
})
|
||||
->addColumn('sales_volume_points', function (User $user) {
|
||||
return '<div class="no-line-break">'.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_sum').'</div>'.
|
||||
'<span class="small no-line-break">B: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points').' | S: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_shop').'</span>';
|
||||
})
|
||||
->addColumn('sales_volume_total', function (User $user) {
|
||||
return '<div class="no-line-break">'.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_sum').'</div>'.
|
||||
'<span class="small no-line-break">B: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total').' | S: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_shop').'</span>';
|
||||
return '<div class="no-line-break">'.formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_sum')).' €</div>'.
|
||||
'<span class="small no-line-break">B: '.formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total')).' | S: '.formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_shop')).'</span>';
|
||||
})
|
||||
->addColumn('email', function (User $user) {
|
||||
return $user->email;
|
||||
})
|
||||
->addColumn('first_name', function (User $user) {
|
||||
return $user->account ? $user->account->first_name : '';
|
||||
})
|
||||
->addColumn('last_name', function (User $user) {
|
||||
return $user->account ? $user->account->last_name : '';
|
||||
})
|
||||
->addColumn('sponsor', function (User $user) {
|
||||
if($user->user_sponsor){
|
||||
|
|
@ -175,7 +304,7 @@ class BusinessController extends Controller
|
|||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button><br>';
|
||||
}
|
||||
$sponsor .= '<span class="small no-line-break">'.$user->email;
|
||||
$sponsor .= '<span class="small no-line-break">'.$user->user_sponsor->email;
|
||||
if($user->user_sponsor->account){
|
||||
$sponsor .= ' | '.$user->user_sponsor->account->m_account;
|
||||
}
|
||||
|
|
@ -184,51 +313,17 @@ class BusinessController extends Controller
|
|||
return $sponsor;
|
||||
}
|
||||
return '-';
|
||||
|
||||
return '<div class="no-line-break">'.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_sum').'</div>'.
|
||||
'<span class="small no-line-break">B: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total').' | S: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_shop').'</span>';
|
||||
})
|
||||
|
||||
->addColumn('is_qual_kp', function (User $user) {
|
||||
if($user->user_level){
|
||||
$qual_kp = $user->user_level->qual_kp;
|
||||
$sales_volume_points_sum = $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_sum');
|
||||
$isQualKP = ($sales_volume_points_sum >= $qual_kp) ? true : false;
|
||||
return '<span class="badge '.($isQualKP ? 'badge-outline-success' : 'badge-outline-danger').'"> KD '.$qual_kp.'</span>';
|
||||
}
|
||||
return '-';
|
||||
->addColumn('active_account', function (User $user) {
|
||||
return get_active_badge($user->isActiveAccount());
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ->addColumn('sales_volume_points', function (User $user) {
|
||||
return $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points');
|
||||
->addColumn('payment_account_date', function (User $user) {
|
||||
return $user->payment_account ? $user->getPaymentAccountDateFormat(false) : "-";
|
||||
})
|
||||
->addColumn('sales_volume_points_shop', function (User $user) {
|
||||
return $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_shop');
|
||||
})
|
||||
->addColumn('sales_volume_points_sum', function (User $user) {
|
||||
return $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_sum');
|
||||
})
|
||||
->addColumn('sales_volume_total', function (User $user) {
|
||||
return $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total');
|
||||
})
|
||||
->addColumn('sales_volume_total_shop', function (User $user) {
|
||||
return $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_shop');
|
||||
})
|
||||
->addColumn('sales_volume_total_sum', function (User $user) {
|
||||
return $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_sum');
|
||||
})*/
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('m_account', 'm_account $1')
|
||||
->orderColumn('first_name', 'first_name $1')
|
||||
->orderColumn('last_name', 'last_name $1')
|
||||
->orderColumn('user_level', 'm_level $1')
|
||||
->orderColumn('active_account', 'payment_account $1')
|
||||
->rawColumns(['id', 'is_qual_kp', 'confirmed', 'sales_volume_points', 'sales_volume_total', 'sponsor', 'active', 'active_account'])
|
||||
->rawColumns(['id', 'is_qual_kp', 'sales_volume_points', 'sales_volume_total', 'sponsor', 'active_account'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue