23-01-2026
This commit is contained in:
parent
a939cd51ef
commit
a8b395e20d
248 changed files with 29342 additions and 4805 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use Auth;
|
||||
use Yard;
|
||||
use Request;
|
||||
|
|
@ -38,35 +39,35 @@ class HomepartyController extends Controller
|
|||
|
||||
public function detail($id, $step = false)
|
||||
{
|
||||
if($id === 'new'){
|
||||
if ($id === 'new') {
|
||||
$homeparty = new Homeparty();
|
||||
$homeparty->id = 0;
|
||||
$step = 1;
|
||||
}else{
|
||||
} else {
|
||||
$homeparty = $this->getHomparty($id);
|
||||
if($homeparty->step < 10){
|
||||
if ($homeparty->step < 10) {
|
||||
$step = $homeparty->step;
|
||||
}else{
|
||||
if(!$step){
|
||||
} else {
|
||||
if (!$step) {
|
||||
$step = 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($homeparty->homeparty_host){
|
||||
if ($homeparty->homeparty_host) {
|
||||
$homeparty_user = $homeparty->homeparty_host;
|
||||
}else{
|
||||
} else {
|
||||
$homeparty_user = new HomepartyUser();
|
||||
$homeparty_user->is_host = true;
|
||||
}
|
||||
|
||||
if($homeparty->completed){
|
||||
if ($homeparty->completed) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'homeparty' => $homeparty,
|
||||
'homeparty_user' => $homeparty_user,
|
||||
'step' => $step,
|
||||
'homeparty' => $homeparty,
|
||||
'homeparty_user' => $homeparty_user,
|
||||
'step' => $step,
|
||||
|
||||
];
|
||||
return view('user.homeparty.detail', $data);
|
||||
|
|
@ -76,13 +77,13 @@ class HomepartyController extends Controller
|
|||
{
|
||||
$data = Request::all();
|
||||
|
||||
if($data['action'] === 'homeparty-party-store-detail'){
|
||||
if ($data['action'] === 'homeparty-party-store-detail') {
|
||||
$rules = array(
|
||||
'date' => 'required',
|
||||
'name' => 'required',
|
||||
'place' => 'required',
|
||||
);
|
||||
if(!$id){
|
||||
if (!$id) {
|
||||
$rules = array(
|
||||
'date' => 'required',
|
||||
'name' => 'required',
|
||||
|
|
@ -91,7 +92,7 @@ class HomepartyController extends Controller
|
|||
);
|
||||
}
|
||||
}
|
||||
if($data['action'] === 'homeparty-party-store-address'){
|
||||
if ($data['action'] === 'homeparty-party-store-address') {
|
||||
$rules = array(
|
||||
'shipping_firstname' => 'required',
|
||||
'shipping_lastname' => 'required',
|
||||
|
|
@ -103,7 +104,7 @@ class HomepartyController extends Controller
|
|||
);
|
||||
}
|
||||
|
||||
if($data['action'] === 'homeparty-party-store-host'){
|
||||
if ($data['action'] === 'homeparty-party-store-host') {
|
||||
$rules = array(
|
||||
'billing_salutation' => 'required',
|
||||
'billing_firstname' => 'required',
|
||||
|
|
@ -118,13 +119,13 @@ class HomepartyController extends Controller
|
|||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
|
||||
if($data['action'] === 'homeparty-party-store-detail'){
|
||||
if(!$id){
|
||||
|
||||
if ($data['action'] === 'homeparty-party-store-detail') {
|
||||
if (!$id) {
|
||||
//first save create and empty user/host
|
||||
do {
|
||||
$token = Util::uuidToken();
|
||||
} while( Homeparty::where('token', $token)->count() );
|
||||
} while (Homeparty::where('token', $token)->count());
|
||||
$data['token'] = $token;
|
||||
$data['auth_user_id'] = \Auth::user()->id;
|
||||
$data['step'] = 2;
|
||||
|
|
@ -139,35 +140,35 @@ class HomepartyController extends Controller
|
|||
'same_as_billing' => false,
|
||||
'is_host' => true,
|
||||
]);
|
||||
}else {
|
||||
} else {
|
||||
$homeparty = $this->getHomparty($id);
|
||||
$homeparty->fill($data)->save();
|
||||
$this->storeTranslations($homeparty, \App::getLocale(), $data);
|
||||
$step = 10;
|
||||
}
|
||||
}
|
||||
if($data['action'] === 'homeparty-party-store-address'){
|
||||
if ($data['action'] === 'homeparty-party-store-address') {
|
||||
$homeparty = $this->getHomparty($id);
|
||||
$homeparty_user = $homeparty->homeparty_host;
|
||||
$homeparty_user->fill($data)->save();
|
||||
if($homeparty->step === 2){
|
||||
if ($homeparty->step === 2) {
|
||||
$homeparty->step = 3;
|
||||
$homeparty->save();
|
||||
$step = 3;
|
||||
}else{
|
||||
} else {
|
||||
$step = 12;
|
||||
}
|
||||
}
|
||||
|
||||
if($data['action'] === 'homeparty-party-store-host'){
|
||||
if ($data['action'] === 'homeparty-party-store-host') {
|
||||
$homeparty = $this->getHomparty($id);
|
||||
$homeparty_user = $homeparty->homeparty_host;
|
||||
$homeparty_user->fill($data)->save();
|
||||
if($homeparty->step === 3){
|
||||
if ($homeparty->step === 3) {
|
||||
$homeparty->step = 10;
|
||||
$homeparty->save();
|
||||
$step = 10;
|
||||
}else{
|
||||
} else {
|
||||
$step = 13;
|
||||
}
|
||||
}
|
||||
|
|
@ -176,9 +177,10 @@ class HomepartyController extends Controller
|
|||
return redirect(route('user_homeparty_detail', [$homeparty->id, $step]));
|
||||
}
|
||||
|
||||
private function storeTranslations($homeparty, $lang, $data){
|
||||
private function storeTranslations($homeparty, $lang, $data)
|
||||
{
|
||||
|
||||
if($lang == 'de'){
|
||||
if ($lang == 'de') {
|
||||
$homeparty->description = $data['description'];
|
||||
$homeparty->save();
|
||||
return;
|
||||
|
|
@ -204,18 +206,18 @@ class HomepartyController extends Controller
|
|||
public function guestDetail($id = null, $gid = null)
|
||||
{
|
||||
$homeparty = $this->getHomparty($id);
|
||||
if($gid === 'new'){
|
||||
if ($gid === 'new') {
|
||||
$homeparty_user = new HomepartyUser();
|
||||
$homeparty_user->same_as_billing = true;
|
||||
$homeparty_user->billing_country_id = $homeparty->country_id;
|
||||
$homeparty_user->shipping_country_id = $homeparty->country_id;
|
||||
}else{
|
||||
} else {
|
||||
$homeparty_user = HomepartyUser::findOrFail($gid);
|
||||
if($homeparty->id !== $homeparty_user->homeparty_id){
|
||||
if ($homeparty->id !== $homeparty_user->homeparty_id) {
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
if($homeparty->completed){
|
||||
if ($homeparty->completed) {
|
||||
abort(404);
|
||||
}
|
||||
$data = [
|
||||
|
|
@ -254,16 +256,16 @@ class HomepartyController extends Controller
|
|||
}
|
||||
|
||||
$homeparty = $this->getHomparty($id);
|
||||
if($gid === null){
|
||||
if ($gid === null) {
|
||||
$homeparty_user = HomepartyUser::create([
|
||||
'homeparty_id' => $homeparty->id,
|
||||
'auth_user_id' => \Auth::user()->id,
|
||||
'is_host' => false,
|
||||
]);
|
||||
}else{
|
||||
]);
|
||||
} else {
|
||||
$homeparty_user = HomepartyUser::findOrFail($gid);
|
||||
}
|
||||
if($homeparty->id !== $homeparty_user->homeparty_id){
|
||||
if ($homeparty->id !== $homeparty_user->homeparty_id) {
|
||||
abort(404);
|
||||
}
|
||||
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
|
||||
|
|
@ -279,12 +281,12 @@ class HomepartyController extends Controller
|
|||
$user = User::find(Auth::user()->id);
|
||||
$homeparty = $this->getHomparty($id);
|
||||
$shipping_country_id = $this->checkShoppingCountry($homeparty->country_id);
|
||||
if(!$shipping_country_id){
|
||||
if (!$shipping_country_id) {
|
||||
\Session()->flash('custom-error', __('validation.custom.shipping_not_found'));
|
||||
return redirect(route('user_homepartys'));
|
||||
}
|
||||
UserService::checkUserTaxShippingCountry($user, $shipping_country_id);
|
||||
if($this->userChangeCountry($homeparty)){
|
||||
if ($this->userChangeCountry($homeparty)) {
|
||||
\Session()->flash('custom-error', __('msg.country_account_has_been_changed__cost_has_been_reset'));
|
||||
return redirect(route('user_homeparty_order', [$homeparty->id]));
|
||||
}
|
||||
|
|
@ -299,24 +301,26 @@ class HomepartyController extends Controller
|
|||
return view('user.homeparty.order', $data);
|
||||
}
|
||||
|
||||
private function userChangeCountry($homeparty){
|
||||
if(isset($homeparty->card_info['user_country_id'])){
|
||||
if($homeparty->card_info['user_country_id'] !== UserService::$user_country->id){
|
||||
private function userChangeCountry($homeparty)
|
||||
{
|
||||
if (isset($homeparty->card_info['user_country_id'])) {
|
||||
if ($homeparty->card_info['user_country_id'] !== UserService::$user_country->id) {
|
||||
// es wurde schon eine order angelegt, aber das Rechungsland geändert
|
||||
if($homeparty->homeparty_order_items->count()){
|
||||
foreach($homeparty->homeparty_order_items as $homeparty_order_item){
|
||||
if ($homeparty->homeparty_order_items->count()) {
|
||||
foreach ($homeparty->homeparty_order_items as $homeparty_order_item) {
|
||||
$homeparty_order_item->delete();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function checkShoppingCountry($country_id){
|
||||
if($country_id){
|
||||
if($shipping_country = ShippingCountry::whereCountryId($country_id)->first()){
|
||||
private function checkShoppingCountry($country_id)
|
||||
{
|
||||
if ($country_id) {
|
||||
if ($shipping_country = ShippingCountry::whereCountryId($country_id)->first()) {
|
||||
return $shipping_country->id;
|
||||
}
|
||||
}
|
||||
|
|
@ -328,26 +332,26 @@ class HomepartyController extends Controller
|
|||
{
|
||||
$homeparty = $this->getHomparty($id);
|
||||
|
||||
if(Request::ajax()) {
|
||||
if (Request::ajax()) {
|
||||
$data = Request::all();
|
||||
|
||||
if($data['action'] === 'addProduct') {
|
||||
if($data['homeparty_id'] == $homeparty->id){
|
||||
if ($data['action'] === 'addProduct') {
|
||||
if ($data['homeparty_id'] == $homeparty->id) {
|
||||
$homeparty_user = HomepartyUser::findOrFail($data['homeparty_user_id']);
|
||||
if($homeparty_user->homeparty_id !== $homeparty->id){
|
||||
if ($homeparty_user->homeparty_id !== $homeparty->id) {
|
||||
abort(404);
|
||||
}
|
||||
if($product = Product::find($data['product_id'])){
|
||||
if ($product = Product::find($data['product_id'])) {
|
||||
$margin = 0;
|
||||
if(\Auth::user() && \Auth::user()->user_level){
|
||||
if (\Auth::user() && \Auth::user()->user_level) {
|
||||
$margin = \Auth::user()->user_level->margin;
|
||||
}
|
||||
$HomepartyUserOrderItem = HomepartyUserOrderItem::where('homeparty_user_id', $homeparty_user->id)->where('product_id', $product->id)->first();
|
||||
if($HomepartyUserOrderItem){
|
||||
$HomepartyUserOrderItem->qty = $HomepartyUserOrderItem->qty+1;
|
||||
if ($HomepartyUserOrderItem) {
|
||||
$HomepartyUserOrderItem->qty = $HomepartyUserOrderItem->qty + 1;
|
||||
$HomepartyUserOrderItem->save();
|
||||
}else{
|
||||
if($homeparty->getCardInfo('user_tax_free')){
|
||||
} else {
|
||||
if ($homeparty->getCardInfo('user_tax_free')) {
|
||||
$HomepartyUserOrderItem = HomepartyUserOrderItem::create([
|
||||
'homeparty_id' => $homeparty->id,
|
||||
'homeparty_user_id' => $homeparty_user->id,
|
||||
|
|
@ -362,7 +366,7 @@ class HomepartyController extends Controller
|
|||
'ek_price_net' => $product->getPriceWith(true, true, $homeparty->getUserCountry()),
|
||||
'slug' => $product->slug
|
||||
]);
|
||||
}else{
|
||||
} else {
|
||||
$HomepartyUserOrderItem = HomepartyUserOrderItem::create([
|
||||
'homeparty_id' => $homeparty->id,
|
||||
'homeparty_user_id' => $homeparty_user->id,
|
||||
|
|
@ -379,9 +383,7 @@ class HomepartyController extends Controller
|
|||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$homeparty_user = HomepartyUser::findOrFail($data['homeparty_user_id']);
|
||||
HomepartyCart::calculateHomeparty($homeparty);
|
||||
|
|
@ -389,18 +391,18 @@ class HomepartyController extends Controller
|
|||
$html_bonus = view("user.homeparty.show_bonus", ['homeparty' => $homeparty])->render();
|
||||
$html_host_bonus = view("user.homeparty.show_calc_bonus_host", ['homeparty' => $homeparty])->render();
|
||||
$html_total = view("user.homeparty.show_total_order", ['homeparty' => $homeparty])->render();
|
||||
return response()->json(['response' => true, 'data'=>$data, 'html_user_cart'=>$html_user_cart, 'html_bonus'=>$html_bonus, 'html_host_bonus'=>$html_host_bonus, 'html_total'=>$html_total]);
|
||||
return response()->json(['response' => true, 'data' => $data, 'html_user_cart' => $html_user_cart, 'html_bonus' => $html_bonus, 'html_host_bonus' => $html_host_bonus, 'html_total' => $html_total]);
|
||||
}
|
||||
|
||||
if($data['action'] === 'updateCart') {
|
||||
if($data['homeparty_id'] == $homeparty->id){
|
||||
if ($data['action'] === 'updateCart') {
|
||||
if ($data['homeparty_id'] == $homeparty->id) {
|
||||
$homeparty_user = HomepartyUser::findOrFail($data['homeparty_user_id']);
|
||||
if($homeparty_user->homeparty_id !== $homeparty->id){
|
||||
if ($homeparty_user->homeparty_id !== $homeparty->id) {
|
||||
abort(404);
|
||||
}
|
||||
if(isset($data['product_id']) && $product = Product::find($data['product_id'])){
|
||||
if(isset($data['order_item_id']) && $HomepartyUserOrderItem = HomepartyUserOrderItem::find($data['order_item_id'])){
|
||||
if(isset($data['qty'])){
|
||||
if (isset($data['product_id']) && $product = Product::find($data['product_id'])) {
|
||||
if (isset($data['order_item_id']) && $HomepartyUserOrderItem = HomepartyUserOrderItem::find($data['order_item_id'])) {
|
||||
if (isset($data['qty'])) {
|
||||
$qty = (int) $data['qty'];
|
||||
$qty = $qty < 1 ? 1 : $qty;
|
||||
$qty = $qty > 100 ? 100 : $qty;
|
||||
|
|
@ -416,17 +418,17 @@ class HomepartyController extends Controller
|
|||
$html_bonus = view("user.homeparty.show_bonus", ['homeparty' => $homeparty])->render();
|
||||
$html_host_bonus = view("user.homeparty.show_calc_bonus_host")->render();
|
||||
$html_total = view("user.homeparty.show_total_order", ['homeparty' => $homeparty])->render();
|
||||
return response()->json(['response' => true, 'data'=>$data, 'html_user_cart'=>$html_user_cart, 'html_bonus'=>$html_bonus, 'html_host_bonus'=>$html_host_bonus, 'html_total'=>$html_total]);
|
||||
return response()->json(['response' => true, 'data' => $data, 'html_user_cart' => $html_user_cart, 'html_bonus' => $html_bonus, 'html_host_bonus' => $html_host_bonus, 'html_total' => $html_total]);
|
||||
}
|
||||
|
||||
if($data['action'] === 'removeFromCart') {
|
||||
if($data['homeparty_id'] == $homeparty->id){
|
||||
if ($data['action'] === 'removeFromCart') {
|
||||
if ($data['homeparty_id'] == $homeparty->id) {
|
||||
$homeparty_user = HomepartyUser::findOrFail($data['homeparty_user_id']);
|
||||
if($homeparty_user->homeparty_id !== $homeparty->id){
|
||||
if ($homeparty_user->homeparty_id !== $homeparty->id) {
|
||||
abort(404);
|
||||
}
|
||||
if(isset($data['product_id']) && $product = Product::find($data['product_id'])){
|
||||
if(isset($data['order_item_id']) && $HomepartyUserOrderItem = HomepartyUserOrderItem::find($data['order_item_id'])){
|
||||
if (isset($data['product_id']) && $product = Product::find($data['product_id'])) {
|
||||
if (isset($data['order_item_id']) && $HomepartyUserOrderItem = HomepartyUserOrderItem::find($data['order_item_id'])) {
|
||||
$HomepartyUserOrderItem->delete();
|
||||
}
|
||||
}
|
||||
|
|
@ -437,16 +439,16 @@ class HomepartyController extends Controller
|
|||
$html_bonus = view("user.homeparty.show_bonus", ['homeparty' => $homeparty])->render();
|
||||
$html_host_bonus = view("user.homeparty.show_calc_bonus_host")->render();
|
||||
$html_total = view("user.homeparty.show_total_order", ['homeparty' => $homeparty])->render();
|
||||
return response()->json(['response' => true, 'data'=>$data, 'html_user_cart'=>$html_user_cart, 'html_bonus'=>$html_bonus, 'html_host_bonus'=>$html_host_bonus, 'html_total'=>$html_total]);
|
||||
return response()->json(['response' => true, 'data' => $data, 'html_user_cart' => $html_user_cart, 'html_bonus' => $html_bonus, 'html_host_bonus' => $html_host_bonus, 'html_total' => $html_total]);
|
||||
}
|
||||
|
||||
if($data['action'] === 'updateDeliveryOption') {
|
||||
if($data['homeparty_id'] == $homeparty->id){
|
||||
if ($data['action'] === 'updateDeliveryOption') {
|
||||
if ($data['homeparty_id'] == $homeparty->id) {
|
||||
$homeparty_user = HomepartyUser::findOrFail($data['homeparty_user_id']);
|
||||
if($homeparty_user->homeparty_id !== $homeparty->id){
|
||||
if ($homeparty_user->homeparty_id !== $homeparty->id) {
|
||||
abort(404);
|
||||
}
|
||||
if(isset($data['delivery'])){
|
||||
if (isset($data['delivery'])) {
|
||||
$homeparty_user->delivery = $data['delivery'];
|
||||
$homeparty_user->save();
|
||||
}
|
||||
|
|
@ -457,17 +459,17 @@ class HomepartyController extends Controller
|
|||
$html_bonus = view("user.homeparty.show_bonus", ['homeparty' => $homeparty])->render();
|
||||
$html_host_bonus = view("user.homeparty.show_calc_bonus_host")->render();
|
||||
$html_total = view("user.homeparty.show_total_order", ['homeparty' => $homeparty])->render();
|
||||
return response()->json(['response' => true, 'data'=>$data, 'html_user_cart'=>$html_user_cart, 'html_bonus'=>$html_bonus, 'html_host_bonus'=>$html_host_bonus, 'html_total'=>$html_total]);
|
||||
return response()->json(['response' => true, 'data' => $data, 'html_user_cart' => $html_user_cart, 'html_bonus' => $html_bonus, 'html_host_bonus' => $html_host_bonus, 'html_total' => $html_total]);
|
||||
}
|
||||
|
||||
|
||||
return response()->json(['response' => false, 'data'=>$data]);
|
||||
return response()->json(['response' => false, 'data' => $data]);
|
||||
}
|
||||
|
||||
HomepartyCart::calculateHomeparty($homeparty);
|
||||
if(\App\Services\HomepartyCart::$price === 0){
|
||||
\Session()->flash('alert-error', __('msg.your_shopping_cart_is_empty_please_add_products_first'));
|
||||
return redirect(route('user_homeparty_order', [$homeparty->id]));
|
||||
if (\App\Services\HomepartyCart::$price === 0) {
|
||||
\Session()->flash('alert-error', __('msg.your_shopping_cart_is_empty_please_add_products_first'));
|
||||
return redirect(route('user_homeparty_order', [$homeparty->id]));
|
||||
}
|
||||
|
||||
//save the calucalte card!
|
||||
|
|
@ -475,29 +477,29 @@ class HomepartyController extends Controller
|
|||
$date = date('d.m.Y H:i:s', $time);
|
||||
$user = User::find(Auth::user()->id);
|
||||
Yard::instance('shopping')->destroy();
|
||||
$cartItem = Yard::instance('shopping')->add($homeparty->id, 'Bestellung Homeparty '.$date, 1, \App\Services\HomepartyCart::$ek_price, false, false, ['image' => "", 'slug' => $time, 'weight' => 0]);
|
||||
$cartItem = Yard::instance('shopping')->add($homeparty->id, 'Bestellung Homeparty ' . $date, 1, \App\Services\HomepartyCart::$ek_price, false, false, ['image' => "", 'slug' => $time, 'weight' => 0]);
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
do {
|
||||
$identifier = Util::getToken();
|
||||
} while( ShoppingInstance::where('identifier', $identifier)->count() );
|
||||
} while (ShoppingInstance::where('identifier', $identifier)->count());
|
||||
|
||||
HomepartyCart::store($identifier, $date);
|
||||
|
||||
$data = [];
|
||||
$data['is_from'] = 'homeparty';
|
||||
|
||||
if($homeparty->getCardInfo('user_tax_free')){
|
||||
if ($homeparty->getCardInfo('user_tax_free')) {
|
||||
$data['shop_price'] = HomepartyCart::getFormattedEkPrice();
|
||||
$data['shop_price_net'] = HomepartyCart::getFormattedEkPrice();
|
||||
$data['shop_price_tax'] = 0;
|
||||
$data['user_tax_free'] = true;
|
||||
}else{
|
||||
} else {
|
||||
$data['shop_price'] = HomepartyCart::getFormattedEkPrice();
|
||||
$data['shop_price_net'] = HomepartyCart::getFormattedEkPriceNet();
|
||||
$data['shop_price_tax'] = HomepartyCart::getFormattedEkPriceTax();
|
||||
$data['user_tax_free'] = false;
|
||||
}
|
||||
|
||||
|
||||
$data['homeparty_id'] = $homeparty->id;
|
||||
$data['is_for'] = 'hp';
|
||||
$data['user_price_infos'] = $homeparty->card_info;
|
||||
|
|
@ -518,68 +520,68 @@ class HomepartyController extends Controller
|
|||
HomepartyCart::store($identifier, $date);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
|
||||
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'payment_homeparty', 'status'=>1, 'referenz'=>$homeparty->id, 'identifier'=>$identifier]);
|
||||
$path = route('checkout.checkout_card', ['identifier' => $identifier]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action' => 'payment_homeparty', 'status' => 1, 'referenz' => $homeparty->id, 'identifier' => $identifier]);
|
||||
//$path = str_replace('http', 'https', $path);
|
||||
return redirect()->secure($path);
|
||||
}
|
||||
|
||||
|
||||
public function delete($do, $id = null, $gid=null)
|
||||
public function delete($do, $id = null, $gid = null)
|
||||
{
|
||||
$homeparty = $this->getHomparty($id);
|
||||
|
||||
if($do === 'hpu'){
|
||||
if ($do === 'hpu') {
|
||||
$homeparty_user = HomepartyUser::findOrFail($gid);
|
||||
if($homeparty->id !== $homeparty_user->homeparty_id){
|
||||
if ($homeparty->id !== $homeparty_user->homeparty_id) {
|
||||
abort(404);
|
||||
}
|
||||
if($homeparty_user->homeparty_user_order_items){
|
||||
foreach($homeparty_user->homeparty_user_order_items as $homeparty_user_order_item){
|
||||
$homeparty_user_order_item->delete();
|
||||
if ($homeparty_user->homeparty_user_order_items) {
|
||||
foreach ($homeparty_user->homeparty_user_order_items as $homeparty_user_order_item) {
|
||||
$homeparty_user_order_item->delete();
|
||||
}
|
||||
}
|
||||
//$homeparty_user->save();
|
||||
$homeparty_user->delete();
|
||||
\Session()->flash('alert-success', __('msg.homeparty_guest_delete'));
|
||||
return redirect(route('user_homeparty_guests', [$homeparty->id]));
|
||||
|
||||
}
|
||||
if($do === 'hp') {
|
||||
if ($do === 'hp') {
|
||||
|
||||
foreach ($homeparty->homeparty_users as $homeparty_user){
|
||||
foreach ($homeparty->homeparty_users as $homeparty_user) {
|
||||
if ($homeparty->id !== $homeparty_user->homeparty_id) {
|
||||
abort(404);
|
||||
}
|
||||
if($homeparty_user->homeparty_user_order_items){
|
||||
foreach($homeparty_user->homeparty_user_order_items as $homeparty_user_order_item){
|
||||
$homeparty_user_order_item->delete();
|
||||
if ($homeparty_user->homeparty_user_order_items) {
|
||||
foreach ($homeparty_user->homeparty_user_order_items as $homeparty_user_order_item) {
|
||||
$homeparty_user_order_item->delete();
|
||||
}
|
||||
}
|
||||
$homeparty_user->delete();
|
||||
}
|
||||
if($homeparty->homeparty_order_items){
|
||||
foreach($homeparty->homeparty_order_items as $homeparty_order_item){
|
||||
$homeparty_order_item->delete();
|
||||
if ($homeparty->homeparty_order_items) {
|
||||
foreach ($homeparty->homeparty_order_items as $homeparty_order_item) {
|
||||
$homeparty_order_item->delete();
|
||||
}
|
||||
}
|
||||
$homeparty->delete();
|
||||
\Session()->flash('alert-success', __('msg.homeparty_delete'));
|
||||
return redirect(route('user_homepartys'));
|
||||
|
||||
}
|
||||
abort(404);
|
||||
}
|
||||
|
||||
private function getHomparty($id){
|
||||
private function getHomparty($id)
|
||||
{
|
||||
$homeparty = Homeparty::findOrFail($id);
|
||||
if($homeparty->auth_user_id !== \Auth::user()->id){
|
||||
if ($homeparty->auth_user_id !== \Auth::user()->id) {
|
||||
abort(404);
|
||||
}
|
||||
return $homeparty;
|
||||
}
|
||||
|
||||
public function datatable($homeparty_id){
|
||||
public function datatable($homeparty_id)
|
||||
{
|
||||
|
||||
$query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '4');
|
||||
$homeparty = Homeparty::findOrFail($homeparty_id);
|
||||
|
|
@ -587,20 +589,19 @@ class HomepartyController extends Controller
|
|||
return \DataTables::eloquent($query)
|
||||
|
||||
->addColumn('add_card', function (Product $product) use ($homeparty) {
|
||||
if($homeparty->getCardInfo('user_tax_free')){
|
||||
return '<button type="button" class="btn btn-sm btn-md-extra btn-secondary add-product-basket" data-product-id="'.$product->id.'">
|
||||
<strong>€ '.$product->getFormattedPriceWith(true, false, $homeparty->getUserCountry()).'</strong> +<span class="ion ion-md-cart"></span>
|
||||
if ($homeparty->getCardInfo('user_tax_free')) {
|
||||
return '<button type="button" class="btn btn-sm btn-md-extra btn-secondary add-product-basket" data-product-id="' . $product->id . '">
|
||||
<strong>€ ' . $product->getFormattedPriceWith(true, false, $homeparty->getUserCountry()) . '</strong> +<span class="ion ion-md-cart"></span>
|
||||
</button>';
|
||||
}else{
|
||||
return '<button type="button" class="btn btn-sm btn-md-extra btn-secondary add-product-basket" data-product-id="'.$product->id.'">
|
||||
<strong>€ '.$product->getFormattedPriceWith(false, false, $homeparty->getUserCountry()).'</strong> +<span class="ion ion-md-cart"></span>
|
||||
} else {
|
||||
return '<button type="button" class="btn btn-sm btn-md-extra btn-secondary add-product-basket" data-product-id="' . $product->id . '">
|
||||
<strong>€ ' . $product->getFormattedPriceWith(false, false, $homeparty->getUserCountry()) . '</strong> +<span class="ion ion-md-cart"></span>
|
||||
</button>';
|
||||
}
|
||||
|
||||
})
|
||||
->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]).'">';
|
||||
if (count($product->images)) {
|
||||
return '<img class="img-fluid img-extra" alt="" src="' . route('product_image', [$product->images->first()->slug]) . '">';
|
||||
}
|
||||
return "";
|
||||
})
|
||||
|
|
@ -609,32 +610,35 @@ class HomepartyController extends Controller
|
|||
'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(true, true, $homeparty->getUserCountry()).'</span>';
|
||||
})
|
||||
*/
|
||||
->addColumn('points', function (Product $product) use ($homeparty) {
|
||||
return '<span class="no-line-break">' . $product->getFormattedPoints() . '</span>';
|
||||
})
|
||||
->addColumn('price_gross', function (Product $product) use ($homeparty) {
|
||||
if($homeparty->getCardInfo('user_tax_free')){
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(true, true, $homeparty->getUserCountry()). " €</span>".
|
||||
'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(true, true, $homeparty->getUserCountry()).'</span>';
|
||||
}else{
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(false, true, $homeparty->getUserCountry()). " €</span>".
|
||||
'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(false, true, $homeparty->getUserCountry()).'</span>';
|
||||
if ($homeparty->getCardInfo('user_tax_free')) {
|
||||
return '<span class="no-line-break">' . $product->getFormattedPriceWith(true, true, $homeparty->getUserCountry()) . " €</span>" .
|
||||
'<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(true, true, $homeparty->getUserCountry()) . '</span>';
|
||||
} else {
|
||||
return '<span class="no-line-break">' . $product->getFormattedPriceWith(false, true, $homeparty->getUserCountry()) . " €</span>" .
|
||||
'<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(false, true, $homeparty->getUserCountry()) . '</span>';
|
||||
}
|
||||
})
|
||||
->addColumn('price_vk_gross', function (Product $product) use ($homeparty) {
|
||||
if($homeparty->getCardInfo('user_tax_free')){
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(true, false, $homeparty->getUserCountry()). " €</span>".
|
||||
'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(true, false, $homeparty->getUserCountry()).'</span>';
|
||||
}else{
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(false, false, $homeparty->getUserCountry()). " €</span>".
|
||||
'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(false, false, $homeparty->getUserCountry()).'</span>';
|
||||
if ($homeparty->getCardInfo('user_tax_free')) {
|
||||
return '<span class="no-line-break">' . $product->getFormattedPriceWith(true, false, $homeparty->getUserCountry()) . " €</span>" .
|
||||
'<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(true, false, $homeparty->getUserCountry()) . '</span>';
|
||||
} else {
|
||||
return '<span class="no-line-break">' . $product->getFormattedPriceWith(false, false, $homeparty->getUserCountry()) . " €</span>" .
|
||||
'<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(false, false, $homeparty->getUserCountry()) . '</span>';
|
||||
}
|
||||
})
|
||||
->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-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>';
|
||||
})
|
||||
->filterColumn('product', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('name', 'LIKE', '%'.$keyword.'%');
|
||||
->filterColumn('product', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->where('name', 'LIKE', '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->orderColumn('name', 'name $1')
|
||||
|
|
@ -647,8 +651,7 @@ class HomepartyController extends Controller
|
|||
->orderColumn('contents_total', 'contents_total $1')
|
||||
->orderColumn('weight', 'weight $1')
|
||||
|
||||
->rawColumns(['add_card', 'product', 'quantity', 'picture', 'price_net', 'price_gross', 'price_vk_gross', 'action'])
|
||||
->rawColumns(['add_card', 'points', 'product', 'quantity', 'picture', 'price_net', 'price_gross', 'price_vk_gross', 'action'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue