diff --git a/app/Http/Controllers/AdminUserController.php b/app/Http/Controllers/AdminUserController.php index 7a7b670..f1e7d10 100755 --- a/app/Http/Controllers/AdminUserController.php +++ b/app/Http/Controllers/AdminUserController.php @@ -100,6 +100,9 @@ class AdminUserController extends Controller if(isset($data['save-active'])){ $data['active'] = isset($data['active']) ? true : false; $user->active = $data['active']; + if($data['active'] === true && $user->wizard < 20){ + $user->wizard = 20; + } if($data['active']){ if(!isset($data['active_date']) || $data['active_date'] == ""){ $user->active_date = now(); diff --git a/app/Http/Controllers/Api/GoogleMerchantController.php b/app/Http/Controllers/Api/GoogleMerchantController.php new file mode 100644 index 0000000..c3c3242 --- /dev/null +++ b/app/Http/Controllers/Api/GoogleMerchantController.php @@ -0,0 +1,97 @@ +whereJsonContains('show_on', '1')->orderBy('pos', 'DESC')->get(); + // Create feed object + $feed = new Feed("mivita shop", "https://mivita.shop", "Bio Aloe Vera & Naturkosmetuk"); + + // Put products to the feed ($products - some data from database for example) + foreach ($products as $product) { + $item = new Product(); + + // Set common product properties + $item->setId($product->id); + $item->setTitle($product->name); + $item->setDescription($product->copy); + $item->setLink($product->getProductUrl()); + $item->setImage($product->getImageUrl()); + $item->setAvailability(Availability::IN_STOCK); + + /*if ($product->isAvailable()) { + $item->setAvailability(Availability::IN_STOCK); + } else { + $item->setAvailability(Availability::OUT_OF_STOCK); + }*/ + $item->setPrice("{$product->price} EUR"); + //$item->setGoogleCategory($product->category_name); + $item->setBrand('MIVITA'); + $item->setGtin($product->ean); + $item->setCondition('new'); + + // Some additional properties + //$item->setColor($product->color); + //$item->setSize($product->size); + + // Shipping info + /* + $shipping = new Shipping(); + $shipping->setCountry('US'); + $shipping->setRegion('CA, NSW, 03'); + $shipping->setPostalCode('94043'); + $shipping->setLocationId('21137'); + $shipping->setService('DHL'); + $shipping->setPrice('1300 USD'); + $item->setShipping($shipping); + */ + + // Set a custom shipping label and weight (optional) + //$item->setShippingLabel('ups-ground'); + //$item->setShippingWeight('2.14'); + + // Set a custom label (optional) + $item->setCustomLabel($product->weight, 'product_width'); + $item->setCustomLabel($product->contents_total, 'product_contents_total'); + $item->setCustomLabel($product->getUnitType(), 'product_contents_unit',); + $item->setCustomLabel($product->contents_str, 'product_contents'); + $item->setCustomLabel($product->ingredients, 'product_ingredients'); + + $item->setCustomLabel($product->getBasePriceFormattedFullWith(false, false, null), 'product_base_pricing_unit'); + + + //$item->setCustomLabel('Some Label 2', 1); + + // Add this product to the feed + $feed->addProduct($item); + } + + // Here we get complete XML of the feed, that we could write to file or send directly + $feedXml = $feed->build(); + print ($feedXml); + } + + // http://api.mivita.test/google/merchant/feed + +} \ No newline at end of file diff --git a/app/Http/Controllers/Api/ShoppingUserController.php b/app/Http/Controllers/Api/ShoppingUserController.php index 71f0098..f6f1483 100755 --- a/app/Http/Controllers/Api/ShoppingUserController.php +++ b/app/Http/Controllers/Api/ShoppingUserController.php @@ -593,7 +593,7 @@ class ShoppingUserController extends Controller if ($order->price != ($product->price * 100)) { $error[] = "different price: " . ($product->price * 100); } - Yard::instance('shopping')->add($product->id, $product->name, (int) $order->qty, $product->price, false, false, ['image' => [], 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]); + Yard::instance('shopping')->add($product->id, $product->name, (int) $order->qty, $product->price, false, false, ['image' => [], 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission]); } } $order->message = $error; @@ -662,7 +662,7 @@ class ShoppingUserController extends Controller 'tax_rate' => $item->taxRate, 'tax' => $tax, 'price_vk_net' => $shopping_order->getPriceVkNetBy($item->id), - 'discount' => $shopping_order->getUserDiscount(), + 'discount' => $item->options->no_commission ? 0 : $shopping_order->getUserDiscount(), 'points' => $item->options->points, 'slug' => $item->options->slug, ])->save(); @@ -687,7 +687,7 @@ class ShoppingUserController extends Controller 'tax_rate' => $item->taxRate, 'tax' => $tax, 'price_vk_net' => $shopping_order->getPriceVkNetBy($item->id), - 'discount' => $shopping_order->getUserDiscount(), + 'discount' => $item->options->no_commission ? 0 : $shopping_order->getUserDiscount(), 'points' => $item->options->points, 'slug' => $item->options->slug ]); diff --git a/app/Http/Controllers/BusinessController.php b/app/Http/Controllers/BusinessController.php new file mode 100644 index 0000000..ae98a3b --- /dev/null +++ b/app/Http/Controllers/BusinessController.php @@ -0,0 +1,234 @@ + 'aktiv', 2 => 'nicht aktiv', 3 => 'alle']; + public function __construct() + { + $this->middleware('admin'); + } + + public function show() + { + $this->setFilterVars(); + + $data = [ + 'filter_months' => HTMLHelper::$months, + 'filter_years' => HTMLHelper::getYearRange(), + 'filter_active' => $this->filter_active, + + ]; + return view('admin.business.show', $data); + } + + + public function structure() + { + $this->setFilterVars(); + $TreeCalcBot = new TreeCalcBot(session('business_user_filter_month'), session('business_user_filter_year'), 'admin'); + $TreeCalcBot->initMain(); + $data = [ + 'filter_months' => HTMLHelper::$months, + 'filter_years' => HTMLHelper::getYearRange(), + 'TreeCalcBot' => $TreeCalcBot, + ]; + return view('admin.business.structure', $data); + } + + public function userDetail($user_id) + { + $user = User::findOrFail($user_id); + $this->setFilterVars(); + + $TreeCalcBot = new TreeCalcBot(session('business_user_filter_month'), session('business_user_filter_year'), 'admin'); + $TreeCalcBot->initDetailUser($user); + if(!$TreeCalcBot->user){ + abort(403, 'no user found'); + } + $data = [ + 'month' => HTMLHelper::getMonth(session('business_user_filter_month')), + 'year' => session('business_user_filter_year'), + 'TreeCalcBot' => $TreeCalcBot, + 'user' => $user, + ]; + return view('admin.business.user_detail', $data); + } + + private function setFilterVars(){ + + if(!session('business_user_filter_month')){ + session(['business_user_filter_month' => intval(date('m'))]); + } + if(!session('business_user_filter_year')){ + session(['business_user_filter_year' => intval(date('Y'))]); + } + if(!session('business_user_filter_active')){ + session(['business_user_filter_active' => 1]); + } + + if(Request::get('business_user_filter_name')){ + session(['business_user_filter_name' => Request::get('business_user_filter_name')]); + } + if(Request::get('business_user_filter_active')){ + session(['business_user_filter_active' => Request::get('business_user_filter_active')]); + } + if(Request::get('business_user_filter_month')){ + session(['business_user_filter_month' => Request::get('business_user_filter_month')]); + } + if(Request::get('business_user_filter_year')){ + session(['business_user_filter_year' => Request::get('business_user_filter_year')]); + } + } + + private function initSearch($archive = false, $request = true) + { + $this->setFilterVars(); + $this->month = Request::get('business_user_filter_month'); + $this->year = Request::get('business_user_filter_year'); + + $query = User::with('account')->select('users.*') + ->where('users.deleted_at', '=', null) + ->where('users.id', '!=', 1) + ->where('users.admin', "<", 4) + ->where('users.m_level', "!=", null) + ->where('users.payment_account', "!=", null); + + if(Request::get('business_user_filter_active')){ + if(Request::get('business_user_filter_active') == 1){ + $query->where('users.payment_account', ">=", now()); + } + if(Request::get('business_user_filter_active') == 2){ + $query->where('users.payment_account', "<", now()); + } + if(Request::get('business_user_filter_active') == 3){ + //both -> payment_account only not null + } + } + + if(Request::get('business_user_filter_name')){ + //$query->where('users.account.first_name', 'LIKE', '%'.Request::get('business_user_filter_name').'%'); + //$query->where('users.account.last_name', 'LIKE', '%'.Request::get('business_user_filter_name').'%'); + //$query->where('users.account.m_account', 'LIKE', '%'.Request::get('business_user_filter_name').'%'); + //$query->where('users.email', 'LIKE', '%'.Request::get('business_user_filter_name').'%'); + + } + + //->orderBy('created_at', 'DESC'); + /* $query = FlexHour::leftJoin("flex_hour_items", function($join) { + $join->on("flex_hour_items.flex_hour_id","=","flex_hours.id"); + $join->where("flex_hour_items.date","=", FlexHourItemBot::$date); + })*/ + return $query; + } + + public function userDatatable() + { + $query = $this->initSearch(); + return \DataTables::eloquent($query) + ->addColumn('id', function (User $user) { + return ''; + // + }) + ->addColumn('user_level', function (User $user) { + return $user->user_level ? $user->user_level->name : ''; + }) + ->addColumn('active_account', function (User $user) { + return get_active_badge($user->isActiveAccount()); + }) + ->addColumn('payment_account_date', function (User $user) { + return $user->payment_account ? $user->getPaymentAccountDateFormat(false) : "-"; + }) + ->addColumn('sales_volume_points', function (User $user) { + return '
'.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_sum').'
'. + 'B: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points').' | S: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_shop').''; + }) + ->addColumn('sales_volume_total', function (User $user) { + return '
'.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_sum').'
'. + 'B: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total').' | S: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_shop').''; + }) + ->addColumn('sponsor', function (User $user) { + if($user->user_sponsor){ + $sponsor = ""; + if($user->user_sponsor->account){ + $sponsor .= $user->user_sponsor->account->first_name." ".$user->user_sponsor->account->last_name; + $sponsor .= "  ".'
'; + } + $sponsor .= ''.$user->email; + if($user->user_sponsor->account){ + $sponsor .= ' | '.$user->user_sponsor->account->m_account; + } + $sponsor .= ''; + + return $sponsor; + } + return '-'; + + return '
'.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_sum').'
'. + 'B: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total').' | S: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_shop').''; + }) + + ->addColumn('is_qual_kp', function (User $user) { + if($user->user_level){ + $qual_kp = $user->user_level->qual_kp; + $sales_volume_points_sum = $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_sum'); + $isQualKP = ($sales_volume_points_sum >= $qual_kp) ? true : false; + return ' KD '.$qual_kp.''; + } + return '-'; + }) + + + + + + /* ->addColumn('sales_volume_points', function (User $user) { + return $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points'); + }) + ->addColumn('sales_volume_points_shop', function (User $user) { + return $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_shop'); + }) + ->addColumn('sales_volume_points_sum', function (User $user) { + return $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_sum'); + }) + ->addColumn('sales_volume_total', function (User $user) { + return $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total'); + }) + ->addColumn('sales_volume_total_shop', function (User $user) { + return $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_shop'); + }) + ->addColumn('sales_volume_total_sum', function (User $user) { + return $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_sum'); + })*/ + + ->orderColumn('id', 'id $1') + ->orderColumn('m_account', 'm_account $1') + ->orderColumn('first_name', 'first_name $1') + ->orderColumn('last_name', 'last_name $1') + ->orderColumn('user_level', 'm_level $1') + ->orderColumn('active_account', 'payment_account $1') + ->rawColumns(['id', 'is_qual_kp', 'confirmed', 'sales_volume_points', 'sales_volume_total', 'sponsor', 'active', 'active_account']) + ->make(true); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/LeadController.php b/app/Http/Controllers/LeadController.php index 76261da..dd78eec 100755 --- a/app/Http/Controllers/LeadController.php +++ b/app/Http/Controllers/LeadController.php @@ -122,6 +122,21 @@ class LeadController extends Controller $data = Request::all(); $show = Request::get('show'); + if(isset($data['reverse_charge_validate']) && isset($data['user_id'])){ + $user = User::findOrFail($data['user_id']); + $user->wizard = 1; + $user->save(); + $userRepo = new UserRepository($user); + return $userRepo->reverse_charge_validate($data, $user); + } + + if(isset($data['reverse_charge_delete']) && isset($data['user_id'])){ + $user = User::findOrFail($data['user_id']); + $user->wizard = 1; + $user->save(); + $userRepo = new UserRepository($user); + return $userRepo->reverse_charge_delete($data, $user); + } if ($data['user_id'] === "new" || $data['user_id'] == 0) { $rules = array( @@ -158,9 +173,8 @@ class LeadController extends Controller if(isset($data['m_account']) && $data['m_account']){ $user = User::findOrFail($data['user_id']); $rules['m_account'] = 'unique:user_accounts,m_account,'.$user->account->id.',id'; - - } + $validator = Validator::make(Request::all(), $rules); if ($validator->fails()) { diff --git a/app/Http/Controllers/MembershipController.php b/app/Http/Controllers/MembershipController.php index 134fd91..436400b 100755 --- a/app/Http/Controllers/MembershipController.php +++ b/app/Http/Controllers/MembershipController.php @@ -132,7 +132,7 @@ class MembershipController extends Controller $image = $product->images->first()->slug; } $qty = Request::get('qty') ? Request::get('qty') : 1; - $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]); + $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()){ Yard::setTax($cartItem->rowId, 0); }else{ diff --git a/app/Http/Controllers/ModalController.php b/app/Http/Controllers/ModalController.php index db94f38..dd82c2b 100644 --- a/app/Http/Controllers/ModalController.php +++ b/app/Http/Controllers/ModalController.php @@ -2,14 +2,17 @@ namespace App\Http\Controllers; -use App\Models\Homeparty; -use App\Models\HomepartyUser; -use App\Models\Product; -use App\Models\ShoppingOrder; -use App\Models\ShoppingUser; - -use App\User; use Request; +use App\User; +use App\Models\Product; +use App\Models\Homeparty; +use App\Models\UserLevel; + +use App\Models\ShoppingUser; +use App\Services\HTMLHelper; +use App\Models\HomepartyUser; +use App\Models\ShoppingOrder; +use App\Services\BusinessPlan\TreeCalcBot; class ModalController extends Controller { @@ -61,23 +64,49 @@ class ModalController extends Controller /* $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') { $homeparty = Homeparty::find($data['id']); $homeparty_user = HomepartyUser::find($data['user_id']); $data['homeparty'] = $homeparty; $ret = view("user.homeparty.modal_show_products", compact( 'data', 'homeparty', 'homeparty_user'))->render(); - - } - - + 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'] === 'business-user-detail'){ + $user = User::findOrFail($data['id']); + if($data['init_from'] === 'admin'){ + $data['month'] = session('business_user_filter_month'); + $data['year'] = session('business_user_filter_year'); + }else{ + $data['month'] = session('team_user_filter_month'); + $data['year'] = session('team_user_filter_year'); + } + $TreeCalcBot = $this->getForBusinessUserDetail($user, $data); + $route = ""; + $ret = view("admin.modal.business_user_detail", compact('TreeCalcBot', 'user', 'data'))->render(); + } } return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]); } + private function getForBusinessUserDetail(User $user, $data){ + + $auth_user = \Auth::user(); + if($auth_user->isAdmin() || $auth_user->id === $user->id){ + $TreeCalcBot = new TreeCalcBot($data['month'], $data['year'], $data['init_from']); + $TreeCalcBot->initDetailUser($user); + if(!$TreeCalcBot->user){ + abort(403, 'no user found'); + } + return $TreeCalcBot; + } + return null; + + } } diff --git a/app/Http/Controllers/PaymentInvoiceController.php b/app/Http/Controllers/PaymentInvoiceController.php index 7e95f89..23fb580 100644 --- a/app/Http/Controllers/PaymentInvoiceController.php +++ b/app/Http/Controllers/PaymentInvoiceController.php @@ -6,6 +6,7 @@ use Carbon; use Request; use App\Services\Payment; use App\Models\UserInvoice; +use App\Services\HTMLHelper; class PaymentInvoiceController extends Controller { @@ -25,8 +26,8 @@ class PaymentInvoiceController extends Controller $this->setFilterVars(); $data = [ - 'filter_months' => UserInvoice::$monthNames, - 'filter_years' => UserInvoice::getYearRange(), + 'filter_months' => HTMLHelper::$months, + 'filter_years' => HTMLHelper::getYearRange(), ]; return view('admin.payment.invoice', $data); } diff --git a/app/Http/Controllers/SyS/SysController.php b/app/Http/Controllers/SyS/SysController.php new file mode 100644 index 0000000..0c22a9a --- /dev/null +++ b/app/Http/Controllers/SyS/SysController.php @@ -0,0 +1,87 @@ +middleware('sysadmin'); + + } + + public function index() + { + return view('sys.index'); + } + + public function tool($serve) + { + switch ($serve) { + case 'sales_members': + return Sales::show(); + break; + case 'customers': + return Customers::show(); + break; + case 'cronjobs': + return Cronjobs::show(); + break; + case 'domainssl': + return DomainSSL::show(); + break; + case 'shopping_orders': + return ShoppingOrders::show(); + break; + case 'import': + return Import::show(); + break; + case 'corrections': + return Correction::show(); + break; + } + abort(403, 'not found tool'); + } + + + public function store($serve) + { + switch ($serve) { + case 'sales_members': + return Sales::show(); + break; + case 'customers': + return Customers::store(); + break; + case 'cronjobs': + return Cronjobs::store(); + break; + case 'domainssl': + return DomainSSL::store(); + break; + case 'shopping_orders': + return ShoppingOrders::store(); + break; + case 'import': + return Import::store(); + break; + case 'corrections': + return Correction::store(); + break; + } + abort(403, 'not found tool'); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Sys/AdminToolsController.php b/app/Http/Controllers/Sys/AdminToolsController.php deleted file mode 100755 index 4268c64..0000000 --- a/app/Http/Controllers/Sys/AdminToolsController.php +++ /dev/null @@ -1,374 +0,0 @@ -middleware('sysadmin'); - - } - - /** - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View - */ - public function index() - { - dd('index'); - } - - public function customers() - { - $shopping_users = ShoppingUser::where('member_id', '=', NULL)->where('auth_user_id', '=', NULL)->get(); - $data = [ - 'values' => $shopping_users, - 'text' => '', - ]; - - return view('sys.admin.customers', $data); - } - - - public function customerStore() - { - $data = Request::all(); - $ret = ""; - if($data['action'] === 'makePaymentMethodsDefault'){ - $users = User::where('payment_methods', '=', NULL)->get(); - //$users = User::all(); - foreach ($users as $user){ - $user->payment_methods = PaymentMethod::getDefaultAsArray(); - $user->save(); - } - } - if($data['action'] === 'checkForAll'){ - $shopping_users = CustomerPriority::checkForAll(); - } - - if($data['action'] === 'checkContractPDF'){ - //create PDF - $user = User::findOrFail(80); - - $pdf = new ContractPDFRepository($user); - $pdf->_set('disk', 'user'); - $pdf->_set('dir', '/'.$user->id.'/documents/'); - $pdf->_set('user_id', $user->id); - $pdf->_set('identifier', 'contract'); - $pdf->createContractPDF(); - } - - if(strpos($data['action'], 'checkOne_') !== false){ - $id = (int) str_replace('checkOne_', '', $data['action']); - $shopping_user = ShoppingUser::findOrFail($id); - $ret = CustomerPriority::checkOne($shopping_user); - } - \Session()->flash('alert-success', $ret); - return back(); - } - - public function points() - { - $c = 0; - - if(false){ //8 - dump("make homeparty tax_split in shopping_order"); - dd('check point function'); - $ShoppingOrders = ShoppingOrder::where('payment_for', '=', NULL)->get(); - - foreach($ShoppingOrders as $ShoppingOrder){ - dump($ShoppingOrder->id); - dump($ShoppingOrder->shopping_user->getOrderPaymentFor()); - $ShoppingOrder->payment_for = $ShoppingOrder->shopping_user->getOrderPaymentFor(); - $ShoppingOrder->save(); - - $c ++; - } - dd($c); - } - - - if(false){ //8 - dump("make homeparty tax_split in shopping_order"); - dd('check point function'); - $ShoppingOrders = ShoppingOrder::where('homeparty_id', '!=', NULL)->get(); - //->skip(0)->take(500)->get(); - //->skip(500)->take(500)->get(); - foreach($ShoppingOrders as $ShoppingOrder){ - $ShoppingOrder->makeHomepartyTaxSplit(); - $c ++; - } - dd($c); - } - - if(false){ //7 - dump("make homeparty shipping_tax in homeparty order user_cart"); - dd('check point function'); - $ShoppingOrders = ShoppingOrder::where('homeparty_id', '!=', NULL)->get(); - //->skip(0)->take(500)->get(); - //->skip(500)->take(500)->get(); - foreach($ShoppingOrders as $ShoppingOrder){ - if(isset($ShoppingOrder->homeparty->order['user_carts'])){ - $user_carts = []; - foreach($ShoppingOrder->homeparty->order['user_carts'] as $id => $values){ - $values['shipping_tax'] = round($values['shipping_price'] - $values['shipping_price_net'], 2); - dump($values['shipping_tax']); - $user_carts[$id] = $values; - } - $order = $ShoppingOrder->homeparty->order; - $order['user_carts'] = $user_carts; - $ShoppingOrder->homeparty->order = $order; - $ShoppingOrder->homeparty->save(); - - } - $c ++; - } - dd($c); - } - - if(false){ //6 - dump("make tax_split in shopping_order"); - dd('check point function'); - $ShoppingOrders = ShoppingOrder::where('homeparty_id', '=', NULL)->get(); - //->skip(0)->take(500)->get(); - //->skip(500)->take(500)->get(); - foreach($ShoppingOrders as $ShoppingOrder){ - $ShoppingOrder->makeTaxSplit(); - $c ++; - } - dd($c); - } - - if(false){ //5 - //run after make points etc. - dump("correction shopping_order homeparty"); - //dd('check point function'); - $ShoppingOrders = ShoppingOrder::where('payment_for', 5)->get(); - //->skip(0)->take(500)->get(); - //->skip(500)->take(500)->get(); - foreach($ShoppingOrders as $ShoppingOrder){ - $homeparty = Homeparty::find($ShoppingOrder->homeparty_id); - if($homeparty && $homeparty->completed && $homeparty->step > 10){ - $ShoppingOrder->subtotal = $homeparty->order['ek_price_net']; - $ShoppingOrder->subtotal_ws = 0; - $ShoppingOrder->tax = $ShoppingOrder->total - $homeparty->order['ek_price_net']; - $ShoppingOrder->points = $homeparty->order['points'] - $homeparty->order['bonus_points_diff']; - $ShoppingOrder->save(); - $c ++; - } - - } - dd($c); - } - - if(false){ //4 - dump("make tax in ShoppingOrderItem"); - dd('check point function'); - $ShoppingOrderItems = ShoppingOrderItem::all(); - //->skip(0)->take(500)->get(); - //->skip(500)->take(500)->get(); - foreach($ShoppingOrderItems as $item){ - $item->tax = $item->price - $item->price_net; - $item->save(); - $c ++; - } - dd($c); - } - - - - if(false){ //3 - dump("make price_net in ShoppingOrderItem"); - dd('check point function'); - $ShoppingOrderItems = ShoppingOrderItem::where('price_net', '=', NULL)->get(); - //->skip(0)->take(500)->get(); - //->skip(500)->take(500)->get(); - foreach($ShoppingOrderItems as $item){ - $item->price_net = $item->price / (100 + $item->tax_rate) * 100; - $item->save(); - $c ++; - } - dd($c); - } - - if(false){ //2 - dump("add payment_for in shopping_order"); - dd('check point function'); - $ShoppingUsers = ShoppingUser::all(); - foreach($ShoppingUsers as $ShoppingUser){ - if($ShoppingUser->shopping_order){ - $ShoppingUser->shopping_order->payment_for = $ShoppingUser->getOrderPaymentFor(); - $ShoppingUser->shopping_order->save(); - $c ++; - } - } - dd($c); - } - - if(false){ //1 - dump("make points in shopping_order_item and total in ShoppingOrder"); - dd('check point function'); - $ShoppingOrders = ShoppingOrder::all(); - //->skip(0)->take(500)->get(); - //->skip(500)->take(500)->get(); - foreach($ShoppingOrders as $ShoppingOrder){ - $points_total = 0; - foreach($ShoppingOrder->shopping_order_items as $shopping_order_item){ - $points = $shopping_order_item->product ? $shopping_order_item->product->points : 0; - $points_total += $points; - $shopping_order_item->points = $points; - $shopping_order_item->save(); - $c ++; - } - $ShoppingOrder->points = $points_total; - $ShoppingOrder->save(); - } - dd($c); - } - } - - - - public function cronjobs() - { - //$user_shops = UserShop::all(); - $text = ""; - $values = [ - 'check_payments_account' => route('cron_jobs_action', ['check_payments_account', 'key']) - ]; - $data = [ - 'values' => $values, - 'text' => $text, - ]; - return view('sys.admin.cronjobs', $data); - } - - public function cronjobsStore() - { - $data = Request::all(); - \Session()->flash('alert-save', true); - return back(); - } - - public function domainSSL() - { - $user_shops = UserShop::all(); - $text = ""; - - /* $kas = new KasController(); - $domain = 'mivita.care'; - - $ssl = KasSLLController::getApiSSLParameter(); - - $subdomains = $kas->action('get_subdomains'); - foreach ($subdomains as $subdomain){ - /*if($subdomain['subdomain_name'] === 'bio-aloe.mivita.care'){ - dump($subdomain); - } - if($subdomain['subdomain_name'] === 'rockmyworld-by-conny.mivita.care'){ - dd($subdomain); - }*/ - /* - $text .= $subdomain['subdomain_name']." - ".$subdomain['ssl_certificate_sni']." - "; - - if($subdomain['ssl_certificate_sni'] !== "Y"){ - $pra = array( - 'hostname' => $subdomain['subdomain_name'], - ); - $pra = array_merge($pra, $ssl); - $value = $kas->action('update_ssl', $pra); - $text .= $value; - }else{ - if(isset($subdomain['ssl_certificate_sni_is_active'])){ - $text .= $subdomain['ssl_certificate_sni_is_active'].'-is_active'; - }else{ - $text .= '-CHECK!'; - - } - } - - $text .= "\n"; - }*/ - $data = [ - 'values' => $user_shops, - 'text' => $text, - ]; - - return view('sys.admin.domain-ssl', $data); - } - - public function domainSSLStore() - { - $data = Request::all(); - \Session()->flash('alert-save', true); - return back(); - } - - public function shoppingOrders() - { - $shopping_users = ShoppingUser::all(); - $data = [ - 'values' => $shopping_users, - 'text' => '', - ]; - return view('sys.admin.shopping-orders', $data); - - } - - public function shoppingOrdersStore() - { - //first run - $data = Request::all(); - - if($data['action'] === 'first_run'){ - $shopping_users = ShoppingUser::whereHas('shopping_order', function($q) { - $q->where('txaction', 'paid')->OrWhere('txaction', 'appointed'); - })->get(); - - $order_email = []; - $order_number = []; - - foreach ($shopping_users as $shopping_user){ - $order_email[$shopping_user->billing_email] = isset($order_email[$shopping_user->billing_email]) ? $order_email[$shopping_user->billing_email] + 1 : 1; - if($shopping_user->number) { - $order_number[$shopping_user->number] = isset($order_number[$shopping_user->number]) ? $order_number[$shopping_user->number] + 1 : 1; - $shopping_user->orders = $order_number[$shopping_user->number]; - }else { - $shopping_user->orders = $order_email[$shopping_user->billing_email]; - } - $shopping_user->save(); - - } - \Session()->flash('alert-save', true); - } - - if($data['action'] === 'next_run'){ - Shop::userOrders(); - \Session()->flash('alert-save', true); - } - return back(); - } - -} \ No newline at end of file diff --git a/app/Http/Controllers/Sys/ImportController.php b/app/Http/Controllers/Sys/ImportController.php deleted file mode 100755 index 325d935..0000000 --- a/app/Http/Controllers/Sys/ImportController.php +++ /dev/null @@ -1,54 +0,0 @@ -middleware('sysadmin'); - $this->import = $import; - - } - - - public function import() - { - $data = [ - ]; - return view('sys.admin.import', $data); - } - - - public function importStore() - { - $input = Request::all(); - return $this->import->upload($input); - } - - public function importShow($type, $file, $skip = 0, $limit = 4000) - { - $import = $this->import->read($type, $file, $skip, $limit); - $data = [ - 'limit' => $limit, - 'type' => $type, - 'file' => $file, - 'import' => $import, - 'skip' => $skip, - ]; - return view('sys.admin.import-show', $data); - - } - - - -} \ No newline at end of file diff --git a/app/Http/Controllers/User/OrderController.php b/app/Http/Controllers/User/OrderController.php index 7552345..a8efc3a 100755 --- a/app/Http/Controllers/User/OrderController.php +++ b/app/Http/Controllers/User/OrderController.php @@ -378,7 +378,7 @@ class OrderController extends Controller } //get the card item - $cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(false, true, Yard::instance('shopping')->getUserCountry()), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]); + $cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(false, true, Yard::instance('shopping')->getUserCountry()), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission]); Yard::setTax($cartItem->rowId, $product->getTaxWith(Yard::instance('shopping')->getUserCountry())); if(isset($data['qty']) && $data['qty'] > 0){ diff --git a/app/Http/Controllers/User/TeamController.php b/app/Http/Controllers/User/TeamController.php index 23de8fd..4045db8 100755 --- a/app/Http/Controllers/User/TeamController.php +++ b/app/Http/Controllers/User/TeamController.php @@ -2,8 +2,12 @@ namespace App\Http\Controllers\User; -use App\Http\Controllers\Controller; use App\User; +use App\Services\HTMLHelper; +use App\Http\Controllers\Controller; +use App\Services\BusinessPlan\TreeCalcBot; +use Request; + class TeamController extends Controller @@ -28,4 +32,40 @@ class TeamController extends Controller ]; return view('user.team.members', $data); } + + public function structure() + { + $user = User::find(\Auth::user()->id); + $this->setFilterVars(); + $TreeCalcBot = new TreeCalcBot(session('team_user_filter_month'), session('team_user_filter_year'), 'member'); + $TreeCalcBot->initUser($user->id); + //for testing + //$TreeCalcBot->initUser(56); + $data = [ + 'filter_months' => HTMLHelper::$months, + 'filter_years' => HTMLHelper::getYearRange(2022), + 'TreeCalcBot' => $TreeCalcBot, + ]; + return view('user.team.structure', $data); + } + + + private function setFilterVars(){ + + if(!session('team_user_filter_month')){ + session(['team_user_filter_month' => intval(date('m'))]); + } + if(!session('team_user_filter_year')){ + session(['team_user_filter_year' => intval(date('Y'))]); + } + + if(Request::get('team_user_filter_month')){ + session(['team_user_filter_month' => Request::get('team_user_filter_month')]); + } + if(Request::get('team_user_filter_year')){ + session(['team_user_filter_year' => Request::get('team_user_filter_year')]); + } + } + + } \ No newline at end of file diff --git a/app/Http/Controllers/UserDataController.php b/app/Http/Controllers/UserDataController.php index e3c42d9..24702c4 100755 --- a/app/Http/Controllers/UserDataController.php +++ b/app/Http/Controllers/UserDataController.php @@ -45,43 +45,14 @@ class UserDataController extends Controller /*if(!$user->account){ $user->account = new UserAccount(); }*/ - $data = Request::all(); + if(isset($data['reverse_charge_validate'])){ - - $rules = array( - 'tax_identification_number' => 'required', - 'reverse_charge' => 'required', - ); - $validator = Validator::make(Request::all(), $rules); - if ($validator->fails()) { - $data = [ - 'user' => $user, - ]; - return view('user.edit', $data)->withErrors($validator); - } - $ret = $this->userRepo->reverse_charge_activate(Request::all(), $user); - if($ret === 'error'){ - $validator = Validator::make(Request::all(), []); - $validator->errors()->add('tax_identification_number', __('Die UST-ID konnte nicht validiert werden, Eingabe bitte prüfen.')); - $data['reverse_charge'] = 0; - return redirect(route('user_edit'))->withErrors($validator)->withInput($data); - } - if($ret === 'valid'){ - \Session()->flash('alert-success', 'UST-ID erfolgreich eingetragen.'); - return redirect('/user/edit'); - - } + return $this->userRepo->reverse_charge_validate($data, $user); } + if(isset($data['reverse_charge_delete'])){ - $user->account->tax_identification_number = ''; - $user->account->reverse_charge = 0; - $user->account->reverse_charge_code = null; - $user->account->reverse_charge_valid = null; - $user->account->save(); - \Session()->flash('alert-success', 'Reverse Charge Verfahren und UST-ID gelöscht.'); - return redirect('/user/edit'); - + return $this->userRepo->reverse_charge_delete($data, $user); } $rules = array( diff --git a/app/Http/Controllers/UserLevelController.php b/app/Http/Controllers/UserLevelController.php index f18381d..ad7ced5 100755 --- a/app/Http/Controllers/UserLevelController.php +++ b/app/Http/Controllers/UserLevelController.php @@ -2,9 +2,6 @@ namespace App\Http\Controllers; - -use App\Models\Attribute; -use App\Models\ProductAttribute; use App\Models\UserLevel; use Request; @@ -19,9 +16,8 @@ class UserLevelController extends Controller public function index() { - $data = [ - 'values' => UserLevel::all(), + 'values' => UserLevel::orderBy('pos', 'asc')->get(), 'trans' => array_keys(config('localization.supportedLocales')), ]; return view('admin.level.index', $data); @@ -31,23 +27,27 @@ class UserLevelController extends Controller { $data = Request::all(); + $data['active'] = isset($data['active']) ? true : false; + $data['default'] = isset($data['default']) ? true : false; + $data['next_id'] = (isset($data['next_id']) && $data['next_id'] != 0) ? $data['next_id'] : null; + //is true -> set all other of false; + if($data['default'] === true){ + $values = UserLevel::all(); + foreach ($values as $value) { + $value->default = false; + $value->save(); + } + } + if($data['id'] == "new"){ - $model = UserLevel::create([ - 'name' => $data['name'], - 'pos' => $data['pos'], - 'margin' => $data['margin'], - 'active' => isset($data['active']) ? true : false, - ]); + $model = UserLevel::create($data); }else{ $model = UserLevel::find($data['id']); - $model->name = $data['name']; - $model->pos = $data['pos']; - $model->margin = $data['margin']; - $model->active = isset($data['active']) ? true : false; + $model->fill($data); $model->save(); } - if(!empty($data['trans'])){ + /*if(!empty($data['trans'])){ $trans = []; foreach ($data['trans'] as $lang => $value){ if($value && $value != null){ @@ -58,7 +58,7 @@ class UserLevelController extends Controller $model->trans_name = $trans; $model->save(); } - } + }*/ \Session()->flash('alert-save', '1'); return redirect(route('admin_levels')); diff --git a/app/Http/Controllers/Web/CardController.php b/app/Http/Controllers/Web/CardController.php index 93d3d25..ded2af7 100755 --- a/app/Http/Controllers/Web/CardController.php +++ b/app/Http/Controllers/Web/CardController.php @@ -33,7 +33,7 @@ class CardController extends Controller if($product->images->count()){ $image = $product->images->first()->slug; } - $cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]); + $cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission]); if(Yard::instance('shopping')->getUserTaxFree()){ Yard::setTax($cartItem->rowId, 0); }else{ @@ -59,7 +59,7 @@ class CardController extends Controller $image = $product->images->first()->slug; } $quantity = Request::get('quantity') ? Request::get('quantity') : 1; - $cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]); + $cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission]); if(Yard::instance('shopping')->getUserTaxFree()){ Yard::setTax($cartItem->rowId, 0); }else{ diff --git a/app/Http/Controllers/Web/CheckoutController.php b/app/Http/Controllers/Web/CheckoutController.php index 3eb3b32..276da26 100755 --- a/app/Http/Controllers/Web/CheckoutController.php +++ b/app/Http/Controllers/Web/CheckoutController.php @@ -110,19 +110,7 @@ class CheckoutController extends Controller //$shopping_user->save(); } - - - if($is_from !== 'shopping' && Util::getAuthUser()){ - $user = Util::getAuthUser(); - $payment_methods = $user->payment_methods; - $payment_data = $user->account->payment_data; - }else{ - $payment_methods = PaymentMethod::getDefaultAsArray()->toArray(); - $payment_data = false; - } - - $payment_methods_active = \App\Models\PaymentMethod::where('active', true)->get()->pluck( 'id', 'short')->toArray(); - + $payment_methods = $this->getPaymentsMethods($is_from); $data = [ 'is_from' => $is_from, 'is_for' => $is_for, @@ -130,13 +118,40 @@ class CheckoutController extends Controller 'user_shop' => Util::getUserShop(), 'shopping_user' => $shopping_user, 'shopping_mode' => Util::getUserShoppingMode(), - 'payment_methods' => $payment_methods, - 'payment_methods_active' => $payment_methods_active, - 'payment_data' => $payment_data, + 'payment_methods' => $payment_methods['default'], + 'payment_methods_active' => $payment_methods['active'], + 'payment_data' => $payment_methods['data'], ]; return view('web.templates.checkout', $data); } + private function getPaymentsMethods($is_from){ + $payment_methods = []; + if($is_from !== 'shopping' && Util::getAuthUser()){ + $user = Util::getAuthUser(); + $payment_methods['default'] = $user->payment_methods; + $payment_methods['data'] = $user->account->payment_data; + }else{ + $payment_methods['default'] = PaymentMethod::getDefaultAsArray()->toArray(); + $payment_methods['data'] = false; + } + + $payment_methods['active'] = \App\Models\PaymentMethod::where('active', true)->get()->pluck( 'id', 'short')->toArray(); + return $payment_methods; + } + + private function isPaymentsMethodsActive($payment_method, $is_from){ + $payment_names = ['wlt#PPE' => 'PP', 'cc' => 'CC', 'sb#PNT' => 'SB', 'elv' => 'SEPA', 'vor' => 'VOR', 'fnc#MIV' => 'FNC']; + $payment_methods = $this->getPaymentsMethods($is_from); + if(isset($payment_names[$payment_method])){ + $payment_with = $payment_names[$payment_method]; + if(array_key_exists($payment_with, $payment_methods['active']) && in_array($payment_methods['active'][$payment_with], $payment_methods['default'])){ + return true; + } + } + abort(404); + } + private function shoppingUserAuthData($is_from, $is_for, $data = []){ $user = Util::getAuthUser(); @@ -217,8 +232,11 @@ class CheckoutController extends Controller public function checkoutFinal(){ - $data = Request::all(); + if(isset($data['payment_method'])){ + $this->isPaymentsMethodsActive($data['payment_method'], $data['is_from']); + } + //change selected Country if(isset($data['selected_country']) && $data['selected_country'] === 'change'){ if(!Request::get('same_as_billing')){ @@ -541,7 +559,7 @@ class CheckoutController extends Controller 'tax_rate' => $item->taxRate, 'tax' => $tax, 'price_vk_net' => $shopping_order->getPriceVkNetBy($item->id), - 'discount' => $shopping_order->getUserDiscount(), + 'discount' => $item->options->no_commission ? 0 : $shopping_order->getUserDiscount(), 'points' => $item->options->points, 'slug' => $item->options->slug, ]; @@ -572,7 +590,7 @@ class CheckoutController extends Controller 'tax_rate' => $item->taxRate, 'tax' => $tax, 'price_vk_net' => $shopping_order->getPriceVkNetBy($item->id), - 'discount' => $shopping_order->getUserDiscount(), + 'discount' => $item->options->no_commission ? 0 : $shopping_order->getUserDiscount(), 'points' => $item->options->points, 'slug' => $item->options->slug ]; diff --git a/app/Http/Controllers/Web/RegisterController.php b/app/Http/Controllers/Web/RegisterController.php index 26bc85e..23f1d79 100755 --- a/app/Http/Controllers/Web/RegisterController.php +++ b/app/Http/Controllers/Web/RegisterController.php @@ -3,17 +3,18 @@ namespace App\Http\Controllers\Web; -use App\Http\Controllers\Controller; -use App\Mail\MailContact; -use App\Mail\MailVerifyAccount; -use App\Repositories\UserRepository; -use App\Services\UserService; -use App\User; -use GuzzleHttp\Client; use Request; -use Illuminate\Support\Facades\Mail; -use App\Services\Util; +use App\User; use Validator; +use App\Services\Util; +use GuzzleHttp\Client; +use App\Mail\MailContact; +use App\Models\UserLevel; +use App\Services\UserService; +use App\Mail\MailVerifyAccount; +use App\Http\Controllers\Controller; +use App\Repositories\UserRepository; +use Illuminate\Support\Facades\Mail; class RegisterController extends Controller @@ -104,7 +105,15 @@ class RegisterController extends Controller $user->confirmation_code_to = date('Y-m-d H:i:s', strtotime('+1 week')); $user->confirmation_code_remider = 0; $user->m_sponsor = $m_sponsor_id; - $user->m_level = 1; + + $UserLevel = UserLevel::where('default', 1)->first(); + if($UserLevel){ + $user->m_level = $UserLevel->id; + }else{ + $user->m_level = 10; + + } + $user->save(); $user->account->data_protection = now(); diff --git a/app/Http/Controllers/WizardController.php b/app/Http/Controllers/WizardController.php index 2bfb855..1ed9b19 100755 --- a/app/Http/Controllers/WizardController.php +++ b/app/Http/Controllers/WizardController.php @@ -18,6 +18,7 @@ use App\Models\ShippingCountry; use App\Mail\MailReleaseAccount; use App\Models\ShoppingInstance; use App\Repositories\FileRepository; +use App\Repositories\UserRepository; use Illuminate\Support\Facades\Mail; class WizardController extends Controller @@ -100,6 +101,10 @@ class WizardController extends Controller 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(), ]; if($step == 5){ + if($user->active){ + $user->active = false; + $user->save(); + } return view('user.wizard.register_release', $data); } @@ -211,6 +216,22 @@ class WizardController extends Controller return redirect(route('wizard_register')); } if ($step == 1) { + $data = Request::all(); + + if(isset($data['reverse_charge_validate'])){ + $user->wizard = 1; + $user->save(); + $userRepo = new UserRepository($user); + return $userRepo->reverse_charge_validate($data, $user); + } + + if(isset($data['reverse_charge_delete'])){ + $user->wizard = 1; + $user->save(); + $userRepo = new UserRepository($user); + return $userRepo->reverse_charge_delete($data, $user); + } + $rules = array( 'salutation' => 'required', 'first_name' => 'required', @@ -241,7 +262,6 @@ class WizardController extends Controller $user->save(); return redirect(route('wizard_register', [1]))->withErrors($validator)->withInput(Request::all()); } - $data = Request::all(); $data['same_as_billing'] = Request::get('same_as_billing') == NULL ? 0 : 1; $user->account->fill($data)->save(); $user->wizard = 2; @@ -478,8 +498,7 @@ class WizardController extends Controller 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]); + $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]); if(\App\Services\UserService::getTaxFree()){ Yard::setTax($cartItem->rowId, 0); }else{ @@ -494,7 +513,7 @@ class WizardController extends Controller 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]); + $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]); if(\App\Services\UserService::getTaxFree()){ Yard::setTax($cartItem->rowId, 0); }else{ diff --git a/app/Http/Middleware/Checkout.php b/app/Http/Middleware/Checkout.php index 4535a47..1ec495d 100755 --- a/app/Http/Middleware/Checkout.php +++ b/app/Http/Middleware/Checkout.php @@ -59,7 +59,6 @@ class Checkout if(\Session::has('user_shop') && \Session::has('isCheckout') && Yard::instance('shopping')->count()){ return $next($request); } - return redirect(config('app.url')); } diff --git a/app/Http/Middleware/Subdomain.php b/app/Http/Middleware/Subdomain.php index 87456b1..704a1f3 100755 --- a/app/Http/Middleware/Subdomain.php +++ b/app/Http/Middleware/Subdomain.php @@ -30,7 +30,10 @@ class Subdomain if(!$user_shop->active){ abort(503); } - if(!$user_shop->user && !$user_shop->user->isActiveShop()){ + if(!$user_shop->user){ + abort(503); + } + if(!$user_shop->user->isActiveShop()){ abort(503); } \Session::put('user_shop', $user_shop); @@ -52,7 +55,7 @@ class Subdomain return $next($request); } } - return redirect(config('app.url') .$tld); + return redirect(config('app.url')); } } diff --git a/app/Models/UserInvoiceCredit.php b/app/Models/Models/_UserInvoiceCredit.php similarity index 98% rename from app/Models/UserInvoiceCredit.php rename to app/Models/Models/_UserInvoiceCredit.php index 8b834c9..3c973a3 100644 --- a/app/Models/UserInvoiceCredit.php +++ b/app/Models/Models/_UserInvoiceCredit.php @@ -206,12 +206,6 @@ class UserInvoiceCredit extends Model return isset($this->attributes['cancellation_date']) ? $this->attributes['cancellation_date'] : NULL; } - public static function getYearRange() - { - $start = 2021; - $end = date("Y"); - return array_reverse(range($start, $end)); - } public static function getMonthName($month) { diff --git a/app/Models/Product.php b/app/Models/Product.php index d4b5558..b28a9b2 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -163,6 +163,7 @@ class Product extends Model 'contents_total', 'unit', 'number', + 'ean', 'wp_number', 'icons', 'description', @@ -183,8 +184,8 @@ class Product extends Model '' => '-', 'show_upgrade' => 'Kann geupdatet werden', 'show_order' => 'Wird immer als Option angezeigt', - 'upgrade' => 'Produktupgrade zur Produkt ID', - 'upgrade_member' => 'Beraterupgrade zur Karriere ID', + 'upgrade_product' => 'Produkt upgrade zur Produkt ID', + 'upgrade_member' => 'Berater upgrade zur Karriere ID', 'proportional_voucher' => 'Anteiliger Gutschein Berater', ]; public $unitTypes = [ @@ -224,6 +225,14 @@ class Product extends Model ]; + public $actionNames = [ + 0 => 'Zahlung für Mitgliedschaft', + 1 => 'Zahlung für Mitgliedschaft + Shop', + 2 => 'Bei Zahlung Shop upgrade auf ID', + 4 => 'Bei Zahlung Karriere upgrade auf ID', + + ]; + public function sluggable() { return [ @@ -249,6 +258,17 @@ class Product extends Model return $this->hasMany('App\Models\ProductImage', 'product_id', 'id')->where('active', true)->orderBy('pos'); } + public function getImageUrl(){ + if(count($this->imagesActive)){ + return route('product_image', [$this->imagesActive->first()->slug]); + } + return ""; + } + + public function getProductUrl(){ + return 'https://mivita.shop/produkte/alle-produkte/'.$this->slug; + } + public function country_prices() { return $this->hasMany(CountryPrice::class, 'product_id'); @@ -267,13 +287,26 @@ class Product extends Model return $this->hasMany(ProductIngredient::class, 'product_ingredients', 'id'); } - public function getActionName($id = 0){ if(isset($this->actions[$id])){ return $this->actions[$id]; } return false; } + + public function getUpgradeToIdName($from){ + if($from === 'payment_for_shop_upgrade'){ + $value = Product::find($this->upgrade_to_id); + } + if($from === 'payment_for_lead_upgrade'){ + $value = UserLevel::find($this->upgrade_to_id); + } + if($value){ + return $value->name; + } + return "not found"; + } + public function _format_number($value){ return preg_replace("/[^0-9,]/", "", $value); } diff --git a/app/Models/ShoppingOrder.php b/app/Models/ShoppingOrder.php index 99b5138..fc3fd70 100644 --- a/app/Models/ShoppingOrder.php +++ b/app/Models/ShoppingOrder.php @@ -85,6 +85,11 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property-read \App\Models\Homeparty|null $homeparty * @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereHomepartyId($value) * @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereWpNotice($value) + * @property array|null $tax_split + * @property-read \App\Models\UserInvoice|null $user_invoice + * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserSalesVolume[] $user_sales_volume + * @property-read int|null $user_sales_volume_count + * @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereTaxSplit($value) */ class ShoppingOrder extends Model { @@ -265,6 +270,19 @@ class ShoppingOrder extends Model return ""; } + public function getLastShoppingPaymentTransaction(){ + if($this->shopping_payments){ + $shopping_payment = $this->shopping_payments->last(); + if($shopping_payment){ + $payt = $shopping_payment->payment_transactions->last(); + if($payt){ + return $payt; + } + } + } + return false; + } + public function getShippedType(){ return isset(self::$shippedTypes[$this->shipped]) ? self::$shippedTypes[$this->shipped] : ""; } diff --git a/app/Models/ShoppingOrderItem.php b/app/Models/ShoppingOrderItem.php index 86b7e20..388b04d 100644 --- a/app/Models/ShoppingOrderItem.php +++ b/app/Models/ShoppingOrderItem.php @@ -48,6 +48,14 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property int|null $homeparty_id * @property-read \App\Models\Homeparty|null $homeparty * @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem whereHomepartyId($value) + * @property string|null $tax + * @property string|null $price_vk_net + * @property string|null $discount + * @property int|null $points + * @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem whereDiscount($value) + * @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem wherePoints($value) + * @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem wherePriceVkNet($value) + * @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem whereTax($value) */ class ShoppingOrderItem extends Model { diff --git a/app/Models/UserAccount.php b/app/Models/UserAccount.php index 8671b47..6c2d475 100644 --- a/app/Models/UserAccount.php +++ b/app/Models/UserAccount.php @@ -133,7 +133,7 @@ class UserAccount extends Model 'm_account', 'm_salutation', 'm_first_name', 'm_last_name', 'm_notes', 'company', 'salutation', 'first_name', 'last_name', 'address', 'address_2', 'zipcode', 'city', 'country_id', 'pre_phone_id', 'phone', 'pre_mobil_id', 'mobil', 'tax_number', 'tax_identification_number', 'taxable_sales', 'same_as_billing', 'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_country_id', 'shipping_pre_phone_id', 'shipping_phone', - 'birthday', 'website', 'facebook', 'facebook_fanpage', 'instagram', 'notice' + 'birthday', 'website', 'facebook', 'facebook_fanpage', 'instagram', 'bank_owner', 'bank_iban', 'bank_bic', 'notice' ]; //'reverse_charge', 'reverse_charge_valid' diff --git a/app/Models/UserInvoice.php b/app/Models/UserInvoice.php index 22010bd..c779ceb 100644 --- a/app/Models/UserInvoice.php +++ b/app/Models/UserInvoice.php @@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class UserInvoice - * + * * @property int $id * @property int $shopping_order_id * @property int|null $month @@ -31,10 +31,42 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property Carbon|null $created_at * @property Carbon|null $updated_at * @property string|null $deleted_at - * * @property ShoppingOrder $shopping_order - * * @package App\Models + * @property string|null $filename + * @property string|null $dir + * @property string|null $delivery_filename + * @property string|null $delivery_dir + * @property string|null $disk + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice newModelQuery() + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice newQuery() + * @method static \Illuminate\Database\Query\Builder|UserInvoice onlyTrashed() + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice query() + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereCancellation($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereCancellationDate($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereCancellationId($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereCreatedAt($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereDate($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereDeletedAt($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereDeliveryDir($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereDeliveryFilename($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereDir($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereDisk($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereFilename($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereFullNumber($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereId($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereInfos($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereMonth($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereNumber($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice wherePaid($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice wherePaidDate($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereShoppingOrderId($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereStatus($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereUpdatedAt($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereYear($value) + * @method static \Illuminate\Database\Query\Builder|UserInvoice withTrashed() + * @method static \Illuminate\Database\Query\Builder|UserInvoice withoutTrashed() + * @mixin \Eloquent */ class UserInvoice extends Model { @@ -146,13 +178,6 @@ class UserInvoice extends Model public function getCancellationDateRaw(){ return isset($this->attributes['cancellation_date']) ? $this->attributes['cancellation_date'] : NULL; } - - public static function getYearRange() - { - $start = 2021; - $end = date("Y"); - return array_reverse(range($start, $end)); - } public static function getMonthName($month) { diff --git a/app/Models/UserLevel.php b/app/Models/UserLevel.php index d752aa7..4ca1e30 100644 --- a/app/Models/UserLevel.php +++ b/app/Models/UserLevel.php @@ -2,7 +2,9 @@ namespace App\Models; +use App\Services\Util; use Illuminate\Database\Eloquent\Model; +use App\Models\UserLevel as ModelsUserLevel; /** * App\Models\UserLevel @@ -13,12 +15,14 @@ use Illuminate\Database\Eloquent\Model; * @property float|null $margin * @property int|null $pos * @property int $active + * @property int $default * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at * @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 query() * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereActive($value) + * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereDefault($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereCreatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereId($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereMargin($value) @@ -27,6 +31,29 @@ use Illuminate\Database\Eloquent\Model; * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereTransName($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereUpdatedAt($value) * @mixin \Eloquent + * @property int|null $next_id + * @property int|null $margin_shop + * @property int|null $qual_kp + * @property int|null $qual_tp + * @property string|null $growth_bonus + * @property int|null $pr_line_1 + * @property int|null $pr_line_2 + * @property int|null $pr_line_3 + * @property int|null $pr_line_4 + * @property int|null $pr_line_5 + * @property int|null $pr_line_6 + * @property-read UserLevel|null $next_user_level + * @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereGrowthBonus($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereMarginShop($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereNextId($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine1($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine2($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine3($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine4($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine5($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine6($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereQualKp($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereQualTp($value) */ class UserLevel extends Model { @@ -35,41 +62,40 @@ class UserLevel extends Model protected $casts = ['trans_name' => 'array']; protected $fillable = [ - 'name', 'margin', 'pos', 'active', + 'next_id', 'name', 'margin', 'margin_shop', 'qual_kp', 'qual_tp', 'growth_bonus', 'pr_line_1', 'pr_line_2', 'pr_line_3', 'pr_line_4', 'pr_line_5', 'pr_line_6', 'pos', 'active', 'default', ]; - /* public function childrens() + public function next_user_level() { - return $this->hasMany('App\Models\Attribute', 'parent_id', 'id'); + return $this->belongsTo('App\Models\UserLevel', 'next_id', 'id'); + } + + public function getNextUserLevels(){ + //$ret = [0=>'Keinen']; + $ret = UserLevel::where('active', true)->where('id', '!=', $this->id)->orderBy('pos', 'asc')->get()->pluck('name', 'id')->toArray(); + return array_add($ret, 0, '-> Keinen Karriere Level'); } - */ public function setPosAttribute($value){ $this->attributes['pos'] = is_numeric($value) ? $value : null; } - - public function _format_number($value){ - return preg_replace("/[^0-9,]/", "", $value); + public function setGrowthBonusAttribute($value) + { + $this->attributes['growth_bonus'] = $value !== null ? Util::reFormatNumber($value) : null; } - - public function setMarginAttribute( $value ) { - $value = $this->_format_number($value); - $this->attributes['margin'] = floatval(str_replace(',', '.', $value)); + public function getFormattedGrowthBonus() + { + return isset($this->attributes['growth_bonus']) ? Util::formatNumber($this->attributes['growth_bonus'],1) : ""; } public function getFormattedMargin() { - if(!isset($this->attributes['margin'])){ - return ""; - } - if(\App::getLocale() === "en"){ - return number_format($this->attributes['margin'], 2, '.', ','); - } - return number_format($this->attributes['margin'], 2, ',', '.'); + return isset($this->attributes['margin']) ? $this->attributes['margin'] : ""; } + public function getLang($key) { diff --git a/app/Models/UserSalesVolume.php b/app/Models/UserSalesVolume.php index 37d6199..8b91039 100644 --- a/app/Models/UserSalesVolume.php +++ b/app/Models/UserSalesVolume.php @@ -9,10 +9,11 @@ namespace App\Models; use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; use App\Models\ShoppingOrder; +use App\User; /** * Class UserSalesVolume - * + * * @property int $id * @property int $user_id * @property int|null $shopping_order_id @@ -27,11 +28,34 @@ use App\Models\ShoppingOrder; * @property int $status * @property Carbon|null $created_at * @property Carbon|null $updated_at - * * @property ShoppingOrder|null $shopping_order * @property User $user - * * @package App\Models + * @property int|null $user_invoice_id + * @property int|null $month_shop_points + * @property float|null $month_shop_total_net + * @property-read \App\Models\UserInvoice|null $user_invoice + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume newModelQuery() + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume newQuery() + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume query() + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereCreatedAt($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereDate($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereId($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMessage($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMonth($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMonthPoints($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMonthShopPoints($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMonthShopTotalNet($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMonthTotalNet($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume wherePoints($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereShoppingOrderId($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereStatus($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereTotalNet($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereUpdatedAt($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereUserId($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereUserInvoiceId($value) + * @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereYear($value) + * @mixin \Eloquent */ class UserSalesVolume extends Model { diff --git a/app/Repositories/InvoiceRepository.php b/app/Repositories/InvoiceRepository.php index ad9b3d2..1580939 100644 --- a/app/Repositories/InvoiceRepository.php +++ b/app/Repositories/InvoiceRepository.php @@ -2,13 +2,14 @@ namespace App\Repositories; -use App\Libraries\InvoicePDF; use PDF; use Storage; use App\Services\Invoice; use App\Models\UserInvoice; +use App\Libraries\InvoicePDF; use App\Models\ShoppingOrder; use App\Services\MyPDFMerger; +use App\Services\UserService; use App\Models\UserSalesVolume; class InvoiceRepository extends BaseRepository { @@ -32,7 +33,10 @@ class InvoiceRepository extends BaseRepository { { //need invoice $data $number = Invoice::getInvoiceNumber(); - $this->invoice_date = isset($request['invoice_date']) ? $request['invoice_date'] : $this->model->created_at->format("d.m.Y"); + if($payt = $this->model->getLastShoppingPaymentTransaction()){ + $invoice_date = $payt->created_at->format("d.m.Y"); + } + $this->invoice_date = isset($request['invoice_date']) ? $request['invoice_date'] : $invoice_date; $invoice_send_mail = isset($request['invoice_send_mail']) ? false : true; $this->invoice_number = Invoice::createInvoiceNumber($number, $this->invoice_date); $this->dir = Invoice::getInvoiceStorageDir($this->invoice_date); @@ -100,6 +104,7 @@ class InvoiceRepository extends BaseRepository { } private function makePDF(){ + $data = [ 'shopping_order' => $this->model, 'invoice_date' => $this->invoice_date, @@ -107,6 +112,11 @@ class InvoiceRepository extends BaseRepository { 'user_sales_volume' => $this->user_sales_volume, ]; + if($this->model->auth_user_id){ + UserService::checkUserTaxShippingCountry($this->model->auth_user, $this->model->country_id); + $data = array_merge($data, UserService::getYardInfo()); + } + if(!Storage::disk('public')->exists( $this->dir )){ Storage::disk('public')->makeDirectory($this->dir); //creates directory } @@ -144,8 +154,10 @@ class InvoiceRepository extends BaseRepository { */ $status = UserSalesVolume::getStatusByOrder($this->model); $user_id = $this->model->auth_user_id ? $this->model->auth_user_id : $this->model->member_id; + //akuteller tag / Monat. $month = date('m'); $year = date('Y'); + $date = date('d.m.Y'); if($status === 3){ //shop bestellung User pending $user_id = $this->model->auth_user_id ? $this->model->auth_user_id : $this->model->member_id; @@ -175,7 +187,7 @@ class InvoiceRepository extends BaseRepository { 'shopping_order_id' => $this->model->id, 'month' => $month, 'year' => $year, - 'date' => date('d.m.Y'), + 'date' => $date, 'points' => $this->model->points, 'month_points' => $month_points, 'month_shop_points' => $month_shop_points, diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index 7ce87bc..e3b60fa 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -2,12 +2,14 @@ namespace App\Repositories; -use App\Models\PaymentMethod; -use App\Models\UserAccount; use App\User; +use App\Models\UserAccount; +use App\Models\PaymentMethod; use Illuminate\Support\Facades\Hash; - - +use App\Http\Controllers\Api\KasController; +use Util; +use Validator; +use Request; class UserRepository extends BaseRepository { @@ -17,8 +19,6 @@ class UserRepository extends BaseRepository { $this->model = $model; } - - public function update($data) { @@ -74,81 +74,28 @@ class UserRepository extends BaseRepository { return $this->model; } - public function reverse_charge_activate($data, $user){ - - /* 'AT' => 'AT-Oesterreich', - 'BE' => 'BE-Belgien', - 'BG' => 'BG-Bulgarien', - 'CY' => 'CY-Zypern', - 'CZ' => 'CZ-Tschechische Republik', - 'DE' => 'DE-Deutschland', - 'DK' => 'DK-Dänemark', - 'EE' => 'EE-Estland', - 'EL' => 'EL-Griechenland', - 'ES' => 'ES-Spanien', - 'FI' => 'FI-Finnland', - 'FR' => 'FR-Frankreich ', - 'HR' => 'HR-Kroatien ', - 'HU' => 'HU-Ungarn', - 'IE' => 'IE-Irland', - 'IT' => 'IT-Italien', - 'LT' => 'LT-Litauen', - 'LU' => 'LU-Luxemburg', - 'LV' => 'LV-Lettland', - 'MT' => 'MT-Malta', - 'NL' => 'NL-Niederlande', - 'PL' => 'PL-Polen', - 'PT' => 'PT-Portugal', - 'RO' => 'RO-Rumänien', - 'SE' => 'SE-Schweden', - 'SI' => 'SI-Slowenien', - 'SK' => 'SK-Slowakei', - 'XI' => 'XI-Nordirland', */ - $countryCode = 'DE'; - - if($user->account->country_id){ - $countryCode = $user->account->country->code; - } - - $vatid = str_replace(array(' ', '.', '-', ',', ', '), '', trim($data['tax_identification_number'])); - $cc = substr($vatid, 0, 2); - $vatNo = substr($vatid, 2); - - $options = [ - 'cache_wsdl' => WSDL_CACHE_NONE, - 'trace' => 1, - 'stream_context' => stream_context_create( - [ - 'ssl' => [ - 'verify_peer' => false, - 'verify_peer_name' => false, - 'allow_self_signed' => true - ] - ] - ) - ]; - - $client = new \SoapClient("https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl", $options); - $result = $client->checkVat(['countryCode' => $countryCode, 'vatNumber' => $vatNo]); - - if($result->valid == true) { - $user->account->tax_identification_number = $data['tax_identification_number']; - $user->account->reverse_charge = 1; - $user->account->reverse_charge_code = $countryCode; - $user->account->reverse_charge_valid = now(); - $user->account->save(); - return 'valid'; - } else { - return 'error'; - } - - - } + public function deleteUser(User $user) { if($user->account){ $user->account->delete(); } + if($user->shop){ + $subdomain_name = $user->shop->slug.'.mivita.care'; + $user->shop->name = "delete".$user->shop->id; + $user->shop->slug = "delete".$user->shop->id; + $user->shop->save(); + $user->shop->delete(); + //isset KAS - delete Subdomain + if(!Util::isTestSystem()){ + $kas = new KasController(); + $pra = array( + 'subdomain_name' => $subdomain_name, + ); + $kas->action('delete_subdomain', $pra); + } + + } $user->email = "delete".time(); $user->password = "delete".time(); $user->confirmed = 0; @@ -167,5 +114,114 @@ class UserRepository extends BaseRepository { return true; } + public function reverse_charge_validate($data, $user){ + if(isset($data['reverse_charge_validate'])){ + $rules = array( + 'tax_identification_number' => 'required', + 'reverse_charge' => 'required', + ); + $validator = Validator::make($data, $rules); + if ($validator->fails()) { + $data = [ + 'user' => $user, + ]; + return view('user.edit', $data)->withErrors($validator); + } + $ret = $this->reverse_charge_activate($data, $user); + if($ret === 'error'){ + $validator = Validator::make($data, []); + $validator->errors()->add('tax_identification_number', __('Die UST-ID konnte nicht validiert werden, Eingabe bitte prüfen.')); + $data['reverse_charge'] = 0; + return redirect(route('user_edit'))->withErrors($validator)->withInput($data); + } + if($ret === 'valid'){ + \Session()->flash('alert-success', 'UST-ID erfolgreich eingetragen.'); + return redirect('/user/edit'); + } + } + } + + public function reverse_charge_delete($data, $user){ + if(isset($data['reverse_charge_delete'])){ + $user->account->tax_identification_number = ''; + $user->account->reverse_charge = 0; + $user->account->reverse_charge_code = null; + $user->account->reverse_charge_valid = null; + $user->account->save(); + \Session()->flash('alert-success', 'Reverse Charge Verfahren und UST-ID gelöscht.'); + return redirect('/user/edit'); + } + } + + public function reverse_charge_activate($data, $user){ + + /* 'AT' => 'AT-Oesterreich', + 'BE' => 'BE-Belgien', + 'BG' => 'BG-Bulgarien', + 'CY' => 'CY-Zypern', + 'CZ' => 'CZ-Tschechische Republik', + 'DE' => 'DE-Deutschland', + 'DK' => 'DK-Dänemark', + 'EE' => 'EE-Estland', + 'EL' => 'EL-Griechenland', + 'ES' => 'ES-Spanien', + 'FI' => 'FI-Finnland', + 'FR' => 'FR-Frankreich ', + 'HR' => 'HR-Kroatien ', + 'HU' => 'HU-Ungarn', + 'IE' => 'IE-Irland', + 'IT' => 'IT-Italien', + 'LT' => 'LT-Litauen', + 'LU' => 'LU-Luxemburg', + 'LV' => 'LV-Lettland', + 'MT' => 'MT-Malta', + 'NL' => 'NL-Niederlande', + 'PL' => 'PL-Polen', + 'PT' => 'PT-Portugal', + 'RO' => 'RO-Rumänien', + 'SE' => 'SE-Schweden', + 'SI' => 'SI-Slowenien', + 'SK' => 'SK-Slowakei', + 'XI' => 'XI-Nordirland', */ + $countryCode = 'DE'; + + if($user->account->country_id){ + $countryCode = $user->account->country->code; + } + + $vatid = str_replace(array(' ', '.', '-', ',', ', '), '', trim($data['tax_identification_number'])); + $cc = substr($vatid, 0, 2); + $vatNo = substr($vatid, 2); + + $options = [ + 'cache_wsdl' => WSDL_CACHE_NONE, + 'trace' => 1, + 'stream_context' => stream_context_create( + [ + 'ssl' => [ + 'verify_peer' => false, + 'verify_peer_name' => false, + 'allow_self_signed' => true + ] + ] + ) + ]; + + $client = new \SoapClient("https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl", $options); + $result = $client->checkVat(['countryCode' => $countryCode, 'vatNumber' => $vatNo]); + + if($result->valid == true) { + $user->account->tax_identification_number = $data['tax_identification_number']; + $user->account->reverse_charge = 1; + $user->account->reverse_charge_code = $countryCode; + $user->account->reverse_charge_valid = now(); + $user->account->save(); + return 'valid'; + } else { + return 'error'; + } + + + } } \ No newline at end of file diff --git a/app/Services/BusinessPlan/TreeCalcBot.php b/app/Services/BusinessPlan/TreeCalcBot.php new file mode 100644 index 0000000..0243717 --- /dev/null +++ b/app/Services/BusinessPlan/TreeCalcBot.php @@ -0,0 +1,299 @@ +date = new stdClass(); + $date = \Carbon::parse($year.'-'.$month.'-1'); + $this->date->month = $month; + $this->date->year = $year; + $this->date->start_date = $date->format('Y-m-d H:i:s'); + $this->date->end_date = $date->endOfMonth()->format('Y-m-d H:i:s'); + $this->init_from = $init_from; + } + + public function initMain() + { + $this->readMain(); + $this->readParentsUser(); + $this->readParentlessUser(); + } + + public function initUser($user_id) + { + $user = User::find($user_id); + $TreeUserItem = new TreeUserItem($this->date); + $TreeUserItem->makeUser($user); + $TreeUserItem->addUserID(); + $this->items[] = $TreeUserItem; + + $this->readParentsUser(); + $this->readSponsorUser($user->m_sponsor); + } + + + public function initDetailUser($user) + { + $this->user = new TreeUserItem($this->date); + $this->user->makeUser($user); + $this->user->readParentsUser(); + + + //calculate Lines + if(count($this->user->items) > 0){ + $this->calcUserTP($this->user->items, 1); + } + $this->calcQualTP(); + + } + + private function calcUserTP($items, $line){ + if(!isset($this->lines[$line])){ + $this->lines[$line] = new stdClass(); + $this->lines[$line]->points = 0; + } + foreach($items as $item){ + if(count($item->items) > 0){ + $this->calcUserTP($item->items, $line+1); + } + $this->lines[$line]->points += $item->sales_volume_points_sum; + $this->total_tp += $item->sales_volume_points_sum; + + } + } + + public function getKeybyLine($line, $key){ + if(!isset($this->lines[$line])){ + return 0; + } + return isset($this->lines[$line]->{$key}) ? $this->lines[$line]->{$key} : 0; + + } + + public function calcQualTP(){ + if($this->user->isQualKP()){ + $this->total_qual_tp = $this->total_tp + $this->user->getRestQualKP(); + $this->qual_user_level = UserLevel::where('qual_tp', '<=', $this->total_qual_tp)->orderBy('qual_tp', 'desc')->first(); + $this->commission_total = 0; + if($this->qual_user_level){ + foreach($this->lines as $line => $values){ + $values->margin = $this->qual_user_level->{'pr_line_'.$line}; + $values->commission = round($values->points / 100 * $values->margin, 2); + $this->commission_total += $values->commission; + $this->lines[$line] = $values; + } + } + } + } + + private function readMain(){ + + $users = User::with('account')->select('users.*') + ->where('users.deleted_at', '=', null) + ->where('users.id', '!=', 1) + ->where('users.admin', "<", 4) + ->where('users.m_level', "!=", null) + ->where('users.m_sponsor', "=", null) + ->where('users.payment_account', "!=", null) + ->where('users.active_date', "<=", $this->date->end_date) + ->get(); + if($users){ + foreach($users as $user){ + $TreeUserItem = new TreeUserItem($this->date); + $TreeUserItem->makeUser($user); + $TreeUserItem->addUserID(); + $this->items[] = $TreeUserItem; + } + } + } + + + private function readParentsUser(){ + foreach($this->items as $item){ + $item->readParentsUser(); + } + } + + private function readParentlessUser(){ + $users = User::with('account')->select('users.*') + ->where('users.deleted_at', '=', null) + ->where('users.id', '!=', 1) + ->where('users.admin', "<", 4) + ->where('users.payment_account', "!=", null) + ->where('users.active_date', "<=", $this->date->end_date) + ->get(); + foreach($users as $user){ + if(!isset(self::$userIDs[$user->id])){ + $TreeUserItem = new TreeUserItem($this->date); + $TreeUserItem->makeUser($user); + $TreeUserItem->checkSponsor(); + + $this->parentless[] = $TreeUserItem; + } + } + } + + public function readSponsorUser($m_sponsor_id){ + $sponsor = User::find($m_sponsor_id); + if($sponsor){ + $this->sponsor = new TreeUserItem($this->date); + $this->sponsor->makeUser($sponsor); + } + } + + public function getItems(){ + return $this->items; + } + + public function makeHtmlTree(){ + $deep = 0; + $ret = '
    '; + foreach($this->items as $item){ + $ret .= $this->addItem($item, $deep); + } + $ret .= '
'; + return $ret; + } + + private function addItem($item, $deep){ + + $button = ''; + if(($this->init_from === 'admin' && \Auth::user()->isAdmin()) || ($this->init_from === 'member' && \Auth::user()->id === $item->id)){ + $button = ' | '; + } + return '
  • '. + '
    +
    +
    + '.(($deep > 0) ? '
    '.$deep.'
    ' : '').' +
    +
    + +
    +
    + + +
    '. + $this->addParentItem($item, $deep). + '
  • '; + + } + + private function addParentItem($item, $deep){ + if($item->items){ + $ret = '
      '; + foreach($item->items as $parent){ + $ret .= $this->addItem($parent, $deep+1); + } + $ret .='
    '; + return $ret; + } + return; + } + + + public function isParentless(){ + return $this->parentless ? true : false; + } + + public function makeParentlessHtml(){ + $ret = ""; + foreach($this->parentless as $item){ + $ret .= '
  • '. + '
    + +
    '. + '
  • '; + } + return $ret; + } + + public function makeSponsorHtml(){ + + if($this->sponsor){ + //' | ' + $ret = '
  • '. + '
    + +
    +
  • '; + + return $ret; + } + return 'Keinen Sponsor zugewiesen'; + + + } + +} diff --git a/app/Services/BusinessPlan/TreeUserItem.php b/app/Services/BusinessPlan/TreeUserItem.php new file mode 100644 index 0000000..90c51c5 --- /dev/null +++ b/app/Services/BusinessPlan/TreeUserItem.php @@ -0,0 +1,114 @@ +date = $date; + return $this; + } + + public function makeUser(User $user){ + + $this->id = $user->id; + $this->m_level = $user->m_level; + $this->m_sponsor = $user->m_sponsor; + + $this->user_level = $user->user_level ? $user->user_level->name : ''; + $this->active_account = $user->payment_account ? Carbon::parse($user->payment_account)->gt(Carbon::parse($this->date->start_date)) : false; + $this->payment_account_date = $user->payment_account ? $user->getPaymentAccountDateFormat(false) : "-"; + $this->active_date = $user->active_date ? $user->getActiveDateFormat() : "-"; + + $this->m_account = $user->account->m_account; + $this->email = $user->email; + $this->first_name = $user->account->first_name; + $this->last_name = $user->account->last_name; + $this->sales_volume_points = $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_points'); + $this->sales_volume_points_shop = $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_points_shop'); + $this->sales_volume_points_sum = $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_points_sum'); + $this->sales_volume_total = $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_total'); + $this->sales_volume_total_shop = $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_total_shop'); + $this->sales_volume_total_sum = $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_total_sum'); + + if($user->user_level){ + $this->margin = $user->user_level->margin; + $this->margin_shop = $user->user_level->margin_shop; + $this->qual_kp = $user->user_level->qual_kp; + $this->qual_tp = $user->user_level->qual_tp; + }else{ + $this->margin = 0; + $this->margin_shop = 0; + $this->qual_kp = 0; + $this->qual_tp = 0; + } + } + + public function addUserID(){ + TreeCalcBot::addUserID($this->id); + } + + public function isQualKP(){ + return ($this->sales_volume_points_sum >= $this->qual_kp) ? true : false; + } + + public function getRestQualKP(){ + return $this->sales_volume_points_sum - $this->qual_kp; + } + + public function checkSponsor(){ + if($this->m_sponsor === null){ + $this->m_sponsor_name = 'Keinen Sponsor zugewiesen'; + return; + } + $user = User::find($this->m_sponsor); + if($user){ + if($user->account){ + $this->m_sponsor_name = 'Sponsor: '.$user->account->first_name.' '.$user->account->last_name.' | '.$user->email.' | '.$user->account->m_account; + }else{ + $this->m_sponsor_name = 'Sponsor: '.$user->email; + } + return; + } + $this->m_sponsor_name = 'Sponsor wurde gelöscht.'; + return; + } + + public function readParentsUser(){ + + $users = User::with('account')->select('users.*') + ->where('users.deleted_at', '=', null) + ->where('users.id', '!=', 1) + ->where('users.admin', "<", 4) + ->where('users.m_level', "!=", null) + ->where('users.m_sponsor', "=", $this->id) //<- need the id for parents / sponsors + ->where('users.payment_account', "!=", null) + ->where('users.active_date', "<=", $this->date->end_date) + ->get(); + + if($users){ + foreach($users as $user){ + $TreeUserItem = new TreeUserItem($this->date); + $TreeUserItem->makeUser($user); + $TreeUserItem->addUserID(); + $this->items[] = $TreeUserItem; } + } + + foreach($this->items as $item){ + $item->readParentsUser(); + } + + } + + +} diff --git a/app/Services/CartHelper.php b/app/Services/CartHelper.php deleted file mode 100644 index 09602fe..0000000 --- a/app/Services/CartHelper.php +++ /dev/null @@ -1,352 +0,0 @@ - 'Januar', - 2 => 'Februar', - 3 => 'März', - 4 => 'April', - 5 => 'Mai', - 6 => 'Juni', - 7 => 'Juli', - 8 => 'August', - 9 => 'September', - 10 => 'Oktober', - 11 => 'November', - 12 => 'Dezember', - ]; - - - private static $roles = [ - 0 => 'Kunde', - 1 => 'Admin', - 2 => 'SuperAdmin', - 3 => 'SySAdmin', - ]; - - - public static function getMonth($i){ - return self::$months[intval($i)]; - } - - public static function getRoleLabel($role_id = 0){ - return ''.self::$roles[$role_id].''; - } - - public static function getLabel($id){ - switch ($id) { - case 0: - return 'badge-default'; - break; - case 1: - return 'badge-warning'; - break; - case 2: - return 'badge-primary'; - break; - case 3: - return 'badge-primary'; - break; - } - - } - - public static function getRolesOptions(){ - $ret = ""; - foreach (self::$roles as $role_id => $value){ - $ret .= '\n'; - } - return $ret; - } - - public static function getYearSelectOptions(){ - $start = date("Y", strtotime("-5 years", time())); - $end = date("Y", strtotime("+1 years", time())); - $values = range($start, $end); - $now = date("Y", time()); - $ret = ""; - foreach ($values as $value){ - $attr = ($value == $now) ? 'selected="selected"' : ''; - $ret .= '\n'; - } - return $ret; - } - - public static function getAttributesWithoutParents($id = false, $sameId = false, $all = true){ - $values = Attribute::where('parent_id', null)->get(); - $ret = ""; - if($all){ - $ret .= '\n'; - } - foreach ($values as $value){ - if($sameId == $value->id){ - continue; - } - $attr = ($value->id == $id) ? 'selected="selected"' : ''; - $ret .= '\n'; - } - return $ret; - } - - public static function getCategoriesWithoutParents($id = false, $sameId = false, $all = true){ - $values = Category::where('parent_id', null)->get(); - $ret = ""; - if($all){ - $ret .= '\n'; - } - foreach ($values as $value){ - if($sameId == $value->id){ - continue; - } - $attr = ($value->id == $id) ? 'selected="selected"' : ''; - $ret .= '\n'; - } - return $ret; - } - - public static function getProductsOptions($ids = array(), $all = true){ - if($ids == null){ - $ids = array(); - } - $values = Product::where('active', 1)->get(); - $ret = ""; - if($all){ - $ret .= '\n'; - } - foreach ($values as $value){ - $attr = in_array($value->id, $ids) ? 'selected="selected"' : ''; - $ret .= '\n'; - } - return $ret; - } - - public static function getCategoriesOptions($ids = array(), $all = true){ - $values = Category::where('active', 1)->get(); - $ret = ""; - if($all){ - $ret .= '\n'; - } - foreach ($values as $value){ - $attr = in_array($value->id, $ids) ? 'selected="selected"' : ''; - $ret .= '\n'; - } - return $ret; - } - - public static function getProductIngredientsOptions($has_ids = array(), $all = true){ - $values = Ingredient::where('active', 1)->get(); - $ret = ""; - $attr = ""; - foreach ($values as $value){ - if(!in_array($value->id, $has_ids)){ - $ret .= '\n'; - } - } - return $ret; - } - - public static function getAttributesOptions($ids = array(), $all = true){ - $values = Attribute::where('active', 1)->get(); - $ret = ""; - if($all){ - $ret .= '\n'; - } - foreach ($values as $value){ - $attr = in_array($value->id, $ids) ? 'selected="selected"' : ''; - $ret .= '\n'; - } - return $ret; - } - - public static function getUserLevelOptions($id = false, $all = true){ - $values = UserLevel::where('active', 1)->get(); - $ret = ""; - if($all){ - $ret .= '\n'; - } - foreach ($values as $value){ - $attr = ($value->id == $id) ? 'selected="selected"' : ''; - $ret .= '\n'; - } - return $ret; - } - - - public static function getCompanyOptions($company){ - $options = array(1 => __('business'), 0 => __('private'), ); - $ret = ""; - foreach ($options as $id => $value){ - $attr = ($id == $company) ? 'selected="selected"' : ''; - $ret .= '\n'; - } - return $ret; - } - - public static function getContriesWithMore($id, $all=true){# - $values = Country::all(); - $counter = 1; - $ret = ""; - if($all){ - $ret .= '\n'; - - } - foreach ($values as $value){ - if( $counter == 7){ - $ret .= ''; - } - $attr = ($value->id == $id) ? 'selected="selected"' : ''; - $ret .= '\n'; - - $counter ++; - } - $ret .= ''; - return $ret; - } - - public static function getContriesCodes($id, $all=true){# - $values = Country::all(); - $counter = 1; - $ret = ""; - if($all){ - $ret .= '\n'; - - } - foreach ($values as $value){ - - if(!$value->phone) continue; - if( $counter == 7){ - $ret .= ''; - } - $attr = ($value->id == $id) ? 'selected="selected"' : ''; - $ret .= '\n'; - - $counter ++; - } - $ret .= ''; - return $ret; - } - - public static function getCountriesWithoutUsedShippings($all=true){# - $values = Country::all(); - $country_ids = ShippingCountry::all()->pluck('country_id')->toArray(); - $ret = ""; - if($all){ - $ret .= '\n'; - } - foreach ($values as $value){ - if(!in_array($value->id, $country_ids)){ - $ret .= '\n'; - } - } - return $ret; - } - - public static function getCountryNameFormShipping($id){ - $value = ShippingCountry::find($id); - if($value){ - return $value->country->getLocated(); - } - return "not defined"; - } - - public static function getCountriesForShipping($id, $all=false){# - $values = ShippingCountry::all(); - $ret = ""; - if($all){ - $ret .= '\n'; - } - foreach ($values as $value){ - $attr = ($value->id == $id) ? 'selected="selected"' : ''; - $ret .= '\n'; - - } - return $ret; - } - - public static function getSalutation($id){ - $values = array('mr' => __('MR'), 'ms' => __('MS')); - $ret = ""; - $ret .= '\n'; - foreach ($values as $key => $value){ - $attr = ($key == $id) ? 'selected="selected"' : ''; - $ret .= '\n'; - } - return $ret; - } - - public static function getSalutationLang($id){ - $values = array('mr' => __('MR'), 'ms' => __('MS')); - return (!empty($values[$id]) ? $values[$id] : ''); - } - - public static function getTaxSaleOptions($id){ - $values = array('1' => __('taxable_sales_1'), '2' => __('taxable_sales_2')); - $ret = ""; - $ret .= '\n'; - foreach ($values as $key => $value){ - $attr = ($key == $id) ? 'selected="selected"' : ''; - $ret .= '\n'; - } - return $ret; - } - - public static function getMembersOptions($id, $all=false){ - $values = User::where('active', '=', true)->where('blocked', '=', false)->where('payment_account', '>=', now())->get(); - $ret = ""; - if($all){ - $ret .= '\n'; - } - foreach ($values as $value){ - $attr = ($value->id == $id) ? 'selected="selected"' : ''; - $to=""; - if($value->account){ - $to = $value->account->first_name." ".$value->account->last_name." | "; - } - $ret .= '\n'; - - } - return $ret; - } - - public static function getUserCustomerOptions($id, $all=false){ - $values = ShoppingUser::select(['id', 'billing_firstname', 'billing_lastname', 'billing_email', 'number']) - ->where('shopping_users.member_id', '=', \Auth::user()->id)->get(); - $ret = ""; - if($all){ - $ret .= '\n'; - } - foreach ($values as $value){ - dump($value); - $attr = ($value->id == $id) ? 'selected="selected"' : ''; - $to = $value->billing_firstname." ".$value->billing_lastname." | ".$value->billing_email; - $ret .= '\n'; - - } - return $ret; - } - - public static function getOptionRange($select, $from=1, $to=50){ - $values = range($from, $to); - $ret = ""; - foreach ($values as $value){ - $attr = ($value == $select) ? 'selected="selected"' : ''; - $ret .= '\n'; - } - return $ret; - - } -} \ No newline at end of file diff --git a/app/Services/HTMLHelper.php b/app/Services/HTMLHelper.php index c0a1622..b07b87c 100644 --- a/app/Services/HTMLHelper.php +++ b/app/Services/HTMLHelper.php @@ -15,19 +15,19 @@ class HTMLHelper { - private static $months = [ + public static $months = [ 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', + 2 => 'Februar', + 3 => 'März', + 4 => 'April', + 5 => 'Mai', + 6 => 'Juni', + 7 => 'Juli', + 8 => 'August', + 9 => 'September', + 10 => 'Oktober', + 11 => 'November', + 12 => 'Dezember' ]; @@ -43,6 +43,13 @@ class HTMLHelper return self::$months[intval($i)]; } + public static function getYearRange($start = 2021) + { + $end = date("Y"); + return array_reverse(range($start, $end)); + } + + public static function getRoleLabel($role_id = 0){ return ''.self::$roles[$role_id].''; } diff --git a/app/Services/Payment.php b/app/Services/Payment.php index 7907c22..6579aa3 100644 --- a/app/Services/Payment.php +++ b/app/Services/Payment.php @@ -74,7 +74,7 @@ class Payment /* Wir bei Zahlung aufgerufen. Betätigung durch Payone oder Zahlung auf MIVITA Rechnung - $paid = Status der Zahlung, Payone = true, MIVITA Rechnung = false + $paid = Status der Zahlung, Payone = true, MIVITA Rechnung = false damit kann später die rechnung auf bezahlt gesetzt werden. */ public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid){ diff --git a/app/Services/PaymentHelper.php b/app/Services/PaymentHelper.php index 2162bde..abdfc28 100644 --- a/app/Services/PaymentHelper.php +++ b/app/Services/PaymentHelper.php @@ -17,7 +17,7 @@ class PaymentHelper public function setProduct($product){ Yard::instance('shopping')->destroy(); - Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, false, false, ['image' => "", 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]); + Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, false, false, ['image' => "", 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission]); } public function initELVPayment($user){ @@ -153,7 +153,7 @@ class PaymentHelper 'tax_rate' => $item->taxRate, 'tax' => $tax, 'price_vk_net' => $shopping_order->getPriceVkNetBy($item->id), - 'discount' => $shopping_order->getUserDiscount(), + 'discount' => $item->options->no_commission ? 0 : $shopping_order->getUserDiscount(), 'points' => $item->options->points, 'slug' => $item->options->slug ]; diff --git a/app/Services/PriceService.php b/app/Services/PriceService.php deleted file mode 100644 index 4cadd3a..0000000 --- a/app/Services/PriceService.php +++ /dev/null @@ -1,29 +0,0 @@ -count() == 0){ - $unique = true; - } - } - while(!$unique); - return $confirmation_code; - } - - - -} \ No newline at end of file diff --git a/app/Services/SyS/Correction.php b/app/Services/SyS/Correction.php new file mode 100644 index 0000000..88f899c --- /dev/null +++ b/app/Services/SyS/Correction.php @@ -0,0 +1,304 @@ + 'hinzugefügt aus Bestellung', + 2 => 'hinzugefügt aus Shop', + 3 => 'hinzugefügt aus Shop / pending', + + */ + $status = UserSalesVolume::getStatusByOrder($order); + $user_id = $order->auth_user_id ? $order->auth_user_id : $order->member_id; + //akuteller tag / Monat. + $month = $order->created_at->format('m'); + $year = $order->created_at->format('Y'); + $date = $order->created_at->format('d.m.Y'); + + + if($status === 3){ //shop bestellung User pending + $user_id = $order->auth_user_id ? $order->auth_user_id : $order->member_id; + $month_points = 0; + $month_total_net = 0; + $month_shop_points = 0; + $month_shop_total_net = 0; + }else{ + $month_points = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('points'); + $month_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('total_net'); + $month_shop_points = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('points'); + $month_shop_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('total_net'); + } + switch ($status) { + case 1: //Bestellung + $month_points += $order->points; + $month_total_net += $order->subtotal; + break; + case 2: //Shop + $month_shop_points += $order->points; + $month_shop_total_net += $order->subtotal; + break; + } + + return UserSalesVolume::create([ + 'user_id' => $user_id, + 'shopping_order_id' => $order->id, + 'month' => $month, + 'year' => $year, + 'date' => $date, + 'points' => $order->points, + 'month_points' => $month_points, + 'month_shop_points' => $month_shop_points, + 'total_net' => $order->subtotal, + 'month_total_net' => $month_total_net, + 'month_shop_total_net' => $month_shop_total_net, + 'message' => '', + 'status' => $status, + ]); + } + + public static function show() + { + // abort(403, 'STOP funtion not online'); + + $c = 0; + + if(true){ //11 + dump("calculate user_sales_volumes from Orders"); + //dd('check function'); + $year = 21; + $months = range(1, 12); + foreach($months as $month){ + $ShoppingOrders = ShoppingOrder::where('txaction', 'paid')->where('created_at', '>=', $year.'-'.$month.'-01 00:00:00')->where('created_at', '<=', $year.'-'.$month.'-31 23:59:59')->get(); + foreach($ShoppingOrders as $item){ + + if(UserSalesVolume::whereShoppingOrderId($item->id)->count() === 0){ + dump($item->id); + self::userSalesVolume($item); + } + $c ++; + } + + } + + + dump("counter"); + dd($c); + } + + if(false){ //11 + dump("set Discount to Order Items"); + dd('check function'); + $ShoppingOrderItems = ShoppingOrderItem::where('discount', null) + //$ShoppingOrderItems = ShoppingOrderItem::where('discount', 0)->get(); + ->skip(0)->take(1000)->get(); + //->skip(2000)->take(2000)->get(); + foreach($ShoppingOrderItems as $item){ + $no_commission = $item->product ? $item->product->no_commission : false; + $item->discount = $no_commission ? 0 : $item->shopping_order->getUserDiscount(); + $item->save(); + //dump($item->discount); + + $c ++; + } + dump("counter"); + dd($c); + } + + + if(false){ //10 + dump("set ProduktPoints to Order Items"); + dd('check function'); + $ShoppingOrderItems = ShoppingOrderItem::where('points', null)->get(); + $ShoppingOrderItems = ShoppingOrderItem::where('points', 0)->get(); + //->skip(0)->take(500)->get(); + //->skip(500)->take(500)->get(); + foreach($ShoppingOrderItems as $item){ + if($item->product){ + $item->points = $item->product->points; + $item->save(); + }else{ + + } + $c ++; + } + dd($c); + } + + if(false){ //9 + dump("make homeparty tax_split in shopping_order"); + dd('check function'); + $ShoppingOrders = ShoppingOrder::where('payment_for', '=', NULL)->get(); + + foreach($ShoppingOrders as $ShoppingOrder){ + dump($ShoppingOrder->id); + dump($ShoppingOrder->shopping_user->getOrderPaymentFor()); + $ShoppingOrder->payment_for = $ShoppingOrder->shopping_user->getOrderPaymentFor(); + $ShoppingOrder->save(); + + $c ++; + } + dd($c); + } + + + if(false){ //8 + dump("make homeparty tax_split in shopping_order"); + dd('check function'); + $ShoppingOrders = ShoppingOrder::where('homeparty_id', '!=', NULL)->get(); + //->skip(0)->take(500)->get(); + //->skip(500)->take(500)->get(); + foreach($ShoppingOrders as $ShoppingOrder){ + $ShoppingOrder->makeHomepartyTaxSplit(); + $c ++; + } + dd($c); + } + + if(false){ //7 + dump("make homeparty shipping_tax in homeparty order user_cart"); + dd('check function'); + $ShoppingOrders = ShoppingOrder::where('homeparty_id', '!=', NULL)->get(); + //->skip(0)->take(500)->get(); + //->skip(500)->take(500)->get(); + foreach($ShoppingOrders as $ShoppingOrder){ + if(isset($ShoppingOrder->homeparty->order['user_carts'])){ + $user_carts = []; + foreach($ShoppingOrder->homeparty->order['user_carts'] as $id => $values){ + $values['shipping_tax'] = round($values['shipping_price'] - $values['shipping_price_net'], 2); + dump($values['shipping_tax']); + $user_carts[$id] = $values; + } + $order = $ShoppingOrder->homeparty->order; + $order['user_carts'] = $user_carts; + $ShoppingOrder->homeparty->order = $order; + $ShoppingOrder->homeparty->save(); + + } + $c ++; + } + dd($c); + } + + if(false){ //6 + dump("make tax_split in shopping_order"); + dd('check function'); + $ShoppingOrders = ShoppingOrder::where('homeparty_id', '=', NULL)->get(); + //->skip(0)->take(500)->get(); + //->skip(500)->take(500)->get(); + foreach($ShoppingOrders as $ShoppingOrder){ + $ShoppingOrder->makeTaxSplit(); + $c ++; + } + dd($c); + } + + if(false){ //5 + //run after make points etc. + dump("correction shopping_order homeparty"); + dd('check function'); + $ShoppingOrders = ShoppingOrder::where('payment_for', 5)->get(); + //->skip(0)->take(500)->get(); + //->skip(500)->take(500)->get(); + foreach($ShoppingOrders as $ShoppingOrder){ + $homeparty = Homeparty::find($ShoppingOrder->homeparty_id); + if($homeparty && $homeparty->completed && $homeparty->step > 10){ + $ShoppingOrder->subtotal = $homeparty->order['ek_price_net']; + $ShoppingOrder->subtotal_ws = 0; + $ShoppingOrder->tax = $ShoppingOrder->total - $homeparty->order['ek_price_net']; + $ShoppingOrder->points = $homeparty->order['points'] - $homeparty->order['bonus_points_diff']; + $ShoppingOrder->save(); + $c ++; + } + + } + dd($c); + } + + if(false){ //4 + dump("make tax in ShoppingOrderItem"); + dd('check function'); + $ShoppingOrderItems = ShoppingOrderItem::all(); + //->skip(0)->take(500)->get(); + //->skip(500)->take(500)->get(); + foreach($ShoppingOrderItems as $item){ + $item->tax = $item->price - $item->price_net; + $item->save(); + $c ++; + } + dd($c); + } + + + + if(false){ //3 + dump("make price_net in ShoppingOrderItem"); + dd('check function'); + $ShoppingOrderItems = ShoppingOrderItem::where('price_net', '=', NULL)->get(); + //->skip(0)->take(500)->get(); + //->skip(500)->take(500)->get(); + foreach($ShoppingOrderItems as $item){ + $item->price_net = $item->price / (100 + $item->tax_rate) * 100; + $item->save(); + $c ++; + } + dd($c); + } + + if(false){ //2 + dump("add payment_for in shopping_order"); + dd('check function'); + $ShoppingUsers = ShoppingUser::all(); + foreach($ShoppingUsers as $ShoppingUser){ + if($ShoppingUser->shopping_order){ + $ShoppingUser->shopping_order->payment_for = $ShoppingUser->getOrderPaymentFor(); + $ShoppingUser->shopping_order->save(); + $c ++; + } + } + dd($c); + } + + if(false){ //1 + dump("make points in shopping_order_item and total in ShoppingOrder"); + dd('check function'); + $ShoppingOrders = ShoppingOrder::all(); + //->skip(0)->take(500)->get(); + //->skip(500)->take(500)->get(); + foreach($ShoppingOrders as $ShoppingOrder){ + $points_total = 0; + foreach($ShoppingOrder->shopping_order_items as $shopping_order_item){ + $points = $shopping_order_item->product ? $shopping_order_item->product->points : 0; + $points_total += $points; + $shopping_order_item->points = $points; + $shopping_order_item->save(); + $c ++; + } + $ShoppingOrder->points = $points_total; + $ShoppingOrder->save(); + } + dd($c); + } + } + + + public static function store() + { + abort(403, 'STOP funtion not online'); + } + +} diff --git a/app/Services/SyS/CronJobs.php b/app/Services/SyS/CronJobs.php new file mode 100644 index 0000000..f9509c1 --- /dev/null +++ b/app/Services/SyS/CronJobs.php @@ -0,0 +1,32 @@ + route('cron_jobs_action', ['check_payments_account', 'key']) + ]; + $data = [ + 'values' => $values, + 'text' => $text, + ]; + return view('sys.tools.cronjobs', $data); + + } + + + public static function store() + { + $data = Request::all(); + \Session()->flash('alert-save', true); + return back(); + } + +} diff --git a/app/Services/SyS/Customers.php b/app/Services/SyS/Customers.php new file mode 100644 index 0000000..93c38d6 --- /dev/null +++ b/app/Services/SyS/Customers.php @@ -0,0 +1,63 @@ +where('auth_user_id', '=', NULL)->get(); + $data = [ + 'values' => $shopping_users, + 'text' => '', + ]; + + return view('sys.tools.customers', $data); + } + + + public static function store() + { + $data = Request::all(); + $ret = ""; + if($data['action'] === 'makePaymentMethodsDefault'){ + $users = User::where('payment_methods', '=', NULL)->get(); + //$users = User::all(); + foreach ($users as $user){ + $user->payment_methods = PaymentMethod::getDefaultAsArray(); + $user->save(); + } + } + if($data['action'] === 'checkForAll'){ + $shopping_users = CustomerPriority::checkForAll(); + } + + if($data['action'] === 'checkContractPDF'){ + //create PDF + $user = User::findOrFail(80); + + $pdf = new ContractPDFRepository($user); + $pdf->_set('disk', 'user'); + $pdf->_set('dir', '/'.$user->id.'/documents/'); + $pdf->_set('user_id', $user->id); + $pdf->_set('identifier', 'contract'); + $pdf->createContractPDF(); + } + + if(strpos($data['action'], 'checkOne_') !== false){ + $id = (int) str_replace('checkOne_', '', $data['action']); + $shopping_user = ShoppingUser::findOrFail($id); + $ret = CustomerPriority::checkOne($shopping_user); + } + \Session()->flash('alert-success', $ret); + return back(); + } +} diff --git a/app/Services/SyS/DomainSSL.php b/app/Services/SyS/DomainSSL.php new file mode 100644 index 0000000..40779ee --- /dev/null +++ b/app/Services/SyS/DomainSSL.php @@ -0,0 +1,104 @@ +get(); + $text = ""; + + $kas = new KasController(); + //$domain = 'mivita.care'; + // $ssl = KasSLLController::getApiSSLParameter(); + $SubDomains = []; + $get_subdomains = $kas->action('get_subdomains'); + foreach ($get_subdomains as $subdomain){ + + if(strpos($subdomain['subdomain_name'], 'www.') !== false){ + continue; + } + if(strpos($subdomain['subdomain_name'], 'api.') !== false){ + continue; + } + if(strpos($subdomain['subdomain_name'], 'checkout.') !== false){ + continue; + } + $SubDomains[$subdomain['subdomain_name']] = $subdomain['ssl_certificate_sni']; + + /* if($subdomain['ssl_certificate_sni'] !== "Y"){ + $pra = array( + 'hostname' => $subdomain['subdomain_name'], + ); + $pra = array_merge($pra, $ssl); + $value = $kas->action('update_ssl', $pra); + $text .= $value; + }else{ + if(isset($subdomain['ssl_certificate_sni_is_active'])){ + $text .= $subdomain['ssl_certificate_sni_is_active'].'-is_active'; + }else{ + $text .= '-CHECK!'; + + } + }*/ + + //$text .= "\n"; + } + foreach($user_shops as $user_shop){ + $user_shop->hasSubdomain = false; + $user_shop->hasSSL = false; + if(array_key_exists($user_shop->slug.'.mivita.care', $SubDomains)){ + $user_shop->hasSubdomain = true; + $user_shop->hasSSL = $SubDomains[$user_shop->slug.'.mivita.care'] === 'Y' ? true : false; + unset($SubDomains[$user_shop->slug.'.mivita.care']); + } + } + $data = [ + 'values' => $user_shops, + 'text' => $text, + 'SubDomains' => $SubDomains, + ]; + + return view('sys.tools.domain-ssl', $data); + } + + + public static function store() + { + $data = Request::all(); + if(isset($data['delete_sub_kas'])){ + $kas = new KasController(); + $pra = array( + 'subdomain_name' => $data['delete_sub_kas'], + ); + $value = $kas->action('delete_subdomain', $pra); + \Session()->flash('alert-success', 'subdomain: '.$value.' gelöscht'); + + } + if(isset($data['delete_user_shop'])){ + $user_shop = UserShop::findOrFail($data['delete_user_shop']); + $subdomain_name = $user_shop->slug.'.mivita.care'; + $user_shop->name = "delete".$user_shop->id; + $user_shop->slug = "delete".$user_shop->id; + $user_shop->save(); + $user_shop->delete(); + $kas = new KasController(); + $pra = array( + 'subdomain_name' => $subdomain_name, + ); + $value = $kas->action('delete_subdomain', $pra); + \Session()->flash('alert-success', 'shop/subdomain: '.$value.' gelöscht'); + + } + + + return back(); + } + +} diff --git a/app/Services/SyS/Import.php b/app/Services/SyS/Import.php new file mode 100644 index 0000000..7d0a174 --- /dev/null +++ b/app/Services/SyS/Import.php @@ -0,0 +1,49 @@ +upload($input); + } + + public function importShow($type, $file, $skip = 0, $limit = 4000) + { + $import_repo = new ImportRepository(); + $import = $import_repo->read($type, $file, $skip, $limit); + $data = [ + 'limit' => $limit, + 'type' => $type, + 'file' => $file, + 'import' => $import, + 'skip' => $skip, + ]; + return view('sys.tools.import-show', $data); + + } +} diff --git a/app/Http/Controllers/SyS/SalesController.php b/app/Services/SyS/Sales.php similarity index 80% rename from app/Http/Controllers/SyS/SalesController.php rename to app/Services/SyS/Sales.php index 876d3bf..42a3fd3 100644 --- a/app/Http/Controllers/SyS/SalesController.php +++ b/app/Services/SyS/Sales.php @@ -1,25 +1,15 @@ middleware('sysadmin'); - - } - - public function index() + public static function show() { $start = 2019; $end = date('Y'); @@ -50,11 +40,11 @@ class SalesController extends Controller 'active_year' => $active_year, 'values' => $values, ]; - return view('sys.sales.index', $data); + return view('sys.tools.sales', $data); } - public function store() + public static function store() { $data = Request::all(); @@ -68,11 +58,8 @@ class SalesController extends Controller $model->save(); } - \Session()->flash('alert-save', '1'); - return redirect(route('sysadmin_settings')); + return redirect(route('sysadmin_tool', ['sales_members'])); } - - -} \ No newline at end of file +} diff --git a/app/Services/SyS/ShoppingOrders.php b/app/Services/SyS/ShoppingOrders.php new file mode 100644 index 0000000..cd67847 --- /dev/null +++ b/app/Services/SyS/ShoppingOrders.php @@ -0,0 +1,64 @@ + $shopping_users, + 'text' => '', + ]; + return view('sys.tools.shopping-orders', $data); + } + + + public static function store() + { + abort(403, 'STOP funtion not online'); + dd(""); + + + $data = Request::all(); + + if($data['action'] === 'first_run'){ + $shopping_users = ShoppingUser::whereHas('shopping_order', function($q) { + $q->where('txaction', 'paid')->OrWhere('txaction', 'appointed'); + })->get(); + + $order_email = []; + $order_number = []; + + foreach ($shopping_users as $shopping_user){ + $order_email[$shopping_user->billing_email] = isset($order_email[$shopping_user->billing_email]) ? $order_email[$shopping_user->billing_email] + 1 : 1; + if($shopping_user->number) { + $order_number[$shopping_user->number] = isset($order_number[$shopping_user->number]) ? $order_number[$shopping_user->number] + 1 : 1; + $shopping_user->orders = $order_number[$shopping_user->number]; + }else { + $shopping_user->orders = $order_email[$shopping_user->billing_email]; + } + $shopping_user->save(); + + } + \Session()->flash('alert-save', true); + } + + if($data['action'] === 'next_run'){ + Shop::userOrders(); + \Session()->flash('alert-save', true); + } + return back(); + } + +} diff --git a/app/Services/TaxPriceHelper.php b/app/Services/TaxPriceHelper.php deleted file mode 100644 index 1f42a2d..0000000 --- a/app/Services/TaxPriceHelper.php +++ /dev/null @@ -1,13 +0,0 @@ -slug === 'aloevera' || $user_shop->slug === 'naturcosmetic'){ + return true; + } + } + } + if(Request::getHost() === 'naturcosmetic.'.config('app.domain').config('app.tld_care')){ + return true; + } return \Config::get('app.url') === config('app.domain').config('app.tld_shop'); } + public static function isTestSystem(){ + if(\Config::get('app.tld_care') === '.test' || \Config::get('app.tld_shop') === '.lshop'){ + return true; + } + return false; + } public static function sanitize($string, $force_lowercase = true, $anal = false, $substr = false) { diff --git a/app/User.php b/app/User.php index bafbf6f..9f6dc2d 100755 --- a/app/User.php +++ b/app/User.php @@ -8,6 +8,7 @@ use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Support\Facades\Mail; use App\Mail\MailResetPassword; +use App\Models\UserSalesVolume; use Illuminate\Database\Eloquent\SoftDeletes; use Laravel\Passport\HasApiTokens; @@ -149,6 +150,7 @@ class User extends Authenticatable 'password', 'remember_token', 'token', ]; + private $userSalesVolume = false; public function account(){ return $this->belongsTo('App\Models\UserAccount', 'account_id'); @@ -463,4 +465,40 @@ class User extends Authenticatable // $this->notify(new ResetPasswordNotification($token)); } + public function getUserSalesVolumeBy($month, $year, $key) + { + if($this->userSalesVolume === false){ + $this->userSalesVolume = UserSalesVolume::where('user_id', $this->id)->where('month', $month)->where('year', $year)->get()->last(); + } + if($this->userSalesVolume){ + switch ($key) { + case 'sales_volume_points': + return $this->userSalesVolume->month_points; + break; + + case 'sales_volume_points_shop': + return $this->userSalesVolume->month_shop_points; + break; + + case 'sales_volume_points_sum': + return $this->userSalesVolume->month_points + $this->userSalesVolume->month_shop_points; + break; + + case 'sales_volume_total': + return formatNumber($this->userSalesVolume->month_total_net); + break; + + case 'sales_volume_total_shop': + return formatNumber($this->userSalesVolume->month_shop_total_net); + break; + + case 'sales_volume_total_sum': + return formatNumber($this->userSalesVolume->month_total_net + $this->userSalesVolume->month_shop_total_net); + break; + } + } + return 0; + + } + } diff --git a/database/migrations/2018_10_21_164001_create_products_table.php b/database/migrations/2018_10_21_164001_create_products_table.php index c883fe3..c40c5ef 100644 --- a/database/migrations/2018_10_21_164001_create_products_table.php +++ b/database/migrations/2018_10_21_164001_create_products_table.php @@ -41,6 +41,8 @@ class CreateProductsTable extends Migration $table->unsignedTinyInteger('unit')->nullable(); $table->string('number')->nullable(); + $table->string('ean')->nullable(); + $table->unsignedInteger('wp_number')->nullable(); $table->string('icons')->nullable(); //as array cast diff --git a/database/migrations/2019_02_29_170559_create_user_accounts_table.php b/database/migrations/2019_02_29_170559_create_user_accounts_table.php index 03fc83e..da7c68e 100644 --- a/database/migrations/2019_02_29_170559_create_user_accounts_table.php +++ b/database/migrations/2019_02_29_170559_create_user_accounts_table.php @@ -70,7 +70,10 @@ class CreateUserAccountsTable extends Migration $table->string('instagram')->nullable(); $table->text('payment_data')->nullable(); - + $table->string('bank_owner')->nullable(); + $table->string('bank_iban')->nullable(); + $table->string('bank_bic')->nullable(); + $table->timestamp('data_protection')->nullable(); $table->timestamp('accepted_contract')->nullable(); $table->text('notice')->nullable(); diff --git a/database/migrations/2020_01_02_165917_create_user_levels_table.php b/database/migrations/2020_01_02_165917_create_user_levels_table.php index 9fdf8a9..bf492e1 100644 --- a/database/migrations/2020_01_02_165917_create_user_levels_table.php +++ b/database/migrations/2020_01_02_165917_create_user_levels_table.php @@ -18,12 +18,23 @@ class CreateUserLevelsTable extends Migration $table->string('name')->index(); $table->text('trans_name')->nullable(); - $table->decimal('margin', 8, 2)->nullable(); + $table->unsignedTinyInteger('margin')->nullable(); + $table->unsignedTinyInteger('margin_shop')->nullable(); + + $table->unsignedSmallInteger('qual_kp')->nullable(); + $table->unsignedInteger('qual_tp')->nullable(); + + $table->unsignedTinyInteger('growth_bonus')->nullable(); + $table->unsignedTinyInteger('pr_line_1')->nullable(); + $table->unsignedTinyInteger('pr_line_2')->nullable(); + $table->unsignedTinyInteger('pr_line_3')->nullable(); + $table->unsignedTinyInteger('pr_line_4')->nullable(); + $table->unsignedTinyInteger('pr_line_5')->nullable(); + $table->unsignedTinyInteger('pr_line_6')->nullable(); $table->tinyInteger('pos')->unsigned()->nullable(); $table->boolean('active')->default(false); - - + $table->boolean('default')->default(false); $table->timestamps(); diff --git a/resources/lang/de/navigation.php b/resources/lang/de/navigation.php index 4bbb4cc..1ffb268 100755 --- a/resources/lang/de/navigation.php +++ b/resources/lang/de/navigation.php @@ -40,5 +40,8 @@ return [ 'payments' => 'Finanzen', 'invoice' => 'Rechnungen', 'credit' => 'Gutschriften', - 'system_settings' => 'System-E.' + 'system_settings' => 'System-E.', + 'business' => 'Business', + 'structure' => 'Struktur', + ]; diff --git a/resources/lang/de/validation.php b/resources/lang/de/validation.php index 3d3105b..7e6aa84 100755 --- a/resources/lang/de/validation.php +++ b/resources/lang/de/validation.php @@ -206,7 +206,7 @@ return [ 'shipping_address'=>'Adresse', 'shipping_zipcode'=>'PLZ', 'shipping_city' => 'Stadt', - 'm_account' => 'Account ID', + 'm_account' => 'Berater-ID', 'has_customer_buyed' => 'Die Angabe', 'billing_country_code' => 'Land Code', 'sales_partnership' => 'Vertriebspartnerschaft', diff --git a/resources/views/admin/attribute/index.blade.php b/resources/views/admin/attribute/index.blade.php index 220b649..8ae1717 100755 --- a/resources/views/admin/attribute/index.blade.php +++ b/resources/views/admin/attribute/index.blade.php @@ -2,9 +2,9 @@ @section('content')
    -
    +
    {{__('Attribute')}} -
    +
    diff --git a/resources/views/admin/business/index.blade.php b/resources/views/admin/business/index.blade.php new file mode 100644 index 0000000..973b727 --- /dev/null +++ b/resources/views/admin/business/index.blade.php @@ -0,0 +1,109 @@ +@extends('layouts.layout-2') + +@section('content') +
    +
    + {{__('Business')}} +
    + +
    + {!! Form::open(['url' => route('admin_payments_invoice'), 'class' => 'form-horizontal', 'id'=>'form_filter_payment_invoices']) !!} + +
    + {{--
    + +
    + --}} +
    + +
    +
    + +
    +
    + {!! Form::close() !!} + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    {{__('ID') }}{{__('Berater-ID') }}{{__('Points')}}{{__('Points Shop')}}{{__('Gesamt')}}{{__('Umsatz')}}{{__('Umsatz Shop')}}{{__('Gesamt Shop')}}{{__('E-Mail')}}{{__('Vorname')}}{{__('Nachname')}}{{__('Level')}}{{__('Mitglied')}}
    +
    +
    + + +@endsection diff --git a/resources/views/admin/business/show.blade.php b/resources/views/admin/business/show.blade.php new file mode 100644 index 0000000..7032f12 --- /dev/null +++ b/resources/views/admin/business/show.blade.php @@ -0,0 +1,113 @@ +@extends('layouts.layout-2') + +@section('content') +
    +
    + {{__('Business')}} {{__('Übersicht')}} +
    + +
    + {!! Form::open(['url' => route('admin_payments_invoice'), 'class' => 'form-horizontal', 'id'=>'form_filter_business_user']) !!} + +
    + {{--
    + +
    + --}} + +
    + +
    +
    + +
    +
    + +
    +
    + {!! Form::close() !!} + +
    + + + + + + + + + + + + + + + + + + + +
    {{__('ID') }}{{__('Berater-ID') }}{{ __('Level') }}{{ __('KD') }}{{__('Points')}}{{__('Umsatz')}}{{__('E-Mail')}}{{__('Vorname')}}{{__('Nachname')}}{{__('Sponsor')}}{{__('Account')}}{{__('bis')}}
    +
    +
    + + +@endsection diff --git a/resources/views/admin/business/structure.blade.php b/resources/views/admin/business/structure.blade.php new file mode 100644 index 0000000..d905946 --- /dev/null +++ b/resources/views/admin/business/structure.blade.php @@ -0,0 +1,90 @@ +@extends('layouts.layout-2') + +@section('content') +
    +
    + {{__('Business')}} {{__('Struktur')}} +
    + +
    + {!! Form::open(['url' => route('admin_business_structure'), 'class' => 'form-horizontal', 'id'=>'form_filter_business_user']) !!} + +
    +
    + +
    +
    + +
    +
    + {!! Form::close() !!} + +
    +
    +
    + + +
    + +
    +
    +
    + {!! $TreeCalcBot->makeHtmlTree() !!} +
    +
    +
    + @if($TreeCalcBot->isParentless()) + +
    +
    +
    +
    + Berater ohne Sponsor +
    +
    + {!! $TreeCalcBot->makeParentlessHtml() !!} +
    +
    +
    + @endif +
    +
    + + + +@endsection diff --git a/resources/views/admin/business/user_detail.blade.php b/resources/views/admin/business/user_detail.blade.php new file mode 100644 index 0000000..7c0ef4a --- /dev/null +++ b/resources/views/admin/business/user_detail.blade.php @@ -0,0 +1,157 @@ +@extends('layouts.layout-2') + +@section('content') +
    +
    + {{__('Business')}} {{__('Übersicht')}} Berater +
    +
    + {{-- --}} +
    +

    {{ $user->account->first_name }} {{ $user->account->last_name }} {{ $user->email }}

    +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Account ID:{{ $user->account->m_account }}
    Level: + @if($user->user_level) + {{ $user->user_level->name }} + @else + - + @endif +
    Kundenprovision: + {{ $TreeCalcBot->user->margin }} % +
    Shop Provision: + {{ $TreeCalcBot->user->margin_shop }} % +
    Account: + @if($user->isActiveAccount()) + aktiv + @else + nicht aktiv + @endif + + @if($user->payment_account) + bis: {{ $user->getPaymentAccountDateFormat(false) }} + @endif +
    Sponsor:@if($user->user_sponsor) + @if($user->user_sponsor->account) + {{ $user->user_sponsor->account->first_name }} {{ $user->user_sponsor->account->last_name }} | + @endif + {{ $user->email }} | + @if($user->user_sponsor->account) + {{ $user->user_sponsor->account->m_account }} | + @endif + + + @else + - + @endif +
    Datum:{{ $month }} {{ $year }}
    Points: + {{ $TreeCalcBot->user->sales_volume_points_sum }} + | Berater: {{ $TreeCalcBot->user->sales_volume_points }} | Shop: {{ $TreeCalcBot->user->sales_volume_points_shop }} +
    Umsatz: + {{ $TreeCalcBot->user->sales_volume_total_sum }} € + | Berater: {{ $TreeCalcBot->user->sales_volume_total }} € | Shop: {{ $TreeCalcBot->user->sales_volume_total_shop }} € +
    Persönliches Volumen: + KD {{ $TreeCalcBot->user->qual_kp }} +
    Qualifikation: + TP {{ formatNumber($TreeCalcBot->user->qual_tp, 0) }} / + @if($TreeCalcBot->user->isQualKP()) + TP{{ formatNumber($TreeCalcBot->total_qual_tp, 0) }}   + @if($TreeCalcBot->qual_user_level) + {{ formatNumber($TreeCalcBot->qual_user_level->qual_tp, 0) }} | {{ $TreeCalcBot->qual_user_level->name }} + @endif + @else + + @endif +
    +
    +
    +
    + + + + + + + + + @for ($line=1; $line<=6; $line++) + + + + + + + + @endfor + + + + + + + + + + +
    LiniePointsProvisionProvision
    +
    {{ $line }}
    +
    {{ formatNumber($TreeCalcBot->getKeybyLine($line, 'points'), 0) }}{{ formatNumber($TreeCalcBot->getKeybyLine($line, 'margin'), 0) }} %{{ formatNumber($TreeCalcBot->getKeybyLine($line, 'commission'), 2) }}
    Gesamt{{ formatNumber($TreeCalcBot->total_tp, 0) }}{{ formatNumber($TreeCalcBot->commission_total, 2) }}
    +
    + + +@endsection diff --git a/resources/views/admin/category/index.blade.php b/resources/views/admin/category/index.blade.php index 790dca3..384b611 100755 --- a/resources/views/admin/category/index.blade.php +++ b/resources/views/admin/category/index.blade.php @@ -2,9 +2,9 @@ @section('content')
    -
    +
    {{__('Kategorien')}} -
    +
    diff --git a/resources/views/admin/category/products.blade.php b/resources/views/admin/category/products.blade.php index e4f7637..6dc9a18 100644 --- a/resources/views/admin/category/products.blade.php +++ b/resources/views/admin/category/products.blade.php @@ -1,7 +1,7 @@
    -
    +
    {{__('Produktliste')}} / {{ $category->name }} -
    +
    diff --git a/resources/views/admin/ingredient/index.blade.php b/resources/views/admin/ingredient/index.blade.php index 3cf00f1..75d7edd 100755 --- a/resources/views/admin/ingredient/index.blade.php +++ b/resources/views/admin/ingredient/index.blade.php @@ -2,9 +2,9 @@ @section('content')
    -
    +
    {{__('Inhaltsstoffe')}} -
    +
    diff --git a/resources/views/admin/lead/m_data_form.blade.php b/resources/views/admin/lead/m_data_form.blade.php index 2c5eb2e..4efcd9c 100644 --- a/resources/views/admin/lead/m_data_form.blade.php +++ b/resources/views/admin/lead/m_data_form.blade.php @@ -20,7 +20,7 @@ - + diff --git a/resources/views/admin/lead/m_data_form_edit.blade.php b/resources/views/admin/lead/m_data_form_edit.blade.php index ced1ae8..81d55ef 100644 --- a/resources/views/admin/lead/m_data_form_edit.blade.php +++ b/resources/views/admin/lead/m_data_form_edit.blade.php @@ -3,9 +3,9 @@
    - + Nächste freie ID: {{$next_account_id}} - {{ Form::text('m_account', $user->account->m_account, array('placeholder'=>__('Account ID'), 'class'=>'form-control', 'id'=>'m_account')) }} + {{ Form::text('m_account', $user->account->m_account, array('placeholder'=>__('Berater-ID'), 'class'=>'form-control', 'id'=>'m_account')) }}
    diff --git a/resources/views/admin/level/index.blade.php b/resources/views/admin/level/index.blade.php index 4b08238..4790837 100755 --- a/resources/views/admin/level/index.blade.php +++ b/resources/views/admin/level/index.blade.php @@ -2,9 +2,9 @@ @section('content')
    -
    +
    {{__('Karriere-Level')}} -
    +
    {{ __('Name') }}{{ __('Account ID') }}{{ __('Berater-ID') }} {{ __('Karriere-Level') }} {{ __('Sponsor') }}
    @@ -12,30 +12,50 @@ - - + + + + + + + + + + + + + + @foreach($values as $value) - - + + + + + + + + + + + + + + @endforeach @@ -51,99 +71,15 @@ - - - - - - + + + diff --git a/resources/views/admin/modal/show_user_customers.blade.php b/resources/views/admin/modal/show_user_customers.blade.php index 963592b..198f38c 100644 --- a/resources/views/admin/modal/show_user_customers.blade.php +++ b/resources/views/admin/modal/show_user_customers.blade.php @@ -77,8 +77,5 @@ - - + \ No newline at end of file diff --git a/resources/views/admin/modal/user_level_edit.blade.php b/resources/views/admin/modal/user_level_edit.blade.php new file mode 100644 index 0000000..dc890c1 --- /dev/null +++ b/resources/views/admin/modal/user_level_edit.blade.php @@ -0,0 +1,119 @@ +{!! Form::open(['url' => $route, 'class' => 'modal-content', 'enctype' => 'multipart/form-data']) !!} + + + +{!! Form::close() !!} + + + diff --git a/resources/views/admin/payment/invoice.blade.php b/resources/views/admin/payment/invoice.blade.php index 248536f..8f7d56d 100644 --- a/resources/views/admin/payment/invoice.blade.php +++ b/resources/views/admin/payment/invoice.blade.php @@ -2,11 +2,9 @@ @section('content')
    -
    +
    Finanzen / Rechnungen -
    - - +
    {!! Form::open(['url' => route('admin_payments_invoice'), 'class' => 'form-horizontal', 'id'=>'form_filter_payment_invoices']) !!} diff --git a/resources/views/admin/payment_method/index.blade.php b/resources/views/admin/payment_method/index.blade.php index 249c8a2..a92dc2f 100755 --- a/resources/views/admin/payment_method/index.blade.php +++ b/resources/views/admin/payment_method/index.blade.php @@ -2,9 +2,9 @@ @section('content')
    -
    +
    {{__('Zahlungsarten')}} -
    +
      {{__('Pos')}} {{__('Description')}}{{__('Marge') }}{{__('Translate') }}{{__('Nächste Ebene')}}{{__('Pr.') }}{{__('Pr.Shop') }}{{__('Qual.KP') }}{{__('Qual.TP') }}{{__('Pr. L.1') }}{{__('Pr. L.2') }}{{__('Pr. L.3') }}{{__('Pr. L.4') }}{{__('Pr. L.5') }}{{__('Pr. L.6') }}{{__('W.Bonus') }} {{__('Status')}}{{__('Standard')}}{{__('ID')}}
    - + {{ $value->pos }} {{ $value->name }}{{ $value->getFormattedMargin() }}{{ $value->getTranNames() }}@if($value->next_user_level) {{ $value->next_user_level->name }} @endif{{ $value->margin }}{{ $value->margin_shop }}{{ $value->qual_kp }}{{ $value->qual_tp }}{{ $value->pr_line_1 }}{{ $value->pr_line_2 }}{{ $value->pr_line_3 }}{{ $value->pr_line_4 }}{{ $value->pr_line_5 }}{{ $value->pr_line_6 }}{{ $value->getFormattedGrowthBonus() }} {!! get_active_badge($value->active) !!}{!! get_active_badge($value->default) !!}{{ $value->id }}
    diff --git a/resources/views/admin/product/_form.blade.php b/resources/views/admin/product/_form.blade.php new file mode 100755 index 0000000..e4d3766 --- /dev/null +++ b/resources/views/admin/product/_form.blade.php @@ -0,0 +1,353 @@ + +
    + +
    + {{ __('Produkt') }} + +
    + +
    + +
    + + + {{ Form::text('name', $product->name, array('placeholder'=>__('Name'), 'class'=>'form-control', 'id'=>'name', 'required')) }} +
    +
    + +
    + + {{ Form::text('number', $product->number, array('placeholder'=>__('number'), 'class'=>'form-control', 'id'=>'number')) }} + +
    +
    + + {{ Form::text('ean', $product->ean, array('placeholder'=>__('EAN'), 'class'=>'form-control', 'id'=>'ean')) }} +
    +
    + +
    +
    + + +
    + {{-- +
    + + {{ Form::select('show_at', $product->showATs, $product->show_at, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'show_at') ) }} +
    + --}} + +
    + + {{ Form::text('pos', $product->pos, array('placeholder'=>__('1, 2, 3, etc'), 'class'=>'form-control', 'id'=>'pos')) }} +
    +
    +
    +
    + + {{ Form::select('show_on[]', $product->showONs, $product->show_on, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'show_on', 'multiple') ) }} +
    +
    +
    + + {{ Form::textarea('copy', $product->copy , array('placeholder'=>__('Produktbeschreibung'), 'class'=>'form-control summernote', 'id'=>'copy')) }} +
    + +
    +
    + +
    +
    + {{ __('Preise in EUR') }} +
    +
    +
    +
    + + {{ Form::text('price', $product->getFormattedPrice(), array('placeholder'=>__('Preis VK in EUR (Brutto)'), 'class'=>'form-control', 'id'=>'price')) }} + +
    +
    + + {{ Form::text('price_ek', $product->getFormattedPriceEk(), array('placeholder'=>__('Preis EK in EUR'), 'class'=>'form-control', 'id'=>'price_ek')) }} + +
    +
    + + {{ Form::text('tax', $product->getFormattedTax(), array('placeholder'=>__('MwSt in %'), 'class'=>'form-control', 'id'=>'tax')) }} + +
    +
    + + {{ Form::text('price_old', $product->getFormattedPriceOld(), array('placeholder'=>__('Streichpreis'), 'class'=>'form-control', 'id'=>'price_old')) }} + +
    +
    +
    +
    + + {{ Form::text('weight', $product->weight, array('placeholder'=>__('Gewicht in g'), 'class'=>'form-control', 'id'=>'weight')) }} +
    +
    + + {{ Form::text('points', $product->points, array('placeholder'=>__('Points pro Produkt'), 'class'=>'form-control', 'id'=>'points')) }} +
    +
    + + {{ Form::text('amount', $product->amount, array('placeholder'=>__('Anzahl/Verfügbarkeit'), 'class'=>'form-control', 'id'=>'amount')) }} +
    +
    +
    +
    + + +
    +
    +
    +
    + +
    +
    + Landesspezifische Preise +
    + +
    + @foreach($country_for_prices as $country) + + {{ Form::hidden('country_prices[]', $country->id) }} +
    +
    {{$country->de}}
    +
    +
    + @if($country->own_eur) +
    +
    + +

    +
    +
    + + {{ Form::text('c_price['.$country->id.']', formatNumber($product->getCPrice($country)), array('placeholder'=>__('Preis VK in EUR Brutto'), 'class'=>'form-control', 'id'=>'c_price_'.$country->id)) }} + +
    +
    + + {{ Form::text('c_tax['.$country->id.']', formatNumber($product->getCTax($country)), array('placeholder'=>__('MwSt in %'), 'class'=>'form-control', 'id'=>'c_tax'.$country->id)) }} + +
    +
    + + {{ Form::text('c_price_old['.$country->id.']', formatNumber($product->getCPriceOld($country)), array('placeholder'=>__('Streichpreis'), 'class'=>'form-control', 'id'=>'c_price_old'.$country->id)) }} + +
    +
    + @endif + @if($country->currency) +
    +
    + +

    @if($country->currency_calc) Preis Berechnung automatisch @else Preis manuell + angegeben @endif

    +
    + + + + {{-- NUR Anzeige vom automatisch berechneten Preis currency_faktor + Auf Basis vom price + Wenn own_eur auf basis vom own_eur price + --}} +
    + + {{ Form::text('c_currency['.$country->id.']', formatNumber($product->getRealPrice($country) * $country->currency_faktor), array('class'=>'form-control', 'readonly')) }} + +
    + {{--@if($country->currency_calc) + @else + + Eingabe + Währungs Namen aus currency_name + currency_faktor als Hinweis ausgeben + Auf Basis vom price + Wenn own_eur auf basis vom own_eur price +
    + + {{ Form::text('c_currency['.$country->id.']', formatNumber($product->getCCurrency($country->id)), array('placeholder'=>__('Preis VK in ').$country->currency_unit, 'class'=>'form-control')) }} +
    + @endif --}} + +
    + + {{ Form::text('currency_faktor['.$country->id.']', formatNumber($country->currency_faktor, 4), array('class'=>'form-control', 'readonly')) }} +
    +
    + + {{ Form::text('preis_eur['.$country->id.']', formatNumber($product->getRealPrice($country)), array('class'=>'form-control', 'readonly')) }} +
    +
    + + {{ Form::text('currency_unit['.$country->id.']', $country->currency_unit, array('class'=>'form-control', 'readonly')) }} +
    + +
    + @endif +
    + @endforeach + für die Einstellung von landesspezifischen Preisen müssen diese unter + Länder -> Land aktiviert werden. +
    +
    + + +
    +
    + {{ __('Details') }} +
    +
    +
    + +
    + + {{ Form::text('contents', $product->contents, array('placeholder'=>__('Bsp: 150 ml'), 'class'=>'form-control', 'id'=>'contents')) }} +
    +
    + + {{ Form::text('contents_total', $product->contents_total, array('placeholder'=>__('Bsp: 150'), 'class'=>'form-control', 'id'=>'contents_total')) }} +
    +
    + + {{ Form::select('unit', $product->unitTypes, $product->unit, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'unit') ) }} +
    +
    + + {{ Form::text('base_price', $product->getBasePriceFormattedFull(), array('placeholder'=>__(''), 'class'=>'form-control', 'id'=>'base_price', 'readonly')) }} +
    + {{--
    + + +
    + --}} +
    + +
    + + {{ Form::textarea('description', $product->description , array('placeholder'=>__('description'), 'class'=>'form-control summernote', 'id'=>'description')) }} +
    +
    + + {{ Form::textarea('usage', $product->usage , array('placeholder'=>__('usage'), 'class'=>'form-control summernote', 'id'=>'usage')) }} +
    +
    + + {{ Form::textarea('ingredients', $product->ingredients , array('placeholder'=>__('ingredients'), 'class'=>'form-control summernote', 'id'=>'ingredients')) }} +
    + +
    + + {{ Form::text('icons', $product->icons, array('placeholder'=>__('icons'), 'class'=>'form-control', 'id'=>'icons')) }} + "product_icons_1.png" +
    +
    +
    + +
    +
    + {{ __('Inhalte') }} +
    +
    +
    +
    + + + + + + + + + + @foreach($product->p_ingredients as $ingredient) + + + + + + + @endforeach + +
    {{__('Name')}}{{__('INCI')}}{{__('Wirkung') }}
    {{ $ingredient->name }}{{ $ingredient->inci }}{{ $ingredient->effect }}
    +
    +
    +
    + + + Inhaltsstoffe anlegen +
    +
    +   +
    +
    +
    +
    + +@if(Auth::user()->isSuperAdmin()) +
    +
    + {{ __('SuperAdmin Einstellungen') }} +
    +
    +
    +
    + + {{ Form::select('action[]', $product->actionNames, $product->action, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'action', 'multiple') ) }} +
    +
    + + {{ Form::select('identifier', $product->identifiers_types, $product->identifier, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'identifier') ) }} +
    +
    + + {{ Form::text('upgrade_to_id', $product->upgrade_to_id, array('placeholder'=>__('Upgrade-ID'), 'class'=>'form-control', 'id'=>'upgrade_to_id')) }} +
    +
    + @if($product->action && is_array($product->action)) + @foreach ($product->action as $do ) + @if($product->getActionName($do) === 'payment_for_shop_upgrade') + +
    {{ $product->getUpgradeToIdName('payment_for_shop_upgrade') }} +
    + @endif + @if($product->getActionName($do) === 'payment_for_lead_upgrade') + +
    {{ $product->getUpgradeToIdName('payment_for_lead_upgrade') }} + + @endif + @endforeach + @endif +
    +
    +
    +
    + + {{ Form::text('wp_number', $product->wp_number, array('placeholder'=>__('WP Number'), 'class'=>'form-control', 'id'=>'wp_number')) }} +
    +
    +
    +
    +@endif \ No newline at end of file diff --git a/resources/views/admin/product/form.blade.php b/resources/views/admin/product/form.blade.php old mode 100755 new mode 100644 index ca2d9fa..7eecf4b --- a/resources/views/admin/product/form.blade.php +++ b/resources/views/admin/product/form.blade.php @@ -17,11 +17,16 @@ {{ Form::text('name', $product->name, array('placeholder'=>__('Name'), 'class'=>'form-control', 'id'=>'name', 'required')) }}
    - {{--
    - - {{ Form::text('title', $product->title, array('placeholder'=>__('Title'), 'class'=>'form-control', 'id'=>'title')) }} + +
    + + {{ Form::text('number', $product->number, array('placeholder'=>__('number'), 'class'=>'form-control', 'id'=>'number')) }} + +
    +
    + + {{ Form::text('ean', $product->ean, array('placeholder'=>__('EAN'), 'class'=>'form-control', 'id'=>'ean')) }}
    - --}}
    @@ -207,7 +212,7 @@
    - {{ __('Inhalte') }} + {{ __('Details') }}
    @@ -227,25 +232,15 @@
    {{ Form::text('base_price', $product->getBasePriceFormattedFull(), array('placeholder'=>__(''), 'class'=>'form-control', 'id'=>'base_price', 'readonly')) }} -
    -
    - - {{ Form::text('number', $product->number, array('placeholder'=>__('number'), 'class'=>'form-control', 'id'=>'number')) }} - -
    -
    - - {{ Form::text('icons', $product->icons, array('placeholder'=>__('icons'), 'class'=>'form-control', 'id'=>'icons')) }} - -
    -
    + {{--
    + --}}
    @@ -260,6 +255,18 @@ {{ Form::textarea('ingredients', $product->ingredients , array('placeholder'=>__('ingredients'), 'class'=>'form-control summernote', 'id'=>'ingredients')) }}
    +
    + + +
    + + {{ Form::select('icons', [null=>'Kein Icon', 'product_icons_1.png'=>'product_icons_1.png','product_icons_2.jpg'=>'product_icons_2.jpg'], $product->icons, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'icons') ) }} +
    +
    + +
    +
    +
    @@ -305,24 +312,40 @@
    -@if(Auth::user()->isSySAdmin()) +@if(Auth::user()->isSuperAdmin())
    - {{ __('SySAdmin Einstellungen') }} + {{ __('SuperAdmin Einstellungen') }}
    -
    +
    - {{ Form::select('action[]', $product->actions, $product->action, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'action', 'multiple') ) }} + {{ Form::select('action[]', $product->actionNames, $product->action, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'action', 'multiple') ) }}
    -
    +
    {{ Form::select('identifier', $product->identifiers_types, $product->identifier, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'identifier') ) }}
    - - {{ Form::text('upgrade_to_id', $product->upgrade_to_id, array('placeholder'=>__('Produkt-ID auf das geupdatet werden soll'), 'class'=>'form-control', 'id'=>'upgrade_to_id')) }} + + {{ Form::text('upgrade_to_id', $product->upgrade_to_id, array('placeholder'=>__('Upgrade-ID'), 'class'=>'form-control', 'id'=>'upgrade_to_id')) }} +
    +
    + @if($product->action && is_array($product->action)) + @foreach ($product->action as $do ) + @if($product->getActionName($do) === 'payment_for_shop_upgrade') + +
    {{ $product->getUpgradeToIdName('payment_for_shop_upgrade') }} +
    + @endif + @if($product->getActionName($do) === 'payment_for_lead_upgrade') + +
    {{ $product->getUpgradeToIdName('payment_for_lead_upgrade') }} + + @endif + @endforeach + @endif
    diff --git a/resources/views/admin/product/index.blade.php b/resources/views/admin/product/index.blade.php index 722531c..b9c5664 100755 --- a/resources/views/admin/product/index.blade.php +++ b/resources/views/admin/product/index.blade.php @@ -3,13 +3,13 @@ @section('content')
    -
    +
    {{__('Produkte')}} -
    +
    diff --git a/resources/views/admin/sales/_detail.blade.php b/resources/views/admin/sales/_detail.blade.php index b42623d..0539fac 100644 --- a/resources/views/admin/sales/_detail.blade.php +++ b/resources/views/admin/sales/_detail.blade.php @@ -43,7 +43,8 @@ @endif @else - {{-- + @if(Auth::user()->isSySAdmin()) + - --}} + @endif @endif @else @if($shopping_order->isInvoice()) diff --git a/resources/views/admin/shipping/edit.blade.php b/resources/views/admin/shipping/edit.blade.php index 3f3da40..f745008 100755 --- a/resources/views/admin/shipping/edit.blade.php +++ b/resources/views/admin/shipping/edit.blade.php @@ -60,9 +60,9 @@ @if($value->id>0)
    -
    +
    {{__('Preise')}} -
    +
    @@ -195,9 +195,9 @@
    -
    +
    {{__('Land')}} -
    +
    diff --git a/resources/views/admin/shipping/index.blade.php b/resources/views/admin/shipping/index.blade.php index 5b38132..dadafab 100755 --- a/resources/views/admin/shipping/index.blade.php +++ b/resources/views/admin/shipping/index.blade.php @@ -2,9 +2,9 @@ @section('content')
    -
    +
    {{__('Versandkosten')}} -
    +
    diff --git a/resources/views/emails/checkout.blade.php b/resources/views/emails/checkout.blade.php index cac63f0..5577ae5 100644 --- a/resources/views/emails/checkout.blade.php +++ b/resources/views/emails/checkout.blade.php @@ -566,7 +566,7 @@ @if($shopping_order->member) Berater: {{ \App\Services\HTMLHelper::getSalutationLang($shopping_order->member->account->m_salutation) }} {{ $shopping_order->member->account->m_first_name }} {{ $shopping_order->member->account->m_last_name }}
    - Account ID: {{ $shopping_order->member->account->m_account }}
    + Berater-ID: {{ $shopping_order->member->account->m_account }}
    @if($shopping_order->member->user_level) Karriere-Level: {{ $shopping_order->member->user_level->name }}
    @endif diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 55c047a..a43cc87 100755 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -149,7 +149,6 @@
    {{__('Mitgliedschaft') }}
    - @if($user->isActiveAccount() )
    diff --git a/resources/views/layouts/includes/layout-sidenav.blade.php b/resources/views/layouts/includes/layout-sidenav.blade.php index 8d48d76..df1f5aa 100755 --- a/resources/views/layouts/includes/layout-sidenav.blade.php +++ b/resources/views/layouts/includes/layout-sidenav.blade.php @@ -13,7 +13,6 @@ @if(Auth::user()->showSideNav()) -
  • @@ -52,8 +51,11 @@
    {{ __('navigation.my_team') }}
  • @@ -146,6 +148,21 @@ +
  • + + +
    {{ __('navigation.business') }}
    +
    + +
  • +
  • @@ -178,8 +195,8 @@
  • - - {{-- --}}
  • + {{-- +
  • {{ __('navigation.translate') }}
    @@ -195,6 +212,7 @@
  • + --}} @endif @if(Auth::user()->isSuperAdmin()) @@ -224,38 +242,12 @@
  • SYSADMIN
  • -
  • - - -
    Tools
    -
    - +
  • +
    Tools
    +
  • +
  • +
    {{ __('navigation.system_settings') }}
  • -
  • -
    {{ __('navigation.system_settings') }}
    -
  • @endif
  • diff --git a/resources/views/pdf/invoice.blade.php b/resources/views/pdf/invoice.blade.php index 9b5d07e..17809b2 100755 --- a/resources/views/pdf/invoice.blade.php +++ b/resources/views/pdf/invoice.blade.php @@ -377,8 +377,23 @@ @if($shopping_order->tax == 0)
    * Preise netto @endif -

    + @if($shopping_order->payment_for !== 6 && isset($shopping_order->shopping_user->auth_user)) +

    + @if(isset($shopping_order->shopping_user->auth_user->account->tax_identification_number)) + USt-ID des Leistungsempfängers: {{ $shopping_order->shopping_user->auth_user->account->tax_identification_number }}
    + + @else + @if(isset($shopping_order->shopping_user->auth_user->account->tax_number)) + USt-Nr. des Leistungsempfängers: {{ $shopping_order->shopping_user->auth_user->account->tax_number }}
    + @endif + @endif + @if(isset($user_reverse_charge) && $user_reverse_charge) + Die Rechnung erfolgt ohne Umsatzsteuer, da vorliegend der Wechsel der Steuerschuldnerschaft (Reverse-Charge-Verfahren) greift.
    + Die Umsatzsteuer ist vom Leistungsempfänger anzumelden und abzuführen.
    + @endif +

    + @endif @if($shopping_order->member)

    Bei Fragen sind wir jederzeit für Dich da.
    diff --git a/resources/views/sys/index.blade.php b/resources/views/sys/index.blade.php new file mode 100644 index 0000000..98853db --- /dev/null +++ b/resources/views/sys/index.blade.php @@ -0,0 +1,20 @@ +@extends('layouts.layout-2') + +@section('content') + +

    + +@endsection diff --git a/resources/views/sys/sales/index.blade.php b/resources/views/sys/sales/index.blade.php index c5d454d..6b1706a 100755 --- a/resources/views/sys/sales/index.blade.php +++ b/resources/views/sys/sales/index.blade.php @@ -6,7 +6,7 @@ Berater Bestellungen
    - {!! Form::open(['url' => route('sysadmin_sales_members'), 'class' => 'form-horizontal', 'id'=>'filter_sales_member']) !!} + {!! Form::open(['url' => route('sysadmin_tool_store', ['sales_members']), 'class' => 'form-horizontal', 'id'=>'filter_sales_member']) !!}
    diff --git a/resources/views/sys/tools/cronjobs.blade.php b/resources/views/sys/tools/cronjobs.blade.php new file mode 100644 index 0000000..f2489a1 --- /dev/null +++ b/resources/views/sys/tools/cronjobs.blade.php @@ -0,0 +1,39 @@ +@extends('layouts.layout-2') + +@section('content') + + @if ($errors->any()) +
    +
    +
    +
      + @foreach ($errors->all() as $error) +
    • {{ $error }}
    • + @endforeach +
    +
    +
    +
    + @endif + + +

    + SysAdmin Cron Jobs +

    + + +
    + + @if(count($values)>0) +
    + + @foreach($values as $name=>$link) +

    {{ $name }}

    + {{$link}}


    + @endforeach +
    + @endif +
    + +@endsection + diff --git a/resources/views/sys/tools/customers.blade.php b/resources/views/sys/tools/customers.blade.php new file mode 100644 index 0000000..1a97ede --- /dev/null +++ b/resources/views/sys/tools/customers.blade.php @@ -0,0 +1,75 @@ +@extends('layouts.layout-2') + +@section('content') + + @if ($errors->any()) +
    +
    +
    +
      + @foreach ($errors->all() as $error) +
    • {{ $error }}
    • + @endforeach +
    +
    +
    +
    + @endif + + +

    + SysAdmin Kundenhoheit prüfen +

    + + {!! Form::open(['url' => route('sysadmin_tool_store', ['customers']), 'class' => '']) !!} +
    + + {{--
    + + + + + + + + +
    --}} + + @if(count($values)>0) +
    + +
    +
    + + + + + + + + + + + + @foreach($values as $shopping_user) + + + + + + + + + @endforeach + +
    ID{{__('Mail')}}{{__('is like')}}{{__('OrderID')}}{{__('txaction')}}{{__('Action')}}
    {{$shopping_user->id}}{{$shopping_user->billing_email}}{{$shopping_user->is_like}}@if($shopping_user->shopping_order){{$shopping_user->shopping_order->id}}@endif@if($shopping_user->shopping_order){{$shopping_user->shopping_order->txaction}}@endif
    + +
    +
    + @endif + +
    + {!! Form::close() !!} + +@endsection + diff --git a/resources/views/sys/tools/domain-ssl.blade.php b/resources/views/sys/tools/domain-ssl.blade.php new file mode 100644 index 0000000..9a3cf95 --- /dev/null +++ b/resources/views/sys/tools/domain-ssl.blade.php @@ -0,0 +1,186 @@ +@extends('layouts.layout-2') + +@section('content') + + @if ($errors->any()) +
    +
    +
    +
      + @foreach ($errors->all() as $error) +
    • {{ $error }}
    • + @endforeach +
    +
    +
    +
    + @endif + + +

    + Subdomains prüfen SSL/Aktiv +

    + + +
    + + @if(count($SubDomains)>0) + {!! Form::open(['url' => route('sysadmin_tool_store', ['domainssl']), 'class' => '']) !!} +
    +
    + + + + + + + + + + @foreach($SubDomains as $SubDomain=>$ssl) + + + + + + + @endforeach + + +
    SubDomainSSL#
    {{ $SubDomain }}{{ $ssl }} + +
    + +
    + +
    + {!! Form::close() !!} + @endif + + @if(count($values)>0) + {!! Form::open(['url' => route('sysadmin_tool_store', ['domainssl']), 'class' => '']) !!} + +
    +
    + + + + + + + + + + + + + + + + + + + + + + @foreach($values as $value) + + + + + + + + + + + + + + + + + + + + @endforeach + +
    IDUser-IDDomainSubSSLseitDatumErreichbarStatusUser AccountUser ShopUser seit#
    {{ $value->id }}{{ $value->user_id }}{{ $value->slug }}.mivita.care {!! get_active_badge($value->hasSubdomain) !!} {!! get_active_badge($value->hasSSL) !!} {{ $value->getActiveDateFormatSmall() }} + @if($value->user && $value->user->payment_shop) + @if($value->user->isActiveShop()) + {{ $value->user->getPaymentShopDateFormat() }} + @else + {{ $value->user->getPaymentShopDateFormat() }} + @endif + @else + + @endif + + + -- + {{-- + @if($value->getSubdomainAvailable()) + {{ __('available') }} + @if($value->getSubdomainSslSin()) HTTPS @else HTTP @endif + + @else + {{ __('not available') }} HTTP + @endif + --}} + {!! get_active_badge($value->active) !!}@if($value->user) + @if($value->user->payment_account) + @if($value->user->isActiveAccount()) + {{ $value->user->getPaymentAccountDateFormat() }} + @else + {{ $value->user->getPaymentAccountDateFormat() }} + @endif + @else + + @endif + @else + - + @endif + + @if($value->user) + @if($value->user->payment_shop) + @if($value->user->isActiveShop()) + {{ $value->user->getPaymentShopDateFormat() }} + @else + {{ $value->user->getPaymentShopDateFormat() }} + @endif + @else + + @endif + @else + - + @endif + + @if($value->user) + @if($value->user->shop) + @if($value->user->shop->active) + {{ $value->user->shop->getActiveDateFormatSmall() }} + @else + {{ $value->user->shop->getActiveDateFormatSmall() }} + @endif + @else + + @endif + @else + - + @endif + + @if(!$value->user || !$value->user->payment_shop || !$value->user->isActiveShop()) + + @endif +
    + +
    + +
    + {!! Form::close() !!} + + @endif +
    + +@endsection + diff --git a/resources/views/sys/tools/import.blade.php b/resources/views/sys/tools/import.blade.php new file mode 100644 index 0000000..ee74dca --- /dev/null +++ b/resources/views/sys/tools/import.blade.php @@ -0,0 +1,109 @@ +@extends('layouts.layout-2') + +@section('content') + +

    + SysAdmin Kontakte importieren +

    + +
    +
    + Excel-Datei hochladen +
    +
    + + {!! Form::open([ 'url' => route('sysadmin_tool_store', ['import']), 'method' => 'post', 'files' => true, 'enctype' => 'multipart/form-data', 'class' => 'dropzone', 'id' => 'realDropzone' ]) !!} +
    + +
    + {!! Form::close() !!} + +
    + +
    +
    +@endsection + +@section('scripts') + +@endsection diff --git a/resources/views/sys/tools/sales.blade.php b/resources/views/sys/tools/sales.blade.php new file mode 100755 index 0000000..b9543e6 --- /dev/null +++ b/resources/views/sys/tools/sales.blade.php @@ -0,0 +1,65 @@ +@extends('layouts.layout-2') + +@section('content') +
    +
    + SysAdmin Berater Bestellungen +
    +
    + {!! Form::open(['url' => route('sysadmin_tool_store', ['sales_members']), 'class' => 'form-horizontal', 'id'=>'filter_sales_member']) !!} + + + + {!! Form::close() !!} + +
    + +
    + + + + + + + + + + + + + + @foreach($values as $value) + + + + + + + + + + + @endforeach + +
    {{__('Vorname')}}{{__('Nachname') }}{{__('E-Mail') }}{{__('Betrag') }}{{__('Datum') }}{{__('Order')}}{{__('Status')}}
    {{ $value->shopping_user->billing_firstname }}{{ $value->shopping_user->billing_lastname }}{{ $value->shopping_user->billing_email }}{{ $value->getFormattedTotalShipping()." €" }}{{ $value->created_at->format("d.m.Y") }}@foreach($value->shopping_order_items as $shopping_order_item) + {{ $shopping_order_item->product->name }}
    + @endforeach + +
    {!! App\Services\Payment::getShoppingOrderBadge($value) !!}
    +
    + +
    + + +@endsection diff --git a/resources/views/sys/tools/shopping-orders.blade.php b/resources/views/sys/tools/shopping-orders.blade.php new file mode 100644 index 0000000..d12fb7b --- /dev/null +++ b/resources/views/sys/tools/shopping-orders.blade.php @@ -0,0 +1,51 @@ +@extends('layouts.layout-2') + +@section('content') + + @if ($errors->any()) +
    +
    +
    +
      + @foreach ($errors->all() as $error) +
    • {{ $error }}
    • + @endforeach +
    +
    +
    +
    + @endif + + +

    + SysAdmin Shopping Orders +

    + + +
    + +
    + + {!! Form::open(['url' => route('sysadmin_tool_store', ['sales_members']), 'class' => '']) !!} +
    + + {{ Form::textarea('text', $text, array('class'=>'form-control', 'rows'=>1)) }} +
    + + + + {!! Form::close() !!} +
    + + @if(count($values)>0) +
    + + @foreach($values as $value) +
    {{$value->billing_email}} | {{$value->orders}}
    + @endforeach +
    + @endif +
    + +@endsection + diff --git a/resources/views/user/components/user_shop_edit.blade.php b/resources/views/user/components/user_shop_edit.blade.php index acc174c..b7dd883 100644 --- a/resources/views/user/components/user_shop_edit.blade.php +++ b/resources/views/user/components/user_shop_edit.blade.php @@ -47,7 +47,7 @@
    -
    {{ __('Shop details') }}
    +
    {{ __('Shop details') }}
    • {{ __('name') }}
      diff --git a/resources/views/user/components/user_shop_image.blade.php b/resources/views/user/components/user_shop_image.blade.php index 81c2d09..cf3e02b 100755 --- a/resources/views/user/components/user_shop_image.blade.php +++ b/resources/views/user/components/user_shop_image.blade.php @@ -2,8 +2,8 @@ -
      {{ __('shop image') }}
      {{ __('shop image copy') }} -
      +
      {{ __('shop image') }}
      {{ __('shop image copy') }} +