User Order step1

This commit is contained in:
Kevin Adametz 2020-08-07 16:02:03 +02:00
parent eb55b01b0d
commit a5db985ae8
90 changed files with 6439 additions and 421 deletions

View file

@ -4,8 +4,11 @@ namespace App\Http\Controllers;
use App\Models\PaymentMethod;
use App\Models\UserAccount;
use App\Repositories\UserRepository;
use App\Services\HTMLHelper;
use App\Services\SysLog;
use App\User;
use Auth;
use Illuminate\Support\Facades\Mail;
@ -63,6 +66,11 @@ class AdminUserController extends Controller
if(isset($data['save-admin'])){
$user->admin = $data['admin'];
SysLog::action('save-admin', 'admin_user', 3)
->setUserId(Auth::user()->id)
->setModel($user->id, User::class)
->setMessage('Set user admin value: '.HTMLHelper::getRoleLabel($user->admin))
->save();
}
if(isset($data['save-confirmed'])){
@ -77,10 +85,14 @@ class AdminUserController extends Controller
}else{
$user->confirmation_date = null;
}
SysLog::action('save-confirmed', 'admin_user', 3)
->setUserId(Auth::user()->id)
->setModel($user->id, User::class)
->setMessage('Set user confirmed value: '.$user->confirmed." to date: ".$data['confirmation_date'])
->save();
}
if(isset($data['save-active'])){
$data['active'] = isset($data['active']) ? true : false;
$user->active = $data['active'];
if($data['active']){
@ -92,28 +104,59 @@ class AdminUserController extends Controller
}else{
$user->active_date = null;
}
SysLog::action('save-active', 'admin_user', 3)
->setUserId(Auth::user()->id)
->setModel($user->id, User::class)
->setMessage('Set user active value: '.$user->active." to date: ".$data['active_date'])
->save();
}
if(isset($data['save-account'])){
$old = $user->getPaymentAccountDateFormat(true);
if(!isset($data['payment_account']) || $data['payment_account'] == ""){
$user->payment_account = null;
}else{
$user->wizard = 100;
$user->payment_account = \Carbon::parse(str_replace("- ", "", $data['payment_account']));
}
SysLog::action('save-account', 'admin_user', 3)
->setUserId(Auth::user()->id)
->setModel($user->id, User::class)
->setMessage('Set user payment_account from date: '.$old." to date: ".$data['payment_account'])
->save();
}
if(isset($data['save-shop'])){
$old = $user->getPaymentShopDateFormat(true);
if(!isset($data['payment_shop']) || $data['payment_shop'] == ""){
$user->payment_shop = null;
}else{
$user->wizard = 100;
$user->payment_shop = \Carbon::parse(str_replace("- ", "", $data['payment_shop']));
}
SysLog::action('save-shop', 'admin_user', 3)
->setUserId(Auth::user()->id)
->setModel($user->id, User::class)
->setMessage('Set user payment_shop from date: '.$old." to date: ".$data['payment_shop'])
->save();
}
if(isset($data['save-test_mode'])){
$user->test_mode = isset($data['test_mode']) ? true : false;;
$user->test_mode = isset($data['test_mode']) ? true : false;
SysLog::action('save-test_mode', 'admin_user', 3)
->setUserId(Auth::user()->id)
->setModel($user->id, User::class)
->setMessage('Set user test_mode value: '.$user->test_mode)
->save();
}
if(isset($data['save-payment_methods'])){
$user->payment_methods = isset($data['payment_methods']) ? array_map('intval', $data['payment_methods']) : null;
SysLog::action('save-payment_methods', 'admin_user', 3)
->setUserId(Auth::user()->id)
->setModel($user->id, User::class)
->setMessage('Set user payment_methods value: '.$user->getPaymentMethodsShort())
->save();
}
$user->save();

View file

@ -132,36 +132,36 @@ idWkvklsQLI+qGu41SWyxP7x09fn1txDAXYw+zuLXfdKiXyaNb78yvBXAfCNP6CH
MntHWpdLgtJmwsQt6j8k9Kf5qLnjatkYYaA7jBU=
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIFdzCCBF+gAwIBAgIQE+oocFv07O0MNmMJgGFDNjANBgkqhkiG9w0BAQwFADBv
MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk
ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF
eHRlcm5hbCBDQSBSb290MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFow
gYgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpOZXcgSmVyc2V5MRQwEgYDVQQHEwtK
ZXJzZXkgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMS4wLAYD
VQQDEyVVU0VS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9ffgZGclCKxO/WIu6pKJmBHaIkU4MiRTOok3JMrO66BQavHHxW/BBC5gA
CiIDEOUMsfnNkjcZ7Tvx5Dq2+UUTJnWvu6rvP3t3O9LEApE9GQDTF1w52z97GA1F
zZOFli9d31kWTz9RvdVFGD/tSo7oBmF0Ixa1DVBzJ0RHfxBdiSprhTEUxOipakyA
vGp4z7h/jnZymQyd/teRCBaho1+V
-----END CERTIFICATE-----";

View file

@ -86,8 +86,11 @@ class PayoneController extends Controller
die();
}
$price = intval($data['price']*100);
if($shopping_payment->amount != $price){
$price = number_format((round($data['price'],2) * 100), 0, '.', '');
$price_amount = number_format($shopping_payment->amount, 0, '.', '');
if($price_amount != $price){
$data['shopping_payment-amount'] = $price_amount;
$data['price-amount'] = $price;
\Log::channel('payone')->error('PaymentStatus: Price error: '.json_encode($data));
echo "PaymentStatus: Price error:";
var_dump($data);

View file

@ -229,6 +229,7 @@ class ShoppingUserController extends Controller
'wp_order' => 'required',
]);
$shopping_user = ShoppingUser::where('wp_order_number', '=', $request->wp_order_number)->first();
if (!$shopping_user) {
return response()->json([
@ -251,7 +252,10 @@ class ShoppingUserController extends Controller
}else{
$wp_order = $request->wp_order;
}
$wp_order = $this->prepareOrder($wp_order, $shopping_user);
$wp_invoice_path = isset($request->wp_invoice_path) ? $request->wp_invoice_path : null;
$wp_order = $this->prepareOrder($wp_order, $shopping_user, $wp_invoice_path);
//TODO Status
if ($wp_order){
$user = $this->prepareForShow($shopping_user);
@ -260,6 +264,7 @@ class ShoppingUserController extends Controller
'success' => true,
'data' => [
'wp_order_number' => $shopping_user->wp_order_number,
'wp_invoice_path' => $wp_invoice_path,
'wp_order' => $wp_order,
'user' => $user,
'order' => $order,
@ -351,6 +356,7 @@ class ShoppingUserController extends Controller
}
$ret = [
'country' => isset($shopping_order->shipping_country->country->code) ? $shopping_order->shipping_country->country->code : '',
'wp_invoice_path' => $shopping_order->wp_invoice_path,
'total' => ($shopping_order->total*100),
'shipping' => ($shopping_order->shipping*100),
'total_net' => ($shopping_order->subtotal*100),
@ -374,18 +380,21 @@ class ShoppingUserController extends Controller
private function prepareForUpdate($data){
//$salutation = array(1 => 'mr', 2 => 'ms', 3=>null);
if(isset($data['billing_salutation'])){
$data['billing_salutation'] = (int) $data['billing_salutation'];
$data['billing_salutation'] = $data['billing_salutation'] == 2 ? 'ms' : 'mr';
}
if(isset($data['shipping_salutation'])){
$data['shipping_salutation'] = (int) $data['shipping_salutation'];
$data['shipping_salutation'] = $data['shipping_salutation'] == 2 ? 'ms' : 'mr';
}
$ret = [];
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_phone', 'billing_email', 'same_as_billing',
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_phone'];
foreach ($data as $key=>$value){
if($key === 'billing_salutation') {
$ret['billing_salutation'] = $data['billing_salutation'] == 2 ? 'ms' : 'mr';
}
if($key === 'shipping_salutation') {
$ret['shipping_salutation'] = $data['shipping_salutation'] == 2 ? 'ms' : 'mr';
}
if($key === 'billing_country_code' && isset($data['billing_country_code'])) {
$ret['billing_country_id'] = Country::getCountryIdByCodeOrOne($data['billing_country_code']);
}
@ -408,6 +417,14 @@ class ShoppingUserController extends Controller
private function prepareForStore($data){
//$salutation = array(1 => 'mr', 2 => 'ms', 3=>null);
if(isset($data['billing_salutation'])){
$data['billing_salutation'] = (int) $data['billing_salutation'];
$data['billing_salutation'] = $data['billing_salutation'] == 2 ? 'ms' : 'mr';
}
if(isset($data['shipping_salutation'])){
$data['shipping_salutation'] = (int) $data['shipping_salutation'];
$data['shipping_salutation'] = $data['shipping_salutation'] == 2 ? 'ms' : 'mr';
}
$ret = [];
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_country_id', 'billing_phone', 'billing_email',
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_country_id', 'shipping_phone',
@ -417,13 +434,6 @@ class ShoppingUserController extends Controller
foreach ($needs as $need){
$ret[$need] = isset($data[$need]) ? $data[$need] : null;
if ($need === 'billing_salutation' && $ret[$need] !== null) {
$ret['billing_salutation'] = $ret['billing_salutation'] == 2 ? 'ms' : 'mr';
}
if ($need === 'shipping_salutation' && $ret[$need] !== null) {
$ret['shipping_salutation'] = $ret['shipping_salutation'] == 2 ? 'ms' : 'mr';
}
if ($need === 'billing_country_id') {
$ret['billing_country_id'] = isset($data['billing_country_code']) ? Country::getCountryIdByCodeOrOne($data['billing_country_code']) : 1;
}
@ -448,7 +458,7 @@ class ShoppingUserController extends Controller
return $ret;
}
private function prepareOrder($wp_shopping_order, $shopping_user){
private function prepareOrder($wp_shopping_order, $shopping_user, $wp_invoice_path){
Yard::instance('shopping')->destroy();
$ret = [];
@ -479,14 +489,14 @@ class ShoppingUserController extends Controller
if($ShippingCountry){
Yard::instance('shopping')->setShippingCountryWithPrice($ShippingCountry->id);
}
$shopping_order = $this->makeShoppingOrder($shopping_user);
$shopping_order = $this->makeShoppingOrder($shopping_user, $wp_invoice_path);
$shopping_user->shopping_order = $shopping_order;
Yard::instance('shopping')->destroy();
}
return $ret;
}
private function makeShoppingOrder($shopping_user){
private function makeShoppingOrder($shopping_user, $wp_invoice_path){
$data = [
'shopping_user_id' => $shopping_user->id,
@ -503,6 +513,7 @@ class ShoppingUserController extends Controller
'weight' => Yard::instance('shopping')->weight(),
'paid' => true,
'txaction' => 'extern',
'wp_invoice_path' => $wp_invoice_path,
'mode' => $shopping_user->mode,
];
$shopping_order = $shopping_user->shopping_order;

View file

@ -163,9 +163,6 @@ class CustomerController extends Controller
return get_active_badge($ShoppingUser->auth_user_id).($ShoppingUser->mode==='dev' ? ' <span class="badge badge-warning">dev</span>' : '');
})
->addColumn('member_id', function (ShoppingUser $ShoppingUser) {
if($ShoppingUser->member_id){
return '<a href="'.route('admin_lead_edit', [$ShoppingUser->member_id]).'">'.$ShoppingUser->member->getFullName().'</a>';
}
if($ShoppingUser->is_like){
return '<button type="button" class="btn btn-xs btn-outline-info" data-toggle="modal" data-target="#modals-load-content"
data-id="'.$ShoppingUser->id.'"
@ -174,6 +171,10 @@ class CustomerController extends Controller
data-modal="modal-xl"
data-route="'.route('modal_load').'"><span class="fa fa-edit"></span> Berater zuordnen</button>';
}
if($ShoppingUser->member_id){
return '<a href="'.route('admin_lead_edit', [$ShoppingUser->member_id]).'">'.$ShoppingUser->member->getFullName().'</a>';
}
return '';
})
->addColumn('created_at', function (ShoppingUser $ShoppingUser) {

View file

@ -70,10 +70,21 @@ class DataTableController extends Controller
return $user->shop->getActiveDateFormatSmall();
}
return "-";
})
->addColumn('my_payment_methods', function (User $user) {
$payment_methods = json_encode($user->payment_methods);
$link = '<a href="#" data-toggle="modal" data-target="#modals-payment_methods" data-id="'.$user->id.'" data-email="'.$user->email.'" data-payment_methods="'.htmlspecialchars($payment_methods).'">';
if(!$user->payment_methods){
return $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
}
return $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$user->getPaymentMethodsShort().'</span></a>';
})
->addColumn('action_delete', function (User $user) {
return '<a href="' . route('admin_user_delete', [$user->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>
<a href="' . route('admin_user_login_as', [$user->id]) . '" class="btn icon-btn btn-sm btn-warning" onclick="return confirm(\''.__('Login as User?').'\');"><span class="fa fa-sign-in-alt"></span></a>';
return '<span class="no-line-break"><a href="' . route('admin_user_delete', [$user->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>
<a href="' . route('admin_user_login_as', [$user->id]) . '" class="btn icon-btn btn-sm btn-warning" onclick="return confirm(\''.__('Login as User?').'\');"><span class="fa fa-sign-in-alt"></span></a></span>';
})
->addColumn('test_mode', function (User $user) {
$link = '<a href="#" data-toggle="modal" data-target="#modals-test_mode" data-id="'.$user->id.'" data-email="'.$user->email.'" data-test_mode="'.$user->test_mode.'">';
@ -85,7 +96,7 @@ class DataTableController extends Controller
->orderColumn('active', 'active $1')
->orderColumn('shop', 'shop $1')
->orderColumn('admin', 'active $1')
->rawColumns(['id', 'admin', 'confirmed', 'active', 'account', 'shop', 'test_mode', 'action_delete'])
->rawColumns(['id', 'admin', 'confirmed', 'active', 'account', 'shop', 'my_payment_methods', 'test_mode', 'action_delete'])
->make(true);
}
}

View file

@ -344,6 +344,9 @@ class LeadController extends Controller
->addColumn('last_name', function (User $user) {
return $user->account ? $user->account->last_name : '';
})
->addColumn('user_level', function (User $user) {
return $user->user_level ? $user->user_level->name : '';
})
->addColumn('id', function (User $user) {
return '<a href="' . route('admin_lead_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
})

View file

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Models\Product;
use App\Models\ShoppingOrder;
use App\Models\ShoppingUser;
@ -42,6 +43,25 @@ class ModalController extends Controller
}
$ret = view("admin.modal.is_like_member", compact('current', 'possibles', 'data'))->render();
}
if($data['action'] === 'user-order-show-product'){
$product = Product::find($data['id']); //current user form order
$ret = view("admin.modal.show_product", compact('product', 'data'))->render();
}
if($data['action'] === 'user-order-my-delivery-show'){
$user = \Auth::user();
$ret = view("admin.modal.show_user_customers", compact('user', 'data'))->render();
}
if($data['action'] === 'user-order-my-delivery-add'){
$user = \Auth::user();
/* $product = Product::find($data['id']); //current user form order
$ret = view("admin.modal.show_product", compact('product', 'data'))->render(); */
}
}

View file

@ -0,0 +1,87 @@
<?php
namespace App\Http\Controllers;
use App\Models\PaymentMethod;
use App\Models\UserLevel;
use Request;
class PaymentMethodController extends Controller
{
public function __construct()
{
$this->middleware('admin');
}
public function index()
{
$data = [
'values' => PaymentMethod::all(),
'trans' => array_keys(config('localization.supportedLocales')),
];
return view('admin.payment_method.index', $data);
}
public function store()
{
$data = Request::all();
if($data['id'] === "new"){
$model = PaymentMethod::create([
'name' => $data['name'],
'short' => $data['short'],
'pos' => $data['pos'],
'show_at' => $data['show_at'],
'default' => isset($data['default']) ? true : false,
'active' => isset($data['active']) ? true : false,
]);
}else{
$model = PaymentMethod::find($data['id']);
$model->name = $data['name'];
$model->short = $data['short'];
$model->pos = $data['pos'];
$model->show_at = $data['show_at'];
$model->default = isset($data['default']) ? true : false;
$model->active = isset($data['active']) ? true : false;
$model->save();
}
/* if(!empty($data['trans'])){
$trans = [];
foreach ($data['trans'] as $lang => $value){
if($value && $value != null){
$trans[$lang] = $value;
}
}
if(count($trans)){
$model->trans_name = $trans;
$model->save();
}
}*/
\Session()->flash('alert-save', '1');
return redirect(route('admin_payment_methods'));
}
/*public function delete($id){
if(ProductAttribute::where('attribute_id', $id)->count()){
\Session()->flash('alert-error', 'Eintrag wird als Produktattribute verwendet');
return redirect(route('admin_product_attributes'));
}
$model = Attribute::findOrFail($id);
$model->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect(route('admin_product_attributes'));
}
*/
}

View file

@ -41,7 +41,7 @@ class ProductController extends Controller
public function edit($id)
{
if($id == "new"){
if($id === "new"){
$model = new Product();
$model->active = true;
}else{
@ -66,7 +66,7 @@ class ProductController extends Controller
);
$validator = Validator::make(Request::all(), $rules);
if($data['id'] == "new"){
if($data['id'] === "new"){
$model = new Product();
}else{
$model = Product::findOrFail($data['id']);

View file

@ -34,7 +34,7 @@ class ShippingController extends Controller
public function edit($shipping_id)
{
if($shipping_id == "new"){
if($shipping_id === "new"){
$shipping = new Shipping();
$shipping->active = 1;

View file

@ -0,0 +1,50 @@
<?php
namespace App\Http\Controllers\SyS;
use App\Http\Controllers\Controller;
use App\Models\SySetting;
use Request;
class SettingController extends Controller
{
protected $userRepo;
public function __construct()
{
$this->middleware('sysadmin');
}
public function index()
{
$data = [
'values' => SySetting::all(),
];
return view('sys.settings.index', $data);
}
public function store()
{
$data = Request::all();
$data['active'] = isset($data['active']) ? true : false;
if($data['id'] === "new"){
$model = SySetting::create($data);
}else{
$model = SySetting::find($data['id']);
$model->fill($data);
$model->save();
}
\Session()->flash('alert-save', '1');
return redirect(route('sysadmin_settings'));
}
}

View file

@ -7,10 +7,12 @@ use App\Http\Controllers\Api\KasController;
use App\Http\Controllers\Api\KasSLLController;
use App\Http\Controllers\Controller;
use App\Mail\MailInfo;
use App\Models\PaymentMethod;
use App\Models\ShoppingUser;
use App\Models\UserShop;
use App\Services\CustomerPriority;
use App\Services\Shop;
use App\User;
use Auth;
use Illuminate\Support\Facades\Mail;
use Request;
@ -50,6 +52,15 @@ class AdminToolsController extends Controller
public function customerStore()
{
$data = Request::all();
$ret = "";
if($data['action'] === 'makePaymentMethodsDefault'){
$users = User::where('payment_methods', '=', NULL)->get();
//$users = User::all();
foreach ($users as $user){
$user->payment_methods = PaymentMethod::getDefaultAsArray();
$user->save();
}
}
if($data['action'] === 'checkForAll'){
$shopping_users = CustomerPriority::checkForAll();
}

View file

@ -177,9 +177,9 @@ class CustomerController extends Controller
{
$user = User::find(\Auth::user()->id);
$query = ShoppingUser::select(['id', 'billing_company', 'billing_salutation', 'billing_firstname', 'billing_lastname', 'billing_email', 'billing_zipcode', 'billing_city', 'billing_country_id', 'orders', 'subscribed', 'created_at', 'number', 'mode', 'wp_order_number'])
$query = ShoppingUser::select(['id', 'billing_company', 'billing_salutation', 'billing_firstname', 'billing_lastname', 'billing_email', 'billing_zipcode', 'billing_city', 'billing_country_id', 'orders', 'subscribed', 'created_at', 'number', 'mode', 'is_like', 'wp_order_number'])
->where('shopping_users.member_id', '=', $user->id);
//->groupBy('shopping_users.number');
//->groupBy('shopping_users.number');
/*set_user_attr('filter_member_id', Request::get('filter_member_id'));
if(Request::get('filter_member_id') != ""){
@ -187,8 +187,11 @@ class CustomerController extends Controller
}*/
return \DataTables::eloquent($query)
->addColumn('send_to', function (ShoppingUser $ShoppingUser) {
return $ShoppingUser->is_like ? '<span class="badge badge-pill badge-warning"><i class="fa fa-clock"></i> in Prüfung</span>' : '<a href="' . route('user_order_my_delivery', ['ot', $ShoppingUser->id]) . '" class="btn btn-sm btn-secondary"><span class="fa fa-shopping-cart"></span> wählen</a>';
})
->addColumn('id', function (ShoppingUser $ShoppingUser) {
return '<a href="' . route('user_customer_detail', [$ShoppingUser->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
return '<a href="' . route('user_customer_detail', [$ShoppingUser->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
})
->addColumn('billing_salutation', function (ShoppingUser $ShoppingUser) {
return HTMLHelper::getSalutationLang($ShoppingUser->billing_salutation);
@ -205,16 +208,20 @@ class CustomerController extends Controller
->addColumn('subscribed', function (ShoppingUser $ShoppingUser) {
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>';
})
->addColumn('extras', function (ShoppingUser $ShoppingUser) {
return $ShoppingUser->wp_order_number.($ShoppingUser->mode==='dev' ? ' <span class="badge badge-warning">dev</span>' : '');
})
->orderColumn('send_to', 'id $1')
->orderColumn('id', 'id $1')
->orderColumn('billing_country_id', 'billing_country_id $1')
->orderColumn('billing_salutation', 'billing_salutation $1')
->orderColumn('first_created_at', 'created_at $1')
->orderColumn('orders', 'orders $1')
->orderColumn('subscribed', 'subscribed $1')
->rawColumns(['id', 'subscribed', 'extras'])
->rawColumns(['send_to', 'id', 'subscribed', 'extras', 'status'])
->make(true);
}
}

View file

@ -0,0 +1,187 @@
<?php
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use App\Models\Product;
use App\Models\ShoppingOrder;
use App\Models\ShoppingUser;
use App\Services\HTMLHelper;
use App\Services\Payment;
use App\User;
use Request;
class OrderController extends Controller
{
public function __construct()
{
$this->middleware('active.shop');
}
public function index()
{
$data = [
];
return view('user.order.index', $data);
}
public function detail($id)
{
$user = User::find(\Auth::user()->id);
$shopping_order = ShoppingOrder::findOrFail($id);
if($shopping_order->member_id !== $user->id){
abort(404);
}
$data = [
'shopping_order' => $shopping_order,
'isAdmin' => false,
];
return view('user.shop.sales.order_detail', $data);
}
public function delivery($for, $id=null)
{
$user = User::find(\Auth::user()->id);
/*if (Request::isMethod('post')) {
$data = Request::all();
if($data['switchers-radio-is-for'] === 'is-for-member'){
return redirect(route('user_order_my_list', ['me']));
}
if($data['switchers-radio-is-for'] === 'is-for-customer'){
//check ist customer
return redirect(route('user_order_my_list', ['ot', $id]));
}
}*/
$shopping_user = null;
$delivery_id = null;
if($for === 'ot'){
$shopping_user = $this->checkShoppingUser($id, $user);
$delivery_id = $shopping_user->id;
}
$data = [
'shopping_user' => $shopping_user,
'isAdmin' => false,
'isView' => 'customer',
'for' => $for,
'delivery_id' => $delivery_id,
];
return view('user.order.delivery', $data);
}
public function list($for, $id=null)
{
$user = User::find(\Auth::user()->id);
$shopping_user = null;
$delivery_id = null;
if($for === 'ot'){
$shopping_user = $this->checkShoppingUser($id, $user);
$delivery_id = $shopping_user->id;
}
//$data = Request::all();
//dd(session('switchers-radio-is-for'));
//$shopping_user = new ShoppingUser();
//$shopping_user->id = "new";
//$shopping_user->same_as_billing = true;
$data = [
'shopping_user' => $shopping_user,
'user' => $user,
'isAdmin' => false,
'isView' => 'customer',
'for' => $for,
'delivery_id' => $delivery_id,
];
return view('user.order.list', $data);
}
private function checkShoppingUser($id, $user){
if($id === null){
abort(403, 'Error: Keine User ID');
}
$shopping_user = ShoppingUser::findOrFail($id);
if($shopping_user->member_id !== $user->id){
abort(403, 'Error: Falsche User ID');
}
$shopping_user = ShoppingUser::findOrFail($id);
if($shopping_user->is_like){
abort(403, 'Error: Kunde in Prüfung');
}
return $shopping_user;
}
public function datatable(){
// $user = User::find(\Auth::user()->id);
$query = Product::select('products.*')->where('active', true)
->where('show_at', '=', 1); //Kunden und Berater
//->orWhere('show_at', '=', 2); // Nur Berater
//->orderBy('pos', 'DESC')
//->orderBy('id', 'DESC');
return \DataTables::eloquent($query)
->addColumn('add_card', function (Product $product) {
return '<a href="#" class="btn btn-sm btn-md-extra btn-secondary">
<strong>&euro; '.$product->getFormattedPriceWith().'</strong>&nbsp; +<span class="ion ion-md-cart"></span>
</a>';
/*'<a href="javascript:void(0)" class="btn btn-secondary btn-sm my-1 mx-2">
<i class="ion ion-md-add"></i> <i class="ion ion-md-basket"></i>
</a><br>
<a href="javascript:void(0)" class="btn btn-outline-secondary btn-sm my-1 mx-2">
<i class="ion ion-md-remove"></i> <i class="ion ion-md-basket"></i>
</a>'*/;
})
->addColumn('quantity', function (Product $product) {
//return '<input type="text" class="form-control text-center" value="0" style="width: 4em">';
return '<div class="no-line-break input-group-min-w">
<div class="input-group d-inline-flex w-auto">
<span class="input-group-prepend">
<button class="btn btn-secondary icon-btn md-btn-extra" type="button">-</button>
</span>
<input type="text" class="form-control text-center input-extra" value="0">
<span class="input-group-append">
<button class="btn btn-secondary icon-btn md-btn-extra" type="button">+</button>
</span>
</div>
</div>';
})
->addColumn('picture', function (Product $product) {
if(count($product->images)){
return '<img class="img-fluid img-extra" alt="" src="'.route('product_image', [$product->images->first()->slug]).'">';
}
return "";
})
->addColumn('price', function (Product $product) {
return $product->getFormattedPriceWith();
})
->addColumn('action', function (Product $product) {
return '<button class="btn btn-default btn-sm icon-btn md-btn-flat product-tooltip" title="details" data-modal="modal-lg"
data-toggle="modal" data-target="#modals-load-content" data-id="'.$product->id.'" data-route="'.route('modal_load').'"
data-action="user-order-show-product" data-view="customer"><i class="ion ion-md-eye"></i></button>';
})
->orderColumn('name', 'name $1')
->orderColumn('number', 'number $1')
->orderColumn('points', 'points $1')
->orderColumn('price', 'price $1')
->orderColumn('contents_total', 'contents_total $1')
->orderColumn('weight', 'weight $1')
->rawColumns(['add_card', 'quantity', 'picture', 'action'])
->make(true);
}
}

View file

@ -41,16 +41,25 @@ class ContactController extends Controller
$user_shop = Util::getUserShop();
$rules = array(
'first_name'=>'required',
'last_name'=>'required',
'email'=>'required|email',
'message'=>'required',
'g-recaptcha-response'=>'required|recaptcha',
'salutation' => 'required',
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required|email',
'message' => 'required',
'g-recaptcha-response' => 'required|recaptcha',
'accepted_data_protection' => 'required',
);
if (!$user_shop || $user_shop->id === 22) {
$rules['sales_partnership'] = 'required';
if (Request::get('sales_partnership') === 'JA') {
$rules['sales_partnership_message'] = 'required';
}
}
Validator::extend('recaptcha', function($attribute, $value, $parameters, $validator) {
Validator::extend('recaptcha', function ($attribute, $value, $parameters, $validator) {
return $this->reCaptcha_validate($attribute, $value, $parameters, $validator);
});
@ -60,15 +69,20 @@ class ContactController extends Controller
}
$contact = [];
$contact['first_name'] = Request::get('first_name');
$contact['last_name'] = Request::get('last_name');
$contact['email'] = Request::get('email');
$contact['phone'] = Request::get('phone');
$contact['subject'] = Request::get('subject');
$contact['message'] = Request::get('message');
$contact = [];
$contact['salutation'] = Request::get('salutation');
$contact['first_name'] = Request::get('first_name');
$contact['last_name'] = Request::get('last_name');
$contact['email'] = Request::get('email');
$contact['phone'] = Request::get('phone');
$contact['message'] = Request::get('message');
if (!$user_shop){
$contact['sales_partnership'] = Request::get('sales_partnership');
$contact['sales_partnership_message'] = Request::get('sales_partnership_message');
}
$checkout_mail = config('app.checkout_mail');
$checkout_mail = config('app.checkout_mail');
if($user_shop){
Mail::to($contact['email'])->bcc([$user_shop->user->email, $checkout_mail])->send(new MailContact($contact));
}else{

View file

@ -67,9 +67,9 @@ class RegisterController extends Controller
$rules = array(
'salutation' => 'required',
'first_name'=>'required',
'last_name'=>'required',
'salutation' => 'required',
'email' => 'required|string|email|max:255|unique:users',
'email-confirm' => 'required|same:email',
'password' => 'required|string|min:6|confirmed',