Promotion Backend v1
This commit is contained in:
parent
0ed47d3553
commit
f0da981737
43 changed files with 2765 additions and 45 deletions
2
.env
2
.env
|
|
@ -4,6 +4,8 @@ APP_KEY=base64:w0K6RjfleoAOpuICea14JnaZ28PNc6EMzIFMQZ3MVtU=
|
|||
APP_DEBUG=true
|
||||
APP_URL=https://partner.gruene-seele.test
|
||||
APP_DOMAIN=partner.gruene-seele.test
|
||||
APP_PROMO_URL=https://www.testemich.jetzt/
|
||||
APP_PROMO_DOMAIN=testemich.jetzt/
|
||||
|
||||
APP_CHECKOUT_MAIL=register@adametz.media
|
||||
APP_CHECKOUT_TEST_MAIL=register@adametz.media
|
||||
|
|
|
|||
189
app/Http/Controllers/AdminPromotionController.php
Executable file
189
app/Http/Controllers/AdminPromotionController.php
Executable file
|
|
@ -0,0 +1,189 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Request;
|
||||
use Validator;
|
||||
use App\Models\PromotionUser;
|
||||
use App\Models\PromotionAdmin;
|
||||
use App\Models\PromotionAdminProduct;
|
||||
use App\Repositories\AdminPromotionRepository;
|
||||
|
||||
|
||||
|
||||
class AdminPromotionController extends Controller
|
||||
{
|
||||
protected $promoRepo;
|
||||
|
||||
public function __construct(AdminPromotionRepository $promoRepo)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->promoRepo = $promoRepo;
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'values' => PromotionAdmin::all(),
|
||||
];
|
||||
return view('admin.promotion.index', $data);
|
||||
}
|
||||
|
||||
public function detail($id){
|
||||
if($id == 0 || $id === 'new'){
|
||||
$promotion = new PromotionAdmin();
|
||||
$promotion->id = 0;
|
||||
|
||||
$promotion->active = true;
|
||||
}else{
|
||||
$promotion = PromotionAdmin::findOrFail($id);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'promotion' => $promotion,
|
||||
|
||||
];
|
||||
return view('admin.promotion.detail', $data);
|
||||
}
|
||||
|
||||
|
||||
public function store($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
if(isset($data['action']) && $data['action'] === 'save-promotion_product'){
|
||||
$model = $this->promoRepo->updateProduct($id, Request::all());
|
||||
}
|
||||
|
||||
if(isset($data['action']) && $data['action'] === 'save-promotion'){
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
'type' => 'required',
|
||||
);
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return redirect(route('admin_promotion_detail', [$id]))->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
$model = $this->promoRepo->update($id, Request::all());
|
||||
}
|
||||
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('admin_promotion_detail', [$model->id]));
|
||||
}
|
||||
|
||||
public function delete($id, $del = false)
|
||||
{
|
||||
if($del === 'promotion_admin_product'){
|
||||
$PromotionAdminProduct = PromotionAdminProduct::findOrFail($id);
|
||||
$PromotionAdmin = $PromotionAdminProduct->promotion_admin;
|
||||
if($PromotionAdminProduct->canDelete()){
|
||||
\Session()->flash('alert-success', "Promotion Produkt gelöscht");
|
||||
$PromotionAdminProduct->delete();
|
||||
}else{
|
||||
\Session()->flash('alert-error', "Promotion Produkt kann nicht gelöscht werden, schon in Verwendung.");
|
||||
}
|
||||
return redirect(route('admin_promotion_detail', [$PromotionAdmin->id]));
|
||||
}
|
||||
|
||||
if($del === 'admin_promotion'){
|
||||
$PromotionAdmin = PromotionAdmin::findOrFail($id);
|
||||
if($PromotionAdmin->canDelete()){
|
||||
foreach($PromotionAdmin->promotion_admin_products as $promotion_admin_product){
|
||||
$promotion_admin_product->delete();
|
||||
}
|
||||
$PromotionAdmin->delete();
|
||||
\Session()->flash('alert-success', "Promotion gelöscht");
|
||||
}else{
|
||||
\Session()->flash('alert-error', "Promotion kann nicht gelöscht werden, schon in Verwendung.");
|
||||
}
|
||||
return redirect(route('admin_promotions'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function show($by, $id = null){
|
||||
|
||||
$data = [
|
||||
'id' => $id,
|
||||
'by' => $by,
|
||||
];
|
||||
|
||||
if($by === 'promotion'){
|
||||
$data['promotion'] = PromotionAdmin::findOrFail($id);
|
||||
}
|
||||
if($by === 'all'){
|
||||
$data['promotion'] = null;
|
||||
|
||||
}
|
||||
return view('admin.promotion.show', $data);
|
||||
}
|
||||
|
||||
public function datatable($by, $id = null){
|
||||
|
||||
$query = PromotionUser::with('promotion_user_products', 'user')->select('promotion_users.*');
|
||||
if($by === 'promotion'){
|
||||
// $query->where('promotion_admin_id', $id);
|
||||
}
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (PromotionUser $PromotionUser) {
|
||||
return $PromotionUser->id; //'<a href="" class="btn icon-btn btn-sm btn-primary">'.$PromotionUser->id.'</a>';
|
||||
})
|
||||
->addColumn('user', function (PromotionUser $PromotionUser) {
|
||||
if($PromotionUser->user){
|
||||
return $PromotionUser->user->getFullName();
|
||||
}
|
||||
return "";
|
||||
})
|
||||
->addColumn('name', function (PromotionUser $PromotionUser) {
|
||||
if(strlen($PromotionUser->name) > 30){
|
||||
return substr($PromotionUser->name, 0, 30)."...";
|
||||
}
|
||||
return $PromotionUser->name;
|
||||
})
|
||||
->addColumn('products_active', function (PromotionUser $PromotionUser) {
|
||||
return $PromotionUser->promotion_user_products_active->count();
|
||||
})
|
||||
->addColumn('count_open_items', function (PromotionUser $PromotionUser) {
|
||||
return $PromotionUser->getCountOpenItems();
|
||||
})
|
||||
->addColumn('count_sell_items', function (PromotionUser $PromotionUser) {
|
||||
return $PromotionUser->getCountSellItems();
|
||||
})
|
||||
->addColumn('user_promotion_cart_price', function (PromotionUser $PromotionUser) {
|
||||
$back = $PromotionUser->calculateCart();
|
||||
return formatNumber($back['price'])." €";
|
||||
})
|
||||
->addColumn('user_promotion_sell_price', function (PromotionUser $PromotionUser) {
|
||||
$back = $PromotionUser->calculateSell();
|
||||
return formatNumber($back['price'])." €";
|
||||
})
|
||||
->addColumn('user_credit', function (PromotionUser $PromotionUser) {
|
||||
return formatNumber($PromotionUser->user->payment_credit)." €";;
|
||||
})
|
||||
->addColumn('active', function (PromotionUser $PromotionUser) {
|
||||
return get_active_badge($PromotionUser->active);
|
||||
})
|
||||
->addColumn('pick_up', function (PromotionUser $PromotionUser) {
|
||||
return get_active_badge($PromotionUser->pick_up);
|
||||
})
|
||||
->addColumn('user_delete', function (PromotionUser $PromotionUser) {
|
||||
return get_active_badge(($PromotionUser->user_deleted_at != null));
|
||||
})
|
||||
|
||||
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('name', 'name $1')
|
||||
//->orderColumn('status', 'status $1')
|
||||
->orderColumn('active', 'active $1')
|
||||
->orderColumn('pick_up', 'pick_up $1')
|
||||
// ->orderColumn('user_delete', 'user_delete $1')
|
||||
|
||||
|
||||
->rawColumns(['id', 'status', 'active', 'pick_up', 'user_delete'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ class LeadController extends Controller
|
|||
$user->account = new UserAccount();
|
||||
}
|
||||
}
|
||||
$next_account_id = UserAccount::max('m_account') +1;
|
||||
$next_account_id = UserAccount::withTrashed()->max('m_account') +1;
|
||||
if($user->account->m_account === null){
|
||||
$user->account->m_account = $next_account_id;
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ class LeadController extends Controller
|
|||
|
||||
$data = Request::all();
|
||||
$show = Request::get('show');
|
||||
|
||||
dd($data);
|
||||
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
|
|
@ -237,7 +237,7 @@ class LeadController extends Controller
|
|||
}
|
||||
|
||||
if(!$user->account->m_account){
|
||||
$user->account->m_account = UserAccount::max('m_account') +1;
|
||||
$user->account->m_account = UserAccount::withTrashed()->max('m_account') +1;
|
||||
$user->account->save();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||
use App\Models\Homeparty;
|
||||
use App\Models\HomepartyUser;
|
||||
use App\Models\Product;
|
||||
use App\Models\PromotionAdminProduct;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserCredit;
|
||||
|
|
@ -82,17 +83,18 @@ class ModalController extends Controller
|
|||
$ret = view("admin.modal.user-credit-status", compact('value', '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'] === 'save-promotion_product'){
|
||||
if($data['id'] === 'new'){
|
||||
$value = new PromotionAdminProduct();
|
||||
$value->calcu_commission = true;
|
||||
$value->shipping = true;
|
||||
$value->active = true;
|
||||
}else{
|
||||
$value = PromotionAdminProduct::find($data['id']);
|
||||
}
|
||||
$ret = view("admin.modal.promotion-product", compact('value', 'data'))->render();
|
||||
}
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,16 +2,17 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\PaymentTransaction;
|
||||
use App\Models\Setting;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserShop;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Services\Payment;
|
||||
use Request;
|
||||
use App\Models\Setting;
|
||||
use App\Models\UserShop;
|
||||
use App\Services\Payment;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\UserPayCredit;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Models\PaymentTransaction;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
|
||||
class SalesController extends Controller
|
||||
{
|
||||
|
|
@ -307,6 +308,19 @@ class SalesController extends Controller
|
|||
$shopping_order = ShoppingOrder::findOrFail($data['id']);
|
||||
$shopping_payment = ShoppingPayment::findOrFail($data['payment_id']);
|
||||
|
||||
if($shopping_order->shopping_order_margin->from_payment_credit > 0){
|
||||
$last_UserPayCredit = UserPayCredit::where('shopping_order_id', $shopping_order->id)->whereIn('status', [2, 4])->orderBy('id', 'DESC')->first();
|
||||
//Status Keine Zahlung, Guthaben zurückführen, wenn status 2 / deduction from payment
|
||||
if($data['txaction'] === 'non' && $last_UserPayCredit->status === 2){
|
||||
Payment::handelUserPayCredits($shopping_order, 'return');
|
||||
}
|
||||
//Status Zahlung, voher gab es eine Storno, Guthaben abziehen wenn status 4 / return from order
|
||||
if($last_UserPayCredit->status === 4 && ($data['txaction'] === 'open' || $data['txaction'] === 'paid')){
|
||||
Payment::handelUserPayCredits($shopping_order, 'deduction');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$payt = PaymentTransaction::create([
|
||||
'shopping_payment_id' => $shopping_payment->id,
|
||||
'request' => 'transaction',
|
||||
|
|
@ -327,6 +341,7 @@ class SalesController extends Controller
|
|||
if($payt->status === 'vor' && $payt->txaction === 'paid'){
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
|
||||
}
|
||||
|
||||
$edata = [
|
||||
'mode' => $payt->mode,
|
||||
'txaction' => $payt->txaction,
|
||||
|
|
|
|||
|
|
@ -555,6 +555,8 @@ class CheckoutController extends Controller
|
|||
|
||||
if($shopping_payment){
|
||||
|
||||
Payment::handelUserPayCredits($shopping_order, 'deduction');
|
||||
|
||||
if($payt->status === 'vor'){
|
||||
$shopping_payment->txaction = 'open';
|
||||
$shopping_order->txaction = 'open';
|
||||
|
|
|
|||
|
|
@ -367,10 +367,10 @@ class OrderController extends Controller
|
|||
return "";
|
||||
})
|
||||
->addColumn('price_net', function (Product $product) {
|
||||
return $product->getFormattedPriceWith(true, true). "€";
|
||||
return $product->getFormattedPriceWith(true, false). "€";
|
||||
})
|
||||
->addColumn('price_gross', function (Product $product) {
|
||||
return $product->getFormattedPriceWith(false, true). "€";
|
||||
return $product->getFormattedPriceWith(false, false). "€";
|
||||
})
|
||||
->addColumn('price_vk_gross', function (Product $product) {
|
||||
return $product->getFormattedPriceWith(false, false). "€";
|
||||
|
|
|
|||
147
app/Http/Controllers/User/PromotionController.php
Normal file
147
app/Http/Controllers/User/PromotionController.php
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use Request;
|
||||
use Validator;
|
||||
use App\Models\PromotionUser;
|
||||
use App\Models\PromotionAdmin;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Response;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\PromotionAdminProduct;
|
||||
use App\Repositories\UserPromotionRepository;
|
||||
use App\Services\Util;
|
||||
|
||||
class PromotionController extends Controller
|
||||
{
|
||||
protected $promoRepo;
|
||||
|
||||
public function __construct(UserPromotionRepository $promoRepo)
|
||||
{
|
||||
$this->middleware('active.account');
|
||||
$this->promoRepo = $promoRepo;
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'values' => PromotionUser::where('user_id', Auth::user()->id)->whereNull('user_deleted_at')->get(),
|
||||
];
|
||||
return view('user.promotion.index', $data);
|
||||
}
|
||||
|
||||
public function detail($id){
|
||||
|
||||
|
||||
$user_promotion = PromotionUser::findOrFail($id);
|
||||
if($user_promotion->user_id != Auth::user()->id){
|
||||
abort(404);
|
||||
}
|
||||
$data = [
|
||||
'checkPaymentCredit' => $user_promotion->checkPaymentCredit(),
|
||||
'user_promotion_cart' => PromotionUser::preCalculateCart($user_promotion, 'user_promotion'),
|
||||
'user_promotion' => $user_promotion,
|
||||
];
|
||||
return view('user.promotion.detail', $data);
|
||||
}
|
||||
|
||||
public function store($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
|
||||
if(isset($data['action']) && $data['action'] === 'new-user-promotion'){
|
||||
$model = $this->promoRepo->create(Request::all());
|
||||
\Session()->flash('alert-save', true);
|
||||
}
|
||||
|
||||
if(isset($data['action']) && $data['action'] === 'save-user-promotion'){
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
'user_promotion_url' => ' required|alpha_dash|profanity|unique:promotion_users,url,'.\Auth::user()->id.'|min:4|max:20',
|
||||
);
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return redirect(route('user_promotion_detail', [$id]))->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
$model = $this->promoRepo->update($id, Request::all());
|
||||
|
||||
}
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('user_promotion_detail', [$model->id]));
|
||||
}
|
||||
|
||||
public function delete($id, $del = false)
|
||||
{
|
||||
|
||||
if($del === 'user_promotion'){
|
||||
$PromotionUser = PromotionUser::findOrFail($id);
|
||||
if($PromotionUser->canDelete()){
|
||||
$PromotionUser->user_deleted_at = now();
|
||||
$PromotionUser->save();
|
||||
\Session()->flash('alert-success', "Promotion gelöscht");
|
||||
}else{
|
||||
\Session()->flash('alert-error', "Promotion kann nicht gelöscht werden, schon in Verwendung.");
|
||||
}
|
||||
return redirect(route('user_promotions'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function load(){
|
||||
$data = Request::all();
|
||||
|
||||
if(Request::ajax()) {
|
||||
if(isset($data['action']) && $data['action'] === 'validate_url'){
|
||||
$rules = array(
|
||||
//'user_promotion_url' => ' required|alpha_dash|profanity|unique:user_shops,name|min:4|max:20|full_word_check',
|
||||
'user_promotion_url' => ' required|alpha_dash|profanity|unique:promotion_users,url,'.\Auth::user()->id.'|min:4|max:20',
|
||||
);
|
||||
/*Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
|
||||
if(in_array($value, config('profanity.full_word_check'))){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});*/
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
//$messages = $validator->messages();
|
||||
return Response::json(array(
|
||||
'success' => false,
|
||||
'errors' => $validator->getMessageBag()->toArray()
|
||||
|
||||
));
|
||||
}
|
||||
//$slug = SlugService::createSlug(UserShop::class, 'slug', Request::get('user_promotion_url'));
|
||||
$name = Util::sanitize(Request::get('user_promotion_url'), true, false, true, true);
|
||||
|
||||
return Response::json(array(
|
||||
'success' => true,
|
||||
'preview_user_promotion_url' => config('app.promo_url').$name,
|
||||
));
|
||||
}
|
||||
if(isset($data['action']) && $data['action'] === 'updateCart'){
|
||||
|
||||
$fill = [
|
||||
'user_promotion_cart' => ['price' => 0, 'price_net' => 0],
|
||||
];
|
||||
|
||||
if(isset($data['products'])){
|
||||
$fill['user_promotion_cart'] = PromotionUser::preCalculateCart($data['products'], 'products');
|
||||
$fill['checkPaymentCredit'] = PromotionUser::preCheckPaymentCredit($fill['user_promotion_cart']);
|
||||
|
||||
}
|
||||
/*if(isset($data['user_promotion_id']) && $user_promotion = PromotionUser::find($data['user_promotion_id'])){
|
||||
}*/
|
||||
$html_cart = view("user.promotion.cart", $fill)->render();
|
||||
return response()->json(['response' => true, 'data'=>$data, 'html_cart'=>$html_cart]);
|
||||
}
|
||||
return response()->json(['success' => false, 'data'=>$data]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -221,6 +221,10 @@ class WizardController extends Controller
|
|||
}
|
||||
$data = Request::all();
|
||||
$data['same_as_billing'] = Request::get('same_as_billing') == NULL ? 0 : 1;
|
||||
$data['birthday_day'] = isset($data['birthday_day']) ? $data['birthday_day'] : 1;
|
||||
$data['birthday_month'] = isset($data['birthday_month']) ? $data['birthday_month'] : 1;
|
||||
$data['birthday_year'] = isset($data['birthday_year']) ? $data['birthday_year'] : 1970;
|
||||
$data['birthday'] = $data['birthday_day'].".".$data['birthday_month'].".".$data['birthday_year'];
|
||||
$user->account->fill($data)->save();
|
||||
$user->wizard = 2;
|
||||
$user->save();
|
||||
|
|
|
|||
|
|
@ -117,6 +117,13 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|Product wherePartnerCommission($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereSingleCommission($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereValueCommission($value)
|
||||
* @property bool|null $shipping_addon
|
||||
* @property bool|null $max_buy
|
||||
* @property int|null $max_buy_num
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductBuy[] $product_buys
|
||||
* @property-read int|null $product_buys_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereMaxBuy($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereMaxBuyNum($value)
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
|
|
@ -340,10 +347,13 @@ class Product extends Model
|
|||
|
||||
/*price by user Factor*/
|
||||
private function calcPriceUserFactor($price){
|
||||
/*
|
||||
Nicht in benutzung, die margin errechnet sich im Warenkorb, wegen der Staffelprovision
|
||||
if(\Auth::user() && \Auth::user()->user_level){
|
||||
$margin = ((\Auth::user()->user_level->margin -100)*-1) / 100;
|
||||
$price = $price * $margin;
|
||||
}
|
||||
*/
|
||||
return $price;
|
||||
}
|
||||
/*price net*/
|
||||
|
|
|
|||
181
app/Models/PromotionAdmin.php
Normal file
181
app/Models/PromotionAdmin.php
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Services\Util;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
/**
|
||||
* Class PromotionAdmin
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string|null $description
|
||||
* @property Carbon|null $from
|
||||
* @property Carbon|null $to
|
||||
* @property float|null $max_bugdet
|
||||
* @property int|null $max_items
|
||||
* @property bool $active
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Collection|Product[] $products
|
||||
* @property Collection|PromotionUserProduct[] $promotion_user_products
|
||||
* @property Collection|PromotionUser[] $promotion_users
|
||||
* @package App\Models
|
||||
* @property-read int|null $products_count
|
||||
* @property-read int|null $promotion_user_products_count
|
||||
* @property-read int|null $promotion_users_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereFrom($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereMaxBugdet($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereMaxItems($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereTo($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class PromotionAdmin extends Model
|
||||
{
|
||||
protected $table = 'promotion_admins';
|
||||
|
||||
protected $casts = [
|
||||
'max_bugdet' => 'float',
|
||||
'max_items' => 'int',
|
||||
'active' => 'bool',
|
||||
'type' => 'int',
|
||||
'shop' => 'bool',
|
||||
|
||||
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'from',
|
||||
'to'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'type',
|
||||
'name',
|
||||
'description',
|
||||
'from',
|
||||
'to',
|
||||
'shop',
|
||||
'max_bugdet',
|
||||
'max_items',
|
||||
'active'
|
||||
];
|
||||
|
||||
public $promotionType = [
|
||||
1 => 'verschenken',
|
||||
2 => 'Nachlass (not built in!)',
|
||||
3 => 'Gewinnspiel (not built in!)',
|
||||
];
|
||||
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany(Product::class, 'promotion_admin_products')
|
||||
->withPivot('id', 'own_price', 'price', 'tax', 'price_old', 'calcu_commission', 'max_items', 'used_items', 'shipping', 'active')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
|
||||
public function promotion_admin_products()
|
||||
{
|
||||
return $this->hasMany(PromotionAdminProduct::class);
|
||||
}
|
||||
|
||||
public function promotion_admin_products_active()
|
||||
{
|
||||
return $this->hasMany(PromotionAdminProduct::class)->where('active', 1);
|
||||
}
|
||||
|
||||
public function promotion_user_products()
|
||||
{
|
||||
return $this->hasMany(PromotionUserProduct::class);
|
||||
}
|
||||
|
||||
public function promotion_users()
|
||||
{
|
||||
return $this->hasMany(PromotionUser::class);
|
||||
}
|
||||
|
||||
public function getPromotionType(){
|
||||
if(isset($this->promotionType[$this->type])){
|
||||
return $this->promotionType[$this->type];
|
||||
}
|
||||
}
|
||||
|
||||
public function getFromAttribute($value)
|
||||
{
|
||||
if(!$value){ return ""; }
|
||||
return Carbon::parse($value)->format(\Util::formatDateDB());
|
||||
}
|
||||
|
||||
public function getFromRaw(){
|
||||
return isset($this->attributes['from']) ? $this->attributes['from'] : NULL;
|
||||
}
|
||||
|
||||
public function setFromAttribute( $value ) {
|
||||
$this->attributes['from'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
|
||||
public function getToAttribute($value)
|
||||
{
|
||||
if(!$value){ return ""; }
|
||||
return Carbon::parse($value)->format(\Util::formatDateDB());
|
||||
}
|
||||
|
||||
public function getToRaw(){
|
||||
return isset($this->attributes['to']) ? $this->attributes['to'] : NULL;
|
||||
}
|
||||
|
||||
public function setToAttribute( $value ) {
|
||||
$this->attributes['to'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
|
||||
|
||||
public function setMaxBugdetAttribute( $value ) {
|
||||
|
||||
$this->attributes['max_bugdet'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function getFormattedMaxBugdet()
|
||||
{
|
||||
return isset($this->attributes['max_bugdet']) ? Util::formatNumber($this->attributes['max_bugdet']) : "";
|
||||
}
|
||||
|
||||
|
||||
public function canDelete(){
|
||||
|
||||
if($this->promotion_users->count() === 0 && $this->promotion_user_products->count() === 0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function getActiveAdminPromotionsAsArray(){
|
||||
$query = PromotionAdmin::where('active', true)
|
||||
->where(function ($query) {
|
||||
$query->where('from', '<', Carbon::now())
|
||||
->orWhereNull('from');
|
||||
})
|
||||
->where(function ($query) {
|
||||
$query->where('to', '>=', Carbon::now())
|
||||
->orWhereNull('to');
|
||||
});
|
||||
return $query->pluck('name', 'id')->toArray();
|
||||
}
|
||||
}
|
||||
194
app/Models/PromotionAdminProduct.php
Normal file
194
app/Models/PromotionAdminProduct.php
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Services\Util;
|
||||
use Auth;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
/**
|
||||
* Class PromotionAdminProduct
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $promotion_admin_id
|
||||
* @property int $product_id
|
||||
* @property bool $own_price
|
||||
* @property float|null $price
|
||||
* @property float|null $tax
|
||||
* @property float|null $price_old
|
||||
* @property bool $calcu_commission
|
||||
* @property int|null $max_items
|
||||
* @property int|null $used_items
|
||||
* @property bool $shipping
|
||||
* @property bool $active
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Product $product
|
||||
* @property PromotionAdmin $promotion_admin
|
||||
* @property Collection|PromotionUserProduct[] $promotion_user_products
|
||||
* @package App\Models
|
||||
* @property-read int|null $promotion_user_products_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct whereCalcuCommission($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct whereMaxItems($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct whereOwnPrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct wherePrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct wherePriceOld($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct wherePromotionAdminId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct whereShipping($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct whereTax($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdminProduct whereUsedItems($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class PromotionAdminProduct extends Model
|
||||
{
|
||||
protected $table = 'promotion_admin_products';
|
||||
|
||||
protected $casts = [
|
||||
'promotion_admin_id' => 'int',
|
||||
'product_id' => 'int',
|
||||
'own_price' => 'bool',
|
||||
'price' => 'float',
|
||||
'tax' => 'float',
|
||||
'price_old' => 'float',
|
||||
'calcu_commission' => 'bool',
|
||||
'max_items' => 'int',
|
||||
'used_items' => 'int',
|
||||
'shipping' => 'bool',
|
||||
'active' => 'bool'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'promotion_admin_id',
|
||||
'product_id',
|
||||
'own_price',
|
||||
'price',
|
||||
'tax',
|
||||
'price_old',
|
||||
'calcu_commission',
|
||||
'max_items',
|
||||
'used_items',
|
||||
'shipping',
|
||||
'active'
|
||||
];
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
public function promotion_admin()
|
||||
{
|
||||
return $this->belongsTo(PromotionAdmin::class);
|
||||
}
|
||||
|
||||
public function promotion_user_products()
|
||||
{
|
||||
return $this->hasMany(PromotionUserProduct::class);
|
||||
}
|
||||
|
||||
public function setPriceAttribute( $value ) {
|
||||
|
||||
$this->attributes['price'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function getFormattedPrice()
|
||||
{
|
||||
return isset($this->attributes['price']) ? Util::formatNumber($this->attributes['price']) : "";
|
||||
}
|
||||
|
||||
public function getRealPrice()
|
||||
{
|
||||
if($this->own_price && $this->price){
|
||||
return $this->price;
|
||||
}
|
||||
if($this->product && $this->product->price){
|
||||
return $this->product->price;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getFormattedRealPrice()
|
||||
{
|
||||
return Util::formatNumber($this->getRealPrice());
|
||||
}
|
||||
|
||||
/*price calcu Marign single_commission Factor*/
|
||||
private function calcPriceCommissionFactor($price){
|
||||
//einzelrabatt aus produkt
|
||||
$margin = 100;
|
||||
if(isset($this->product) && $this->product->single_commission){
|
||||
$margin = $this->product->value_commission;
|
||||
}else{
|
||||
//rabatt aus user level
|
||||
$user = Auth::user();
|
||||
if($user && $user->user_level && $user->user_level->user_level_margins){
|
||||
if($user_level_margin = $user->user_level->user_level_margins_re->first()){
|
||||
$margin = $user_level_margin->trading_margin;
|
||||
}
|
||||
}
|
||||
}
|
||||
$margin = (100 - $margin) / 100;
|
||||
$price = $price * $margin;
|
||||
return $price;
|
||||
}
|
||||
/*price net*/
|
||||
private function calcPriceNet($price){
|
||||
$tax = isset($this->product->tax) ? $this->product->tax : 0;
|
||||
$tax_rate = ($tax + 100) / 100;
|
||||
return $price / $tax_rate;
|
||||
}
|
||||
//price calu with
|
||||
public function getPriceWith(Bool $net = true){
|
||||
$price = $this->getRealPrice();
|
||||
$price = $net ? $this->calcPriceNet($price) : $price;
|
||||
$price = $this->calcu_commission ? $this->calcPriceCommissionFactor($price) : $price;
|
||||
return round($price, 2);
|
||||
}
|
||||
/*out*/
|
||||
public function getFormattedPriceWith(Bool $net = true)
|
||||
{
|
||||
return Util::formatNumber($this->getPriceWith($net));
|
||||
}
|
||||
|
||||
public function canDelete(){
|
||||
if($this->promotion_user_products->count() === 0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public function getPromotionUserProducts($user_promotion, $key = false)
|
||||
{
|
||||
$user_promotion_product = $user_promotion->hasPromotionUserProducts($this->id);
|
||||
if($user_promotion_product){
|
||||
if(!$key){
|
||||
return $user_promotion_product;
|
||||
}
|
||||
if(isset($user_promotion_product->{$key})){
|
||||
return $user_promotion_product->{$key};
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
//return $this->hasMany(PromotionUserProduct::class)->where('promotion_admin_product_id', $promotion_admin_product->id)->first();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
222
app/Models/PromotionUser.php
Normal file
222
app/Models/PromotionUser.php
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class PromotionUser
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $promotion_admin_id
|
||||
* @property string $name
|
||||
* @property string|null $description
|
||||
* @property string|null $url
|
||||
* @property bool $pick_up
|
||||
* @property float|null $used_budget_total
|
||||
* @property int|null $sell_items_total
|
||||
* @property bool $active
|
||||
* @property Carbon|null $user_deleted_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property PromotionAdmin $promotion_admin
|
||||
* @property Collection|Product[] $products
|
||||
* @package App\Models
|
||||
* @property-read int|null $products_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser wherePickUp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser wherePromotionAdminId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereSellItemsTotal($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereUrl($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereUsedBudgetTotal($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereUserDeletedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class PromotionUser extends Model
|
||||
{
|
||||
protected $table = 'promotion_users';
|
||||
|
||||
protected $casts = [
|
||||
'promotion_admin_id' => 'int',
|
||||
'user_id' => 'int',
|
||||
'pick_up' => 'bool',
|
||||
'used_budget_total' => 'float',
|
||||
'sell_items_total' => 'int',
|
||||
'active' => 'bool'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'user_deleted_at'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'promotion_admin_id',
|
||||
'user_id',
|
||||
'name',
|
||||
'description',
|
||||
'url',
|
||||
'pick_up',
|
||||
'used_budget_total',
|
||||
'sell_items_total',
|
||||
'active',
|
||||
'user_deleted_at'
|
||||
];
|
||||
|
||||
public function promotion_admin()
|
||||
{
|
||||
return $this->belongsTo(PromotionAdmin::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(\App\User::class);
|
||||
}
|
||||
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany(Product::class, 'promotion_user_products')
|
||||
->withPivot('id', 'promotion_admin_id', 'promotion_admin_product_id', 'open_items', 'sell_items', 'used_budget_total', 'active')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function promotion_user_products()
|
||||
{
|
||||
return $this->hasMany(PromotionUserProduct::class);
|
||||
}
|
||||
|
||||
public function promotion_user_products_active()
|
||||
{
|
||||
return $this->hasMany(PromotionUserProduct::class)->where('active', 1);
|
||||
}
|
||||
|
||||
|
||||
public function getUrlPreview()
|
||||
{
|
||||
return $this->url ? config('app.promo_url').$this->url : "";
|
||||
}
|
||||
|
||||
public function canDelete(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function hasPromotionUserProducts($promotion_admin_product_id)
|
||||
{
|
||||
return $this->hasMany(PromotionUserProduct::class)->where('promotion_admin_product_id', $promotion_admin_product_id)->first();
|
||||
}
|
||||
public function calculateSell(){
|
||||
$price = 0;
|
||||
$price_net = 0;
|
||||
//used_budget_total
|
||||
//von den user produkte, inkl. der nicht aktiven!
|
||||
//ToDo der Preis vom verkauf muss eingesetzt werden, wird gespeichert beim Sale
|
||||
if($this->promotion_user_products){
|
||||
foreach($this->promotion_user_products as $promotion_user_product){
|
||||
$qty = $promotion_user_product->sell_items;
|
||||
$price += $promotion_user_product->promotion_admin_product->getPriceWith(false) * intval($qty);
|
||||
$price_net += $promotion_user_product->promotion_admin_product->getPriceWith(true) * intval($qty);
|
||||
|
||||
}
|
||||
}
|
||||
return ['price' => $price, 'price_net' => $price_net];
|
||||
}
|
||||
|
||||
public function calculateCart(){
|
||||
$price = 0;
|
||||
$price_net = 0;
|
||||
if(isset($this->promotion_admin->promotion_admin_products_active)){
|
||||
foreach($this->promotion_admin->promotion_admin_products_active as $promotion_admin_product){
|
||||
if($promotion_user_product = $this->hasPromotionUserProducts($promotion_admin_product->id)){
|
||||
if($promotion_user_product->active){
|
||||
$qty = $promotion_user_product->open_items;
|
||||
$price += $promotion_admin_product->getPriceWith(false) * intval($qty);
|
||||
$price_net += $promotion_admin_product->getPriceWith(true) * intval($qty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['price' => $price, 'price_net' => $price_net];
|
||||
}
|
||||
|
||||
public function getCountOpenItems(){
|
||||
//hier die aktiven
|
||||
return $this->promotion_user_products_active->sum('open_items');
|
||||
}
|
||||
|
||||
public function getCountSellItems(){
|
||||
//hier alle zusammenziehen
|
||||
return $this->promotion_user_products->sum('sell_items');
|
||||
}
|
||||
|
||||
public function checkPaymentCredit()
|
||||
{
|
||||
if($this->promotion_user_products_active->count() > 0 && $this->getCountOpenItems() > 0){
|
||||
$payment_credit = \Auth::user()->payment_credit;
|
||||
if($payment_credit <= 0){
|
||||
return "empty";
|
||||
}
|
||||
|
||||
$prices = $this->calculateCart();
|
||||
if(isset($prices['price']) && $prices['price'] > 0){
|
||||
if($payment_credit >= $prices['price']){
|
||||
return "okay";
|
||||
}
|
||||
}
|
||||
return 'not';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static function preCheckPaymentCredit($values){
|
||||
if($values['count_items'] > 0 && $values['sum_items'] > 0){
|
||||
$payment_credit = \Auth::user()->payment_credit;
|
||||
if($payment_credit <= 0){
|
||||
return "empty";
|
||||
}
|
||||
if(isset($values['price']) && $values['price'] > 0){
|
||||
if($payment_credit >= $values['price']){
|
||||
return "okay";
|
||||
}
|
||||
}
|
||||
return 'not';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function preCalculateCart($value, $by = ''){
|
||||
$price = 0;
|
||||
$price_net = 0;
|
||||
$count_items = 0;
|
||||
$sum_items = 0;
|
||||
if($by === 'products'){
|
||||
foreach($value as $product){
|
||||
if(isset($product['product_id']) && isset($product['qty'])){
|
||||
if($promotion_admin_product = PromotionAdminProduct::find($product['product_id'])){
|
||||
$count_items ++;
|
||||
$sum_items += intval($product['qty']);
|
||||
$price += $promotion_admin_product->getPriceWith(false) * intval($product['qty']);
|
||||
$price_net += $promotion_admin_product->getPriceWith(true) * intval($product['qty']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($by === 'user_promotion'){
|
||||
return $value->calculateCart();
|
||||
}
|
||||
return ['price' => $price, 'price_net' => $price_net, 'count_items' => $count_items, 'sum_items' => $sum_items];
|
||||
|
||||
}
|
||||
}
|
||||
92
app/Models/PromotionUserProduct.php
Normal file
92
app/Models/PromotionUserProduct.php
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class PromotionUserProduct
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $promotion_admin_id
|
||||
* @property int $promotion_user_id
|
||||
* @property int $promotion_admin_product_id
|
||||
* @property int $product_id
|
||||
* @property int|null $open_items
|
||||
* @property int|null $sell_items
|
||||
* @property float|null $used_budget_total
|
||||
* @property bool $active
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Product $product
|
||||
* @property PromotionAdmin $promotion_admin
|
||||
* @property PromotionAdminProduct $promotion_admin_product
|
||||
* @property PromotionUser $promotion_user
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserProduct newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserProduct newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserProduct query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserProduct whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserProduct whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserProduct whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserProduct whereOpenItems($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserProduct whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserProduct wherePromotionAdminId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserProduct wherePromotionAdminProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserProduct wherePromotionUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserProduct whereSellItems($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserProduct whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserProduct whereUsedBudgetTotal($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class PromotionUserProduct extends Model
|
||||
{
|
||||
protected $table = 'promotion_user_products';
|
||||
|
||||
protected $casts = [
|
||||
'promotion_admin_id' => 'int',
|
||||
'promotion_user_id' => 'int',
|
||||
'promotion_admin_product_id' => 'int',
|
||||
'product_id' => 'int',
|
||||
'open_items' => 'int',
|
||||
'sell_items' => 'int',
|
||||
'used_budget_total' => 'float',
|
||||
'active' => 'bool'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'promotion_admin_id',
|
||||
'promotion_user_id',
|
||||
'promotion_admin_product_id',
|
||||
'product_id',
|
||||
'open_items',
|
||||
'sell_items',
|
||||
'used_budget_total',
|
||||
'active'
|
||||
];
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
public function promotion_admin()
|
||||
{
|
||||
return $this->belongsTo(PromotionAdmin::class);
|
||||
}
|
||||
|
||||
public function promotion_admin_product()
|
||||
{
|
||||
return $this->belongsTo(PromotionAdminProduct::class);
|
||||
}
|
||||
|
||||
public function promotion_user()
|
||||
{
|
||||
return $this->belongsTo(PromotionUser::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -47,6 +47,7 @@ class UserPayCredit extends Model
|
|||
1 => 'add from payment',
|
||||
2 => 'deduction from payment',
|
||||
3 => 'manually added credit',
|
||||
4 => 'return from order',
|
||||
|
||||
];
|
||||
protected $table = 'user_pay_credits';
|
||||
|
|
|
|||
62
app/Repositories/AdminPromotionRepository.php
Normal file
62
app/Repositories/AdminPromotionRepository.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\PromotionAdmin;
|
||||
use App\Models\PromotionAdminProduct;
|
||||
|
||||
class AdminPromotionRepository extends BaseRepository {
|
||||
|
||||
|
||||
public function __construct(PromotionAdmin $model){
|
||||
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function update($id, $data)
|
||||
{
|
||||
|
||||
$data['active'] = isset($data['active']) ? 1 : 0;
|
||||
$data['shop'] = isset($data['shop']) ? 1 : 0;
|
||||
|
||||
if($id == 0 || $id === 'new'){
|
||||
$this->model = PromotionAdmin::create($data);
|
||||
}
|
||||
else{
|
||||
$this->model = $this->getById($id);
|
||||
$this->model->fill($data);
|
||||
$this->model->save();
|
||||
}
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
public function updateProduct($id, $data){
|
||||
$this->model = $this->getById($id);
|
||||
|
||||
$data['own_price'] = isset($data['own_price']) ? 1 : 0;
|
||||
$data['calcu_commission'] = isset($data['calcu_commission']) ? 1 : 0;
|
||||
$data['shipping'] = isset($data['shipping']) ? 1 : 0;
|
||||
$data['active'] = isset($data['active']) ? 1 : 0;
|
||||
|
||||
if($data['id'] === 'new'){
|
||||
$data['promotion_admin_id'] = $this->model->id;
|
||||
$product = PromotionAdminProduct::create($data);
|
||||
}
|
||||
else{
|
||||
$product = PromotionAdminProduct::findOrFail($data['id']);
|
||||
$product->fill($data);
|
||||
$product->save();
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
public function create($data){
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
81
app/Repositories/UserPromotionRepository.php
Normal file
81
app/Repositories/UserPromotionRepository.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Services\Util;
|
||||
use App\Models\PromotionUser;
|
||||
use App\Models\PromotionAdmin;
|
||||
use App\Models\PromotionUserProduct;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\PromotionAdminProduct;
|
||||
|
||||
class UserPromotionRepository extends BaseRepository {
|
||||
|
||||
|
||||
public function __construct(PromotionUser $model){
|
||||
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function update($id, $data)
|
||||
{
|
||||
|
||||
$data['active'] = isset($data['active']) ? 1 : 0;
|
||||
$data['pick_up'] = isset($data['pick_up']) ? 1 : 0;
|
||||
$data['url'] = Util::sanitize($data['user_promotion_url'], true, false, true, true);
|
||||
|
||||
$this->model = $this->getById($id);
|
||||
$this->model->fill($data);
|
||||
$this->model->save();
|
||||
|
||||
$this->updateProducts($id, $data);
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
public function updateProducts($id, $data){
|
||||
|
||||
$this->model = $this->getById($id);
|
||||
if(isset($data['products_qty'])){
|
||||
foreach($data['products_qty'] as $pa_id => $qty){
|
||||
$PromotionAdminProduct = PromotionAdminProduct::findOrFail($pa_id);
|
||||
$PromotionUserProduct = $PromotionAdminProduct->getPromotionUserProducts($this->model);
|
||||
|
||||
if(isset($data['products_user'][$pa_id]) && $data['products_user'][$pa_id] > 0 && $PromotionUserProduct){
|
||||
$PromotionUserProduct->fill([
|
||||
'open_items' => intval($qty),
|
||||
'active' => isset($data['products_active'][$pa_id]) ? 1 : 0,
|
||||
]);
|
||||
$PromotionUserProduct->save();
|
||||
}else{
|
||||
$user_product = PromotionUserProduct::create([
|
||||
'promotion_admin_id' => $PromotionAdminProduct->promotion_admin_id,
|
||||
'promotion_user_id' => $this->model->id,
|
||||
'promotion_admin_product_id' => $PromotionAdminProduct->id,
|
||||
'product_id' => $PromotionAdminProduct->product_id,
|
||||
'open_items' => intval($qty),
|
||||
'active' => isset($data['products_active'][$pa_id]) ? 1 : 0,
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
public function create($data){
|
||||
|
||||
if(isset($data['promotion_admin_id'])){
|
||||
$PromotionAdmin = PromotionAdmin::findOrFail($data['promotion_admin_id']);
|
||||
$this->model = PromotionUser::create([
|
||||
'promotion_admin_id' => $PromotionAdmin->id,
|
||||
'user_id' => Auth::user()->id,
|
||||
]);
|
||||
return $this->model;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -197,22 +197,35 @@ class Payment
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
//if the order has action
|
||||
if($shopping_order->shopping_user->is_from === 'user_order'){
|
||||
//is margin -> set paid
|
||||
$shopping_order->shopping_order_margin->paid = true;
|
||||
$shopping_order->shopping_order_margin->save();
|
||||
}
|
||||
|
||||
}
|
||||
//if the order has action
|
||||
if($shopping_order->shopping_user->is_from === 'user_order'){
|
||||
//is margin -> set paid
|
||||
$shopping_order->shopping_order_margin->paid = true;
|
||||
$shopping_order->shopping_order_margin->save();
|
||||
//is payment credit, reduce
|
||||
return $send_link;
|
||||
}
|
||||
|
||||
//remove form credit, every sale fnc / vor / etc from CheckoutController
|
||||
//when stone, put it back SalesController
|
||||
public static function handelUserPayCredits(ShoppingOrder $shopping_order, $do){
|
||||
//is payment credit, reduce Sae
|
||||
if($do === 'deduction'){
|
||||
if($shopping_order->shopping_order_margin->from_payment_credit > 0){
|
||||
$credit = $shopping_order->shopping_order_margin->from_payment_credit * -1;
|
||||
self::addUserPayCredits($shopping_order->auth_user, $credit, 2, 'user_order_deduction', $shopping_order->id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $send_link;
|
||||
if($do === 'return'){
|
||||
if($shopping_order->shopping_order_margin->from_payment_credit > 0){
|
||||
$credit = $shopping_order->shopping_order_margin->from_payment_credit;
|
||||
self::addUserPayCredits($shopping_order->auth_user, $credit, 4, 'user_order_return', $shopping_order->id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function paymentStatusSendMail(ShoppingOrder $shopping_order, $shopping_payment, $data){
|
||||
|
|
|
|||
|
|
@ -66,6 +66,10 @@ class Util
|
|||
return number_format($value, $dec, ',', '.');
|
||||
}
|
||||
|
||||
public static function formatPlural($count, $singular, $plural){
|
||||
return ($count === 1) ? $singular : $singular.$plural;
|
||||
}
|
||||
|
||||
public static function utf8ize( $mixed ) {
|
||||
if (is_array($mixed)) {
|
||||
foreach ($mixed as $key => $value) {
|
||||
|
|
@ -218,15 +222,27 @@ class Util
|
|||
}
|
||||
return url($uri);
|
||||
}
|
||||
public static function sanitize($string, $force_lowercase = true, $anal = false, $substr = false)
|
||||
public static function sanitize($string, $force_lowercase = true, $anal = false, $substr = false, $anCon = false)
|
||||
{
|
||||
$strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]",
|
||||
$strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "=", "+", "[", "{", "]",
|
||||
"}", "\\", "|", ";", ":", "\"", "'", "‘", "’", "“", "”", "–", "—",
|
||||
"—", "–", ",", "<", ".", ">", "/", "?");
|
||||
$clean = trim(str_replace($strip, "", strip_tags($string)));
|
||||
$clean = preg_replace('/\s+/', "_", $clean);
|
||||
$clean = ($anal) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean ;
|
||||
$clean = ($anal) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean;
|
||||
|
||||
if($anCon){
|
||||
$ers = array(
|
||||
'Ä' => 'Ae',
|
||||
'Ö' => 'Oe',
|
||||
'Ü' => 'Ue',
|
||||
'ä' => 'ae',
|
||||
'ö' => 'oe',
|
||||
'ü' => 'ue',
|
||||
'ß' => 'ss'
|
||||
);
|
||||
$clean = strtr($clean,$ers);
|
||||
}
|
||||
if($substr){
|
||||
$clean = (strlen($clean) > 20) ? substr($clean,-20) : $clean;
|
||||
|
||||
|
|
|
|||
|
|
@ -75,4 +75,11 @@ if (! function_exists('reFormatNumber')) {
|
|||
}
|
||||
}
|
||||
|
||||
if (! function_exists('formatPlural')) {
|
||||
function formatPlural($count, $singular, $plural)
|
||||
{
|
||||
return Util::formatPlural($count, $singular, $plural);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,11 @@ return [
|
|||
'url' => env('APP_URL', 'https://partner.gruene-seele.bio'),
|
||||
'domain' => env('APP_DOMAIN', 'partner.gruene-seele.bio'),
|
||||
|
||||
|
||||
'promo_url' => env('APP_PROMO_URL', 'https://www.testemich.jetzt/'),
|
||||
'promo_domain' => env('APP_PROMO_DOMAIN', 'testemich.jetzt/'),
|
||||
|
||||
|
||||
'checkout_mail' => env('APP_CHECKOUT_MAIL', 'kevin.adametz@me.com'),
|
||||
'checkout_test_mail' => env('APP_CHECKOUT_TEST_MAIL', 'kevin.adametz@me.com'),
|
||||
'info_mail' => env('APP_INFO_MAIL', 'kevin.adametz@me.com'),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePromotionAdminsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('promotion_admins', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
|
||||
$table->unsignedTinyInteger('type')->default(1);
|
||||
|
||||
$table->string('name', 255);
|
||||
$table->text('description')->nullable();
|
||||
|
||||
$table->date('from')->nullable();
|
||||
$table->date('to')->nullable();
|
||||
|
||||
$table->decimal('max_bugdet', 13, 2)->nullable();
|
||||
$table->unsignedSmallInteger('max_items')->nullable();
|
||||
|
||||
$table->boolean('shop')->default(false);
|
||||
|
||||
$table->boolean('active')->default(false);
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('promotion_admins');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePromotionAdminProductsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('promotion_admin_products', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('promotion_admin_id')->index();
|
||||
$table->unsignedInteger('product_id')->index();
|
||||
|
||||
$table->boolean('own_price')->default(false);
|
||||
$table->decimal('price', 8, 2)->nullable();
|
||||
$table->decimal('tax', 5, 2)->nullable();
|
||||
$table->decimal('price_old', 8, 2)->nullable(); //streichpreis
|
||||
|
||||
$table->boolean('calcu_commission')->default(true);
|
||||
|
||||
$table->unsignedSmallInteger('max_items')->nullable();
|
||||
$table->unsignedSmallInteger('used_items')->nullable();
|
||||
|
||||
$table->boolean('shipping')->default(true);
|
||||
|
||||
$table->boolean('active')->default(false);
|
||||
|
||||
$table->foreign('promotion_admin_id')
|
||||
->references('id')
|
||||
->on('promotion_admins');
|
||||
|
||||
$table->foreign('product_id')
|
||||
->references('id')
|
||||
->on('products');
|
||||
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('promotion_admin_products');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePromotionUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('promotion_users', function (Blueprint $table) {
|
||||
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('promotion_admin_id')->index();
|
||||
$table->unsignedInteger('user_id');
|
||||
|
||||
$table->string('name', 255);
|
||||
$table->text('description')->nullable();
|
||||
$table->string('url', 255)->nullable();
|
||||
|
||||
$table->boolean('pick_up')->default(true);
|
||||
|
||||
$table->decimal('used_budget_total', 13, 2)->nullable();
|
||||
$table->unsignedSmallInteger('sell_items_total')->nullable();
|
||||
|
||||
$table->boolean('active')->default(false);
|
||||
|
||||
$table->timestamp('user_deleted_at')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('promotion_admin_id')
|
||||
->references('id')
|
||||
->on('promotion_admins');
|
||||
|
||||
$table->foreign('user_id')
|
||||
->references('id')
|
||||
->on('users');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('promotion_users');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePromotionUserProductsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('promotion_user_products', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
|
||||
$table->unsignedInteger('promotion_admin_id')->index();
|
||||
$table->unsignedInteger('promotion_user_id')->index();
|
||||
|
||||
$table->unsignedInteger('promotion_admin_product_id')->index();
|
||||
$table->unsignedInteger('product_id')->index();
|
||||
|
||||
$table->unsignedSmallInteger('open_items')->nullable();
|
||||
$table->unsignedSmallInteger('sell_items')->nullable();
|
||||
|
||||
$table->decimal('used_budget_total', 13, 2)->nullable();
|
||||
|
||||
$table->boolean('active')->default(false);
|
||||
|
||||
$table->foreign('promotion_admin_id')
|
||||
->references('id')
|
||||
->on('promotion_admins');
|
||||
|
||||
$table->foreign('promotion_user_id')
|
||||
->references('id')
|
||||
->on('promotion_users');
|
||||
|
||||
$table->foreign('promotion_admin_product_id')
|
||||
->references('id')
|
||||
->on('promotion_admin_products');
|
||||
|
||||
$table->foreign('product_id')
|
||||
->references('id')
|
||||
->on('products');
|
||||
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('promotion_user_products');
|
||||
}
|
||||
}
|
||||
|
|
@ -81,4 +81,8 @@ a[aria-expanded='true'] > .fa-caret-expand:before {
|
|||
|
||||
.spinner {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.table-striped tbody tr:nth-of-type(odd) {
|
||||
background-color: rgba(38, 64, 95, 0.04);
|
||||
}
|
||||
120
public/js/iq-promotion-cart.js
Normal file
120
public/js/iq-promotion-cart.js
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
|
||||
var IqPromotionCart = {
|
||||
table: "#datatables-promotion-list",
|
||||
btn_add: '.add-product-promotion',
|
||||
btn_remove: '.remove-product-promotion',
|
||||
input_event: '.input-event-promotion-onchange',
|
||||
check_event: '.check-event-promotion-onchange',
|
||||
url: null,
|
||||
action: null,
|
||||
cart_holder: '#holder_html_view_cart',
|
||||
|
||||
init: function () {
|
||||
var _self = this;
|
||||
_self.url = $(_self.table).data('url');
|
||||
_self.action = $(_self.table).data('action');
|
||||
_self.initElements();
|
||||
return _self;
|
||||
},
|
||||
initElements: function (){
|
||||
var _self = this;
|
||||
$(_self.table).find(_self.btn_add).on('click', function(){
|
||||
_self.add_product($(this))
|
||||
});
|
||||
$(_self.table).find(_self.btn_remove).on('click', function(){
|
||||
_self.remove_product($(this))
|
||||
});
|
||||
$(_self.table).find(_self.input_event).off('change').on('change', function(){
|
||||
_self.update_input_table($(this));
|
||||
});
|
||||
$(_self.table).find(_self.check_event).off('change').on('change', function(){
|
||||
_self.update_input_table($(this));
|
||||
});
|
||||
},
|
||||
|
||||
add_product: function (_obj){
|
||||
var _self = this;
|
||||
var input = $(_self.table).find('input#product_qty_'+_obj.data('product-id'));
|
||||
var qty = parseInt(input.val()) + 1;
|
||||
qty = _self.checkNumber(qty);
|
||||
input.val(qty);
|
||||
_self.update_cart();
|
||||
},
|
||||
remove_product: function (_obj){
|
||||
var _self = this;
|
||||
var input = $(_self.table).find('input#product_qty_'+_obj.data('product-id'));
|
||||
var qty = parseInt(input.val()) - 1;
|
||||
if(qty < 0){
|
||||
qty = 0;
|
||||
}
|
||||
input.val(qty);
|
||||
_self.update_cart();
|
||||
},
|
||||
update_input_table: function (_obj){
|
||||
var _self = this;
|
||||
var qty = parseInt(_obj.val());
|
||||
qty = _self.checkNumber(qty);
|
||||
_obj.val(qty);
|
||||
_self.update_cart();
|
||||
},
|
||||
checkNumber : function(number){
|
||||
if(number < 0 || isNaN(number)){
|
||||
return 0;
|
||||
}
|
||||
if(number >= 100){
|
||||
return 100;
|
||||
}
|
||||
return number;
|
||||
},
|
||||
update_cart: function (){
|
||||
var _self = this;
|
||||
var data = {};
|
||||
var tempData = [];
|
||||
$(_self.table).find(_self.input_event).each(function(){
|
||||
//push, is checked
|
||||
if($(_self.table).find('#product_check_'+$(this).data('product-id')).is(':checked')){
|
||||
tempData.push({product_id: $(this).data('product-id'), qty: $(this).val()});
|
||||
}
|
||||
});
|
||||
data.action = $(_self.table).data('action');
|
||||
data.user_promotion_id = $(_self.table).data('user_promotion_id');
|
||||
data.products = tempData;
|
||||
_self.performRequest(data)
|
||||
.done(_self.refreshItemsAndView);
|
||||
},
|
||||
|
||||
refreshItemsAndView: function (data){
|
||||
var _self = IqPromotionCart;
|
||||
//console.log(data.html_cart);
|
||||
$(_self.cart_holder).html(data.html_cart);
|
||||
},
|
||||
performRequest : function(data) {
|
||||
var _self = this;
|
||||
var url = _self.url,
|
||||
contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
|
||||
// console.log(data);
|
||||
// console.log(url);
|
||||
return $.ajax({
|
||||
url: url,
|
||||
data: data,
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
contentType: contentType,
|
||||
encode: true,
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
})
|
||||
.done(function (data) {
|
||||
// console.log('performRequest');
|
||||
// console.log(data);
|
||||
}).fail(function (jqXHR, textStatus, errorThrown) {
|
||||
console.log(jqXHR);
|
||||
console.log(jqXHR.responseText);
|
||||
console.log(textStatus);
|
||||
console.log(errorThrown);
|
||||
console.log("Sorry, there was a problem!");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -45,5 +45,8 @@ return [
|
|||
'invoice' => 'Rechnungen',
|
||||
'revenue' => 'Umsätze',
|
||||
'paycredit' => 'Einkaufsguthaben',
|
||||
'commissions' => 'Provisionen'
|
||||
'commissions' => 'Provisionen',
|
||||
'promotion' => 'Promotion',
|
||||
'my_promotions' => 'Meine Promotions'
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -22,4 +22,5 @@ return [
|
|||
],
|
||||
'payment_for_account' => 'Aufladung durch Mitgliedschaft',
|
||||
'user_order_deduction' => 'Abzug durch Bestellung',
|
||||
'user_order_return' => 'Rückführung durch Storno',
|
||||
];
|
||||
|
|
@ -212,6 +212,7 @@ return [
|
|||
'sales_partnership' => 'Vertriebspartnerschaft',
|
||||
'sales_partnership_message' => 'Vertriebspartnerschaft Hinweis',
|
||||
'tax_number' => 'Steuernummer',
|
||||
'tax_identification_number' => 'USt-ID Nummer'
|
||||
'tax_identification_number' => 'USt-ID Nummer',
|
||||
'user_promotion_url' => "Promotion Domain"
|
||||
],
|
||||
];
|
||||
|
|
|
|||
72
resources/views/admin/modal/promotion-product.blade.php
Normal file
72
resources/views/admin/modal/promotion-product.blade.php
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
{!! Form::open(['url' => route('admin_promotion_detail', [$data['promotion_id']]), 'class' => 'modal-content form-prevent-multiple-submits', 'enctype' => 'multipart/form-data']) !!}
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">
|
||||
{{ __('Produkt') }} <span class="font-weight-light">hinzufügen / bearbeiten</span>
|
||||
<span class="font-weight-light">hinzufügen</span>
|
||||
</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="action" value="{{$data['action']}}">
|
||||
<input type="hidden" name="id" value="{{$data['id']}}">
|
||||
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="country_ids" class="form-label">{{__('Produkt')}}</label>
|
||||
<select class="selectpicker" name="product_id" id="product_id" data-style="btn-light" data-live-search="true" required>
|
||||
{!! HTMLHelper::getProductsOptions([$value->product_id], true) !!}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-sm-6">
|
||||
<label class="custom-control custom-checkbox mt-2">
|
||||
{!! Form::checkbox('shipping', 1, $value->shipping, ['class'=>'custom-control-input']) !!}
|
||||
<span class="custom-control-label">Versandkosten für dieses Produkt berechnen</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label class="custom-control custom-checkbox mt-2">
|
||||
{!! Form::checkbox('active', 1, $value->active, ['class'=>'custom-control-input']) !!}
|
||||
<span class="custom-control-label">Produkt aktiv</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label class="custom-control custom-checkbox mt-2">
|
||||
{!! Form::checkbox('calcu_commission', 1, $value->calcu_commission, ['class'=>'custom-control-input']) !!}
|
||||
<span class="custom-control-label">Provision der User-Rolle vom Preis abziehen</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-sm-12">
|
||||
<hr class="mt-0">
|
||||
<label class="custom-control custom-checkbox mt-2">
|
||||
{!! Form::checkbox('own_price', 1, $value->own_price, ['class'=>'custom-control-input']) !!}
|
||||
<span class="custom-control-label">Neuer Preis (sonst wird der eingestellte Produktpreis genommen)</span>
|
||||
</label>
|
||||
{{ Form::text('price', $value->getFormattedPrice(), array('placeholder'=>__('Neuer Preis in Euro / Brutto'), 'class'=>'form-control', 'id'=>'price')) }}
|
||||
</div>
|
||||
|
||||
<div class="form-group col-sm-12">
|
||||
<hr class="mt-0">
|
||||
|
||||
<label class="form-label" for="max_items">{{ __('Max. Produkte für diese Promotion') }}</label>
|
||||
{{ Form::text('max_items', $value->max_items, array('placeholder'=>__('Einheiten in Stück'), 'class'=>'form-control', 'id'=>'max_items')) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">schließen</button>
|
||||
<button type="submit" class="btn btn-primary button-prevent-multiple-submits">{{__('save')}}</button>
|
||||
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
|
||||
<script type="text/javascript">
|
||||
$( document ).ready(function() {
|
||||
|
||||
});
|
||||
</script>
|
||||
45
resources/views/admin/modal/promotion-products.blade.php
Normal file
45
resources/views/admin/modal/promotion-products.blade.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{!! Form::open(['url' => route('admin_payments_credit'), 'class' => 'modal-content form-prevent-multiple-submits', 'enctype' => 'multipart/form-data']) !!}
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">
|
||||
{{ __('Gutschrift') }}
|
||||
<span class="font-weight-light">hinzufügen</span>
|
||||
</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="action" value="{{$data['action']}}">
|
||||
<input type="hidden" name="id" value="{{$data['id']}}">
|
||||
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-12">
|
||||
<label for="member_id" class="form-label">{{ __('Vertriebspartner auswählen') }}*</label>
|
||||
<select class="selectpicker" name="member_id" data-style="btn-light" data-live-search="true" required>
|
||||
{!! HTMLHelper::getMembersOptions(0, true) !!}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-12">
|
||||
<label class="form-label" for="credit">{{ __('Betrag') }} netto*</label>
|
||||
{{ Form::text('credit', '', array('placeholder'=>__('in Euro'), 'class'=>'form-control', 'required'=>true)) }}
|
||||
</div>
|
||||
|
||||
<div class="form-group col-12">
|
||||
<label class="form-label" for="message">{{ __('Mitteilung') }}*</label>
|
||||
{{ Form::textarea('message', '' , array('placeholder'=>__('Mitteilung'), 'class'=>'form-control', 'rows'=>4, 'required'=>true)) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">schließen</button>
|
||||
<button type="submit" class="btn btn-primary button-prevent-multiple-submits">{{__('Gutschrift hinzufügen')}}</button>
|
||||
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
|
||||
<script type="text/javascript">
|
||||
$( document ).ready(function() {
|
||||
|
||||
});
|
||||
</script>
|
||||
46
resources/views/admin/promotion/detail.blade.php
Normal file
46
resources/views/admin/promotion/detail.blade.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
@extends('layouts.layout-2')
|
||||
|
||||
@section('content')
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<h4 class="font-weight-bold py-2 mb-2">
|
||||
{{ __('Create/Edit Promotion') }}
|
||||
</h4>
|
||||
|
||||
{!! Form::open(['url' => route('admin_promotion_detail', $promotion->id), 'class' => 'form-horizontal']) !!}
|
||||
<input type="hidden" name="id" id="id" value="@if($promotion->id>0){{$promotion->id}}@else new @endif">
|
||||
|
||||
<div class="text-left mt-0 mb-2">
|
||||
<button type="submit" class="btn btn-submit" name="action" value="save-promotion">{{ __('save') }}</button>
|
||||
<a href="{{ route('admin_promotions') }}" class="btn btn-default">{{ __('back') }}</a>
|
||||
</div>
|
||||
|
||||
@include('admin.promotion.form')
|
||||
|
||||
<div class="text-left mt-0 mb-2">
|
||||
<button type="submit" class="btn btn-submit" name="action" value="save-promotion">{{ __('save') }}</button>
|
||||
<a href="{{ route('admin_promotions') }}" class="btn btn-default">{{ __('back') }}</a>
|
||||
</div>
|
||||
|
||||
{!! Form::close() !!}
|
||||
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
150
resources/views/admin/promotion/form.blade.php
Normal file
150
resources/views/admin/promotion/form.blade.php
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
|
||||
<div class="card mb-2">
|
||||
|
||||
<h5 class="card-header">
|
||||
{{ __('Promotion') }}
|
||||
</h5>
|
||||
<div class="card-body">
|
||||
|
||||
<div class="form-group ">
|
||||
<label class="custom-control custom-checkbox float-right">
|
||||
{!! Form::checkbox('active', 1, $promotion->active, ['class'=>'custom-control-input']) !!}
|
||||
<span class="custom-control-label">{{__('aktiv')}}</span>
|
||||
</label>
|
||||
<label class="form-label" for="name">{{ __('Promotionname / Titel') }}*</label>
|
||||
{{ Form::text('name', $promotion->name, array('placeholder'=>__('Name'), 'class'=>'form-control', 'id'=>'name', 'required')) }}
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-sm-6">
|
||||
<label class="form-label" for="type">{{ __('Promotiontyp') }}*</label>
|
||||
{{ Form::select('type', $promotion->promotionType, $promotion->type, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'type') ) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-sm-6">
|
||||
<label class="form-label" for="">Zusätzliches einkaufen</label>
|
||||
<label class="custom-control custom-checkbox mt-2">
|
||||
{!! Form::checkbox('shop', 1, $promotion->shop, ['class'=>'custom-control-input']) !!}
|
||||
<span class="custom-control-label">Shop bei Promotion anzeigen</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-12">
|
||||
<label class="form-label" for="description">{{ __('Promotioninfo') }}</label>
|
||||
{{ Form::textarea('description', $promotion->description , array('placeholder'=>__('Interne Notiz'), 'class'=>'form-control', 'rows'=>2, 'id'=>'description')) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-sm-3">
|
||||
<label class="form-label" for="max_bugdet">{{ __('Max. gesamtes Budget für diese Promotion') }}</label>
|
||||
{{ Form::text('max_bugdet', $promotion->getFormattedMaxBugdet(), array('placeholder'=>__('Budget in Euro / Brutto'), 'class'=>'form-control', 'id'=>'max_bugdet')) }}
|
||||
</div>
|
||||
|
||||
<div class="form-group col-sm-3">
|
||||
<label class="form-label" for="max_items">{{ __('Max. gesamte Produkte für diese Promotion') }}</label>
|
||||
{{ Form::text('max_items', $promotion->max_items, array('placeholder'=>__('Einheiten in Stück'), 'class'=>'form-control', 'id'=>'max_items')) }}
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label class="form-label"> </label><br>
|
||||
<i>Ist das Budget oder Einheiten erreicht, wird auf der Microseite keine Promotion mehr angezeigt.</i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-sm-3">
|
||||
<label class="form-label" for="from">{{ __('Promotion Datum ab') }}</label>
|
||||
{!! Form::text('from', $promotion->from, ['class'=>'form-control datepicker-base']) !!}
|
||||
</div>
|
||||
|
||||
<div class="form-group col-sm-3">
|
||||
<label class="form-label" for="to">{{ __('Promotion Datum bis') }}</label>
|
||||
{!! Form::text('to', $promotion->to, ['class'=>'form-control datepicker-base']) !!}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group col-sm-6">
|
||||
<label class="form-label"> </label><br>
|
||||
<i>Ist das ab oder bis Datum gesetzt wird die Promotion nur innerhalb dieses Zeitraumns angezeigt.</i>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card mb-2">
|
||||
<h5 class="card-header">
|
||||
{{ __('Produkte') }}
|
||||
</h5>
|
||||
@if($promotion->id > 0)
|
||||
|
||||
<div class="mt-3 ml-3">
|
||||
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="new"
|
||||
data-promotion_id="{{ $promotion->id }}"
|
||||
data-action="save-promotion_product"
|
||||
data-back="{{url()->current()}}"
|
||||
data-route="{{ route('modal_load') }}"><span class="far fa-plus-circle"></span> Produkt hinzufügen
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<div class="card-body px-0">
|
||||
<div class="card-datatable table-responsive pt-0">
|
||||
<table class="datatables-style table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="max-width: 60px;"> </th>
|
||||
<th>{{__('Bild')}}</th>
|
||||
|
||||
<th>{{__('Produkt')}}</th>
|
||||
<th>{{__('Versandkosten') }}</th>
|
||||
<th>{{__('Provision') }}</th>
|
||||
<th>{{__('Neuer Preis')}}</th>
|
||||
<th>{{__('Preis B.') }}</th>
|
||||
<th>{{__('max. P.') }}</th>
|
||||
<th>{{__('verkauft P.') }}</th>
|
||||
<th>{{__('active') }}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($promotion->promotion_admin_products as $promotion_admin_products)
|
||||
<tr>
|
||||
<td>
|
||||
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="{{ $promotion_admin_products->id }}"
|
||||
data-promotion_id="{{ $promotion->id }}"
|
||||
data-action="save-promotion_product"
|
||||
data-back="{{url()->current()}}"
|
||||
data-route="{{ route('modal_load') }}"><span class="fa fa-edit"></span></button>
|
||||
</td>
|
||||
<td>
|
||||
@if(count($promotion_admin_products->product->images))
|
||||
<img class="img-fluid" alt="" style="max-height: 80px" src="{{ route('product_image', [$promotion_admin_products->product->images->first()->slug]) }}">
|
||||
@endif
|
||||
</td>
|
||||
<td><a href="{{ route('admin_product_edit', [$promotion_admin_products->product->id]) }}">{{ $promotion_admin_products->product->name }}</a></td>
|
||||
<td>{!! get_active_badge($promotion_admin_products->calcu_commission) !!}</td>
|
||||
<td>{!! get_active_badge($promotion_admin_products->shipping) !!}</td>
|
||||
<td>{!! get_active_badge($promotion_admin_products->own_price) !!}</td>
|
||||
<td>{{ $promotion_admin_products->getFormattedRealPrice() }} €</td>
|
||||
<td>{{ $promotion_admin_products->max_items }}</td>
|
||||
<td>{{ $promotion_admin_products->used_items }}</td>
|
||||
<td>{!! get_active_badge($promotion_admin_products->active) !!}</td>
|
||||
<td><a class="text-danger" href="{{ route('admin_promotion_delete', [$promotion_admin_products->id, 'promotion_admin_product']) }}" onclick="return confirm('{{__('Produkt entfernen?')}}');"><i class="far fa-trash-alt"></i></a></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
90
resources/views/admin/promotion/index.blade.php
Normal file
90
resources/views/admin/promotion/index.blade.php
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
@extends('layouts.layout-2')
|
||||
|
||||
@section('content')
|
||||
<h4 class="font-weight-bold py-2 mb-2 d-flex justify-content-between align-items-center w-100 ">
|
||||
<div>{{ __('navigation.promotion') }} / {{ __('navigation.overview') }}</div>
|
||||
<a href="{{route('admin_promotion_detail', ['new'])}}" class="btn btn-secondary rounded-pill d-block float-right"><span class="ion ion-md-add"></span> Neue Promotion anlegen</a>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
@foreach($values as $value)
|
||||
<div class="card mb-4">
|
||||
<div class="card-body d-flex justify-content-between align-items-start pb-2">
|
||||
<div>
|
||||
<a href="{{route('admin_promotion_detail', [$value->id])}}" class="text-body text-big font-weight-semibold">{{$value->name}}</a>
|
||||
</div>
|
||||
@if($value->canDelete())
|
||||
<div class="btn-group project-actions">
|
||||
<a href="{{ route('admin_promotion_delete', [$value->id, 'admin_promotion']) }}"
|
||||
class=" dropdown-item" onclick="return confirm('Promotion wirklich löschen?');">
|
||||
<span class="ion ion-md-trash text-danger"></span>
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<div class="progress rounded-0" style="height: 2px;">
|
||||
<div class="progress-bar" style="width: 100%;"></div>
|
||||
</div>
|
||||
<div class="card-body pt-3 pb-1">
|
||||
{{$value->description}}
|
||||
<hr>
|
||||
</div>
|
||||
<div class="card-body pt-0">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="text-muted small">Typ</div>
|
||||
<div class="font-weight-bold">{{$value->getPromotionType()}}</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="text-muted small">Produkte</div>
|
||||
<div class="font-weight-bold">{{$value->promotion_admin_products->count()}}</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="text-muted small">max Budget</div>
|
||||
<div class="font-weight-bold">{{ $value->getFormattedMaxBugdet() }}</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="text-muted small">max Produkte</div>
|
||||
<div class="font-weight-bold">{{$value->max_items}}</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="text-muted small">Datum von</div>
|
||||
<div class="font-weight-bold">{{ $value->from }}</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="text-muted small">Datum bis</div>
|
||||
<div class="font-weight-bold">{{ $value->to }}</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="text-muted small">Aktiv</div>
|
||||
<div class="font-weight-bold">{!! get_active_badge($value->active) !!}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="m-0">
|
||||
<div class="card-body py-3">
|
||||
<div class="d-flex flex-wrap">
|
||||
<a href="{{route('admin_promotion_detail', [$value->id])}}" class="btn btn-secondary mr-2 mb-2"><i class="ion ion-ios-cog"></i> Bearbeiten</a>
|
||||
<a href="{{route('admin_promotion_show', ['promotion', $value->id])}}" class="btn btn-secondary mr-2 mb-2"><i class="ion ion-md-rocket"></i> User Promotions ansehen</a>
|
||||
{{--
|
||||
<a href="#" class="btn btn-secondary mr-2 mb-2"><i class="ion ion-md-basket"></i> Bestellung ansehen (n.b!)</a>
|
||||
--}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<hr class="mt-0">
|
||||
<a href="{{route('admin_promotion_show', ['all'])}}" class="btn btn-secondary mr-2 mb-2"><i class="ion ion-md-rocket"></i> Alle User Promotions ansehen</a>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
76
resources/views/admin/promotion/show.blade.php
Normal file
76
resources/views/admin/promotion/show.blade.php
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
@extends('layouts.layout-2')
|
||||
|
||||
@section('content')
|
||||
|
||||
<h4 class="font-weight-bold py-2 mb-2">
|
||||
{{ __('navigation.promotion') }} /
|
||||
@if($by === 'promotion')
|
||||
{{ $promotion->name }} User Promotions
|
||||
@endif
|
||||
@if($by === 'all')
|
||||
Alle User Promotions
|
||||
@endif
|
||||
</h4>
|
||||
|
||||
<div class="text-left mt-0 mb-2">
|
||||
<a href="{{ route('admin_promotions') }}" class="btn btn-default">{{ __('back') }}</a>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-datatable table-responsive">
|
||||
<table class="datatable-users table table-striped table-bordered">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>{{__('User')}}</th>
|
||||
<th>{{__('Name')}}</th>
|
||||
<th>{{__('aktive Produkte')}}</th>
|
||||
<th>{{__('geplant Produkte')}}</th>
|
||||
<th>{{__('geordert Produkte')}}</th>
|
||||
<th>{{__('Potentielle Kosten')}}</th>
|
||||
<th>{{__('User Guthaben')}}</th>
|
||||
<th>{{__('Kosten bisher')}}</th>
|
||||
<th>{{__('aktiv')}}</th>
|
||||
<th>{{__('Abholung')}}</th>
|
||||
<th>{{__('Gelöscht')}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
$('.datatable-users').dataTable({
|
||||
"processing": true,
|
||||
"serverSide": true,
|
||||
"ajax": '{!! route('admin_promotion_datatable', [$by, $id]) !!}',
|
||||
"order": [[0, "desc" ]],
|
||||
"columns": [
|
||||
{data: 'id', name: 'id'},
|
||||
{ data: 'user', name: 'user', orderable: false, searchable: false },
|
||||
{ data: 'name', name: 'name' },
|
||||
{ data: 'products_active', name: 'products_active', orderable: false, searchable: false },
|
||||
{ data: 'count_open_items', name: 'count_open_items', orderable: false, searchable: false },
|
||||
{ data: 'count_sell_items', name: 'count_sell_items', orderable: false, searchable: false },
|
||||
{ data: 'user_promotion_cart_price', name: 'user_promotion_cart_price', orderable: false, searchable: false },
|
||||
{ data: 'user_credit', name: 'user_credit', orderable: false, searchable: false },
|
||||
{ data: 'user_promotion_sell_price', name: 'user_promotion_sell_price', orderable: false, searchable: false },
|
||||
{ data: 'active', name: 'active', searchable: false },
|
||||
{ data: 'pick_up', name: 'pick_up', searchable: false },
|
||||
{ data: 'user_delete', name: 'user_delete', orderable: false, searchable: false },
|
||||
],
|
||||
"bLengthChange": false,
|
||||
"iDisplayLength": 50,
|
||||
"language": {
|
||||
"url": "/js/German.json"
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
|
@ -39,7 +39,6 @@
|
|||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
@if(Auth::user()->isActiveAccount())
|
||||
<li class="sidenav-item @if(Request::is('user/team/*')) open @endif">
|
||||
<a href="javascript:void(0)" class="sidenav-link sidenav-toggle">
|
||||
|
|
@ -85,6 +84,23 @@
|
|||
</ul>
|
||||
</li>
|
||||
@endif
|
||||
{{-- TODO Remove isAdmin --}}
|
||||
@if(Auth::user()->isActiveAccount() && Auth::user()->isAdmin())
|
||||
<li class="sidenav-item @if(Request::is('user/promotions', '/user/promotion/*')) open @endif">
|
||||
<a href="javascript:void(0)" class="sidenav-link sidenav-toggle">
|
||||
<i class="sidenav-icon ion ion-md-rocket"></i>
|
||||
<div>{{ __('navigation.my_promotions') }}</div>
|
||||
<div class="pl-1 ml-auto">
|
||||
<div class="badge badge-secondary">Admin</div>
|
||||
</div>
|
||||
</a>
|
||||
<ul class="sidenav-menu">
|
||||
<li class="sidenav-item{{ Request::is('user/promotions') ? ' active' : '' }}">
|
||||
<a href="{{ route('user_promotions') }}" class="sidenav-link"><i class="sidenav-icon ion-md-rocket"></i><div>{{ __('navigation.overview') }}</div></a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
@if(Auth::user()->isAdmin())
|
||||
|
|
@ -153,6 +169,19 @@
|
|||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="sidenav-item @if(Request::is('admin/promotions', '/admin/promotion/*')) open @endif">
|
||||
<a href="javascript:void(0)" class="sidenav-link sidenav-toggle">
|
||||
<i class="sidenav-icon ion ion-ios-rocket"></i>
|
||||
<div>{{ __('navigation.promotion') }}</div>
|
||||
</a>
|
||||
<ul class="sidenav-menu">
|
||||
<li class="sidenav-item{{ Request::is('admin/promotions') ? ' active' : '' }}">
|
||||
<a href="{{ route('admin_promotions') }}" class="sidenav-link"><i class="sidenav-icon ion-ios-rocket"></i><div>{{ __('navigation.overview') }}</div></a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
{{--
|
||||
<li class="sidenav-item @if(Request::is('admin/sites/*')) open @endif">
|
||||
<a href="javascript:void(0)" class="sidenav-link sidenav-toggle">
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
@if($user->isRenewalAccount())
|
||||
<div class="card w-100 mb-4">
|
||||
<h5 class="card-header">Deine Mitglidschaft wurde am {{ $user->nextRenewalAccount() }} verlängert.</h5>
|
||||
<h5 class="card-header">Deine Mitgliedschaft wurde am {{ $user->nextRenewalAccount() }} verlängert.</h5>
|
||||
<div class="card-body">
|
||||
@if($userHistoryPaymentOrder && $userHistoryPaymentOrder->status > 2)
|
||||
<h6 class="alert badge-{{$userHistoryPaymentOrder->getStatusColor()}}">Eine Zahlung wurde ausgeführt. Status: {{ trans('payment.status.'.$userHistoryPaymentOrder->getStatusType())}}</h6>
|
||||
|
|
@ -102,7 +102,7 @@
|
|||
<div class="card w-100 mb-4">
|
||||
<h5 class="card-header">{{__('Mitgliedschaft')}} {{__('anpassen')}}</h5>
|
||||
<div class="card-body">
|
||||
<h6 class="d-block text-dark">Du kannst Deine Mitglidschaft bis zur nächsten Vertragsverlängerung, am {{ $user->nextRenewalAccount() }}, ändern.</h6>
|
||||
<h6 class="d-block text-dark">Du kannst Deine Mitgliedschaft bis zur nächsten Vertragsverlängerung, am {{ $user->nextRenewalAccount() }}, ändern.</h6>
|
||||
<p>Die restlichen Laufzeiten bleiben erhalten, erst mit der Verlängerung wird das geänderte Paket aktiv.</p>
|
||||
@include('user.membership._change')
|
||||
</div>
|
||||
|
|
@ -117,7 +117,7 @@
|
|||
<div class="card w-100 mb-4">
|
||||
<h5 class="card-header">{{__('Mitgliedschaft')}} {{__('anpassen')}}</h5>
|
||||
<div class="card-body">
|
||||
<h6 class="d-block text-dark">Du kannst Deine Mitglidschaftsrolle bis zur nächsten Vertragsverlängerung ({{ $user->nextRenewalAccount() }}), ändern.
|
||||
<h6 class="d-block text-dark">Du kannst Deine Mitgliedschaftsrolle bis zur nächsten Vertragsverlängerung ({{ $user->nextRenewalAccount() }}), ändern.
|
||||
<br> <span class="small">Erst nach der Verlängerug ist die neue Rolle aktiv.</span>
|
||||
</h6>
|
||||
@include('user.membership._change_level')
|
||||
|
|
|
|||
17
resources/views/user/promotion/cart.blade.php
Normal file
17
resources/views/user/promotion/cart.blade.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<h5>
|
||||
Potentielle Kosten für diese Promotion:
|
||||
{{ formatNumber($user_promotion_cart['price_net']) }} € netto / {{ formatNumber($user_promotion_cart['price']) }} € inkl. MwSt.
|
||||
</h5>
|
||||
<p>Text ...</p>
|
||||
|
||||
@if(isset($checkPaymentCredit))
|
||||
@if($checkPaymentCredit === 'empty')
|
||||
<h6 class="alert badge-danger mt-3 py-2">Du hast kein Guthaben aus Deinem Konto auf, lade Dein Konto auf, bis dahin ist die Promotion gestoppt.</h6>
|
||||
@endif
|
||||
@if($checkPaymentCredit === 'okay')
|
||||
<h6 class="alert badge-success mt-3 py-2">Dein Guthaben ist für diese Promotion</h6>
|
||||
@endif
|
||||
@if($checkPaymentCredit === 'not')
|
||||
<h6 class="alert badge-danger mt-3 py-2">Dein Guthaben ist nicht ausreichend für diese Promotion, lade Dein Konto auf, bis dahin ist die Promotion gestoppt.</h6>
|
||||
@endif
|
||||
@endif
|
||||
47
resources/views/user/promotion/detail.blade.php
Normal file
47
resources/views/user/promotion/detail.blade.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
@extends('layouts.layout-2')
|
||||
|
||||
@section('content')
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<h4 class="font-weight-bold py-2 mb-2">
|
||||
<div>{{ __('navigation.my_promotions') }} / {{ __('bearbeiten') }}</div>
|
||||
</h4>
|
||||
|
||||
{!! Form::open(['url' => route('user_promotion_detail', $user_promotion->id), 'class' => 'form-horizontal', 'id'=>"user-promotion-form-validations"]) !!}
|
||||
|
||||
<div class="text-left mt-0 mb-2">
|
||||
<button type="submit" class="btn btn-submit" name="action" value="save-user-promotion">Promotion {{ __('save') }}</button>
|
||||
<a href="{{ route('user_promotions') }}" class="btn btn-default">{{ __('back') }}</a>
|
||||
</div>
|
||||
|
||||
@include('user.promotion.form')
|
||||
|
||||
<div class="text-left mt-0 mb-2">
|
||||
<button type="submit" class="btn btn-submit" name="action" value="save-user-promotion">Promotion {{ __('save') }}</button>
|
||||
<a href="{{ route('user_promotions') }}" class="btn btn-default">{{ __('back') }}</a>
|
||||
</div>
|
||||
|
||||
{!! Form::close() !!}
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
341
resources/views/user/promotion/form.blade.php
Normal file
341
resources/views/user/promotion/form.blade.php
Normal file
|
|
@ -0,0 +1,341 @@
|
|||
|
||||
<div class="card mb-2">
|
||||
<h5 class="card-header">
|
||||
{{ __('Promotion') }}
|
||||
</h5>
|
||||
<div class="card-body">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12 {{ $errors->has('name') ? 'has-error' : '' }}">
|
||||
<label class="custom-control custom-checkbox float-right">
|
||||
{!! Form::checkbox('active', 1, $user_promotion->active, ['class' => 'custom-control-input']) !!}
|
||||
<span class="custom-control-label">{{ __('Promotion aktiv') }}</span>
|
||||
</label>
|
||||
<label class="form-label" for="name">Promotion Name vergeben*</label>
|
||||
{{ Form::text('name', $user_promotion->name, ['placeholder' => __('Promotion Name'), 'class' => 'form-control', 'id' => 'name', 'required' => true]) }}
|
||||
@if ($errors->has('name'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('name') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="form-group col-12">
|
||||
<label class="form-label" for="description">Kurzbeschreibung (optional)</label>
|
||||
{{ Form::textarea('description', $user_promotion->description, ['placeholder' => __('Kurzbeschreibung'), 'class' => 'form-control', 'rows' => 2, 'id' => 'description']) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Text...</p>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-8">
|
||||
<div class="input-group mt-2 mb-2 ">
|
||||
<span class="input-group-prepend">
|
||||
<div class="py-2 px-1">
|
||||
<strong>www.testemicht.jetzt/ </strong>
|
||||
</div>
|
||||
</span>
|
||||
{{ Form::text('user_promotion_url', $user_promotion->url, ['placeholder' => 'z.B. "thomas" oder "dani21" o.ä.', 'class' => 'form-control' . ($errors->has('user_promotion_url') ? ' is-invalid' : ''), 'id' => 'user_promotion_url', 'required' => true]) }}
|
||||
</div>
|
||||
@if ($errors->has('user_promotion_url'))
|
||||
<span class="invalid-feedback" style="display: inline-block;">
|
||||
<strong>{{ $errors->first('user_promotion_url') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<div class="px-3 py-0 py-md-3">
|
||||
<div class="badge badge-success" style="display: none" id="user_promotion_url_success"><i
|
||||
class="fa fa-check"></i> ist noch frei</div>
|
||||
<div class="badge badge-danger" style="display: none" id="user_promotion_url_error"><i
|
||||
class="fa fa-times"></i> nicht verfügbar/Fehler</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="from-group mb-2 col-md-8">
|
||||
<label class="form-label">Vorschau Domain</label>
|
||||
{{ Form::text('preview_user_promotion_url', $user_promotion->getUrlPreview(), ['placeholder' => __('Vorschau Shop-Internet Adresse'), 'class' => 'form-control', 'id' => 'preview_user_promotion_url', 'readonly']) }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-sm-12">
|
||||
<hr>
|
||||
<label class="custom-control custom-checkbox mt-2">
|
||||
{!! Form::checkbox('pick_up', 1, $user_promotion->pick_up, ['class' => 'custom-control-input']) !!}
|
||||
<span class="custom-control-label">Kunden können bei mir persönlich abholen.</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<hr class="m-0">
|
||||
<div class="card-body">
|
||||
<p>Text ...</p>
|
||||
<h5>
|
||||
Aktuelles Guthaben: {{ Auth::user()->getFormattedPaymentCredit() }} €
|
||||
<span class="text-muted small">(Guthaben aufladen unter: <a
|
||||
href="{{ route('user_order_my_delivery', ['me']) }}">Bestellungen aufgeben</a> -> Produkt
|
||||
Guthaben aufladen)</span>
|
||||
</h5>
|
||||
<style>
|
||||
table.table-product,
|
||||
table.table-product tr td,
|
||||
table.table-product tr th {
|
||||
border: none;
|
||||
}
|
||||
|
||||
table.table-product tr.border-top td {
|
||||
border-top: 1px solid #b8b8b9;
|
||||
}
|
||||
|
||||
table.table-product tr.border-bottom td,
|
||||
table.table-product tr.border-bottom th {
|
||||
border-bottom: 1px solid #b8b8b9;
|
||||
}
|
||||
|
||||
|
||||
.btn-md-extra {
|
||||
padding: 0.3rem 0.6rem;
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.5;
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
|
||||
.md-btn-extra {
|
||||
width: calc(1.7rem + 2px) !important;
|
||||
line-height: 1.5rem;
|
||||
}
|
||||
|
||||
.form-control.input-extra {
|
||||
padding: 0.28rem 0.6rem;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 500;
|
||||
min-height: calc(1.8rem + 2px);
|
||||
height: calc(1.8rem + 2px);
|
||||
width: 44px;
|
||||
}
|
||||
|
||||
.input-group-min-w {
|
||||
min-width: 102px;
|
||||
}
|
||||
|
||||
.img-extra {
|
||||
min-width: 55px;
|
||||
max-height: 160px;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.default-style:not([dir=rtl]) div.card-datatable table.dataTable thead th:first-child, .default-style:not([dir=rtl]) div.card-datatable table.dataTable tbody td:first-child, .default-style:not([dir=rtl]) div.card-datatable table.dataTable tfoot th:first-child {
|
||||
padding-left: 0.6rem !important;
|
||||
}
|
||||
|
||||
.img-extra {
|
||||
min-width: 35px;
|
||||
max-height: 160px;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-product table-striped m-0" id="datatables-promotion-list" data-url="{{ route('user_promotion_load') }}" data-action="updateCart" data-user_promotion_id="{{ $user_promotion->id }}">
|
||||
<thead>
|
||||
<tr class="border-bottom">
|
||||
<th style="max-width: 60px;">Aktiv</th>
|
||||
<th>{{ __('Anzahl') }}</th>
|
||||
<th>{{ __('Produkt') }}</th>
|
||||
<th class="text-right">{{ __('Mein Preis netto') }}</th>
|
||||
<th class="text-right">{{ __('Mein Preis brutto') }}</th>
|
||||
<th class="text-right">{{ __('geordert') }}</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($user_promotion->promotion_admin->promotion_admin_products_active as $promotion_admin_product)
|
||||
<tr class="border-bottom">
|
||||
<td class="align-middle">
|
||||
<label class="custom-control custom-checkbox mt-2">
|
||||
{!! Form::checkbox('products_active['.$promotion_admin_product->id.']', 1, $promotion_admin_product->getPromotionUserProducts($user_promotion, 'active'),
|
||||
['class' => 'custom-control-input check-event-promotion-onchange', 'id'=>'product_check_'.$promotion_admin_product->id]) !!}
|
||||
<span class="custom-control-label"></span>
|
||||
</label>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<div class="no-line-break input-group-min-w">
|
||||
<div class="input-group d-inline-flex w-auto">
|
||||
<span class="input-group-prepend">
|
||||
<button type="button" class="btn btn-secondary icon-btn md-btn-extra remove-product-promotion" data-product-id="{{ $promotion_admin_product->id }}">-</button>
|
||||
</span>
|
||||
<input type="text" class="form-control text-center input-extra input-event-promotion-onchange"
|
||||
name="products_qty[{{ $promotion_admin_product->id }}]"
|
||||
id="product_qty_{{ $promotion_admin_product->id }}" data-product-id="{{ $promotion_admin_product->id }}"
|
||||
value="{{ $promotion_admin_product->getPromotionUserProducts($user_promotion, 'open_items') }}">
|
||||
<input type="hidden" name="products_user[{{ $promotion_admin_product->id }}]" value="{{ $promotion_admin_product->getPromotionUserProducts($user_promotion, 'id') }}">
|
||||
<span class="input-group-append">
|
||||
<button type="button" class="btn btn-secondary icon-btn md-btn-extra add-product-promotion" data-product-id="{{ $promotion_admin_product->id }}">+</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-3 py-2 align-middle">
|
||||
<div class="media align-items-center">
|
||||
@if ($promotion_admin_product->product)
|
||||
@if ($promotion_admin_product->product->images)
|
||||
@if ($image = $promotion_admin_product->product->images->first())
|
||||
<img src="{{ route('product_image', [$image->slug]) }}"
|
||||
class="d-block ui-w-80 mr-4" alt>
|
||||
@endif
|
||||
@endif
|
||||
<div class="media-body">
|
||||
<a href="{{ route('admin_product_edit', [$promotion_admin_product->product->id]) }}"
|
||||
class="d-block">{{ $promotion_admin_product->product->name }}
|
||||
<span
|
||||
class="text-muted">#{{ $promotion_admin_product->product->number }}</span></a>
|
||||
<small>
|
||||
<span class="text-muted">Inhalt: </span>
|
||||
{{ $promotion_admin_product->product->contents }}<br>
|
||||
<span class="text-muted">Gewicht: </span>
|
||||
{{ $promotion_admin_product->product->weight }} g<br>
|
||||
</small>
|
||||
<a href="" class="" data-modal="modal-lg" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="{{ $promotion_admin_product->product->id }}"
|
||||
data-route="{{ route('modal_load') }}"
|
||||
data-action="user-order-show-product" data-view="customer">
|
||||
<div class=""><i class="ion ion-md-eye"></i></div></a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</td>
|
||||
<td class="align-middle px-3 py-2 nowrap text-right" style="">
|
||||
{{ $promotion_admin_product->getFormattedPriceWith(true) }} €
|
||||
</td>
|
||||
<td class="align-middle px-3 py-2 text-right" style="">
|
||||
{{ $promotion_admin_product->getFormattedPriceWith(false) }} €
|
||||
</td>
|
||||
<td class="align-middle px-3 py-2 text-right" style="">
|
||||
{{ $promotion_admin_product->getPromotionUserProducts($user_promotion, 'sell_items') }}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="m-0">
|
||||
<div class="card-body" id="holder_html_view_cart">
|
||||
@include('user.promotion.cart', ['user_promotion_cart'=> $user_promotion_cart, 'checkPaymentCredit' => $checkPaymentCredit] )
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="application/javascript">
|
||||
$(document).ready(function() {
|
||||
$.extend($.validator.messages, {
|
||||
required: "Dieses Feld ist ein Pflichtfeld.",
|
||||
maxlength: $.validator.format("Gib bitte maximal {0} Zeichen ein."),
|
||||
minlength: $.validator.format("Gib bitte mindestens {0} Zeichen ein."),
|
||||
rangelength: $.validator.format("Gib bitte mindestens {0} und maximal {1} Zeichen ein."),
|
||||
email: "Gib bitte eine gültige E-Mail Adresse ein.",
|
||||
url: "Gib bitte eine gültige URL ein.",
|
||||
date: "Bitte gib ein gültiges Datum ein.",
|
||||
number: "Gib bitte eine Nummer ein.",
|
||||
digits: "Gib bitte nur Ziffern ein.",
|
||||
equalTo: "Bitte denselben Wert wiederholen.",
|
||||
range: $.validator.format("Gib bitte einen Wert zwischen {0} und {1} ein."),
|
||||
max: $.validator.format("Gib bitte einen Wert kleiner oder gleich {0} ein."),
|
||||
min: $.validator.format("Gib bitte einen Wert größer oder gleich {0} ein."),
|
||||
creditcard: "Gib bitte eine gültige Kreditkarten-Nummer ein."
|
||||
});
|
||||
// Set up validator
|
||||
var message = 'Default error message';
|
||||
$('#user-promotion-form-validations').validate({
|
||||
rules: {
|
||||
'user_promotion_url': {
|
||||
required: true,
|
||||
remote: {
|
||||
url: "{{ route('user_promotion_load') }}",
|
||||
type: "post",
|
||||
data: {
|
||||
user_promotion_url: function() {
|
||||
return $(
|
||||
'#user-promotion-form-validations :input[name="user_promotion_url"]'
|
||||
).val();
|
||||
},
|
||||
action: 'validate_url'
|
||||
},
|
||||
encode: true,
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
},
|
||||
dataFilter: function(response) {
|
||||
response = $.parseJSON(response);
|
||||
console.log(response);
|
||||
$('#user_promotion_url_success').hide();
|
||||
$('#user_promotion_url_error').hide();
|
||||
if (response.success === true) {
|
||||
$('#user_promotion_url_success').show();
|
||||
$('#preview_user_promotion_url').val(response
|
||||
.preview_user_promotion_url);
|
||||
return true;
|
||||
} else {
|
||||
$('#user_promotion_url_error').show();
|
||||
message = response.errors.user_promotion_url;
|
||||
$('#preview_user_promotion_url').val('');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
errorPlacement: function errorPlacement(error, element) {
|
||||
$(element).parents('.form-group').find('.input-group').after(
|
||||
error.addClass('invalid-feedback d-block font-weight-bold')
|
||||
)
|
||||
},
|
||||
highlight: function(element) {
|
||||
if($(element).attr('required')){
|
||||
$(element).parent().find('button').removeClass('btn-success');
|
||||
$(element).parent().find('button').addClass('btn-danger');
|
||||
$(element).parent().find('button i').removeClass('fa-check');
|
||||
$(element).parent().find('button i').addClass('fa-times');
|
||||
$(element).removeClass('is-valid');
|
||||
$(element).addClass('is-invalid');
|
||||
}
|
||||
},
|
||||
unhighlight: function(element) {
|
||||
if($(element).attr('required')){
|
||||
$(element).removeClass('is-invalid');
|
||||
$(element).addClass('is-valid');
|
||||
$(element).parent().find('button').removeClass('btn-danger');
|
||||
$(element).parent().find('button').addClass('btn-success');
|
||||
$(element).parent().find('button i').removeClass('fa-times');
|
||||
$(element).parent().find('button i').addClass('fa-check');
|
||||
$(element).parents('.form-group').find('.is-invalid').removeClass('is-invalid');
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
messages: {
|
||||
required: "{{ __('This field is required.') }}",
|
||||
user_promotion_url: {
|
||||
email: "{{ __('Please enter a valid email address.') }}",
|
||||
remote: function() {
|
||||
return message;
|
||||
}
|
||||
},
|
||||
},
|
||||
onkeyup: function(element) {
|
||||
$(element).valid()
|
||||
},
|
||||
});
|
||||
|
||||
var iqPromotionCart = IqPromotionCart.init();
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@section('scripts')
|
||||
<script src="{{ asset('/js/iq-promotion-cart.js') }}?v=2{{ get_file_last_time('/js/iq-promotion-cart.js') }}"></script>
|
||||
@endsection
|
||||
199
resources/views/user/promotion/index.blade.php
Normal file
199
resources/views/user/promotion/index.blade.php
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
@extends('layouts.layout-2')
|
||||
|
||||
@section('content')
|
||||
<h4 class="font-weight-bold py-2 mb-2 d-flex justify-content-between align-items-center w-100 ">
|
||||
<div>{{ __('navigation.my_promotions') }} / {{ __('navigation.overview') }}</div>
|
||||
<button type="button" class="btn btn-secondary rounded-pill d-block float-right" data-toggle="modal" data-target="#modals-new-user-promotion">
|
||||
<span class="ion ion-md-add"></span> Neue Promotion anlegen
|
||||
</button>
|
||||
</h4>
|
||||
|
||||
<p> Text ...</p>
|
||||
|
||||
<div class="card mb-3">
|
||||
<h5 class="card-header bg-white">
|
||||
<a href="#" class="" data-toggle="collapse" data-target="#collapsePromotionFaq" aria-expanded="false" aria-controls="collapsePromotionFaq">
|
||||
<i class="fa fa-caret-expand"></i> {{ __('Und so geht\'s / FAQs') }}
|
||||
</a>
|
||||
</h5>
|
||||
<div class="collapse" id="collapsePromotionFaq">
|
||||
<div class="px-4 py-3">
|
||||
<p>Text ...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
@foreach($values as $value)
|
||||
|
||||
<div class="card mb-4">
|
||||
<div class="card-body d-flex justify-content-between align-items-start pb-2">
|
||||
<div>
|
||||
<a href="{{route('user_promotion_detail', [$value->id])}}" class="text-body text-big font-weight-semibold">{{$value->name}}</a>
|
||||
</div>
|
||||
@if($value->canDelete())
|
||||
<div class="btn-group project-actions">
|
||||
<a href="{{ route('user_promotion_delete', [$value->id, 'user_promotion']) }}"
|
||||
class=" dropdown-item" onclick="return confirm('Promotion wirklich löschen?');">
|
||||
<span class="ion ion-md-trash text-danger"></span>
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<div class="progress rounded-0" style="height: 2px;">
|
||||
<div class="progress-bar" style="width: 100%;"></div>
|
||||
</div>
|
||||
<div class="card-body pt-3 pb-1">
|
||||
{{$value->description}}
|
||||
<hr>
|
||||
</div>
|
||||
<div class="card-body pt-0">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="text-muted small">Promotion Produkte</div>
|
||||
<div class="font-weight-bold">{{$value->promotion_admin->promotion_admin_products_active->count()}}
|
||||
{{ formatPlural($value->promotion_admin->promotion_admin_products_active->count(), 'Sorte', 'n') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
<div class="text-muted small">aktive Produkte</div>
|
||||
<div class="font-weight-bold">{{$value->promotion_user_products_active->count()}}
|
||||
{{ formatPlural($value->promotion_user_products_active->count(), 'Sorte', 'n') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
<div class="text-muted small">geplant Produkte</div>
|
||||
<div class="font-weight-bold">{{$value->getCountOpenItems()}} Stk.</div>
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
<div class="text-muted small">geordert Produkte</div>
|
||||
<div class="font-weight-bold">{{$value->getCountSellItems()}} Stk.</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<div class="col">
|
||||
<div class="text-muted small">Promotion aktiv</div>
|
||||
<div class="font-weight-bold">{!! get_active_badge($value->active) !!}</div>
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
<div class="text-muted small">persönliche Abholung</div>
|
||||
<div class="font-weight-bold">{!! get_active_badge($value->pick_up) !!}</div>
|
||||
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="text-muted small">Potentielle Kosten</div>
|
||||
@php($user_promotion_cart = $value->calculateCart())
|
||||
<div class="font-weight-bold">{{ formatNumber($user_promotion_cart['price']) }} € brutto</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="text-muted small">Kosten bisher</div>
|
||||
@php($user_promotion_sell = $value->calculateSell())
|
||||
<div class="font-weight-bold">{{ formatNumber($user_promotion_sell['price']) }} € brutto</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<hr class="m-0">
|
||||
<div class="card-body py-3">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-10 mb-0">
|
||||
<label class="form-label">Domain / URL für Deine Promotion</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-prepend">
|
||||
<button class="btn btn-sm btn-secondary" type="button" title="Kopiert!" data-clipboard-demo data-clipboard-target="#promotion_link_{{$value->id}}"><i class="ion ion-ios-copy"></i> Domain kopieren</button>
|
||||
</span>
|
||||
<input type="text" class="form-control" name="promotion_link_{{$value->id}}" value="{{ $value->getUrlPreview() }}" id="promotion_link_{{$value->id}}" placeholder="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-2 mb-0">
|
||||
<label class="form-label"> </label>
|
||||
<div>
|
||||
<a class="btn btn-sm btn-outline-primary mt-1" href="{{ $value->getUrlPreview() }}" target="_blank"><i class="ion ion-ios-share-alt"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@php($checkPaymentCredit = $value->checkPaymentCredit())
|
||||
@if($checkPaymentCredit === 'empty')
|
||||
<h6 class="alert badge-danger mt-3 py-2">Du hast kein Guthaben aus Deinem Konto auf, lade Dein Konto auf, bis dahin ist die Promotion gestoppt.</h6>
|
||||
@endif
|
||||
@if($checkPaymentCredit === 'okay')
|
||||
<h6 class="alert badge-success mt-3 py-2">Dein Guthaben ist für diese Promotion</h6>
|
||||
@endif
|
||||
@if($checkPaymentCredit === 'not')
|
||||
<h6 class="alert badge-danger mt-3 py-2">Dein Guthaben ist nicht ausreichend für diese Promotion, lade Dein Konto auf, bis dahin ist die Promotion gestoppt.</h6>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<hr class="m-0">
|
||||
<div class="card-body py-3">
|
||||
<div class="d-flex flex-wrap">
|
||||
<a href="{{route('user_promotion_detail', [$value->id])}}" class="btn btn-secondary mr-2 mb-2"><i class="ion ion-ios-cog"></i> Bearbeiten</a>
|
||||
{{--
|
||||
<a href="#" class="btn btn-secondary mr-2 mb-2"><i class="ion ion-md-basket"></i> Promotions ansehen (n.b!)</a>
|
||||
<a href="#" class="btn btn-secondary mr-2 mb-2"><i class="ion ion-md-basket"></i> Bestellung ansehen (n.b!)</a>
|
||||
--}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- Modal template -->
|
||||
<div class="modal fade" id="modals-new-user-promotion">
|
||||
<div class="modal-dialog">
|
||||
<form class="modal-content" action="{{route('user_promotion_detail', ['new'])}}" method="post">
|
||||
@csrf
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Neue Promotion anlegen</span></h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="country_ids" class="form-label">Wähle die Art deiner Promotion</label>
|
||||
<select class="selectpicker" name="promotion_admin_id" id="promotion_admin_id" data-style="btn-light" data-live-search="true" required>
|
||||
{!! HTMLHelper::getAnyOptions(null, \App\Models\PromotionAdmin::getActiveAdminPromotionsAsArray(), true) !!}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{__('close')}}</button>
|
||||
<button type="submit" class="btn btn-primary" name="action" value="new-user-promotion">{{__('anlegen')}}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
$( document ).ready(function() {
|
||||
var clipboardDemos = new ClipboardJS('[data-clipboard-demo]');
|
||||
clipboardDemos.on('success', function (e) {
|
||||
e.clearSelection();
|
||||
$(e.trigger).tooltip('enable').tooltip('show');
|
||||
});
|
||||
clipboardDemos.on('error', function (e) {
|
||||
console.error('Action:', e.action);
|
||||
console.error('Trigger:', e.trigger);
|
||||
});
|
||||
|
||||
$('button[data-clipboard-demo]').on('mouseout', function () {
|
||||
$(this).tooltip('disable');
|
||||
})
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
|
@ -21,6 +21,7 @@ Route::get('/logout', function(){
|
|||
return Redirect::to('login');
|
||||
})->name('logout');
|
||||
|
||||
/*
|
||||
Route::get('storage/images/{from}/{slug}', function($from = null, $slug = null) {
|
||||
if ($from == 'shop'){
|
||||
$image = \App\Models\UserShop::where('filename', $slug)->first();
|
||||
|
|
@ -31,6 +32,7 @@ Route::get('storage/images/{from}/{slug}', function($from = null, $slug = null)
|
|||
}
|
||||
|
||||
})->name('storage_images');
|
||||
*/
|
||||
|
||||
Route::get('/product/image/{slug}', function($slug = null)
|
||||
{
|
||||
|
|
@ -195,6 +197,12 @@ Route::group(['middleware' => ['auth:user']], function() {
|
|||
Route::post('/user/checkout_store/{identifier?}', 'User\CheckoutController@store')->name('user_checkout_store');
|
||||
Route::get('/user/checkout_final/{payid}/{reference}/{identifier?}', 'User\CheckoutController@final')->name('user_checkout_final');
|
||||
|
||||
Route::get('/user/promotions', 'User\PromotionController@index')->name('user_promotions');
|
||||
Route::get('/user/promotion/detail/{id}', 'User\PromotionController@detail')->name('user_promotion_detail');
|
||||
Route::post('/user/promotion/detail/{id}', 'User\PromotionController@store')->name('user_promotion_detail');
|
||||
Route::post('/user/promotion/load', 'User\PromotionController@load')->name('user_promotion_load');
|
||||
Route::get('/user/promotion/delete/{id}/{del?}', 'User\PromotionController@delete')->name('user_promotion_delete');
|
||||
|
||||
});
|
||||
|
||||
Route::group(['middleware' => ['admin']], function()
|
||||
|
|
@ -307,8 +315,12 @@ Route::group(['middleware' => ['admin']], function()
|
|||
Route::post('/admin/payments/invoice', 'PaymentInvoiceController@index')->name('admin_payments_invoice');
|
||||
Route::get('/admin/payments/invoice/datatable', 'PaymentInvoiceController@datatable')->name('admin_payments_invoice_datatable');
|
||||
|
||||
|
||||
|
||||
Route::get('/admin/promotions', 'AdminPromotionController@index')->name('admin_promotions');
|
||||
Route::get('/admin/promotion/detail/{id}', 'AdminPromotionController@detail')->name('admin_promotion_detail');
|
||||
Route::post('/admin/promotion/detail/{id}', 'AdminPromotionController@store')->name('admin_promotion_detail');
|
||||
Route::get('/admin/promotion/delete/{id}/{del?}', 'AdminPromotionController@delete')->name('admin_promotion_delete');
|
||||
Route::get('/admin/promotion/show/{by}/{id?}', 'AdminPromotionController@show')->name('admin_promotion_show');
|
||||
Route::get('/admin/promotion/datatable/{by}/{id?}', 'AdminPromotionController@datatable')->name('admin_promotion_datatable');
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue