diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 21988bc..646ab68 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,75 +2,57 @@ - - - - - - - - - + + + + + + + + + + + + + + - - + - - + + + + - + + + + - - + + - - - - + + + - - - - - - - + - + - - + + - - - - - - - - - - - - - - - - - - - - - - + + - - - - - + + + + + @@ -470,6 +452,23 @@ + + + + + + + + + + + + + + + + + @@ -514,10 +513,10 @@ - + - + @@ -528,20 +527,21 @@ - + + - + - + - + - + @@ -552,6 +552,16 @@ 15 diff --git a/app/Http/Controllers/Api/PayoneController.php b/app/Http/Controllers/Api/PayoneController.php index ee72ea5..96ebda5 100755 --- a/app/Http/Controllers/Api/PayoneController.php +++ b/app/Http/Controllers/Api/PayoneController.php @@ -8,6 +8,7 @@ use App\Mail\MailCheckout; use App\Models\PaymentTransaction; use App\Models\ShoppingOrder; use App\Models\ShoppingPayment; +use App\Services\Shop; use App\Services\Util; use App\User; use Illuminate\Support\Facades\Mail; @@ -129,10 +130,12 @@ class PayoneController extends Controller } if($data['txaction'] === 'appointed'){ $shopping_order->setUserHistoryValue(['status' => 7]); + Shop::userOrders(); } if($data['txaction'] === 'paid'){ $shopping_order->setUserHistoryValue(['status' => 8]); + Shop::userOrders(); $shopping_order->paid = true; $shopping_order->save(); @@ -150,7 +153,6 @@ class PayoneController extends Controller if($user->payment_account && $user->daysActiveAccount()>0){ $date = \Carbon::parse($user->payment_account)->modify('1 year'); } - foreach ($shopping_order_item->product->action as $do){ if($shopping_order_item->product->getActionName($do) === 'payment_for_account'){ $user->payment_order_id = $shopping_order_item->product->id; //34 @@ -183,9 +185,8 @@ class PayoneController extends Controller } } } - + $bcc = []; $billing_email = $shopping_order->shopping_user->billing_email; - $user_shop_email = $shopping_order->user_shop->user->email; if(!$billing_email){ if($data['mode'] === 'test'){ $billing_email = config('app.checkout_test_mail'); @@ -194,17 +195,15 @@ class PayoneController extends Controller } } if($data['mode'] === 'test'){ - $checkout_mail = config('app.checkout_test_mail'); + $bcc[] = config('app.checkout_test_mail'); }else{ - $checkout_mail = config('app.checkout_mail'); + $bcc[] = config('app.checkout_mail'); } - if($user_shop_email){ - Mail::to($billing_email)->bcc([$user_shop_email, $checkout_mail])->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment, $send_link, $data['mode'])); - }else{ - Mail::to($billing_email)->bcc($checkout_mail)->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment, $send_link, $data['mode'])); + if(!$shopping_order->shopping_user->is_like && $shopping_order->shopping_user->member){ + $bcc[] = $shopping_order->shopping_user->member->email; } - + Mail::to($billing_email)->bcc($bcc)->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment, $send_link, $data['mode'])); print("TSOK"); exit; } diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php new file mode 100755 index 0000000..43a52e5 --- /dev/null +++ b/app/Http/Controllers/CustomerController.php @@ -0,0 +1,135 @@ +middleware('admin'); + $this->customerRepository = $customerRepository; + + } + + public function index() + { + if(Request::get('reset') === 'filter'){ + set_user_attr('filter_member_id', null); + set_user_attr('filter_customer_member', null); + return redirect(route('admin_customers')); + } + $filter_members = ShoppingUser::join('users', 'member_id', '=', 'users.id')->groupBy('member_id')->join('user_accounts', 'account_id', '=', 'user_accounts.id')->select('users.id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')->get(); //->pluck('email', 'id')->unique()->toArray(); + $data = [ + 'filter_members' => $filter_members, + ]; + return view('admin.customer.index', $data); + } + + + public function edit($id) + { + if($id === "new"){ + $shopping_user = new ShoppingUser(); + $shopping_user->id = "new"; + }else{ + $shopping_user = ShoppingUser::findOrFail($id); + } + $data = [ + 'shopping_user' => $shopping_user, + 'isAdmin' => true, + 'isView' => 'customer', + + ]; + return view('admin.customer.detail', $data); + } + + public function store($id) + { + $data = Request::all(); + $change_member_error = false; + if($data['action']==='shopping-user-change-member'){ + if(!isset($data['change_member_key']) || $data['change_member_key'] !== config('mivita.edit_data_pass')){ + $change_member_error = "Das Passwort ist falsch."; + }else{ + //change + $shopping_user = ShoppingUser::findOrFail($data['id']); + CustomerPriority::newMemberForCustomer($shopping_user, $data['change_member_id'], $data['customer_set_member_for']); + \Session()->flash('alert-save', true); + return redirect(route('admin_customer_edit', [$shopping_user->id])); + } + } + $data = [ + 'change_member_error' => $change_member_error, + 'shopping_user' => ShoppingUser::find($id), + 'isAdmin' => true, + 'isView' => 'customer', + ]; + return view('admin.customer.detail', $data); + } + + public function getCustomers() + { + $query = ShoppingUser::select('shopping_users.*')->where('auth_user_id', '=', NULL); + + set_user_attr('filter_member_id', Request::get('filter_member_id')); + if(Request::get('filter_member_id') != ""){ + $query->where('member_id', '=', Request::get('filter_member_id')); + } + /* set_user_attr('filter_customer_member', Request::get('filter_customer_member')); + if(Request::get('filter_customer_member') != ""){ + if(Request::get('filter_customer_member') === 'customers'){ + $query->where('auth_user_id', '=', NULL); + } + if(Request::get('filter_customer_member') === 'members'){ + $query->where('auth_user_id', '!=', NULL); + } + }*/ + return \DataTables::eloquent($query) + ->addColumn('id', function (ShoppingUser $ShoppingUser) { + return ''; + }) + ->addColumn('billing_salutation', function (ShoppingUser $ShoppingUser) { + return HTMLHelper::getSalutationLang($ShoppingUser->billing_salutation); + }) + ->addColumn('billing_country_id', function (ShoppingUser $ShoppingUser) { + return $ShoppingUser->billing_country ? $ShoppingUser->billing_country->getLocated() : ''; + }) + ->addColumn('isMember', function (ShoppingUser $ShoppingUser) { + return $ShoppingUser->auth_user_id ? '' : ''; + }) + ->addColumn('member_id', function (ShoppingUser $ShoppingUser) { + if($ShoppingUser->member_id){ + return ''.$ShoppingUser->member->getFullName().''; + } + if($ShoppingUser->is_like){ + return ''; + } + return ''; + }) + ->addColumn('created_at', function (ShoppingUser $ShoppingUser) { + return $ShoppingUser->created_at->format('d.m.Y'); + }) + ->orderColumn('id', 'id $1') + ->orderColumn('billing_country_id', 'billing_country_id $1') + ->orderColumn('billing_salutation', 'billing_salutation $1') + ->orderColumn('created_at', 'created_at $1') + ->orderColumn('isMember', 'auth_user_id $1') + ->orderColumn('member_id', 'member_id $1') + ->rawColumns(['id', 'isMember', 'member_id']) + ->make(true); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/DataTableController.php b/app/Http/Controllers/DataTableController.php index ead1f46..19a5385 100644 --- a/app/Http/Controllers/DataTableController.php +++ b/app/Http/Controllers/DataTableController.php @@ -15,7 +15,7 @@ class DataTableController extends Controller public function getUsers() { - $query = User::with('account')->where('users.deleted_at', '=', null); + $query = User::with('account')->select('users.*')->where('users.deleted_at', '=', null); return \DataTables::eloquent($query) ->addColumn('first_name', function (User $user) { diff --git a/app/Http/Controllers/LeadController.php b/app/Http/Controllers/LeadController.php index 54a7d8f..7954aa9 100755 --- a/app/Http/Controllers/LeadController.php +++ b/app/Http/Controllers/LeadController.php @@ -81,8 +81,8 @@ class LeadController extends Controller { $m_data_load = false; $m_data_error = false; - $data = Input::all(); - if(!isset($data['edit_m_data_key']) && $data['edit_m_data_key'] !== config('mivita.edit_data_pass')){ + $data = Request::all(); + if(!isset($data['edit_m_data_key']) || $data['edit_m_data_key'] !== config('mivita.edit_data_pass')){ $m_data_error = "Das Passwort ist falsch."; }else{ $m_data_load = true; @@ -340,7 +340,7 @@ class LeadController extends Controller public function getLeads() { - $query = User::with('account')->where('users.deleted_at', '=', null); + $query = User::with('account')->select('users.*')->where('users.deleted_at', '=', null); return \DataTables::eloquent($query) ->addColumn('first_name', function (User $user) { diff --git a/app/Http/Controllers/ModalController.php b/app/Http/Controllers/ModalController.php new file mode 100644 index 0000000..a92abc1 --- /dev/null +++ b/app/Http/Controllers/ModalController.php @@ -0,0 +1,63 @@ +middleware('auth'); + } + + public function load(){ + $data = Request::all(); + $ret = ""; + $status = false; + if(Request::ajax()){ + if($data['action'] === 'shopping-order-change-member'){ + $value = ShoppingOrder::find($data['id']); + $route = route('admin_sales_customers_detail', [$value->id]); + $ret = view("admin.modal.member", compact('value', 'data', 'route'))->render(); + } + if($data['action'] === 'shopping-user-change-member'){ + $value = ShoppingUser::find($data['id']); + $route = route('admin_customer_edit', [$value->id]); + $ret = view("admin.modal.member", compact('value', 'data', 'route'))->render(); + } + if($data['action'] === 'shopping-user-is-like-member'){ + $current = ShoppingUser::find($data['id']); //current user form order + $possibles = []; + if($current->is_like){ + $likes = $current->getNotice('like'); + foreach ($likes as $like_id=>$number){ + $possibles[] = ShoppingUser::find($like_id); + } + } + $ret = view("admin.modal.is_like_member", compact('current', 'possibles', 'data'))->render(); + } + + + } + return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]); + } + + +} + + + +/* */ \ No newline at end of file diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index 329877b..fe70a41 100755 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -25,11 +25,10 @@ class ProductController extends Controller public function index() { if(Request::get('show_active_products')){ - \Auth::user()->setSetting(['show_active_products' => Request::get('show_active_products')]); + set_user_attr('show_active_products', Request::get('show_active_products')); } - if(\Auth::user()->getSetting('show_active_products') === "true"){ + if(get_user_attr('show_active_products') === "true"){ $values = Product::where('active', true)->orderBy('pos', 'DESC')->orderBy('id', 'DESC')->get(); - }else{ $values = Product::orderBy('pos', 'DESC')->orderBy('id', 'DESC')->get(); diff --git a/app/Http/Controllers/SalesController.php b/app/Http/Controllers/SalesController.php index 934ca62..6e11f43 100755 --- a/app/Http/Controllers/SalesController.php +++ b/app/Http/Controllers/SalesController.php @@ -2,61 +2,68 @@ namespace App\Http\Controllers; - - use App\Models\Country; use App\Models\ShoppingOrder; +use App\Models\ShoppingUser; use App\Models\UserShop; +use App\Services\CustomerPriority; +use App\Services\Payment; +use App\User; use Input; - +use Request; class SalesController extends Controller { - public function __construct() - { + public function __construct(){ $this->middleware('admin'); - } - public function users() - { + public function users(){ + + if(Request::get('reset') === 'filter'){ + return redirect(route('admin_sales_users')); + } $data = [ - //'values' => ShoppingOrder::all(), + ]; return view('admin.sales.users', $data); } - public function usersDetail() + public function usersDetail($id) { $data = [ - // 'values' => Country::all(), + 'shopping_order' => ShoppingOrder::find($id), + 'isAdmin' => true, + 'isView' => 'sales_user', ]; return view('admin.sales.user_detail', $data); } + public function usersStore($id) + { + die("keine funktion"); + $data = [ + 'shopping_order' => ShoppingOrder::find($id), + 'isAdmin' => true, + ]; + return view('admin.sales.user_detail', $data); + } + + public function usersDatatable(){ - $query = ShoppingOrder::with('shopping_user', 'user_shop')->where('shopping_orders.auth_user_id', '!=', NULL); + $query = ShoppingOrder::with('shopping_user', 'user_shop')->select('shopping_orders.*')->where('shopping_orders.auth_user_id', '!=', NULL); return \DataTables::eloquent($query) - ->addColumn('billing_firstname', function (ShoppingOrder $ShoppingOrder) { - return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->billing_firstname : ''; - }) - ->addColumn('billing_lastname', function (ShoppingOrder $ShoppingOrder) { - return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->billing_lastname : ''; - }) - ->addColumn('billing_email', function (ShoppingOrder $ShoppingOrder) { - return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->billing_email : ''; + ->addColumn('id', function (ShoppingOrder $ShoppingOrder) { + return ''; }) ->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) { return $ShoppingOrder->created_at->format("d.m.Y"); }) ->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) { - if($ShoppingOrder->mode === 'test'){ - return 'TEST - '.$ShoppingOrder->getFormattedTxaction().''; - } - return ''.$ShoppingOrder->getFormattedTxaction().''; + return Payment::getShoppingOrderBadge($ShoppingOrder); }) ->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) { return $ShoppingOrder->getFormattedTotalShipping(); @@ -69,26 +76,8 @@ class SalesController extends Controller }) ->addColumn('auth_user_shop', function (ShoppingOrder $ShoppingOrder) { $auth_user_shop = UserShop::whereUserId($ShoppingOrder->auth_user_id)->first(); - return $auth_user_shop ? ''.$auth_user_shop->getSubdomain(false).'' : '-'; }) - - ->addColumn('id', function (ShoppingOrder $ShoppingOrder) { - return ''; - }) - /* ->addColumn('confirmed', function (User $user) { - return $user->confirmed ? '' : ''; - }) - ->addColumn('active', function (User $user) { - return $user->active ? ' ' : ''; - }) - ->addColumn('agreement', function (User $user) { - return $user->agreement ? ' ' : ''; - }) - ->orderColumn('confirmed', 'confirmed $1') - ->orderColumn('active', 'active $1') - ->orderColumn('agreement', 'agreement $1') - */ ->orderColumn('id', 'id $1') ->orderColumn('txaction', 'txaction $1') ->orderColumn('user_shop_id', 'user_shop_id $1') @@ -99,72 +88,132 @@ class SalesController extends Controller public function customers() { + if(Request::get('reset') === 'filter'){ + set_user_attr('filter_user_shop_id', null); + set_user_attr('filter_txaction', null); + set_user_attr('filter_member_id', null); + return redirect(route('admin_sales_customers')); + } + $filter_user_shops = ShoppingOrder::join('user_shops', 'user_shop_id', '=', 'user_shops.id')->get()->pluck('slug', 'id')->unique()->toArray(); + $filter_members = ShoppingOrder::join('users', 'member_id', '=', 'users.id')->groupBy('member_id')->join('user_accounts', 'account_id', '=', 'user_accounts.id')->select('users.id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')->get(); //->pluck('email', 'id')->unique()->toArray(); $data = [ - // 'values' => ShoppingOrder::all(), + 'filter_user_shops' => $filter_user_shops, + 'filter_members' => $filter_members, ]; return view('admin.sales.customers', $data); } - public function customersDetail() + public function customersDetail($id) { $data = [ - // 'values' => Country::all(), + 'shopping_order' => ShoppingOrder::find($id), + 'isAdmin' => true, + 'isView' => 'sales_customer', + ]; + return view('admin.sales.customer_detail', $data); + } + + public function customersStore($id) + { + $data = Request::all(); + $change_member_error = false; + if($data['action']==='shopping-order-change-member'){ + if(!isset($data['change_member_key']) || $data['change_member_key'] !== config('mivita.edit_data_pass')){ + $change_member_error = "Das Passwort ist falsch."; + }else{ + //change + $shopping_order = ShoppingOrder::findOrFail($data['id']); + CustomerPriority::newMemberForOrder($shopping_order, $data['change_member_id'], $data['customer_set_member_for']); + \Session()->flash('alert-save', true); + return redirect(route('admin_sales_customers_detail', [$shopping_order->id])); + } + } + if($data['action']==='shopping-user-is-like-member'){ + if(!isset($data['change_member_key']) || $data['change_member_key'] !== config('mivita.edit_data_pass')){ + \Session()->flash('alert-error', 'Das Passwort ist falsch.'); + return redirect($data['back']); + }else{ + if(!isset($data['is_like_shopping_user_id'])){ + \Session()->flash('alert-error', 'Keine Änderung ausgewählt'); + return redirect($data['back']); + } + $shopping_user = ShoppingUser::findOrFail($data['id']); + $set_like_shopping_user = ShoppingUser::findOrFail($data['is_like_shopping_user_id']); + $send_member_mail = isset($data['send_member_mail']) ? true : false; + //Mail send in setIsLike + CustomerPriority::setIsLike($shopping_user, $set_like_shopping_user, $send_member_mail); + \Session()->flash('alert-save', true); + return redirect($data['back']); + } + } + $data = [ + 'change_member_error' => $change_member_error, + 'shopping_order' => ShoppingOrder::find($id), + 'isAdmin' => true, + 'isView' => 'sales_customer', ]; return view('admin.sales.customer_detail', $data); } public function customersDatatable(){ - $query = ShoppingOrder::with('shopping_user')->where('shopping_orders.auth_user_id', NULL); + $query = ShoppingOrder::with('shopping_user')->select('shopping_orders.*')->where('shopping_orders.auth_user_id', NULL); + set_user_attr('filter_user_shop_id', Request::get('filter_user_shop_id')); + if(Request::get('filter_user_shop_id') != ""){ + $query->where('user_shop_id', '=', Request::get('filter_user_shop_id')); + } + set_user_attr('filter_txaction', Request::get('filter_txaction')); + if(Request::get('filter_txaction') != ""){ + if(Request::get('filter_txaction') === 'NULL'){ + $query->where('txaction', '=', NULL); + + }else{ + $query->where('txaction', '=', Request::get('filter_txaction')); + } + } + set_user_attr('filter_member_id', Request::get('filter_member_id')); + if(Request::get('filter_member_id') != ""){ + $query->where('member_id', '=', Request::get('filter_member_id')); + } return \DataTables::eloquent($query) - ->addColumn('billing_firstname', function (ShoppingOrder $ShoppingOrder) { - return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->billing_firstname : ''; - }) - ->addColumn('billing_lastname', function (ShoppingOrder $ShoppingOrder) { - return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->billing_lastname : ''; - }) - ->addColumn('billing_email', function (ShoppingOrder $ShoppingOrder) { - return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->billing_email : ''; + ->addColumn('id', function (ShoppingOrder $ShoppingOrder) { + return ''; }) ->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) { return $ShoppingOrder->created_at->format("d.m.Y"); }) ->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) { - if($ShoppingOrder->mode === 'test'){ - return 'TEST - '.$ShoppingOrder->getFormattedTxaction().''; - } - return ''.$ShoppingOrder->getFormattedTxaction().''; + return Payment::getShoppingOrderBadge($ShoppingOrder); }) ->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) { return $ShoppingOrder->getFormattedTotalShipping(); }) - ->addColumn('orders', function (ShoppingOrder $ShoppingOrder) { - return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->orders : ''; + + ->addColumn('member_id', function (ShoppingOrder $ShoppingOrder) { + if($ShoppingOrder->member_id) { + return $ShoppingOrder->member_id ? '' . $ShoppingOrder->member->getFullName() . '' : ''; + } + if($ShoppingOrder->shopping_user && $ShoppingOrder->shopping_user->is_like){ + return ''; + } + return ''; }) + ->addColumn('user_shop_id', function (ShoppingOrder $ShoppingOrder) { return $ShoppingOrder->user_shop ? ''.$ShoppingOrder->user_shop->getSubdomain(false).'' : ''; }) - ->addColumn('id', function (ShoppingOrder $ShoppingOrder) { - return ''; - }) - /* ->addColumn('confirmed', function (User $user) { - return $user->confirmed ? '' : ''; - }) - ->addColumn('active', function (User $user) { - return $user->active ? ' ' : ''; - }) - ->addColumn('agreement', function (User $user) { - return $user->agreement ? ' ' : ''; - }) - ->orderColumn('confirmed', 'confirmed $1') - ->orderColumn('active', 'active $1') - ->orderColumn('agreement', 'agreement $1') - */ - ->orderColumn('id', 'id $1') + + ->orderColumn('id', 'id $1') ->orderColumn('txaction', 'txaction $1') ->orderColumn('user_shop_id', 'user_shop_id $1') - ->rawColumns(['id', 'txaction', 'user_shop_id']) + ->orderColumn('member_id', 'member_id $1') + ->rawColumns(['id', 'member_id', 'txaction', 'user_shop_id']) ->make(true); } diff --git a/app/Http/Controllers/Sys/AdminToolsController.php b/app/Http/Controllers/Sys/AdminToolsController.php index 4f7ec87..f8feb03 100755 --- a/app/Http/Controllers/Sys/AdminToolsController.php +++ b/app/Http/Controllers/Sys/AdminToolsController.php @@ -7,9 +7,13 @@ namespace App\Http\Controllers\Sys; use App\Http\Controllers\Api\KasController; use App\Http\Controllers\Api\KasSLLController; use App\Http\Controllers\Controller; +use App\Mail\MailInfo; use App\Models\ShoppingUser; use App\Models\UserShop; +use App\Services\CustomerPriority; +use App\Services\Shop; use Auth; +use Illuminate\Support\Facades\Mail; use Input; use Illuminate\Http\Request; @@ -32,9 +36,27 @@ class AdminToolsController extends Controller dd('index'); } - /** - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View - */ + public function customers() + { + + $shopping_users = CustomerPriority::checkForAll(); + $data = [ + 'values' => $shopping_users, + 'text' => '', + ]; + + return view('sys.admin.customers', $data); + } + public function customerStore() + { + $data = Input::all(); + \Session()->flash('alert-save', true); + return back(); + } + + + + public function cronjobs() { //$user_shops = UserShop::all(); @@ -48,25 +70,15 @@ class AdminToolsController extends Controller ]; return view('sys.admin.cronjobs', $data); - - - } - /** - * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View - */ public function cronjobsStore() { $data = Input::all(); \Session()->flash('alert-save', true); return back(); } - - /** - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View - */ + public function domainSSL() { $user_shops = UserShop::all(); @@ -100,10 +112,6 @@ class AdminToolsController extends Controller } - /** - * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View - */ public function domainSSLStore() { $data = Input::all(); @@ -111,10 +119,6 @@ class AdminToolsController extends Controller return back(); } - - /** - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View - */ public function shoppingOrders() { $shopping_users = ShoppingUser::all(); @@ -125,34 +129,37 @@ class AdminToolsController extends Controller return view('sys.admin.shopping-orders', $data); } - - - /** - * @return \Illuminate\Http\RedirectResponse - */ public function shoppingOrdersStore() { + //first run $data = Input::all(); - $orders = []; - $shopping_users = ShoppingUser::all(); - foreach ($shopping_users as $shopping_user){ - if(!isset($shopping_user->shopping_order)){ - $shopping_user->orders = NULL; + if($data['action'] === 'first_run'){ + $shopping_users = ShoppingUser::whereHas('shopping_order', function($q) { + $q->where('txaction', 'paid')->OrWhere('txaction', 'appointed'); + })->get(); - }else{ - if($shopping_user->shopping_order->txaction === "paid" || $shopping_user->shopping_order->txaction === "appointed") { - $orders[$shopping_user->billing_email] = isset($orders[$shopping_user->billing_email]) ? $orders[$shopping_user->billing_email] + 1 : 1; - $shopping_user->orders = $orders[$shopping_user->billing_email]; - }else{ - $shopping_user->orders = NULL; + $order_email = []; + $order_number = []; + + foreach ($shopping_users as $shopping_user){ + $order_email[$shopping_user->billing_email] = isset($order_email[$shopping_user->billing_email]) ? $order_email[$shopping_user->billing_email] + 1 : 1; + if($shopping_user->number) { + $order_number[$shopping_user->number] = isset($order_number[$shopping_user->number]) ? $order_number[$shopping_user->number] + 1 : 1; + $shopping_user->orders = $order_number[$shopping_user->number]; + }else { + $shopping_user->orders = $order_email[$shopping_user->billing_email]; } - } - $shopping_user->save(); + $shopping_user->save(); + } + \Session()->flash('alert-save', true); } - \Session()->flash('alert-save', true); + if($data['action'] === 'next_run'){ + Shop::userOrders(); + \Session()->flash('alert-save', true); + } return back(); } diff --git a/app/Http/Controllers/User/ShopSalesController.php b/app/Http/Controllers/User/ShopSalesController.php index f2fce40..59b4326 100755 --- a/app/Http/Controllers/User/ShopSalesController.php +++ b/app/Http/Controllers/User/ShopSalesController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\User; use App\Http\Controllers\Controller; use App\Models\ShoppingOrder; +use App\Services\Payment; use App\User; @@ -22,37 +23,37 @@ class ShopSalesController extends Controller return view('user.shop.sales.orders', $data); } - public function orderDetail() + public function orderDetail($id) { + $user = User::find(\Auth::user()->id); + $shopping_order = ShoppingOrder::find($id); + if(!$shopping_order){ + abort(404); + } + if($shopping_order->user_shop_id !== $user->shop->id){ + abort(404); + } $data = [ - // 'values' => Country::all(), + 'shopping_order' => $shopping_order, + 'isAdmin' => false, ]; - return view('admin.sales.customer_detail', $data); + return view('user.shop.sales.order_detail', $data); } public function ordersDatatable(){ $user = User::find(\Auth::user()->id); - $query = ShoppingOrder::with('shopping_user')->where('user_shop_id', $user->shop->id); + $query = ShoppingOrder::with('shopping_user')->select('shopping_orders.*')->where('user_shop_id', $user->shop->id); return \DataTables::eloquent($query) - ->addColumn('billing_firstname', function (ShoppingOrder $ShoppingOrder) { - return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->billing_firstname : ''; - }) - ->addColumn('billing_lastname', function (ShoppingOrder $ShoppingOrder) { - return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->billing_lastname : ''; - }) - ->addColumn('billing_email', function (ShoppingOrder $ShoppingOrder) { - return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->billing_email : ''; + ->addColumn('id', function (ShoppingOrder $ShoppingOrder) { + return ''; }) ->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) { return $ShoppingOrder->created_at->format("d.m.Y"); }) ->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) { - if($ShoppingOrder->mode === 'test'){ - return 'TEST - '.$ShoppingOrder->getFormattedTxaction().''; - } - return ''.$ShoppingOrder->getFormattedTxaction().''; + return Payment::getShoppingOrderBadge($ShoppingOrder); }) ->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) { return $ShoppingOrder->getFormattedTotalShipping(); @@ -63,22 +64,7 @@ class ShopSalesController extends Controller ->addColumn('user_shop_id', function (ShoppingOrder $ShoppingOrder) { return $ShoppingOrder->user_shop ? ''.$ShoppingOrder->user_shop->getSubdomain(false).'' : ''; }) - ->addColumn('id', function (ShoppingOrder $ShoppingOrder) { - return ''; - }) - /* ->addColumn('confirmed', function (User $user) { - return $user->confirmed ? '' : ''; - }) - ->addColumn('active', function (User $user) { - return $user->active ? ' ' : ''; - }) - ->addColumn('agreement', function (User $user) { - return $user->agreement ? ' ' : ''; - }) - ->orderColumn('confirmed', 'confirmed $1') - ->orderColumn('active', 'active $1') - ->orderColumn('agreement', 'agreement $1') - */ + ->orderColumn('id', 'id $1') ->orderColumn('txaction', 'txaction $1') ->orderColumn('user_shop_id', 'user_shop_id $1') diff --git a/app/Http/Controllers/User/TeamController.php b/app/Http/Controllers/User/TeamController.php index 57fee11..23de8fd 100755 --- a/app/Http/Controllers/User/TeamController.php +++ b/app/Http/Controllers/User/TeamController.php @@ -11,7 +11,7 @@ class TeamController extends Controller public function __construct() { - $this->middleware('active.shop'); + $this->middleware('active.account'); } public function members() diff --git a/app/Http/Controllers/Web/CheckoutController.php b/app/Http/Controllers/Web/CheckoutController.php index 5e67d8f..4bcf8c3 100755 --- a/app/Http/Controllers/Web/CheckoutController.php +++ b/app/Http/Controllers/Web/CheckoutController.php @@ -10,6 +10,7 @@ use App\Models\ShoppingOrder; use App\Models\ShoppingOrderItem; use App\Models\ShoppingPayment; use App\Models\ShoppingUser; +use App\Services\CustomerPriority; use App\User; use Illuminate\Session\SessionManager; use Illuminate\Support\Collection; @@ -310,6 +311,8 @@ class CheckoutController extends Controller if(!$shopping_user){ $shopping_user = ShoppingUser::create($data); } + //CustomerPriority + CustomerPriority::checkOne($shopping_user, true); $this->putPayments('shopping_user_id', $shopping_user->id); return $shopping_user; diff --git a/app/Mail/MailCheckout.php b/app/Mail/MailCheckout.php index b958da8..ea2c7eb 100644 --- a/app/Mail/MailCheckout.php +++ b/app/Mail/MailCheckout.php @@ -52,10 +52,6 @@ class MailCheckout extends Mailable //make Adresse } if($this->txaction === 'paid'){ - - if($this->send_link){ - - } return $this->view('emails.checkout')->with([ 'salutation' => $salutation, 'copy1line' => __('email.checkout_copy1line'), diff --git a/app/Mail/MailInfo.php b/app/Mail/MailInfo.php index 0b55138..2722b1f 100644 --- a/app/Mail/MailInfo.php +++ b/app/Mail/MailInfo.php @@ -16,46 +16,66 @@ class MailInfo extends Mailable public $subject; - public function __construct(User $user, $action) + public function __construct($user, $action) { $this->user = $user; $this->action = $action; - if($action === "delete_membership"){ + if($this->action === "delete_membership"){ $this->subject = 'Mitgliedschaft beenden - beantragt'; - + } + if($this->action === "check_is_like_customer"){ + $this->subject = 'Kunden überprüfen - Kundenhoheit'; } } public function build() { - $content = __(strtoupper($this->user->account->salutation))." "; - $content .= $this->user->account->first_name." ".$this->user->account->last_name."\n"; - $content .= $this->user->account->address."\n"; - $content .= $this->user->account->zipcode." ".$this->user->account->city."\n"; - $content .= $this->user->account->country_id ? $this->user->account->country->de."\n\n" : "\n\n"; - if($this->user->account->phone){ - $content .= "Telefon: "; - $content .= $this->user->account->pre_phone_id ? $this->user->account->pre_phone->phone." " : " "; - $content .= $this->user->account->phone; - } - if($this->user->account->mobil){ - $content .= "Mobil: "; - $content .= $this->user->account->pre_mobil_id ? $this->user->account->pre_mobil->phone." " : " "; - $content .= $this->user->account->mobil; - } - $content .= "E-Mail: ".$this->user->email; - + $content = ""; if($this->action === "delete_membership"){ + $content .= __(strtoupper($this->user->account->salutation))." "; + $content .= $this->user->account->first_name." ".$this->user->account->last_name."\n"; + $content .= $this->user->account->address."\n"; + $content .= $this->user->account->zipcode." ".$this->user->account->city."\n"; + $content .= $this->user->account->country_id ? $this->user->account->country->de."\n\n" : "\n\n"; + if($this->user->account->phone){ + $content .= "Telefon: "; + $content .= $this->user->account->pre_phone_id ? $this->user->account->pre_phone->phone." " : " "; + $content .= $this->user->account->phone; + } + if($this->user->account->mobil){ + $content .= "Mobil: "; + $content .= $this->user->account->pre_mobil_id ? $this->user->account->pre_mobil->phone." " : " "; + $content .= $this->user->account->mobil; + } + $content .= "E-Mail: ".$this->user->email; + $copy1line = "Infos zum Berater:"."\n"; $button = "zum Berater"; $title = "Ein Berater möchte seine Mitgliedschaft beenden."; + $url = route('admin_lead_edit', $this->user->id).'?show=check_lead'; } - + if($this->action === "check_is_like_customer") { + $copy1line = "Hier geht es zum Kunden:"."\n"; + $button = "zum Kunden"; + $title = "Ein Kunden muss überprüfen werden und einem Berater zugeordnet werden, da die Adresse nicht eindeutig ist."; + $url = route('admin_customer_edit', $this->user->id); + $content .= $this->user ? 'Firma: '.$this->user->billing_company."\n" : ''; + $content .= \App\Services\HTMLHelper::getSalutationLang($this->user->billing_salutation)." "; + $content .= $this->user->billing_firstname." "; + $content .= $this->user->billing_lastname."\n"; + $content .= $this->user->billing_address; + $content .= $this->user->billing_address_2 ? '/ '.$this->user->billing_address_2."\n" : "\n"; + $content .= $this->user->billing_zipcode." "; + $content .= $this->user->billing_city."\n"; + $content .= $this->user->billing_email."\n"; + $content .= $this->user->billing_phone."\n"; + $content .= $this->user->billing_country->getLocated(); + } return $this->view('emails.info')->with([ - 'url' => route('admin_lead_edit', $this->user->id).'?show=check_lead', + 'url' => $url, 'title' => $title, 'button' => $button, 'copy1line' => $copy1line, diff --git a/app/Models/ShoppingOrder.php b/app/Models/ShoppingOrder.php index ab0be95..872d6dd 100644 --- a/app/Models/ShoppingOrder.php +++ b/app/Models/ShoppingOrder.php @@ -61,6 +61,7 @@ class ShoppingOrder extends Model protected $fillable = [ 'shopping_user_id', 'auth_user_id', + 'member_id', 'country_id', 'user_shop_id', 'total', @@ -73,18 +74,6 @@ class ShoppingOrder extends Model 'mode', ]; - protected $txaction_text = [ - 'paid' => "bezahlt", - 'appointed' => "offen", - 'failed' => "abbruch", - ]; - - protected $txaction_color = [ - 'paid' => "success", - 'appointed' => "warning", - 'failed' => "danger", - ]; - public function shopping_user() { @@ -101,6 +90,11 @@ class ShoppingOrder extends Model return $this->belongsTo('App\Models\UserShop','user_shop_id'); } + //can null + public function member() + { + return $this->belongsTo('App\User','member_id'); + } //can null public function auth_user() { @@ -162,18 +156,15 @@ class ShoppingOrder extends Model } - public function getFormattedTxaction(){ - if($this->txaction && isset($this->txaction_text[$this->txaction])){ - return $this->txaction_text[$this->txaction]; + public function getItemsCount(){ + $count = 0; + if($this->shopping_order_items){ + foreach ($this->shopping_order_items as $shopping_order_item){ + $count += $shopping_order_item->qty; + } } - return "not"; - } - public function getFormattedTxactionColor(){ - if($this->txaction && isset($this->txaction_color[$this->txaction])){ - return $this->txaction_color[$this->txaction]; - } - return "danger"; + return $count; } diff --git a/app/Models/ShoppingPayment.php b/app/Models/ShoppingPayment.php index 7f75eb7..2384248 100644 --- a/app/Models/ShoppingPayment.php +++ b/app/Models/ShoppingPayment.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Services\Util; use Illuminate\Database\Eloquent\Model; /** @@ -88,4 +89,7 @@ class ShoppingPayment extends Model } } + public function getPaymentAmount(){ + return Util::formatNumber($this->amount/100)." ".$this->currency; + } } \ No newline at end of file diff --git a/app/Models/ShoppingUser.php b/app/Models/ShoppingUser.php index 82f95f4..d692325 100644 --- a/app/Models/ShoppingUser.php +++ b/app/Models/ShoppingUser.php @@ -80,7 +80,13 @@ class ShoppingUser extends Model { protected $table = 'shopping_users'; + + protected $fillable = [ + 'auth_user_id', + 'member_id', + 'number', + 'is_like', 'billing_salutation', 'billing_company', 'billing_firstname', @@ -104,10 +110,25 @@ class ShoppingUser extends Model 'shipping_city', 'shipping_country_id', 'shipping_phone', + 'notice', ]; + protected $casts = [ + 'notice' => 'array', + 'is_like' => 'bool', + 'accepted_data_checkbox' => 'bool', + 'same_as_billing' => 'bool', + ]; - + //can null + public function member() + { + return $this->belongsTo('App\User','member_id'); + } + public function auth_user() + { + return $this->belongsTo('App\User','auth_user_id'); + } public function billing_country() { return $this->belongsTo('App\Models\Country','billing_country_id'); @@ -128,4 +149,23 @@ class ShoppingUser extends Model return $this->hasOne('App\Models\ShoppingOrder','shopping_user_id'); } + public function setNotice($key, $value){ + $notice = $this->notice; + $notice[$key] = $value; + $this->notice = $notice; + $this->save(); + } + + public function getNotice($key){ + return isset($this->notice[$key]) ? $this->notice[$key] : false; + } + + public function removeNotice($key){ + $notice = $this->notice; + if(isset($notice[$key])){ + unset($notice[$key]); + } + $this->notice = $notice; + $this->save(); + } } \ No newline at end of file diff --git a/app/Models/UserAccount.php b/app/Models/UserAccount.php index 77341f3..8d0bc08 100644 --- a/app/Models/UserAccount.php +++ b/app/Models/UserAccount.php @@ -129,7 +129,6 @@ class UserAccount extends Model protected $casts = [ 'payment_data' => 'array', 'notice' => 'array', - ]; use SoftDeletes; diff --git a/app/Repositories/CustomerRepository.php b/app/Repositories/CustomerRepository.php new file mode 100644 index 0000000..f9f59d3 --- /dev/null +++ b/app/Repositories/CustomerRepository.php @@ -0,0 +1,71 @@ +model = $model; + } + + + + public function update($data) + { + + /*if($data['user_id'] === "new" || $data['user_id'] == 0){ + + $this->model = User::create([ + 'email' => $data['email'], + 'password' => env('APP_KEY'), + ]); + } + else{ + $this->model = $this->getById($data['user_id']); + } + + if(!$this->model->account_id){ + $account = new UserAccount(); + }else{ + $account = $this->model->account; + } + + $data['same_as_billing'] = !isset($data['same_as_billing']) ? 0 : 1; + + $account->fill($data)->save(); + + if(!$this->model->account_id){ + $this->model->account_id = $account->id; + $this->model->save(); + }*/ + + return true; + } + + public function create($data){ + + /* $this->model = User::create([ + 'email' => $data['email'], + 'password' => Hash::make($data['password']), + ]); + + $account = UserAccount::create([ + 'm_salutation' => $data['salutation'], + 'm_first_name' => $data['first_name'], + 'm_last_name' => $data['last_name'], + 'salutation' => $data['salutation'], + 'first_name' => $data['first_name'], + 'last_name' => $data['last_name'], + ]); + + $this->model->account_id = $account->id; + $this->model->save(); + + + return $this->model;*/ + } + + +} \ No newline at end of file diff --git a/app/Services/CustomerPriority.php b/app/Services/CustomerPriority.php new file mode 100644 index 0000000..4de4bce --- /dev/null +++ b/app/Services/CustomerPriority.php @@ -0,0 +1,201 @@ +where('number', '=', NULL)->orderBy('created_at', 'ASC')->get(); + foreach ($shopping_users as $shopping_user){ + if($shopping_user->shopping_order && $shopping_user->shopping_order->user_shop){ + self::checkOne($shopping_user); + } + } + return $shopping_users; + } + + public static function checkOne($shopping_user, $mail=false){ + //look for entry + if(self::entryExists($shopping_user)){ + return 'exists'; + } + if(self::entryLike($shopping_user)){ + if($mail){ //send mail + Mail::to(config('app.info_mail'))->send(new MailInfo($shopping_user, 'check_is_like_customer')); + } + return 'like'; + } + self::newCustomer($shopping_user); + return 'update'; + + } + + public static function setIsLike($shopping_user, $set_like_shopping_user, $send_member_mail) + { + if ($shopping_user->id === $set_like_shopping_user->id) { + //set new customer for shopping_user + self::newCustomer($shopping_user); + } else { + //set existing customer for shopping_user + self::existingCustomer($shopping_user, $set_like_shopping_user); + } + self::clearIsLike($shopping_user); + //SEND MAIL TO MEMBER + if ($send_member_mail){ + if ($shopping_user->shopping_order && $shopping_user->shopping_order->shopping_payments) { + Mail::to($shopping_user->member->email)->send(new MailCheckout($shopping_user->shopping_order->txaction, $shopping_user->shopping_order, $shopping_user->shopping_order->shopping_payments->last(), false, $shopping_user->shopping_order->mode)); + } + } + return true; + } + + public static function newMemberForOrder($shopping_order, $member_id, Bool $all = false){ + if($all){ + if($shopping_order->shopping_user && $shopping_order->shopping_user->number){ + $shopping_users = ShoppingUser::where('number', '=', $shopping_order->shopping_user->number)->get(); + $new_number = self::nextNumber(); + foreach ($shopping_users as $shopping_user) { + self::changeCustomer($shopping_user, $member_id, $new_number); + } + } + }else{ + $shopping_order->member_id = $member_id; + $shopping_order->save(); + if($shopping_order->shopping_user){ + $shopping_order->shopping_user->member_id = $member_id; + $shopping_order->shopping_user->number = self::nextNumber(); + $shopping_order->shopping_user->save(); + } + } + } + + public static function newMemberForCustomer($shopping_user, $member_id, Bool $all = false){ + if($all){ + if($shopping_user && $shopping_user->number){ + $shopping_users = ShoppingUser::where('number', '=', $shopping_user->number)->get(); + $new_number = self::nextNumber(); + foreach ($shopping_users as $s_user) { + self::changeCustomer($s_user, $member_id, $new_number); + } + } + }else{ + $shopping_user->member_id = $member_id; + $shopping_user->number = self::nextNumber(); + $shopping_user->save(); + if($shopping_user->shopping_order){ + $shopping_user->shopping_order->member_id = $member_id; + $shopping_user->shopping_order->save(); + } + } + } + + private static function entryExists($shopping_user){ + //check same email + $matches = ShoppingUser::where('auth_user_id', '=', NULL) + ->where('number', '!=', NULL) //has number + ->where('id', '!=', $shopping_user->id) + ->where('billing_email', '=', $shopping_user->billing_email)->get(); + + if($matches && count($matches)){ + $match = $matches->last(); + $shopping_user->member_id = $match->member_id; + $shopping_user->number = $match->number; + $shopping_user->save(); + //has order + if($shopping_user->shopping_order){ + $shopping_user->shopping_order->member_id = $match->member_id; + $shopping_user->shopping_order->save(); + } + return true; + } + return false; + } + + private static function entryLike($shopping_user){ + //check same last name und PLZ + $matches = ShoppingUser::select('*') + ->where('auth_user_id', '=', NULL) + ->where('number', '!=', NULL) //has number + ->where('id', '!=', $shopping_user->id) + ->where('billing_lastname', '=', $shopping_user->billing_lastname) + ->where('billing_zipcode', '=', $shopping_user->billing_zipcode) + ->get()->pluck('number', 'id')->unique()->toArray(); + if($matches && count($matches)){ + $shopping_user->is_like = true; + $shopping_user->setNotice(self::$user_notice_key, $matches); + $shopping_user->save(); + return true; + } + return false; + } + + private static function newCustomer($shopping_user){ + if($shopping_user->shopping_order && $shopping_user->shopping_order->user_shop) { + $member_id = $shopping_user->shopping_order->user_shop->user_id; + $shopping_user->member_id = $member_id; + $shopping_user->number = self::nextNumber(); + $shopping_user->save(); + $shopping_user->shopping_order->member_id = $member_id; + $shopping_user->shopping_order->save(); + } + } + + private static function changeCustomer($shopping_user, $member_id, $number){ + + $old_number = $shopping_user->number; + $shopping_user->member_id = $member_id; + $shopping_user->number = $number; + $shopping_user->save(); + if($shopping_user->shopping_order) { + $shopping_user->shopping_order->member_id = $member_id; + $shopping_user->shopping_order->save(); + } + \App\Services\Shop::newUserOrder($old_number); + \App\Services\Shop::newUserOrder($number); + + } + + private static function existingCustomer($shopping_user, $set_like_shopping_user){ + $old_number = $shopping_user->number; + + $shopping_user->member_id = $set_like_shopping_user->member_id; + $shopping_user->number = $set_like_shopping_user->number; + $shopping_user->save(); + if($shopping_user->shopping_order) { + $shopping_user->shopping_order->member_id = $set_like_shopping_user->member_id; + $shopping_user->shopping_order->save(); + } + \App\Services\Shop::newUserOrder($old_number); + \App\Services\Shop::newUserOrder($set_like_shopping_user->number); + } + + private static function clearIsLike($shopping_user){ + $shopping_user->is_like = false; + $shopping_user->removeNotice(self::$user_notice_key); + $shopping_user->save(); + + } + + private static function nextNumber (){ + if(!$number = ShoppingUser::max('number')){ + $number = self::$start_number; + } + return $number+1; + } + +} diff --git a/app/Services/HTMLHelper.php b/app/Services/HTMLHelper.php index d9ab4fc..a7167d4 100644 --- a/app/Services/HTMLHelper.php +++ b/app/Services/HTMLHelper.php @@ -282,8 +282,8 @@ class HTMLHelper return $ret; } - public static function getSponsorOptions($id, $all=false){ - $values = User::all(); + public static function getMembersOptions($id, $all=false){ + $values = User::where('active', '=', true)->where('blocked', '=', false)->where('payment_account', '>=', now())->get(); $ret = ""; if($all){ $ret .= '\n'; @@ -294,36 +294,9 @@ class HTMLHelper if($value->account){ $to = $value->account->first_name." ".$value->account->last_name." | "; } - $ret .= '\n'; + $ret .= '\n'; } return $ret; } - - - - - - /*public static function getIndustrySectorsWithoutParents($id = false, $sameId = false, $all = true){ - $values = IndustrySector::where('parent_id', null)->get(); - $ret = ""; - if($all){ - $ret .= '\n'; - } - foreach ($values as $value){ - if($sameId == $value->id){ - continue; - } - $attr = ($value->id == $id) ? 'selected="selected"' : ''; - $ret .= '\n'; - } - return $ret; - } - - - - - - - */ } \ No newline at end of file diff --git a/app/Services/Payment.php b/app/Services/Payment.php new file mode 100644 index 0000000..733db30 --- /dev/null +++ b/app/Services/Payment.php @@ -0,0 +1,55 @@ + "bezahlt", + 'appointed' => "offen", + 'failed' => "abbruch", + 'NULL' => 'keine Zahlung', + ]; + + public static $txaction_color = [ + 'paid' => "success", + 'appointed' => "warning", + 'failed' => "danger", + ]; + + + public static function getFormattedTxaction($txaction){ + if($txaction && isset(self::$txaction_text[$txaction])){ + return self::$txaction_text[$txaction]; + } + return self::$txaction_text['NULL']; + } + + public static function getFormattedTxactionColor($txaction){ + if($txaction && isset(self::$txaction_color[$txaction])){ + return self::$txaction_color[$txaction]; + } + return "warning"; + } + + public static function getShoppingOrderBadge(ShoppingOrder $shopping_order){ + if($shopping_order->mode === 'test'){ + return ''.strtoupper($shopping_order->mode).' - '.self::getFormattedTxaction($shopping_order->txaction).''; + } + return ''.self::getFormattedTxaction($shopping_order->txaction).''; + } + + public static function getShoppingPaymentBadge(ShoppingPayment $shopping_payment){ + if($shopping_payment->mode === 'test'){ + return ''.strtoupper($shopping_payment->mode).' - '.self::getFormattedTxaction($shopping_payment->txaction).''; + } + return ''.self::getFormattedTxaction($shopping_payment->txaction).''; + } + + +} diff --git a/app/Services/Shop.php b/app/Services/Shop.php new file mode 100644 index 0000000..579da65 --- /dev/null +++ b/app/Services/Shop.php @@ -0,0 +1,40 @@ +where('txaction', 'paid')->OrWhere('txaction', 'appointed'); + })->where('orders', '=', NULL)->get(); + foreach ($shopping_users as $shopping_user) { + if ($shopping_user->number) { + $orders = ShoppingUser::where('number', '=', $shopping_user->number)->max('orders'); + $orders = $orders + 1; + } else { + $orders = ShoppingUser::where('billing_email', '=', $shopping_user->billing_email)->max('orders'); + $orders = $orders + 1; + } + $shopping_user->orders = $orders; + $shopping_user->save(); + } + } + + public static function newUserOrder($number){ + $shopping_users = ShoppingUser::where('number', '=', $number)->get(); + $orders = 1; + foreach ($shopping_users as $shopping_user) { + if($shopping_user->shopping_order && ($shopping_user->shopping_order->txaction === 'paid' || $shopping_user->shopping_order->txaction === 'appointed')){ + $shopping_user->orders = $orders++; + + }else{ + $shopping_user->orders = NULL; + } + $shopping_user->save(); + + } + } +} \ No newline at end of file diff --git a/app/Services/UserService.php b/app/Services/UserService.php index d6e1a5b..b8523b9 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -6,7 +6,6 @@ use App\User; class UserService { - public static function createConfirmationCode() { $unique = false; do{ diff --git a/app/User.php b/app/User.php index 01d439b..c866b2d 100755 --- a/app/User.php +++ b/app/User.php @@ -167,18 +167,38 @@ class User extends Authenticatable return $this->hasOne('App\Models\UserShop', 'user_id', 'id'); } - public function user_update_email() { return $this->hasMany('App\Models\UserUpdateEmail', 'user_id', 'id'); } + public function member_shopping_orders() + { + return $this->hasMany('App\Models\ShoppingOrder', 'member_id', 'id'); + } + + public function member_shopping_users() + { + return $this->hasMany('App\Models\ShoppingUser', 'member_id', 'id'); + } + public function getMUserSponsor(){ if($this->user_sponsor && $this->user_sponsor->account){ return $this->user_sponsor->account->first_name." ".$this->user_sponsor->account->last_name." | ".$this->user_sponsor->email; } } + public function getFullName($email=true){ + $ret = ""; + if($this->account){ + $ret = $this->account->first_name." ".$this->account->last_name; + + } + if($email && $this->id > 1){ + $ret .= " | ".$this->email; + } + return $ret; + } /** * @return bool */ @@ -259,8 +279,7 @@ class User extends Authenticatable return $this->payment_shop ? Carbon::parse($this->payment_shop)->gt(Carbon::now()) : false; } - public function isRenewalAccount() - { + public function isRenewalAccount(){ if ($this->payment_account) { return Carbon::parse($this->payment_account)->modify('-'.(config('mivita.renewal_days')+1).' days')->lt(Carbon::now()); } diff --git a/app/helpers.php b/app/helpers.php index 3dfcaab..0a0c6c2 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -14,3 +14,31 @@ if (! function_exists('make_old_url')) { return config('app.old_url').$path; } } + +if (! function_exists('get_file_last_time')) { + function get_file_last_time($value) + { + if (file_exists($value)) { + return filemtime($value); + } + return date("Ymd-i", time()); + } +} + +if (! function_exists('get_user_attr')) { + function get_user_attr($key){ + if ($user = Auth::user()) { + return $user->getSetting($key); + } + return null; + } +} + +if (! function_exists('set_user_attr')) { + function set_user_attr($key, $value){ + if ($user = Auth::user()) { + return $user->setSetting([$key => $value]); + } + return null; + } +} \ No newline at end of file diff --git a/archiv.tar b/archiv.tar deleted file mode 100644 index d59eb89..0000000 Binary files a/archiv.tar and /dev/null differ diff --git a/database/migrations/2019_02_23_161530_create_shopping_users_table.php b/database/migrations/2019_02_23_161530_create_shopping_users_table.php index 46b9c38..29c986f 100644 --- a/database/migrations/2019_02_23_161530_create_shopping_users_table.php +++ b/database/migrations/2019_02_23_161530_create_shopping_users_table.php @@ -17,6 +17,10 @@ class CreateShoppingUsersTable extends Migration $table->increments('id'); $table->unsignedInteger('auth_user_id'); + $table->unsignedInteger('member_id')->nullable(); + + $table->unsignedInteger('number')->index()->nullable(); + $table->boolean('is_like')->default(false); $table->char('billing_salutation', 2)->nullable(); $table->string('billing_company')->nullable(); @@ -49,6 +53,7 @@ class CreateShoppingUsersTable extends Migration $table->boolean('abo_options')->default(false); + $table->text('notice')->default(false); $table->timestamps(); @@ -60,6 +65,14 @@ class CreateShoppingUsersTable extends Migration ->references('id') ->on('countries'); + $table->foreign('auth_user_id') + ->references('id') + ->on('users'); + + $table->foreign('member_id') + ->references('id') + ->on('users'); + }); } diff --git a/database/migrations/2019_02_23_163527_create_shopping_orders_table.php b/database/migrations/2019_02_23_163527_create_shopping_orders_table.php index db74d89..896fe66 100644 --- a/database/migrations/2019_02_23_163527_create_shopping_orders_table.php +++ b/database/migrations/2019_02_23_163527_create_shopping_orders_table.php @@ -22,6 +22,8 @@ class CreateShoppingOrdersTable extends Migration $table->unsignedInteger('country_id'); $table->unsignedInteger('user_shop_id'); + $table->unsignedInteger('member_id')->nullable(); + $table->unsignedTinyInteger('payment_for'); $table->decimal('total', 13, 2)->nullable(); @@ -53,6 +55,10 @@ class CreateShoppingOrdersTable extends Migration $table->foreign('user_shop_id') ->references('id') ->on('user_shops'); + + $table->foreign('member_id') + ->references('id') + ->on('users'); }); } diff --git a/public/css/application.css b/public/css/application.css index 7f82223..ab97437 100644 --- a/public/css/application.css +++ b/public/css/application.css @@ -30,4 +30,25 @@ a[aria-expanded='true'] > .fa-caret-expand:before { .custom-control-label::before { border: 1px solid rgba(182, 117, 16, 0.8); +} + +.text-muted { + color: #868686 !important; +} + +@media (min-width: 992px){ + .modal-lg { + max-width: 55rem; + } +} + +@media (min-width: 768px) { + .modal-xl { + width: 90%; + max-width:75rem; + } +} + +.text-match{ + color:#295B28; } \ No newline at end of file diff --git a/public/js/custom.js b/public/js/custom.js index 64eccf5..bb3ed0e 100644 --- a/public/js/custom.js +++ b/public/js/custom.js @@ -1,6 +1,6 @@ $(function () { // $('.selectpicker').selectpicker(); - // $('[data-toggle="tooltip"]').tooltip(); + $('[data-toggle="tooltip"]').tooltip(); }); @@ -89,171 +89,102 @@ function _scrollTo(to, offset) { $('html,body').animate({scrollTop: $(to).offset().top - offset}, 800); } -/* -$(function() { - $('.select2-main').each(function() { - $(this) - .wrap('
') - .select2({ - placeholder: 'Bitte wählen', - dropdownParent: $(this).parent(), - }); - }) - $('.select2-sub').each(function() { - $(this) - .wrap('
') - .select2({ - placeholder: 'Bitte wählen', - dropdownParent: $(this).parent(), - closeOnSelect: false - }); - }) -}); -*/ -/* -jQuery(document).ready(function() { +$(function () { - $('.main-branch').on('change', function () { - - target = $(this).data('target'); - if ($(this).is(':checked')) { - $(target).stop().show('slow'); - } else { - $(target).stop().hide('slow'); - $(target).find('.custom-control-input').prop('checked', false); + $('#modals-load-content').on('show.bs.modal', function (event) { + var button = $(event.relatedTarget); + if (!button.data('id')) { + return; } + var data = {}; + $.each(button.data(), function(index, value){ + data[index] = value; + }); + //console.log(data); + loadModalInner(this, data); + }); - var $form = $('#lead-form-validation'); - if($form.find('#company_country_id').length){ - $form.find('#company_country_id').on('change', function(){ - $form.find('#company_pre_phone_id').val($(this).val()); - $form.find('#company_pre_phone_id').selectpicker('refresh'); - }); - } - - if($form.find('#country_id').length){ - $form.find('#country_id').on('change', function(){ - $form.find('#pre_phone_id').val($(this).val()); - $form.find('#pre_phone_id').selectpicker('refresh'); - - $form.find('#pre_mobil_id').val($(this).val()); - $form.find('#pre_mobil_id').selectpicker('refresh'); - }); - } - - - -}); -*/ - -/* -function trigger_company($ele, $speed){ - if($ele.val() == 1){ - $('.show_company_holder').show($speed); - $('.show_company_holder').find('#company_name').prop('required', true); - $('.show_company_holder').find('#company_country_id').prop('required', true); - - }else{ - $('.show_company_holder').hide($speed); - $('.show_company_holder').find('#company_name').prop('required', false); - $('.show_company_holder').find('#company_country_id').prop('required', false); - } - } - - $( document ).ready(function() { - - // With validation - var $form = $('#lead-form-validation'); - $form.find('#company').on('change', function () { - trigger_company($(this), 'slow'); - }); - - trigger_company($form.find('#company'), 0); - - // Set up validator - $form.validate({ - rules: { - 'email': { - required: true, - email: true, - remote: - { - url: "{{ route('user_check_mail') }}", - type: "post", - data: - { - user_id: function() - { - return $('#lead-form-validation :input[name="user_id"]').val(); - }, - email: function() - { - return $('#lead-form-validation :input[name="email"]').val(); - } - }, - encode: true, - headers: { - 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') - }, - } - }, - 'email-confirm': { - required: true, - equalTo: "#email" - }, - 'accepted_data_protection': { - required: true - }, - }, - errorPlacement: function errorPlacement(error, element) { - $(element).parents('.form-group').append( - error.addClass('invalid-feedback small d-block') - ) - }, - highlight: function (element) { - if ($(element).hasClass('selectpicker')) { - $(element).parent().addClass('is-invalid'); - } - $(element).addClass('is-invalid'); - }, - unhighlight: function (element) { - $(element).removeClass('is-invalid'); - $(element).parents('.form-group').find('.is-invalid').removeClass('is-invalid'); - }, - messages : { - required: "{{__('This field is required.')}}", - company_country_id : { - required: "{{__('This field is required.')}}", - }, - accepted_data_protection : { - required: "{{__('This field is required.')}}", - }, - salutation : { - required: "{{__('This field is required.')}}", - }, - company_name : { - required: "{{__('This field is required.')}}", - }, - last_name : { - required: "{{__('This field is required.')}}", - }, - equalTo : "{{__('Please enter the same value again.')}}", - 'email-confirm' : { - equalTo : "{{__('Please enter the same value again.')}}", - required: "{{__('This field is required.')}}", - }, - email: { - required : "{{__('This field is required.')}}", - email: "{{ __('Please enter a valid email address.') }}", - remote : "{{ __('This E-mail is already in use.') }}" - }, - }, - onkeyup: false + function initModalInner() { + $('[data-toggle="reloadModal"]').off().on('click', function(event) { + event.preventDefault(); + button = $(this); + var data = {}; + $.each(button.data(), function(index, value){ + data[index] = value; }); + //console.log(data); + loadModalInner(this, data); + }); + } + function loadModalInner(self, data){ + var url = data.route, + contentType = 'application/x-www-form-urlencoded; charset=UTF-8'; + $.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') + }, + success: function(data) { + //console.log(data); + if(data.response.modal){ + $(data.response.target).find('.modal-dialog').addClass(data.response.modal); + } + $(data.response.target).find('.modal-dialog').html(data.html); + $(data.response.target).find('.selectpicker').selectpicker('refresh'); + initModalInner(); + }, + error: function(xhr, status, errorThrown) { + console.log(xhr); + console.log(xhr.responseText); + console.log(errorThrown); + console.log("Sorry, there was a problem!"); + } + }); + return false; + } - - - }); - */ \ No newline at end of file + function ajax_object_action(event, object, callback) { + event.preventDefault(); + var data = {}; + $.each(object.data(), function(index, value){ + if(typeof value !== 'object'){ + data[index] = value; + } + }); + var url = data['url']; + console.log(data); + console.log(url); + $.ajax({ + url: url, + data: data, + type: "POST", + dataType: "json", + cache: false, + contentType: 'application/x-www-form-urlencoded; charset=UTF-8', + encode: true, + headers: { + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') + }, + success: function(data) { + //data will send data to callback function + callback(data); + }, + error: function(xhr, status, errorThrown) { + console.log(xhr); + console.log(xhr.responseText); + console.log(status); + console.log(errorThrown); + console.log("Sorry, there was a problem!"); + } + }); + return false; + } +}); \ No newline at end of file diff --git a/resources/views/admin/customer/_detail.blade.php b/resources/views/admin/customer/_detail.blade.php new file mode 100644 index 0000000..b170871 --- /dev/null +++ b/resources/views/admin/customer/_detail.blade.php @@ -0,0 +1,326 @@ +
+ + +
+
+
+
Datum
+ {{$shopping_user->created_at->format("d.m.Y H:i")}} +
+
+
Kundennummer
+ {{$shopping_user->number}} +
+
+
ist Berater
+ @if($shopping_user->auth_user) + + + {{$shopping_user->auth_user->getFullName()}} #{{$shopping_user->auth_user->number}} + @else + + @endif +
+
+
+
+ + + + @if($isAdmin) + +
+
+
+ @if(isset($change_member_error) && $change_member_error) +
+
+
+
    +
  • {{ $change_member_error }}
  • +
+
+
+
+ @endif +
Zugewiesener Berater
+ + @if($shopping_user->is_like) + + @else + + @if($shopping_user->member) + + {{$shopping_user->member->getFullName()}} #{{$shopping_user->member->number}} + @endif + + @endif + + +
+
+
Über Shop
+ @if($shopping_user->shopping_order) + @if($shopping_user->shopping_order->user_shop->user->isActive() && $shopping_user->shopping_order->user_shop->user->isActiveShop()) + {{$shopping_user->shopping_order->user_shop->getSubdomain(false)}} + @else + {{$shopping_user->shopping_order->user_shop->getSubdomain(false)}} + @endif + @endif +
+
+
+
+ + @endif + + +
+
+ Rechnungsadresse +
+
+ @if($shopping_user->billing_company) +
+
Firma
+ {{ $shopping_user->billing_company }} +
+ @endif + +
+
Anrede
+ {{ \App\Services\HTMLHelper::getSalutationLang($shopping_user->billing_salutation) }} +
+
+
Vorname
+ {{ $shopping_user->billing_firstname }} +
+
+
Nachname
+ {{ $shopping_user->billing_lastname }} +
+
+
+
+
Straße
+ {{ $shopping_user->billing_address }} +
+
+
Zusatz
+ {{ $shopping_user->billing_address_2 }} +
+
+
PLZ
+ {{ $shopping_user->billing_zipcode }} +
+
+
Stadt
+ {{ $shopping_user->billing_city }} +
+
+
E-Mail
+ {{ $shopping_user->billing_email }} +
+
+
Telefon
+ {{ $shopping_user->billing_phone }} +
+
+
Land
+ {{ $shopping_user->billing_country->getLocated() }} +
+
+
+
+ + + +
+
+ Lieferadresse +
+ @if($shopping_user->same_as_billing) + {{__('email.checkout_mail_same_address')}} + @else +
+ @if($shopping_user->shipping_company) +
+
Firma
+ {{ $shopping_user->shipping_company }} +
+ @endif + +
+
Anrede
+ {{ \App\Services\HTMLHelper::getSalutationLang($shopping_user->shipping_salutation) }} +
+
+
Vorname
+ {{ $shopping_user->shipping_firstname }} +
+
+
Nachname
+ {{ $shopping_user->shipping_lastname }} +
+
+
+
+
Straße
+ {{ $shopping_user->shipping_address }} +
+
+
Zusatz
+ {{ $shopping_user->shipping_address_2 }} +
+
+
PLZ
+ {{ $shopping_user->shipping_zipcode }} +
+
+
Stadt
+ {{ $shopping_user->shipping_city }} +
+
+
E-Mail
+ {{ $shopping_user->shipping_email }} +
+
+
Telefon
+ {{ $shopping_user->shipping_phone }} +
+
+
Land
+ {{ $shopping_user->shipping_country->getLocated() }} +
+
+ @endif +
+
+ + + +
+
+ Bestellung +
+
+ + + + + + + + @if($shopping_user->shopping_order) + @foreach($shopping_user->shopping_order->shopping_order_items as $shopping_order_item) + + + + + + + + @endforeach + @endif + +
ProduktAnzahlPreis
+
+ @if($shopping_order_item->product->images) + @if($image = $shopping_order_item->product->images->first()) + + @endif + @endif + +
+ {{ $shopping_order_item->product->name }} + #{{ $shopping_order_item->product->number }} + + Inhalt: {{ $shopping_order_item->product->contents }}
+ Gewicht: {{ $shopping_order_item->product->weight }} g
+ Points: {{ $shopping_order_item->product->points }} +
+
+
+
+ {{ $shopping_order_item->qty }} + + {{ $shopping_order_item->getFormattedPrice() }} € +
+
+
+
+ + +
+
+ Zahlung +
+
+ + + + + + + @if($isAdmin)@endif + + + + + + + @php($count=0) + @if($shopping_user->shopping_order) + @foreach($shopping_user->shopping_order->shopping_payments as $shopping_payment) + + + + @if($isAdmin)@endif + + + + + @if($isAdmin && $shopping_payment->payment_transactions) + @php($ccount=0) + + + + + @endif + @endforeach + @endif + +
#ZahlungsartReferenznummerGesamtStatusDatum
{{++$count}}{{$shopping_payment->getPaymentType()}}{{$shopping_payment->reference}}{{$shopping_payment->getPaymentAmount()}}{!! \App\Services\Payment::getShoppingPaymentBadge($shopping_payment) !!}{{$shopping_payment->created_at->format("d.m.Y H:i")}}
{{$count}}.{{++$ccount}} + + + + + + + + + + + @foreach($shopping_payment->payment_transactions as $payment_transaction) + + + + + + + @endforeach + +
RequestStatusTX-ActionDatum
{{$payment_transaction->request}}{{$payment_transaction->status}}{{$payment_transaction->txaction}} {{$payment_transaction->errormessage}}{{$payment_transaction->created_at->format("d.m.Y H:i")}}
+
+
+
+
\ No newline at end of file diff --git a/resources/views/admin/customer/detail.blade.php b/resources/views/admin/customer/detail.blade.php new file mode 100644 index 0000000..12c74aa --- /dev/null +++ b/resources/views/admin/customer/detail.blade.php @@ -0,0 +1,12 @@ +@extends('layouts.layout-2') + +@section('content') + +

+ zurück + {{ __('Kunden Details') }} #{{$shopping_user->id}} +

+ @include('admin.customer._detail') + zurück + +@endsection \ No newline at end of file diff --git a/resources/views/admin/customer/index.blade.php b/resources/views/admin/customer/index.blade.php new file mode 100644 index 0000000..5ffa428 --- /dev/null +++ b/resources/views/admin/customer/index.blade.php @@ -0,0 +1,120 @@ +@extends('layouts.layout-2') + +@section('content') + + +

+ {{ __('Kunden') }} +

+ +
+
+
+ {{--
+ + +
--}} +
+ + +
+
+ + + +
+
+ +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
#{{__('Nummer')}}{{__('E-Mail')}}{{__('ist Berater')}}{{__('Anrede')}}{{__('Firma')}}{{__('Vorname')}}{{__('Nachname')}}{{__('PLZ')}}{{__('Stadt')}}{{__('Land')}}{{__('Käufe')}}{{__('zugewiesener Berater')}}{{__('Datum')}}
+
+ +
+
+
+ + +@endsection + diff --git a/resources/views/admin/lead/m_data_form_edit.blade.php b/resources/views/admin/lead/m_data_form_edit.blade.php index 566fdad..b53aba0 100644 --- a/resources/views/admin/lead/m_data_form_edit.blade.php +++ b/resources/views/admin/lead/m_data_form_edit.blade.php @@ -16,7 +16,7 @@
diff --git a/resources/views/admin/modal/is_like_member.blade.php b/resources/views/admin/modal/is_like_member.blade.php new file mode 100644 index 0000000..b960cd4 --- /dev/null +++ b/resources/views/admin/modal/is_like_member.blade.php @@ -0,0 +1,214 @@ +{!! Form::open(['url' => route('admin_sales_customers_detail', [$current->id]), 'class' => 'modal-content', 'enctype' => 'multipart/form-data']) !!} + + + + + + + + +{!! Form::close() !!} + + diff --git a/resources/views/admin/modal/member.blade.php b/resources/views/admin/modal/member.blade.php new file mode 100644 index 0000000..3d66c80 --- /dev/null +++ b/resources/views/admin/modal/member.blade.php @@ -0,0 +1,73 @@ +{!! Form::open(['url' => $route, 'class' => 'modal-content', 'enctype' => 'multipart/form-data']) !!} + + + +{!! Form::close() !!} + + diff --git a/resources/views/admin/product/index.blade.php b/resources/views/admin/product/index.blade.php index c685473..44c9971 100755 --- a/resources/views/admin/product/index.blade.php +++ b/resources/views/admin/product/index.blade.php @@ -6,7 +6,7 @@
{{__('Produkte')}}
diff --git a/resources/views/admin/sales/_detail.blade.php b/resources/views/admin/sales/_detail.blade.php new file mode 100644 index 0000000..5a11990 --- /dev/null +++ b/resources/views/admin/sales/_detail.blade.php @@ -0,0 +1,333 @@ + +
+ +
+ Status: + + {!! \App\Services\Payment::getShoppingOrderBadge($shopping_order); !!} + + {{$shopping_order->created_at->format("d.m.Y")}} +
+
+ + + +
+
+
+
Bestelldatum
+ {{$shopping_order->created_at->format("d.m.Y H:i")}} +
+
+
Anzahl Artikel
+ {{$shopping_order->getItemsCount()}} +
+
+
Preis gesamt
+ {{$shopping_order->getFormattedTotalShipping()}} € +
+
+
+
+ + + @if($isAdmin) + +
+
+
+ @if(isset($change_member_error) && $change_member_error) +
+
+
+
    +
  • {{ $change_member_error }}
  • +
+
+
+
+ @endif + +
Zugewiesener Berater
+ @if($isView === 'sales_user') + @if($shopping_order->user_shop) + {{$shopping_order->user_shop->title}} + @endif + @endif + + @if($isView === 'sales_customer') + @if($shopping_order->shopping_user && $shopping_order->shopping_user->is_like) + + @else + @if($shopping_order->member) + + {{$shopping_order->member->getFullName()}} #{{$shopping_order->member->number}} + @endif + + @endif + + @endif + +
+ +
+
Gekauft im Shop
+ @if($shopping_order->user_shop->user->isActive() && $shopping_order->user_shop->user->isActiveShop()) + {{$shopping_order->user_shop->getSubdomain(false)}} + @else + {{$shopping_order->user_shop->getSubdomain(false)}} + @endif +
+
+
+
+ + @endif + + +
+
+ Rechnungsadresse +
+
+ @if($shopping_order->shopping_user->billing_company) +
+
Firma
+ {{ $shopping_order->shopping_user->billing_company }} +
+ @endif + +
+
Anrede
+ {{ \App\Services\HTMLHelper::getSalutationLang($shopping_order->shopping_user->billing_salutation) }} +
+
+
Vorname
+ {{ $shopping_order->shopping_user->billing_firstname }} +
+
+
Nachname
+ {{ $shopping_order->shopping_user->billing_lastname }} +
+
+
+
+
Straße
+ {{ $shopping_order->shopping_user->billing_address }} +
+
+
Zusatz
+ {{ $shopping_order->shopping_user->billing_address_2 }} +
+
+
PLZ
+ {{ $shopping_order->shopping_user->billing_zipcode }} +
+
+
Stadt
+ {{ $shopping_order->shopping_user->billing_city }} +
+
+
E-Mail
+ {{ $shopping_order->shopping_user->billing_email }} +
+
+
Telefon
+ {{ $shopping_order->shopping_user->billing_phone }} +
+
+
Land
+ {{ $shopping_order->shopping_user->billing_country->getLocated() }} +
+
+
+
+ + + +
+
+ Lieferadresse +
+ @if($shopping_order->shopping_user->same_as_billing) + {{__('email.checkout_mail_same_address')}} + @else +
+ @if($shopping_order->shopping_user->shipping_company) +
+
Firma
+ {{ $shopping_order->shopping_user->shipping_company }} +
+ @endif + +
+
Anrede
+ {{ \App\Services\HTMLHelper::getSalutationLang($shopping_order->shopping_user->shipping_salutation) }} +
+
+
Vorname
+ {{ $shopping_order->shopping_user->shipping_firstname }} +
+
+
Nachname
+ {{ $shopping_order->shopping_user->shipping_lastname }} +
+
+
+
+
Straße
+ {{ $shopping_order->shopping_user->shipping_address }} +
+
+
Zusatz
+ {{ $shopping_order->shopping_user->shipping_address_2 }} +
+
+
PLZ
+ {{ $shopping_order->shopping_user->shipping_zipcode }} +
+
+
Stadt
+ {{ $shopping_order->shopping_user->shipping_city }} +
+
+
E-Mail
+ {{ $shopping_order->shopping_user->shipping_email }} +
+
+
Telefon
+ {{ $shopping_order->shopping_user->shipping_phone }} +
+
+
Land
+ {{ $shopping_order->shopping_user->shipping_country->getLocated() }} +
+
+ @endif +
+
+ + + +
+
+ Artikel +
+
+ + + + + + + + @foreach($shopping_order->shopping_order_items as $shopping_order_item) + + + + + + + + @endforeach + +
ProduktAnzahlPreis
+
+ @if($shopping_order_item->product->images) + @if($image = $shopping_order_item->product->images->first()) + + @endif + @endif + +
+ {{ $shopping_order_item->product->name }} + #{{ $shopping_order_item->product->number }} + + Inhalt: {{ $shopping_order_item->product->contents }}
+ Gewicht: {{ $shopping_order_item->product->weight }} g
+ Points: {{ $shopping_order_item->product->points }} +
+
+
+
+ {{ $shopping_order_item->qty }} + + {{ $shopping_order_item->getFormattedPrice() }} € +
+
+
+
+ + +
+
+ Zahlung +
+
+ + + + + + + @if($isAdmin)@endif + + + + + + + @php($count=0) + @foreach($shopping_order->shopping_payments as $shopping_payment) + + + + @if($isAdmin)@endif + + + + + @if($isAdmin && $shopping_payment->payment_transactions) + @php($ccount=0) + + + + + @endif + @endforeach + +
#ZahlungsartReferenznummerGesamtStatusDatum
{{++$count}}{{$shopping_payment->getPaymentType()}}{{$shopping_payment->reference}}{{$shopping_payment->getPaymentAmount()}}{!! \App\Services\Payment::getShoppingPaymentBadge($shopping_payment) !!}{{$shopping_payment->created_at->format("d.m.Y H:i")}}
{{$count}}.{{++$ccount}} + + + + + + + + + + + @foreach($shopping_payment->payment_transactions as $payment_transaction) + + + + + + + @endforeach + +
RequestStatusTX-ActionDatum
{{$payment_transaction->request}}{{$payment_transaction->status}}{{$payment_transaction->txaction}} {{$payment_transaction->errormessage}}{{$payment_transaction->created_at->format("d.m.Y H:i")}}
+
+
+
+ +
\ No newline at end of file diff --git a/resources/views/admin/sales/customer_detail.blade.php b/resources/views/admin/sales/customer_detail.blade.php index 6d2f615..f9aef7b 100644 --- a/resources/views/admin/sales/customer_detail.blade.php +++ b/resources/views/admin/sales/customer_detail.blade.php @@ -1,15 +1,11 @@ @extends('layouts.layout-2') @section('content') - -

- {{ __('Bestellung Kunde') }} + zurück + {{ __('Bestellung Kunde') }} #{{$shopping_order->id}}

+ @include('admin.sales._detail') + zurück - - -
-

Ansicht Bestellung

-
@endsection \ No newline at end of file diff --git a/resources/views/admin/sales/customers.blade.php b/resources/views/admin/sales/customers.blade.php index ba34ba7..e2a465f 100644 --- a/resources/views/admin/sales/customers.blade.php +++ b/resources/views/admin/sales/customers.blade.php @@ -6,12 +6,46 @@

{{ __('Bestellungen Kunden') }}

- -
-
- +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+
+
+
@@ -22,7 +56,8 @@ - + +
#{{__('Status')}} {{__('Betrag')}} {{__('Käufe')}}{{__('Shop')}}{{__('zugewiesener Berater')}}{{__('Gekauft im Shop')}}
@@ -30,29 +65,45 @@
@endsection \ No newline at end of file diff --git a/resources/views/admin/sales/user_detail.blade.php b/resources/views/admin/sales/user_detail.blade.php index 9731db1..3f3ba3d 100644 --- a/resources/views/admin/sales/user_detail.blade.php +++ b/resources/views/admin/sales/user_detail.blade.php @@ -2,13 +2,11 @@ @section('content') -

- {{ __('Bestellung Berater') }} + zurück + {{ __('Bestellung Berater') }} #{{$shopping_order->id}}

+ @include('admin.sales._detail') + zurück - -
-

Ansicht Bestellung

-
@endsection \ No newline at end of file diff --git a/resources/views/admin/sales/users.blade.php b/resources/views/admin/sales/users.blade.php index b1a9140..fcc9157 100644 --- a/resources/views/admin/sales/users.blade.php +++ b/resources/views/admin/sales/users.blade.php @@ -22,7 +22,7 @@ {{__('Status')}} {{__('Betrag')}} {{__('Käufe')}} - {{__('User-Shop')}} + {{__('Berater-Shop')}} @@ -37,13 +37,13 @@ "order": [[0, "desc" ]], "columns": [ { data: 'id', searchable: false }, - { data: 'billing_firstname', name: 'shopping_user.billing_firstname' }, - { data: 'billing_lastname', name: 'shopping_user.billing_lastname' }, - { data: 'billing_email', name: 'shopping_user.billing_email' }, + { data: 'shopping_user.billing_firstname', name: 'shopping_user.billing_firstname' }, + { data: 'shopping_user.billing_lastname', name: 'shopping_user.billing_lastname' }, + { data: 'shopping_user.billing_email', name: 'shopping_user.billing_email' }, { data: 'created_at', name: 'shopping_orders.created_at' }, { data: 'txaction', name: 'txaction' }, - { data: 'total_shipping', name: 'shopping_orders.total_shipping' }, - { data: 'orders', name: 'shopping_user.orders' }, + { data: 'total_shipping', name: 'total_shipping' }, + { data: 'shopping_user.orders', name: 'shopping_user.orders' }, { data: 'auth_user_shop', name: 'auth_user_shop' }, ], "bLengthChange": false, diff --git a/resources/views/emails/checkout.blade.php b/resources/views/emails/checkout.blade.php index ad8a116..6b03315 100644 --- a/resources/views/emails/checkout.blade.php +++ b/resources/views/emails/checkout.blade.php @@ -361,15 +361,18 @@ {{ $copy3line }}
- @if($shopping_order->user_shop) - @if($shopping_order->user_shop->title) - {{ $shopping_order->user_shop->title }}
+ @if($shopping_order->member) + @if($shopping_order->member->shop && $shopping_order->member->isActiveShop()) + @if($shopping_order->member->shop->title) + {{ $shopping_order->member->shop->title }}
+ @endif + @if($shopping_order->member->shop->contact) + {!! nl2br($shopping_order->member->shop->contact) !!}
+ @endif + {{ $shopping_order->member->shop->getSubdomain(true) }} + @else + Dein Berater: {{$shopping_order->member->getFullName()}} @endif - @if($shopping_order->user_shop->contact) - {!! nl2br($shopping_order->user_shop->contact) !!}
- @endif - {{ $shopping_order->user_shop->getSubdomain(true) }} - @endif

{{ $greetings }}
{{ $sender }} diff --git a/resources/views/emails/checkout_status.blade.php b/resources/views/emails/checkout_status.blade.php index c6127dd..009a697 100644 --- a/resources/views/emails/checkout_status.blade.php +++ b/resources/views/emails/checkout_status.blade.php @@ -349,16 +349,18 @@ {{ $copy3line }}
- - @if($shopping_order->user_shop) - @if($shopping_order->user_shop->title) - {{ $shopping_order->user_shop->title }}
+ @if($shopping_order->member) + @if($shopping_order->member->shop && $shopping_order->member->isActiveShop()) + @if($shopping_order->member->shop->title) + {{ $shopping_order->member->shop->title }}
+ @endif + @if($shopping_order->member->shop->contact) + {!! nl2br($shopping_order->member->shop->contact) !!}
+ @endif + {{ $shopping_order->member->shop->getSubdomain(true) }} + @else + Dein Berater: {{$shopping_order->member->getFullName()}} @endif - @if($shopping_order->user_shop->contact) - {!! nl2br($shopping_order->user_shop->contact) !!}
- @endif - {{ $shopping_order->user_shop->getSubdomain(true) }} - @endif

{{ $greetings }}
{{ $sender }} diff --git a/resources/views/layouts/application.blade.php b/resources/views/layouts/application.blade.php index b8654aa..2f841dc 100755 --- a/resources/views/layouts/application.blade.php +++ b/resources/views/layouts/application.blade.php @@ -53,7 +53,7 @@ @yield('styles') - + @@ -97,6 +97,12 @@ @yield('layout-content') + + + @@ -133,7 +139,7 @@ - + @yield('scripts') diff --git a/resources/views/layouts/includes/layout-sidenav.blade.php b/resources/views/layouts/includes/layout-sidenav.blade.php index e0de633..d21884e 100755 --- a/resources/views/layouts/includes/layout-sidenav.blade.php +++ b/resources/views/layouts/includes/layout-sidenav.blade.php @@ -27,7 +27,7 @@
  • {{ __('navigation.settings') }}
  • -
  • +
  • {{ __('navigation.orders') }}
  • @@ -56,6 +56,10 @@
    {{ __('navigation.member') }}
    +
  • +
    {{ __('navigation.clients') }}
    +
  • +
  • @@ -147,6 +151,9 @@
    Tools
      +
    • +
      Kunden
      +
    • Cron Jobs
    • diff --git a/resources/views/sys/admin/customers.blade.php b/resources/views/sys/admin/customers.blade.php new file mode 100644 index 0000000..bbf43b0 --- /dev/null +++ b/resources/views/sys/admin/customers.blade.php @@ -0,0 +1,51 @@ +@extends('layouts.layout-2') + +@section('content') + + @if ($errors->any()) +
      +
      +
      +
        + @foreach ($errors->all() as $error) +
      • {{ $error }}
      • + @endforeach +
      +
      +
      +
      + @endif + + +

      + Kunden +

      + + +
      + + {{--
      + + {!! Form::open(['url' => url()->current(), 'class' => '']) !!} +
      + + {{ Form::textarea('text', $text, array('class'=>'form-control', 'rows'=>20)) }} +
      + + + {!! Form::close() !!} +
      --}} + + @if(count($values)>0) +
      + + @foreach($values as $shopping_user) +
      {{$shopping_user->billing_email}} |
      +                        @if($shopping_user->shopping_order && $shopping_user->shopping_order->user_shop) {{ $shopping_user->shopping_order->user_shop->user_id}} @endif {{$shopping_user->orders}}
      + @endforeach +
      + @endif +
      + +@endsection + diff --git a/resources/views/sys/admin/shopping-orders.blade.php b/resources/views/sys/admin/shopping-orders.blade.php index 2114540..adcffe4 100644 --- a/resources/views/sys/admin/shopping-orders.blade.php +++ b/resources/views/sys/admin/shopping-orders.blade.php @@ -31,7 +31,8 @@ {{ Form::textarea('text', $text, array('class'=>'form-control', 'rows'=>1)) }}
  • - + + {!! Form::close() !!} diff --git a/resources/views/user/shop/sales/order_detail.blade.php b/resources/views/user/shop/sales/order_detail.blade.php new file mode 100644 index 0000000..81c48fd --- /dev/null +++ b/resources/views/user/shop/sales/order_detail.blade.php @@ -0,0 +1,11 @@ +@extends('layouts.layout-2') + +@section('content') +

    + zurück + {{ __('Bestellung Kunde') }} #{{$shopping_order->id}} +

    + @include('admin.sales._detail') + zurück + +@endsection \ No newline at end of file diff --git a/resources/views/user/shop/sales/orders.blade.php b/resources/views/user/shop/sales/orders.blade.php index 1e32f7a..ef791fb 100644 --- a/resources/views/user/shop/sales/orders.blade.php +++ b/resources/views/user/shop/sales/orders.blade.php @@ -14,12 +14,14 @@ + # {{__('First name')}} {{__('Last name')}} {{__('E-Mail')}} {{__('Datum')}} {{__('Status')}} {{__('Betrag')}} + @@ -33,13 +35,14 @@ "ajax": '{!! route('user_shop_orders_datatable') !!}', "order": [[0, "desc" ]], "columns": [ - // { data: 'id', searchable: false }, - { data: 'billing_firstname', name: 'shopping_user.billing_firstname' }, - { data: 'billing_lastname', name: 'shopping_user.billing_lastname' }, - { data: 'billing_email', name: 'shopping_user.billing_email' }, - { data: 'created_at', name: 'shopping_orders.created_at' }, + { data: 'id', searchable: false }, + { data: 'shopping_user.billing_firstname', name: 'shopping_user.billing_firstname' }, + { data: 'shopping_user.billing_lastname', name: 'shopping_user.billing_lastname' }, + { data: 'shopping_user.billing_email', name: 'shopping_user.billing_email' }, + { data: 'created_at', name: 'created_at' }, { data: 'txaction', name: 'txaction' }, - { data: 'total_shipping', name: 'shopping_orders.total_shipping' }, + { data: 'total_shipping', name: 'total_shipping' }, + // { data: 'shopping_user.orders', name: 'shopping_user.orders' }, ], "bLengthChange": false, "iDisplayLength": 100, diff --git a/routes/web.php b/routes/web.php index 47cd83c..26b8290 100755 --- a/routes/web.php +++ b/routes/web.php @@ -192,6 +192,8 @@ Route::domain(config('app.pre_url_crm').config('app.domain').config('app.tld_car Route::get('/home', 'HomeController@show')->name('home'); + Route::post('/modal/load', 'ModalController@load')->name('modal_load'); + /* Route::get('/user/edit', 'UserController@userEdit')->name('user_edit'); */ @@ -227,7 +229,7 @@ Route::domain(config('app.pre_url_crm').config('app.domain').config('app.tld_car //user shop Sales Route::get('/user/shop/orders', 'User\ShopSalesController@orders')->name('user_shop_orders'); - Route::get('/user/shop/order/detail', 'User\ShopSalesController@orderDetail')->name('user_shop_order_detail'); + Route::get('/user/shop/order/detail/{id}', 'User\ShopSalesController@orderDetail')->name('user_shop_order_detail'); Route::get('/user/shop/orders/datatable', 'User\ShopSalesController@ordersDatatable')->name('user_shop_orders_datatable'); @@ -296,6 +298,13 @@ Route::domain(config('app.pre_url_crm').config('app.domain').config('app.tld_car Route::get('/admin/lead/edit/{id}', 'LeadController@edit')->name('admin_lead_edit'); Route::post('/admin/lead/edit/{id}', 'LeadController@editPost')->name('admin_lead_edit'); + //leads + Route::get('/admin/customers', 'CustomerController@index')->name('admin_customers'); + Route::get('/admin/customer/edit/{id}', 'CustomerController@edit')->name('admin_customer_edit'); + Route::post('/admin/customer/edit/{id}', 'CustomerController@store')->name('admin_customer_edit'); + Route::get('/admin/customer/datatable', 'CustomerController@getCustomers')->name('admin_customer_datatable'); + + Route::get('/admin/lead/change_mail/{id}', 'UserUpdateEmailController@adminChangeMail')->name('admin_lead_change_mail'); Route::post('/admin/lead/change_mail/{id}', 'UserUpdateEmailController@adminUpdateMail')->name('admin_lead_change_mail'); @@ -312,11 +321,13 @@ Route::domain(config('app.pre_url_crm').config('app.domain').config('app.tld_car //sales Route::get('/admin/sales/users', 'SalesController@users')->name('admin_sales_users'); Route::get('/admin/sales/users/detail/{id}', 'SalesController@usersDetail')->name('admin_sales_users_detail'); + Route::post('/admin/sales/users/detail/{id}', 'SalesController@usersStore')->name('admin_sales_users_detail'); Route::get('/admin/sales/users/datatable', 'SalesController@usersDatatable')->name('admin_sales_users_datatable'); Route::get('/admin/sales/customers', 'SalesController@customers')->name('admin_sales_customers'); Route::get('/admin/sales/customers/detail/{id}', 'SalesController@customersDetail')->name('admin_sales_customers_detail'); + Route::post('/admin/sales/customers/detail/{id}', 'SalesController@customersStore')->name('admin_sales_customers_detail'); Route::get('/admin/sales/customers/datatable', 'SalesController@customersDatatable')->name('admin_sales_customers_datatable'); }); @@ -353,6 +364,9 @@ Route::domain(config('app.pre_url_crm').config('app.domain').config('app.tld_car //login pages for sysadmin Route::group(['middleware' => ['sysadmin']], function() { + Route::get('/sysadmin/tools/customers', 'SyS\AdminToolsController@customers')->name('sysadmin_tools_customers'); + Route::post('/sysadmin/tools/customers', 'SyS\AdminToolsController@customerStore')->name('sysadmin_tools_customers'); + Route::get('/sysadmin/tools/domainssl', 'SyS\AdminToolsController@domainSSL')->name('sysadmin_tools_domainssl'); Route::post('/sysadmin/tools/domainssl', 'SyS\AdminToolsController@domainSSLStore')->name('sysadmin_tools_domainssl');