Partnercenter: Rollen-Flags fuer Einzelprovision und interne Rollen
- exclude_single_commission: Rollen (z. B. Barkunde 0 %) ziehen den produktseitigen Kunden-Einzelrabatt (single_commission/value_commission) nicht mehr ab. Behebt: 0-%-Rolle zog trotzdem die Produktprovision. - hide_registration: interne Rollen (z. B. Mitarbeiter) werden im Wizard und der Mitgliedschafts-Auswahl ausgeblendet, bleiben im Admin/Lead (HTMLHelper) weiter zuweisbar. - Migration 2026_09_11_100000 (beide Flags, Default false), Model-casts/ fillable, Admin-Formular (2 Checkboxen), Warenkorb-Gate in Yard. - Test tests/Feature/UserLevelSingleCommissionTest.php. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
ef19dc2ced
commit
5e55fa63bb
8 changed files with 752 additions and 521 deletions
|
|
@ -10,13 +10,10 @@ use App\Models\UserLevel;
|
||||||
use App\User;
|
use App\User;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Carbon;
|
use Carbon;
|
||||||
use Config;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Illuminate\Validation\Rules\In;
|
|
||||||
use Request;
|
use Request;
|
||||||
use Util;
|
use Util;
|
||||||
use Yard;
|
use Yard;
|
||||||
use Illuminate\Support\Facades\Mail;
|
|
||||||
|
|
||||||
|
|
||||||
class MembershipController extends Controller
|
class MembershipController extends Controller
|
||||||
{
|
{
|
||||||
|
|
@ -30,14 +27,13 @@ class MembershipController extends Controller
|
||||||
$this->middleware('auth');
|
$this->middleware('auth');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$user = User::find(Auth::user()->id);
|
$user = User::find(Auth::user()->id);
|
||||||
$diff_months = 0;
|
$diff_months = 0;
|
||||||
|
|
||||||
if($user->payment_account){
|
if ($user->payment_account) {
|
||||||
$diff_months = Carbon::now()->diffInMonths(Carbon::parse($user->payment_account)) +1;
|
$diff_months = Carbon::now()->diffInMonths(Carbon::parse($user->payment_account)) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$userHistoryPaymentOrder = UserHistory::whereUserId($user->id)->whereAction('payment_order')->get()->last();
|
$userHistoryPaymentOrder = UserHistory::whereUserId($user->id)->whereAction('payment_order')->get()->last();
|
||||||
|
|
@ -45,27 +41,26 @@ class MembershipController extends Controller
|
||||||
$userHistoryDeleteMembership = UserHistory::whereUserId($user->id)->whereAction('delete_membership')->whereStatus(50)->get()->last();
|
$userHistoryDeleteMembership = UserHistory::whereUserId($user->id)->whereAction('delete_membership')->whereStatus(50)->get()->last();
|
||||||
$data = [
|
$data = [
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
||||||
'upgrade' => Product::where('active', true)->whereJsonContains('show_on', '5')->where('identifier', 'upgrade')->get(),
|
'upgrade' => Product::where('active', true)->whereJsonContains('show_on', '5')->where('identifier', 'upgrade')->get(),
|
||||||
'diff_months' => $diff_months,
|
'diff_months' => $diff_months,
|
||||||
'userHistoryPaymentOrder' => $userHistoryPaymentOrder,
|
'userHistoryPaymentOrder' => $userHistoryPaymentOrder,
|
||||||
'userHistoryUpgradeOrder' => $userHistoryUpgradeOrder,
|
'userHistoryUpgradeOrder' => $userHistoryUpgradeOrder,
|
||||||
'userHistoryDeleteMembership' => $userHistoryDeleteMembership,
|
'userHistoryDeleteMembership' => $userHistoryDeleteMembership,
|
||||||
'user_levels' => UserLevel::where('active', true)->orderBy('pos')->get(),
|
'user_levels' => UserLevel::where('active', true)->where('hide_registration', false)->orderBy('pos')->get(),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return view('user.membership.index', $data);
|
return view('user.membership.index', $data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function storePayment($action){
|
public function storePayment($action)
|
||||||
|
{
|
||||||
|
|
||||||
$data = Request::all();
|
$data = Request::all();
|
||||||
|
|
||||||
|
// #### remove_abo
|
||||||
|
|
||||||
//#### remove_abo
|
|
||||||
/*if($action === "remove_abo"){
|
/*if($action === "remove_abo"){
|
||||||
if(Request::get('abo_options_remove')){
|
if(Request::get('abo_options_remove')){
|
||||||
$user = User::find(Auth::user()->id);
|
$user = User::find(Auth::user()->id);
|
||||||
|
|
@ -80,28 +75,28 @@ class MembershipController extends Controller
|
||||||
\Session()->flash('alert-error', "Fehler, Checkbox nicht bestätigt.");
|
\Session()->flash('alert-error', "Fehler, Checkbox nicht bestätigt.");
|
||||||
return back();
|
return back();
|
||||||
}*/
|
}*/
|
||||||
//#### payment order
|
// #### payment order
|
||||||
//#### shop upgrade
|
// #### shop upgrade
|
||||||
if($action === "upgrade_order" || $action === "payment_order"){
|
if ($action === 'upgrade_order' || $action === 'payment_order') {
|
||||||
if(Request::get('switchers-package-wizard')){
|
if (Request::get('switchers-package-wizard')) {
|
||||||
$user = User::find(Auth::user()->id);
|
$user = User::find(Auth::user()->id);
|
||||||
Yard::instance('shopping')->destroy();
|
Yard::instance('shopping')->destroy();
|
||||||
$product = Product::find(Request::get('switchers-package-wizard'));
|
$product = Product::find(Request::get('switchers-package-wizard'));
|
||||||
// $showAboOptions = false;
|
// $showAboOptions = false;
|
||||||
/* if(Request::get('abo_options')){
|
/* if(Request::get('abo_options')){
|
||||||
$showAboOptions = true;
|
$showAboOptions = true;
|
||||||
$user->abo_options = true;
|
$user->abo_options = true;
|
||||||
$user->save();
|
$user->save();
|
||||||
}*/
|
}*/
|
||||||
if($product && $product->active){
|
if ($product && $product->active) {
|
||||||
$image = "";
|
$image = '';
|
||||||
if($product->images->count()){
|
if ($product->images->count()) {
|
||||||
$image = $product->images->first()->slug;
|
$image = $product->images->first()->slug;
|
||||||
}
|
}
|
||||||
$qty = Request::get('qty') ? Request::get('qty') : 1;
|
$qty = Request::get('qty') ? Request::get('qty') : 1;
|
||||||
|
|
||||||
/* //need setGlobalTaxRate
|
/* //need setGlobalTaxRate
|
||||||
|
|
||||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $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]);
|
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $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]);
|
||||||
if(\App\Services\UserService::getTaxFree()){
|
if(\App\Services\UserService::getTaxFree()){
|
||||||
Yard::setTax($cartItem->rowId, 0);
|
Yard::setTax($cartItem->rowId, 0);
|
||||||
|
|
@ -109,7 +104,7 @@ class MembershipController extends Controller
|
||||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
|
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//Keine steuer
|
// Keine steuer
|
||||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->price, $product->tax, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->price, $product->tax, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||||
Yard::instance('shopping')->setGlobalTaxRate(0);
|
Yard::instance('shopping')->setGlobalTaxRate(0);
|
||||||
/*
|
/*
|
||||||
|
|
@ -122,27 +117,27 @@ class MembershipController extends Controller
|
||||||
$data['is_from'] = 'membership';
|
$data['is_from'] = 'membership';
|
||||||
$data['is_for'] = 'me';
|
$data['is_for'] = 'me';
|
||||||
|
|
||||||
/* ShoppingInstance::create([
|
/* ShoppingInstance::create([
|
||||||
'identifier' => $identifier,
|
'identifier' => $identifier,
|
||||||
'user_shop_id' => 1, //is first faker shop for nuy intern
|
'user_shop_id' => 1, //is first faker shop for nuy intern
|
||||||
'auth_user_id' => Auth::user()->id,
|
'auth_user_id' => Auth::user()->id,
|
||||||
'payment' => 3, //Vertriebspartner Membership
|
'payment' => 3, //Vertriebspartner Membership
|
||||||
'subdomain' => url('/'),
|
'subdomain' => url('/'),
|
||||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||||
'shopping_data' => $data,
|
'shopping_data' => $data,
|
||||||
'back' => url()->previous(),
|
'back' => url()->previous(),
|
||||||
|
|
||||||
]);*/
|
]);*/
|
||||||
Yard::instance('shopping')->putYardExtra('shopping_data', $data);
|
Yard::instance('shopping')->putYardExtra('shopping_data', $data);
|
||||||
|
|
||||||
//Yard::instance('shopping')->store($identifier);
|
// Yard::instance('shopping')->store($identifier);
|
||||||
//add to DB
|
// add to DB
|
||||||
UserHistory::create(['user_id' => $user->id, 'action'=>$action, 'status'=>1, 'product_id'=>$product->id, 'identifier'=>$identifier]);
|
UserHistory::create(['user_id' => $user->id, 'action' => $action, 'status' => 1, 'product_id' => $product->id, 'identifier' => $identifier]);
|
||||||
|
|
||||||
//$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
// $path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
||||||
//$path = str_replace('http', 'https', $path);
|
// $path = str_replace('http', 'https', $path);
|
||||||
// return redirect()->secure($path);
|
// return redirect()->secure($path);
|
||||||
return redirect(route('user_checkout', [$identifier]));
|
return redirect(route('user_checkout', [$identifier]));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -169,39 +164,41 @@ class MembershipController extends Controller
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if($action === "change_level"){
|
if ($action === 'change_level') {
|
||||||
if(Request::get('switchers-package-level')){
|
if (Request::get('switchers-package-level')) {
|
||||||
$user = User::find(Auth::user()->id);
|
$user = User::find(Auth::user()->id);
|
||||||
//hier wird die nächste Mitgliedschaftsstufe gesetzt
|
// hier wird die nächste Mitgliedschaftsstufe gesetzt
|
||||||
//wird im Cronjob UserCheckPaymentsAccounts.php verwendet und gesetzt
|
// wird im Cronjob UserCheckPaymentsAccounts.php verwendet und gesetzt
|
||||||
$user->next_m_level = Request::get('switchers-package-level');
|
$user->next_m_level = Request::get('switchers-package-level');
|
||||||
$user->save();
|
$user->save();
|
||||||
UserHistory::create(['user_id' => $user->id, 'action'=>$action, 'status'=>10, 'referenz'=>Request::get('switchers-package-level')]);
|
UserHistory::create(['user_id' => $user->id, 'action' => $action, 'status' => 10, 'referenz' => Request::get('switchers-package-level')]);
|
||||||
\Session()->flash('alert-success', "Änderung gespeichert");
|
\Session()->flash('alert-success', 'Änderung gespeichert');
|
||||||
|
|
||||||
return back();
|
return back();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($action === "delete_membership"){
|
if ($action === 'delete_membership') {
|
||||||
if(Request::get('delete_membership')){
|
if (Request::get('delete_membership')) {
|
||||||
//TODO
|
// TODO
|
||||||
$user = User::find(Auth::user()->id);
|
$user = User::find(Auth::user()->id);
|
||||||
if($user->isTestMode()){
|
if ($user->isTestMode()) {
|
||||||
$mail = config('app.info_test_mail');
|
$mail = config('app.info_test_mail');
|
||||||
}else{
|
} else {
|
||||||
$mail = config('app.info_mail');
|
$mail = config('app.info_mail');
|
||||||
}
|
}
|
||||||
Mail::to($mail)->send(new MailInfo($user, 'delete_membership'));
|
Mail::to($mail)->send(new MailInfo($user, 'delete_membership'));
|
||||||
UserHistory::create(['user_id' => $user->id, 'action'=>$action, 'status'=>50]);
|
UserHistory::create(['user_id' => $user->id, 'action' => $action, 'status' => 50]);
|
||||||
\Session()->flash('alert-success', "Mitgliedschaft beenden ist beantragt");
|
\Session()->flash('alert-success', 'Mitgliedschaft beenden ist beantragt');
|
||||||
|
|
||||||
return back();
|
return back();
|
||||||
}
|
}
|
||||||
\Session()->flash('alert-error', "Fehler, Checkbox nicht bestätigt.");
|
\Session()->flash('alert-error', 'Fehler, Checkbox nicht bestätigt.');
|
||||||
|
|
||||||
return back();
|
return back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,15 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\Attribute;
|
use App\Models\Attribute;
|
||||||
use App\Models\ProductAttribute;
|
use App\Models\ProductAttribute;
|
||||||
use App\Models\Shipping;
|
|
||||||
use App\Models\UserLevel;
|
use App\Models\UserLevel;
|
||||||
use App\Models\UserLevelMargin;
|
use App\Models\UserLevelMargin;
|
||||||
use Request;
|
use Request;
|
||||||
use Validator;
|
use Validator;
|
||||||
|
|
||||||
|
|
||||||
class UserLevelController extends Controller
|
class UserLevelController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->middleware('admin');
|
$this->middleware('admin');
|
||||||
|
|
@ -27,53 +23,59 @@ class UserLevelController extends Controller
|
||||||
'values' => UserLevel::orderBy('pos')->get(),
|
'values' => UserLevel::orderBy('pos')->get(),
|
||||||
'trans' => array_keys(config('localization.supportedLocales')),
|
'trans' => array_keys(config('localization.supportedLocales')),
|
||||||
];
|
];
|
||||||
|
|
||||||
return view('admin.level.index', $data);
|
return view('admin.level.index', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
if($id === "new"){
|
if ($id === 'new') {
|
||||||
$user_level = new UserLevel();
|
$user_level = new UserLevel;
|
||||||
$user_level->active = 1;
|
$user_level->active = 1;
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
$user_level = UserLevel::findOrFail($id);
|
$user_level = UserLevel::findOrFail($id);
|
||||||
|
|
||||||
}
|
}
|
||||||
$data = [
|
$data = [
|
||||||
'value' => $user_level,
|
'value' => $user_level,
|
||||||
];
|
];
|
||||||
|
|
||||||
return view('admin.level.edit', $data);
|
return view('admin.level.edit', $data);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store()
|
public function store()
|
||||||
{
|
{
|
||||||
|
|
||||||
$data = Request::all();
|
$data = Request::all();
|
||||||
|
|
||||||
if($data['action'] === 'user_level') {
|
if ($data['action'] === 'user_level') {
|
||||||
if ($data['id'] === "new") {
|
if ($data['id'] === 'new') {
|
||||||
$user_level = UserLevel::create([
|
$user_level = UserLevel::create([
|
||||||
'name' => $data['name'],
|
'name' => $data['name'],
|
||||||
'pos' => $data['pos'],
|
'pos' => $data['pos'],
|
||||||
'payment_year' => isset($data['payment_year']) ? true : false,
|
'payment_year' => isset($data['payment_year']) ? true : false,
|
||||||
'content' => $data['content'],
|
'content' => $data['content'],
|
||||||
'partner_provision' => isset($data['partner_provision']) ? true : false,
|
'partner_provision' => isset($data['partner_provision']) ? true : false,
|
||||||
|
'exclude_single_commission' => isset($data['exclude_single_commission']) ? true : false,
|
||||||
|
'hide_registration' => isset($data['hide_registration']) ? true : false,
|
||||||
'active' => isset($data['active']) ? true : false,
|
'active' => isset($data['active']) ? true : false,
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$user_level = UserLevel::find($data['id']);
|
$user_level = UserLevel::find($data['id']);
|
||||||
$user_level->name = $data['name'];
|
$user_level->name = $data['name'];
|
||||||
$user_level->pos = $data['pos'];
|
$user_level->pos = $data['pos'];
|
||||||
$user_level->payment_year =isset($data['payment_year']) ? true : false;
|
$user_level->payment_year = isset($data['payment_year']) ? true : false;
|
||||||
$user_level->content = $data['content'];
|
$user_level->content = $data['content'];
|
||||||
$user_level->partner_provision = isset($data['partner_provision']) ? true : false;
|
$user_level->partner_provision = isset($data['partner_provision']) ? true : false;
|
||||||
|
$user_level->exclude_single_commission = isset($data['exclude_single_commission']) ? true : false;
|
||||||
|
$user_level->hide_registration = isset($data['hide_registration']) ? true : false;
|
||||||
$user_level->active = isset($data['active']) ? true : false;
|
$user_level->active = isset($data['active']) ? true : false;
|
||||||
$user_level->save();
|
$user_level->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['trans'])) {
|
if (! empty($data['trans'])) {
|
||||||
$trans = [];
|
$trans = [];
|
||||||
foreach ($data['trans'] as $lang => $value) {
|
foreach ($data['trans'] as $lang => $value) {
|
||||||
if ($value && $value != null) {
|
if ($value && $value != null) {
|
||||||
|
|
@ -87,19 +89,19 @@ class UserLevelController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data['action'] === 'user_level_margin') {
|
if ($data['action'] === 'user_level_margin') {
|
||||||
$user_level = UserLevel::findOrFail($data['user_level_id']);
|
$user_level = UserLevel::findOrFail($data['user_level_id']);
|
||||||
$rules = array('price_from' => 'required');
|
$rules = ['price_from' => 'required'];
|
||||||
$ret = ['value' => $user_level];
|
$ret = ['value' => $user_level];
|
||||||
$validator = Validator::make(Request::all(), $rules);
|
$validator = Validator::make(Request::all(), $rules);
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
return view('admin.level.edit', $ret)->withErrors($validator);
|
return view('admin.level.edit', $ret)->withErrors($validator);
|
||||||
}
|
}
|
||||||
if ($data['id'] === "new") {
|
if ($data['id'] === 'new') {
|
||||||
$user_level_margin = UserLevelMargin::create($data);
|
$user_level_margin = UserLevelMargin::create($data);
|
||||||
} else {
|
} else {
|
||||||
$user_level_margin = UserLevelMargin::findOrFail($data['id']);
|
$user_level_margin = UserLevelMargin::findOrFail($data['id']);
|
||||||
if($user_level_margin->user_level_id != $user_level->id){
|
if ($user_level_margin->user_level_id != $user_level->id) {
|
||||||
abort(404);
|
abort(404);
|
||||||
}
|
}
|
||||||
$user_level_margin->fill($data);
|
$user_level_margin->fill($data);
|
||||||
|
|
@ -108,23 +110,24 @@ class UserLevelController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
\Session()->flash('alert-save', '1');
|
\Session()->flash('alert-save', '1');
|
||||||
|
|
||||||
return redirect(route('admin_level_edit', [$user_level->id]));
|
return redirect(route('admin_level_edit', [$user_level->id]));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($do, $id)
|
public function delete($do, $id)
|
||||||
{
|
{
|
||||||
if($do === 'user_level_margin'){
|
if ($do === 'user_level_margin') {
|
||||||
$model = UserLevelMargin::findOrFail($id);
|
$model = UserLevelMargin::findOrFail($id);
|
||||||
$id = $model->user_level->id;
|
$id = $model->user_level->id;
|
||||||
$model->delete();
|
$model->delete();
|
||||||
\Session()->flash('alert-success', "Eintrag gelöscht");
|
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||||
|
|
||||||
return redirect(route('admin_level_edit', [$id]));
|
return redirect(route('admin_level_edit', [$id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*public function delete($id){
|
/*public function delete($id){
|
||||||
|
|
||||||
if(ProductAttribute::where('attribute_id', $id)->count()){
|
if(ProductAttribute::where('attribute_id', $id)->count()){
|
||||||
|
|
@ -139,4 +142,4 @@ class UserLevelController extends Controller
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,30 +2,28 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
use App\Mail\MailReleaseAccount;
|
||||||
use Hash;
|
|
||||||
use Yard;
|
|
||||||
use Request;
|
|
||||||
use App\User;
|
|
||||||
use Validator;
|
|
||||||
use App\Models\File;
|
use App\Models\File;
|
||||||
use App\Services\Util;
|
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Models\UserLevel;
|
use App\Models\ShoppingInstance;
|
||||||
use App\Models\UserAccount;
|
use App\Models\UserAccount;
|
||||||
use App\Models\UserHistory;
|
use App\Models\UserHistory;
|
||||||
use App\Mail\MailReleaseAccount;
|
use App\Models\UserLevel;
|
||||||
use App\Models\ShoppingInstance;
|
|
||||||
use App\Repositories\FileRepository;
|
use App\Repositories\FileRepository;
|
||||||
use App\Repositories\UserRepository;
|
use App\Repositories\UserRepository;
|
||||||
|
use App\Services\Util;
|
||||||
|
use App\User;
|
||||||
|
use Auth;
|
||||||
|
use Hash;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Request;
|
||||||
|
use Validator;
|
||||||
|
use Yard;
|
||||||
|
|
||||||
class WizardController extends Controller
|
class WizardController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $fileRepo;
|
protected $fileRepo;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new controller instance.
|
* Create a new controller instance.
|
||||||
*
|
*
|
||||||
|
|
@ -39,21 +37,22 @@ class WizardController extends Controller
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
if(!Auth::check()){
|
if (! Auth::check()) {
|
||||||
return redirect('login');
|
return redirect('login');
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::findOrFail(Auth::user()->id);
|
$user = User::findOrFail(Auth::user()->id);
|
||||||
if(!$user->account){
|
if (! $user->account) {
|
||||||
$account = UserAccount::create([]);
|
$account = UserAccount::create([]);
|
||||||
$user->account_id = $account->id;
|
$user->account_id = $account->id;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return redirect(route('wizard_create'));
|
return redirect(route('wizard_create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$step = !$user->wizard ? 0 : $user->wizard;
|
$step = ! $user->wizard ? 0 : $user->wizard;
|
||||||
|
|
||||||
if($step >= 20){
|
if ($step >= 20) {
|
||||||
return redirect('/home');
|
return redirect('/home');
|
||||||
}
|
}
|
||||||
$userHistoryWizardPayment = UserHistory::whereUserId($user->id)->whereAction('wizard_payment')->get()->last();
|
$userHistoryWizardPayment = UserHistory::whereUserId($user->id)->whereAction('wizard_payment')->get()->last();
|
||||||
|
|
@ -61,12 +60,12 @@ class WizardController extends Controller
|
||||||
$data = [
|
$data = [
|
||||||
'user' => Auth::user(),
|
'user' => Auth::user(),
|
||||||
'step' => $step,
|
'step' => $step,
|
||||||
'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
||||||
'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(),
|
'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(),
|
||||||
'userHistoryWizardPayment' => $userHistoryWizardPayment,
|
'userHistoryWizardPayment' => $userHistoryWizardPayment,
|
||||||
];
|
];
|
||||||
|
|
||||||
if($step == 15){
|
if ($step == 15) {
|
||||||
return view('user.wizard.create_release', $data);
|
return view('user.wizard.create_release', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,32 +75,33 @@ class WizardController extends Controller
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!Auth::check()){
|
if (! Auth::check()) {
|
||||||
return redirect('login');
|
return redirect('login');
|
||||||
}
|
}
|
||||||
$user = User::findOrFail(Auth::user()->id);
|
$user = User::findOrFail(Auth::user()->id);
|
||||||
if(!$user->account){
|
if (! $user->account) {
|
||||||
$account = UserAccount::create([]);
|
$account = UserAccount::create([]);
|
||||||
$user->account_id = $account->id;
|
$user->account_id = $account->id;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return redirect(route('wizard_register'));
|
return redirect(route('wizard_register'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$step = !$user->wizard ? 0 : $user->wizard;
|
$step = ! $user->wizard ? 0 : $user->wizard;
|
||||||
|
|
||||||
if($step >= 10){
|
if ($step >= 10) {
|
||||||
return redirect('/home');
|
return redirect('/home');
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'user' => Auth::user(),
|
'user' => Auth::user(),
|
||||||
'step' => $step,
|
'step' => $step,
|
||||||
'user_levels' => UserLevel::where('active', true)->orderBy('pos', 'ASC')->get(),
|
'user_levels' => UserLevel::where('active', true)->where('hide_registration', false)->orderBy('pos', 'ASC')->get(),
|
||||||
//'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
// 'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
||||||
//'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(),
|
// 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(),
|
||||||
|
|
||||||
];
|
];
|
||||||
if($step == 5){
|
if ($step == 5) {
|
||||||
return view('user.wizard.register_release', $data);
|
return view('user.wizard.register_release', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,15 +110,16 @@ class WizardController extends Controller
|
||||||
|
|
||||||
public function payment()
|
public function payment()
|
||||||
{
|
{
|
||||||
if(!Auth::check()){
|
if (! Auth::check()) {
|
||||||
return redirect('login');
|
return redirect('login');
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::findOrFail(Auth::user()->id);
|
$user = User::findOrFail(Auth::user()->id);
|
||||||
if(!$user->account){
|
if (! $user->account) {
|
||||||
$account = UserAccount::create([]);
|
$account = UserAccount::create([]);
|
||||||
$user->account_id = $account->id;
|
$user->account_id = $account->id;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return redirect(route('wizard_payment'));
|
return redirect(route('wizard_payment'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,12 +128,12 @@ class WizardController extends Controller
|
||||||
$data = [
|
$data = [
|
||||||
'user' => Auth::user(),
|
'user' => Auth::user(),
|
||||||
'step' => 0,
|
'step' => 0,
|
||||||
'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
||||||
'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(),
|
'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(),
|
||||||
'userHistoryWizardPayment' => $userHistoryWizardPayment,
|
'userHistoryWizardPayment' => $userHistoryWizardPayment,
|
||||||
];
|
];
|
||||||
|
|
||||||
if($user->wizard == 20){
|
if ($user->wizard == 20) {
|
||||||
return view('user.wizard.register_payment', $data);
|
return view('user.wizard.register_payment', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,74 +143,79 @@ class WizardController extends Controller
|
||||||
public function storeRegister($step = false)
|
public function storeRegister($step = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!Auth::check()) {
|
if (! Auth::check()) {
|
||||||
return redirect('login');
|
return redirect('login');
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::findOrFail(Auth::user()->id);
|
$user = User::findOrFail(Auth::user()->id);
|
||||||
if (!$user->account) {
|
if (! $user->account) {
|
||||||
$user->account = new UserAccount();
|
$user->account = new UserAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = Request::all();
|
$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->country_id = Request::get('user_country_id');
|
||||||
$user->account->save();
|
$user->account->save();
|
||||||
|
|
||||||
return redirect(route('wizard_register', [1]));
|
return redirect(route('wizard_register', [1]));
|
||||||
}
|
}
|
||||||
if ($step == 0) {
|
if ($step == 0) {
|
||||||
$rules = array(
|
$rules = [
|
||||||
'accepted_data_protection' => 'required',
|
'accepted_data_protection' => 'required',
|
||||||
'accepted_active' => 'required',
|
'accepted_active' => 'required',
|
||||||
'accepted_contract' => 'required'
|
'accepted_contract' => 'required',
|
||||||
);
|
];
|
||||||
$validator = Validator::make(Request::all(), $rules);
|
$validator = Validator::make(Request::all(), $rules);
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
$data = [
|
$data = [
|
||||||
'user' => Auth::user(),
|
'user' => Auth::user(),
|
||||||
'step' => $step,
|
'step' => $step,
|
||||||
'user_levels' => UserLevel::where('active', true)->orderBy('pos', 'ASC')->get(),
|
'user_levels' => UserLevel::where('active', true)->where('hide_registration', false)->orderBy('pos', 'ASC')->get(),
|
||||||
//'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
// 'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
||||||
//'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(),,
|
// 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(),,
|
||||||
];
|
];
|
||||||
$user->wizard = 0;
|
$user->wizard = 0;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return view('user.wizard.register', $data)->withErrors($validator);
|
return view('user.wizard.register', $data)->withErrors($validator);
|
||||||
}
|
}
|
||||||
$account = $user->account;
|
$account = $user->account;
|
||||||
if($account->accepted_contract === null){
|
if ($account->accepted_contract === null) {
|
||||||
$account->accepted_contract = now();
|
$account->accepted_contract = now();
|
||||||
}
|
}
|
||||||
if($account->data_protection === null){
|
if ($account->data_protection === null) {
|
||||||
$account->data_protection = now();
|
$account->data_protection = now();
|
||||||
}
|
}
|
||||||
$account->save();
|
$account->save();
|
||||||
if($user->agreement === null){
|
if ($user->agreement === null) {
|
||||||
$user->agreement = now();
|
$user->agreement = now();
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->wizard = 1;
|
$user->wizard = 1;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return redirect(route('wizard_register'));
|
return redirect(route('wizard_register'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($step == 1) {
|
if ($step == 1) {
|
||||||
$data = Request::all();
|
$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->wizard = 1;
|
||||||
$user->save();
|
$user->save();
|
||||||
$userRepo = new UserRepository($user);
|
$userRepo = new UserRepository($user);
|
||||||
|
|
||||||
return $userRepo->reverse_charge_validate($data, $user, route('wizard_register', [1]));
|
return $userRepo->reverse_charge_validate($data, $user, route('wizard_register', [1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($data['action']) && $data['action'] == "reverse_charge_delete"){
|
if (isset($data['action']) && $data['action'] == 'reverse_charge_delete') {
|
||||||
$user->wizard = 1;
|
$user->wizard = 1;
|
||||||
$user->save();
|
$user->save();
|
||||||
$userRepo = new UserRepository($user);
|
$userRepo = new UserRepository($user);
|
||||||
return $userRepo->reverse_charge_delete($data, $user, route('wizard_register', [1]));
|
|
||||||
}
|
|
||||||
|
|
||||||
$rules = array(
|
return $userRepo->reverse_charge_delete($data, $user, route('wizard_register', [1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
$rules = [
|
||||||
'salutation' => 'required',
|
'salutation' => 'required',
|
||||||
'first_name' => 'required',
|
'first_name' => 'required',
|
||||||
'last_name' => 'required',
|
'last_name' => 'required',
|
||||||
|
|
@ -221,9 +227,9 @@ class WizardController extends Controller
|
||||||
'tax_number' => 'required_without:tax_identification_number',
|
'tax_number' => 'required_without:tax_identification_number',
|
||||||
'tax_identification_number' => 'required_without:tax_number',
|
'tax_identification_number' => 'required_without:tax_number',
|
||||||
'country_id' => 'required|integer|min:1',
|
'country_id' => 'required|integer|min:1',
|
||||||
);
|
];
|
||||||
|
|
||||||
if (!Request::get('same_as_billing')) {
|
if (! Request::get('same_as_billing')) {
|
||||||
$rules = array_merge($rules, [
|
$rules = array_merge($rules, [
|
||||||
'shipping_firstname' => 'required',
|
'shipping_firstname' => 'required',
|
||||||
'shipping_lastname' => 'required',
|
'shipping_lastname' => 'required',
|
||||||
|
|
@ -238,73 +244,77 @@ class WizardController extends Controller
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
$user->wizard = 1;
|
$user->wizard = 1;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return redirect(route('wizard_register', [1]))->withErrors($validator)->withInput(Request::all());
|
return redirect(route('wizard_register', [1]))->withErrors($validator)->withInput(Request::all());
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = Request::all();
|
$data = Request::all();
|
||||||
$data['same_as_billing'] = Request::get('same_as_billing') == NULL ? 0 : 1;
|
$data['same_as_billing'] = Request::get('same_as_billing') == null ? 0 : 1;
|
||||||
$data['birthday_day'] = isset($data['birthday_day']) ? $data['birthday_day'] : 1;
|
$data['birthday_day'] = isset($data['birthday_day']) ? $data['birthday_day'] : 1;
|
||||||
$data['birthday_month'] = isset($data['birthday_month']) ? $data['birthday_month'] : 1;
|
$data['birthday_month'] = isset($data['birthday_month']) ? $data['birthday_month'] : 1;
|
||||||
$data['birthday_year'] = isset($data['birthday_year']) ? $data['birthday_year'] : 1900;
|
$data['birthday_year'] = isset($data['birthday_year']) ? $data['birthday_year'] : 1900;
|
||||||
$data['birthday'] = $data['birthday_day'].".".$data['birthday_month'].".".$data['birthday_year'];
|
$data['birthday'] = $data['birthday_day'].'.'.$data['birthday_month'].'.'.$data['birthday_year'];
|
||||||
$data['birthday'] = $data['birthday'] == "1.1.1900" ? null : $data['birthday'];
|
$data['birthday'] = $data['birthday'] == '1.1.1900' ? null : $data['birthday'];
|
||||||
$user->account->fill($data)->save();
|
$user->account->fill($data)->save();
|
||||||
$user->wizard = 2;
|
$user->wizard = 2;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return redirect(route('wizard_register'));
|
return redirect(route('wizard_register'));
|
||||||
}
|
}
|
||||||
/* if ($step == 2) {
|
/* if ($step == 2) {
|
||||||
//kein Ausweis hochladen - deaktiviert
|
//kein Ausweis hochladen - deaktiviert
|
||||||
dd("deaktiviert");
|
dd("deaktiviert");
|
||||||
$user->wizard = 3;
|
$user->wizard = 3;
|
||||||
$user->save();
|
$user->save();
|
||||||
return redirect(route('wizard_register'));
|
return redirect(route('wizard_register'));
|
||||||
/*
|
/*
|
||||||
if(Request::get('submit') === 'do'){
|
if(Request::get('submit') === 'do'){
|
||||||
if(File::whereUserId($user->id)->whereIdentifier('id_card')->count() == 0){
|
if(File::whereUserId($user->id)->whereIdentifier('id_card')->count() == 0){
|
||||||
$validator = Validator::make(Request::all(), []);
|
$validator = Validator::make(Request::all(), []);
|
||||||
$validator->errors()->add('field', __('Kein Ausweis hinterlegt, bitte erst hochladen.'));
|
$validator->errors()->add('field', __('Kein Ausweis hinterlegt, bitte erst hochladen.'));
|
||||||
$user->wizard = 2;
|
$user->wizard = 2;
|
||||||
$user->save();
|
$user->save();
|
||||||
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
||||||
}
|
}
|
||||||
$user->wizard = 3;
|
$user->wizard = 3;
|
||||||
$user->save();
|
$user->save();
|
||||||
return redirect(route('wizard_register'));
|
return redirect(route('wizard_register'));
|
||||||
}
|
}
|
||||||
$this->fileRepo->_set('disk', 'user');
|
$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('user_id', $user->id);
|
||||||
$this->fileRepo->_set('identifier', 'id_card');
|
$this->fileRepo->_set('identifier', 'id_card');
|
||||||
return $this->fileRepo->uploadFile(Request::all());
|
return $this->fileRepo->uploadFile(Request::all());
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($step == 2) {
|
if ($step == 2) {
|
||||||
$data = Request::all();
|
$data = Request::all();
|
||||||
if(Request::get('submit') === 'do'){
|
if (Request::get('submit') === 'do') {
|
||||||
$data = Request::all();
|
$data = Request::all();
|
||||||
|
|
||||||
if($data['business_license_choose'] === "now"){
|
if ($data['business_license_choose'] === 'now') {
|
||||||
if(File::whereUserId($user->id)->whereIdentifier('business_license')->count() == 0){
|
if (File::whereUserId($user->id)->whereIdentifier('business_license')->count() == 0) {
|
||||||
$validator = Validator::make(Request::all(), []);
|
$validator = Validator::make(Request::all(), []);
|
||||||
$validator->errors()->add('field', __('Kein Gewerbeschein hinterlegt, bitte erst hochladen.'));
|
$validator->errors()->add('field', __('Kein Gewerbeschein hinterlegt, bitte erst hochladen.'));
|
||||||
$user->wizard = 2;
|
$user->wizard = 2;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
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['business_license_choose'] === 'non') {
|
||||||
if(!$data['non_business_license_reason'] || $data['non_business_license_reason'] == ""){
|
if (! $data['non_business_license_reason'] || $data['non_business_license_reason'] == '') {
|
||||||
$validator = Validator::make(Request::all(), []);
|
$validator = Validator::make(Request::all(), []);
|
||||||
$validator->errors()->add('field', __('Bitte gib eine Begründung ein, warum Du keinen Gewerbeschein benötigst.'));
|
$validator->errors()->add('field', __('Bitte gib eine Begründung ein, warum Du keinen Gewerbeschein benötigst.'));
|
||||||
$user->wizard = 2;
|
$user->wizard = 2;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
||||||
}else{
|
} else {
|
||||||
$user->account->setNotice('business_license_reason', $data['non_business_license_reason']);
|
$user->account->setNotice('business_license_reason', $data['non_business_license_reason']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -319,16 +329,18 @@ class WizardController extends Controller
|
||||||
$this->fileRepo->_set('dir', '/'.$user->id.'/verification/');
|
$this->fileRepo->_set('dir', '/'.$user->id.'/verification/');
|
||||||
$this->fileRepo->_set('user_id', $user->id);
|
$this->fileRepo->_set('user_id', $user->id);
|
||||||
$this->fileRepo->_set('identifier', 'business_license');
|
$this->fileRepo->_set('identifier', 'business_license');
|
||||||
return $this->fileRepo->uploadFile(Request::all());
|
|
||||||
|
return $this->fileRepo->uploadFile(Request::all());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($step == 3) {
|
if ($step == 3) {
|
||||||
|
|
||||||
$data = Request::all();
|
$data = Request::all();
|
||||||
|
|
||||||
if(!isset($data['switchers-package-wizard'])){
|
if (! isset($data['switchers-package-wizard'])) {
|
||||||
$validator = Validator::make(Request::all(), []);
|
$validator = Validator::make(Request::all(), []);
|
||||||
$validator->errors()->add('field', __('Bitte wähle erst Deine Mitgildschaft aus.'));
|
$validator->errors()->add('field', __('Bitte wähle erst Deine Mitgildschaft aus.'));
|
||||||
|
|
||||||
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -336,12 +348,12 @@ class WizardController extends Controller
|
||||||
$user->next_m_level = $data['switchers-package-wizard'];
|
$user->next_m_level = $data['switchers-package-wizard'];
|
||||||
$user->wizard = 5;
|
$user->wizard = 5;
|
||||||
$user->release_account = now();
|
$user->release_account = now();
|
||||||
UserHistory::create(['user_id' => $user->id, 'action'=>'release_account', 'status'=>0]);
|
UserHistory::create(['user_id' => $user->id, 'action' => 'release_account', 'status' => 0]);
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
if($user->isTestMode()){
|
if ($user->isTestMode()) {
|
||||||
$mail = config('app.info_test_mail');
|
$mail = config('app.info_test_mail');
|
||||||
}else{
|
} else {
|
||||||
$mail = config('app.info_mail');
|
$mail = config('app.info_mail');
|
||||||
}
|
}
|
||||||
Mail::to($mail)->send(new MailReleaseAccount($user));
|
Mail::to($mail)->send(new MailReleaseAccount($user));
|
||||||
|
|
@ -353,42 +365,43 @@ class WizardController extends Controller
|
||||||
public function storeCreate($step = 0)
|
public function storeCreate($step = 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!Auth::check()){
|
if (! Auth::check()) {
|
||||||
return redirect('login');
|
return redirect('login');
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::findOrFail(Auth::user()->id);
|
$user = User::findOrFail(Auth::user()->id);
|
||||||
if(!$user->account){
|
if (! $user->account) {
|
||||||
$user->account = new UserAccount();
|
$user->account = new UserAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($step == 10){
|
if ($step == 10) {
|
||||||
$rules = array(
|
$rules = [
|
||||||
'accepted_data_protection' => 'required',
|
'accepted_data_protection' => 'required',
|
||||||
'accepted_active' => 'required',
|
'accepted_active' => 'required',
|
||||||
);
|
];
|
||||||
$validator = Validator::make(Request::all(), $rules);
|
$validator = Validator::make(Request::all(), $rules);
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
$data = [
|
$data = [
|
||||||
'user' => Auth::user(),
|
'user' => Auth::user(),
|
||||||
'step' => $step,
|
'step' => $step,
|
||||||
'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
||||||
'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(),
|
'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(),
|
||||||
];
|
];
|
||||||
$user->wizard = 10;
|
$user->wizard = 10;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return view('user.wizard.create', $data)->withErrors($validator);
|
return view('user.wizard.create', $data)->withErrors($validator);
|
||||||
|
|
||||||
}
|
}
|
||||||
$account = $user->account;
|
$account = $user->account;
|
||||||
if($account->accepted_contract === null){
|
if ($account->accepted_contract === null) {
|
||||||
$account->accepted_contract = now();
|
$account->accepted_contract = now();
|
||||||
}
|
}
|
||||||
if($account->data_protection === null){
|
if ($account->data_protection === null) {
|
||||||
$account->data_protection = now();
|
$account->data_protection = now();
|
||||||
}
|
}
|
||||||
$account->save();
|
$account->save();
|
||||||
if($user->agreement === null){
|
if ($user->agreement === null) {
|
||||||
$user->agreement = now();
|
$user->agreement = now();
|
||||||
}
|
}
|
||||||
$user->wizard = 11;
|
$user->wizard = 11;
|
||||||
|
|
@ -396,54 +409,59 @@ class WizardController extends Controller
|
||||||
|
|
||||||
return redirect(route('wizard_create', [11]));
|
return redirect(route('wizard_create', [11]));
|
||||||
}
|
}
|
||||||
if($step == 11){
|
if ($step == 11) {
|
||||||
|
|
||||||
if($user->isPasswort()){
|
if ($user->isPasswort()) {
|
||||||
$user->wizard = 12;
|
$user->wizard = 12;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return redirect(route('wizard_create', [12]));
|
return redirect(route('wizard_create', [12]));
|
||||||
}
|
}
|
||||||
$rules = array(
|
$rules = [
|
||||||
'password' => 'required|string|min:6|confirmed',
|
'password' => 'required|string|min:6|confirmed',
|
||||||
);
|
];
|
||||||
$validator = Validator::make(Request::all(), $rules);
|
$validator = Validator::make(Request::all(), $rules);
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
$data = [
|
$data = [
|
||||||
'user' => Auth::user(),
|
'user' => Auth::user(),
|
||||||
'step' => $step,
|
'step' => $step,
|
||||||
'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
||||||
'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(),
|
'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(),
|
||||||
];
|
];
|
||||||
|
|
||||||
return view('user.wizard.create', $data)->withErrors($validator);
|
return view('user.wizard.create', $data)->withErrors($validator);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->fill([
|
$user->fill([
|
||||||
'password' => Hash::make(Request::get('password'))
|
'password' => Hash::make(Request::get('password')),
|
||||||
])->save();
|
])->save();
|
||||||
$user->wizard = 12;
|
$user->wizard = 12;
|
||||||
|
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return redirect(route('wizard_create', [12]));
|
return redirect(route('wizard_create', [12]));
|
||||||
}
|
}
|
||||||
if($step == 12){
|
if ($step == 12) {
|
||||||
|
|
||||||
$data = Request::all();
|
$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->wizard = 12;
|
||||||
$user->save();
|
$user->save();
|
||||||
$userRepo = new UserRepository($user);
|
$userRepo = new UserRepository($user);
|
||||||
|
|
||||||
return $userRepo->reverse_charge_validate($data, $user, route('wizard_create', [12]));
|
return $userRepo->reverse_charge_validate($data, $user, route('wizard_create', [12]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($data['action']) && $data['action'] == "reverse_charge_delete"){
|
|
||||||
$user->wizard = 12;
|
|
||||||
$user->save();
|
|
||||||
$userRepo = new UserRepository($user);
|
|
||||||
return $userRepo->reverse_charge_delete($data, $user, route('wizard_create', [12]));
|
|
||||||
}
|
|
||||||
|
|
||||||
$rules = array(
|
if (isset($data['action']) && $data['action'] == 'reverse_charge_delete') {
|
||||||
|
$user->wizard = 12;
|
||||||
|
$user->save();
|
||||||
|
$userRepo = new UserRepository($user);
|
||||||
|
|
||||||
|
return $userRepo->reverse_charge_delete($data, $user, route('wizard_create', [12]));
|
||||||
|
}
|
||||||
|
|
||||||
|
$rules = [
|
||||||
'salutation' => 'required',
|
'salutation' => 'required',
|
||||||
'first_name' => 'required',
|
'first_name' => 'required',
|
||||||
'last_name' => 'required',
|
'last_name' => 'required',
|
||||||
|
|
@ -455,16 +473,16 @@ class WizardController extends Controller
|
||||||
'tax_number' => 'required_without:tax_identification_number',
|
'tax_number' => 'required_without:tax_identification_number',
|
||||||
'tax_identification_number' => 'required_without:tax_number',
|
'tax_identification_number' => 'required_without:tax_number',
|
||||||
'country_id' => 'required|integer|min:1',
|
'country_id' => 'required|integer|min:1',
|
||||||
);
|
];
|
||||||
|
|
||||||
if(!Request::get('same_as_billing')){
|
if (! Request::get('same_as_billing')) {
|
||||||
$rules = array_merge($rules, [
|
$rules = array_merge($rules, [
|
||||||
'shipping_firstname'=>'required',
|
'shipping_firstname' => 'required',
|
||||||
'shipping_lastname'=>'required',
|
'shipping_lastname' => 'required',
|
||||||
'shipping_address'=>'required',
|
'shipping_address' => 'required',
|
||||||
'shipping_zipcode'=>'required',
|
'shipping_zipcode' => 'required',
|
||||||
'shipping_city' => 'required',
|
'shipping_city' => 'required',
|
||||||
'shipping_salutation' => 'required'
|
'shipping_salutation' => 'required',
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
@ -474,7 +492,7 @@ class WizardController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = Request::all();
|
$data = Request::all();
|
||||||
$data['same_as_billing'] = Request::get('same_as_billing') == NULL ? 0 : 1;
|
$data['same_as_billing'] = Request::get('same_as_billing') == null ? 0 : 1;
|
||||||
$user->account->fill($data)->save();
|
$user->account->fill($data)->save();
|
||||||
|
|
||||||
$user->wizard = 13;
|
$user->wizard = 13;
|
||||||
|
|
@ -484,14 +502,16 @@ class WizardController extends Controller
|
||||||
$user->confirmation_code_to = null;
|
$user->confirmation_code_to = null;
|
||||||
$user->confirmation_code_remider = 0;
|
$user->confirmation_code_remider = 0;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return redirect(route('wizard_create', [13]));
|
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);
|
$user = User::find(Auth::user()->id);
|
||||||
Yard::instance('shopping')->destroy();
|
Yard::instance('shopping')->destroy();
|
||||||
$product = Product::find(Request::get('switchers-package-wizard'));
|
$product = Product::find(Request::get('switchers-package-wizard'));
|
||||||
|
|
@ -501,10 +521,10 @@ class WizardController extends Controller
|
||||||
$user->abo_options = true;
|
$user->abo_options = true;
|
||||||
$user->save();
|
$user->save();
|
||||||
}*/
|
}*/
|
||||||
if($product && $product->active){
|
if ($product && $product->active) {
|
||||||
//set membership product
|
// set membership product
|
||||||
$image = "";
|
$image = '';
|
||||||
if($product->images->count()){
|
if ($product->images->count()) {
|
||||||
$image = $product->images->first()->slug;
|
$image = $product->images->first()->slug;
|
||||||
}
|
}
|
||||||
/*need setGlobalTaxRate
|
/*need setGlobalTaxRate
|
||||||
|
|
@ -515,23 +535,23 @@ class WizardController extends Controller
|
||||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
|
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//Keine steuer
|
// Keine steuer
|
||||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, $product->tax, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, $product->tax, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||||
Yard::instance('shopping')->setGlobalTaxRate(0);
|
Yard::instance('shopping')->setGlobalTaxRate(0);
|
||||||
|
|
||||||
//set onboarding products
|
// set onboarding products
|
||||||
if(Request::get('products_on_board')){
|
if (Request::get('products_on_board')) {
|
||||||
foreach (Request::get('products_on_board') as $product_on_board_id){
|
foreach (Request::get('products_on_board') as $product_on_board_id) {
|
||||||
$product_on_board = Product::find($product_on_board_id);
|
$product_on_board = Product::find($product_on_board_id);
|
||||||
$image = "";
|
$image = '';
|
||||||
if($product_on_board->images->count()){
|
if ($product_on_board->images->count()) {
|
||||||
$image = $product_on_board->images->first()->slug;
|
$image = $product_on_board->images->first()->slug;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
need?
|
need?
|
||||||
$cartItem = Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1,
|
$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),
|
$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]);
|
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]);
|
||||||
if(\App\Services\UserService::getTaxFree()){
|
if(\App\Services\UserService::getTaxFree()){
|
||||||
Yard::setTax($cartItem->rowId, 0);
|
Yard::setTax($cartItem->rowId, 0);
|
||||||
|
|
@ -553,7 +573,6 @@ class WizardController extends Controller
|
||||||
$data['is_from'] = 'wizard';
|
$data['is_from'] = 'wizard';
|
||||||
$data['is_for'] = 'me';
|
$data['is_for'] = 'me';
|
||||||
|
|
||||||
|
|
||||||
/*ShoppingInstance::create([
|
/*ShoppingInstance::create([
|
||||||
'identifier' => $identifier,
|
'identifier' => $identifier,
|
||||||
'user_shop_id' => 1, //is first faker shop for buy intern
|
'user_shop_id' => 1, //is first faker shop for buy intern
|
||||||
|
|
@ -566,39 +585,41 @@ class WizardController extends Controller
|
||||||
|
|
||||||
]);*/
|
]);*/
|
||||||
Yard::instance('shopping')->putYardExtra('shopping_data', $data);
|
Yard::instance('shopping')->putYardExtra('shopping_data', $data);
|
||||||
//Yard::instance('shopping')->store($identifier);
|
// Yard::instance('shopping')->store($identifier);
|
||||||
//add to DB
|
// add to DB
|
||||||
//$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
// $path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
||||||
UserHistory::create(['user_id' => $user->id, 'action'=>'wizard_payment', 'status'=>1, 'product_id'=>$product->id, 'identifier'=>$identifier]);
|
UserHistory::create(['user_id' => $user->id, 'action' => 'wizard_payment', 'status' => 1, 'product_id' => $product->id, 'identifier' => $identifier]);
|
||||||
//$path = str_replace('http', 'https', $path);
|
|
||||||
//return redirect()->secure($path);
|
|
||||||
return redirect(route('user_checkout', [$identifier]));
|
|
||||||
|
|
||||||
|
// $path = str_replace('http', 'https', $path);
|
||||||
|
// return redirect()->secure($path);
|
||||||
|
return redirect(route('user_checkout', [$identifier]));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\Session()->flash('alert-error', "Fehler beim Produkt");
|
\Session()->flash('alert-error', 'Fehler beim Produkt');
|
||||||
|
|
||||||
return back();
|
return back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id, $relation){
|
public function delete($id, $relation)
|
||||||
|
{
|
||||||
|
|
||||||
if($relation === 'upload'){
|
if ($relation === 'upload') {
|
||||||
$user = User::findOrFail(Auth::user()->id);
|
$user = User::findOrFail(Auth::user()->id);
|
||||||
$file = $user->files()->findOrFail($id);
|
$file = $user->files()->findOrFail($id);
|
||||||
$identifier = $file->identifier;
|
$identifier = $file->identifier;
|
||||||
//remove file
|
// remove file
|
||||||
\Storage::disk('user')->delete($file->dir.$file->filename);
|
\Storage::disk('user')->delete($file->dir.$file->filename);
|
||||||
$file->delete();
|
$file->delete();
|
||||||
\Session()->flash('alert-success', "Datei gelöscht");
|
\Session()->flash('alert-success', 'Datei gelöscht');
|
||||||
if($identifier === 'business_license'){
|
if ($identifier === 'business_license') {
|
||||||
$user->wizard = 2;
|
$user->wizard = 2;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return redirect(route('wizard_register', [2]));
|
return redirect(route('wizard_register', [2]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return back();
|
return back();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App\Models\UserLevel
|
* App\Models\UserLevel
|
||||||
|
|
@ -13,8 +15,9 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
* @property float|null $margin
|
* @property float|null $margin
|
||||||
* @property int|null $pos
|
* @property int|null $pos
|
||||||
* @property int $active
|
* @property int $active
|
||||||
* @property \Illuminate\Support\Carbon|null $created_at
|
* @property Carbon|null $created_at
|
||||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
* @property Carbon|null $updated_at
|
||||||
|
*
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel newQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel query()
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel query()
|
||||||
|
|
@ -26,36 +29,44 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel wherePos($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel wherePos($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereTransName($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereTransName($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereUpdatedAt($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereUpdatedAt($value)
|
||||||
|
*
|
||||||
* @property string|null $content
|
* @property string|null $content
|
||||||
* @property array|null $trans_content
|
* @property array|null $trans_content
|
||||||
|
*
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereContent($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereContent($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereTransContent($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereTransContent($value)
|
||||||
|
*
|
||||||
* @property bool $partner_provision
|
* @property bool $partner_provision
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserLevelMargin[] $user_level_margins
|
* @property-read Collection|UserLevelMargin[] $user_level_margins
|
||||||
* @property-read int|null $user_level_margins_count
|
* @property-read int|null $user_level_margins_count
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserLevelMargin[] $user_level_margins_re
|
* @property-read Collection|UserLevelMargin[] $user_level_margins_re
|
||||||
* @property-read int|null $user_level_margins_re_count
|
* @property-read int|null $user_level_margins_re_count
|
||||||
|
*
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePartnerProvision($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePartnerProvision($value)
|
||||||
|
*
|
||||||
* @property bool $payment_year
|
* @property bool $payment_year
|
||||||
|
*
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePaymentYear($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePaymentYear($value)
|
||||||
|
*
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class UserLevel extends Model
|
class UserLevel extends Model
|
||||||
{
|
{
|
||||||
protected $table = 'user_levels';
|
protected $table = 'user_levels';
|
||||||
|
|
||||||
protected $casts = ['trans_name' => 'array',
|
protected $casts = ['trans_name' => 'array',
|
||||||
'trans_content' => 'array',
|
'trans_content' => 'array',
|
||||||
'partner_provision'=>'bool',
|
'partner_provision' => 'bool',
|
||||||
'payment_year' => 'bool',
|
'payment_year' => 'bool',
|
||||||
];
|
'exclude_single_commission' => 'bool',
|
||||||
|
'hide_registration' => 'bool',
|
||||||
|
];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name', 'content', 'pos', 'payment_year', 'active', 'partner_provision',
|
'name', 'content', 'pos', 'payment_year', 'active', 'partner_provision',
|
||||||
|
'exclude_single_commission', 'hide_registration',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function user_level_margins()
|
public function user_level_margins()
|
||||||
{
|
{
|
||||||
return $this->hasMany('App\Models\UserLevelMargin', 'user_level_id', 'id');
|
return $this->hasMany('App\Models\UserLevelMargin', 'user_level_id', 'id');
|
||||||
|
|
@ -66,28 +77,32 @@ class UserLevel extends Model
|
||||||
return $this->hasMany('App\Models\UserLevelMargin', 'user_level_id', 'id')->orderBy('price_from', 'DESC');
|
return $this->hasMany('App\Models\UserLevelMargin', 'user_level_id', 'id')->orderBy('price_from', 'DESC');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPosAttribute($value){
|
public function setPosAttribute($value)
|
||||||
|
{
|
||||||
$this->attributes['pos'] = is_numeric($value) ? $value : null;
|
$this->attributes['pos'] = is_numeric($value) ? $value : null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _format_number($value){
|
public function _format_number($value)
|
||||||
return preg_replace("/[^0-9,]/", "", $value);
|
{
|
||||||
|
return preg_replace('/[^0-9,]/', '', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMarginAttribute( $value ) {
|
public function setMarginAttribute($value)
|
||||||
|
{
|
||||||
$value = $this->_format_number($value);
|
$value = $this->_format_number($value);
|
||||||
$this->attributes['margin'] = floatval(str_replace(',', '.', $value));
|
$this->attributes['margin'] = floatval(str_replace(',', '.', $value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormattedMargin()
|
public function getFormattedMargin()
|
||||||
{
|
{
|
||||||
if(!isset($this->attributes['margin'])){
|
if (! isset($this->attributes['margin'])) {
|
||||||
return "";
|
return '';
|
||||||
}
|
}
|
||||||
if(\App::getLocale() === "en"){
|
if (\App::getLocale() === 'en') {
|
||||||
return number_format($this->attributes['margin'], 2, '.', ',');
|
return number_format($this->attributes['margin'], 2, '.', ',');
|
||||||
}
|
}
|
||||||
|
|
||||||
return number_format($this->attributes['margin'], 2, ',', '.');
|
return number_format($this->attributes['margin'], 2, ',', '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,26 +113,28 @@ class UserLevel extends Model
|
||||||
return $this->{$key};
|
return $this->{$key};
|
||||||
}
|
}
|
||||||
$trans = $this->getTrans($key, $lang);
|
$trans = $this->getTrans($key, $lang);
|
||||||
if (!$trans || $trans == '') {
|
if (! $trans || $trans == '') {
|
||||||
return $this->{$key};
|
return $this->{$key};
|
||||||
}
|
}
|
||||||
|
|
||||||
return $trans;
|
return $trans;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTrans($key, $lang)
|
public function getTrans($key, $lang)
|
||||||
{
|
{
|
||||||
$key = 'trans_' . $key;
|
$key = 'trans_'.$key;
|
||||||
if (!empty($this->{$key}[$lang])) {
|
if (! empty($this->{$key}[$lang])) {
|
||||||
return $this->{$key}[$lang];
|
return $this->{$key}[$lang];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTranNames()
|
public function getTranNames()
|
||||||
{
|
{
|
||||||
$ret = "";
|
$ret = '';
|
||||||
foreach ((array) $this->trans_name as $value){
|
foreach ((array) $this->trans_name as $value) {
|
||||||
$ret .= $value.', ';
|
$ret .= $value.', ';
|
||||||
}
|
}
|
||||||
|
|
||||||
return rtrim($ret, ', ');
|
return rtrim($ret, ', ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zwei Steuer-Flags an den Berater-Rollen:
|
||||||
|
* - exclude_single_commission: Rollen (z. B. Barkunde 0 %) ziehen den produktseitigen
|
||||||
|
* Kunden-Einzelrabatt (single_commission/value_commission) NICHT mehr ab.
|
||||||
|
* - hide_registration: interne Rollen (z. B. Mitarbeiter) werden bei der Registrierung
|
||||||
|
* und der Mitgliedschafts-Auswahl ausgeblendet, bleiben aber im Admin zuweisbar.
|
||||||
|
* Default false => bestehende Rollen verhalten sich unverändert.
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('user_levels', function (Blueprint $table) {
|
||||||
|
$table->boolean('exclude_single_commission')->default(false)->after('partner_provision');
|
||||||
|
$table->boolean('hide_registration')->default(false)->after('exclude_single_commission');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('user_levels', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['exclude_single_commission', 'hide_registration']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -59,6 +59,22 @@
|
||||||
<em>Auch immer die Provision bei den Staffelpreisen eintragen!<br>Die Provision wird beim Käufer berechnet und nur ein Sponsor mit der Rolle wo diese Checkbox aktiv ist bekommt die Provison gutgeschrieben.</em>
|
<em>Auch immer die Provision bei den Staffelpreisen eintragen!<br>Die Provision wird beim Käufer berechnet und nur ein Sponsor mit der Rolle wo diese Checkbox aktiv ist bekommt die Provison gutgeschrieben.</em>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-12">
|
||||||
|
<label class="custom-control custom-checkbox m-2">
|
||||||
|
{!! Form::checkbox('exclude_single_commission', 1, $value->exclude_single_commission, ['class'=>'custom-control-input']) !!}
|
||||||
|
<span class="custom-control-label">Produktseitige Einzelprovision nicht abziehen</span>
|
||||||
|
</label>
|
||||||
|
<em>Für Rollen ohne Rabatt (z. B. Barkunde 0 %): Der am Produkt hinterlegte Kunden-Einzelrabatt (Einzelprovision) wird im Warenkorb NICHT abgezogen. Staffelrabatt und Sponsor-Provision bleiben davon unberührt.</em>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-12">
|
||||||
|
<label class="custom-control custom-checkbox m-2">
|
||||||
|
{!! Form::checkbox('hide_registration', 1, $value->hide_registration, ['class'=>'custom-control-input']) !!}
|
||||||
|
<span class="custom-control-label">Nicht bei Registrierung/Mitgliedschaft anzeigen (interne Rolle)</span>
|
||||||
|
</label>
|
||||||
|
<em>Interne Rollen (z. B. Mitarbeiter) werden bei der Registrierung und der Mitgliedschafts-Auswahl ausgeblendet. Im Admin/Lead-Formular bleibt die Rolle zuweisbar.</em>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-12">
|
<div class="form-group col-12">
|
||||||
<label class="custom-control custom-checkbox m-2">
|
<label class="custom-control custom-checkbox m-2">
|
||||||
{!! Form::checkbox('payment_year', 1, $value->payment_year, ['class'=>'custom-control-input']) !!}
|
{!! Form::checkbox('payment_year', 1, $value->payment_year, ['class'=>'custom-control-input']) !!}
|
||||||
|
|
|
||||||
63
tests/Feature/UserLevelSingleCommissionTest.php
Normal file
63
tests/Feature/UserLevelSingleCommissionTest.php
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\UserLevel;
|
||||||
|
use App\Services\Facade\Yard;
|
||||||
|
use App\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
uses(TestCase::class, RefreshDatabase::class);
|
||||||
|
|
||||||
|
function commissionUser(bool $excludeSingleCommission): User
|
||||||
|
{
|
||||||
|
$level = UserLevel::create([
|
||||||
|
'name' => $excludeSingleCommission ? 'Barkunde 0%' : 'Wiederverkäufer',
|
||||||
|
'active' => true,
|
||||||
|
'partner_provision' => false,
|
||||||
|
'exclude_single_commission' => $excludeSingleCommission,
|
||||||
|
'hide_registration' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = User::query()->create([
|
||||||
|
'email' => uniqid('cart_', true).'@test.example',
|
||||||
|
'password' => bcrypt('password'),
|
||||||
|
]);
|
||||||
|
$user->forceFill(['m_level' => $level->id])->save();
|
||||||
|
|
||||||
|
return $user->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
function cartWithSingleCommissionProduct(User $user)
|
||||||
|
{
|
||||||
|
$cart = Yard::instance('shopping');
|
||||||
|
$cart->destroy();
|
||||||
|
// price 119 brutto @ 19% => 100 netto; Produkt trägt 25% Kunden-Einzelrabatt
|
||||||
|
$cart->add(1, 'Deocreme MINI', 1, 119, 19, [
|
||||||
|
'image' => '',
|
||||||
|
'slug' => 'deocreme-mini',
|
||||||
|
'weight' => 0,
|
||||||
|
'single_commission' => 1,
|
||||||
|
'amount_commission' => 0,
|
||||||
|
'value_commission' => 25,
|
||||||
|
'partner_commission' => 0,
|
||||||
|
]);
|
||||||
|
$cart->setUser($user);
|
||||||
|
$cart->calculateMargins();
|
||||||
|
|
||||||
|
return $cart;
|
||||||
|
}
|
||||||
|
|
||||||
|
test('rolle mit exclude_single_commission zieht keinen produktseitigen einzelrabatt', function () {
|
||||||
|
$cart = cartWithSingleCommissionProduct(commissionUser(true));
|
||||||
|
|
||||||
|
expect((float) $cart->getYardCommission()->single_value_commission)->toBe(0.0);
|
||||||
|
expect((float) $cart->getYardMargin()->net_discount)->toBe(0.0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('rolle ohne flag zieht den produktseitigen einzelrabatt weiterhin ab', function () {
|
||||||
|
$cart = cartWithSingleCommissionProduct(commissionUser(false));
|
||||||
|
|
||||||
|
// 25% von 100 netto = 25
|
||||||
|
expect((float) $cart->getYardCommission()->single_value_commission)->toBe(25.0);
|
||||||
|
expect((float) $cart->getYardMargin()->net_discount)->toBe(25.0);
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue