06 2022
This commit is contained in:
parent
9b0b5feb7e
commit
7a040c3e19
106 changed files with 4074 additions and 1349 deletions
|
|
@ -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();
|
||||
|
|
|
|||
97
app/Http/Controllers/Api/GoogleMerchantController.php
Normal file
97
app/Http/Controllers/Api/GoogleMerchantController.php
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Product as ModelsProduct;
|
||||
use Vitalybaev\GoogleMerchant\Feed;
|
||||
use Vitalybaev\GoogleMerchant\Product;
|
||||
use Vitalybaev\GoogleMerchant\Product\Shipping;
|
||||
use Vitalybaev\GoogleMerchant\Product\Availability\Availability;
|
||||
use App\Services\Util;
|
||||
|
||||
|
||||
class GoogleMerchantController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function feed(){
|
||||
|
||||
$products = ModelsProduct::where('active', true)->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
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
]);
|
||||
|
|
|
|||
234
app/Http/Controllers/BusinessController.php
Normal file
234
app/Http/Controllers/BusinessController.php
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\BusinessPlan\TreeCalcBot;
|
||||
use Request;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use App\Services\HTMLHelper;
|
||||
|
||||
|
||||
class BusinessController extends Controller
|
||||
{
|
||||
|
||||
private $filter_active = [1 => '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 '<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$user->id.'"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button>';
|
||||
//<a href="' . route('admin_business_user_detail', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-calculator"></span></a>
|
||||
})
|
||||
->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 '<div class="no-line-break">'.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_sum').'</div>'.
|
||||
'<span class="small no-line-break">B: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points').' | S: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_shop').'</span>';
|
||||
})
|
||||
->addColumn('sales_volume_total', function (User $user) {
|
||||
return '<div class="no-line-break">'.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_sum').'</div>'.
|
||||
'<span class="small no-line-break">B: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total').' | S: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_shop').'</span>';
|
||||
})
|
||||
->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 .= " ".'<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$user->user_sponsor->id.'"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button><br>';
|
||||
}
|
||||
$sponsor .= '<span class="small no-line-break">'.$user->email;
|
||||
if($user->user_sponsor->account){
|
||||
$sponsor .= ' | '.$user->user_sponsor->account->m_account;
|
||||
}
|
||||
$sponsor .= '</span>';
|
||||
|
||||
return $sponsor;
|
||||
}
|
||||
return '-';
|
||||
|
||||
return '<div class="no-line-break">'.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_sum').'</div>'.
|
||||
'<span class="small no-line-break">B: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total').' | S: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_shop').'</span>';
|
||||
})
|
||||
|
||||
->addColumn('is_qual_kp', function (User $user) {
|
||||
if($user->user_level){
|
||||
$qual_kp = $user->user_level->qual_kp;
|
||||
$sales_volume_points_sum = $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_sum');
|
||||
$isQualKP = ($sales_volume_points_sum >= $qual_kp) ? true : false;
|
||||
return '<span class="badge '.($isQualKP ? 'badge-outline-success' : 'badge-outline-danger').'"> KD '.$qual_kp.'</span>';
|
||||
}
|
||||
return '-';
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ->addColumn('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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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()) {
|
||||
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
87
app/Http/Controllers/SyS/SysController.php
Normal file
87
app/Http/Controllers/SyS/SysController.php
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SyS;
|
||||
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\Services\SyS\Sales;
|
||||
use App\Services\SyS\Import;
|
||||
use App\Services\SyS\Cronjobs;
|
||||
use App\Services\SyS\Customers;
|
||||
use App\Services\SyS\DomainSSL;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\SyS\Correction;
|
||||
use App\Services\SyS\ShoppingOrders;
|
||||
|
||||
class SysController extends Controller
|
||||
{
|
||||
protected $userRepo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->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');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,374 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SyS;
|
||||
|
||||
|
||||
use Auth;
|
||||
use Request;
|
||||
use App\User;
|
||||
use App\Mail\MailInfo;
|
||||
use App\Services\Shop;
|
||||
use App\Models\UserShop;
|
||||
use App\Models\Homeparty;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Http\Controllers\Api\KasController;
|
||||
use App\Repositories\ContractPDFRepository;
|
||||
use App\Http\Controllers\Api\KasSLLController;
|
||||
|
||||
|
||||
class AdminToolsController extends Controller
|
||||
{
|
||||
protected $userRepo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SyS;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\ImportRepository;
|
||||
use Request;
|
||||
|
||||
|
||||
class ImportController extends Controller
|
||||
{
|
||||
protected $userRepo;
|
||||
protected $import;
|
||||
|
||||
public function __construct(ImportRepository $import)
|
||||
{
|
||||
$this->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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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){
|
||||
|
|
|
|||
|
|
@ -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')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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] : "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
299
app/Services/BusinessPlan/TreeCalcBot.php
Normal file
299
app/Services/BusinessPlan/TreeCalcBot.php
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
<?php
|
||||
namespace App\Services\BusinessPlan;
|
||||
|
||||
use App\Models\UserLevel;
|
||||
use App\User;
|
||||
use stdClass;
|
||||
|
||||
class TreeCalcBot
|
||||
{
|
||||
private $items = [];
|
||||
private $parentless = [];
|
||||
private $sponsor;
|
||||
private $date;
|
||||
public $user;
|
||||
public $lines = [];
|
||||
public $total_tp = 0;
|
||||
public $total_qual_tp = 0;
|
||||
public $commission_total = 0;
|
||||
public $qual_user_level = null;
|
||||
private $init_from;
|
||||
|
||||
|
||||
|
||||
|
||||
private static $userIDs = [];
|
||||
|
||||
public static function addUserID($id){
|
||||
self::$userIDs[$id] = $id;
|
||||
}
|
||||
|
||||
public function __construct($month, $year, $init_from = 'member')
|
||||
{
|
||||
$this->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 = '<ol class="dd-list">';
|
||||
foreach($this->items as $item){
|
||||
$ret .= $this->addItem($item, $deep);
|
||||
}
|
||||
$ret .= '</ol>';
|
||||
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 = ' | <button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$item->id.'"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="'.$this->init_from .'"
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button>';
|
||||
}
|
||||
return '<li class="dd-item dd-nodrag" data-id="'.$item->id.'">'.
|
||||
'<div class="dd-handle">
|
||||
<div class="media align-items-center">
|
||||
<div class="d-flex flex-column justify-content-center align-items-center">
|
||||
'.(($deep > 0) ? '<div class="text-large font-weight-bolder line-height-1 my-2 text-secondary badge badge-outline-secondary">'.$deep.'</div>' : '').'
|
||||
</div>
|
||||
<div class="media-body ml-2">
|
||||
<span class="'.($item->active_account ? '' : 'text-muted').'">
|
||||
<span class="mr-1 ion ion-ios-contact '.($item->active_account ? 'text-primary' : 'text-danger').'"></span>
|
||||
<strong>'.$item->first_name.' '.$item->last_name.'</strong> <a href="mailto: '.$item->email.'">'.$item->email.'</a> <span class="badge badge-outline-default '.($item->active_account ? '' : 'text-muted').'">'.$item->user_level.' | '.$item->m_account.'</span>
|
||||
<br><span class="small">'.
|
||||
($item->active_account ?
|
||||
'<strong>Points: '.$item->sales_volume_points_sum.'</strong> | B: '.$item->sales_volume_points.' | S: '.$item->sales_volume_points_shop.' <strong> | Umsatz: '.$item->sales_volume_total_sum.' €</strong> | B: '.$item->sales_volume_total.' € | S: '.$item->sales_volume_total_shop.' €'.
|
||||
$button
|
||||
:
|
||||
'Account bis: '.$item->payment_account_date).
|
||||
'</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>'.
|
||||
$this->addParentItem($item, $deep).
|
||||
'</li>';
|
||||
|
||||
}
|
||||
|
||||
private function addParentItem($item, $deep){
|
||||
if($item->items){
|
||||
$ret = '<ol class="dd-list dd-nodrag">';
|
||||
foreach($item->items as $parent){
|
||||
$ret .= $this->addItem($parent, $deep+1);
|
||||
}
|
||||
$ret .='</ol>';
|
||||
return $ret;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
public function isParentless(){
|
||||
return $this->parentless ? true : false;
|
||||
}
|
||||
|
||||
public function makeParentlessHtml(){
|
||||
$ret = "";
|
||||
foreach($this->parentless as $item){
|
||||
$ret .= '<li class="dd-item dd-nodrag" data-id="'.$item->id.'">'.
|
||||
'<div class="dd-handle">
|
||||
<span class="'.($item->active_account ? '' : 'text-muted').'">
|
||||
<span class="mr-1 ion ion-ios-contact '.($item->active_account ? 'text-primary' : 'text-danger').'"></span>
|
||||
<strong>'.$item->first_name.' '.$item->last_name.'</strong> <a href="mailto: '.$item->email.'">'.$item->email.'</a> <span class="badge badge-outline-default '.($item->active_account ? '' : 'text-muted').'">'.$item->user_level.' | '.$item->m_account.'</span>
|
||||
<br><span class="small">'.
|
||||
($item->active_account ?
|
||||
'<strong>Points: '.$item->sales_volume_points_sum.'</strong> | B: '.$item->sales_volume_points.' | S: '.$item->sales_volume_points_shop.' <strong> | Umsatz: '.$item->sales_volume_total_sum.' €</strong> | B: '.$item->sales_volume_total.' € | S: '.$item->sales_volume_total_shop.' €'.
|
||||
' | <button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$item->id.'"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button>'
|
||||
:
|
||||
'Account bis: '.$item->payment_account_date).
|
||||
'<br>'.$item->m_sponsor_name.
|
||||
'</span>
|
||||
</span>
|
||||
</div>'.
|
||||
'</li>';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function makeSponsorHtml(){
|
||||
|
||||
if($this->sponsor){
|
||||
//' | <a href="' . route('admin_business_user_detail', [$this->sponsor->id]) . '" class="btn icon-btn btn-xs btn-secondary"><span class="far fa-calculator"></span></a>'
|
||||
$ret = '<li class="dd-item dd-nodrag" data-id="">'.
|
||||
'<div class="dd-handle">
|
||||
<span class="'.($this->sponsor->active_account ? '' : 'text-muted').'">
|
||||
<span class="mr-1 ion ion-ios-contact '.($this->sponsor->active_account ? 'text-primary' : 'text-danger').'"></span>
|
||||
<strong>'.$this->sponsor->first_name.' '.$this->sponsor->last_name.'</strong> <a href="mailto: '.$this->sponsor->email.'">'.$this->sponsor->email.'</a> <span class="badge badge-outline-default '.($this->sponsor->active_account ? '' : 'text-muted').'">'.$this->sponsor->user_level.' | '.$this->sponsor->m_account.'</span>';
|
||||
|
||||
if($this->init_from === 'admin'){
|
||||
$ret .= '<br><span class="small">'.
|
||||
($this->sponsor->active_account ?
|
||||
'<strong>Points: '.$this->sponsor->sales_volume_points_sum.'</strong> | B: '.$this->sponsor->sales_volume_points.' | S: '.$this->sponsor->sales_volume_points_shop.' <strong> | Umsatz: '.$this->sponsor->sales_volume_total_sum.' €</strong> | B: '.$this->sponsor->sales_volume_total.' € | S: '.$this->sponsor->sales_volume_total_shop.' €'
|
||||
:
|
||||
'Account bis: '.$this->sponsor->payment_account_date).
|
||||
'</span>';
|
||||
}
|
||||
$ret .= '</span>
|
||||
</div>
|
||||
</li>';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
return 'Keinen Sponsor zugewiesen';
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
114
app/Services/BusinessPlan/TreeUserItem.php
Normal file
114
app/Services/BusinessPlan/TreeUserItem.php
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
namespace App\Services\BusinessPlan;
|
||||
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
class TreeUserItem
|
||||
{
|
||||
public $items = [];
|
||||
private $date;
|
||||
|
||||
|
||||
|
||||
|
||||
public function __construct($date)
|
||||
{
|
||||
$this->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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,352 +0,0 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Attribute;
|
||||
use App\Models\Category;
|
||||
use App\Models\Country;
|
||||
use App\Models\Ingredient;
|
||||
use App\Models\Product;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserLevel;
|
||||
use App\User;
|
||||
|
||||
class HTMLHelper
|
||||
{
|
||||
|
||||
|
||||
private 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',
|
||||
];
|
||||
|
||||
|
||||
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 '<span class="badge badge-pill '.self::getLabel($role_id).'">'.self::$roles[$role_id].'</span>';
|
||||
}
|
||||
|
||||
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 .= '<option value="'.$role_id.'">'.$value.'</option>\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 .= '<option value="'.$value.'" '.$attr.'>'.$value.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getAttributesWithoutParents($id = false, $sameId = false, $all = true){
|
||||
$values = Attribute::where('parent_id', null)->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('no').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
if($sameId == $value->id){
|
||||
continue;
|
||||
}
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getCategoriesWithoutParents($id = false, $sameId = false, $all = true){
|
||||
$values = Category::where('parent_id', null)->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('no').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
if($sameId == $value->id){
|
||||
continue;
|
||||
}
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\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 .= '<option value="">'.__('no').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
$attr = in_array($value->id, $ids) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getCategoriesOptions($ids = array(), $all = true){
|
||||
$values = Category::where('active', 1)->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('no').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
$attr = in_array($value->id, $ids) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\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 .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getAttributesOptions($ids = array(), $all = true){
|
||||
$values = Attribute::where('active', 1)->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('no').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
$attr = in_array($value->id, $ids) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getUserLevelOptions($id = false, $all = true){
|
||||
$values = UserLevel::where('active', 1)->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('no').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\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 .= '<option value="'.$id.'" '.$attr.'>'.$value.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getContriesWithMore($id, $all=true){#
|
||||
$values = Country::all();
|
||||
$counter = 1;
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
|
||||
}
|
||||
foreach ($values as $value){
|
||||
if( $counter == 7){
|
||||
$ret .= '<optgroup label="'.__('further countrie').'">';
|
||||
}
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->getLocated().'</option>\n';
|
||||
|
||||
$counter ++;
|
||||
}
|
||||
$ret .= '</optgroup>';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getContriesCodes($id, $all=true){#
|
||||
$values = Country::all();
|
||||
$counter = 1;
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
|
||||
}
|
||||
foreach ($values as $value){
|
||||
|
||||
if(!$value->phone) continue;
|
||||
if( $counter == 7){
|
||||
$ret .= '<optgroup label="'.__('further countrie').'">';
|
||||
}
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->phone.'('.$value->getLocated().')</option>\n';
|
||||
|
||||
$counter ++;
|
||||
}
|
||||
$ret .= '</optgroup>';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getCountriesWithoutUsedShippings($all=true){#
|
||||
$values = Country::all();
|
||||
$country_ids = ShippingCountry::all()->pluck('country_id')->toArray();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
if(!in_array($value->id, $country_ids)){
|
||||
$ret .= '<option value="'.$value->id.'">'.$value->getLocated().'</option>\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 .= '<option value="">'.__('please select').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->country->getLocated().'</option>\n';
|
||||
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getSalutation($id){
|
||||
$values = array('mr' => __('MR'), 'ms' => __('MS'));
|
||||
$ret = "";
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
foreach ($values as $key => $value){
|
||||
$attr = ($key == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$key.'" '.$attr.'>'.$value.'</option>\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 .= '<option value="">'.__('please select').'</option>\n';
|
||||
foreach ($values as $key => $value){
|
||||
$attr = ($key == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$key.'" '.$attr.'>'.$value.'</option>\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 .= '<option value="">'.__('please select').'</option>\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 .= '<option value="'.$value->id.'" '.$attr.'>'.$to.$value->email.' #'.$value->number.'</option>\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 .= '<option value="">'.__('please select').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
dump($value);
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$to = $value->billing_firstname." ".$value->billing_lastname." | ".$value->billing_email;
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$to.' #'.$value->number.'</option>\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 .= '<option value="'.$value.'" '.$attr.'>'.$value.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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 '<span class="badge badge-pill '.self::getLabel($role_id).'">'.self::$roles[$role_id].'</span>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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){
|
||||
|
|
|
|||
|
|
@ -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
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
use App\User;
|
||||
|
||||
class PriceService
|
||||
{
|
||||
public static $country;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function createConfirmationCode() {
|
||||
$unique = false;
|
||||
do{
|
||||
$confirmation_code = str_random(30);
|
||||
if(User::where('confirmation_code', '=', $confirmation_code)->count() == 0){
|
||||
$unique = true;
|
||||
}
|
||||
}
|
||||
while(!$unique);
|
||||
return $confirmation_code;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
304
app/Services/SyS/Correction.php
Normal file
304
app/Services/SyS/Correction.php
Normal file
|
|
@ -0,0 +1,304 @@
|
|||
<?php
|
||||
namespace App\Services\SyS;
|
||||
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\Models\Product;
|
||||
use App\Models\Homeparty;
|
||||
use App\Models\SySetting;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\UserSalesVolume;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use App\Repositories\ImportRepository;
|
||||
|
||||
class Correction
|
||||
{
|
||||
|
||||
private static function userSalesVolume($order){
|
||||
/*
|
||||
status
|
||||
1 => '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');
|
||||
}
|
||||
|
||||
}
|
||||
32
app/Services/SyS/CronJobs.php
Normal file
32
app/Services/SyS/CronJobs.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
namespace App\Services\SyS;
|
||||
|
||||
use Request;
|
||||
|
||||
class Cronjobs
|
||||
{
|
||||
|
||||
public static function show()
|
||||
{
|
||||
//$user_shops = UserShop::all();
|
||||
$text = "";
|
||||
$values = [
|
||||
'Prüft die Dauer der Mitgliedschaft und sendet Erinnerungsmails' => 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();
|
||||
}
|
||||
|
||||
}
|
||||
63
app/Services/SyS/Customers.php
Normal file
63
app/Services/SyS/Customers.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
namespace App\Services\SyS;
|
||||
|
||||
use Auth;
|
||||
use Request;
|
||||
use App\User;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Repositories\ContractPDFRepository;
|
||||
|
||||
class Customers
|
||||
{
|
||||
|
||||
public static function show()
|
||||
{
|
||||
$shopping_users = ShoppingUser::where('member_id', '=', NULL)->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();
|
||||
}
|
||||
}
|
||||
104
app/Services/SyS/DomainSSL.php
Normal file
104
app/Services/SyS/DomainSSL.php
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
namespace App\Services\SyS;
|
||||
|
||||
use Request;
|
||||
use App\Models\UserShop;
|
||||
use App\Http\Controllers\Api\KasController;
|
||||
use App\Http\Controllers\Api\KasSLLController;
|
||||
|
||||
class DomainSSL
|
||||
{
|
||||
|
||||
public static function show()
|
||||
{
|
||||
$user_shops = UserShop::limit(1000)->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();
|
||||
}
|
||||
|
||||
}
|
||||
49
app/Services/SyS/Import.php
Normal file
49
app/Services/SyS/Import.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
namespace App\Services\SyS;
|
||||
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\Models\SySetting;
|
||||
use App\Repositories\ImportRepository;
|
||||
|
||||
class Import
|
||||
{
|
||||
|
||||
public static function show()
|
||||
{
|
||||
abort(403, 'STOP funtion not online');
|
||||
|
||||
return view('sys.tools.import', []);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function store()
|
||||
{
|
||||
abort(403, 'STOP funtion not online');
|
||||
}
|
||||
|
||||
|
||||
public function importStore()
|
||||
{
|
||||
$input = Request::all();
|
||||
$import_repo = new ImportRepository();
|
||||
|
||||
return $import_repo->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);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SyS;
|
||||
namespace App\Services\SyS;
|
||||
|
||||
use Request;
|
||||
use Carbon;
|
||||
use App\Models\SySetting;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
|
||||
class SalesController extends Controller
|
||||
class Sales
|
||||
{
|
||||
protected $userRepo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->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']));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
64
app/Services/SyS/ShoppingOrders.php
Normal file
64
app/Services/SyS/ShoppingOrders.php
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
namespace App\Services\SyS;
|
||||
|
||||
use Request;
|
||||
use App\Services\Shop;
|
||||
use App\Models\UserShop;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Http\Controllers\Api\KasController;
|
||||
use App\Http\Controllers\Api\KasSLLController;
|
||||
|
||||
class ShoppingOrders
|
||||
{
|
||||
|
||||
public static function show()
|
||||
{
|
||||
abort(403, 'STOP funtion not online');
|
||||
|
||||
$shopping_users = ShoppingUser::all();
|
||||
$data = [
|
||||
'values' => $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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
class TaxPriceHelper
|
||||
{
|
||||
public static function userOrders() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -110,6 +110,4 @@ class UserService
|
|||
return $confirmation_code;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ use App\Models\Country;
|
|||
use App\Models\UserHistory;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\ShippingCountry;
|
||||
use Request;
|
||||
|
||||
class Util
|
||||
{
|
||||
|
|
@ -205,7 +206,6 @@ class Util
|
|||
if(\Session::has('user_shop_payment')){
|
||||
return \Session::get('user_shop_payment');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -245,9 +245,25 @@ class Util
|
|||
}
|
||||
|
||||
public static function isMivitaShop(){
|
||||
if(Request::getHost() === 'checkout.'.config('app.domain').config('app.tld_care')){
|
||||
if($user_shop = \Session::get('user_shop')){
|
||||
if($user_shop->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)
|
||||
{
|
||||
|
|
|
|||
38
app/User.php
38
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue