main system

This commit is contained in:
Kevin Adametz 2021-01-15 18:16:31 +01:00
parent 0baac018a2
commit a96d7d5c77
115 changed files with 4589 additions and 557 deletions

View file

@ -24,8 +24,6 @@ class OrderController extends Controller
public function __construct()
{
$this->middleware('superadmin');
$this->middleware('active.account');
}
@ -159,14 +157,13 @@ class OrderController extends Controller
'isView' => 'customer',
'for' => $for,
'delivery_id' => $delivery_id,
'comp_products' => $this->getCompProducts($for),
//'comp_products' => $this->getCompProducts($for),
];
return view('user.order.list', $data);
}
public function payment($for, $id=null){
$data = Request::all();
$user = User::find(Auth::user()->id);
$rules = array(
'shipping_salutation' => 'required',
@ -180,10 +177,11 @@ class OrderController extends Controller
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
dd($validator);
return back()->withErrors($validator)->withInput(Request::all());
}
if(Yard::instance('shopping')->getNumComp() > 0){
/* if(Yard::instance('shopping')->getNumComp() > 0){
if(!isset($data['switchers-comp-product'])){
$validator->errors()->add('switchers-comp-product', __('Bitte wähle ein Kompensationsprodukt aus'));
}else{
@ -199,16 +197,20 @@ class OrderController extends Controller
return back()->withErrors($validator)->withInput(Request::all());
}
}
do {
*/
/*do {
$identifier = Util::getToken();
} while( ShoppingInstance::where('identifier', $identifier)->count() );
} while( ShoppingInstance::where('identifier', $identifier)->count() );*/
$identifier = Util::getToken();
$data['is_from'] = 'user_order';
$data['is_for'] = $for;
$data['shopping_user_id'] = $id;
unset($data['quantity']);
unset($data['_token']);
ShoppingInstance::create([
Yard::instance('shopping')->putYardExtra('shopping_data', $data);
/*ShoppingInstance::create([
'identifier' => $identifier,
'user_shop_id' => 1, //is first faker shop for buy intern
'auth_user_id' => Auth::user()->id,
@ -220,14 +222,13 @@ class OrderController extends Controller
]);
Yard::instance('shopping')->store($identifier);
*/
//add to DB
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
UserHistory::create(['user_id' => $user->id, 'action'=>'user_order_payment', 'status'=>1, 'product_id'=>null, 'identifier'=>$identifier, 'abo_options'=>0]);
//$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
UserHistory::create(['user_id' => $user->id, 'action'=>'user_order_payment', 'status'=>1, 'product_id'=>null, 'identifier'=>$identifier]);
//$path = str_replace('http', 'https', $path);
return redirect()->secure($path);
//return redirect()->secure($path);
return redirect(route('user_checkout', [$identifier]));
}
private function checkShoppingCountry($for, $id=null){
@ -384,14 +385,13 @@ class OrderController extends Controller
->make(true);
}
public function performRequest(){
if(Request::ajax()) {
$data = Request::all();
$data = Request::all();
$is_for = isset($data['shipping_is_for']) ? $data['shipping_is_for'] : 'ot';
$data['comp_products'] = $this->getCompProducts($is_for);
// $data['comp_products'] = $this->getCompProducts($is_for);
if($data['action'] === 'updateCart' && isset($data['product_id'])){
if($product = Product::find($data['product_id'])){
@ -401,7 +401,7 @@ class OrderController extends Controller
}
//get the card item
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(false, true), ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]);
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(false, true), $product->tax, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]);
Yard::setTax($cartItem->rowId, $product->tax);
if(isset($data['qty']) && $data['qty'] > 0){
@ -411,34 +411,31 @@ class OrderController extends Controller
Yard::instance('shopping')->remove($cartItem->rowId);
}
//
Yard::instance('shopping')->reCalculateShippingPrice();
$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
//$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
$html_card = view("user.order.yard_view_form", $data)->render();
$html_comp = view("user.order.comp_product", $data)->render();
//$html_comp = view("user.order.comp_product", $data)->render();
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>$html_comp]);
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>'']);
}
}
if($data['action'] === 'clearCart') {
Yard::instance('shopping')->destroy();
return response()->json(['response' => true, 'data'=>Yard::instance('shopping')->count(), 'html_card'=>'', 'html_comp'=>'']);
}
if($data['action'] === 'updateShippingCountry') {
if(isset($data['shipping_country_id'])){
if($shipping_country = ShippingCountry::find($data['shipping_country_id'])){
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country->id, $is_for);
$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
//$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
}
}
$html_card = view("user.order.yard_view_form", $data)->render();
$html_comp = view("user.order.comp_product", $data)->render();
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>$html_comp]);
//$html_comp = view("user.order.comp_product", $data)->render();
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>'']);
}
if($data['action'] === 'updateCompProduct'){
/* if($data['action'] === 'updateCompProduct'){
// $data['comp_product_id']
// $data['comp_num']
//count_comp_products
@ -450,11 +447,12 @@ class OrderController extends Controller
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>$html_comp]);
}
*/
return response()->json(['response' => false, 'data'=>$data]);
}
}
private function checkCompProduct($count_comp_products){
/* private function checkCompProduct($count_comp_products){
foreach (Yard::instance('shopping')->content() as $row) {
//wenn gleich löschen, da neue Versandkosten
if($row->options->comp > $count_comp_products) {
@ -491,5 +489,5 @@ class OrderController extends Controller
return Product::whereActive(true)->where('show_at', '=', 1)->where('shipping_addon', true)->orderBy('pos', 'DESC')->get();
}
return null;
}
}*/
}