diff --git a/app/Classes/Settings/System.php b/app/Classes/Settings/System.php index fe881892..756f1dd3 100644 --- a/app/Classes/Settings/System.php +++ b/app/Classes/Settings/System.php @@ -69,31 +69,33 @@ class System $this->updateIcons($request); $values = [ - 'SETTINGS::SYSTEM:REGISTER_IP_CHECK' => 'register-ip-check', - 'SETTINGS::SYSTEM:SERVER_CREATE_CHARGE_FIRST_HOUR' => 'server-create-charge-first-hour', - 'SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME' => 'credits-display-name', - 'SETTINGS::SERVER:ALLOCATION_LIMIT' => 'allocation-limit', - 'SETTINGS::USER:FORCE_DISCORD_VERIFICATION' => 'force-discord-verification', - 'SETTINGS::USER:FORCE_EMAIL_VERIFICATION' => 'force-email-verification', - 'SETTINGS::USER:INITIAL_CREDITS' => 'initial-credits', - 'SETTINGS::USER:INITIAL_SERVER_LIMIT' => 'initial-server-limit', - 'SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD' => 'credits-reward-amount-discord', - 'SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL' => 'credits-reward-amount-email', - 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD' => 'server-limit-discord', - 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL' => 'server-limit-email', - 'SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE' => 'server-limit-purchase', - 'SETTINGS::MISC:PHPMYADMIN:URL' => 'phpmyadmin-url', - 'SETTINGS::SYSTEM:PTERODACTYL:URL' => 'pterodactyl-url', - 'SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT' => 'per-page-limit', - 'SETTINGS::SYSTEM:PTERODACTYL:TOKEN' => 'pterodactyl-api-key', - 'SETTINGS::SYSTEM:ENABLE_LOGIN_LOGO' => 'enable-login-logo', - 'SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN' => 'pterodactyl-admin-api-key', - 'SETTINGS::SYSTEM:ENABLE_UPGRADE' => 'enable-upgrade', - 'SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS' => 'enable-disable-servers', - 'SETTINGS::SYSTEM:CREATION_OF_NEW_USERS' => 'enable-disable-new-users', - 'SETTINGS::SYSTEM:SHOW_IMPRINT' => 'show-imprint', - 'SETTINGS::SYSTEM:SHOW_PRIVACY' => 'show-privacy', - 'SETTINGS::SYSTEM:SHOW_TOS' => 'show-tos', + + "SETTINGS::SYSTEM:REGISTER_IP_CHECK" => "register-ip-check", + "SETTINGS::SYSTEM:SERVER_CREATE_CHARGE_FIRST_HOUR" => "server-create-charge-first-hour", + "SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME" => "credits-display-name", + "SETTINGS::SERVER:ALLOCATION_LIMIT" => "allocation-limit", + "SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER" => "minimum-credits", + "SETTINGS::USER:FORCE_DISCORD_VERIFICATION" => "force-discord-verification", + "SETTINGS::USER:FORCE_EMAIL_VERIFICATION" => "force-email-verification", + "SETTINGS::USER:INITIAL_CREDITS" => "initial-credits", + "SETTINGS::USER:INITIAL_SERVER_LIMIT" => "initial-server-limit", + "SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD" => "credits-reward-amount-discord", + "SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL" => "credits-reward-amount-email", + "SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD" => "server-limit-discord", + "SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL" => "server-limit-email", + "SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE" => "server-limit-purchase", + "SETTINGS::MISC:PHPMYADMIN:URL" => "phpmyadmin-url", + "SETTINGS::SYSTEM:PTERODACTYL:URL" => "pterodactyl-url", + 'SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT' => "per-page-limit", + "SETTINGS::SYSTEM:PTERODACTYL:TOKEN" => "pterodactyl-api-key", + "SETTINGS::SYSTEM:ENABLE_LOGIN_LOGO" => "enable-login-logo", + "SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN" => "pterodactyl-admin-api-key", + "SETTINGS::SYSTEM:ENABLE_UPGRADE" => "enable-upgrade", + "SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS" => "enable-disable-servers", + "SETTINGS::SYSTEM:CREATION_OF_NEW_USERS" => "enable-disable-new-users", + "SETTINGS::SYSTEM:SHOW_IMPRINT" => "show-imprint", + "SETTINGS::SYSTEM:SHOW_PRIVACY" => "show-privacy", + "SETTINGS::SYSTEM:SHOW_TOS" => "show-tos", ]; foreach ($values as $key => $value) { diff --git a/app/Http/Controllers/Admin/OverViewController.php b/app/Http/Controllers/Admin/OverViewController.php index baf51dea..280b59d4 100644 --- a/app/Http/Controllers/Admin/OverViewController.php +++ b/app/Http/Controllers/Admin/OverViewController.php @@ -44,25 +44,18 @@ class OverViewController extends Controller $counters->put('payments', collect()); //Get and save payments from last 2 months for later filtering and looping $payments = Payment::query()->where('created_at', '>=', Carbon::today()->startOfMonth()->subMonth())->where('status', 'paid')->get(); - //Prepare collections and set a few variables + //Prepare collections $counters['payments']->put('thisMonth', collect()); $counters['payments']->put('lastMonth', collect()); - $counters['payments']['thisMonth']->timeStart = Carbon::today()->startOfMonth()->toDateString(); - $counters['payments']['thisMonth']->timeEnd = Carbon::today()->toDateString(); - $counters['payments']['lastMonth']->timeStart = Carbon::today()->startOfMonth()->subMonth()->toDateString(); - $counters['payments']['lastMonth']->timeEnd = Carbon::today()->endOfMonth()->subMonth()->toDateString(); + //Prepare subCollection 'taxPayments' $counters->put('taxPayments', collect()); //Get and save taxPayments from last 2 years for later filtering and looping $taxPayments = Payment::query()->where('created_at', '>=', Carbon::today()->startOfYear()->subYear())->where('status', 'paid')->get(); - //Prepare collections and set a few variables + //Prepare collections $counters['taxPayments']->put('thisYear', collect()); $counters['taxPayments']->put('lastYear', collect()); - $counters['taxPayments']['thisYear']->timeStart = Carbon::today()->startOfYear()->toDateString(); - $counters['taxPayments']['thisYear']->timeEnd = Carbon::today()->toDateString(); - $counters['taxPayments']['lastYear']->timeStart = Carbon::today()->startOfYear()->subYear()->toDateString(); - $counters['taxPayments']['lastYear']->timeEnd = Carbon::today()->endOfYear()->subYear()->toDateString(); //Fill out variables for each currency separately foreach ($payments->where('created_at', '>=', Carbon::today()->startOfMonth()) as $payment) { @@ -85,11 +78,21 @@ class OverViewController extends Controller $counters['payments']['lastMonth'][$paymentCurrency]->total += $payment->total_price; $counters['payments']['lastMonth'][$paymentCurrency]->count++; } + + //sort currencies alphabetically and set some additional variables + $counters['payments']['thisMonth'] = $counters['payments']['thisMonth']->sortKeys(); + $counters['payments']['thisMonth']->timeStart = Carbon::today()->startOfMonth()->toDateString(); + $counters['payments']['thisMonth']->timeEnd = Carbon::today()->toDateString(); + $counters['payments']['lastMonth'] = $counters['payments']['lastMonth']->sortKeys(); + $counters['payments']['lastMonth']->timeStart = Carbon::today()->startOfMonth()->subMonth()->toDateString(); + $counters['payments']['lastMonth']->timeEnd = Carbon::today()->endOfMonth()->subMonth()->toDateString(); $counters['payments']->total = Payment::query()->count(); - foreach ($taxPayments->where('created_at', '>=', Carbon::today()->startOfYear()->subYear()) as $taxPayment) { - $paymentCurrency = $payment->currency_code; - if (! isset($counters['taxPayments']['thisYear'][$paymentCurrency])) { + + foreach($taxPayments->where('created_at', '>=', Carbon::today()->startOfYear()) as $taxPayment){ + $paymentCurrency = $taxPayment->currency_code; + if(!isset($counters['taxPayments']['thisYear'][$paymentCurrency])){ + $counters['taxPayments']['thisYear']->put($paymentCurrency, collect()); $counters['taxPayments']['thisYear'][$paymentCurrency]->total = 0; $counters['taxPayments']['thisYear'][$paymentCurrency]->count = 0; @@ -101,9 +104,11 @@ class OverViewController extends Controller $counters['taxPayments']['thisYear'][$paymentCurrency]->price += $taxPayment->price; $counters['taxPayments']['thisYear'][$paymentCurrency]->taxes += $taxPayment->tax_value; } - foreach ($taxPayments->where('created_at', '<', Carbon::today()->startOfYear()) as $taxPayment) { - $paymentCurrency = $payment->currency_code; - if (! isset($counters['taxPayments']['lastYear'][$paymentCurrency])) { + + foreach($taxPayments->where('created_at', '>=', Carbon::today()->startOfYear()->subYear())->where('created_at', '<', Carbon::today()->startOfYear()) as $taxPayment){ + $paymentCurrency = $taxPayment->currency_code; + if(!isset($counters['taxPayments']['lastYear'][$paymentCurrency])){ + $counters['taxPayments']['lastYear']->put($paymentCurrency, collect()); $counters['taxPayments']['lastYear'][$paymentCurrency]->total = 0; $counters['taxPayments']['lastYear'][$paymentCurrency]->count = 0; @@ -116,6 +121,14 @@ class OverViewController extends Controller $counters['taxPayments']['lastYear'][$paymentCurrency]->taxes += $taxPayment->tax_value; } + //sort currencies alphabetically and set some additional variables + $counters['taxPayments']['thisYear'] = $counters['taxPayments']['thisYear']->sortKeys(); + $counters['taxPayments']['thisYear']->timeStart = Carbon::today()->startOfYear()->toDateString(); + $counters['taxPayments']['thisYear']->timeEnd = Carbon::today()->toDateString(); + $counters['taxPayments']['lastYear'] = $counters['taxPayments']['lastYear']->sortKeys(); + $counters['taxPayments']['lastYear']->timeStart = Carbon::today()->startOfYear()->subYear()->toDateString(); + $counters['taxPayments']['lastYear']->timeEnd = Carbon::today()->endOfYear()->subYear()->toDateString(); + $lastEgg = Egg::query()->latest('updated_at')->first(); $syncLastUpdate = $lastEgg ? $lastEgg->updated_at->isoFormat('LLL') : __('unknown'); diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index c109d8ef..96c82664 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -70,8 +70,61 @@ class PaymentController extends Controller * @param ShopProduct $shopProduct * @return RedirectResponse */ + public function FreePay(Request $request, ShopProduct $shopProduct) + { + //dd($shopProduct); + //check if the product is really free or the discount is 100% + if($shopProduct->getTotalPrice()>0) return redirect()->route('home')->with('error', __('An error ocured. Please try again.')); + + //give product + /** @var User $user */ + $user = Auth::user(); + + //not updating server limit + + //update User with bought item + if ($shopProduct->type=="Credits") { + $user->increment('credits', $shopProduct->quantity); + }elseif ($shopProduct->type=="Server slots"){ + $user->increment('server_limit', $shopProduct->quantity); + } + + //skipped the referral commission, because the user did not pay anything. + + //not giving client role + + //store payment + $payment = Payment::create([ + 'user_id' => $user->id, + 'payment_id' => uniqid(), + 'payment_method' => 'free', + 'type' => $shopProduct->type, + 'status' => 'paid', + 'amount' => $shopProduct->quantity, + 'price' => $shopProduct->price - ($shopProduct->price*PartnerDiscount::getDiscount()/100), + 'tax_value' => $shopProduct->getTaxValue(), + 'tax_percent' => $shopProduct->getTaxPercent(), + 'total_price' => $shopProduct->getTotalPrice(), + 'currency_code' => $shopProduct->currency_code, + 'shop_item_product_id' => $shopProduct->id, + ]); + + event(new UserUpdateCreditsEvent($user)); + + //not sending an invoice + + //redirect back to home + return redirect()->route('home')->with('success', __('Your credit balance has been increased!')); + } + + /** + * @param Request $request + * @param ShopProduct $shopProduct + * @return RedirectResponse + */ public function PaypalPay(Request $request, ShopProduct $shopProduct) { + if(!$this->checkAmount($shopProduct->getTotalPrice(), strtoupper($shopProduct->currency_code), "paypal")) return redirect()->route('home')->with('error', __('The product you chose can´t be purchased with this payment method. The total amount is too small. Please buy a bigger amount or try a different payment method.')); $request = new OrdersCreateRequest(); $request->prefer('return=representation'); $request->body = [ @@ -271,6 +324,7 @@ class PaymentController extends Controller */ public function StripePay(Request $request, ShopProduct $shopProduct) { + if(!$this->checkAmount($shopProduct->getTotalPrice(), strtoupper($shopProduct->currency_code), "stripe")) return redirect()->route('home')->with('error', __('The product you chose can´t be purchased with this payment method. The total amount is too small. Please buy a bigger amount or try a different payment method.')); $stripeClient = $this->getStripeClient(); $request = $stripeClient->checkout->sessions->create([ @@ -637,6 +691,114 @@ class PaymentController extends Controller $user->notify(new InvoiceNotification($invoice, $user, $payment)); } + public function checkAmount($amount, $currencyCode, $payment_method) + { + $minimums = [ + "USD" => [ + "paypal" => 0, + "stripe" => 0.5 + ], + "AED" => [ + "paypal" => 0, + "stripe" => 2 + ], + "AUD" => [ + "paypal" => 0, + "stripe" => 0.5 + ], + "BGN" => [ + "paypal" => 0, + "stripe" => 1 + ], + "BRL" => [ + "paypal" => 0, + "stripe" => 0.5 + ], + "CAD" => [ + "paypal" => 0, + "stripe" => 0.5 + ], + "CHF" => [ + "paypal" => 0, + "stripe" => 0.5 + ], + "CZK" => [ + "paypal" => 0, + "stripe" => 15 + ], + "DKK" => [ + "paypal" => 0, + "stripe" => 2.5 + ], + "EUR" => [ + "paypal" => 0, + "stripe" => 0.5 + ], + "GBP" => [ + "paypal" => 0, + "stripe" => 0.3 + ], + "HKD" => [ + "paypal" => 0, + "stripe" => 4 + ], + "HRK" => [ + "paypal" => 0, + "stripe" => 0.5 + ], + "HUF" => [ + "paypal" => 0, + "stripe" => 175 + ], + "INR" => [ + "paypal" => 0, + "stripe" => 0.5 + ], + "JPY" => [ + "paypal" => 0, + "stripe" => 0.5 + ], + "MXN" => [ + "paypal" => 0, + "stripe" => 10 + ], + "MYR" => [ + "paypal" => 0, + "stripe" => 2 + ], + "NOK" => [ + "paypal" => 0, + "stripe" => 3 + ], + "NZD" => [ + "paypal" => 0, + "stripe" => 0.5 + ], + "PLN" => [ + "paypal" => 0, + "stripe" => 2 + ], + "RON" => [ + "paypal" => 0, + "stripe" => 2 + ], + "SEK" => [ + "paypal" => 0, + "stripe" => 3 + ], + "SGD" => [ + "paypal" => 0, + "stripe" => 0.5 + ], + "THB" => [ + "paypal" => 0, + "stripe" => 10 + ] + ]; + return $amount >= $minimums[$currencyCode][$payment_method]; + } + + /** * @return JsonResponse|mixed * @@ -647,9 +809,11 @@ class PaymentController extends Controller $query = Payment::with('user'); return datatables($query) - ->editColumn('user', function (Payment $payment) { - return - ($payment->user) ? ''.$payment->user->name.'' : __('Unknown user'); + + ->addColumn('user', function (Payment $payment) { + return + ($payment->user)?''.$payment->user->name.'':__('Unknown user'); + }) ->editColumn('price', function (Payment $payment) { return $payment->formatToCurrency($payment->price); @@ -665,7 +829,8 @@ class PaymentController extends Controller }) ->editColumn('created_at', function (Payment $payment) { - return $payment->created_at ? $payment->created_at->diffForHumans() : ''; + return ['display' => $payment->created_at ? $payment->created_at->diffForHumans() : '', + 'raw' => $payment->created_at ? strtotime($payment->created_at) : '']; }) ->addColumn('actions', function (Payment $payment) { return ''; diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php index c90c3c5f..5e9157d9 100644 --- a/app/Http/Controllers/Admin/ProductController.php +++ b/app/Http/Controllers/Admin/ProductController.php @@ -229,6 +229,9 @@ class ProductController extends Controller '; }) + ->editColumn('minimum_credits', function (Product $product) { + return $product->minimum_credits==-1 ? config('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER') : $product->minimum_credits; + }) ->editColumn('created_at', function (Product $product) { return $product->created_at ? $product->created_at->diffForHumans() : ''; }) diff --git a/app/Http/Controllers/Moderation/TicketsController.php b/app/Http/Controllers/Moderation/TicketsController.php index 3a6787ac..ffc0a321 100644 --- a/app/Http/Controllers/Moderation/TicketsController.php +++ b/app/Http/Controllers/Moderation/TicketsController.php @@ -117,10 +117,14 @@ class TicketsController extends Controller return ''.$tickets->status.''; }) - ->editColumn('updated_at', function (Ticket $tickets) { - return $tickets->updated_at ? $tickets->updated_at->diffForHumans() : ''; + ->editColumn('priority', function (Ticket $tickets) { + return __($tickets->priority); }) - ->rawColumns(['category', 'title', 'user_id', 'status', 'updated_at', 'actions']) + ->editColumn('updated_at', function (Ticket $tickets) { + return ['display' => $tickets->updated_at ? $tickets->updated_at->diffForHumans() : '', + 'raw' => $tickets->updated_at ? strtotime($tickets->updated_at) : '']; + }) + ->rawColumns(['category', 'title', 'user_id', 'status', 'priority', 'updated_at', 'actions']) ->make(true); } diff --git a/app/Http/Controllers/TicketsController.php b/app/Http/Controllers/TicketsController.php index 5e8d22dd..9ef9600e 100644 --- a/app/Http/Controllers/TicketsController.php +++ b/app/Http/Controllers/TicketsController.php @@ -100,6 +100,13 @@ class TicketsController extends Controller return redirect()->back()->with('success', __('Your comment has been submitted')); } + public function close($ticket_id) + { + $ticket = Ticket::where('user_id', Auth::user()->id)->where("ticket_id", $ticket_id)->firstOrFail(); + $ticket->status = "Closed"; + $ticket->save(); + return redirect()->back()->with('success', __('A ticket has been closed, ID: #') . $ticket->ticket_id); + } public function dataTable() { @@ -130,6 +137,9 @@ class TicketsController extends Controller return ''.$tickets->status.''; }) + ->editColumn('priority', function (Ticket $tickets) { + return __($tickets->priority); + }) ->editColumn('updated_at', function (Ticket $tickets) { return $tickets->updated_at ? $tickets->updated_at->diffForHumans() : ''; }) diff --git a/database/seeders/Seeds/SettingsSeeder.php b/database/seeders/Seeds/SettingsSeeder.php index 8639252d..1b744204 100644 --- a/database/seeders/Seeds/SettingsSeeder.php +++ b/database/seeders/Seeds/SettingsSeeder.php @@ -117,6 +117,13 @@ class SettingsSeeder extends Seeder 'type' => 'integer', 'description' => 'The maximum amount of allocations to pull per node for automatic deployment, if more allocations are being used than this limit is set to, no new servers can be created!', ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', + ], [ + 'value' => '0', + 'type' => 'integer', + 'description' => 'The minimum amount of credits user has to have to create a server. Can be overridden by package limits.' + ]); //credits display name Settings::firstOrCreate([ @@ -545,16 +552,27 @@ class SettingsSeeder extends Seeder Settings::firstOrCreate([ 'key' => 'SETTINGS::SYSTEM:SHOW_IMPRINT', ], [ - 'value' => 'true', - 'type' => 'boolean', - 'description' => 'Enable/disable imprint in footer', + + 'value' => "false", + 'type' => 'boolean', + 'description' => 'Enable/disable imprint in footer' + ]); Settings::firstOrCreate([ 'key' => 'SETTINGS::SYSTEM:SHOW_PRIVACY', ], [ - 'value' => 'true', + + 'value' => "false", + 'type' => 'boolean', + 'description' => 'Enable/disable privacy policy in footer' + + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::SYSTEM:SHOW_TOS', + ], [ + 'value' => 'false', 'type' => 'boolean', - 'description' => 'Enable/disable privacy policy in footer', + 'description' => 'Enable/disable Terms of Service in footer', ]); } } diff --git a/resources/views/admin/partners/create.blade.php b/resources/views/admin/partners/create.blade.php index 8ac26d54..c2a56427 100644 --- a/resources/views/admin/partners/create.blade.php +++ b/resources/views/admin/partners/create.blade.php @@ -56,7 +56,11 @@
diff --git a/resources/views/moderator/ticket/index.blade.php b/resources/views/moderator/ticket/index.blade.php index 3ec056a4..fe908a0f 100644 --- a/resources/views/moderator/ticket/index.blade.php +++ b/resources/views/moderator/ticket/index.blade.php @@ -40,6 +40,7 @@