From 2ffc33dcd60fde768737304d9375d254f4b5426c Mon Sep 17 00:00:00 2001
From: Kevin Adametz
Date: Fri, 20 Aug 2021 18:22:21 +0200
Subject: [PATCH] Custom Price / Land / User Order Homeparty
---
app/Http/Controllers/MembershipController.php | 9 +-
.../Controllers/PaymentMethodController.php | 4 +-
.../Controllers/Sys/AdminToolsController.php | 24 +-
.../Controllers/User/HomepartyController.php | 262 +++++++---
app/Http/Controllers/User/OrderController.php | 74 +--
app/Http/Controllers/UserDataController.php | 4 +-
.../Controllers/Web/HomepartyController.php | 2 +
app/Http/Controllers/Web/SiteController.php | 16 +-
app/Http/Controllers/WizardController.php | 26 +-
app/Http/Middleware/Checkout.php | 2 +-
app/Models/Homeparty.php | 47 +-
app/Models/HomepartyUserOrderItem.php | 24 +
app/Models/PaymentMethod.php | 22 +
app/Models/Product.php | 107 ++--
app/Models/ShippingCountry.php | 14 +
app/Models/ShippingPrice.php | 12 +-
app/Models/ShoppingOrderItem.php | 1 -
app/Repositories/ProductRepository.php | 2 +
app/Repositories/UserRepository.php | 6 +-
app/Services/HTMLHelper.php | 2 +
app/Services/HomepartyCart.php | 49 +-
app/Services/HomepartyUserCart.php | 27 +
app/Services/PriceService.php | 29 ++
app/Services/TaxPriceHelper.php | 13 +
app/Services/UserService.php | 82 +++
app/Services/Yard.php | 146 +++++-
...018_10_21_164001_create_products_table.php | 5 +-
...2_29_170559_create_user_accounts_table.php | 4 +
...25_131854_create_payment_methods_table.php | 1 +
..._10_15_151059_create_homeparties_table.php | 6 +-
public/images/logo_mivita.png | Bin 6874 -> 9194 bytes
resources/views/admin/country/form.blade.php | 36 +-
resources/views/admin/country/index.blade.php | 2 +-
.../admin/payment_method/index.blade.php | 20 +-
resources/views/admin/product/form.blade.php | 39 +-
resources/views/admin/product/index.blade.php | 4 +-
.../views/sys/admin/domain-ssl.blade.php | 57 +-
.../views/user/homeparty/_edit.blade.php | 28 +-
.../views/user/homeparty/detail.blade.php | 485 ++++++++++++++----
.../views/user/homeparty/guests.blade.php | 26 +-
.../views/user/homeparty/index.blade.php | 9 +-
.../homeparty/modal_show_products.blade.php | 15 +-
.../views/user/homeparty/order.blade.php | 40 +-
.../homeparty/self_guest_detail.blade.php | 2 +-
.../homeparty/show_calc_bonus_host.blade.php | 69 ++-
.../homeparty/show_products_order.blade.php | 64 ++-
.../user/homeparty/show_total_order.blade.php | 106 +++-
resources/views/user/order/delivery.blade.php | 14 +-
resources/views/user/order/list.blade.php | 81 ++-
.../views/user/order/shipping_me.blade.php | 23 +-
.../views/user/order/shipping_ot.blade.php | 15 +-
.../views/user/order/yard_view_form.blade.php | 55 +-
.../views/web/templates/checkout.blade.php | 88 +++-
routes/web.php | 6 +-
54 files changed, 1794 insertions(+), 512 deletions(-)
create mode 100644 app/Services/PriceService.php
create mode 100644 app/Services/TaxPriceHelper.php
diff --git a/app/Http/Controllers/MembershipController.php b/app/Http/Controllers/MembershipController.php
index 65ca030b..4308f61c 100755
--- a/app/Http/Controllers/MembershipController.php
+++ b/app/Http/Controllers/MembershipController.php
@@ -43,11 +43,10 @@ class MembershipController extends Controller
$userHistoryUpgradeOrder = UserHistory::whereUserId($user->id)->whereAction('upgrade_order')->get()->last();
$userHistoryDeleteMembership = UserHistory::whereUserId($user->id)->whereAction('delete_membership')->whereStatus(50)->get()->last();
-
$data = [
'user' => $user,
- 'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
- 'upgrade' => Product::where('active', true)->where('show_at', '=', 4)->where('identifier', 'upgrade')->get(),
+ 'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
+ 'upgrade' => Product::where('active', true)->whereJsonContains('show_on', '5')->where('identifier', 'upgrade')->get(),
'diff_months' => $diff_months,
'userHistoryPaymentOrder' => $userHistoryPaymentOrder,
'userHistoryUpgradeOrder' => $userHistoryUpgradeOrder,
@@ -91,7 +90,7 @@ class MembershipController extends Controller
$user->abo_options = true;
$user->save();
}
- if($product && $product->active && $product->show_at >= 3){
+ if($product && $product->active){
$image = "";
if($product->images->count()){
$image = $product->images->first()->slug;
@@ -136,7 +135,7 @@ class MembershipController extends Controller
\Session()->flash('alert-success', "keine Änderung vorgenommen.");
return back();
}
- if($product && $product->active && $product->show_at >= 3){
+ if($product && $product->active){
$user->payment_order_id = $product->id;
$user->save();
UserHistory::create(['user_id' => $user->id, 'action'=>$action, 'status'=>10, 'product_id'=>$product->id]);
diff --git a/app/Http/Controllers/PaymentMethodController.php b/app/Http/Controllers/PaymentMethodController.php
index c85c4942..fd965e72 100755
--- a/app/Http/Controllers/PaymentMethodController.php
+++ b/app/Http/Controllers/PaymentMethodController.php
@@ -35,7 +35,7 @@ class PaymentMethodController extends Controller
'name' => $data['name'],
'short' => $data['short'],
'pos' => $data['pos'],
- 'show_at' => $data['show_at'],
+ 'show_on' => isset($data['show_on']) ? $data['show_on'] : null,
'default' => isset($data['default']) ? true : false,
'active' => isset($data['active']) ? true : false,
]);
@@ -44,7 +44,7 @@ class PaymentMethodController extends Controller
$model->name = $data['name'];
$model->short = $data['short'];
$model->pos = $data['pos'];
- $model->show_at = $data['show_at'];
+ $model->show_on = isset($data['show_on']) ? $data['show_on'] : null;
$model->default = isset($data['default']) ? true : false;
$model->active = isset($data['active']) ? true : false;
$model->save();
diff --git a/app/Http/Controllers/Sys/AdminToolsController.php b/app/Http/Controllers/Sys/AdminToolsController.php
index 93257a46..bc26470e 100755
--- a/app/Http/Controllers/Sys/AdminToolsController.php
+++ b/app/Http/Controllers/Sys/AdminToolsController.php
@@ -115,14 +115,21 @@ class AdminToolsController extends Controller
$user_shops = UserShop::all();
$text = "";
- $kas = new KasController();
+ /* $kas = new KasController();
$domain = 'mivita.care';
$ssl = KasSLLController::getApiSSLParameter();
$subdomains = $kas->action('get_subdomains');
foreach ($subdomains as $subdomain){
- $text .= $subdomain['subdomain_name']." - ".$subdomain['ssl_certificate_sni']."\n";
+ /*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(
@@ -130,9 +137,18 @@ class AdminToolsController extends Controller
);
$pra = array_merge($pra, $ssl);
$value = $kas->action('update_ssl', $pra);
- $text .= $value."\n";
+ $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,
diff --git a/app/Http/Controllers/User/HomepartyController.php b/app/Http/Controllers/User/HomepartyController.php
index 897dc57f..ac2107d5 100755
--- a/app/Http/Controllers/User/HomepartyController.php
+++ b/app/Http/Controllers/User/HomepartyController.php
@@ -2,25 +2,22 @@
namespace App\Http\Controllers\User;
-use App\Http\Controllers\Controller;
-use App\Models\Homeparty;
-use App\Models\HomepartyUser;
-use App\Models\HomepartyUserOrderItem;
-use App\Models\Product;
-use App\Models\ShippingCountry;
-use App\Models\ShoppingInstance;
-use App\Models\ShoppingOrder;
-use App\Models\ShoppingUser;
-use App\Models\UserHistory;
-use App\Models\UserShop;
-use App\Services\HomepartyCart;
-use App\Services\Payment;
-use App\Services\Util;
-use App\User;
use Auth;
-use Request;
-use Validator;
use Yard;
+use Request;
+use App\User;
+use Validator;
+use App\Services\Util;
+use App\Models\Product;
+use App\Models\Homeparty;
+use App\Models\UserHistory;
+use App\Models\HomepartyUser;
+use App\Services\UserService;
+use App\Models\ShippingCountry;
+use App\Services\HomepartyCart;
+use App\Models\ShoppingInstance;
+use App\Http\Controllers\Controller;
+use App\Models\HomepartyUserOrderItem;
class HomepartyController extends Controller
@@ -34,18 +31,28 @@ class HomepartyController extends Controller
public function index()
{
$data = [
- 'homepartys' => Homeparty::where('auth_user_id', '=', \Auth::user()->id)->get(),
+ 'homepartys' => Homeparty::where('auth_user_id', '=', \Auth::user()->id)->orderByDesc('id')->get(),
];
return view('user.homeparty.index', $data);
}
- public function detail($id)
+ public function detail($id, $step = false)
{
if($id === 'new'){
$homeparty = new Homeparty();
+ $homeparty->id = 0;
+ $step = 1;
$homeparty->description = "Willkommen zu unserer Auszeitparty rund um das Thema Bio Aloe Vera und Naturkosmetik. Wir informieren Dich darüber, was Premiumqualität bei Naturkosmetik wirklich ausmacht, zeigen Dir viele Anwendungsbeispiele bei Haut- und Darmproblemen und natürlich kannst Du unsere Produkte ausgiebig testen. Wir freuen uns auf Dich!";
}else{
$homeparty = $this->getHomparty($id);
+ if($homeparty->step < 10){
+ $step = $homeparty->step;
+ }else{
+ if(!$step){
+ $step = 10;
+ }
+ }
+
}
if($homeparty->homeparty_host){
$homeparty_user = $homeparty->homeparty_host;
@@ -61,22 +68,43 @@ class HomepartyController extends Controller
$data = [
'homeparty' => $homeparty,
'homeparty_user' => $homeparty_user,
+ 'step' => $step,
];
return view('user.homeparty.detail', $data);
}
- public function store($id = null)
+ public function store($id = null, $step = false)
{
$data = Request::all();
- if($data['action'] === 'homeparty-party-store'){
+ if($data['action'] === 'homeparty-party-store-detail'){
$rules = array(
'date' => 'required',
'name' => 'required',
- 'place' => 'required'
+ 'place' => 'required',
+ );
+ if(!$id){
+ $rules = array(
+ 'date' => 'required',
+ 'name' => 'required',
+ 'place' => 'required',
+ 'country_id' => 'required'
+ );
+ }
+ }
+ if($data['action'] === 'homeparty-party-store-address'){
+ $rules = array(
+ 'shipping_firstname' => 'required',
+ 'shipping_lastname' => 'required',
+ 'shipping_address' => 'required',
+ 'shipping_zipcode' => 'required',
+ 'shipping_city' => 'required',
+ 'shipping_salutation' => 'required',
+ 'shipping_country_id' => 'required'
);
}
- if($data['action'] === 'homeparty-user-store'){
+
+ if($data['action'] === 'homeparty-party-store-host'){
$rules = array(
'billing_salutation' => 'required',
'billing_firstname' => 'required',
@@ -86,25 +114,13 @@ class HomepartyController extends Controller
'billing_city' => 'required',
'billing_country_id' => 'required',
);
- if (!Request::get('same_as_billing')) {
- $rules = array_merge($rules, [
- 'shipping_firstname' => 'required',
- 'shipping_lastname' => 'required',
- 'shipping_address' => 'required',
- 'shipping_zipcode' => 'required',
- 'shipping_city' => 'required',
- 'shipping_salutation' => 'required',
- 'shipping_country_id' => 'required'
- ]);
- }
}
-
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return back()->withErrors($validator)->withInput(Request::all());
}
-
- if($data['action'] === 'homeparty-party-store'){
+
+ if($data['action'] === 'homeparty-party-store-detail'){
if(!$id){
//first save create and empty user/host
do {
@@ -112,29 +128,51 @@ class HomepartyController extends Controller
} while( Homeparty::where('token', $token)->count() );
$data['token'] = $token;
$data['auth_user_id'] = \Auth::user()->id;
+ $data['step'] = 2;
+ $step = 2;
$homeparty = Homeparty::create($data);
-
$homeparty_user = HomepartyUser::create([
'homeparty_id' => $homeparty->id,
'auth_user_id' => \Auth::user()->id,
+ 'shipping_country_id' => $homeparty->country_id,
+ 'billing_country_id' => $homeparty->country_id,
+ 'same_as_billing' => false,
'is_host' => true,
]);
}else {
$homeparty = $this->getHomparty($id);
$homeparty->fill($data)->save();
+ $step = 10;
+ }
+ }
+ if($data['action'] === 'homeparty-party-store-address'){
+ $homeparty = $this->getHomparty($id);
+ $homeparty_user = $homeparty->homeparty_host;
+ $homeparty_user->fill($data)->save();
+ if($homeparty->step === 2){
+ $homeparty->step = 3;
+ $homeparty->save();
+ $step = 3;
+ }else{
+ $step = 12;
}
}
- if($data['action'] === 'homeparty-user-store'){
+ if($data['action'] === 'homeparty-party-store-host'){
$homeparty = $this->getHomparty($id);
- $data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
- $data['shipping_country_id'] = isset($data['shipping_country_id']) ? $data['shipping_country_id'] : $data['billing_country_id'];
$homeparty_user = $homeparty->homeparty_host;
$homeparty_user->fill($data)->save();
+ if($homeparty->step === 3){
+ $homeparty->step = 10;
+ $homeparty->save();
+ $step = 10;
+ }else{
+ $step = 13;
+ }
}
\Session()->flash('alert-save', '1');
- return redirect(route('user_homeparty_detail', $homeparty->id));
+ return redirect(route('user_homeparty_detail', [$homeparty->id, $step]));
}
@@ -154,6 +192,8 @@ class HomepartyController extends Controller
if($gid === 'new'){
$homeparty_user = new HomepartyUser();
$homeparty_user->same_as_billing = true;
+ $homeparty_user->billing_country_id = $homeparty->country_id;
+ $homeparty_user->shipping_country_id = $homeparty->country_id;
}else{
$homeparty_user = HomepartyUser::findOrFail($gid);
if($homeparty->id !== $homeparty_user->homeparty_id){
@@ -222,9 +262,20 @@ class HomepartyController extends Controller
public function order($id = null)
{
$user = User::find(Auth::user()->id);
-
$homeparty = $this->getHomparty($id);
+ $shipping_country_id = $this->checkShoppingCountry($homeparty->country_id);
+ if(!$shipping_country_id){
+ \Session()->flash('custom-error', __('validation.custom.shipping_not_found'));
+ return redirect(route('user_homepartys'));
+ }
+ UserService::checkUserTaxShippingCountry($user, $shipping_country_id);
+ if($this->userChangeCountry($homeparty)){
+ \Session()->flash('custom-error', 'Das Rechnungsland wurde geändert und der Warenkrob zurückgesetzt.');
+ return redirect(route('user_homeparty_order', [$homeparty->id]));
+ }
HomepartyCart::calculateHomeparty($homeparty);
+ $homeparty->card_info = UserService::getYardInfo();
+ $homeparty->save();
$userHistoryPaymentOrder = UserHistory::whereUserId($user->id)->whereAction('payment_homeparty')->where('referenz', $homeparty->id)->get()->last();
$data = [
'homeparty' => $homeparty,
@@ -232,10 +283,34 @@ class HomepartyController extends Controller
];
return view('user.homeparty.order', $data);
}
+
+ private function userChangeCountry($homeparty){
+ if(isset($homeparty->card_info['user_country_id'])){
+ if($homeparty->card_info['user_country_id'] !== UserService::$user_country->id){
+ // es wurde schon eine order angelegt, aber das Rechungsland geändert
+ if($homeparty->homeparty_order_items->count()){
+ foreach($homeparty->homeparty_order_items as $homeparty_order_item){
+ $homeparty_order_item->delete();
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private function checkShoppingCountry($country_id){
+ if($country_id){
+ if($shipping_country = ShippingCountry::whereCountryId($country_id)->first()){
+ return $shipping_country->id;
+ }
+ }
+ return false;
+ }
+
//perform Request
public function orderStore($id = null)
{
-
$homeparty = $this->getHomparty($id);
if(Request::ajax()) {
@@ -257,20 +332,37 @@ class HomepartyController extends Controller
$HomepartyUserOrderItem->qty = $HomepartyUserOrderItem->qty+1;
$HomepartyUserOrderItem->save();
}else{
- $HomepartyUserOrderItem = HomepartyUserOrderItem::create([
- 'homeparty_id' => $homeparty->id,
- 'homeparty_user_id' => $homeparty_user->id,
- 'product_id' => $product->id,
- 'qty' => 1,
- 'price' => $product->price,
- 'price_net' => $product->getPriceWith(true, false),
- 'tax_rate' => $product->tax,
- 'points' => $product->points,
- 'margin' => $margin,
- 'ek-price' => $product->getPriceWith(false, true),
- 'ek-price_net' => $product->getPriceWith(true, true),
- 'slug' => $product->slug
- ]);
+ if($homeparty->getCardInfo('user_tax_free')){
+ $HomepartyUserOrderItem = HomepartyUserOrderItem::create([
+ 'homeparty_id' => $homeparty->id,
+ 'homeparty_user_id' => $homeparty_user->id,
+ 'product_id' => $product->id,
+ 'qty' => 1,
+ 'price' => $product->getPriceWith(true, false, $homeparty->getUserCountry()),
+ 'price_net' => $product->getPriceWith(true, false, $homeparty->getUserCountry()),
+ 'tax_rate' => 0,
+ 'points' => $product->points,
+ 'margin' => $margin,
+ 'ek-price' => $product->getPriceWith(true, true, $homeparty->getUserCountry()),
+ 'ek-price_net' => $product->getPriceWith(true, true, $homeparty->getUserCountry()),
+ 'slug' => $product->slug
+ ]);
+ }else{
+ $HomepartyUserOrderItem = HomepartyUserOrderItem::create([
+ 'homeparty_id' => $homeparty->id,
+ 'homeparty_user_id' => $homeparty_user->id,
+ 'product_id' => $product->id,
+ 'qty' => 1,
+ 'price' => $product->getPriceWith(false, false, $homeparty->getUserCountry()),
+ 'price_net' => $product->getPriceWith(true, false, $homeparty->getUserCountry()),
+ 'tax_rate' => $product->getTaxWith($homeparty->getUserCountry()),
+ 'points' => $product->points,
+ 'margin' => $margin,
+ 'ek-price' => $product->getPriceWith(false, true, $homeparty->getUserCountry()),
+ 'ek-price_net' => $product->getPriceWith(true, true, $homeparty->getUserCountry()),
+ 'slug' => $product->slug
+ ]);
+ }
}
}
@@ -280,7 +372,7 @@ class HomepartyController extends Controller
HomepartyCart::calculateHomeparty($homeparty);
$html_user_cart = view("user.homeparty.show_products_order", ['homeparty' => $homeparty, 'homeparty_guest' => $homeparty_user])->render();
$html_bonus = view("user.homeparty.show_bonus", ['homeparty' => $homeparty])->render();
- $html_host_bonus = view("user.homeparty.show_calc_bonus_host")->render();
+ $html_host_bonus = view("user.homeparty.show_calc_bonus_host", ['homeparty' => $homeparty])->render();
$html_total = view("user.homeparty.show_total_order", ['homeparty' => $homeparty])->render();
return response()->json(['response' => true, 'data'=>$data, 'html_user_cart'=>$html_user_cart, 'html_bonus'=>$html_bonus, 'html_host_bonus'=>$html_host_bonus, 'html_total'=>$html_total]);
}
@@ -458,18 +550,24 @@ class HomepartyController extends Controller
return $homeparty;
}
- public function datatable(){
- $query = Product::select('products.*')->where('active', true)->where(function ($q) {
- $q->where('show_at', '=', 0)
- ->orWhere('show_at', '=', 1);
- });
+ public function datatable($homeparty_id){
+
+ $query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '3');
+ $homeparty = Homeparty::findOrFail($homeparty_id);
return \DataTables::eloquent($query)
- ->addColumn('add_card', function (Product $product) {
- return '';
+ ->addColumn('add_card', function (Product $product) use ($homeparty) {
+ if($homeparty->getCardInfo('user_tax_free')){
+ return '';
+ }else{
+ return '';
+ }
+
})
->addColumn('picture', function (Product $product) {
if(count($product->images)){
@@ -477,14 +575,28 @@ class HomepartyController extends Controller
}
return "";
})
- ->addColumn('price_net', function (Product $product) {
- return $product->getFormattedPriceWith(true, true). " €";
+ /*->addColumn('price_net', function (Product $product) use ($homeparty) {
+ return ''.$product->getFormattedPriceWith(true, true, $homeparty->getUserCountry()). " € ".
+ ''.$product->getFormattedPriceCurrencyWith(true, true, $homeparty->getUserCountry()).' ';
})
- ->addColumn('price_gross', function (Product $product) {
- return $product->getFormattedPriceWith(false, true). " €";
+ */
+ ->addColumn('price_gross', function (Product $product) use ($homeparty) {
+ if($homeparty->getCardInfo('user_tax_free')){
+ return ''.$product->getFormattedPriceWith(true, true, $homeparty->getUserCountry()). " € ".
+ ''.$product->getFormattedPriceCurrencyWith(true, true, $homeparty->getUserCountry()).' ';
+ }else{
+ return ''.$product->getFormattedPriceWith(false, true, $homeparty->getUserCountry()). " € ".
+ ''.$product->getFormattedPriceCurrencyWith(false, true, $homeparty->getUserCountry()).' ';
+ }
})
- ->addColumn('price_vk_gross', function (Product $product) {
- return $product->getFormattedPriceWith(false, false). " €";
+ ->addColumn('price_vk_gross', function (Product $product) use ($homeparty) {
+ if($homeparty->getCardInfo('user_tax_free')){
+ return ''.$product->getFormattedPriceWith(true, false, $homeparty->getUserCountry()). " € ".
+ ''.$product->getFormattedPriceCurrencyWith(true, false, $homeparty->getUserCountry()).' ';
+ }else{
+ return ''.$product->getFormattedPriceWith(false, false, $homeparty->getUserCountry()). " € ".
+ ''.$product->getFormattedPriceCurrencyWith(false, false, $homeparty->getUserCountry()).' ';
+ }
})
->addColumn('action', function (Product $product) {
return 'orderColumn('contents_total', 'contents_total $1')
->orderColumn('weight', 'weight $1')
- ->rawColumns(['add_card', 'product', 'quantity', 'picture', 'action'])
+ ->rawColumns(['add_card', 'product', 'quantity', 'picture', 'price_net', 'price_gross', 'price_vk_gross', 'action'])
->make(true);
}
diff --git a/app/Http/Controllers/User/OrderController.php b/app/Http/Controllers/User/OrderController.php
index 115411e7..2b7cc18e 100755
--- a/app/Http/Controllers/User/OrderController.php
+++ b/app/Http/Controllers/User/OrderController.php
@@ -11,6 +11,7 @@ use App\Models\ShoppingUser;
use App\Models\UserHistory;
use App\Models\UserShop;
use App\Services\Payment;
+use App\Services\UserService;
use App\Services\Util;
use App\User;
use Auth;
@@ -102,7 +103,6 @@ class OrderController extends Controller
public function delivery($for, $id=null)
{
$user = User::find(\Auth::user()->id);
-
$shopping_user = null;
$delivery_id = null;
if($for === 'ot'){
@@ -134,10 +134,10 @@ class OrderController extends Controller
public function list($for, $id=null)
{
+
$user = User::find(\Auth::user()->id);
$shopping_user = null;
$delivery_id = null;
-
if($for === 'ot'){
$shopping_user = $this->checkShoppingUser($id, $user);
$delivery_id = $shopping_user->id;
@@ -147,8 +147,10 @@ class OrderController extends Controller
\Session()->flash('custom-error', __('validation.custom.shipping_not_found'));
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
}
-
+ UserService::checkUserTaxShippingCountry($user, $shipping_country_id);
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country_id, $for);
+ Yard::instance('shopping')->setUserPriceInfos(UserService::getYardInfo());
+
$data = [
'shopping_user' => $shopping_user,
@@ -202,6 +204,7 @@ class OrderController extends Controller
$data['is_from'] = 'user_order';
$data['is_for'] = $for;
$data['shopping_user_id'] = $id;
+ $data['user_price_infos'] = Yard::instance('shopping')->getUserPriceInfos();
unset($data['quantity']);
unset($data['_token']);
@@ -232,7 +235,7 @@ class OrderController extends Controller
$country_id = null;
if($for === 'me'){
$user = User::find(\Auth::user()->id);
- if($user->same_as_billing){
+ if($user->account->same_as_billing){
$country_id = $user->account->country_id;
}else{
$country_id = $user->account->shipping_country_id;
@@ -246,7 +249,6 @@ class OrderController extends Controller
$country_id = $shopping_user->shipping_country_id;
}
}
-
if($country_id){
if($shipping_country = ShippingCountry::whereCountryId($country_id)->first()){
return $shipping_country->id;
@@ -272,50 +274,28 @@ class OrderController extends Controller
public function datatable(){
- $show_at = 1;
-
- // $user = User::find(\Auth::user()->id);
- ;
-
if(Request::get('shipping_is_for') === 'me'){
- $query = Product::select('products.*')->where('active', true)->where(function ($q) {
- $q->where('show_at', '=', 1)
- ->orWhere('show_at', '=', 2)
- ->orWhere('show_at', '=', 6);
-
- });
-
+ $query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '2');
}else{
- $query = Product::select('products.*')->where('active', true)->where(function ($q) {
- $q->where('show_at', '=', 0)
- ->orWhere('show_at', '=', 1);
- });
-
+ $query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '1');
}
-
-
- //Kunden und Berater
- //->orWhere('show_at', '=', 2); // Nur Berater
- //->orderBy('pos', 'DESC')
- //->orderBy('id', 'DESC');
-
return \DataTables::eloquent($query)
->addColumn('product', function (Product $product) {
-
$cartItem = Yard::instance('shopping')->getCartItemByProduct($product->id);
$qty = isset($cartItem->qty) ? $cartItem->qty : 0;
$rowId = isset($cartItem->rowId) ? $cartItem->rowId : '';
- return ''.$product->name.'
@@ -88,27 +92,27 @@
{!! Form::checkbox('switch', 1, $country->switch, ['class'=>'custom-control-input']) !!}
Land als Auswahl auf der Webseite anzeigen (Länderwechsel)
+ Hinweis: Die hier aktivierten Länder werden in auf der Shopseite zum Länderwächsel angezeigt, allerdings müssen auch die Versandkosten angelegt sein.
-
@@ -116,6 +120,10 @@
+ Abkürzung der Währung
+ {{ Form::text('currency_unit', $country->currency_unit, array('placeholder'=>__('CHF'), 'class'=>'form-control', 'id'=>'currency_unit')) }}
+
+ {{--
+
Hinweis: Ist für die Einstellungen bei den Produktenpreisen.
+
--}}
Faktor Währungen zum Euro (z.B. 1 Euro zu 1,07 CHF)
{{ Form::text('currency_faktor', formatNumber($country->currency_faktor, 4), array('placeholder'=>__('1,07'), 'class'=>'form-control', 'id'=>'currency_faktor')) }}
+ Hinweis: Der Preis berechnet sich automatisch nach dem Faktor.
+
-
+
+ Hinweis: Bei der Registierung eines Beraters gelten für dieses Land diese Pflichtfelder
diff --git a/resources/views/admin/country/index.blade.php b/resources/views/admin/country/index.blade.php
index 96ebe898..d9525d25 100644
--- a/resources/views/admin/country/index.blade.php
+++ b/resources/views/admin/country/index.blade.php
@@ -17,7 +17,7 @@
{{__('Status')}}
{{__('Reverse Charge')}}
{{__('Länderwechsel')}}
- {{__('Lieferland') }}
+ {{__('Drittland') }}
{{__('e. Preis')}}
{{__('e. Währung')}}
{{__('Kalkulation')}}
diff --git a/resources/views/admin/payment_method/index.blade.php b/resources/views/admin/payment_method/index.blade.php
index 1bd0ac75..249c8a2c 100755
--- a/resources/views/admin/payment_method/index.blade.php
+++ b/resources/views/admin/payment_method/index.blade.php
@@ -26,7 +26,7 @@
data-pos="{{ $value->pos }}"
data-name="{{ $value->name }}"
data-short="{{ $value->short }}"
- data-show_at="{{ $value->show_at }}"
+ data-show_on="{{ json_encode($value->show_on) }}"
data-default="{{ $value->default }}"
data-active="{{ $value->active }}">
@@ -34,7 +34,7 @@
{{ $value->pos }}
{{ $value->name }} ({{ $value->short }})
- {{ $value->getShowAtType() }}
+ {!! implode($value->getShowOnTypes(), ' ') !!}
{!! get_active_badge($value->default) !!}
{!! get_active_badge($value->active) !!}
@@ -47,7 +47,7 @@
data-pos=""
data-name=""
data-short=""
- data-show_at="9"
+ data-show_on="[]"
data-default="1"
data-active="1"
>{{__('Neue Zahlungsart hinzufügen')}}
@@ -83,12 +83,14 @@
-
-
+
{{ __('Produktbeschreibung') }}
{{ Form::textarea('copy', $product->copy , array('placeholder'=>__('Produktbeschreibung'), 'class'=>'form-control summernote', 'id'=>'copy')) }}
@@ -80,7 +86,6 @@
@@ -119,17 +132,17 @@
{{ __('Preis VK in EUR Brutto') }}
- {{ Form::text('c_price['.$country->id.']', formatNumber($product->getCPrice($country->id)), array('placeholder'=>__('Preis VK in EUR Brutto'), 'class'=>'form-control', 'id'=>'c_price_'.$country->id)) }}
+ {{ 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)) }}
{{ __('MwSt in %') }}
- {{ Form::text('c_tax['.$country->id.']', formatNumber($product->getCTax($country->id)), array('placeholder'=>__('MwSt in %'), 'class'=>'form-control', 'id'=>'c_tax'.$country->id)) }}
+ {{ Form::text('c_tax['.$country->id.']', formatNumber($product->getCTax($country)), array('placeholder'=>__('MwSt in %'), 'class'=>'form-control', 'id'=>'c_tax'.$country->id)) }}
{{ __('Streichpreis (wenn > 0)') }}
- {{ Form::text('c_price_old['.$country->id.']', formatNumber($product->getCPriceOld($country->id)), array('placeholder'=>__('Streichpreis'), 'class'=>'form-control', 'id'=>'c_price_old'.$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)) }}
@@ -142,9 +155,9 @@
angegeben @endif
- @if($country->currency_calc)
- {{--
- NUR Anzeige vom automatisch berechneten Preis currency_faktor
+
+
+ {{-- NUR Anzeige vom automatisch berechneten Preis currency_faktor
Auf Basis vom price
Wenn own_eur auf basis vom own_eur price
--}}
@@ -153,19 +166,19 @@
{{ Form::text('c_currency['.$country->id.']', formatNumber($product->getRealPrice($country) * $country->currency_faktor), array('class'=>'form-control', 'readonly')) }}
- @else
- {{--
+ {{--@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
- --}}
{{__('Preis VK in ')}} {{ $country->currency_unit }} ({{formatNumber($product->getRealPrice($country) * $country->currency_faktor)}})
{{ Form::text('c_currency['.$country->id.']', formatNumber($product->getCCurrency($country->id)), array('placeholder'=>__('Preis VK in ').$country->currency_unit, 'class'=>'form-control')) }}
- @endif
+ @endif --}}
- @if(count($values)>0)
+ @if(count($values)>0)
-
- @foreach($values as $value)
-
{{$value}}
- @endforeach
+
+
+
+
+
+ ID
+ User-ID
+ {{__('Name')}}
+ {{__('seit')}}
+ Datum
+ Erreichbar
+ {{__('Status')}}
+
+
+
+ @foreach($values as $value)
+
+ {{ $value->id }}
+ {{ $value->user_id }}
+ {{ $value->name }}.mivita.care
+ {{ $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) !!}
+
+ @endforeach
+
+
+
+
+
+
@endif
diff --git a/resources/views/user/homeparty/_edit.blade.php b/resources/views/user/homeparty/_edit.blade.php
index 2ddf253f..f5f7dfae 100644
--- a/resources/views/user/homeparty/_edit.blade.php
+++ b/resources/views/user/homeparty/_edit.blade.php
@@ -81,16 +81,10 @@