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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,78 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SyS;
|
||||
|
||||
use Request;
|
||||
use Carbon;
|
||||
use App\Models\SySetting;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
|
||||
class SalesController extends Controller
|
||||
{
|
||||
protected $userRepo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('sysadmin');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$start = 2019;
|
||||
$end = date('Y');
|
||||
$years = range($start, $end);
|
||||
|
||||
if(Request::get('filter_sales_year')){
|
||||
$active_year = Request::get('filter_sales_year');
|
||||
}else{
|
||||
$active_year = $end;
|
||||
}
|
||||
|
||||
$date1 = Carbon::parse('01.01.'.$active_year." 00:00:00")->format('Y-m-d H:i:s');
|
||||
$date2 = Carbon::parse('31.12.'.$active_year." 23:59:59")->toDateString();
|
||||
|
||||
|
||||
$values = ShoppingOrder::where('shopping_orders.auth_user_id', '!=', NULL) //::with('shopping_user', )->select('shopping_orders.*')
|
||||
->where('mode', '=', 'live')
|
||||
->where('paid', '=', 1)
|
||||
->whereHas('shopping_order_items', function($q) {
|
||||
|
||||
$q->where('product_id', 34)->OrWhere('product_id', 35)->OrWhere('product_id', 36)->OrWhere('product_id', 67)->OrWhere('product_id', 69);
|
||||
})
|
||||
->whereBetween('created_at', [$date1, $date2])
|
||||
->get();
|
||||
|
||||
$data = [
|
||||
'years' => $years,
|
||||
'active_year' => $active_year,
|
||||
'values' => $values,
|
||||
];
|
||||
return view('sys.sales.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Request::all();
|
||||
|
||||
$data['active'] = isset($data['active']) ? true : false;
|
||||
if($data['id'] === "new"){
|
||||
$model = SySetting::create($data);
|
||||
}else{
|
||||
$model = SySetting::find($data['id']);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('sysadmin_settings'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
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'));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue