update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
162
app/Http/Controllers/AdminUserController.php
Executable file → Normal file
162
app/Http/Controllers/AdminUserController.php
Executable file → Normal file
|
|
@ -26,7 +26,6 @@ class AdminUserController extends Controller
|
|||
{
|
||||
$this->middleware('superadmin');
|
||||
$this->userRepo = $userRepo;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -44,7 +43,7 @@ class AdminUserController extends Controller
|
|||
public function edit($user_id)
|
||||
{
|
||||
$user = User::findOrFail($user_id);
|
||||
if(!$user->account){
|
||||
if (!$user->account) {
|
||||
$user->account = new UserAccount();
|
||||
}
|
||||
|
||||
|
|
@ -52,8 +51,6 @@ class AdminUserController extends Controller
|
|||
'user' => $user,
|
||||
];
|
||||
return view('admin.user.edit', $data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -64,77 +61,77 @@ class AdminUserController extends Controller
|
|||
{
|
||||
$data = Request::all();
|
||||
$user = User::findOrFail($data['id']);
|
||||
|
||||
/* if(isset($data['user-delete'])){
|
||||
|
||||
/* if(isset($data['user-delete'])){
|
||||
if(isset($data['realy_delete_user'])){
|
||||
return redirect(route('admin_user_delete', [$user->id]));
|
||||
}
|
||||
}*/
|
||||
if(isset($data['save-admin'])){
|
||||
if (isset($data['save-admin'])) {
|
||||
$user->admin = $data['admin'];
|
||||
SysLog::action('save-admin', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user admin value: '.HTMLHelper::getLabel($user->admin))
|
||||
->setMessage('Set user admin value: ' . HTMLHelper::getLabel($user->admin))
|
||||
->save();
|
||||
}
|
||||
|
||||
if(isset($data['save-confirmed'])){
|
||||
if (isset($data['save-confirmed'])) {
|
||||
$data['confirmed'] = isset($data['confirmed']) ? true : false;
|
||||
$user->confirmed = $data['confirmed'];
|
||||
if($data['confirmed']){
|
||||
if(!isset($data['confirmation_date']) || $data['confirmation_date'] == ""){
|
||||
if ($data['confirmed']) {
|
||||
if (!isset($data['confirmation_date']) || $data['confirmation_date'] == "") {
|
||||
$user->confirmation_date = now();
|
||||
}else{
|
||||
} else {
|
||||
$user->confirmation_date = \Carbon::parse(str_replace("- ", "", $data['confirmation_date']));
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$user->confirmation_date = null;
|
||||
}
|
||||
SysLog::action('save-confirmed', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user confirmed value: '.$user->confirmed." to date: ".$data['confirmation_date'])
|
||||
->setMessage('Set user confirmed value: ' . $user->confirmed . " to date: " . $data['confirmation_date'])
|
||||
->save();
|
||||
}
|
||||
|
||||
if(isset($data['save-active'])){
|
||||
if (isset($data['save-active'])) {
|
||||
$data['active'] = isset($data['active']) ? true : false;
|
||||
$user->active = $data['active'];
|
||||
if($data['active'] === true && $user->wizard < 20){
|
||||
if ($data['active'] === true && $user->wizard < 20) {
|
||||
$user->wizard = 20;
|
||||
}
|
||||
if($data['active']){
|
||||
if(!isset($data['active_date']) || $data['active_date'] == ""){
|
||||
if ($data['active']) {
|
||||
if (!isset($data['active_date']) || $data['active_date'] == "") {
|
||||
$user->active_date = now();
|
||||
}else{
|
||||
} else {
|
||||
$user->active_date = \Carbon::parse(str_replace("- ", "", $data['active_date']));
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$user->active_date = null;
|
||||
}
|
||||
SysLog::action('save-active', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user active value: '.$user->active." to date: ".$data['active_date'])
|
||||
->setMessage('Set user active value: ' . $user->active . " to date: " . $data['active_date'])
|
||||
->save();
|
||||
}
|
||||
|
||||
if(isset($data['save-account'])){
|
||||
if (isset($data['save-account'])) {
|
||||
$old = $user->getPaymentAccountDateFormat(true);
|
||||
if(!isset($data['payment_account']) || $data['payment_account'] == ""){
|
||||
if (!isset($data['payment_account']) || $data['payment_account'] == "") {
|
||||
$user->payment_account = null;
|
||||
}else{
|
||||
} else {
|
||||
$user->wizard = 100;
|
||||
$payment_account = \Carbon::parse(str_replace("- ", "", $data['payment_account']));
|
||||
$user->payment_account = $payment_account;
|
||||
if($payment_account > Carbon::now()){
|
||||
if($user->active === 0){
|
||||
if ($payment_account > Carbon::now()) {
|
||||
if ($user->active === 0) {
|
||||
$user->active = true;
|
||||
UserUtil::reactiveUserResetChilds($user->id, 'on save-account AdminUserController');
|
||||
}
|
||||
}else{
|
||||
if($user->active === 1){
|
||||
} else {
|
||||
if ($user->active === 1) {
|
||||
$user->active = false;
|
||||
UserUtil::deactiveUserNewSponsorChilds($user->id, 'on save-account AdminUserController');
|
||||
}
|
||||
|
|
@ -144,40 +141,40 @@ class AdminUserController extends Controller
|
|||
SysLog::action('save-account', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user payment_account from date: '.$old." to date: ".$data['payment_account'])
|
||||
->setMessage('Set user payment_account from date: ' . $old . " to date: " . $data['payment_account'])
|
||||
->save();
|
||||
}
|
||||
|
||||
if(isset($data['save-shop'])){
|
||||
if (isset($data['save-shop'])) {
|
||||
$old = $user->getPaymentShopDateFormat(true);
|
||||
if(!isset($data['payment_shop']) || $data['payment_shop'] == ""){
|
||||
if (!isset($data['payment_shop']) || $data['payment_shop'] == "") {
|
||||
$user->payment_shop = null;
|
||||
}else{
|
||||
} else {
|
||||
$user->wizard = 100;
|
||||
$user->payment_shop = \Carbon::parse(str_replace("- ", "", $data['payment_shop']));
|
||||
}
|
||||
SysLog::action('save-shop', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user payment_shop from date: '.$old." to date: ".$data['payment_shop'])
|
||||
->setMessage('Set user payment_shop from date: ' . $old . " to date: " . $data['payment_shop'])
|
||||
->save();
|
||||
}
|
||||
|
||||
if(isset($data['save-test_mode'])){
|
||||
if (isset($data['save-test_mode'])) {
|
||||
$user->test_mode = isset($data['test_mode']) ? true : false;
|
||||
SysLog::action('save-test_mode', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user test_mode value: '.$user->test_mode)
|
||||
->setMessage('Set user test_mode value: ' . $user->test_mode)
|
||||
->save();
|
||||
}
|
||||
|
||||
if(isset($data['save-payment_methods'])){
|
||||
if (isset($data['save-payment_methods'])) {
|
||||
$user->payment_methods = isset($data['payment_methods']) ? array_map('intval', $data['payment_methods']) : null;
|
||||
SysLog::action('save-payment_methods', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user payment_methods value: '.$user->getPaymentMethodsShort())
|
||||
->setMessage('Set user payment_methods value: ' . $user->getPaymentMethodsShort())
|
||||
->save();
|
||||
}
|
||||
|
||||
|
|
@ -191,22 +188,22 @@ class AdminUserController extends Controller
|
|||
{
|
||||
$data = Request::all();
|
||||
$user = User::withTrashed()->findOrFail($data['id']);
|
||||
if(isset($data['realy_delete_user'])){
|
||||
if (isset($data['realy_delete_user'])) {
|
||||
$this->userRepo->deleteUser($user);
|
||||
\Session()->flash('alert-success', __('msg.contact_delete'));
|
||||
}
|
||||
if(isset($data['realy_delete_user_complete'])){
|
||||
// $this->userRepo->deleteUserComplete($user);
|
||||
$this->userRepo->deleteUser($user, true);
|
||||
\Session()->flash('alert-success', __('msg.contact_delete'));
|
||||
if (isset($data['realy_delete_user_complete'])) {
|
||||
// $this->userRepo->deleteUserComplete($user);
|
||||
$this->userRepo->deleteUser($user, true);
|
||||
\Session()->flash('alert-success', __('msg.contact_delete'));
|
||||
}
|
||||
return redirect('/admin/users');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function userLoginAs($userId){
|
||||
if(Auth::user()->isSuperAdmin()){
|
||||
public function userLoginAs($userId)
|
||||
{
|
||||
if (Auth::user()->isSuperAdmin()) {
|
||||
$user = User::find($userId);
|
||||
Auth::login($user);
|
||||
return redirect('/home');
|
||||
|
|
@ -216,12 +213,12 @@ class AdminUserController extends Controller
|
|||
public function getUsers()
|
||||
{
|
||||
$query = User::withTrashed()
|
||||
->where(function($q) {
|
||||
->where(function ($q) {
|
||||
$q->where('pre_deleted_at', '!=', null)
|
||||
->orWhere(function($query) {
|
||||
$query->whereNull('deleted_at')
|
||||
->orWhere(function ($query) {
|
||||
$query->whereNull('deleted_at')
|
||||
->whereNull('pre_deleted_at');
|
||||
});
|
||||
});
|
||||
})
|
||||
->with('account')
|
||||
->select('users.*')
|
||||
|
|
@ -232,8 +229,8 @@ class AdminUserController extends Controller
|
|||
return $user->account ? $user->account->first_name : '';
|
||||
})
|
||||
->addColumn('email', function (User $user) {
|
||||
if($user->pre_deleted_at){
|
||||
return '<span class="badge badge-pill badge-danger">'.$user->email.'</span>';
|
||||
if ($user->pre_deleted_at) {
|
||||
return '<span class="badge badge-pill badge-danger">' . $user->email . '</span>';
|
||||
}
|
||||
return $user->email;
|
||||
})
|
||||
|
|
@ -244,43 +241,46 @@ class AdminUserController extends Controller
|
|||
return '<a href="' . route('admin_lead_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('admin', function (User $user) {
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-admin" data-id="'.$user->id.'" data-email="'.$user->email.'" data-admin="'.$user->admin.'">'.HTMLHelper::getRoleLabel($user->admin).'</a>';
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-admin" data-id="' . $user->id . '" data-email="' . $user->email . '" data-admin="' . $user->admin . '">' . HTMLHelper::getRoleLabel($user->admin) . '</a>';
|
||||
})
|
||||
->addColumn('confirmed', function (User $user) {
|
||||
$date = $user->getConfirmationDateFormat();
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-confirmed" data-id="'.$user->id.'" data-email="'.$user->email.'" data-confirmed="'.$user->confirmed.'" data-confirmation_date="'.$date.'">';
|
||||
return $user->confirmed ? $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$date.'</span></a>' : $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-confirmed" data-id="' . $user->id . '" data-email="' . $user->email . '" data-confirmed="' . $user->confirmed . '" data-confirmation_date="' . $date . '">';
|
||||
return $user->confirmed ? $link . '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> ' . $date . '</span></a>' : $link . '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
})
|
||||
->addColumn('active', function (User $user) {
|
||||
$date = $user->getActiveDateFormat();
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-active" data-id="'.$user->id.'" data-email="'.$user->email.'" data-active="'.$user->active.'" data-active_date="'.$date.'">';
|
||||
return $user->active ? $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$date.'</span></a>' : $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-active" data-id="' . $user->id . '" data-email="' . $user->email . '" data-active="' . $user->active . '" data-active_date="' . $date . '">';
|
||||
return $user->active ? $link . '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> ' . $date . '</span></a>' : $link . '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
})
|
||||
->addColumn('account', function (User $user) {
|
||||
$date = $user->getPaymentAccountDateFormat();
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-account" data-id="'.$user->id.'" data-email="'.$user->email.'" data-payment_account="'.$date.'">';
|
||||
if($user->payment_account){
|
||||
if($user->isActiveAccount()){
|
||||
return $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$date.'</span></a>';
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-account" data-id="' . $user->id . '" data-email="' . $user->email . '" data-payment_account="' . $date . '">';
|
||||
if ($user->payment_account) {
|
||||
if ($user->isActiveAccount()) {
|
||||
return $link . '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> ' . $date . '</span></a>';
|
||||
}
|
||||
return $link.'<span class="badge badge-pill badge-warning"><i class="fa fa-ban"></i> '.$date.'</span></a>';
|
||||
return $link . '<span class="badge badge-pill badge-warning"><i class="fa fa-ban"></i> ' . $date . '</span></a>';
|
||||
}
|
||||
return $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
return $link . '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
})
|
||||
->addColumn('shop', function (User $user) {
|
||||
$date = $user->getPaymentShopDateFormat();
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-shop" data-id="'.$user->id.'" data-email="'.$user->email.'" data-payment_shop="'.$date.'">';
|
||||
if($user->payment_shop){
|
||||
if($user->isActiveShop()){
|
||||
return $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$date.'</span></a>';
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-shop" data-id="' . $user->id . '" data-email="' . $user->email . '" data-payment_shop="' . $date . '">';
|
||||
if ($user->payment_shop) {
|
||||
if ($user->isActiveShop()) {
|
||||
return $link . '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> ' . $date . '</span></a>';
|
||||
}
|
||||
return $link.'<span class="badge badge-pill badge-warning"><i class="fa fa-ban"></i> '.$date.'</span></a>';
|
||||
return $link . '<span class="badge badge-pill badge-warning"><i class="fa fa-ban"></i> ' . $date . '</span></a>';
|
||||
}
|
||||
return $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
return $link . '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
})
|
||||
->addColumn('shop_domain', function (User $user) {
|
||||
return $user->shop ? '<a href="' . $user->shop->getSubdomain(false) . '" target="_blank">' . $user->shop->getSubdomain(false) . '</a>' : '';
|
||||
})
|
||||
->addColumn('since', function (User $user) {
|
||||
if($user->shop){
|
||||
if($user->shop->active){
|
||||
if ($user->shop) {
|
||||
if ($user->shop->active) {
|
||||
return $user->shop->getActiveDateFormatSmall();
|
||||
}
|
||||
return $user->shop->getActiveDateFormatSmall();
|
||||
|
|
@ -292,23 +292,21 @@ class AdminUserController extends Controller
|
|||
})
|
||||
->addColumn('my_payment_methods', function (User $user) {
|
||||
$payment_methods = json_encode($user->payment_methods);
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-payment_methods" data-id="'.$user->id.'" data-email="'.$user->email.'" data-payment_methods="'.htmlspecialchars($payment_methods).'">';
|
||||
if(!$user->payment_methods){
|
||||
return $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-payment_methods" data-id="' . $user->id . '" data-email="' . $user->email . '" data-payment_methods="' . htmlspecialchars($payment_methods) . '">';
|
||||
if (!$user->payment_methods) {
|
||||
return $link . '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
}
|
||||
return $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$user->getPaymentMethodsShort().'</span></a>';
|
||||
|
||||
return $link . '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> ' . $user->getPaymentMethodsShort() . '</span></a>';
|
||||
})
|
||||
->addColumn('action_login', function (User $user) {
|
||||
return '<a href="' . route('admin_user_login_as', [$user->id]) . '" class="btn icon-btn btn-sm btn-warning" onclick="return confirm(\''.__('Login as User?').'\');"><span class="fa fa-sign-in-alt"></span></a>';
|
||||
return '<a href="' . route('admin_user_login_as', [$user->id]) . '" class="btn icon-btn btn-sm btn-warning" onclick="return confirm(\'' . __('Login as User?') . '\');"><span class="fa fa-sign-in-alt"></span></a>';
|
||||
})
|
||||
->addColumn('action_delete', function (User $user) {
|
||||
return '<a class="btn icon-btn btn-sm btn-danger" href="#" data-toggle="modal" data-target="#modals-user-delete" data-id="'.$user->id.'" data-email="'.$user->email.'"><span class="fa fa-trash"></span></a>';
|
||||
})
|
||||
return '<a class="btn icon-btn btn-sm btn-danger" href="#" data-toggle="modal" data-target="#modals-user-delete" data-id="' . $user->id . '" data-email="' . $user->email . '"><span class="fa fa-trash"></span></a>';
|
||||
})
|
||||
->addColumn('test_mode', function (User $user) {
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-test_mode" data-id="'.$user->id.'" data-email="'.$user->email.'" data-test_mode="'.$user->test_mode.'">';
|
||||
return $user->test_mode ? $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span></a>' : $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-test_mode" data-id="' . $user->id . '" data-email="' . $user->email . '" data-test_mode="' . $user->test_mode . '">';
|
||||
return $user->test_mode ? $link . '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span></a>' : $link . '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('email', 'email $1')
|
||||
|
|
@ -316,7 +314,7 @@ class AdminUserController extends Controller
|
|||
->orderColumn('active', 'active $1')
|
||||
->orderColumn('shop', 'shop $1')
|
||||
->orderColumn('admin', 'active $1')
|
||||
->rawColumns(['id', 'email', 'admin', 'confirmed', 'active', 'account', 'shop', 'my_payment_methods', 'test_mode', 'action_login', 'action_delete'])
|
||||
->rawColumns(['id', 'email', 'admin', 'confirmed', 'active', 'account', 'shop', 'shop_domain', 'my_payment_methods', 'test_mode', 'action_login', 'action_delete'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
app/Http/Controllers/Api/AuthController.php
Executable file → Normal file
0
app/Http/Controllers/Api/AuthController.php
Executable file → Normal file
0
app/Http/Controllers/Api/KasController.php
Executable file → Normal file
0
app/Http/Controllers/Api/KasController.php
Executable file → Normal file
0
app/Http/Controllers/Api/KasSLLController.php
Executable file → Normal file
0
app/Http/Controllers/Api/KasSLLController.php
Executable file → Normal file
0
app/Http/Controllers/Api/PayoneController.php
Executable file → Normal file
0
app/Http/Controllers/Api/PayoneController.php
Executable file → Normal file
0
app/Http/Controllers/Api/ShoppingUserController.php
Executable file → Normal file
0
app/Http/Controllers/Api/ShoppingUserController.php
Executable file → Normal file
0
app/Http/Controllers/AttributeController.php
Executable file → Normal file
0
app/Http/Controllers/AttributeController.php
Executable file → Normal file
0
app/Http/Controllers/Auth/ForgotPasswordController.php
Executable file → Normal file
0
app/Http/Controllers/Auth/ForgotPasswordController.php
Executable file → Normal file
0
app/Http/Controllers/Auth/LoginController.php
Executable file → Normal file
0
app/Http/Controllers/Auth/LoginController.php
Executable file → Normal file
0
app/Http/Controllers/Auth/RegisterController.php
Executable file → Normal file
0
app/Http/Controllers/Auth/RegisterController.php
Executable file → Normal file
0
app/Http/Controllers/Auth/ResetPasswordController.php
Executable file → Normal file
0
app/Http/Controllers/Auth/ResetPasswordController.php
Executable file → Normal file
|
|
@ -25,6 +25,7 @@ class BusinessController extends Controller
|
|||
|
||||
public function show()
|
||||
{
|
||||
abort(403, 'This page is removed');
|
||||
$this->setFilterVars();
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
|
|
@ -36,6 +37,7 @@ class BusinessController extends Controller
|
|||
|
||||
public function structure()
|
||||
{
|
||||
//abort(403, 'This page is removed');
|
||||
$this->setFilterVars();
|
||||
$this->month = session('business_user_filter_month');
|
||||
$this->year = session('business_user_filter_year');
|
||||
|
|
@ -53,6 +55,7 @@ class BusinessController extends Controller
|
|||
|
||||
public function userDetail($user_id)
|
||||
{
|
||||
abort(403, 'This page is removed');
|
||||
$user = User::findOrFail($user_id);
|
||||
$this->setFilterVars();
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class BusinessControllerOptimized extends Controller
|
|||
private $filter_next_level = [
|
||||
0 => 'Alle Status',
|
||||
1 => 'Qualifiziert (grün)',
|
||||
2 => 'In Arbeit (gelb)',
|
||||
2 => 'In Arbeit (gelb)',
|
||||
3 => 'Kein Level (rot)'
|
||||
];
|
||||
private $month;
|
||||
|
|
@ -49,7 +49,7 @@ class BusinessControllerOptimized extends Controller
|
|||
public function show()
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
'filter_years' => HTMLHelper::getYearRange(),
|
||||
|
|
@ -58,7 +58,7 @@ class BusinessControllerOptimized extends Controller
|
|||
'filter_next_level' => $this->filter_next_level,
|
||||
'optimized' => true, // Flag für View um zu zeigen, dass optimierte Version läuft
|
||||
];
|
||||
|
||||
|
||||
return view('admin.business_optimized.show', $data);
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ class BusinessControllerOptimized extends Controller
|
|||
{
|
||||
$startTime = microtime(true);
|
||||
$startMemory = memory_get_usage();
|
||||
|
||||
|
||||
try {
|
||||
$this->setFilterVars();
|
||||
$this->month = session('business_user_filter_month');
|
||||
|
|
@ -79,25 +79,26 @@ class BusinessControllerOptimized extends Controller
|
|||
|
||||
// Verwende optimierte TreeCalcBot-Version
|
||||
$TreeCalcBot = new TreeCalcBotOptimized($this->month, $this->year, 'admin');
|
||||
|
||||
|
||||
// Prüfe ob Live-Berechnung für Struktur erzwungen wird
|
||||
$forceLiveCalculation = Request::get('force_live_calculation', false) ||
|
||||
Request::get('force_live_structure', false) ||
|
||||
Request::get('live', false);
|
||||
|
||||
$forceLiveCalculation = Request::get('force_live_calculation', false) ||
|
||||
Request::get('force_live_structure', false) ||
|
||||
Request::get('live', false);
|
||||
|
||||
if ($forceLiveCalculation) {
|
||||
Log::info("BusinessControllerOptimized: Force live calculation requested");
|
||||
$TreeCalcBot->initStructureAdmin(true, $forceLiveCalculation); // check=true, forceLiveCalculation=true
|
||||
} else {
|
||||
Log::info("BusinessControllerOptimized: Force live calculation not requested");
|
||||
$TreeCalcBot->initStructureAdmin(); // Standard: verwende gespeicherte wenn verfügbar
|
||||
}
|
||||
|
||||
$endTime = microtime(true);
|
||||
$endMemory = memory_get_usage();
|
||||
|
||||
|
||||
$executionTime = round(($endTime - $startTime) * 1000, 2);
|
||||
$memoryUsed = $this->formatBytes($endMemory - $startMemory);
|
||||
|
||||
|
||||
$calculationType = $forceLiveCalculation ? " (LIVE)" : " (CACHE)";
|
||||
Log::info("BusinessControllerOptimized: Structure built in {$executionTime}ms, Memory: {$memoryUsed}{$calculationType}");
|
||||
|
||||
|
|
@ -115,12 +116,11 @@ class BusinessControllerOptimized extends Controller
|
|||
'optimized' => true,
|
||||
'forceLiveCalculation' => $forceLiveCalculation,
|
||||
];
|
||||
|
||||
|
||||
return view('admin.business_optimized.structure', $data);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("BusinessControllerOptimized: Error in structure: " . $e->getMessage());
|
||||
|
||||
|
||||
return view('admin.business_optimized.error', [
|
||||
'error' => $e->getMessage(),
|
||||
'month' => $this->month,
|
||||
|
|
@ -135,7 +135,7 @@ class BusinessControllerOptimized extends Controller
|
|||
public function userDetail($user_id)
|
||||
{
|
||||
$startTime = microtime(true);
|
||||
|
||||
|
||||
try {
|
||||
$user = User::with(['account', 'user_level', 'user_sponsor.account'])->findOrFail($user_id);
|
||||
$this->setFilterVars();
|
||||
|
|
@ -143,22 +143,22 @@ class BusinessControllerOptimized extends Controller
|
|||
$data = [];
|
||||
$data['month'] = session('business_user_filter_month');
|
||||
$data['year'] = session('business_user_filter_year');
|
||||
|
||||
|
||||
Log::info("BusinessControllerOptimized: Building user detail for user {$user_id}");
|
||||
|
||||
|
||||
$TreeCalcBot = new TreeCalcBotOptimized($data['month'], $data['year'], 'admin');
|
||||
|
||||
|
||||
// Prüfe ob Live-Berechnung über URL-Parameter erzwungen wird
|
||||
$forceLiveCalculation = Request::get('force_live_calculation', false) ||
|
||||
Request::get('force_live', false) ||
|
||||
Request::get('live', false);
|
||||
|
||||
$forceLiveCalculation = Request::get('force_live_calculation', false) ||
|
||||
Request::get('force_live', false) ||
|
||||
Request::get('live', false);
|
||||
|
||||
if ($forceLiveCalculation) {
|
||||
Log::info("BusinessControllerOptimized: Force live calculation requested for user {$user_id}");
|
||||
}
|
||||
|
||||
|
||||
$TreeCalcBot->initBusinesslUserDetail($user, $forceLiveCalculation);
|
||||
|
||||
|
||||
if (!$TreeCalcBot->__get('business_user')) {
|
||||
Log::warning("BusinessControllerOptimized: No business user found for {$user_id}");
|
||||
abort(403, 'No business user found');
|
||||
|
|
@ -166,23 +166,22 @@ class BusinessControllerOptimized extends Controller
|
|||
|
||||
$endTime = microtime(true);
|
||||
$executionTime = round(($endTime - $startTime) * 1000, 2);
|
||||
|
||||
|
||||
$data['performance'] = [
|
||||
'execution_time' => $executionTime,
|
||||
'user_id' => $user_id,
|
||||
'calculation_type' => $forceLiveCalculation ? 'Live' : 'Cache'
|
||||
];
|
||||
|
||||
|
||||
$data['forceLiveCalculation'] = $forceLiveCalculation;
|
||||
|
||||
|
||||
$calculationType = $forceLiveCalculation ? " (LIVE)" : " (CACHE)";
|
||||
Log::info("BusinessControllerOptimized: User detail built in {$executionTime}ms{$calculationType}");
|
||||
|
||||
|
||||
return view('admin.business_optimized.user_detail', compact('TreeCalcBot', 'user', 'data'));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("BusinessControllerOptimized: Error in userDetail for {$user_id}: " . $e->getMessage());
|
||||
|
||||
|
||||
return view('admin.business_optimized.error', [
|
||||
'error' => $e->getMessage(),
|
||||
'user_id' => $user_id
|
||||
|
|
@ -215,10 +214,9 @@ class BusinessControllerOptimized extends Controller
|
|||
} else {
|
||||
return $this->userCurrentlyDatatableOptimized();
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("BusinessControllerOptimized: Error in userDatatable: " . $e->getMessage());
|
||||
|
||||
|
||||
return response()->json([
|
||||
'error' => 'Datatable could not be loaded: ' . $e->getMessage()
|
||||
], 500);
|
||||
|
|
@ -231,7 +229,7 @@ class BusinessControllerOptimized extends Controller
|
|||
private function userStoredDatatableOptimized(): JsonResponse
|
||||
{
|
||||
$query = $this->initStoredSearchOptimized();
|
||||
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserBusiness $userBusiness) {
|
||||
return TreeHelperOptimized::generateActionButtons($userBusiness->user_id);
|
||||
|
|
@ -308,10 +306,10 @@ class BusinessControllerOptimized extends Controller
|
|||
private function userCurrentlyDatatableOptimized(): JsonResponse
|
||||
{
|
||||
$repository = new BusinessUserRepository($this->month, $this->year);
|
||||
|
||||
|
||||
// Nutze Repository für optimierte Abfragen
|
||||
$query = $this->initCurrentlySearchOptimized();
|
||||
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (User $user) {
|
||||
return TreeHelperOptimized::generateActionButtons($user->id);
|
||||
|
|
@ -352,11 +350,11 @@ class BusinessControllerOptimized extends Controller
|
|||
->where('month', $this->month)
|
||||
->where('year', $this->year)
|
||||
->first();
|
||||
|
||||
|
||||
if ($userBusiness) {
|
||||
return NextLevelBadgeHelper::generateBadgeFromUserBusiness($userBusiness);
|
||||
}
|
||||
|
||||
|
||||
return NextLevelBadgeHelper::renderNoDataBadge();
|
||||
})
|
||||
->addColumn('payment_account_date', function (User $user) {
|
||||
|
|
@ -364,28 +362,28 @@ class BusinessControllerOptimized extends Controller
|
|||
})
|
||||
->filterColumn('m_account', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("user_businesses.m_account LIKE ?", '%' . $keyword . '%');
|
||||
$query->whereRaw("user_accounts.m_account LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->filterColumn('first_name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("user_businesses.first_name LIKE ?", '%' . $keyword . '%');
|
||||
$query->whereRaw("user_accounts.first_name LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->filterColumn('last_name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("user_businesses.last_name LIKE ?", '%' . $keyword . '%');
|
||||
$query->whereRaw("user_accounts.last_name LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->filterColumn('email', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("user_businesses.email LIKE ?", '%' . $keyword . '%');
|
||||
$query->whereRaw("users.email LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->orderColumn('id', 'users.id $1')
|
||||
->orderColumn('m_account', 'user_accounts.m_account $1')
|
||||
->orderColumn('first_name', 'first_name $1')
|
||||
->orderColumn('last_name', 'last_name $1')
|
||||
->orderColumn('first_name', 'user_accounts.first_name $1')
|
||||
->orderColumn('last_name', 'user_accounts.last_name $1')
|
||||
->orderColumn('email', 'users.email $1')
|
||||
->orderColumn('active_account', 'users.payment_account $1')
|
||||
->rawColumns(['id', 'is_qual_kp', 'sales_volume_KP_points', 'sales_volume_total', 'sponsor', 'active_account', 'next_level_qualified'])
|
||||
|
|
@ -423,26 +421,26 @@ class BusinessControllerOptimized extends Controller
|
|||
switch ($nextLevelFilter) {
|
||||
case 1: // Qualifiziert (grün) - hat next_qual_user_level
|
||||
$query->whereNotNull('user_businesses.next_qual_user_level')
|
||||
->where('user_businesses.next_qual_user_level', '!=', '[]');
|
||||
->where('user_businesses.next_qual_user_level', '!=', '[]');
|
||||
break;
|
||||
case 2: // In Arbeit (gelb) - hat next_can_user_level aber kein next_qual_user_level
|
||||
$query->where(function($q) {
|
||||
$query->where(function ($q) {
|
||||
$q->whereNull('user_businesses.next_qual_user_level')
|
||||
->orWhere('user_businesses.next_qual_user_level', '=', '[]');
|
||||
->orWhere('user_businesses.next_qual_user_level', '=', '[]');
|
||||
})
|
||||
->whereNotNull('user_businesses.next_can_user_level')
|
||||
->where('user_businesses.next_can_user_level', '!=', '[]');
|
||||
->whereNotNull('user_businesses.next_can_user_level')
|
||||
->where('user_businesses.next_can_user_level', '!=', '[]');
|
||||
break;
|
||||
case 3: // Kein Level (rot) - hat weder next_qual noch next_can
|
||||
$query->where(function($q) {
|
||||
$q->where(function($q1) {
|
||||
$query->where(function ($q) {
|
||||
$q->where(function ($q1) {
|
||||
$q1->whereNull('user_businesses.next_qual_user_level')
|
||||
->orWhere('user_businesses.next_qual_user_level', '=', '[]');
|
||||
->orWhere('user_businesses.next_qual_user_level', '=', '[]');
|
||||
})
|
||||
->where(function($q2) {
|
||||
$q2->whereNull('user_businesses.next_can_user_level')
|
||||
->orWhere('user_businesses.next_can_user_level', '=', '[]');
|
||||
});
|
||||
->where(function ($q2) {
|
||||
$q2->whereNull('user_businesses.next_can_user_level')
|
||||
->orWhere('user_businesses.next_can_user_level', '=', '[]');
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
|
@ -563,15 +561,15 @@ class BusinessControllerOptimized extends Controller
|
|||
private function getFilterLevels(): array
|
||||
{
|
||||
$levels = [0 => 'Alle Level'];
|
||||
|
||||
|
||||
$userLevels = \App\Models\UserLevel::orderBy('pos')->get(['id', 'name']);
|
||||
foreach ($userLevels as $level) {
|
||||
$levels[$level->id] = $level->name;
|
||||
}
|
||||
|
||||
|
||||
return $levels;
|
||||
}
|
||||
|
||||
|
||||
// Performance-optimierte Badge-Generierung wurde in NextLevelBadgeHelper ausgelagert
|
||||
// Alte performance-lastige Methoden wurden entfernt um die Datatable-Performance zu verbessern
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
app/Http/Controllers/CategoryController.php
Executable file → Normal file
0
app/Http/Controllers/CategoryController.php
Executable file → Normal file
0
app/Http/Controllers/Controller.php
Executable file → Normal file
0
app/Http/Controllers/Controller.php
Executable file → Normal file
0
app/Http/Controllers/CountryController.php
Executable file → Normal file
0
app/Http/Controllers/CountryController.php
Executable file → Normal file
0
app/Http/Controllers/CustomerController.php
Executable file → Normal file
0
app/Http/Controllers/CustomerController.php
Executable file → Normal file
|
|
@ -11,16 +11,19 @@ use Acme\Dhl\Models\DhlShipment;
|
|||
use App\Models\ShoppingOrder;
|
||||
use App\Services\DhlModalService;
|
||||
use App\Services\DhlShipmentService;
|
||||
use App\Services\DhlTrackingService;
|
||||
use Exception;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
use ZipArchive;
|
||||
|
||||
// Import new DHL package and SettingController
|
||||
use Acme\Dhl\DhlManager;
|
||||
|
|
@ -141,11 +144,15 @@ class DhlShipmentController extends Controller
|
|||
if ($request->filled('search')) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('dhl_shipment_no', 'LIKE', "%{$search}%")
|
||||
->orWhere('id', 'LIKE', "%{$search}%")
|
||||
->orWhereHas('shoppingOrder', function ($orderQuery) use ($search) {
|
||||
$orderQuery->where('id', $search);
|
||||
});
|
||||
// Search in shipment fields
|
||||
$q->where('order_id', 'LIKE', "%{$search}%")
|
||||
->orWhere('dhl_shipment_no', 'LIKE', "%{$search}%")
|
||||
->orWhere('routing_code', 'LIKE', "%{$search}%")
|
||||
->orWhere('related_shipment_id', 'LIKE', "%{$search}%")
|
||||
->orWhere('billing_number', 'LIKE', "%{$search}%")
|
||||
->orWhere('firstname', 'LIKE', "%{$search}%")
|
||||
->orWhere('lastname', 'LIKE', "%{$search}%")
|
||||
->orWhere('company', 'LIKE', "%{$search}%");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -170,11 +177,7 @@ class DhlShipmentController extends Controller
|
|||
return '<span class="text-muted">N/A</span>';
|
||||
})
|
||||
->addColumn('customer', function ($shipment) {
|
||||
if ($shipment->shoppingOrder && $shipment->shoppingOrder->shopping_user) {
|
||||
return e($shipment->shoppingOrder->shopping_user->billing_firstname) . ' ' . e($shipment->shoppingOrder->shopping_user->billing_lastname) .
|
||||
'<br><small class="text-muted">' . e($shipment->shoppingOrder->shopping_user->billing_email) . '</small>';
|
||||
}
|
||||
return '<span class="text-muted">Unbekannt</span>';
|
||||
return $shipment->firstname . ' ' . $shipment->lastname;
|
||||
})
|
||||
->editColumn('dhl_shipment_no', function ($shipment) {
|
||||
return $shipment->dhl_shipment_no ? '<code class="text-success">' . e($shipment->dhl_shipment_no) . '</code>' : '<span class="text-muted">-</span>';
|
||||
|
|
@ -210,12 +213,14 @@ class DhlShipmentController extends Controller
|
|||
if ($shipment->label_path) {
|
||||
$buttons .= '<a href="' . route('admin.dhl.download-label', $shipment) . '" class="btn btn-sm btn-outline-success" data-toggle="tooltip" title="Label herunterladen"><i class="fas fa-download"></i></a>';
|
||||
}
|
||||
/* Todo: Add tracking button
|
||||
if ($shipment->canCancel()) {
|
||||
$buttons .= '<button type="button" class="btn btn-sm btn-outline-warning cancel-shipment-btn" data-shipment-id="' . $shipment->id . '" data-toggle="tooltip" title="Sendung stornieren"><i class="fas fa-ban"></i></button>';
|
||||
}
|
||||
if ($shipment->type == 'outbound' && !$shipment->returns()->count()) {
|
||||
$buttons .= '<button type="button" class="btn btn-sm btn-outline-info create-return-btn" data-shipment-id="' . $shipment->id . '" data-toggle="tooltip" title="Retourenlabel erstellen"><i class="fas fa-undo"></i></button>';
|
||||
}
|
||||
*/
|
||||
$buttons .= '</div>';
|
||||
return $buttons;
|
||||
})
|
||||
|
|
@ -465,27 +470,27 @@ class DhlShipmentController extends Controller
|
|||
public function updateTracking(DhlShipment $shipment): JsonResponse
|
||||
{
|
||||
try {
|
||||
if (!$shipment->tracking_number) {
|
||||
if (!$shipment->dhl_shipment_no) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Keine Tracking-Nummer verfügbar.'
|
||||
'message' => 'Keine DHL-Sendungsnummer verfügbar.'
|
||||
], 422);
|
||||
}
|
||||
|
||||
// Dispatch tracking update job
|
||||
TrackShipmentJob::dispatch($shipment, ['auto_retrack' => false]);
|
||||
// Use DhlTrackingService (handles queue/sync automatically based on config)
|
||||
$dhlTrackingService = new DhlTrackingService();
|
||||
$result = $dhlTrackingService->updateTracking($shipment, ['auto_retrack' => false]);
|
||||
|
||||
Log::info('[DHL Controller] Tracking update job dispatched', [
|
||||
Log::info('[DHL Controller] Tracking update processed', [
|
||||
'shipment_id' => $shipment->id,
|
||||
'tracking_number' => $shipment->tracking_number,
|
||||
'dhl_shipment_no' => $shipment->dhl_shipment_no,
|
||||
'queued' => $result['queued'] ?? false,
|
||||
'success' => $result['success'] ?? false,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Tracking-Informationen werden aktualisiert...'
|
||||
]);
|
||||
return response()->json($result);
|
||||
} catch (Exception $e) {
|
||||
Log::error('[DHL Controller] Failed to dispatch tracking update', [
|
||||
Log::error('[DHL Controller] Failed to process tracking update', [
|
||||
'error' => $e->getMessage(),
|
||||
'shipment_id' => $shipment->id,
|
||||
]);
|
||||
|
|
@ -511,11 +516,9 @@ class DhlShipmentController extends Controller
|
|||
}
|
||||
|
||||
$labelContent = Storage::get($shipment->label_path);
|
||||
$filename = sprintf(
|
||||
'dhl-label-%s-%s.pdf',
|
||||
$shipment->type,
|
||||
$shipment->shipment_number ?: $shipment->id
|
||||
);
|
||||
|
||||
// Generate descriptive filename
|
||||
$filename = $this->generateLabelFilename($shipment);
|
||||
|
||||
return response($labelContent, 200)
|
||||
->header('Content-Type', 'application/pdf')
|
||||
|
|
@ -531,13 +534,63 @@ class DhlShipmentController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate descriptive filename for DHL label
|
||||
* Format: DHL-Kundenname-Sendungsnummer-Datum.pdf
|
||||
* Example: DHL-Geraldine-Seebacher-0034043333301020015589177-15092025.pdf
|
||||
*
|
||||
* @param DhlShipment $shipment
|
||||
* @return string
|
||||
*/
|
||||
private function generateLabelFilename(DhlShipment $shipment): string
|
||||
{
|
||||
// Load order with customer data
|
||||
$customerName = $shipment->firstname . '_' . $shipment->lastname;
|
||||
if ($shipment->company) {
|
||||
$customerName = $shipment->company;
|
||||
}
|
||||
|
||||
// Clean customer name for filename (remove special characters)
|
||||
$customerName = preg_replace('/[^a-zA-Z0-9\-]/', '', $customerName);
|
||||
$customerName = preg_replace('/-+/', '-', $customerName); // Remove multiple dashes
|
||||
$customerName = trim($customerName, '-'); // Remove leading/trailing dashes
|
||||
|
||||
// Get shipment number
|
||||
$shipmentNumber = $shipment->dhl_shipment_no ?: $shipment->id;
|
||||
|
||||
// Get creation date
|
||||
$date = $shipment->created_at->format('d_m_Y');
|
||||
|
||||
// Build filename
|
||||
$filename = sprintf(
|
||||
'DHL-%s-%s-%s.pdf',
|
||||
$customerName,
|
||||
$shipmentNumber,
|
||||
$date
|
||||
);
|
||||
|
||||
// Ensure filename is not too long (max 255 characters)
|
||||
if (strlen($filename) > 255) {
|
||||
$maxCustomerLength = 255 - strlen('DHL--' . $shipmentNumber . '-' . $date . '.pdf');
|
||||
$customerName = substr($customerName, 0, max(10, $maxCustomerLength));
|
||||
$filename = sprintf(
|
||||
'DHL-%s-%s-%s.pdf',
|
||||
$customerName,
|
||||
$shipmentNumber,
|
||||
$date
|
||||
);
|
||||
}
|
||||
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch operations (multiple shipments)
|
||||
*
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @return JsonResponse|BinaryFileResponse
|
||||
*/
|
||||
public function batchAction(Request $request): JsonResponse
|
||||
public function batchAction(Request $request)
|
||||
{
|
||||
try {
|
||||
$request->validate([
|
||||
|
|
@ -550,6 +603,7 @@ class DhlShipmentController extends Controller
|
|||
$action = $request->action;
|
||||
$processed = 0;
|
||||
$errors = [];
|
||||
$labels = []; // For batch label download
|
||||
|
||||
foreach ($shipmentIds as $shipmentId) {
|
||||
try {
|
||||
|
|
@ -566,17 +620,31 @@ class DhlShipmentController extends Controller
|
|||
break;
|
||||
|
||||
case 'update_tracking':
|
||||
if ($shipment->tracking_number) {
|
||||
TrackShipmentJob::dispatch($shipment, ['auto_retrack' => false]);
|
||||
$processed++;
|
||||
if ($shipment->dhl_shipment_no) {
|
||||
$dhlTrackingService = new DhlTrackingService();
|
||||
$trackingResult = $dhlTrackingService->updateTracking($shipment, ['auto_retrack' => false]);
|
||||
|
||||
if ($trackingResult['success']) {
|
||||
$processed++;
|
||||
} else {
|
||||
$errors[] = "Sendung #{$shipment->id}: " . $trackingResult['message'];
|
||||
}
|
||||
} else {
|
||||
$errors[] = "Sendung {$shipment->shipment_number} hat keine Tracking-Nummer.";
|
||||
$errors[] = "Sendung #{$shipment->id} hat keine DHL-Sendungsnummer.";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'download_labels':
|
||||
// This would require ZIP creation - implement if needed
|
||||
$errors[] = "Stapel-Download noch nicht implementiert.";
|
||||
if ($shipment->label_path && Storage::exists($shipment->label_path)) {
|
||||
$labels[] = [
|
||||
'shipment' => $shipment,
|
||||
'filename' => $this->generateLabelFilename($shipment),
|
||||
'path' => $shipment->label_path
|
||||
];
|
||||
$processed++;
|
||||
} else {
|
||||
$errors[] = "Sendung #{$shipment->id} hat kein verfügbares Label.";
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
|
|
@ -584,6 +652,11 @@ class DhlShipmentController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
// Handle batch label download
|
||||
if ($action === 'download_labels' && !empty($labels)) {
|
||||
return $this->createLabelsZip($labels);
|
||||
}
|
||||
|
||||
Log::info('[DHL Controller] Batch action executed', [
|
||||
'action' => $action,
|
||||
'processed' => $processed,
|
||||
|
|
@ -623,7 +696,7 @@ class DhlShipmentController extends Controller
|
|||
]);
|
||||
|
||||
try {
|
||||
$shipment = DhlShipment::where('tracking_number', $request->tracking_number)->first();
|
||||
$shipment = DhlShipment::where('dhl_shipment_no', $request->tracking_number)->first();
|
||||
|
||||
if (!$shipment) {
|
||||
return response()->json([
|
||||
|
|
@ -632,13 +705,15 @@ class DhlShipmentController extends Controller
|
|||
], 404);
|
||||
}
|
||||
|
||||
// Dispatch tracking update
|
||||
TrackShipmentJob::dispatch($shipment, ['auto_retrack' => false]);
|
||||
// Use DhlTrackingService for tracking update
|
||||
$dhlTrackingService = new DhlTrackingService();
|
||||
$trackingResult = $dhlTrackingService->updateTracking($shipment, ['auto_retrack' => false]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'success' => $trackingResult['success'],
|
||||
'message' => $trackingResult['message'],
|
||||
'data' => [
|
||||
'tracking_number' => $shipment->tracking_number,
|
||||
'dhl_shipment_no' => $shipment->dhl_shipment_no,
|
||||
'status' => $shipment->status,
|
||||
'tracking_status' => $shipment->tracking_status,
|
||||
'last_tracked_at' => $shipment->last_tracked_at?->format('d.m.Y H:i'),
|
||||
|
|
@ -659,4 +734,65 @@ class DhlShipmentController extends Controller
|
|||
|
||||
return view('public.tracking');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create ZIP file with multiple labels
|
||||
*
|
||||
* @param array $labels Array of label data
|
||||
* @return Response|BinaryFileResponse
|
||||
*/
|
||||
private function createLabelsZip(array $labels)
|
||||
{
|
||||
try {
|
||||
$zip = new ZipArchive();
|
||||
$zipFilename = 'dhl_labels_' . date('Y-m-d_H-i-s') . '.zip';
|
||||
$zipPath = storage_path('app/temp/' . $zipFilename);
|
||||
|
||||
// Ensure temp directory exists
|
||||
if (!file_exists(storage_path('app/temp'))) {
|
||||
mkdir(storage_path('app/temp'), 0755, true);
|
||||
}
|
||||
|
||||
if ($zip->open($zipPath, ZipArchive::CREATE) !== TRUE) {
|
||||
throw new Exception('ZIP-Datei konnte nicht erstellt werden.');
|
||||
}
|
||||
|
||||
$addedFiles = 0;
|
||||
foreach ($labels as $labelData) {
|
||||
$shipment = $labelData['shipment'];
|
||||
$filename = $labelData['filename'];
|
||||
$filePath = $labelData['path'];
|
||||
|
||||
if (Storage::exists($filePath)) {
|
||||
$content = Storage::get($filePath);
|
||||
$zip->addFromString($filename, $content);
|
||||
$addedFiles++;
|
||||
}
|
||||
}
|
||||
|
||||
$zip->close();
|
||||
|
||||
if ($addedFiles === 0) {
|
||||
throw new Exception('Keine Labels konnten zur ZIP-Datei hinzugefügt werden.');
|
||||
}
|
||||
|
||||
Log::info('[DHL Controller] Labels ZIP created', [
|
||||
'zip_file' => $zipFilename,
|
||||
'files_count' => $addedFiles,
|
||||
'total_labels' => count($labels)
|
||||
]);
|
||||
|
||||
return response()->download($zipPath, $zipFilename)->deleteFileAfterSend(true);
|
||||
} catch (Exception $e) {
|
||||
Log::error('[DHL Controller] Failed to create labels ZIP', [
|
||||
'error' => $e->getMessage(),
|
||||
'labels_count' => count($labels)
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Fehler beim Erstellen der ZIP-Datei: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,33 +15,34 @@ class FileController extends Controller
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct() {}
|
||||
|
||||
private function isPermissionShoppingOrder($shopping_order)
|
||||
{
|
||||
}
|
||||
|
||||
private function isPermissionShoppingOrder($shopping_order){
|
||||
$user_id = $shopping_order->auth_user_id ? $shopping_order->auth_user_id : $shopping_order->member_id;
|
||||
if(Auth::user()->isAdmin() || $user_id == Auth::user()->id){
|
||||
if (Auth::user()->isAdmin() || $user_id == Auth::user()->id) {
|
||||
return true;
|
||||
}
|
||||
abort(404);
|
||||
abort(404);
|
||||
}
|
||||
|
||||
private function isPermissionUserCredit($user_credit){
|
||||
if(Auth::user()->isAdmin() || $user_credit->user_id == Auth::user()->id){
|
||||
private function isPermissionUserCredit($user_credit)
|
||||
{
|
||||
if (Auth::user()->isAdmin() || $user_credit->user_id == Auth::user()->id) {
|
||||
return true;
|
||||
}
|
||||
abort(404);
|
||||
abort(404);
|
||||
}
|
||||
|
||||
private function isPermissionAuth(){
|
||||
if(Auth::check()){
|
||||
private function isPermissionAuth()
|
||||
{
|
||||
if (Auth::check()) {
|
||||
return true;
|
||||
}
|
||||
abort(404);
|
||||
abort(403, "Nicht autorisiert");
|
||||
}
|
||||
|
||||
public function show($id = null, $from = null, $do='file')
|
||||
public function show($id = null, $from = null, $do = 'file')
|
||||
{
|
||||
|
||||
$path = "";
|
||||
|
|
@ -56,69 +57,68 @@ class FileController extends Controller
|
|||
return Response::file($path);
|
||||
}
|
||||
}*/
|
||||
if ($from === 'invoice'){
|
||||
if ($from === 'invoice') {
|
||||
$shopping_order = \App\Models\ShoppingOrder::findOrFail($id);
|
||||
if($shopping_order->user_invoice){
|
||||
if ($shopping_order->user_invoice) {
|
||||
$this->isPermissionShoppingOrder($shopping_order);
|
||||
$user_invoice = $shopping_order->user_invoice;
|
||||
$filename = $user_invoice->filename;
|
||||
$disk = $user_invoice->disk;
|
||||
$path = $user_invoice->getDownloadPath();
|
||||
$filename = $user_invoice->filename;
|
||||
$disk = $user_invoice->disk;
|
||||
$path = $user_invoice->getDownloadPath();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($from === 'delivery'){
|
||||
if ($from === 'delivery') {
|
||||
$shopping_order = \App\Models\ShoppingOrder::findOrFail($id);
|
||||
if($shopping_order->user_invoice){
|
||||
if ($shopping_order->user_invoice) {
|
||||
$this->isPermissionShoppingOrder($shopping_order);
|
||||
$user_invoice = $shopping_order->user_invoice;
|
||||
$filename = $user_invoice->delivery_filename;
|
||||
$disk = $user_invoice->disk;
|
||||
$filename = $user_invoice->delivery_filename;
|
||||
$disk = $user_invoice->disk;
|
||||
$path = $user_invoice->getDownloadPathDelivery();
|
||||
}
|
||||
}
|
||||
|
||||
if ($from === 'credit'){
|
||||
if ($from === 'credit') {
|
||||
$user_credit = \App\Models\UserCredit::findOrFail($id);
|
||||
$this->isPermissionUserCredit($user_credit);
|
||||
$filename = $user_credit->filename;
|
||||
$disk = $user_credit->disk;
|
||||
$filename = $user_credit->filename;
|
||||
$disk = $user_credit->disk;
|
||||
$path = $user_credit->getDownloadPath();
|
||||
}
|
||||
|
||||
if ($from === 'credit_detail'){
|
||||
if ($from === 'credit_detail') {
|
||||
$user_credit = \App\Models\UserCredit::findOrFail($id);
|
||||
$this->isPermissionUserCredit($user_credit);
|
||||
|
||||
|
||||
return $this->create_credit_detail($user_credit, $do);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
$filename = $user_credit->filename;
|
||||
$disk = $user_credit->disk;
|
||||
$path = $user_credit->getDownloadPath();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
if ($from === 'dc_file'){
|
||||
$this->isPermissionAuth();
|
||||
|
||||
if ($from === 'dc_file') {
|
||||
// $this->isPermissionAuth();
|
||||
$dc_file = \App\Models\DcFile::findOrFail($id);
|
||||
$filename = $dc_file->filename;
|
||||
$disk = 'public';
|
||||
$path = $dc_file->getFile();
|
||||
}
|
||||
if ($from === 'dc_thumb'){
|
||||
$this->isPermissionAuth();
|
||||
if ($from === 'dc_thumb') {
|
||||
// $this->isPermissionAuth();
|
||||
$dc_file = \App\Models\DcFile::findOrFail($id);
|
||||
$filename = $dc_file->filename;
|
||||
$disk = 'public';
|
||||
$path = $dc_file->getThumb();
|
||||
}
|
||||
|
||||
if ($from === 'dc_big'){
|
||||
$this->isPermissionAuth();
|
||||
if ($from === 'dc_big') {
|
||||
// $this->isPermissionAuth();
|
||||
$dc_file = \App\Models\DcFile::findOrFail($id);
|
||||
$filename = $dc_file->filename;
|
||||
$disk = 'public';
|
||||
|
|
@ -127,7 +127,7 @@ class FileController extends Controller
|
|||
|
||||
|
||||
|
||||
if(!Storage::disk($disk)->exists($path)){
|
||||
if (!Storage::disk($disk)->exists($path)) {
|
||||
return Response::make('Datei nicht gefunden.', 404);
|
||||
}
|
||||
|
||||
|
|
@ -138,40 +138,41 @@ class FileController extends Controller
|
|||
$file = Storage::disk($disk)->get($path);
|
||||
$mime = Storage::disk($disk)->mimeType($path);
|
||||
|
||||
if(isset($file)){
|
||||
if($do === 'stream'){
|
||||
if (isset($file)) {
|
||||
if ($do === 'stream') {
|
||||
return Storage::disk($disk)->response($path, $filename);
|
||||
}
|
||||
|
||||
if($do === 'file'){
|
||||
if ($do === 'file') {
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header("Content-Length", strlen($file))
|
||||
->header('Content-disposition', 'filename="'.$filename.'"');
|
||||
->header('Content-disposition', 'filename="' . $filename . '"');
|
||||
}
|
||||
if($do === 'image'){
|
||||
if ($do === 'image') {
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime);
|
||||
}
|
||||
if($do === 'pdf'){
|
||||
$path = storage_path().'/app/public/' . $path;
|
||||
if ($do === 'pdf') {
|
||||
$path = storage_path() . '/app/public/' . $path;
|
||||
|
||||
$headers = array(
|
||||
'Content-Type:'. $mime,
|
||||
// 'Content-Length: ' . $file->size
|
||||
// 'Content-Disposition: ' . $stream . '; filename=' . $file->original_name
|
||||
);
|
||||
|
||||
return Response::download($path, $filename, $headers);
|
||||
'Content-Type:' . $mime,
|
||||
// 'Content-Length: ' . $file->size
|
||||
// 'Content-Disposition: ' . $stream . '; filename=' . $file->original_name
|
||||
);
|
||||
|
||||
return Response::download($path, $filename, $headers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function create_credit_detail(UserCredit $user_credit, $do){
|
||||
private function create_credit_detail(UserCredit $user_credit, $do)
|
||||
{
|
||||
|
||||
$credit_repo = new CreditRepository($user_credit->user);
|
||||
return $credit_repo->create_report($user_credit, $do);
|
||||
//\Session()->flash('alert-success', "Gutschrift erstellt");
|
||||
|
||||
$credit_repo = new CreditRepository($user_credit->user);
|
||||
return $credit_repo->create_report($user_credit, $do);
|
||||
//\Session()->flash('alert-success', "Gutschrift erstellt");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
117
app/Http/Controllers/HomeController.php
Executable file → Normal file
117
app/Http/Controllers/HomeController.php
Executable file → Normal file
|
|
@ -4,7 +4,7 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Carbon\Carbon;
|
||||
use Config;
|
||||
use Request;
|
||||
|
|
@ -17,26 +17,23 @@ class HomeController extends Controller
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
public function __construct() {}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
if(!Auth::check()){
|
||||
if (!Auth::check()) {
|
||||
return redirect('login');
|
||||
}
|
||||
return redirect('home');
|
||||
|
||||
}
|
||||
|
||||
//login / Dashboard
|
||||
public function show()
|
||||
{
|
||||
|
||||
if(!Auth::check()){
|
||||
return redirect('login');
|
||||
|
||||
if (!Auth::check()) {
|
||||
return redirect('login');
|
||||
}
|
||||
|
||||
$data = [
|
||||
|
|
@ -47,12 +44,13 @@ class HomeController extends Controller
|
|||
}
|
||||
|
||||
|
||||
public function loadingModal(){
|
||||
public function loadingModal()
|
||||
{
|
||||
|
||||
$data = Request::get('data');
|
||||
$target = Request::get('target');
|
||||
$response = "";
|
||||
if($data === "data_protection"){
|
||||
if ($data === "data_protection") {
|
||||
$data = [
|
||||
'modal' => true,
|
||||
'user_shop' => true,
|
||||
|
|
@ -60,34 +58,34 @@ class HomeController extends Controller
|
|||
];
|
||||
$response = view('legal.data_protect_de', $data)->render();
|
||||
}
|
||||
if($data === "imprint"){
|
||||
if ($data === "imprint") {
|
||||
$data = [
|
||||
'modal' => true,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
];
|
||||
$response = view('legal.imprint_de', $data)->render();
|
||||
}
|
||||
if($data === "shop_term_of_use"){
|
||||
if ($data === "shop_term_of_use") {
|
||||
$data = [
|
||||
'modal' => true,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
];
|
||||
$response = view('legal.shop_term_of_use_de', $data)->render();
|
||||
}
|
||||
if($data === "agb"){
|
||||
if ($data === "agb") {
|
||||
$data = [
|
||||
'modal' => true,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
];
|
||||
$response = view('legal.agb_de', $data)->render();
|
||||
}
|
||||
if(Request::ajax()) {
|
||||
return response()->json(['response' => $response, 'target'=>$target]);
|
||||
if (Request::ajax()) {
|
||||
return response()->json(['response' => $response, 'target' => $target]);
|
||||
}
|
||||
abort(404);
|
||||
}
|
||||
|
||||
/* public function checkLogin($identify, $token)
|
||||
/* public function checkLogin($identify, $token)
|
||||
{
|
||||
if($identify){
|
||||
//user find by $identify
|
||||
|
|
@ -129,7 +127,8 @@ class HomeController extends Controller
|
|||
return abort(404);
|
||||
}
|
||||
*/
|
||||
public function zahlungsarten(){
|
||||
public function zahlungsarten()
|
||||
{
|
||||
return view('web.templates.zahlungsarten', [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'isMivitaShop' => Util::isMivitaShop(),
|
||||
|
|
@ -137,7 +136,8 @@ class HomeController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
public function versandkosten(){
|
||||
public function versandkosten()
|
||||
{
|
||||
return view('web.templates.versandkosten', [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'isMivitaShop' => Util::isMivitaShop(),
|
||||
|
|
@ -170,7 +170,7 @@ class HomeController extends Controller
|
|||
|
||||
public function legalImprint()
|
||||
{
|
||||
|
||||
|
||||
$data = [
|
||||
'modal' => false,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
|
|
@ -179,44 +179,51 @@ class HomeController extends Controller
|
|||
return view('legal.imprint', $data);
|
||||
}
|
||||
|
||||
public function verify($confirmation_code){
|
||||
if( ! $confirmation_code)
|
||||
{
|
||||
public function verify($confirmation_code)
|
||||
{
|
||||
if (! $confirmation_code) {
|
||||
return redirect('/status/error');
|
||||
}
|
||||
|
||||
$user = User::whereConfirmationCode($confirmation_code)->first();
|
||||
|
||||
if ( ! $user)
|
||||
{
|
||||
return redirect('/status/not/found');
|
||||
if (! $user) {
|
||||
return redirect('/status/not/found');
|
||||
}
|
||||
if($user->confirmed === 0){
|
||||
$user_auto_login = false;
|
||||
if ($user->confirmed === 0) {
|
||||
$user->confirmed = 1;
|
||||
$user->confirmation_date = now();
|
||||
$user_auto_login = true;
|
||||
//nur bei der ersten Verifizierung den user auto login
|
||||
}
|
||||
|
||||
// $user->confirmation_code = null;
|
||||
// $user->confirmation_code_to = null;
|
||||
// $user->confirmation_code_remider = 0;
|
||||
//wird nun in WizardController::releaseAccount() auf null gesetzt
|
||||
//$user->confirmation_code = null;
|
||||
//$user->confirmation_code_to = null;
|
||||
//$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
|
||||
//Login!
|
||||
Auth::login($user);
|
||||
|
||||
return redirect('/home');
|
||||
if ($user_auto_login) {
|
||||
Auth::login($user);
|
||||
}
|
||||
$url = Util::getMyMivitaUrl();
|
||||
return redirect($url);
|
||||
}
|
||||
|
||||
public function statusRegister(){
|
||||
public function statusRegister()
|
||||
{
|
||||
return view('status.status_register');
|
||||
}
|
||||
public function statusVerify(){
|
||||
public function statusVerify()
|
||||
{
|
||||
return view('status.status_verify');
|
||||
}
|
||||
public function statusError(){
|
||||
public function statusError()
|
||||
{
|
||||
return view('status.status_error');
|
||||
}
|
||||
public function notFound(){
|
||||
public function notFound()
|
||||
{
|
||||
return view('status.not_found');
|
||||
}
|
||||
|
||||
|
|
@ -224,15 +231,16 @@ class HomeController extends Controller
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function checkMail(){
|
||||
public function checkMail()
|
||||
{
|
||||
|
||||
$data = Request::all();
|
||||
if($data['user_id'] === "new"){
|
||||
if(User::where('email', $data['email'])->count()){
|
||||
if ($data['user_id'] === "new") {
|
||||
if (User::where('email', $data['email'])->count()) {
|
||||
return json_encode(false);
|
||||
}
|
||||
}else{
|
||||
if(User::where('email', $data['email'])->where('id', '!=', $data['user_id'])->count()){
|
||||
} else {
|
||||
if (User::where('email', $data['email'])->where('id', '!=', $data['user_id'])->count()) {
|
||||
return json_encode(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -244,24 +252,23 @@ class HomeController extends Controller
|
|||
return view('status.user_blocked');
|
||||
}
|
||||
|
||||
public function backToShop($reference = ""){
|
||||
public function backToShop($reference = "")
|
||||
{
|
||||
|
||||
if($reference){
|
||||
if ($reference) {
|
||||
$ShoppingPayment = ShoppingPayment::where('reference', $reference)->first();
|
||||
if($ShoppingPayment && $ShoppingPayment->status === 'success'){
|
||||
if ($ShoppingPayment && $ShoppingPayment->status === 'success') {
|
||||
$user = Auth::user();
|
||||
//is form wizard create payment
|
||||
if($user && ($user->wizard == 13 || $user->wizard == 20)){
|
||||
$user->wizard = 15; //realese Payments
|
||||
$user->save();
|
||||
return redirect(route('wizard_create', [15]));
|
||||
if ($user && ($user->wizard == 13 || $user->wizard == 20)) {
|
||||
$user->wizard = 15; //realese Payments
|
||||
$user->save();
|
||||
return redirect(route('wizard_create', [15]));
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
\Session()->flash('alert-error', __('msg.error_occurred_with_order'));
|
||||
return redirect(route('/'));
|
||||
return redirect(url('/'));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
app/Http/Controllers/ImportProductController.php
Executable file → Normal file
0
app/Http/Controllers/ImportProductController.php
Executable file → Normal file
0
app/Http/Controllers/IngredientController.php
Executable file → Normal file
0
app/Http/Controllers/IngredientController.php
Executable file → Normal file
0
app/Http/Controllers/LeadController.php
Executable file → Normal file
0
app/Http/Controllers/LeadController.php
Executable file → Normal file
88
app/Http/Controllers/LevelReportsController.php
Normal file
88
app/Http/Controllers/LevelReportsController.php
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\LevelReportService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class LevelReportsController extends Controller
|
||||
{
|
||||
private $levelReportService;
|
||||
|
||||
public function __construct(LevelReportService $levelReportService)
|
||||
{
|
||||
$this->levelReportService = $levelReportService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeige Level-Aufstieg Reports
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
// Filter aus Request extrahieren
|
||||
$filters = [
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'user_id' => $request->get('user_id'),
|
||||
'only_not_updated' => $request->boolean('not_updated')
|
||||
];
|
||||
|
||||
// Lade Level-Aufstiege
|
||||
$promotions = $this->levelReportService->getLevelPromotions($filters);
|
||||
$statistics = $this->levelReportService->getStatistics($promotions);
|
||||
|
||||
// Verfügbare Jahre für Filter
|
||||
$availableYears = range(date('Y'), date('Y') - 5);
|
||||
$availableMonths = [
|
||||
1 => 'Januar',
|
||||
2 => 'Februar',
|
||||
3 => 'März',
|
||||
4 => 'April',
|
||||
5 => 'Mai',
|
||||
6 => 'Juni',
|
||||
7 => 'Juli',
|
||||
8 => 'August',
|
||||
9 => 'September',
|
||||
10 => 'Oktober',
|
||||
11 => 'November',
|
||||
12 => 'Dezember'
|
||||
];
|
||||
|
||||
return view('admin.level-reports.index', compact(
|
||||
'promotions',
|
||||
'statistics',
|
||||
'filters',
|
||||
'availableYears',
|
||||
'availableMonths'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* CSV Export
|
||||
*/
|
||||
public function export(Request $request)
|
||||
{
|
||||
// Filter aus Request extrahieren
|
||||
$filters = [
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'user_id' => $request->get('user_id'),
|
||||
'only_not_updated' => $request->boolean('not_updated')
|
||||
];
|
||||
|
||||
// Lade Level-Aufstiege
|
||||
$promotions = $this->levelReportService->getLevelPromotions($filters);
|
||||
|
||||
if ($promotions->isEmpty()) {
|
||||
return redirect()->back()->with('error', 'Keine Daten für Export gefunden.');
|
||||
}
|
||||
|
||||
// Erstelle CSV
|
||||
$filename = 'level_promotions_' . date('Y-m-d_H-i-s') . '.csv';
|
||||
$filepath = $this->levelReportService->exportToCsv($promotions, $filename);
|
||||
|
||||
// Download CSV
|
||||
return response()->download($filepath, $filename)->deleteFileAfterSend(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -27,100 +27,101 @@ class ModalController extends Controller
|
|||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function load(){
|
||||
public function load()
|
||||
{
|
||||
$data = Request::all();
|
||||
$ret = "";
|
||||
$status = false;
|
||||
if(Request::ajax()){
|
||||
if($data['action'] === 'shopping-order-change-member'){
|
||||
if (Request::ajax()) {
|
||||
if ($data['action'] === 'shopping-order-change-member') {
|
||||
$value = ShoppingOrder::find($data['id']);
|
||||
$route = route('admin_sales_customers_detail', [$value->id]);
|
||||
$ret = view("admin.modal.member", compact('value', 'data', 'route'))->render();
|
||||
}
|
||||
if($data['action'] === 'shopping-user-change-member'){
|
||||
if ($data['action'] === 'shopping-user-change-member') {
|
||||
$value = ShoppingUser::find($data['id']);
|
||||
$route = route('admin_customer_edit', [$value->id]);
|
||||
$ret = view("admin.modal.member", compact('value', 'data', 'route'))->render();
|
||||
}
|
||||
if($data['action'] === 'shopping-user-is-like-member'){
|
||||
if ($data['action'] === 'shopping-user-is-like-member') {
|
||||
$current = ShoppingUser::find($data['id']); //current user form order
|
||||
$possibles = [];
|
||||
if($current->is_like){
|
||||
if ($current->is_like) {
|
||||
$likes = $current->getNotice('like');
|
||||
foreach ($likes as $like_id=>$number){
|
||||
foreach ($likes as $like_id => $number) {
|
||||
$possibles[] = ShoppingUser::find($like_id);
|
||||
}
|
||||
}
|
||||
$ret = view("admin.modal.is_like_member", compact('current', 'possibles', 'data'))->render();
|
||||
}
|
||||
if($data['action'] === 'shopping-order-change-points'){
|
||||
if ($data['action'] === 'shopping-order-change-points') {
|
||||
$value = ShoppingOrder::find($data['id']);
|
||||
$route = route('admin_sales_customers_detail', [$value->id]);
|
||||
$ret = view("admin.modal.change_points", compact('value', 'data', 'route'))->render();
|
||||
}
|
||||
if($data['action'] === 'user-order-show-product'){
|
||||
if ($data['action'] === 'user-order-show-product') {
|
||||
$product = Product::find($data['id']); //current user form order
|
||||
$ret = view("admin.modal.show_product", compact('product', 'data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'user-order-show-product'){
|
||||
if ($data['action'] === 'user-order-show-product') {
|
||||
$product = Product::find($data['id']); //current user form order
|
||||
$ret = view("admin.modal.show_product", compact('product', 'data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'shop-user-order-detail'){
|
||||
$user = \Auth::user();
|
||||
if ($data['action'] === 'shop-user-order-detail') {
|
||||
$user = \Auth::user();
|
||||
$shopping_order = ShoppingOrder::findOrFail($data['id']);
|
||||
if(!$user->isAdmin() && $shopping_order->member_id !== $user->id){
|
||||
if (!$user->isAdmin() && $shopping_order->member_id !== $user->id) {
|
||||
abort(404);
|
||||
}
|
||||
$isAdmin = false ;
|
||||
$isAdmin = false;
|
||||
$ret = view("user.shop.sales.modal_api_order_detail", compact('shopping_order', 'isAdmin', 'data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'shop-user-order-shipping-detail'){
|
||||
$user = \Auth::user();
|
||||
if ($data['action'] === 'shop-user-order-shipping-detail') {
|
||||
$user = \Auth::user();
|
||||
$shopping_order = ShoppingOrder::findOrFail($data['id']);
|
||||
if(!$user->isAdmin() && $shopping_order->auth_user_id !== $user->id){
|
||||
if (!$user->isAdmin() && $shopping_order->auth_user_id !== $user->id) {
|
||||
abort(404);
|
||||
}
|
||||
$isAdmin = false ;
|
||||
$isAdmin = false;
|
||||
$ret = view("user.shop.sales.modal_api_order_shipping_detail", compact('shopping_order', 'isAdmin', 'data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'user-order-my-delivery-show'){
|
||||
if ($data['action'] === 'user-order-my-delivery-show') {
|
||||
$user = \Auth::user();
|
||||
$ret = view("admin.modal.show_user_customers", compact('user', 'data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'user-order-my-delivery-add'){
|
||||
|
||||
if ($data['action'] === 'user-order-my-delivery-add') {
|
||||
$user = \Auth::user();
|
||||
/* $product = Product::find($data['id']); //current user form order
|
||||
/* $product = Product::find($data['id']); //current user form order
|
||||
$ret = view("admin.modal.show_product", compact('product', 'data'))->render(); */
|
||||
}
|
||||
if($data['action'] === 'homeparty-add-product') {
|
||||
if ($data['action'] === 'homeparty-add-product') {
|
||||
$homeparty = Homeparty::find($data['id']);
|
||||
$homeparty_user = HomepartyUser::find($data['user_id']);
|
||||
$data['homeparty'] = $homeparty;
|
||||
$ret = view("user.homeparty.modal_hp_show_products", compact( 'data', 'homeparty', 'homeparty_user'))->render();
|
||||
$ret = view("user.homeparty.modal_hp_show_products", compact('data', 'homeparty', 'homeparty_user'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'user-level-edit'){
|
||||
if ($data['action'] === 'user-level-edit') {
|
||||
$value = UserLevel::find($data['id']);
|
||||
$route = route('admin_level_store', [$value->id]);
|
||||
$ret = view("admin.modal.user_level_edit", compact('value', 'data', 'route'))->render();
|
||||
}
|
||||
if($data['action'] === 'user-level-add'){
|
||||
if ($data['action'] === 'user-level-add') {
|
||||
$value = new UserLevel();
|
||||
$route = route('admin_level_store', ['new']);
|
||||
$ret = view("admin.modal.user_level_edit", compact('value', 'data', 'route'))->render();
|
||||
}
|
||||
if($data['action'] === 'business-user-detail'){
|
||||
if ($data['action'] === 'business-user-detail') {
|
||||
$user = User::findOrFail($data['id']);
|
||||
if($data['init_from'] === 'admin'){
|
||||
if ($data['init_from'] === 'admin') {
|
||||
$data['month'] = session('business_user_filter_month');
|
||||
$data['year'] = session('business_user_filter_year');
|
||||
}else{
|
||||
} else {
|
||||
$data['month'] = session('team_user_filter_month');
|
||||
$data['year'] = session('team_user_filter_year');
|
||||
}
|
||||
|
|
@ -131,74 +132,72 @@ class ModalController extends Controller
|
|||
$ret = view("admin.modal.business_user_detail", compact('TreeCalcBot', 'user', 'data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'business-user-show'){
|
||||
if ($data['action'] === 'business-user-show') {
|
||||
$user = User::find($data['id']);
|
||||
if($user && $user->account){
|
||||
if ($user && $user->account) {
|
||||
$route = "";
|
||||
$ret = view("admin.modal.business_user_show", compact('user', 'data'))->render();
|
||||
}
|
||||
$ret = view("admin.modal.business_user_notfound", compact('data'))->render();
|
||||
|
||||
}
|
||||
if($data['action'] === 'edit_user_sales_volume'){
|
||||
if ($data['action'] === 'edit_user_sales_volume') {
|
||||
$userSalesVolume = UserSalesVolume::findOrFail($data['id']);
|
||||
$route = route('admin_business_points_store', );
|
||||
$route = route('admin_business_points_store',);
|
||||
$ret = view("admin.business.modal_edit_points", compact('userSalesVolume', 'data', 'route'))->render();
|
||||
}
|
||||
if($data['action'] === 'add_user_sales_volume'){
|
||||
if ($data['action'] === 'add_user_sales_volume') {
|
||||
$userSalesVolume = new UserSalesVolume();
|
||||
$route = route('admin_business_points_store', );
|
||||
$route = route('admin_business_points_store',);
|
||||
$ret = view("admin.business.modal_add_points", compact('userSalesVolume', 'data', 'route'))->render();
|
||||
}
|
||||
if($data['action'] === 'add-user-credit'){
|
||||
}
|
||||
if ($data['action'] === 'add-user-credit') {
|
||||
$value = [];
|
||||
$ret = view("admin.payment.modal_add_credit", compact('value', 'data'))->render();
|
||||
}
|
||||
if($data['action'] === 'user-credit-status'){
|
||||
}
|
||||
if ($data['action'] === 'user-credit-status') {
|
||||
$UserCredit = UserCredit::find($data['id']); //current user form order
|
||||
$ret = view("admin.payment.modal_credit_status", compact('UserCredit', 'data'))->render();
|
||||
}
|
||||
if($data['action'] === 'abo_update_settings'){
|
||||
if ($data['action'] === 'abo_update_settings') {
|
||||
$user_abo = UserAbo::find($data['id']);
|
||||
if($data['view'] === 'admin'){
|
||||
if ($data['view'] === 'admin') {
|
||||
$route = route('admin_abos_update', [$user_abo->id]);
|
||||
}else{
|
||||
} else {
|
||||
$route = route('user_abos_update', [$data['view'], $user_abo->id]);
|
||||
}
|
||||
$ret = view("admin.abo.modal_abo_update", compact('user_abo', 'data', 'route'))->render();
|
||||
}
|
||||
if($data['action'] === 'abo-add-product') {
|
||||
if ($data['action'] === 'abo-add-product') {
|
||||
$user_abo = UserAbo::find($data['id']);
|
||||
$ret = view("user.abo.modal_abo_show_products", compact( 'data', 'user_abo'))->render();
|
||||
$ret = view("user.abo.modal_abo_show_products", compact('data', 'user_abo'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'create-dhl-shipment') {
|
||||
|
||||
if ($data['action'] === 'create-dhl-shipment') {
|
||||
$id = $data['id'] ?? null;
|
||||
$ret = $this->handleDhlShipmentModal($id, $data);
|
||||
}
|
||||
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);
|
||||
return response()->json(['response' => $data, 'html' => $ret, 'status' => $status]);
|
||||
}
|
||||
|
||||
private function getForBusinessUserDetail(User $user, $data){
|
||||
private function getForBusinessUserDetail(User $user, $data)
|
||||
{
|
||||
|
||||
//$auth_user = \Auth::user();
|
||||
//if($auth_user->isAdmin() || $auth_user->id === $user->id){
|
||||
if($data['optimized']){
|
||||
if ($data['optimized']) {
|
||||
$TreeCalcBot = new TreeCalcBotOptimized($data['month'], $data['year'], $data['init_from'], $data['live']);
|
||||
}else{
|
||||
} else {
|
||||
$TreeCalcBot = new TreeCalcBot($data['month'], $data['year'], $data['init_from']);
|
||||
}
|
||||
$TreeCalcBot->initBusinesslUserDetail($user, $data['live']);
|
||||
//TODO is not Admin, read is user in Parent tree ...
|
||||
if(!$TreeCalcBot->business_user){
|
||||
abort(403, 'no user found');
|
||||
}
|
||||
return $TreeCalcBot;
|
||||
$TreeCalcBot->initBusinesslUserDetail($user, $data['live']);
|
||||
//TODO is not Admin, read is user in Parent tree ...
|
||||
if (!$TreeCalcBot->business_user) {
|
||||
abort(403, 'no user found');
|
||||
}
|
||||
return $TreeCalcBot;
|
||||
//}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -213,22 +212,21 @@ class ModalController extends Controller
|
|||
try {
|
||||
$dhlModalService = new DhlModalService();
|
||||
$modalData = $dhlModalService->prepareModalData($id, $data);
|
||||
|
||||
|
||||
// Merge the prepared data with the original request data
|
||||
$viewData = array_merge($data, $modalData, [
|
||||
'id' => $id,
|
||||
'data' => $data
|
||||
]);
|
||||
|
||||
|
||||
return view("admin.dhl.modal_create_shipment", $viewData)->render();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('[ModalController] Error in DHL shipment modal', [
|
||||
'order_id' => $id,
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
]);
|
||||
|
||||
|
||||
// Return error view or fallback
|
||||
$errorData = [
|
||||
'id' => $id,
|
||||
|
|
@ -240,16 +238,14 @@ class ModalController extends Controller
|
|||
'productCodes' => [
|
||||
'V01PAK' => 'DHL Paket (National)',
|
||||
'V53WPAK' => 'DHL Paket International',
|
||||
'V54EPAK' => 'DHL Express'
|
||||
],
|
||||
'errors' => ['Fehler beim Laden der Daten: ' . $e->getMessage()],
|
||||
'warnings' => []
|
||||
];
|
||||
|
||||
|
||||
return view("admin.dhl.modal_create_shipment", $errorData)->render();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
0
app/Http/Controllers/PaymentMethodController.php
Executable file → Normal file
0
app/Http/Controllers/PaymentMethodController.php
Executable file → Normal file
61
app/Http/Controllers/Portal/Auth/LoginController.php
Executable file → Normal file
61
app/Http/Controllers/Portal/Auth/LoginController.php
Executable file → Normal file
|
|
@ -23,7 +23,7 @@ class LoginController extends Controller
|
|||
public function showLoginForm()
|
||||
{
|
||||
//wenn als Berater eingeloggt, dann zum Login wechseln
|
||||
if(Auth::guard('user')->check()){
|
||||
if (Auth::guard('user')->check()) {
|
||||
return redirect()->route('portal.change_login');
|
||||
}
|
||||
//wenn als Kunde eingeloggt, dann direkt zum Dashboard
|
||||
|
|
@ -41,15 +41,18 @@ class LoginController extends Controller
|
|||
|
||||
// 1. Prüfen, ob die E-Mail im System bekannt ist über Kunden-Tabelle)
|
||||
$customer = Customer::firstOrCreate(['email' => $email]); // Erstellt Kunden, wenn nicht vorhanden
|
||||
if($customer && $customer->language){
|
||||
if ($customer && $customer->language) {
|
||||
\App::setLocale($customer->language);
|
||||
}
|
||||
|
||||
//add user_shop_domain for back
|
||||
$customer->user_shop_domain = session('user_shop_domain');
|
||||
$customer->save();
|
||||
|
||||
// if (!$customerExists && !$orderExists) { // Oder nur eine Prüfung, je nach Logik
|
||||
if (!$customer) { // Prüfung anhand des Customer-Models
|
||||
throw ValidationException::withMessages([
|
||||
'email' => __('auth.failed_customer'), // Generische Fehlermeldung
|
||||
]);
|
||||
throw ValidationException::withMessages([
|
||||
'email' => __('auth.failed_customer'), // Generische Fehlermeldung
|
||||
]);
|
||||
}
|
||||
// 2. Alten Token löschen (optional, aber empfohlen)
|
||||
DB::table('otp_tokens')->where('email', $email)->delete();
|
||||
|
|
@ -70,10 +73,10 @@ class LoginController extends Controller
|
|||
try {
|
||||
Mail::to($email)->locale(\App::getLocale())->send(new MailOTPCustomer($otp, $email));
|
||||
} catch (\Exception $e) {
|
||||
// Logge den Fehler
|
||||
\Log::error('OTP Send Error: ' . $e->getMessage());
|
||||
// Gib eine Fehlermeldung zurück, ohne Details preiszugeben
|
||||
return back()->withErrors(['email' => 'Konnte E-Mail nicht senden. Bitte versuchen Sie es später erneut.'])->withInput();
|
||||
// Logge den Fehler
|
||||
\Log::error('OTP Send Error: ' . $e->getMessage());
|
||||
// Gib eine Fehlermeldung zurück, ohne Details preiszugeben
|
||||
return back()->withErrors(['email' => 'Konnte E-Mail nicht senden. Bitte versuchen Sie es später erneut.'])->withInput();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -86,26 +89,26 @@ class LoginController extends Controller
|
|||
public function showOtpForm(Request $request, $email = null, $otp = null)
|
||||
{
|
||||
//wenn als Berater eingeloggt, dann zum Login wechseln
|
||||
if(Auth::guard('user')->check()){
|
||||
if (Auth::guard('user')->check()) {
|
||||
return redirect()->route('portal.change_login');
|
||||
}
|
||||
//wenn als Kunde eingeloggt, dann zum Dashboard wechseln
|
||||
if (Auth::guard('customers')->check()) {
|
||||
return redirect()->route('portal.dashboard');
|
||||
}
|
||||
// E-Mail aus der Session holen (oder als Request-Parameter erwarten)
|
||||
if($email) {
|
||||
if (Auth::guard('customers')->check()) {
|
||||
return redirect()->route('portal.dashboard');
|
||||
}
|
||||
// E-Mail aus der Session holen (oder als Request-Parameter erwarten)
|
||||
if ($email) {
|
||||
$email = $email;
|
||||
} else {
|
||||
} else {
|
||||
$email = session('otp_email', $request->query('email'));
|
||||
}
|
||||
}
|
||||
if (!$email) {
|
||||
return redirect()->route('portal.login.form')->withErrors(['message' => 'Sitzung abgelaufen oder E-Mail fehlt.']);
|
||||
}
|
||||
|
||||
|
||||
// CSRF-Token regenerieren für neue Session
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
|
||||
// Übergebe sowohl 'email' als auch 'otp' an die View
|
||||
return view('portal.auth.verify-otp', ['email' => $email, 'otp_value' => $otp]); // Variable umbenannt zu otp_value für Klarheit
|
||||
}
|
||||
|
|
@ -135,24 +138,24 @@ class LoginController extends Controller
|
|||
|
||||
if (!$customer) {
|
||||
// Sollte eigentlich nicht passieren, wenn sendOtp korrekt funktioniert hat
|
||||
DB::table('otp_tokens')->where('email', $email)->delete();
|
||||
return back()->withErrors(['otp' => __('auth.failed')])->withInput(['email' => $email]);
|
||||
DB::table('otp_tokens')->where('email', $email)->delete();
|
||||
return back()->withErrors(['otp' => __('auth.failed')])->withInput(['email' => $email]);
|
||||
}
|
||||
// 4. Kunden einloggen über den 'customers'-Guard
|
||||
Auth::guard('customers')->login($customer); // Loggt den gefundenen Kunden ein
|
||||
|
||||
|
||||
// 5. Explizite Session-Speicherung
|
||||
$request->session()->save();
|
||||
|
||||
|
||||
// 6. OTP-Eintrag löschen
|
||||
DB::table('otp_tokens')->where('email', $email)->delete();
|
||||
|
||||
// 7. Session Token regenerieren (statt komplette Session)
|
||||
$request->session()->regenerate();
|
||||
$request->session()->regenerate();
|
||||
|
||||
// 8. customer DB aktualisieren
|
||||
$shopping_user = ShoppingUser::where('billing_email', $email)->latest()->first();
|
||||
if($shopping_user){
|
||||
if ($shopping_user) {
|
||||
$data = [
|
||||
'name' => $shopping_user->billing_firstname . ' ' . $shopping_user->billing_lastname,
|
||||
'shopping_user_id' => $shopping_user->id,
|
||||
|
|
@ -161,7 +164,7 @@ class LoginController extends Controller
|
|||
'language' => session('locale') ?? 'de',
|
||||
];
|
||||
$customer->update($data);
|
||||
}else{
|
||||
} else {
|
||||
$data = [
|
||||
'name' => __('portal.guest'),
|
||||
'shopping_user_id' => null,
|
||||
|
|
@ -185,7 +188,7 @@ class LoginController extends Controller
|
|||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
return redirect($url);
|
||||
}
|
||||
}
|
||||
|
||||
// Logout für Berater
|
||||
public function logoutChange(Request $request)
|
||||
|
|
@ -200,4 +203,4 @@ class LoginController extends Controller
|
|||
session(['locale' => $locale]);
|
||||
return redirect()->route('portal.login.form');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
app/Http/Controllers/Portal/InController.php
Executable file → Normal file
0
app/Http/Controllers/Portal/InController.php
Executable file → Normal file
0
app/Http/Controllers/ProductController.php
Executable file → Normal file
0
app/Http/Controllers/ProductController.php
Executable file → Normal file
193
app/Http/Controllers/SalesController.php
Executable file → Normal file
193
app/Http/Controllers/SalesController.php
Executable file → Normal file
|
|
@ -16,25 +16,25 @@ use App\Services\BusinessPlan\SalesPointsVolume;
|
|||
class SalesController extends Controller
|
||||
{
|
||||
|
||||
public function __construct(){
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
}
|
||||
|
||||
public function users(){
|
||||
public function users()
|
||||
{
|
||||
|
||||
if(Request::get('reset') === 'filter'){
|
||||
if (Request::get('reset') === 'filter') {
|
||||
return redirect(route('admin_sales_users'));
|
||||
}
|
||||
$data = [
|
||||
|
||||
];
|
||||
$data = [];
|
||||
return view('admin.sales.users', $data);
|
||||
}
|
||||
|
||||
public function usersDetail($id)
|
||||
{
|
||||
$ShoppingOrder = ShoppingOrder::find($id);
|
||||
if( $ShoppingOrder->payment_for === 6 || $ShoppingOrder->payment_for === 7){
|
||||
if ($ShoppingOrder->payment_for === 6 || $ShoppingOrder->payment_for === 7) {
|
||||
return redirect(route('admin_sales_customers_detail', [$ShoppingOrder->id]));
|
||||
abort(403, 'Kundenbestellung');
|
||||
}
|
||||
|
|
@ -44,9 +44,9 @@ class SalesController extends Controller
|
|||
}*/
|
||||
|
||||
$data = [
|
||||
'shopping_order' => $ShoppingOrder,
|
||||
'isAdmin' => true,
|
||||
'isView' => 'sales_user',
|
||||
'shopping_order' => $ShoppingOrder,
|
||||
'isAdmin' => true,
|
||||
'isView' => 'sales_user',
|
||||
];
|
||||
return view('admin.sales.user_detail', $data);
|
||||
}
|
||||
|
|
@ -61,7 +61,8 @@ class SalesController extends Controller
|
|||
return view('admin.sales.user_detail', $data);
|
||||
}
|
||||
|
||||
public function usersDatatable(){
|
||||
public function usersDatatable()
|
||||
{
|
||||
|
||||
$query = ShoppingOrder::with('shopping_user', 'user_shop', 'shopping_payments')->select('shopping_orders.*')->where('shopping_orders.auth_user_id', '!=', NULL);
|
||||
|
||||
|
|
@ -76,29 +77,35 @@ class SalesController extends Controller
|
|||
return Payment::getShoppingOrderBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="no-line-break">'.$ShoppingOrder->getFormattedTotalShipping()." €</span>";
|
||||
return '<span class="no-line-break">' . $ShoppingOrder->getFormattedTotalShipping() . " €</span>";
|
||||
})
|
||||
->addColumn('payment', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('getPaymentType');
|
||||
})
|
||||
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
|
||||
if($ShoppingOrder->payment_for === 8){
|
||||
if ($ShoppingOrder->payment_for === 8) {
|
||||
return '<button type="button" class="btn btn-xs btn-info btn-round" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$ShoppingOrder->id.'"
|
||||
data-id="' . $ShoppingOrder->id . '"
|
||||
data-action="shop-user-order-shipping-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="user"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-eye"></span></button>';
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-eye"></span></button>';
|
||||
}
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
|
||||
return '<span class="badge badge-pill badge-' . $ShoppingOrder->getShippedColor() . '">' . $ShoppingOrder->getShippedType() . '</span>';
|
||||
})
|
||||
->addColumn('dhl_button', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<button type="button" class="btn btn-xs btn-' . ($ShoppingOrder->hasDhlShipments() ? 'primary' : 'secondary') . '" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="' . $ShoppingOrder->id . '"
|
||||
data-action="create-dhl-shipment"
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-shipping-fast"></span></button>';
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return Payment::getPaymentForBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('invoice', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->isInvoice() ? '<span class="no-line-break"><a href="'.route('storage_file', [$ShoppingOrder->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a>
|
||||
<a href="'.route('storage_file', [$ShoppingOrder->id, 'invoice', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a></span>' : '-';
|
||||
return $ShoppingOrder->isInvoice() ? '<span class="no-line-break"><a href="' . route('storage_file', [$ShoppingOrder->id, 'invoice', 'download']) . '" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a>
|
||||
<a href="' . route('storage_file', [$ShoppingOrder->id, 'invoice', 'stream']) . '" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a></span>' : '-';
|
||||
})
|
||||
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('reference');
|
||||
|
|
@ -107,11 +114,11 @@ class SalesController extends Controller
|
|||
return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->orders : '';
|
||||
})
|
||||
->addColumn('user_shop_id', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->user_shop ? '<a href="'.$ShoppingOrder->user_shop->getSubdomain(false).'" target="_blank">'.$ShoppingOrder->user_shop->getSubdomain(false).'</span>' : '';
|
||||
return $ShoppingOrder->user_shop ? '<a href="' . $ShoppingOrder->user_shop->getSubdomain(false) . '" target="_blank">' . $ShoppingOrder->user_shop->getSubdomain(false) . '</span>' : '';
|
||||
})
|
||||
->addColumn('auth_user_shop', function (ShoppingOrder $ShoppingOrder) {
|
||||
$auth_user_shop = UserShop::whereUserId($ShoppingOrder->auth_user_id)->first();
|
||||
return $auth_user_shop ? '<a href="'.$auth_user_shop->getSubdomain(false).'" target="_blank">'.$auth_user_shop->getSubdomain(false).'</span>' : '-';
|
||||
return $auth_user_shop ? '<a href="' . $auth_user_shop->getSubdomain(false) . '" target="_blank">' . $auth_user_shop->getSubdomain(false) . '</span>' : '-';
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('txaction', 'txaction $1')
|
||||
|
|
@ -120,27 +127,27 @@ class SalesController extends Controller
|
|||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
->orderColumn('payment_for', 'payment_for $1')
|
||||
|
||||
->rawColumns(['id', 'txaction', 'user_shop_id', 'auth_user_shop', 'payment_for', 'total_shipping', 'invoice', 'shipped'])
|
||||
->rawColumns(['id', 'dhl_button', 'txaction', 'user_shop_id', 'auth_user_shop', 'payment_for', 'total_shipping', 'invoice', 'shipped'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
public function customers()
|
||||
{
|
||||
if(Request::get('reset') === 'filter'){
|
||||
if (Request::get('reset') === 'filter') {
|
||||
set_user_attr('filter_user_shop_id', null);
|
||||
set_user_attr('filter_txaction', null);
|
||||
set_user_attr('filter_member_id', null);
|
||||
return redirect(route('admin_sales_customers'));
|
||||
}
|
||||
$filter_user_shops = ShoppingOrder::select('user_shops.id', 'user_shops.slug')
|
||||
->join('user_shops', 'shopping_orders.user_shop_id', '=', 'user_shops.id')
|
||||
->orderBy('user_shops.slug')
|
||||
->distinct()
|
||||
->pluck('slug', 'id')
|
||||
->toArray();
|
||||
$filter_members = ShoppingOrder::join('users', 'member_id', '=', 'users.id')->groupBy('member_id')->join('user_accounts', 'account_id', '=', 'user_accounts.id')->select('users.id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')->get();
|
||||
->join('user_shops', 'shopping_orders.user_shop_id', '=', 'user_shops.id')
|
||||
->orderBy('user_shops.slug')
|
||||
->distinct()
|
||||
->pluck('slug', 'id')
|
||||
->toArray();
|
||||
$filter_members = ShoppingOrder::join('users', 'member_id', '=', 'users.id')->groupBy('member_id')->join('user_accounts', 'account_id', '=', 'user_accounts.id')->select('users.id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')->get();
|
||||
//->pluck('email', 'id')->unique()->toArray();
|
||||
|
||||
|
||||
|
||||
|
||||
$data = [
|
||||
|
|
@ -153,14 +160,14 @@ class SalesController extends Controller
|
|||
public function customersDetail($id)
|
||||
{
|
||||
$ShoppingOrder = ShoppingOrder::find($id);
|
||||
if(!$ShoppingOrder){
|
||||
if (!$ShoppingOrder) {
|
||||
abort(404);
|
||||
}
|
||||
if( $ShoppingOrder->payment_for !== 6 && $ShoppingOrder->payment_for !== 7){
|
||||
if ($ShoppingOrder->payment_for !== 6 && $ShoppingOrder->payment_for !== 7) {
|
||||
return redirect(route('admin_sales_users_detail', [$ShoppingOrder->id]));
|
||||
abort(403, 'Beraterbestellung');
|
||||
}
|
||||
/*
|
||||
/*
|
||||
if($ShoppingOrder->shipped === 0){
|
||||
$ShoppingOrder->shipped = 1;
|
||||
$ShoppingOrder->save();
|
||||
|
|
@ -178,10 +185,10 @@ class SalesController extends Controller
|
|||
{
|
||||
$data = Request::all();
|
||||
$change_member_error = false;
|
||||
if($data['action']==='shopping-order-change-member'){
|
||||
if(!isset($data['change_member_key']) || $data['change_member_key'] !== config('mivita.edit_data_pass')){
|
||||
if ($data['action'] === 'shopping-order-change-member') {
|
||||
if (!isset($data['change_member_key']) || $data['change_member_key'] !== config('mivita.edit_data_pass')) {
|
||||
$change_member_error = "Das Passwort ist falsch.";
|
||||
}else{
|
||||
} else {
|
||||
//change
|
||||
$shopping_order = ShoppingOrder::findOrFail($data['id']);
|
||||
CustomerPriority::newMemberForOrder($shopping_order, $data['change_member_id'], $data['customer_set_member_for']);
|
||||
|
|
@ -189,12 +196,12 @@ class SalesController extends Controller
|
|||
return redirect(route('admin_sales_customers_detail', [$shopping_order->id]));
|
||||
}
|
||||
}
|
||||
if($data['action']==='shopping-user-is-like-member'){
|
||||
if(!isset($data['change_member_key']) || $data['change_member_key'] !== config('mivita.edit_data_pass')){
|
||||
\Session()->flash('alert-error', 'Das Passwort ist falsch.');
|
||||
return redirect($data['back']);
|
||||
}else{
|
||||
if(!isset($data['is_like_shopping_user_id'])){
|
||||
if ($data['action'] === 'shopping-user-is-like-member') {
|
||||
if (!isset($data['change_member_key']) || $data['change_member_key'] !== config('mivita.edit_data_pass')) {
|
||||
\Session()->flash('alert-error', 'Das Passwort ist falsch.');
|
||||
return redirect($data['back']);
|
||||
} else {
|
||||
if (!isset($data['is_like_shopping_user_id'])) {
|
||||
\Session()->flash('alert-error', 'Keine Änderung ausgewählt');
|
||||
return redirect($data['back']);
|
||||
}
|
||||
|
|
@ -208,12 +215,12 @@ class SalesController extends Controller
|
|||
return redirect($data['back']);
|
||||
}
|
||||
}
|
||||
if($data['action']==='shopping-order-change-points'){
|
||||
if(!isset($data['change_member_key']) || $data['change_member_key'] !== config('mivita.edit_data_pass')){
|
||||
\Session()->flash('alert-error', 'Das Passwort ist falsch.');
|
||||
return back();
|
||||
}else{
|
||||
if(!isset($data['change_points'])){
|
||||
if ($data['action'] === 'shopping-order-change-points') {
|
||||
if (!isset($data['change_member_key']) || $data['change_member_key'] !== config('mivita.edit_data_pass')) {
|
||||
\Session()->flash('alert-error', 'Das Passwort ist falsch.');
|
||||
return back();
|
||||
} else {
|
||||
if (!isset($data['change_points'])) {
|
||||
\Session()->flash('alert-error', 'Keine Änderung ausgewählt');
|
||||
return back();
|
||||
}
|
||||
|
|
@ -231,24 +238,24 @@ class SalesController extends Controller
|
|||
return view('admin.sales.customer_detail', $data);
|
||||
}
|
||||
|
||||
public function customersDatatable(){
|
||||
public function customersDatatable()
|
||||
{
|
||||
|
||||
$query = ShoppingOrder::with('shopping_user')->select('shopping_orders.*')->where('shopping_orders.auth_user_id', NULL);
|
||||
set_user_attr('filter_user_shop_id', Request::get('filter_user_shop_id'));
|
||||
if(Request::get('filter_user_shop_id') != ""){
|
||||
if (Request::get('filter_user_shop_id') != "") {
|
||||
$query->where('user_shop_id', '=', Request::get('filter_user_shop_id'));
|
||||
}
|
||||
set_user_attr('filter_txaction', Request::get('filter_txaction'));
|
||||
if(Request::get('filter_txaction') != ""){
|
||||
if(Request::get('filter_txaction') === 'NULL'){
|
||||
if (Request::get('filter_txaction') != "") {
|
||||
if (Request::get('filter_txaction') === 'NULL') {
|
||||
$query->where('txaction', '=', NULL);
|
||||
|
||||
}else{
|
||||
} else {
|
||||
$query->where('txaction', '=', Request::get('filter_txaction'));
|
||||
}
|
||||
}
|
||||
set_user_attr('filter_member_id', Request::get('filter_member_id'));
|
||||
if(Request::get('filter_member_id') != ""){
|
||||
if (Request::get('filter_member_id') != "") {
|
||||
$query->where('member_id', '=', Request::get('filter_member_id'));
|
||||
}
|
||||
|
||||
|
|
@ -263,74 +270,81 @@ class SalesController extends Controller
|
|||
return Payment::getShoppingOrderBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="no-line-break">'.$ShoppingOrder->getFormattedTotalShipping()." €</span>";
|
||||
return '<span class="no-line-break">' . $ShoppingOrder->getFormattedTotalShipping() . " €</span>";
|
||||
})
|
||||
->addColumn('payment', function (ShoppingOrder $ShoppingOrder) {
|
||||
if($ShoppingOrder->txaction === 'extern_paid'){
|
||||
if ($ShoppingOrder->txaction === 'extern_paid') {
|
||||
$shopping_oder_id = isset($ShoppingOrder->api_notice['shopping_order_id']) ? $ShoppingOrder->api_notice['shopping_order_id'] : null;
|
||||
if($shopping_oder_id){
|
||||
return '<a class="btn btn-xs btn-default btn-round" href="'.route('admin_sales_users_detail', [$shopping_oder_id]).'"><i class="fa fa-check fa-check-circle-o"> '.$shopping_oder_id.'</a>';
|
||||
if ($shopping_oder_id) {
|
||||
return '<a class="btn btn-xs btn-default btn-round" href="' . route('admin_sales_users_detail', [$shopping_oder_id]) . '"><i class="fa fa-check fa-check-circle-o"> ' . $shopping_oder_id . '</a>';
|
||||
}
|
||||
}
|
||||
return $ShoppingOrder->getLastShoppingPayment('getPaymentType');
|
||||
})
|
||||
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
|
||||
return '<span class="badge badge-pill badge-' . $ShoppingOrder->getShippedColor() . '">' . $ShoppingOrder->getShippedType() . '</span>';
|
||||
})
|
||||
->addColumn('dhl_button', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<button type="button" class="btn btn-xs btn-' . ($ShoppingOrder->hasDhlShipments() ? 'primary' : 'secondary') . '" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="' . $ShoppingOrder->id . '"
|
||||
data-action="create-dhl-shipment"
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-shipping-fast"></span></button>';
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return Payment::getPaymentForBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('invoice', function (ShoppingOrder $ShoppingOrder) {
|
||||
if(($ShoppingOrder->txaction === 'extern' || $ShoppingOrder->txaction === 'extern_paid') && $ShoppingOrder->wp_invoice_path){
|
||||
return '<span class="no-line-break"><a href="'.$ShoppingOrder->wp_invoice_path.'" class="btn btn-secondary btn-xs"><i class="fa fa-external-link-alt"></i> <i class="fa fa-download"></i></a> </div>';
|
||||
}
|
||||
return $ShoppingOrder->isInvoice() ? '<span class="no-line-break"><a href="'.route('storage_file', [$ShoppingOrder->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a>
|
||||
<a href="'.route('storage_file', [$ShoppingOrder->id, 'invoice', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a></span>' : '-';
|
||||
if (($ShoppingOrder->txaction === 'extern' || $ShoppingOrder->txaction === 'extern_paid') && $ShoppingOrder->wp_invoice_path) {
|
||||
return '<span class="no-line-break"><a href="' . $ShoppingOrder->wp_invoice_path . '" class="btn btn-secondary btn-xs"><i class="fa fa-external-link-alt"></i> <i class="fa fa-download"></i></a> </div>';
|
||||
}
|
||||
return $ShoppingOrder->isInvoice() ? '<span class="no-line-break"><a href="' . route('storage_file', [$ShoppingOrder->id, 'invoice', 'download']) . '" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a>
|
||||
<a href="' . route('storage_file', [$ShoppingOrder->id, 'invoice', 'stream']) . '" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a></span>' : '-';
|
||||
})
|
||||
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('reference');
|
||||
})
|
||||
->addColumn('member_id', function (ShoppingOrder $ShoppingOrder) {
|
||||
if($ShoppingOrder->member_id && $ShoppingOrder->member) {
|
||||
if ($ShoppingOrder->member_id && $ShoppingOrder->member) {
|
||||
return $ShoppingOrder->member ? '<a href="' . route('admin_lead_edit', [$ShoppingOrder->member_id]) . '">' . $ShoppingOrder->member->getFullName() . '</a>' : 'gelöscht';
|
||||
}
|
||||
if($ShoppingOrder->shopping_user && $ShoppingOrder->shopping_user->is_like){
|
||||
if ($ShoppingOrder->shopping_user && $ShoppingOrder->shopping_user->is_like) {
|
||||
return '<button type="button" class="btn btn-xs btn-outline-info" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$ShoppingOrder->shopping_user->id.'"
|
||||
data-id="' . $ShoppingOrder->shopping_user->id . '"
|
||||
data-action="shopping-user-is-like-member"
|
||||
data-back="'.route('admin_sales_customers').'"
|
||||
data-back="' . route('admin_sales_customers') . '"
|
||||
data-modal="modal-xl"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-edit"></span> Berater zuordnen</button>';
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-edit"></span> Berater zuordnen</button>';
|
||||
}
|
||||
return '';
|
||||
})
|
||||
->addColumn('user_shop_id', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->user_shop ? '<a href="'.$ShoppingOrder->user_shop->getSubdomain(false).'" target="_blank">'.$ShoppingOrder->user_shop->getSubdomain(false).'</span>' : '';
|
||||
return $ShoppingOrder->user_shop ? '<a href="' . $ShoppingOrder->user_shop->getSubdomain(false) . '" target="_blank">' . $ShoppingOrder->user_shop->getSubdomain(false) . '</span>' : '';
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('txaction', 'txaction $1')
|
||||
->orderColumn('user_shop_id', 'user_shop_id $1')
|
||||
->orderColumn('member_id', 'member_id $1')
|
||||
->orderColumn('shipped', 'shipped $1')
|
||||
->orderColumn('payment_for', 'payment_for $1')
|
||||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
->rawColumns(['id', 'member_id', 'txaction', 'user_shop_id', 'payment_for', 'payment', 'total_shipping', 'invoice', 'shipped'])
|
||||
->rawColumns(['id', 'dhl_button', 'member_id', 'txaction', 'user_shop_id', 'payment_for', 'payment', 'total_shipping', 'invoice', 'shipped'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
public function store(){
|
||||
public function store()
|
||||
{
|
||||
$data = Request::all();
|
||||
if(!isset($data['id'])){
|
||||
if (!isset($data['id'])) {
|
||||
abort(404);
|
||||
}
|
||||
if(isset($data['action'])){
|
||||
if($data['action'] === 'store_shipped' && isset($data['shipped'])){
|
||||
if (isset($data['action'])) {
|
||||
if ($data['action'] === 'store_shipped' && isset($data['shipped'])) {
|
||||
$shopping_order = ShoppingOrder::findOrFail($data['id']);
|
||||
$shopping_order->shipped = $data['shipped'];
|
||||
$shopping_order->save();
|
||||
}
|
||||
|
||||
if($data['action'] === 'store_txaction' && isset($data['txaction']) && isset($data['payment_id'])){
|
||||
if ($data['action'] === 'store_txaction' && isset($data['txaction']) && isset($data['payment_id'])) {
|
||||
$shopping_order = ShoppingOrder::findOrFail($data['id']);
|
||||
$shopping_payment = ShoppingPayment::findOrFail($data['payment_id']);
|
||||
|
||||
|
|
@ -356,37 +370,36 @@ class SalesController extends Controller
|
|||
//wenn muss hier die Storno erstellt werden
|
||||
//Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
|
||||
}
|
||||
|
||||
}
|
||||
if(isset($data['back'])){
|
||||
if (isset($data['back'])) {
|
||||
return redirect($data['back']);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Manuelle Rechnung erstellen.*/
|
||||
public function invoice(){
|
||||
public function invoice()
|
||||
{
|
||||
$data = Request::all();
|
||||
if(!isset($data['id'])){
|
||||
if (!isset($data['id'])) {
|
||||
abort(404);
|
||||
}
|
||||
if(isset($data['action'])){
|
||||
if($data['action'] === 'create_invoice'){
|
||||
if (isset($data['action'])) {
|
||||
if ($data['action'] === 'create_invoice') {
|
||||
$shopping_order = ShoppingOrder::findOrFail($data['id']);
|
||||
|
||||
|
||||
$invoice_repo = new InvoiceRepository($shopping_order);
|
||||
if($shopping_order->isInvoice()){
|
||||
if ($shopping_order->isInvoice()) {
|
||||
$invoice_repo->update($data);
|
||||
}else{
|
||||
} else {
|
||||
$invoice_repo->createAndSalesVolume($data);
|
||||
}
|
||||
|
||||
if(isset($data['view']) && $data['view'] === 'sales_customer'){
|
||||
|
||||
if (isset($data['view']) && $data['view'] === 'sales_customer') {
|
||||
return redirect(route('admin_sales_customers_detail', [$shopping_order->id]));
|
||||
}
|
||||
return redirect(route('admin_sales_users_detail', [$shopping_order->id]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,9 +54,13 @@ class SettingController extends Controller
|
|||
*/
|
||||
public function getDhlConfig()
|
||||
{
|
||||
// Check if we're in test/sandbox mode
|
||||
$isTestMode = config('dhl.legacy.test_mode', false) || config('dhl.legacy.sandbox', false);
|
||||
$baseUrl = $isTestMode ? config('dhl.sandbox_url') : config('dhl.base_url');
|
||||
|
||||
return [
|
||||
// API Settings
|
||||
'base_url' => Setting::getContentBySlug('dhl_base_url') ?: config('dhl.base_url'),
|
||||
'base_url' => $isTestMode ? $baseUrl : (Setting::getContentBySlug('dhl_base_url') ?: $baseUrl),
|
||||
'api_key' => Setting::getContentBySlug('dhl_api_key') ?: config('dhl.api_key'),
|
||||
'username' => Setting::getContentBySlug('dhl_username') ?: config('dhl.username'),
|
||||
'password' => Setting::getContentBySlug('dhl_password') ?: config('dhl.password'),
|
||||
|
|
@ -91,6 +95,15 @@ class SettingController extends Controller
|
|||
'default' => config('dhl.account_numbers.default'),
|
||||
],
|
||||
|
||||
|
||||
// Dimensions
|
||||
'dimensions' => [
|
||||
'V01PAK' => config('dhl.dimensions.V01PAK'),
|
||||
'V62WP' => config('dhl.dimensions.V62WP'),
|
||||
'V53PAK' => config('dhl.dimensions.V53PAK'),
|
||||
'V07PAK' => config('dhl.dimensions.V07PAK'),
|
||||
'default' => config('dhl.dimensions.default'),
|
||||
],
|
||||
// Static config values (webhook, profile, legacy)
|
||||
'profile' => config('dhl.profile'),
|
||||
'webhook' => config('dhl.webhook'),
|
||||
|
|
|
|||
0
app/Http/Controllers/ShippingController.php
Executable file → Normal file
0
app/Http/Controllers/ShippingController.php
Executable file → Normal file
0
app/Http/Controllers/SitesController.php
Executable file → Normal file
0
app/Http/Controllers/SitesController.php
Executable file → Normal file
0
app/Http/Controllers/SyS/SettingController.php
Executable file → Normal file
0
app/Http/Controllers/SyS/SettingController.php
Executable file → Normal file
0
app/Http/Controllers/TemplateController.php
Executable file → Normal file
0
app/Http/Controllers/TemplateController.php
Executable file → Normal file
0
app/Http/Controllers/TranslationController.php
Executable file → Normal file
0
app/Http/Controllers/TranslationController.php
Executable file → Normal file
0
app/Http/Controllers/TranslationFileController.php
Executable file → Normal file
0
app/Http/Controllers/TranslationFileController.php
Executable file → Normal file
0
app/Http/Controllers/User/CustomerController.php
Executable file → Normal file
0
app/Http/Controllers/User/CustomerController.php
Executable file → Normal file
0
app/Http/Controllers/User/HomepartyController.php
Executable file → Normal file
0
app/Http/Controllers/User/HomepartyController.php
Executable file → Normal file
0
app/Http/Controllers/User/MembershipController.php
Executable file → Normal file
0
app/Http/Controllers/User/MembershipController.php
Executable file → Normal file
0
app/Http/Controllers/User/OrderController.php
Executable file → Normal file
0
app/Http/Controllers/User/OrderController.php
Executable file → Normal file
0
app/Http/Controllers/User/ShopSalesController.php
Executable file → Normal file
0
app/Http/Controllers/User/ShopSalesController.php
Executable file → Normal file
475
app/Http/Controllers/User/TeamController.php
Executable file → Normal file
475
app/Http/Controllers/User/TeamController.php
Executable file → Normal file
|
|
@ -45,7 +45,7 @@ class TeamController extends Controller
|
|||
$this->middleware('active.account');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Zeigt die Team-Übersicht mit optimierter TreeCalcBotOptimized-Datenverarbeitung
|
||||
|
|
@ -55,60 +55,58 @@ class TeamController extends Controller
|
|||
{
|
||||
$startTime = microtime(true);
|
||||
$startMemory = memory_get_usage();
|
||||
|
||||
|
||||
try {
|
||||
$this->setFilterVars();
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$this->month = session('team_user_filter_month');
|
||||
$this->year = session('team_user_filter_year');
|
||||
|
||||
|
||||
// Prüfe ob Live-Berechnung erzwungen werden soll
|
||||
$forceLiveCalculation = Request::get('force_live_calculation', false) || Request::get('live', false);
|
||||
|
||||
\Log::info("TeamController: Building optimized team overview for user {$user->id} ({$this->month}/{$this->year})" .
|
||||
($forceLiveCalculation ? " with forced live calculation" : ""));
|
||||
|
||||
$forceLiveCalculation = false;
|
||||
|
||||
\Log::info("TeamController: Building optimized team overview for user {$user->id} ({$this->month}/{$this->year})" .
|
||||
($forceLiveCalculation === true ? " with forced live calculation" : "not live calculation"));
|
||||
|
||||
// Verwende TreeCalcBotOptimized für bessere Performance
|
||||
$TreeCalcBot = new TreeCalcBotOptimized($this->month, $this->year, 'member', $forceLiveCalculation);
|
||||
$TreeCalcBot->initStructureUser($user->id);
|
||||
|
||||
//$TreeCalcBot = new TreeCalcBotOptimized($this->month, $this->year, 'member', $forceLiveCalculation);
|
||||
//$TreeCalcBot->initStructureUser($user->id);
|
||||
$endTime = microtime(true);
|
||||
$endMemory = memory_get_usage();
|
||||
|
||||
|
||||
$executionTime = round(($endTime - $startTime) * 1000, 2);
|
||||
$memoryUsed = $this->formatBytes($endMemory - $startMemory);
|
||||
|
||||
|
||||
$calculationType = $forceLiveCalculation ? " (LIVE)" : " (CACHE)";
|
||||
\Log::info("TeamController: Optimized team overview built in {$executionTime}ms, Memory: {$memoryUsed}{$calculationType}");
|
||||
|
||||
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
'filter_years' => HTMLHelper::getYearRange(2022),
|
||||
'filter_active' => $this->getFilterActive(),
|
||||
'filter_levels' => $this->getFilterLevels(),
|
||||
'filter_next_level' => $this->getFilterNextLevel(),
|
||||
'TreeCalcBot' => $TreeCalcBot,
|
||||
//'TreeCalcBot' => $TreeCalcBot,
|
||||
'performance' => [
|
||||
'execution_time' => $executionTime,
|
||||
'memory_used' => $memoryUsed,
|
||||
'user_id' => $user->id,
|
||||
'user_count' => $TreeCalcBot->getTotalUserCount(),
|
||||
'user_count' => 0, //$TreeCalcBot->getTotalUserCount(),
|
||||
'version' => 'Optimized',
|
||||
'calculation_type' => $forceLiveCalculation ? 'Live' : 'Cache'
|
||||
],
|
||||
'optimized' => true,
|
||||
'forceLiveCalculation' => $forceLiveCalculation,
|
||||
];
|
||||
|
||||
return view('user.team.show', $data);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("TeamController: Error in optimized show for user {$user->id}: " . $e->getMessage());
|
||||
|
||||
|
||||
// Fallback mit minimalen Daten
|
||||
$endTime = microtime(true);
|
||||
$executionTime = round(($endTime - $startTime) * 1000, 2);
|
||||
|
||||
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
'filter_years' => HTMLHelper::getYearRange(2022),
|
||||
|
|
@ -124,7 +122,7 @@ class TeamController extends Controller
|
|||
],
|
||||
'optimized' => false,
|
||||
];
|
||||
|
||||
|
||||
return view('user.team.show', $data);
|
||||
}
|
||||
}
|
||||
|
|
@ -133,55 +131,54 @@ class TeamController extends Controller
|
|||
{
|
||||
$startTime = microtime(true);
|
||||
$startMemory = memory_get_usage();
|
||||
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
if(config('app.debug')){
|
||||
if (config('app.debug')) {
|
||||
$user = User::find(454);
|
||||
}
|
||||
$this->setFilterVars();
|
||||
|
||||
|
||||
// Prüfe ob optimierte Version explizit angefordert wird
|
||||
$useOptimized = Request::get('use_optimized', true);
|
||||
|
||||
|
||||
// Prüfe ob Live-Berechnung erzwungen werden soll
|
||||
$forceLiveCalculation = Request::get('force_live_calculation', false) || Request::get('live', false);
|
||||
|
||||
|
||||
try {
|
||||
if ($useOptimized) {
|
||||
// Verwende User-spezifische optimierte Version
|
||||
$TreeCalcBot = new TreeCalcBotOptimized(
|
||||
session('team_user_filter_month'),
|
||||
session('team_user_filter_year'),
|
||||
session('team_user_filter_month'),
|
||||
session('team_user_filter_year'),
|
||||
'member',
|
||||
$forceLiveCalculation
|
||||
);
|
||||
$TreeCalcBot->initStructureUser($user->id, $forceLiveCalculation);
|
||||
$optimizedUsed = true;
|
||||
|
||||
} else {
|
||||
// Standard TreeCalcBot mit Performance-Monitoring
|
||||
$TreeCalcBot = new TreeCalcBot(
|
||||
session('team_user_filter_month'),
|
||||
session('team_user_filter_year'),
|
||||
session('team_user_filter_month'),
|
||||
session('team_user_filter_year'),
|
||||
'member'
|
||||
);
|
||||
|
||||
|
||||
// Standard TreeCalcBot unterstützt forceLiveCalculation nicht
|
||||
$TreeCalcBot->initStructureUser($user->id);
|
||||
$optimizedUsed = false;
|
||||
}
|
||||
|
||||
|
||||
$endTime = microtime(true);
|
||||
$endMemory = memory_get_usage();
|
||||
|
||||
|
||||
$executionTime = round(($endTime - $startTime) * 1000, 2);
|
||||
$memoryUsed = $this->formatBytes($endMemory - $startMemory);
|
||||
|
||||
$versionInfo = ($optimizedUsed ? "OPTIMIZED" : "STANDARD") .
|
||||
($forceLiveCalculation ? " + LIVE" : " + CACHE");
|
||||
|
||||
|
||||
$versionInfo = ($optimizedUsed ? "OPTIMIZED" : "STANDARD") .
|
||||
($forceLiveCalculation ? " + LIVE" : " + CACHE");
|
||||
|
||||
\Log::info("TeamController: Structure built for user {$user->id} in {$executionTime}ms, Memory: {$memoryUsed} ({$versionInfo})");
|
||||
|
||||
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
'filter_years' => HTMLHelper::getYearRange(2022),
|
||||
|
|
@ -189,28 +186,27 @@ class TeamController extends Controller
|
|||
'performance' => [
|
||||
'execution_time' => $executionTime,
|
||||
'memory_used' => $memoryUsed,
|
||||
'user_count' => $optimizedUsed && method_exists($TreeCalcBot, 'getTotalUserCount')
|
||||
? $TreeCalcBot->getTotalUserCount()
|
||||
: '-',
|
||||
'user_count' => $optimizedUsed && method_exists($TreeCalcBot, 'getTotalUserCount')
|
||||
? $TreeCalcBot->getTotalUserCount()
|
||||
: '-',
|
||||
'version' => $optimizedUsed ? 'Optimized' : 'Standard',
|
||||
'calculation_type' => $forceLiveCalculation ? 'Live' : 'Cache'
|
||||
],
|
||||
'optimized' => $optimizedUsed,
|
||||
'forceLiveCalculation' => $forceLiveCalculation,
|
||||
];
|
||||
|
||||
|
||||
return view('user.team.structure', $data);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("TeamController: Error in structure for user {$user->id}: " . $e->getMessage());
|
||||
|
||||
|
||||
// Fallback zur Standard-Implementierung
|
||||
$TreeCalcBot = new TreeCalcBot(session('team_user_filter_month'), session('team_user_filter_year'), 'member');
|
||||
$TreeCalcBot->initStructureUser($user->id);
|
||||
|
||||
|
||||
$endTime = microtime(true);
|
||||
$executionTime = round(($endTime - $startTime) * 1000, 2);
|
||||
|
||||
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
'filter_years' => HTMLHelper::getYearRange(2022),
|
||||
|
|
@ -226,14 +222,15 @@ class TeamController extends Controller
|
|||
'optimized' => false,
|
||||
'forceLiveCalculation' => $forceLiveCalculation,
|
||||
];
|
||||
|
||||
|
||||
return view('user.team.structure', $data);
|
||||
}
|
||||
}
|
||||
public function structureOld()
|
||||
{
|
||||
abort(403, 'This page is removed');
|
||||
$user = User::find(\Auth::user()->id);
|
||||
if(config('app.debug')){
|
||||
if (config('app.debug')) {
|
||||
$user = User::find(454);
|
||||
}
|
||||
$this->setFilterVars();
|
||||
|
|
@ -263,27 +260,29 @@ class TeamController extends Controller
|
|||
$user = User::find(\Auth::user()->id);
|
||||
$this->month = Request::get('team_user_filter_month') ?: session('team_user_filter_month');
|
||||
$this->year = Request::get('team_user_filter_year') ?: session('team_user_filter_year');
|
||||
|
||||
|
||||
// Prüfe ob Live-Berechnung erzwungen werden soll
|
||||
$forceLiveCalculation = Request::get('force_live_calculation', false) || Request::get('live', false);
|
||||
|
||||
\Log::info("TeamController: Building optimized datatable for user {$user->id} ({$this->month}/{$this->year})" .
|
||||
($forceLiveCalculation == true ? " with forced live calculation" : ""));
|
||||
|
||||
$forceLiveCalculation = false;
|
||||
\Log::info("TeamController: Building optimized datatable for user {$user->id} ({$this->month}/{$this->year})" .
|
||||
($forceLiveCalculation == true ? " with forced live calculation" : ""));
|
||||
|
||||
// Lade TreeCalcBotOptimized-Daten
|
||||
$TreeCalcBot = new TreeCalcBotOptimized($this->month, $this->year, 'member', $forceLiveCalculation);
|
||||
$TreeCalcBot->initStructureUser($user->id, $forceLiveCalculation);
|
||||
|
||||
// Extrahiere alle User aus der Struktur
|
||||
$teamUsers = collect($this->getTeamUsersFromStructure($TreeCalcBot));
|
||||
// \Log::info("TeamController: TeamUsers: " . $teamUsers->count());
|
||||
|
||||
$teamUsersRaw = $this->getTeamUsersFromStructure($TreeCalcBot);
|
||||
|
||||
// KRITISCH: Bereinige die Objekte für DataTables (entferne zirkuläre Referenzen)
|
||||
$teamUsers = collect($this->cleanBusinessUserItemsForDataTable($teamUsersRaw));
|
||||
|
||||
\Log::info("TeamController: TeamUsers cleaned for DataTable: " . $teamUsers->count());
|
||||
$endTime = microtime(true);
|
||||
$executionTime = round(($endTime - $startTime) * 1000, 2);
|
||||
$this->forceLiveCalculation = $forceLiveCalculation;
|
||||
|
||||
|
||||
\Log::info("TeamController: Optimized datatable data prepared in {$executionTime}ms for " . $teamUsers->count() . " users");
|
||||
|
||||
|
||||
return \DataTables::of($teamUsers)
|
||||
->addColumn('id', function ($teamUser) {
|
||||
return '<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
|
|
@ -310,7 +309,6 @@ class TeamController extends Controller
|
|||
})
|
||||
->addColumn('user_level', function ($teamUser) {
|
||||
return $teamUser->user_level_name ? TranslationHelper::transUserLevelName($teamUser->user_level_name) : '';
|
||||
|
||||
})
|
||||
->addColumn('is_qual_kp', function ($teamUser) {
|
||||
$user = User::find($teamUser->user_id);
|
||||
|
|
@ -320,12 +318,11 @@ class TeamController extends Controller
|
|||
return formatNumber($teamUser->sales_volume_points_KP_sum, 0);
|
||||
})
|
||||
->addColumn('sales_volume_total', function ($teamUser) {
|
||||
|
||||
return formatNumber($teamUser->payline_points_qual_kp, 0);
|
||||
|
||||
return formatNumber($teamUser->payline_points_qual_kp, 0);
|
||||
})
|
||||
->addColumn('next_level_qualified', function ($teamUser) {
|
||||
|
||||
|
||||
$userBusiness = UserBusiness::where('user_id', $teamUser->user_id)
|
||||
->where('month', $this->month)
|
||||
->where('year', $this->year)
|
||||
|
|
@ -334,7 +331,6 @@ class TeamController extends Controller
|
|||
return NextLevelBadgeHelper::generateBadgeFromUserBusiness($userBusiness);
|
||||
}
|
||||
return NextLevelBadgeHelper::renderNoDataBadge();
|
||||
|
||||
})
|
||||
->addColumn('active_account', function ($teamUser) {
|
||||
return get_active_badge($teamUser->active_account);
|
||||
|
|
@ -344,10 +340,9 @@ class TeamController extends Controller
|
|||
})
|
||||
->rawColumns(['id', 'next_level_qualified', 'active_account', 'is_qual_kp', 'sales_volume_KP_points', 'sales_volume_total'])
|
||||
->make(true);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("TeamController: Error in optimized datatable: " . $e->getMessage());
|
||||
|
||||
|
||||
// Fallback zur Standard-DataTable
|
||||
return $this->datatable();
|
||||
}
|
||||
|
|
@ -361,7 +356,7 @@ class TeamController extends Controller
|
|||
try {
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$query = $this->initTeamSearch($user);
|
||||
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (User $teamUser) {
|
||||
return '<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
|
|
@ -397,7 +392,7 @@ class TeamController extends Controller
|
|||
$individual = (int) $teamUser->getUserSalesVolumeBy($month, $year, 'sales_volume_KP_points');
|
||||
$shop = (int) $teamUser->getUserSalesVolumeBy($month, $year, 'sales_volume_points_shop');
|
||||
return '<div class="no-line-break">' . $total . '</div>' .
|
||||
'<span class="small no-line-break">E: ' . $individual . ' | S: ' . $shop . '</span>';
|
||||
'<span class="small no-line-break">E: ' . $individual . ' | S: ' . $shop . '</span>';
|
||||
})
|
||||
->addColumn('sales_volume_total', function (User $teamUser) {
|
||||
$month = Request::get('team_user_filter_month') ?: session('team_user_filter_month');
|
||||
|
|
@ -406,7 +401,7 @@ class TeamController extends Controller
|
|||
$individual = (float) $teamUser->getUserSalesVolumeBy($month, $year, 'sales_volume_total');
|
||||
$shop = (float) $teamUser->getUserSalesVolumeBy($month, $year, 'sales_volume_total_shop');
|
||||
return '<div class="no-line-break">' . formatNumber($total) . ' €</div>' .
|
||||
'<span class="small no-line-break">E: ' . formatNumber($individual) . ' | S: ' . formatNumber($shop) . ' €</span>';
|
||||
'<span class="small no-line-break">E: ' . formatNumber($individual) . ' | S: ' . formatNumber($shop) . ' €</span>';
|
||||
})
|
||||
->addColumn('email', function (User $teamUser) {
|
||||
return e($teamUser->email);
|
||||
|
|
@ -441,35 +436,35 @@ class TeamController extends Controller
|
|||
// Verwende bereits berechnete UserBusiness-Daten für bessere Performance
|
||||
$month = Request::get('team_user_filter_month') ?: session('team_user_filter_month');
|
||||
$year = Request::get('team_user_filter_year') ?: session('team_user_filter_year');
|
||||
|
||||
|
||||
$userBusiness = UserBusiness::where('user_id', $teamUser->id)
|
||||
->where('month', $month)
|
||||
->where('year', $year)
|
||||
->first();
|
||||
|
||||
|
||||
if ($userBusiness) {
|
||||
return NextLevelBadgeHelper::generateBadgeFromUserBusiness($userBusiness);
|
||||
}
|
||||
|
||||
|
||||
return NextLevelBadgeHelper::renderNoDataBadge();
|
||||
})
|
||||
->filterColumn('m_account', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereHas('account', function($q) use ($keyword) {
|
||||
$query->whereHas('account', function ($q) use ($keyword) {
|
||||
$q->where('m_account', 'LIKE', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
})
|
||||
->filterColumn('first_name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereHas('account', function($q) use ($keyword) {
|
||||
$query->whereHas('account', function ($q) use ($keyword) {
|
||||
$q->where('first_name', 'LIKE', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
})
|
||||
->filterColumn('last_name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereHas('account', function($q) use ($keyword) {
|
||||
$query->whereHas('account', function ($q) use ($keyword) {
|
||||
$q->where('last_name', 'LIKE', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
|
|
@ -487,10 +482,9 @@ class TeamController extends Controller
|
|||
->orderColumn('active_account', 'users.payment_account $1')
|
||||
->rawColumns(['id', 'is_qual_kp', 'sales_volume_KP_points', 'sales_volume_total', 'sponsor', 'active_account', 'next_level_qualified'])
|
||||
->make(true);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("TeamController: Error in userDatatable: " . $e->getMessage());
|
||||
|
||||
|
||||
return response()->json([
|
||||
'error' => 'Team-Datatable konnte nicht geladen werden: ' . $e->getMessage()
|
||||
], 500);
|
||||
|
|
@ -504,21 +498,21 @@ class TeamController extends Controller
|
|||
public function marketingplan()
|
||||
{
|
||||
$startTime = microtime(true);
|
||||
|
||||
|
||||
try {
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$currentLevel = $user->user_level;
|
||||
|
||||
|
||||
// Lade alle aktiven User Level, sortiert nach Position
|
||||
$userLevels = \App\Models\UserLevel::where('active', true)
|
||||
->orderBy('pos', 'asc')
|
||||
->get();
|
||||
|
||||
|
||||
$endTime = microtime(true);
|
||||
$executionTime = round(($endTime - $startTime) * 1000, 2);
|
||||
|
||||
|
||||
\Log::info("TeamController: Marketingplan loaded for user {$user->id} in {$executionTime}ms");
|
||||
|
||||
|
||||
$data = [
|
||||
'userLevels' => $userLevels,
|
||||
'currentUser' => $user,
|
||||
|
|
@ -527,12 +521,11 @@ class TeamController extends Controller
|
|||
'execution_time' => $executionTime
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
return view('user.team.marketingplan', $data);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("TeamController: Error loading marketingplan: " . $e->getMessage());
|
||||
|
||||
|
||||
return view('user.team.marketingplan', [
|
||||
'error' => __('marketingplan.loading_error') . ' ' . $e->getMessage(),
|
||||
'userLevels' => collect(),
|
||||
|
|
@ -580,7 +573,7 @@ class TeamController extends Controller
|
|||
// Filtere Team-Mitglieder basierend auf Sponsor-Hierarchie
|
||||
// TODO: Hier müsste die Logik implementiert werden, um nur Team-Mitglieder des aktuellen Users zu finden
|
||||
// Für jetzt zeigen wir alle aktiven User (kann später spezifiziert werden)
|
||||
|
||||
|
||||
$activeFilter = Request::get('team_user_filter_active') ?: session('team_user_filter_active', 1);
|
||||
if ($activeFilter == 1) {
|
||||
$query->where('users.payment_account', '>=', now());
|
||||
|
|
@ -591,7 +584,7 @@ class TeamController extends Controller
|
|||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
public function points()
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
|
@ -718,12 +711,12 @@ class TeamController extends Controller
|
|||
}
|
||||
if (Request::get('team_user_filter_level')) {
|
||||
session(['team_user_filter_level' => Request::get('team_user_filter_level')]);
|
||||
}else{
|
||||
} else {
|
||||
session(['team_user_filter_level' => 0]);
|
||||
}
|
||||
if (Request::get('team_user_filter_next_level')) {
|
||||
session(['team_user_filter_next_level' => Request::get('team_user_filter_next_level')]);
|
||||
}else{
|
||||
} else {
|
||||
session(['team_user_filter_next_level' => 0]);
|
||||
}
|
||||
}
|
||||
|
|
@ -812,96 +805,120 @@ class TeamController extends Controller
|
|||
return round($bytes, $precision) . ' ' . $units[$i];
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt verfügbare User Level für Filter
|
||||
*/
|
||||
private function getFilterLevels(): array
|
||||
{
|
||||
$levels = [0 => 'Alle Level'];
|
||||
|
||||
$userLevels = \App\Models\UserLevel::orderBy('pos')->get(['id', 'name']);
|
||||
foreach ($userLevels as $level) {
|
||||
$levels[$level->id] = $level->name;
|
||||
}
|
||||
|
||||
return $levels;
|
||||
/**
|
||||
* Holt verfügbare User Level für Filter
|
||||
*/
|
||||
private function getFilterLevels(): array
|
||||
{
|
||||
$levels = [0 => 'Alle Level'];
|
||||
|
||||
$userLevels = \App\Models\UserLevel::orderBy('pos')->get(['id', 'name']);
|
||||
foreach ($userLevels as $level) {
|
||||
$levels[$level->id] = $level->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt übersetzte Filter für Aktiv-Status
|
||||
*/
|
||||
private function getFilterActive(): array
|
||||
{
|
||||
return [
|
||||
1 => __('team.filter_active'),
|
||||
2 => __('team.filter_not_active'),
|
||||
3 => __('team.filter_all')
|
||||
];
|
||||
}
|
||||
return $levels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt übersetzte Filter für Next Level Status
|
||||
*/
|
||||
private function getFilterNextLevel(): array
|
||||
{
|
||||
return [
|
||||
0 => __('team.all_status'),
|
||||
1 => __('team.qualified_green'),
|
||||
2 => __('team.in_progress_yellow'),
|
||||
3 => __('team.no_level_red')
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Holt übersetzte Filter für Aktiv-Status
|
||||
*/
|
||||
private function getFilterActive(): array
|
||||
{
|
||||
return [
|
||||
1 => __('team.filter_active'),
|
||||
2 => __('team.filter_not_active'),
|
||||
3 => __('team.filter_all')
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt übersetzte Filter für Next Level Status
|
||||
*/
|
||||
private function getFilterNextLevel(): array
|
||||
{
|
||||
return [
|
||||
0 => __('team.all_status'),
|
||||
1 => __('team.qualified_green'),
|
||||
2 => __('team.in_progress_yellow'),
|
||||
3 => __('team.no_level_red')
|
||||
];
|
||||
}
|
||||
|
||||
// Performance-optimierte Badge-Generierung wurde in NextLevelBadgeHelper ausgelagert
|
||||
// Alte performance-lastige Methoden wurden entfernt um die Datatable-Performance zu verbessern
|
||||
|
||||
/**
|
||||
* Extrahiert alle User aus TreeCalcBotOptimized-Struktur für DataTable-Anzeige
|
||||
* Sammelt rekursiv alle User aus der Struktur und macht sie als flache Liste verfügbar
|
||||
* Sammelt rekursiv alle User aus der Struktur und macht sie als FLACHE Liste verfügbar
|
||||
*/
|
||||
public function getTeamUsersFromStructure(TreeCalcBotOptimized $treeCalcBot): array
|
||||
{
|
||||
$allUsers = [];
|
||||
$deep = 0;
|
||||
$processedIds = [];
|
||||
|
||||
// Debug: Prüfe TreeCalcBot-Inhalt
|
||||
$businessUsers = $treeCalcBot->getItems();
|
||||
\Log::info("TeamController: TreeCalcBot items count: " . count($businessUsers));
|
||||
|
||||
// Sammle alle Root-User
|
||||
\Log::info("TeamController: TreeCalcBot root items count: " . count($businessUsers));
|
||||
|
||||
// Sammle alle Root-User UND deren verschachtelte businessUserItems
|
||||
foreach ($businessUsers as $businessUser) {
|
||||
\Log::debug("TeamController: Processing businessUser", [
|
||||
'user_id' => ($businessUser->user_id),
|
||||
// WICHTIG: user_id korrekt über b_user abrufen (Magic Method Problem mit isset())
|
||||
$userId = $businessUser->user_id; // Über __get() Method
|
||||
|
||||
\Log::debug("TeamController: Processing root businessUser", [
|
||||
'user_id' => $userId,
|
||||
'businessUserItems_count' => count($businessUser->businessUserItems ?? []),
|
||||
]);
|
||||
$businessUser->deep = $deep;
|
||||
$allUsers[] = $businessUser;
|
||||
$this->collectUserIdsFromBusinessUser($businessUser, $allUsers, $deep+1, false);
|
||||
// WICHTIG: Root-User selbst hinzufügen (korrigierte user_id Prüfung)
|
||||
//nur User können auch children haben - businessUserItems
|
||||
if ($userId && !isset($processedIds[$userId])) {
|
||||
$processedIds[$userId] = true;
|
||||
$businessUser->deep = 0;
|
||||
$allUsers[] = $businessUser;
|
||||
$this->collectAllBusinessUserItemsFlat($businessUser->businessUserItems ?? [], $allUsers, $processedIds, 1);
|
||||
\Log::debug("TeamController: Root-User hinzugefügt: {$userId}");
|
||||
}
|
||||
}
|
||||
// Sammle parentless User
|
||||
// Sammle parentless User, kann bei usern eigenlich nicht vorkommen, da sie immer teil des baums sind
|
||||
if ($treeCalcBot->isParentless()) {
|
||||
$parentless = $treeCalcBot->__get('parentless');
|
||||
//\Log::info("TeamController: Found " . count($parentless) . " parentless users");
|
||||
|
||||
if (is_array($parentless)) {
|
||||
foreach ($parentless as $businessUser) {
|
||||
if ($businessUser) {
|
||||
$businessUser->deep = 0;
|
||||
$allUsers[] = $businessUser;
|
||||
|
||||
// Sammle rekursiv alle Unter-User
|
||||
$this->collectUserIdsFromBusinessUser($businessUser, $allUsers, 0, true);
|
||||
// WICHTIG: user_id korrekt über b_user abrufen (Magic Method Problem mit isset())
|
||||
$userId = $businessUser->user_id; // Über __get() Method
|
||||
|
||||
if ($userId) {
|
||||
// Prüfe ob dieser parentless User bereits gesammelt wurde
|
||||
if (!isset($processedIds[$userId])) {
|
||||
$processedIds[$userId] = true;
|
||||
$businessUser->deep = 0;
|
||||
$allUsers[] = $businessUser;
|
||||
|
||||
\Log::debug("TeamController: Parentless-User hinzugefügt: {$userId}");
|
||||
|
||||
// Sammle ALLE verschachtelten businessUserItems rekursiv
|
||||
$this->collectAllBusinessUserItemsFlat($businessUser->businessUserItems ?? [], $allUsers, $processedIds, 1);
|
||||
} else {
|
||||
\Log::debug("TeamController: Parentless-User übersprungen: {$userId} (bereits verarbeitet)");
|
||||
}
|
||||
} else {
|
||||
\Log::warning("TeamController: Parentless BusinessUser ohne user_id übersprungen");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\Log::info("TeamController: AllUsers before filtering: " . count($allUsers));
|
||||
|
||||
// Filter anwenden
|
||||
$filteredUsers = $this->applyTeamFiltersToBusinessUsers($allUsers);
|
||||
\Log::info("TeamController: AllUsers after filtering: " . count($filteredUsers));
|
||||
|
||||
|
||||
return $filteredUsers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wendet Team-Filter auf BusinessUser-Objekte an
|
||||
*/
|
||||
|
|
@ -910,9 +927,9 @@ class TeamController extends Controller
|
|||
$activeFilter = Request::get('team_user_filter_active') ?: session('team_user_filter_active', 1);
|
||||
$levelFilter = Request::get('team_user_filter_level') ?: session('team_user_filter_level', 0);
|
||||
$nextLevelFilter = Request::get('team_user_filter_next_level') ?: session('team_user_filter_next_level', 0);
|
||||
|
||||
|
||||
\Log::info("TeamController: Applying filters - Active: {$activeFilter}, Level: {$levelFilter}, NextLevel: {$nextLevelFilter}");
|
||||
|
||||
|
||||
// Debug: Zeige verfügbare Eigenschaften des ersten BusinessUsers
|
||||
if (!empty($businessUsers)) {
|
||||
$firstUser = $businessUsers[0];
|
||||
|
|
@ -924,8 +941,8 @@ class TeamController extends Controller
|
|||
'next_can_user_level' => isset($firstUser->next_can_user_level) ? 'set' : 'not set',
|
||||
]);
|
||||
}
|
||||
|
||||
$filtered = array_filter($businessUsers, function($businessUser) use ($activeFilter, $levelFilter, $nextLevelFilter) {
|
||||
|
||||
$filtered = array_filter($businessUsers, function ($businessUser) use ($activeFilter, $levelFilter, $nextLevelFilter) {
|
||||
// Active Filter anwenden
|
||||
if ($activeFilter == 1) { // Nur aktive
|
||||
if (!$businessUser->active_account) {
|
||||
|
|
@ -937,19 +954,19 @@ class TeamController extends Controller
|
|||
}
|
||||
}
|
||||
// activeFilter == 3 bedeutet alle (keine Einschränkung)
|
||||
|
||||
|
||||
// Level Filter anwenden
|
||||
if ($levelFilter && $levelFilter != 0) {
|
||||
if ($businessUser->m_level_id != $levelFilter) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Next Level Filter anwenden
|
||||
if ($nextLevelFilter && $nextLevelFilter != 0) {
|
||||
$hasNextQual = ($businessUser->next_qual_user_level) && $businessUser->next_qual_user_level !== '[]';
|
||||
$hasNextCan = ($businessUser->next_can_user_level) && $businessUser->next_can_user_level !== '[]';
|
||||
|
||||
|
||||
switch ($nextLevelFilter) {
|
||||
case 1: // Qualifiziert (grün) - hat next_qual_user_level
|
||||
if (!$hasNextQual) {
|
||||
|
|
@ -968,35 +985,153 @@ class TeamController extends Controller
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true; // Alle Filter bestanden
|
||||
});
|
||||
|
||||
|
||||
// Array-Indizes neu setzen für korrekte DataTable-Verarbeitung
|
||||
return array_values($filtered);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hilfsmethode zum rekursiven Sammeln von User-IDs aus BusinessUser-Struktur
|
||||
* NEUE OPTIMIERTE Methode: Sammelt ALLE BusinessUserItems in einer flachen Liste
|
||||
* Perfekt für DataTable-Verarbeitung - keine verschachtelte Struktur
|
||||
*/
|
||||
private function collectUserIdsFromBusinessUser($businessUser, &$allUsers, $deep, $parentless): void
|
||||
private function collectAllBusinessUserItemsFlat(array $businessUserItems, &$allUsers, &$processedIds, $depth = 1): void
|
||||
{
|
||||
if (isset($businessUser->businessUserItems) && is_array($businessUser->businessUserItems)) {
|
||||
\Log::debug("TeamController: Collecting from businessUser with " . count($businessUser->businessUserItems) . " sub-items");
|
||||
|
||||
foreach ($businessUser->businessUserItems as $subBusinessUser) {
|
||||
if ($subBusinessUser) {
|
||||
$subBusinessUser->deep = $deep;
|
||||
$allUsers[] = $subBusinessUser;
|
||||
if($subBusinessUser->user_id){
|
||||
\Log::debug("TeamController: Collected user ID: " . $subBusinessUser->user_id);
|
||||
// Schutz vor zu tiefer Rekursion (maximale Tiefe: 20 Levels)
|
||||
$maxDepth = 20;
|
||||
if ($depth > $maxDepth) {
|
||||
\Log::warning("TeamController: Maximale Sammlungstiefe ({$maxDepth}) erreicht bei Tiefe {$depth}");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($businessUserItems as $businessUserItem) {
|
||||
if ($businessUserItem) {
|
||||
// WICHTIG: user_id korrekt über b_user abrufen (Magic Method Problem mit isset())
|
||||
$userId = $businessUserItem->user_id; // Über __get() Method
|
||||
if ($userId) {
|
||||
// KRITISCHER SCHUTZ: Prüfe ob User bereits gesammelt wurde
|
||||
if (isset($processedIds[$userId])) {
|
||||
\Log::debug("TeamController: Überspringe bereits gesammelten User {$userId} (Duplikat verhindert)");
|
||||
continue;
|
||||
}
|
||||
// Rekursiver Aufruf für weitere Unter-User
|
||||
$newDeep = $parentless ? 0 : $deep+1;
|
||||
$this->collectUserIdsFromBusinessUser($subBusinessUser, $allUsers, $newDeep, $parentless);
|
||||
|
||||
// User zu flacher Liste hinzufügen
|
||||
$processedIds[$userId] = true;
|
||||
$businessUserItem->deep = $depth;
|
||||
$allUsers[] = $businessUserItem;
|
||||
|
||||
\Log::debug("TeamController: Flach gesammelt - User ID: {$userId} at depth {$depth}");
|
||||
|
||||
// Rekursiv ALLE verschachtelten businessUserItems sammeln
|
||||
if (isset($businessUserItem->businessUserItems) && is_array($businessUserItem->businessUserItems) && !empty($businessUserItem->businessUserItems)) {
|
||||
\Log::debug("TeamController: Sammle " . count($businessUserItem->businessUserItems) . " verschachtelte Items von User {$userId}");
|
||||
$this->collectAllBusinessUserItemsFlat($businessUserItem->businessUserItems, $allUsers, $processedIds, $depth + 1);
|
||||
}
|
||||
} else {
|
||||
\Log::warning("TeamController: BusinessUserItem ohne user_id bei Tiefe {$depth} übersprungen");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATED: Alte Methode zum rekursiven Sammeln von User-IDs aus BusinessUser-Struktur
|
||||
* Wird durch collectAllBusinessUserItemsFlat() ersetzt
|
||||
*/
|
||||
private function collectUserIdsFromBusinessUser($businessUser, &$allUsers, $deep, $parentless, &$processedIds = []): void
|
||||
{
|
||||
// Schutz vor zu tiefer Rekursion (maximale Tiefe: 20 Levels)
|
||||
$maxDepth = 20;
|
||||
if ($deep > $maxDepth) {
|
||||
\Log::warning("TeamController: Maximale Sammlungstiefe ({$maxDepth}) erreicht");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($businessUser->businessUserItems) && is_array($businessUser->businessUserItems)) {
|
||||
\Log::debug("TeamController: Collecting from businessUser with " . count($businessUser->businessUserItems) . " sub-items at depth {$deep}");
|
||||
|
||||
foreach ($businessUser->businessUserItems as $subBusinessUser) {
|
||||
if ($subBusinessUser) {
|
||||
// WICHTIG: user_id korrekt über b_user abrufen (Magic Method Problem mit isset())
|
||||
$userId = $subBusinessUser->user_id; // Über __get() Method
|
||||
|
||||
if ($userId) {
|
||||
// KRITISCHER BUGFIX: Prüfe ob User bereits gesammelt wurde
|
||||
if (isset($processedIds[$userId])) {
|
||||
\Log::debug("TeamController: Überspringe bereits gesammelten User {$userId} (zirkuläre Referenz verhindert)");
|
||||
continue;
|
||||
}
|
||||
|
||||
$processedIds[$userId] = true;
|
||||
$subBusinessUser->deep = $deep;
|
||||
$allUsers[] = $subBusinessUser;
|
||||
|
||||
\Log::debug("TeamController: Collected user ID: {$userId} at depth {$deep}");
|
||||
|
||||
// Rekursiver Aufruf für weitere Unter-User mit Schutz vor Zyklen
|
||||
$newDeep = $parentless ? 0 : $deep + 1;
|
||||
$this->collectUserIdsFromBusinessUser($subBusinessUser, $allUsers, $newDeep, $parentless, $processedIds);
|
||||
} else {
|
||||
\Log::warning("TeamController: SubBusinessUser ohne user_id bei Tiefe {$deep} übersprungen");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* KRITISCHE METHODE: Bereinigt BusinessUserItemOptimized Objekte für DataTables
|
||||
* Entfernt zirkuläre Referenzen und extrahiert nur nötige Properties
|
||||
*/
|
||||
private function cleanBusinessUserItemsForDataTable(array $businessUserItems): array
|
||||
{
|
||||
$cleanedUsers = [];
|
||||
|
||||
foreach ($businessUserItems as $businessUserItem) {
|
||||
if (!$businessUserItem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
// Extrahiere nur die Properties, die für DataTable benötigt werden
|
||||
$cleanedUser = new \stdClass();
|
||||
|
||||
// Basis Properties (direkt über Magic Method __get)
|
||||
$cleanedUser->user_id = $businessUserItem->user_id;
|
||||
$cleanedUser->m_account = $businessUserItem->m_account;
|
||||
$cleanedUser->email = $businessUserItem->email;
|
||||
$cleanedUser->first_name = $businessUserItem->first_name;
|
||||
$cleanedUser->last_name = $businessUserItem->last_name;
|
||||
$cleanedUser->user_level_name = $businessUserItem->user_level_name;
|
||||
$cleanedUser->active_account = $businessUserItem->active_account;
|
||||
$cleanedUser->active_date = $businessUserItem->active_date;
|
||||
|
||||
// Sales Volume Properties
|
||||
$cleanedUser->sales_volume_points_KP_sum = $businessUserItem->sales_volume_points_KP_sum ?? 0;
|
||||
$cleanedUser->payline_points_qual_kp = $businessUserItem->payline_points_qual_kp ?? 0;
|
||||
|
||||
// Depth für Debug/Sortierung (falls gesetzt)
|
||||
$cleanedUser->deep = $businessUserItem->deep ?? 0;
|
||||
|
||||
// Level-Informationen für Filter
|
||||
$cleanedUser->m_level_id = $businessUserItem->m_level_id;
|
||||
$cleanedUser->next_qual_user_level = $businessUserItem->next_qual_user_level;
|
||||
$cleanedUser->next_can_user_level = $businessUserItem->next_can_user_level;
|
||||
|
||||
$cleanedUsers[] = $cleanedUser;
|
||||
|
||||
\Log::debug("TeamController: Cleaned user {$cleanedUser->user_id} for DataTable");
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("TeamController: Error cleaning BusinessUserItem for DataTable: " . $e->getMessage());
|
||||
// Skip diesen User, statt alles abzubrechen
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
\Log::info("TeamController: Cleaned " . count($cleanedUsers) . " users for DataTable (from " . count($businessUserItems) . " raw items)");
|
||||
|
||||
return $cleanedUsers;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
app/Http/Controllers/UserDataController.php
Executable file → Normal file
0
app/Http/Controllers/UserDataController.php
Executable file → Normal file
0
app/Http/Controllers/UserDeleteController.php
Executable file → Normal file
0
app/Http/Controllers/UserDeleteController.php
Executable file → Normal file
0
app/Http/Controllers/UserLevelController.php
Executable file → Normal file
0
app/Http/Controllers/UserLevelController.php
Executable file → Normal file
0
app/Http/Controllers/UserShopController.php
Executable file → Normal file
0
app/Http/Controllers/UserShopController.php
Executable file → Normal file
0
app/Http/Controllers/UserUpdateEmailController.php
Executable file → Normal file
0
app/Http/Controllers/UserUpdateEmailController.php
Executable file → Normal file
0
app/Http/Controllers/UserUpdatePasswordController.php
Executable file → Normal file
0
app/Http/Controllers/UserUpdatePasswordController.php
Executable file → Normal file
0
app/Http/Controllers/Web/CardController.php
Executable file → Normal file
0
app/Http/Controllers/Web/CardController.php
Executable file → Normal file
4
app/Http/Controllers/Web/CheckoutController.php
Executable file → Normal file
4
app/Http/Controllers/Web/CheckoutController.php
Executable file → Normal file
|
|
@ -243,7 +243,7 @@ class CheckoutController extends Controller
|
|||
// Kreditkarte prüfen
|
||||
if ($payment_method === 'cc') {
|
||||
$result = $this->checkCreditCard($data, $shopping_user, $shopping_order);
|
||||
if (!isset($result['returnstatus']) || $result['returnstatus'] !== 'VALID') {
|
||||
if (!is_array($result) || !isset($result['returnstatus']) || $result['returnstatus'] !== 'VALID') {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
@ -251,7 +251,7 @@ class CheckoutController extends Controller
|
|||
// SEPA prüfen
|
||||
if ($payment_method === 'elv') {
|
||||
$result = $this->checkSepaAccount($data, $shopping_user, $shopping_order);
|
||||
if (!isset($result['returnstatus']) || $result['returnstatus'] !== 'VALID') {
|
||||
if (!is_array($result) || !isset($result['returnstatus']) || $result['returnstatus'] !== 'VALID') {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
app/Http/Controllers/Web/ContactController.php
Executable file → Normal file
0
app/Http/Controllers/Web/ContactController.php
Executable file → Normal file
0
app/Http/Controllers/Web/HomepartyController.php
Executable file → Normal file
0
app/Http/Controllers/Web/HomepartyController.php
Executable file → Normal file
55
app/Http/Controllers/Web/RegisterController.php
Executable file → Normal file
55
app/Http/Controllers/Web/RegisterController.php
Executable file → Normal file
|
|
@ -39,6 +39,18 @@ class RegisterController extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
if (config('app.debug')) {
|
||||
\Log::channel('doamin')->debug('RegisterController: index - Session user_shop', [
|
||||
'session_user_shop_id' => \Session::get('user_shop')?->id,
|
||||
'session_user_shop_name' => \Session::get('user_shop')?->name,
|
||||
'session_user_shop_user_id' => \Session::get('user_shop')?->user_id,
|
||||
'session_id' => \Session::getId(),
|
||||
'session_domain' => config('session.domain'),
|
||||
'request_host' => request()->getHost(),
|
||||
'all_session_keys' => array_keys(\Session::all())
|
||||
]);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'GOOGLE_ReCAPTCHA_KEY' => $this->GOOGLE_ReCAPTCHA_KEY,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
|
|
@ -49,12 +61,12 @@ class RegisterController extends Controller
|
|||
|
||||
public function member($member_id = false)
|
||||
{
|
||||
if(!$member_id){
|
||||
if (!$member_id) {
|
||||
return redirect('/registrierung');
|
||||
}
|
||||
$user_id = (int) str_replace('m', '', $member_id) - config('mivita.add_number_id');
|
||||
$user = User::find($user_id);
|
||||
if(!$user || !$user->isActive() || !$user->isActiveAccount()){
|
||||
if (!$user || !$user->isActive() || !$user->isActiveAccount()) {
|
||||
return redirect('/registrierung');
|
||||
}
|
||||
$data = [
|
||||
|
|
@ -66,22 +78,23 @@ class RegisterController extends Controller
|
|||
return view('web.templates.registrierung', $data);
|
||||
}
|
||||
|
||||
public function register(){
|
||||
public function register()
|
||||
{
|
||||
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'first_name'=>'required',
|
||||
'last_name'=>'required',
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'email-confirm' => 'required|same:email',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
'password_confirmation' => 'required|string|min:6',
|
||||
'g-recaptcha-response'=>'required|recaptcha',
|
||||
'g-recaptcha-response' => 'required|recaptcha',
|
||||
'accepted_data_protection' => 'required',
|
||||
);
|
||||
|
||||
Validator::extend('recaptcha', function($attribute, $value, $parameters, $validator) {
|
||||
return $this->reCaptcha_validate($attribute, $value, $parameters, $validator);
|
||||
Validator::extend('recaptcha', function ($attribute, $value, $parameters, $validator) {
|
||||
return $this->reCaptcha_validate($attribute, $value, $parameters, $validator);
|
||||
});
|
||||
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
|
@ -90,16 +103,15 @@ class RegisterController extends Controller
|
|||
}
|
||||
|
||||
$user_shop = Util::getUserShop();
|
||||
|
||||
$data = Request::all();
|
||||
$user = $this->userRepo->create($data);
|
||||
|
||||
$confirmation_code = UserService::createConfirmationCode();
|
||||
$m_sponsor_id = 1;
|
||||
if($user_shop){
|
||||
if ($user_shop) {
|
||||
$m_sponsor_id = $user_shop->user->id;
|
||||
}
|
||||
if(isset($data['from_member_id'])){
|
||||
if (isset($data['from_member_id'])) {
|
||||
$m_sponsor_id = (int) str_replace('m', '', $data['from_member_id']) - config('mivita.add_number_id');
|
||||
}
|
||||
$user->lang = !empty(\App::getLocale()) ? \App::getLocale() : "de";
|
||||
|
|
@ -109,22 +121,19 @@ class RegisterController extends Controller
|
|||
$user->m_sponsor = $m_sponsor_id;
|
||||
|
||||
$UserLevel = UserLevel::where('default', 1)->first();
|
||||
if($UserLevel){
|
||||
if ($UserLevel) {
|
||||
$user->m_level = $UserLevel->id;
|
||||
}else{
|
||||
} else {
|
||||
$user->m_level = 10;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$user->save();
|
||||
|
||||
$user->account->data_protection = now();
|
||||
$user->account->save();
|
||||
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailVerifyAccount($confirmation_code, $user));
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailVerifyAccount($confirmation_code, User::find($user->id)));
|
||||
return redirect('/registrierung/finish');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function finish()
|
||||
|
|
@ -135,7 +144,7 @@ class RegisterController extends Controller
|
|||
];
|
||||
return view('web.templates.registrierung_finish', $data);
|
||||
}
|
||||
|
||||
|
||||
private function reCaptcha_validate($attribute, $value, $parameters, $validator)
|
||||
{
|
||||
|
||||
|
|
@ -143,7 +152,8 @@ class RegisterController extends Controller
|
|||
|
||||
$response = $client->post(
|
||||
'https://www.google.com/recaptcha/api/siteverify',
|
||||
['form_params' =>
|
||||
[
|
||||
'form_params' =>
|
||||
[
|
||||
'secret' => $this->GOOGLE_ReCAPTCHA_SECRET,
|
||||
'response' => $value
|
||||
|
|
@ -154,7 +164,4 @@ class RegisterController extends Controller
|
|||
$body = json_decode((string)$response->getBody());
|
||||
return $body->success;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
66
app/Http/Controllers/Web/SiteController.php
Executable file → Normal file
66
app/Http/Controllers/Web/SiteController.php
Executable file → Normal file
|
|
@ -20,7 +20,7 @@ class SiteController extends Controller
|
|||
{
|
||||
$this->setIPInfo();
|
||||
$products = ['aloe-vera-gel-99', 'aloe-vera-saft-500-ml', 'aloe-vera-lippenbalsam'];
|
||||
// $set_products = ['aloe-vera-cleaner-set', 'aloe-vera-koerper-set', 'aloe-vera-repair-set'];
|
||||
// $set_products = ['aloe-vera-cleaner-set', 'aloe-vera-koerper-set', 'aloe-vera-repair-set'];
|
||||
$set_products = ['aloe-vera-koerper-set', 'baby-set', 'aloe-vera-gel-set'];
|
||||
$data = [
|
||||
'products' => Product::whereIn('slug', $products)->where('active', true)->whereJsonContains('show_on', '1')->get(),
|
||||
|
|
@ -34,16 +34,18 @@ class SiteController extends Controller
|
|||
return view('web.index', $data);
|
||||
}
|
||||
|
||||
public function domainCheck(){
|
||||
public function domainCheck()
|
||||
{
|
||||
die("checked");
|
||||
}
|
||||
|
||||
public function changeLang(){
|
||||
public function changeLang()
|
||||
{
|
||||
$data = Request::all();
|
||||
if(isset($data['change_country_id'])){
|
||||
if (isset($data['change_country_id'])) {
|
||||
$mylangs = Shop::getLangChange('webshop');
|
||||
foreach($mylangs as $code => $country){
|
||||
if(strtolower($data['change_country_id']) === strtolower($code)){
|
||||
foreach ($mylangs as $code => $country) {
|
||||
if (strtolower($data['change_country_id']) === strtolower($code)) {
|
||||
\Session::put('user_init_country', strtolower($code));
|
||||
\Session::forget('user_init_country_options');
|
||||
\Session::put('locale', strtolower($data['change_locale_id']));
|
||||
|
|
@ -58,41 +60,41 @@ class SiteController extends Controller
|
|||
{
|
||||
//wurde schon gesetzt //cache
|
||||
$country = strtolower(Shop::getIPDatabaseInfo());
|
||||
if(\Session::has('user_init_country')){
|
||||
if (\Session::has('user_init_country')) {
|
||||
return;
|
||||
}
|
||||
if(config('app.ipinfo')){
|
||||
if (config('app.ipinfo')) {
|
||||
$country = strtolower(Shop::getIPDatabaseInfo());
|
||||
if($country === 'de'){ //$locale de - init AT
|
||||
if ($country === 'de') { //$locale de - init AT
|
||||
\Session::put('user_init_country', $country);
|
||||
return;
|
||||
}
|
||||
if($country === 'error'){ //$locale at - init AT
|
||||
if ($country === 'error') { //$locale at - init AT
|
||||
$country = 'de';
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$country = 'de';
|
||||
}
|
||||
}
|
||||
|
||||
//$locale = strtolower(\App::getLocale());
|
||||
//ist default
|
||||
|
||||
|
||||
//sprache
|
||||
if(array_key_exists($country, \App\Services\UserService::getTransChange())){
|
||||
if (array_key_exists($country, \App\Services\UserService::getTransChange())) {
|
||||
\Session::put('user_init_country', $country);
|
||||
\Session::put('locale', $country);
|
||||
\App::setLocale($country);
|
||||
}else{
|
||||
} else {
|
||||
//default EN
|
||||
\Session::put('user_init_country', 'de');
|
||||
\Session::put('locale', 'de');
|
||||
\App::setLocale('de');
|
||||
}
|
||||
}
|
||||
|
||||
//bestelland / versandland
|
||||
if(array_key_exists($country, Shop::getLangChange('webshop'))){
|
||||
if (array_key_exists($country, Shop::getLangChange('webshop'))) {
|
||||
\Session::put('user_init_country_options', $country);
|
||||
}else{
|
||||
} else {
|
||||
\Session::put('user_init_country_options', 'de');
|
||||
}
|
||||
|
||||
|
|
@ -101,11 +103,10 @@ class SiteController extends Controller
|
|||
|
||||
public function site($site, $subsite = false, $product_slug = false)
|
||||
{
|
||||
|
||||
$this->setIPInfo();
|
||||
$subsite = trim($subsite, '/');
|
||||
$product_slug = trim($product_slug, '/');
|
||||
if($product_slug){
|
||||
if ($product_slug) {
|
||||
$category = Category::where('slug', $subsite)->where('active', true)->first();
|
||||
$product = Product::where('slug', $product_slug)->where('active', true)->whereJsonContains('show_on', '1')->first();
|
||||
if ($category && $product) {
|
||||
|
|
@ -121,13 +122,12 @@ class SiteController extends Controller
|
|||
return view('web.templates.produkte-show', $data);
|
||||
}
|
||||
}
|
||||
|
||||
if($site === 'produkte'){
|
||||
if($subsite || $subsite !== 'alle-produkte') {
|
||||
if ($site == 'produkte') {
|
||||
if ($subsite || $subsite !== 'alle-produkte') {
|
||||
$category = Category::where('slug', $subsite)->where('active', true)->first();
|
||||
if ($category) {
|
||||
$headline_image = false;
|
||||
if($category->headline_image_id && $category->iq_image && $category->iq_image->active){
|
||||
if ($category->headline_image_id && $category->iq_image && $category->iq_image->active) {
|
||||
$headline_image = $category->iq_image;
|
||||
}
|
||||
|
||||
|
|
@ -148,9 +148,9 @@ class SiteController extends Controller
|
|||
'yard_instance' => 'webshop',
|
||||
];
|
||||
return view('web.templates.' . $site, $data);
|
||||
|
||||
}
|
||||
}
|
||||
dd($subsite);
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'mylangs' => Shop::getLangChange('webshop'),
|
||||
|
|
@ -163,22 +163,22 @@ class SiteController extends Controller
|
|||
'headline_image' => false,
|
||||
'yard_instance' => 'webshop',
|
||||
];
|
||||
return view('web.templates.'.$site, $data);
|
||||
return view('web.templates.' . $site, $data);
|
||||
}
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'mylangs' => Shop::getLangChange('webshop'),
|
||||
'yard_instance' => 'webshop',
|
||||
];
|
||||
if($subsite){
|
||||
if(!view()->exists('web.templates.'.$subsite)){
|
||||
];
|
||||
if ($subsite) {
|
||||
if (!view()->exists('web.templates.' . $subsite)) {
|
||||
abort(404);
|
||||
}
|
||||
return view('web.templates.'.$subsite, $data);
|
||||
return view('web.templates.' . $subsite, $data);
|
||||
}
|
||||
if(!view()->exists('web.templates.'.$site)){
|
||||
if (!view()->exists('web.templates.' . $site)) {
|
||||
abort(404);
|
||||
}
|
||||
return view('web.templates.'.$site, $data);
|
||||
return view('web.templates.' . $site, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
204
app/Http/Controllers/WizardController.php
Executable file → Normal file
204
app/Http/Controllers/WizardController.php
Executable file → Normal file
|
|
@ -38,17 +38,16 @@ class WizardController extends Controller
|
|||
public function __construct(FileRepository $fileRepo)
|
||||
{
|
||||
$this->fileRepo = $fileRepo;
|
||||
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
if(!Auth::check()){
|
||||
if (!Auth::check()) {
|
||||
return redirect('login');
|
||||
}
|
||||
|
||||
$user = User::findOrFail(Auth::user()->id);
|
||||
if(!$user->account){
|
||||
if (!$user->account) {
|
||||
$account = UserAccount::create([]);
|
||||
$user->account_id = $account->id;
|
||||
$user->save();
|
||||
|
|
@ -57,7 +56,7 @@ class WizardController extends Controller
|
|||
|
||||
$step = !$user->wizard ? 0 : $user->wizard;
|
||||
|
||||
if($step >= 20){
|
||||
if ($step >= 20) {
|
||||
return redirect('/home');
|
||||
}
|
||||
$userHistoryWizardPayment = UserHistory::whereUserId($user->id)->whereAction('wizard_payment')->get()->last();
|
||||
|
|
@ -70,7 +69,7 @@ class WizardController extends Controller
|
|||
'userHistoryWizardPayment' => $userHistoryWizardPayment,
|
||||
];
|
||||
|
||||
if($step == 15){
|
||||
if ($step == 15) {
|
||||
return view('user.wizard.create_release', $data);
|
||||
}
|
||||
|
||||
|
|
@ -80,11 +79,11 @@ class WizardController extends Controller
|
|||
public function register()
|
||||
{
|
||||
|
||||
if(!Auth::check()){
|
||||
if (!Auth::check()) {
|
||||
return redirect('login');
|
||||
}
|
||||
$user = User::findOrFail(Auth::user()->id);
|
||||
if(!$user->account){
|
||||
if (!$user->account) {
|
||||
$account = UserAccount::create([]);
|
||||
$user->account_id = $account->id;
|
||||
$user->save();
|
||||
|
|
@ -93,7 +92,7 @@ class WizardController extends Controller
|
|||
|
||||
$step = !$user->wizard ? 0 : $user->wizard;
|
||||
|
||||
if($step >= 10){
|
||||
if ($step >= 10) {
|
||||
return redirect('/home');
|
||||
}
|
||||
|
||||
|
|
@ -103,8 +102,8 @@ class WizardController extends Controller
|
|||
'products' => Product::where('active', true)->whereJsonContains('show_on', ['7', '8'])->orderBy('pos', 'ASC')->get(),
|
||||
'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '9')->orderBy('pos', 'ASC')->get(),
|
||||
];
|
||||
if($step == 5){
|
||||
if($user->active){
|
||||
if ($step == 5) {
|
||||
if ($user->active) {
|
||||
$user->active = false;
|
||||
$user->save();
|
||||
}
|
||||
|
|
@ -116,12 +115,12 @@ class WizardController extends Controller
|
|||
|
||||
public function payment()
|
||||
{
|
||||
if(!Auth::check()){
|
||||
if (!Auth::check()) {
|
||||
return redirect('login');
|
||||
}
|
||||
|
||||
$user = User::findOrFail(Auth::user()->id);
|
||||
if(!$user->account){
|
||||
if (!$user->account) {
|
||||
$account = UserAccount::create([]);
|
||||
$user->account_id = $account->id;
|
||||
$user->save();
|
||||
|
|
@ -129,9 +128,9 @@ class WizardController extends Controller
|
|||
}
|
||||
|
||||
$userHistoryWizardPayment = UserHistory::whereUserId($user->id)->whereAction('wizard_payment')->get()->last();
|
||||
|
||||
|
||||
$shipping_country_id = $this->checkShoppingCountry($user);
|
||||
if(!$shipping_country_id){
|
||||
if (!$shipping_country_id) {
|
||||
abort(403, __('validation.custom.shipping_not_found'));
|
||||
}
|
||||
|
||||
|
|
@ -149,23 +148,24 @@ class WizardController extends Controller
|
|||
];
|
||||
|
||||
|
||||
if($user->wizard == 20){
|
||||
if ($user->wizard == 20) {
|
||||
return view('user.wizard.register_payment', $data);
|
||||
}
|
||||
|
||||
return redirect(route('/'));
|
||||
return redirect(url('/'));
|
||||
}
|
||||
|
||||
private function checkShoppingCountry($user ){
|
||||
private function checkShoppingCountry($user)
|
||||
{
|
||||
|
||||
$country_id = null;
|
||||
if($user->account->same_as_billing){
|
||||
if ($user->account->same_as_billing) {
|
||||
$country_id = $user->account->country_id;
|
||||
}else{
|
||||
} else {
|
||||
$country_id = $user->account->shipping_country_id;
|
||||
}
|
||||
if($country_id){
|
||||
if($shipping_country = ShippingCountry::whereCountryId($country_id)->first()){
|
||||
if ($country_id) {
|
||||
if ($shipping_country = ShippingCountry::whereCountryId($country_id)->first()) {
|
||||
return $shipping_country->id;
|
||||
}
|
||||
}
|
||||
|
|
@ -185,7 +185,7 @@ class WizardController extends Controller
|
|||
|
||||
|
||||
$data = Request::all();
|
||||
if($step == 7 && Request::get('user_country_id')){
|
||||
if ($step == 7 && Request::get('user_country_id')) {
|
||||
$user->account->country_id = Request::get('user_country_id');
|
||||
$user->account->save();
|
||||
return redirect(route('wizard_register', [1]));
|
||||
|
|
@ -209,14 +209,14 @@ class WizardController extends Controller
|
|||
return view('user.wizard.register', $data)->withErrors($validator);
|
||||
}
|
||||
$account = $user->account;
|
||||
if($account->accepted_contract === null){
|
||||
if ($account->accepted_contract === null) {
|
||||
$account->accepted_contract = now();
|
||||
}
|
||||
if($account->data_protection === null){
|
||||
if ($account->data_protection === null) {
|
||||
$account->data_protection = now();
|
||||
}
|
||||
$account->save();
|
||||
if($user->agreement === null){
|
||||
if ($user->agreement === null) {
|
||||
$user->agreement = now();
|
||||
}
|
||||
|
||||
|
|
@ -227,20 +227,20 @@ class WizardController extends Controller
|
|||
if ($step == 1) {
|
||||
|
||||
$data = Request::all();
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_validate"){
|
||||
if (isset($data['action']) && $data['action'] == "reverse_charge_validate") {
|
||||
$user->wizard = 1;
|
||||
$user->save();
|
||||
$userRepo = new UserRepository($user);
|
||||
return $userRepo->reverse_charge_validate($data, $user, route('wizard_register', [0]));
|
||||
}
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_delete"){
|
||||
|
||||
if (isset($data['action']) && $data['action'] == "reverse_charge_delete") {
|
||||
$user->wizard = 1;
|
||||
$user->save();
|
||||
$userRepo = new UserRepository($user);
|
||||
return $userRepo->reverse_charge_delete($data, $user, route('wizard_register', [0]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'first_name' => 'required',
|
||||
|
|
@ -282,31 +282,31 @@ class WizardController extends Controller
|
|||
}
|
||||
|
||||
if ($step == 2) {
|
||||
if(Request::get('submit') === 'do'){
|
||||
if(File::whereUserId($user->id)->whereIdentifier('id_card')->count() == 0){
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
$validator->errors()->add('field', __('msg.no_id_card_deposited_please_upload_first'));
|
||||
$user->wizard = 2;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
$user->wizard = 3;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register'));
|
||||
}
|
||||
if (Request::get('submit') === 'do') {
|
||||
if (File::whereUserId($user->id)->whereIdentifier('id_card')->count() == 0) {
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
$validator->errors()->add('field', __('msg.no_id_card_deposited_please_upload_first'));
|
||||
$user->wizard = 2;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
$user->wizard = 3;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register'));
|
||||
}
|
||||
$this->fileRepo->_set('disk', 'user');
|
||||
$this->fileRepo->_set('dir', '/'.$user->id.'/verification/');
|
||||
$this->fileRepo->_set('dir', '/' . $user->id . '/verification/');
|
||||
$this->fileRepo->_set('user_id', $user->id);
|
||||
$this->fileRepo->_set('identifier', 'id_card');
|
||||
return $this->fileRepo->uploadFile(Request::all());
|
||||
}
|
||||
|
||||
if ($step == 3) {
|
||||
if(Request::get('submit') === 'do'){
|
||||
if (Request::get('submit') === 'do') {
|
||||
$data = Request::all();
|
||||
|
||||
if($data['business_license_choose'] === "now"){
|
||||
if(File::whereUserId($user->id)->whereIdentifier('business_license')->count() == 0){
|
||||
if ($data['business_license_choose'] === "now") {
|
||||
if (File::whereUserId($user->id)->whereIdentifier('business_license')->count() == 0) {
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
$validator->errors()->add('field', __('msg.no_trade_licence_deposited_please_upload_first'));
|
||||
$user->wizard = 3;
|
||||
|
|
@ -314,17 +314,16 @@ class WizardController extends Controller
|
|||
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
}
|
||||
if($data['business_license_choose'] === "later"){
|
||||
|
||||
if ($data['business_license_choose'] === "later") {
|
||||
}
|
||||
if($data['business_license_choose'] === "non"){
|
||||
if(!$data['non_business_license_reason'] || $data['non_business_license_reason'] == ""){
|
||||
if ($data['business_license_choose'] === "non") {
|
||||
if (!$data['non_business_license_reason'] || $data['non_business_license_reason'] == "") {
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
$validator->errors()->add('field', __('msg.please_enter_reason_why_you_not_need_trade_licence'));
|
||||
$user->wizard = 3;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
||||
}else{
|
||||
} else {
|
||||
$user->account->setNotice('business_license_reason', $data['non_business_license_reason']);
|
||||
}
|
||||
}
|
||||
|
|
@ -336,7 +335,7 @@ class WizardController extends Controller
|
|||
return redirect(route('wizard_register'));
|
||||
}
|
||||
$this->fileRepo->_set('disk', 'user');
|
||||
$this->fileRepo->_set('dir', '/'.$user->id.'/verification/');
|
||||
$this->fileRepo->_set('dir', '/' . $user->id . '/verification/');
|
||||
$this->fileRepo->_set('user_id', $user->id);
|
||||
$this->fileRepo->_set('identifier', 'business_license');
|
||||
return $this->fileRepo->uploadFile(Request::all());
|
||||
|
|
@ -371,13 +370,13 @@ class WizardController extends Controller
|
|||
$user->m_sponsor = $user->m_sponsor ? $user->m_sponsor : 1;
|
||||
$user->account->m_first_name = $user->account->m_first_name ? $user->account->m_first_name : $user->account->first_name;
|
||||
$user->account->m_last_name = $user->account->m_last_name ? $user->account->m_last_name : $user->account->last_name;
|
||||
$user->account->m_account = UserAccount::withTrashed()->max('m_account') +1;
|
||||
$user->account->m_account = UserAccount::withTrashed()->max('m_account') + 1;
|
||||
$user->account->save();
|
||||
$user->save();
|
||||
//create PDF
|
||||
$pdf = new ContractPDFRepository($user);
|
||||
$pdf->_set('disk', 'user');
|
||||
$pdf->_set('dir', '/'.$user->id.'/documents/');
|
||||
$pdf->_set('dir', '/' . $user->id . '/documents/');
|
||||
$pdf->_set('user_id', $user->id);
|
||||
$pdf->_set('identifier', 'contract');
|
||||
$pdf->createContractPDF();
|
||||
|
|
@ -393,15 +392,15 @@ class WizardController extends Controller
|
|||
$user->save();
|
||||
|
||||
//mail with code to user?
|
||||
if($user->isTestMode()){
|
||||
if ($user->isTestMode()) {
|
||||
$mail = config('app.info_test_mail');
|
||||
}else{
|
||||
} else {
|
||||
$mail = config('app.info_mail');
|
||||
}
|
||||
Mail::to($mail)->locale($user->getLocale())->send(new MailAutoReleaseAccount($user));
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'release_account', 'status'=>0]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action' => 'release_account', 'status' => 0]);
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailAccountActive($user));
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'released_completed', 'status'=>0]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action' => 'released_completed', 'status' => 0]);
|
||||
\Session()->flash('alert-success', __('msg.account_released'));
|
||||
return redirect(route('wizard_payment'));
|
||||
}
|
||||
|
|
@ -409,16 +408,16 @@ class WizardController extends Controller
|
|||
public function storeCreate($step = 0)
|
||||
{
|
||||
|
||||
if(!Auth::check()){
|
||||
if (!Auth::check()) {
|
||||
return redirect('login');
|
||||
}
|
||||
|
||||
$user = User::findOrFail(Auth::user()->id);
|
||||
if(!$user->account){
|
||||
if (!$user->account) {
|
||||
$user->account = new UserAccount();
|
||||
}
|
||||
|
||||
if($step == 10){
|
||||
if ($step == 10) {
|
||||
$rules = array(
|
||||
'accepted_data_protection' => 'required',
|
||||
'accepted_active' => 'required',
|
||||
|
|
@ -434,17 +433,16 @@ class WizardController extends Controller
|
|||
$user->wizard = 10;
|
||||
$user->save();
|
||||
return view('user.wizard.create', $data)->withErrors($validator);
|
||||
|
||||
}
|
||||
$account = $user->account;
|
||||
if($account->accepted_contract === null){
|
||||
if ($account->accepted_contract === null) {
|
||||
$account->accepted_contract = now();
|
||||
}
|
||||
if($account->data_protection === null){
|
||||
if ($account->data_protection === null) {
|
||||
$account->data_protection = now();
|
||||
}
|
||||
$account->save();
|
||||
if($user->agreement === null){
|
||||
if ($user->agreement === null) {
|
||||
$user->agreement = now();
|
||||
}
|
||||
$user->wizard = 11;
|
||||
|
|
@ -452,9 +450,9 @@ class WizardController extends Controller
|
|||
|
||||
return redirect(route('wizard_create', [11]));
|
||||
}
|
||||
if($step == 11){
|
||||
if ($step == 11) {
|
||||
|
||||
if($user->isPasswort()){
|
||||
if ($user->isPasswort()) {
|
||||
$user->wizard = 12;
|
||||
$user->save();
|
||||
return redirect(route('wizard_create', [12]));
|
||||
|
|
@ -481,23 +479,23 @@ class WizardController extends Controller
|
|||
$user->save();
|
||||
return redirect(route('wizard_create', [12]));
|
||||
}
|
||||
if($step == 12){
|
||||
if ($step == 12) {
|
||||
|
||||
$data = Request::all();
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_validate"){
|
||||
if (isset($data['action']) && $data['action'] == "reverse_charge_validate") {
|
||||
$user->wizard = 12;
|
||||
$user->save();
|
||||
$userRepo = new UserRepository($user);
|
||||
return $userRepo->reverse_charge_validate($data, $user, route('wizard_create', [12]));
|
||||
}
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_delete"){
|
||||
|
||||
if (isset($data['action']) && $data['action'] == "reverse_charge_delete") {
|
||||
$user->wizard = 12;
|
||||
$user->save();
|
||||
$user->save();
|
||||
$userRepo = new UserRepository($user);
|
||||
return $userRepo->reverse_charge_delete($data, $user, route('wizard_create', [12]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rules = array(
|
||||
|
|
@ -513,12 +511,12 @@ class WizardController extends Controller
|
|||
'birthday' => 'required',
|
||||
);
|
||||
|
||||
if(!Request::get('same_as_billing')){
|
||||
if (!Request::get('same_as_billing')) {
|
||||
$rules = array_merge($rules, [
|
||||
'shipping_firstname'=>'required',
|
||||
'shipping_lastname'=>'required',
|
||||
'shipping_address'=>'required',
|
||||
'shipping_zipcode'=>'required',
|
||||
'shipping_firstname' => 'required',
|
||||
'shipping_lastname' => 'required',
|
||||
'shipping_address' => 'required',
|
||||
'shipping_zipcode' => 'required',
|
||||
'shipping_city' => 'required',
|
||||
'shipping_salutation' => 'required'
|
||||
|
||||
|
|
@ -541,59 +539,59 @@ class WizardController extends Controller
|
|||
$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
return redirect(route('wizard_create', [13]));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function storePayment($step = 0){
|
||||
public function storePayment($step = 0)
|
||||
{
|
||||
|
||||
if(Request::get('switchers-package-wizard')){
|
||||
if (Request::get('switchers-package-wizard')) {
|
||||
$user = User::find(Auth::user()->id);
|
||||
Yard::instance('shopping')->destroy();
|
||||
$product = Product::find(Request::get('switchers-package-wizard'));
|
||||
$showAboOptions = false;
|
||||
if(Request::get('abo_options')){
|
||||
if (Request::get('abo_options')) {
|
||||
$showAboOptions = false; //true Abo Option deaktivert
|
||||
$user->abo_options = false; //true Abo Option deaktivert
|
||||
$user->save();
|
||||
}
|
||||
|
||||
$shipping_country_id = $this->checkShoppingCountry($user);
|
||||
if(!$shipping_country_id){
|
||||
if (!$shipping_country_id) {
|
||||
abort(403, __('validation.custom.shipping_not_found'));
|
||||
}
|
||||
|
||||
|
||||
UserService::checkUserTaxShippingCountry($user, $shipping_country_id);
|
||||
Yard::instance('shopping')->setUserPriceInfos(UserService::getYardInfo());
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country_id);
|
||||
|
||||
|
||||
if($product && $product->active){
|
||||
if ($product && $product->active) {
|
||||
//set membership product
|
||||
$image = "";
|
||||
if($product->images->count()){
|
||||
if ($product->images->count()) {
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
if (\App\Services\UserService::getTaxFree()) {
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
} else {
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
|
||||
}
|
||||
|
||||
|
||||
//set onboarding products
|
||||
if(Request::get('products_on_board')){
|
||||
foreach (Request::get('products_on_board') as $product_on_board_id){
|
||||
if (Request::get('products_on_board')) {
|
||||
foreach (Request::get('products_on_board') as $product_on_board_id) {
|
||||
$product_on_board = Product::find($product_on_board_id);
|
||||
$image = "";
|
||||
if($product_on_board->images->count()){
|
||||
if ($product_on_board->images->count()) {
|
||||
$image = $product_on_board->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight, 'points' => $product_on_board->points, 'no_commission' => $product_on_board->no_commission, 'show_on' => $product_on_board->show_on]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
if (\App\Services\UserService::getTaxFree()) {
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
} else {
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
|
||||
}
|
||||
}
|
||||
|
|
@ -601,7 +599,7 @@ class WizardController extends Controller
|
|||
|
||||
do {
|
||||
$identifier = Util::getToken();
|
||||
} while( ShoppingInstance::where('identifier', $identifier)->count() );
|
||||
} while (ShoppingInstance::where('identifier', $identifier)->count());
|
||||
|
||||
$data = [];
|
||||
$data['is_from'] = 'wizard';
|
||||
|
|
@ -622,29 +620,27 @@ class WizardController extends Controller
|
|||
]);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
//add to DB
|
||||
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'wizard_payment', 'status'=>1, 'product_id'=>$product->id, 'identifier'=>$identifier, 'abo_options'=>$showAboOptions]);
|
||||
$path = route('checkout.checkout_card', ['identifier' => $identifier]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action' => 'wizard_payment', 'status' => 1, 'product_id' => $product->id, 'identifier' => $identifier, 'abo_options' => $showAboOptions]);
|
||||
//$path = str_replace('http', 'https', $path);
|
||||
return redirect()->secure($path);
|
||||
|
||||
}
|
||||
}
|
||||
\Session()->flash('alert-error', "Fehler beim Produkt");
|
||||
return back();
|
||||
}
|
||||
|
||||
public function delete($id, $relation){
|
||||
public function delete($id, $relation)
|
||||
{
|
||||
|
||||
if($relation === 'upload'){
|
||||
if ($relation === 'upload') {
|
||||
$user = User::findOrFail(Auth::user()->id);
|
||||
$file = $user->files()->findOrFail($id);
|
||||
//remove file
|
||||
\Storage::disk('user')->delete($file->dir.$file->filename);
|
||||
\Storage::disk('user')->delete($file->dir . $file->filename);
|
||||
$file->delete();
|
||||
\Session()->flash('alert-success', __('msg.file_deleted'));
|
||||
}
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue