Berater Bestellungen
This commit is contained in:
parent
a5db985ae8
commit
bde1095014
26 changed files with 1524 additions and 577 deletions
|
|
@ -79,39 +79,66 @@ class CustomerController extends Controller
|
|||
abort(404);
|
||||
}
|
||||
}
|
||||
if(old('email') || old('billing_email')){
|
||||
$step = 1;
|
||||
$shopping_user->same_as_billing = true;
|
||||
|
||||
$billing_email = null;
|
||||
if(!session('errors')){
|
||||
if(old('email') || old('billing_email')){
|
||||
$step = 1;
|
||||
$shopping_user->same_as_billing = true;
|
||||
$billing_email = old('email');
|
||||
}
|
||||
if(old('switcher-without-email') === 'true'){
|
||||
$step = 1;
|
||||
$shopping_user->same_as_billing = true;
|
||||
$billing_email = time()."@faker-mivita.care";
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'shopping_user' => $shopping_user,
|
||||
'isAdmin' => false,
|
||||
'isView' => $step === 0 ? 'customer' : 'customer-add',
|
||||
'step' => $step,
|
||||
'billing_email' => old('email'),
|
||||
'billing_email' => $billing_email,
|
||||
|
||||
];
|
||||
return view('user.customer.add', $data);
|
||||
}
|
||||
|
||||
private function checkShoppingUsersEmail($data){
|
||||
$rules = array(
|
||||
'email' => 'required|string|email|max:255|unique:shopping_users,billing_email',
|
||||
);
|
||||
$messages = [
|
||||
'unique' => __('validation.custom.unique_email_client'),
|
||||
];
|
||||
$validator = Validator::make(Request::all(), $rules, $messages);
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
|
||||
$rules = array(
|
||||
'email' => 'required|string|email|max:255|unique:users,email',
|
||||
);
|
||||
$messages = [
|
||||
'unique' => __('validation.custom.unique_email_member'),
|
||||
];
|
||||
$validator = Validator::make(Request::all(), $rules, $messages);
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
|
||||
return back()->withInput(Request::all());
|
||||
}
|
||||
|
||||
public function store($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
|
||||
if($id === 'new' && $data['action'] === 'add_customer_step_email'){
|
||||
$rules = array(
|
||||
'email' => 'required|string|email|max:255|unique:shopping_users,billing_email',
|
||||
);
|
||||
$messages = [
|
||||
'unique' => __('validation.custom.unique_email_client'),
|
||||
];
|
||||
$validator = Validator::make(Request::all(), $rules, $messages);
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
//okay, go to step 1
|
||||
if($id === 'new' && $data['action'] === 'add_customer_with_email'){
|
||||
return $this->checkShoppingUsersEmail($data);
|
||||
}
|
||||
if($id === 'new' && $data['action'] === 'add_customer_without_email'){
|
||||
return back()->withInput(Request::all());
|
||||
|
||||
}
|
||||
|
||||
if($data['action'] === 'shopping-user-store-new' || $data['action']==='shopping-user-store'){
|
||||
|
|
@ -159,6 +186,7 @@ class CustomerController extends Controller
|
|||
CustomerPriority::checkChangeOne($shopping_user, $data, true);
|
||||
$shopping_user->fill($data);
|
||||
$shopping_user->save();
|
||||
|
||||
}
|
||||
|
||||
if($id === 'new' && $data['action'] === 'shopping-user-store-new') {
|
||||
|
|
@ -169,6 +197,10 @@ class CustomerController extends Controller
|
|||
}
|
||||
\App\Services\Shop::newUserOrder($shopping_user->number);
|
||||
|
||||
if($shopping_user->is_like){
|
||||
\Session()->flash('custom-error', __('validation.custom.match_found'));
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('user_customer_detail', [$shopping_user->id]));
|
||||
}
|
||||
|
|
@ -209,7 +241,7 @@ class CustomerController extends Controller
|
|||
return get_active_badge($ShoppingUser->subscribed);
|
||||
})
|
||||
->addColumn('status', function (ShoppingUser $ShoppingUser) {
|
||||
return $ShoppingUser->is_like ? '<span class="badge badge-pill badge-warning"><i class="fa fa-clock"></i> in Prüfung</span> ' : '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> aktiv</span>';
|
||||
return $ShoppingUser->is_like ? '<span class="badge badge-pill badge-warning"><i class="fa fa-clock"></i> in Prüfung</span> ' : '<span class="badge badge-pill badge-success"><i class="fa fa-check-circle"></i> zugewiesen</span>';
|
||||
})
|
||||
->addColumn('extras', function (ShoppingUser $ShoppingUser) {
|
||||
return $ShoppingUser->wp_order_number.($ShoppingUser->mode==='dev' ? ' <span class="badge badge-warning">dev</span>' : '');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue