23-01-2026
This commit is contained in:
parent
a939cd51ef
commit
a8b395e20d
248 changed files with 29342 additions and 4805 deletions
|
|
@ -57,10 +57,11 @@ class AdminUserController extends Controller
|
|||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Request::all();
|
||||
$user = User::findOrFail($data['id']);
|
||||
$user = User::withTrashed()->findOrFail($data['id']);
|
||||
|
||||
/* if(isset($data['user-delete'])){
|
||||
if(isset($data['realy_delete_user'])){
|
||||
|
|
@ -117,6 +118,36 @@ class AdminUserController extends Controller
|
|||
->save();
|
||||
}
|
||||
|
||||
if (isset($data['save-restore'])) {
|
||||
$restore_account = isset($data['restore_account']) ? true : false;
|
||||
$restore_childs = isset($data['restore_childs']) ? true : false;
|
||||
$restore_send_email = isset($data['restore_send_email']) ? true : false;
|
||||
if (isset($data['payment_account']) || $data['payment_account'] != "") {
|
||||
|
||||
$error = UserUtil::checkEmailExists($user);
|
||||
if ($error) {
|
||||
\Session()->flash('alert-error', $error);
|
||||
return redirect()->back()->withInput()->withErrors(['error' => $error]);
|
||||
}
|
||||
$payment_account = \Carbon::parse(str_replace("- ", "", $data['payment_account']));
|
||||
if ($restore_account) {
|
||||
UserUtil::restoreUser($user, $payment_account);
|
||||
if ($restore_childs) {
|
||||
UserUtil::resetChildsToSponsor($user->id);
|
||||
}
|
||||
if ($restore_send_email) {
|
||||
$user = User::with('account')->findOrFail($data['id']);
|
||||
Mail::to($user->email)->send(new \App\Mail\UserRestoreEmail($user));
|
||||
}
|
||||
}
|
||||
}
|
||||
SysLog::action('save-restore', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user restore_account value: ' . $user->restore_account . " and restore_childs value: " . $user->restore_childs)
|
||||
->save();
|
||||
}
|
||||
|
||||
if (isset($data['save-account'])) {
|
||||
$old = $user->getPaymentAccountDateFormat(true);
|
||||
if (!isset($data['payment_account']) || $data['payment_account'] == "") {
|
||||
|
|
@ -249,6 +280,12 @@ class AdminUserController extends Controller
|
|||
return $user->confirmed ? $link . '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> ' . $date . '</span></a>' : $link . '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
})
|
||||
->addColumn('active', function (User $user) {
|
||||
if ($user->trashed()) {
|
||||
$date = Carbon::parse(now())->addDays(10)->format('d.m.Y H:i');
|
||||
$email = str_replace("delete-", "", $user->email);
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-restore" data-id="' . $user->id . '" data-email="' . $email . '" data-active="' . $user->active . '" data-payment_account="' . $date . '">';
|
||||
return $link . '<span class="badge badge-pill badge-info"><i class="fa fa-undo"></i> Account reaktivieren</span></a>';
|
||||
}
|
||||
$date = $user->getActiveDateFormat();
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-active" data-id="' . $user->id . '" data-email="' . $user->email . '" data-active="' . $user->active . '" data-active_date="' . $date . '">';
|
||||
return $user->active ? $link . '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> ' . $date . '</span></a>' : $link . '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
|
|
|
|||
|
|
@ -20,18 +20,16 @@ class PayoneController extends Controller
|
|||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
public function __construct() {}
|
||||
|
||||
|
||||
public function paymentStatus()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function paymentStatus(){
|
||||
|
||||
$data = \Request::all();
|
||||
// test para
|
||||
|
||||
/* $data = [
|
||||
/* $data = [
|
||||
'key' => '698fb2555f8b2efc74f60b2121421f45',
|
||||
'txaction' => 'paid',
|
||||
'clearingtype' => 'wlt',
|
||||
|
|
@ -44,34 +42,34 @@ class PayoneController extends Controller
|
|||
|
||||
*/
|
||||
|
||||
if(!isset($data['key']) || !isset($data['param']) || !isset($data['userid']) || !isset($data['txid']) || !isset($data['reference']) || !isset($data['price'])){
|
||||
if (!isset($data['key']) || !isset($data['param']) || !isset($data['userid']) || !isset($data['txid']) || !isset($data['reference']) || !isset($data['price'])) {
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2001 App\Http\Controllers\Api\PayoneController::paymentStatus parameter incomplete',
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2001 App\Http\Controllers\Api\PayoneController::paymentStatus parameter incomplete',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
if($data['key'] != config('payone.defaults.key')) {
|
||||
if ($data['key'] != config('payone.defaults.key')) {
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2002 App\Http\Controllers\Api\PayoneController::paymentStatus Key error',
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2002 App\Http\Controllers\Api\PayoneController::paymentStatus Key error',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$shopping_order = ShoppingOrder::find($data['param']);
|
||||
if(!$shopping_order){
|
||||
if (!$shopping_order) {
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2003 App\Http\Controllers\Api\PayoneController::paymentStatus ShoppingOrder not found:',
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2003 App\Http\Controllers\Api\PayoneController::paymentStatus ShoppingOrder not found:',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
|
|
@ -79,62 +77,64 @@ class PayoneController extends Controller
|
|||
}
|
||||
|
||||
$shopping_payment = ShoppingPayment::where('reference', $data['reference'])->first();
|
||||
if(!$shopping_payment){
|
||||
if (!$shopping_payment) {
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2004 App\Http\Controllers\Api\PayoneController::paymentStatus ShoppingPayment not found',
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2004 App\Http\Controllers\Api\PayoneController::paymentStatus ShoppingPayment not found',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
if($shopping_payment->shopping_order_id != $shopping_order->id){
|
||||
if ($shopping_payment->shopping_order_id != $shopping_order->id) {
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2005 App\Http\Controllers\Api\PayoneController::paymentStatus ShoppingPayment no realation ShoppingOrder',
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2005 App\Http\Controllers\Api\PayoneController::paymentStatus ShoppingPayment no realation ShoppingOrder',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
$price = number_format((round($data['price'],2) * 100), 0, '.', '');
|
||||
$price = number_format((round($data['price'], 2) * 100), 0, '.', '');
|
||||
$price_amount = number_format($shopping_payment->amount, 0, '.', '');
|
||||
if($price_amount != $price){
|
||||
if ($price_amount != $price) {
|
||||
$data['shopping_payment-amount'] = $price_amount;
|
||||
$data['price-amount'] = $price;
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2006 App\Http\Controllers\Api\PayoneController::paymentStatus Price error',
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2006 App\Http\Controllers\Api\PayoneController::paymentStatus Price error',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
/* TODO -- need this? */
|
||||
if($shopping_payment->txaction == $data['txaction']){
|
||||
/* TODO -- need this? */
|
||||
if ($shopping_payment->txaction == $data['txaction']) {
|
||||
|
||||
if($data['txaction'] === 'paid' && $shopping_order->txaction === 'paid'){
|
||||
if ($data['txaction'] === 'paid' && $shopping_order->txaction === 'paid') {
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2007 App\Http\Controllers\Api\PayoneController::paymentStatus same txaction - was already paid',
|
||||
$data
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2007 App\Http\Controllers\Api\PayoneController::paymentStatus same txaction - was already paid',
|
||||
$data,
|
||||
false
|
||||
);
|
||||
//was already paid
|
||||
print("TSOK");
|
||||
exit;
|
||||
}else{
|
||||
} else {
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2007 App\Http\Controllers\Api\PayoneController::paymentStatus same txaction - show',
|
||||
$data
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2007 App\Http\Controllers\Api\PayoneController::paymentStatus same txaction - show',
|
||||
$data,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -159,29 +159,28 @@ class PayoneController extends Controller
|
|||
|
||||
$send_link = false;
|
||||
$send_mail = true;
|
||||
if($data['txaction'] === 'failed'){
|
||||
if ($data['txaction'] === 'failed') {
|
||||
$shopping_order->setUserHistoryValue(['status' => 6]);
|
||||
Util::setInstanceStatusByPayment($shopping_payment, 5);
|
||||
}
|
||||
if($data['txaction'] === 'appointed'){
|
||||
if ($data['txaction'] === 'appointed') {
|
||||
$shopping_order->setUserHistoryValue(['status' => 7]);
|
||||
ShoppingUserService::snycOrdersByShoppingOrder($shopping_order);
|
||||
Util::setInstanceStatusByPayment($shopping_payment, 4);
|
||||
Util::setInstanceStatusByPayment($shopping_payment, 4);
|
||||
}
|
||||
|
||||
if($data['txaction'] === 'paid'){
|
||||
if(!$shopping_order->paid){
|
||||
if ($data['txaction'] === 'paid') {
|
||||
if (!$shopping_order->paid) {
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true, $shopping_payment);
|
||||
}else{
|
||||
} else {
|
||||
$send_mail = false;
|
||||
}
|
||||
}
|
||||
$data['send_link'] = $send_link;
|
||||
if($send_mail){
|
||||
if ($send_mail) {
|
||||
Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
|
||||
}
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\Services\Payment;
|
||||
|
|
@ -20,12 +21,12 @@ class BusinessPointsController extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$filter_members = UserSalesVolume::join('users', 'user_id', '=', 'users.id')
|
||||
->groupBy('user_id')->join('user_accounts', 'account_id', '=', 'user_accounts.id')
|
||||
->select('users.id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')->get();
|
||||
|
||||
|
||||
$filter_members = UserSalesVolume::join('users', 'user_id', '=', 'users.id')
|
||||
->groupBy('user_id')->join('user_accounts', 'account_id', '=', 'user_accounts.id')
|
||||
->select('users.id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')->get();
|
||||
|
||||
|
||||
$this->setFilterVars();
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
|
|
@ -38,52 +39,79 @@ class BusinessPointsController extends Controller
|
|||
return view('admin.business.points', $data);
|
||||
}
|
||||
|
||||
public function store(){
|
||||
public function store()
|
||||
{
|
||||
$data = Request::all();
|
||||
if(!isset($data['action'])){
|
||||
if (!isset($data['action'])) {
|
||||
return back();
|
||||
}
|
||||
if(!isset($data['change_member_key']) || $data['change_member_key'] !== config('mivita.edit_data_pass')){
|
||||
if (!isset($data['change_member_key']) || $data['change_member_key'] !== config('mivita.edit_data_pass')) {
|
||||
\Session()->flash('alert-error', 'Das Passwort ist falsch.');
|
||||
return back();
|
||||
return back();
|
||||
}
|
||||
if(!isset($data['is_checked_action'])){
|
||||
if (!isset($data['is_checked_action'])) {
|
||||
\Session()->flash('alert-error', 'Änderung nicht bestätigt');
|
||||
return back();
|
||||
return back();
|
||||
}
|
||||
|
||||
if($data['action'] === 'add_user_sales_volume'){
|
||||
if ($data['action'] === 'add_user_sales_volume') {
|
||||
SalesPointsVolume::addSalesPointsVolume($data);
|
||||
return back(); }
|
||||
|
||||
if($data['action'] === 'edit_user_sales_volume'){
|
||||
SalesPointsVolume::editSalesPointsVolume($data);
|
||||
return back();
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
dd($data);
|
||||
|
||||
if ($data['action'] === 'edit_user_sales_volume') {
|
||||
SalesPointsVolume::editSalesPointsVolume($data);
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
return redirect(route('admin_business_points'));
|
||||
}
|
||||
|
||||
public function recalculate()
|
||||
{
|
||||
$user_id = Request::get('points_filter_member_id');
|
||||
$month = Request::get('points_filter_month');
|
||||
$year = Request::get('points_filter_year');
|
||||
|
||||
private function setFilterVars(){
|
||||
if (!$user_id) {
|
||||
\Session()->flash('alert-error', 'Kein Berater ausgewählt.');
|
||||
return back();
|
||||
}
|
||||
|
||||
if(!session('points_filter_month')){
|
||||
if (!$month || !$year) {
|
||||
\Session()->flash('alert-error', 'Monat und Jahr müssen angegeben sein.');
|
||||
return back();
|
||||
}
|
||||
|
||||
try {
|
||||
SalesPointsVolume::reCalculateSalesPointsVolume($user_id, $month, $year);
|
||||
\Session()->flash('alert-success', 'Punkte für den ausgewählten Berater im Monat ' . str_pad($month, 2, "0", STR_PAD_LEFT) . '/' . $year . ' wurden erfolgreich neu berechnet.');
|
||||
} catch (\Exception $e) {
|
||||
\Session()->flash('alert-error', 'Fehler bei der Neuberechnung: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
private function setFilterVars()
|
||||
{
|
||||
|
||||
if (!session('points_filter_month')) {
|
||||
session(['points_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('points_filter_year')){
|
||||
if (!session('points_filter_year')) {
|
||||
session(['points_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
|
||||
|
||||
session(['points_filter_member_id' => Request::get('points_filter_member_id')]);
|
||||
session(['points_filter_status_type_id' => Request::get('points_filter_status_type_id')]);
|
||||
|
||||
if(Request::get('points_filter_month')){
|
||||
if (Request::get('points_filter_month')) {
|
||||
session(['points_filter_month' => Request::get('points_filter_month')]);
|
||||
}
|
||||
if(Request::get('points_filter_year')){
|
||||
if (Request::get('points_filter_year')) {
|
||||
session(['points_filter_year' => Request::get('points_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
|
@ -94,83 +122,129 @@ class BusinessPointsController extends Controller
|
|||
|
||||
//$query = UserSalesVolume::with('user', 'user.account')->with('shopping_order')->select('user_sales_volumes.*')
|
||||
$query = UserSalesVolume::join('users', 'user_id', '=', 'users.id')->join('user_accounts', 'account_id', '=', 'user_accounts.id')
|
||||
->select('user_sales_volumes.*', 'users.email', 'user_accounts.m_account', 'user_accounts.first_name', 'user_accounts.last_name')
|
||||
->where('user_sales_volumes.month', '=', Request::get('points_filter_month'))
|
||||
->where('user_sales_volumes.year', '=', Request::get('points_filter_year'));
|
||||
->select('user_sales_volumes.*', 'users.email', 'user_accounts.m_account', 'user_accounts.first_name', 'user_accounts.last_name')
|
||||
->where('user_sales_volumes.month', '=', Request::get('points_filter_month'))
|
||||
->where('user_sales_volumes.year', '=', Request::get('points_filter_year'));
|
||||
|
||||
if(Request::get('points_filter_member_id')){
|
||||
if (Request::get('points_filter_member_id')) {
|
||||
$query->where('user_sales_volumes.user_id', '=', Request::get('points_filter_member_id'));
|
||||
}
|
||||
if(Request::get('points_filter_status_type_id')){
|
||||
if (Request::get('points_filter_status_type_id')) {
|
||||
$query->where('user_sales_volumes.status', '=', Request::get('points_filter_status_type_id'));
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
public function getSummary()
|
||||
{
|
||||
$user_id = Request::get('points_filter_member_id');
|
||||
$month = Request::get('points_filter_month');
|
||||
$year = Request::get('points_filter_year');
|
||||
|
||||
if (!$user_id || !$month || !$year) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'data' => null
|
||||
]);
|
||||
}
|
||||
|
||||
// Hole den letzten Eintrag für den User im Monat, da dort die akkumulierten Summen stehen
|
||||
$lastEntry = UserSalesVolume::where('user_id', $user_id)
|
||||
->where('month', $month)
|
||||
->where('year', $year)
|
||||
->orderBy('id', 'DESC')
|
||||
->first();
|
||||
|
||||
if (!$lastEntry) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'data' => null
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'month_KP_points' => $lastEntry->month_KP_points ?? 0,
|
||||
'month_TP_points' => $lastEntry->month_TP_points ?? 0,
|
||||
'month_shop_points' => $lastEntry->month_shop_points ?? 0,
|
||||
'month_total_net' => $lastEntry->month_total_net ?? 0,
|
||||
'month_shop_total_net' => $lastEntry->month_shop_total_net ?? 0,
|
||||
'total_KP_points' => ($lastEntry->month_KP_points ?? 0) + ($lastEntry->month_shop_points ?? 0),
|
||||
'total_TP_points' => ($lastEntry->month_TP_points ?? 0) + ($lastEntry->month_shop_points ?? 0),
|
||||
'total_net' => ($lastEntry->month_total_net ?? 0) + ($lastEntry->month_shop_total_net ?? 0),
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$query = $this->initSearch();
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserSalesVolume $UserSalesVolume) {
|
||||
return '<button type="button" class="btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$UserSalesVolume->id.'"
|
||||
data-id="' . $UserSalesVolume->id . '"
|
||||
data-action="edit_user_sales_volume"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="user"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-eye"></span></button>';
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-eye"></span></button>';
|
||||
})
|
||||
->addColumn('order', function (UserSalesVolume $UserSalesVolume) {
|
||||
if($UserSalesVolume->shopping_order){
|
||||
if($UserSalesVolume->status === 1){
|
||||
return '<a href="' . route('admin_sales_users_detail', [$UserSalesVolume->shopping_order->id]) . '" class="btn btn-xs btn-primary">'.$UserSalesVolume->shopping_order->id.'</a>';
|
||||
if ($UserSalesVolume->shopping_order) {
|
||||
if ($UserSalesVolume->status === 1) {
|
||||
return '<a href="' . route('admin_sales_users_detail', [$UserSalesVolume->shopping_order->id]) . '" class="btn btn-xs btn-primary">' . $UserSalesVolume->shopping_order->id . '</a>';
|
||||
}
|
||||
if($UserSalesVolume->status === 2 || $UserSalesVolume->status === 3){
|
||||
return '<a href="' . route('admin_sales_customers_detail', [$UserSalesVolume->shopping_order->id]) . '" class="btn btn-xs btn-secondary">'.$UserSalesVolume->shopping_order->id.'</a>';
|
||||
if ($UserSalesVolume->status === 2 || $UserSalesVolume->status === 3) {
|
||||
return '<a href="' . route('admin_sales_customers_detail', [$UserSalesVolume->shopping_order->id]) . '" class="btn btn-xs btn-secondary">' . $UserSalesVolume->shopping_order->id . '</a>';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
})
|
||||
->addColumn('points', function (UserSalesVolume $UserSalesVolume) {
|
||||
return formatNumber($UserSalesVolume->points);
|
||||
})
|
||||
->addColumn('total_net', function (UserSalesVolume $UserSalesVolume) {
|
||||
return formatNumber($UserSalesVolume->total_net).' €';
|
||||
return formatNumber($UserSalesVolume->total_net) . ' €';
|
||||
})
|
||||
->addColumn('status_turnover', function (UserSalesVolume $UserSalesVolume) {
|
||||
return '<span class="badge badge-pill badge-'.$UserSalesVolume->getStatusTurnoverColor().'">'.$UserSalesVolume->getStatusTurnoverType().'</span>';
|
||||
return '<span class="badge badge-pill badge-' . $UserSalesVolume->getStatusTurnoverColor() . '">' . $UserSalesVolume->getStatusTurnoverType() . '</span>';
|
||||
})
|
||||
->addColumn('status', function (UserSalesVolume $UserSalesVolume) {
|
||||
return '<span class="badge badge-pill badge-'.$UserSalesVolume->getStatusColor().'">'.$UserSalesVolume->getStatusType().'</span>';
|
||||
return '<span class="badge badge-pill badge-' . $UserSalesVolume->getStatusColor() . '">' . $UserSalesVolume->getStatusType() . '</span>';
|
||||
})
|
||||
->addColumn('status_points', function (UserSalesVolume $UserSalesVolume) {
|
||||
return '<span class="badge badge-pill badge-'.$UserSalesVolume->getStatusPointsColor().'">'.$UserSalesVolume->getStatusPointsType().'</span>';
|
||||
return '<span class="badge badge-pill badge-' . $UserSalesVolume->getStatusPointsColor() . '">' . $UserSalesVolume->getStatusPointsType() . '</span>';
|
||||
})
|
||||
->addColumn('message', function (UserSalesVolume $UserSalesVolume) {
|
||||
return '<span class="no-line-break">'.$UserSalesVolume->message.'</span>';
|
||||
return '<span class="no-line-break">' . $UserSalesVolume->message . '</span>';
|
||||
})
|
||||
->addColumn('info', function (UserSalesVolume $UserSalesVolume) {
|
||||
return '<span class="no-line-break">'.$UserSalesVolume->info.'</span>';
|
||||
return '<span class="no-line-break">' . $UserSalesVolume->info . '</span>';
|
||||
})
|
||||
|
||||
->filterColumn('m_account', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("m_account LIKE ?", '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->filterColumn('first_name', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("first_name LIKE ?", '%'.$keyword.'%');
|
||||
|
||||
->filterColumn('m_account', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("m_account LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->filterColumn('last_name', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("last_name LIKE ?", '%'.$keyword.'%');
|
||||
->filterColumn('first_name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("first_name LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->filterColumn('email', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("email LIKE ?", '%'.$keyword.'%');
|
||||
->filterColumn('last_name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("last_name LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
|
||||
->filterColumn('email', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("email LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('order', 'order $1')
|
||||
->orderColumn('status', 'status $1')
|
||||
|
|
@ -184,4 +258,4 @@ class BusinessPointsController extends Controller
|
|||
->rawColumns(['id', 'order', 'status_turnover', 'status', 'status_points', 'message', 'info', 'total_net'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ class CategoryController extends Controller
|
|||
|
||||
public function edit($id)
|
||||
{
|
||||
if($id == "new"){
|
||||
if ($id == "new") {
|
||||
$model = new Category();
|
||||
$model->active = true;
|
||||
}else{
|
||||
} else {
|
||||
$model = Category::findOrFail($id);
|
||||
}
|
||||
$data = [
|
||||
|
|
@ -46,9 +46,9 @@ class CategoryController extends Controller
|
|||
{
|
||||
|
||||
$data = Request::all();
|
||||
if($data['action'] === 'save-product_category'){
|
||||
if ($data['action'] === 'save-product_category') {
|
||||
|
||||
if($data['id'] === 'new'){
|
||||
if ($data['id'] === 'new') {
|
||||
$ProductCategory = ProductCategory::create([
|
||||
'pos' => $data['pos'],
|
||||
'product_id' => $data['product_id'],
|
||||
|
|
@ -56,9 +56,9 @@ class CategoryController extends Controller
|
|||
]);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_category_edit', [$ProductCategory->category_id]));
|
||||
}else{
|
||||
} else {
|
||||
$ProductCategory = ProductCategory::findOrFail($data['id']);
|
||||
if($ProductCategory->category_id != $data['category_id']){
|
||||
if ($ProductCategory->category_id != $data['category_id']) {
|
||||
abort(404);
|
||||
}
|
||||
$ProductCategory->pos = $data['pos'];
|
||||
|
|
@ -67,63 +67,63 @@ class CategoryController extends Controller
|
|||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_category_edit', [$ProductCategory->category_id]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($data['action'] === 'save-form'){
|
||||
if ($data['action'] === 'save-form') {
|
||||
$data['active'] = isset($data['active']) ? true : false;
|
||||
$data['parent_id'] = isset($data['parent_id']) ? $data['parent_id'] : null;
|
||||
if($data['id'] == "new"){
|
||||
if ($data['id'] == "new") {
|
||||
$model = Category::create($data);
|
||||
}else{
|
||||
} else {
|
||||
$model = Category::find($data['id']);
|
||||
$model->fill($data)->save();
|
||||
}
|
||||
|
||||
|
||||
$trans = [];
|
||||
if(!empty($data['trans_name'])){
|
||||
|
||||
foreach ($data['trans_name'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
if (!empty($data['trans_name'])) {
|
||||
|
||||
foreach ($data['trans_name'] as $lang => $value) {
|
||||
if ($value && $value != null) {
|
||||
$trans[$lang] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
$model->trans_name = $trans;
|
||||
$model->save();
|
||||
|
||||
|
||||
$trans = [];
|
||||
if(!empty($data['trans_headline'])){
|
||||
foreach ($data['trans_headline'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
if (!empty($data['trans_headline'])) {
|
||||
foreach ($data['trans_headline'] as $lang => $value) {
|
||||
if ($value && $value != null) {
|
||||
$trans[$lang] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
$model->trans_headline = $trans;
|
||||
$model->save();
|
||||
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function delete($do, $id){
|
||||
public function delete($do, $id)
|
||||
{
|
||||
|
||||
if($do === 'product_category'){
|
||||
if ($do === 'product_category') {
|
||||
$model = ProductCategory::findOrFail($id);
|
||||
$category = $model->category;
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_category_edit', [$category->id]));
|
||||
}
|
||||
if($do === 'category'){
|
||||
if(ProductCategory::where('category_id', $id)->count()){
|
||||
if ($do === 'category') {
|
||||
if (ProductCategory::where('category_id', $id)->count()) {
|
||||
\Session()->flash('alert-error', 'Eintrag hat noch Produkte, erst löschen');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
if(Category::where('parent_id', $id)->count()){
|
||||
if (Category::where('parent_id', $id)->count()) {
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Haupt-Kategorie verwendet');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
|
|
@ -132,12 +132,12 @@ class CategoryController extends Controller
|
|||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public function imageUpload(){
|
||||
public function imageUpload()
|
||||
{
|
||||
|
||||
$category_id = Request::get('category_id');
|
||||
$category = Category::findOrFail($category_id);
|
||||
|
|
@ -145,12 +145,11 @@ class CategoryController extends Controller
|
|||
try {
|
||||
$image = \App\Services\Slim::getImages('images')[0];
|
||||
|
||||
if ( isset($image['output']['data']) )
|
||||
{
|
||||
if (isset($image['output']['data'])) {
|
||||
|
||||
// Base64 of the image
|
||||
$data = $image['output']['data'];
|
||||
$file_ex = array( 'image/jpeg' => 'jpg', 'image/png' => 'png');
|
||||
$file_ex = array('image/jpeg' => 'jpg', 'image/png' => 'png');
|
||||
|
||||
if (!isset($file_ex[$image['output']['type']])) {
|
||||
\Session()->flash('alert-danger', 'File is not jpg or png!');
|
||||
|
|
@ -166,10 +165,10 @@ class CategoryController extends Controller
|
|||
$image_name = "";
|
||||
do {
|
||||
$image_name = uniqid('', false) . '_' . $name;
|
||||
} while (\Storage::disk('public')->exists($path.$image_name));
|
||||
} while (\Storage::disk('public')->exists($path . $image_name));
|
||||
|
||||
$data = \Storage::disk('public')->put(
|
||||
$path.$image_name,
|
||||
$path . $image_name,
|
||||
$data
|
||||
);
|
||||
|
||||
|
|
@ -189,21 +188,20 @@ class CategoryController extends Controller
|
|||
}
|
||||
\Session()->flash('alert-danger', __('msg.file_empty'));
|
||||
return redirect(route('admin_product_category_edit', [$category->id]));
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
\Session()->flash('alert-danger', "Error: ".$e);
|
||||
} catch (Exception $e) {
|
||||
\Session()->flash('alert-danger', "Error: " . $e);
|
||||
return redirect(route('admin_product_category_edit', [$category->id]));
|
||||
}
|
||||
}
|
||||
|
||||
public function imageDelete($image_id, $category_id){
|
||||
public function imageDelete($image_id, $category_id)
|
||||
{
|
||||
|
||||
$category = Category::findOrFail($category_id);
|
||||
$iq_image = IqImage::findOrFail($image_id);
|
||||
|
||||
if($iq_image->id == $category->iq_image->id){
|
||||
$file = 'images/iq_images/'.$iq_image->filename;
|
||||
if ($iq_image->id == $category->iq_image->id) {
|
||||
$file = 'images/iq_images/' . $iq_image->filename;
|
||||
\Storage::disk('public')->delete($file);
|
||||
$category->headline_image_id = NULL;
|
||||
$category->save();
|
||||
|
|
@ -212,14 +210,13 @@ class CategoryController extends Controller
|
|||
|
||||
\Session()->flash('alert-success', __('msg.file_deleted'));
|
||||
return redirect(route('admin_product_category_edit', [$category->id]));
|
||||
|
||||
}
|
||||
\Session()->flash('alert-danger', __('msg.file_not_found'));
|
||||
return redirect(route('admin_product_category_edit', [$category->id]));
|
||||
|
||||
}
|
||||
|
||||
public function imageAttribute($image_id, $attr, $val = false){
|
||||
public function imageAttribute($image_id, $attr, $val = false)
|
||||
{
|
||||
|
||||
$iq_image = IqImage::findOrFail($image_id);
|
||||
|
||||
|
|
@ -228,7 +225,5 @@ class CategoryController extends Controller
|
|||
|
||||
\Session()->flash('alert-success', "Wert gespeichert");
|
||||
return redirect()->back();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,12 +18,11 @@ class CustomerController extends Controller
|
|||
{
|
||||
$this->middleware('admin');
|
||||
$this->customerRepository = $customerRepository;
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if(Request::get('reset') === 'filter'){
|
||||
if (Request::get('reset') === 'filter') {
|
||||
set_user_attr('filter_member_id', null);
|
||||
set_user_attr('filter_customer_member', null);
|
||||
return redirect(route('admin_customers'));
|
||||
|
|
@ -47,19 +46,31 @@ class CustomerController extends Controller
|
|||
return view('admin.customer.detail', $data);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
$result = $this->customerRepository->deleteCustomer($shopping_user);
|
||||
if (!$result) {
|
||||
return back()->with('alert-error', 'Kunde hat Bestellungen. Löschen nicht möglich.');
|
||||
} else {
|
||||
\Session()->flash('alert-success', 'Kunde wurde gelöscht');
|
||||
return redirect(route('admin_customers'));
|
||||
}
|
||||
return redirect(route('admin_customers'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
if($id === "new"){
|
||||
if ($id === "new") {
|
||||
$shopping_user = new ShoppingUser();
|
||||
$shopping_user->id = "new";
|
||||
}else{
|
||||
} else {
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
}
|
||||
$data = [
|
||||
'shopping_user' => $shopping_user,
|
||||
'isAdmin' => true,
|
||||
'isView' => 'customer',
|
||||
|
||||
];
|
||||
return view('admin.customer.edit', $data);
|
||||
}
|
||||
|
|
@ -84,24 +95,24 @@ class CustomerController extends Controller
|
|||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('admin_customer_detail', [$shopping_user->id]));
|
||||
}
|
||||
if($data['action'] === 'shopping-user-store') {
|
||||
if ($data['action'] === 'shopping-user-store') {
|
||||
$rules = array(
|
||||
'billing_salutation' => 'required',
|
||||
'billing_firstname'=>'required',
|
||||
'billing_lastname'=>'required',
|
||||
'billing_email'=>'required|email',
|
||||
'billing_address'=>'required',
|
||||
'billing_zipcode'=>'required',
|
||||
'billing_firstname' => 'required',
|
||||
'billing_lastname' => 'required',
|
||||
'billing_email' => 'required|email',
|
||||
'billing_address' => 'required',
|
||||
'billing_zipcode' => 'required',
|
||||
'billing_city' => 'required',
|
||||
'billing_country_id' => 'required'
|
||||
);
|
||||
|
||||
if(!Request::get('same_as_billing')){
|
||||
if (!Request::get('same_as_billing')) {
|
||||
$rules = array_merge($rules, [
|
||||
'shipping_firstname'=>'required',
|
||||
'shipping_lastname'=>'required',
|
||||
'shipping_address'=>'required',
|
||||
'shipping_zipcode'=>'required',
|
||||
'shipping_firstname' => 'required',
|
||||
'shipping_lastname' => 'required',
|
||||
'shipping_address' => 'required',
|
||||
'shipping_zipcode' => 'required',
|
||||
'shipping_city' => 'required',
|
||||
'shipping_salutation' => 'required',
|
||||
'shipping_country_id' => 'required'
|
||||
|
|
@ -117,10 +128,10 @@ class CustomerController extends Controller
|
|||
$data['language'] = isset($data['language']) ? $data['language'] : \App::getLocale();
|
||||
$data['has_buyed'] = isset($data['has_buyed']) ? true : false;
|
||||
$data['subscribed'] = isset($data['subscribed']) ? true : false;
|
||||
//subscribed can only true when has_buyed ist active
|
||||
//subscribed can only true when has_buyed ist active
|
||||
$data['subscribed'] = $data['has_buyed'] ? $data['subscribed'] : false;
|
||||
|
||||
/* if($shopping_user->auth_user_id > 0){
|
||||
/* if($shopping_user->auth_user_id > 0){
|
||||
$data['has_buyed'] = true;
|
||||
$data['subscribed'] = false;
|
||||
}*/
|
||||
|
|
@ -134,7 +145,6 @@ class CustomerController extends Controller
|
|||
\Session()->flash('alert-save', true);
|
||||
}
|
||||
return redirect(route('admin_customer_detail', [$shopping_user->id]));
|
||||
|
||||
}
|
||||
|
||||
public function getCustomers()
|
||||
|
|
@ -142,10 +152,10 @@ class CustomerController extends Controller
|
|||
$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') != ""){
|
||||
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'));
|
||||
/* 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);
|
||||
|
|
@ -168,19 +178,19 @@ class CustomerController extends Controller
|
|||
return $ShoppingUser->billing_country ? $ShoppingUser->billing_country->getLocated() : '';
|
||||
})
|
||||
->addColumn('isMember', function (ShoppingUser $ShoppingUser) {
|
||||
return get_active_badge($ShoppingUser->auth_user_id).($ShoppingUser->mode==='dev' ? ' <span class="badge badge-warning">dev</span>' : '');
|
||||
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->is_like){
|
||||
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.'"
|
||||
data-id="' . $ShoppingUser->id . '"
|
||||
data-action="shopping-user-is-like-member"
|
||||
data-back="'.route('admin_customers').'"
|
||||
data-back="' . route('admin_customers') . '"
|
||||
data-modal="modal-xl"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-edit"></span> Berater zuordnen</button>';
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-edit"></span> Berater zuordnen</button>';
|
||||
}
|
||||
if($ShoppingUser->member){
|
||||
return '<a href="'.route('admin_lead_edit', [$ShoppingUser->member_id]).'">'.$ShoppingUser->member->getFullName().'</a>';
|
||||
if ($ShoppingUser->member) {
|
||||
return '<a href="' . route('admin_lead_edit', [$ShoppingUser->member_id]) . '">' . $ShoppingUser->member->getFullName() . '</a>';
|
||||
}
|
||||
|
||||
return '';
|
||||
|
|
@ -191,9 +201,9 @@ class CustomerController extends Controller
|
|||
->addColumn('subscribed', function (ShoppingUser $ShoppingUser) {
|
||||
return get_active_badge($ShoppingUser->subscribed);
|
||||
})
|
||||
->filterColumn('billing_email', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('billing_email', 'LIKE', '%'.$keyword.'%');
|
||||
->filterColumn('billing_email', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->where('billing_email', 'LIKE', '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
|
|
@ -207,4 +217,4 @@ class CustomerController extends Controller
|
|||
->rawColumns(['id', 'subscribed', 'isMember', 'member_id'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Jobs\CancelShipmentJob;
|
||||
use App\Jobs\CreateReturnLabelJob;
|
||||
use App\Jobs\TrackShipmentJob;
|
||||
// Old DHL model replaced with new package model
|
||||
use Acme\Dhl\Models\DhlShipment;
|
||||
use App\Jobs\CancelShipmentJob;
|
||||
// Old DHL model replaced with new package model
|
||||
use App\Jobs\CreateReturnLabelJob;
|
||||
use App\Mail\MailDhlTracking;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Services\DhlModalService;
|
||||
use App\Services\DhlShipmentService;
|
||||
|
|
@ -16,21 +15,18 @@ use Exception;
|
|||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
// Import new DHL package and SettingController
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
use ZipArchive;
|
||||
|
||||
// Import new DHL package and SettingController
|
||||
use Acme\Dhl\DhlManager;
|
||||
|
||||
/**
|
||||
* DHL Shipment Controller
|
||||
*
|
||||
*
|
||||
* Handles all DHL shipment operations including creation, cancellation,
|
||||
* tracking, and return labels. Provides both web interface and AJAX endpoints.
|
||||
*/
|
||||
|
|
@ -54,7 +50,7 @@ class DhlShipmentController extends Controller
|
|||
{
|
||||
try {
|
||||
// Get DHL configuration with admin settings
|
||||
$settingController = new \App\Http\Controllers\SettingController();
|
||||
$settingController = new \App\Http\Controllers\SettingController;
|
||||
$dhlConfig = $settingController->getDhlConfig();
|
||||
|
||||
// Create DhlClient with merged configuration
|
||||
|
|
@ -74,34 +70,31 @@ class DhlShipmentController extends Controller
|
|||
'message' => 'DHL API Verbindung erfolgreich getestet!',
|
||||
'details' => [
|
||||
'base_url' => $dhlConfig['base_url'],
|
||||
'using_admin_config' => !empty($dhlConfig['api_key'])
|
||||
]
|
||||
'using_admin_config' => ! empty($dhlConfig['api_key']),
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$result = [
|
||||
'success' => false,
|
||||
'message' => 'DHL API Verbindung fehlgeschlagen. Prüfen Sie Ihre Zugangsdaten.'
|
||||
'message' => 'DHL API Verbindung fehlgeschlagen. Prüfen Sie Ihre Zugangsdaten.',
|
||||
];
|
||||
}
|
||||
|
||||
return response()->json($result);
|
||||
} catch (Exception $e) {
|
||||
Log::error('[DHL Controller] Test login failed', [
|
||||
'error' => $e->getMessage()
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'DHL API Test fehlgeschlagen: ' . $e->getMessage()
|
||||
'message' => 'DHL API Test fehlgeschlagen: ' . $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the DHL Cockpit (main overview)
|
||||
*
|
||||
* @param Request $request
|
||||
* @return View
|
||||
*/
|
||||
public function index(Request $request): View
|
||||
{
|
||||
|
|
@ -118,9 +111,6 @@ class DhlShipmentController extends Controller
|
|||
|
||||
/**
|
||||
* Provides data for the DHL Cockpit DataTable.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function datatable(Request $request): JsonResponse
|
||||
{
|
||||
|
|
@ -161,19 +151,22 @@ class DhlShipmentController extends Controller
|
|||
return '<label class="custom-control custom-checkbox mb-0"><input type="checkbox" class="custom-control-input shipment-checkbox" value="' . $shipment->id . '"><span class="custom-control-label"></span></label>';
|
||||
})
|
||||
->editColumn('id', function ($shipment) {
|
||||
return '<a href="' . route('admin.dhl.show', $shipment) . '" class="text-primary font-weight-semibold">#' . $shipment->id . '</a>';
|
||||
$class = $shipment->type === 'return' ? 'text-warning font-weight-bold' : 'text-primary font-weight-semibold';
|
||||
$icon = $shipment->type === 'return' ? '<i class="fas fa-undo mr-1"></i>' : '';
|
||||
return '<a href="' . route('admin.dhl.show', $shipment) . '" class="' . $class . '">' . $icon . '#' . $shipment->id . '</a>';
|
||||
})
|
||||
->addColumn('type', function ($shipment) {
|
||||
if ($shipment->type == 'outbound') {
|
||||
return '<span class="badge badge-primary"><i class="fas fa-arrow-right"></i> Ausgehend</span>';
|
||||
} else {
|
||||
return '<span class="badge badge-info"><i class="fas fa-undo"></i> Retoure</span>';
|
||||
return '<span class="badge badge-warning" style="font-size: 0.9rem; font-weight: 600;"><i class="fas fa-undo"></i> RETOURE</span>';
|
||||
}
|
||||
})
|
||||
->addColumn('order', function ($shipment) {
|
||||
if ($shipment->order_id) {
|
||||
return '<a href="' . route('admin_sales_customers_detail', $shipment->order_id) . '" class="text-primary">#' . $shipment->order_id . '</a>';
|
||||
}
|
||||
|
||||
return '<span class="text-muted">N/A</span>';
|
||||
})
|
||||
->addColumn('customer', function ($shipment) {
|
||||
|
|
@ -184,14 +177,15 @@ class DhlShipmentController extends Controller
|
|||
})
|
||||
->addColumn('status', function ($shipment) {
|
||||
$statusMap = [
|
||||
'pending' => ['class' => 'warning', 'text' => 'Wartend'],
|
||||
'created' => ['class' => 'success', 'text' => 'Erstellt'],
|
||||
'shipped' => ['class' => 'primary', 'text' => 'Versendet'],
|
||||
'pending' => ['class' => 'warning', 'text' => 'Wartend'],
|
||||
'created' => ['class' => 'success', 'text' => 'Erstellt'],
|
||||
'shipped' => ['class' => 'primary', 'text' => 'Versendet'],
|
||||
'delivered' => ['class' => 'info', 'text' => 'Zugestellt'],
|
||||
'cancelled' => ['class' => 'secondary', 'text' => 'Storniert'],
|
||||
'failed' => ['class' => 'danger', 'text' => 'Fehler'],
|
||||
'failed' => ['class' => 'danger', 'text' => 'Fehler'],
|
||||
];
|
||||
$statusInfo = $statusMap[$shipment->status] ?? ['class' => 'light', 'text' => e($shipment->status)];
|
||||
|
||||
return '<span class="badge badge-' . $statusInfo['class'] . '">' . $statusInfo['text'] . '</span>';
|
||||
})
|
||||
->addColumn('tracking_status', function ($shipment) {
|
||||
|
|
@ -199,6 +193,7 @@ class DhlShipmentController extends Controller
|
|||
return '<small class="text-muted">' . e($shipment->tracking_status) . '</small>' .
|
||||
($shipment->last_tracked_at ? '<br><small class="text-muted">' . $shipment->last_tracked_at->format('d.m.Y H:i') . '</small>' : '');
|
||||
}
|
||||
|
||||
return '<span class="text-muted">-</span>';
|
||||
})
|
||||
->editColumn('weight_kg', function ($shipment) {
|
||||
|
|
@ -213,25 +208,36 @@ class DhlShipmentController extends Controller
|
|||
if ($shipment->label_path) {
|
||||
$buttons .= '<a href="' . route('admin.dhl.download-label', $shipment) . '" class="btn btn-sm btn-outline-success" data-toggle="tooltip" title="Label herunterladen"><i class="fas fa-download"></i></a>';
|
||||
}
|
||||
/* Todo: Add tracking button
|
||||
if ($shipment->canCancel()) {
|
||||
$buttons .= '<button type="button" class="btn btn-sm btn-outline-warning cancel-shipment-btn" data-shipment-id="' . $shipment->id . '" data-toggle="tooltip" title="Sendung stornieren"><i class="fas fa-ban"></i></button>';
|
||||
// Email button
|
||||
if ($shipment->dhl_shipment_no && $shipment->canSendTrackingEmail()) {
|
||||
$emailTitle = $shipment->wasTrackingEmailSent()
|
||||
? 'Tracking-E-Mail erneut senden (gesendet: ' . $shipment->tracking_email_sent_at->format('d.m.Y H:i') . ')'
|
||||
: 'Tracking-E-Mail senden';
|
||||
$emailClass = $shipment->wasTrackingEmailSent() ? 'btn-success' : 'btn-outline-info';
|
||||
$buttons .= '<button type="button" class="btn btn-sm ' . $emailClass . ' send-tracking-email-btn" data-shipment-id="' . $shipment->id . '" data-toggle="tooltip" title="' . $emailTitle . '"><i class="fas fa-envelope"></i></button>';
|
||||
}
|
||||
if ($shipment->type == 'outbound' && !$shipment->returns()->count()) {
|
||||
// Cancel button
|
||||
if ($shipment->canCancel()) {
|
||||
$buttons .= '<button type="button" class="btn btn-sm btn-outline-danger cancel-shipment-btn" data-shipment-id="' . $shipment->id . '" data-toggle="tooltip" title="Sendung stornieren"><i class="fas fa-ban"></i></button>';
|
||||
}
|
||||
// Return label button
|
||||
if ($shipment->type == 'outbound' && ! $shipment->returns()->count()) {
|
||||
$buttons .= '<button type="button" class="btn btn-sm btn-outline-info create-return-btn" data-shipment-id="' . $shipment->id . '" data-toggle="tooltip" title="Retourenlabel erstellen"><i class="fas fa-undo"></i></button>';
|
||||
}
|
||||
*/
|
||||
$buttons .= '</div>';
|
||||
|
||||
return $buttons;
|
||||
})
|
||||
->addColumn('DT_RowClass', function ($shipment) {
|
||||
return $shipment->type === 'return' ? 'return-shipment' : '';
|
||||
})
|
||||
->rawColumns(['checkbox', 'id', 'type', 'order', 'customer', 'dhl_shipment_no', 'status', 'tracking_status', 'actions'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new shipment
|
||||
*
|
||||
* @param ShoppingOrder $order
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function create(ShoppingOrder $order): View|\Illuminate\Http\RedirectResponse
|
||||
|
|
@ -251,21 +257,18 @@ class DhlShipmentController extends Controller
|
|||
|
||||
/**
|
||||
* Store a new shipment (async via queue)
|
||||
*
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
// Use DhlModalService for validation
|
||||
$dhlModalService = new DhlModalService();
|
||||
$dhlModalService = new DhlModalService;
|
||||
$validationResult = $dhlModalService->validateShipmentData($request->all());
|
||||
|
||||
if (!$validationResult['valid']) {
|
||||
if (! $validationResult['valid']) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Validierungsfehler: ' . implode(', ', $validationResult['errors'])
|
||||
'message' => 'Validierungsfehler: ' . implode(', ', $validationResult['errors']),
|
||||
], 422);
|
||||
}
|
||||
|
||||
|
|
@ -286,6 +289,8 @@ class DhlShipmentController extends Controller
|
|||
'shipping_city' => 'required|string|max:50',
|
||||
'shipping_country_id' => 'required|exists:countries,id',
|
||||
'shipping_phone' => 'nullable|string|max:20',
|
||||
'shipping_email' => 'required|email|max:100',
|
||||
'shipping_postnumber' => 'nullable|string|max:20',
|
||||
]);
|
||||
|
||||
$order = ShoppingOrder::findOrFail($request->order_id);
|
||||
|
|
@ -313,11 +318,11 @@ class DhlShipmentController extends Controller
|
|||
'auto_track' => $request->get('auto_track', true),
|
||||
'shipping_address' => $shippingAddress,
|
||||
'services' => $request->get('services', []),
|
||||
'dimensions' => $request->only(['length', 'width', 'height'])
|
||||
'dimensions' => $request->only(['length', 'width', 'height']),
|
||||
];
|
||||
|
||||
// Use DhlShipmentService (handles queue/sync automatically based on config)
|
||||
$dhlShipmentService = new DhlShipmentService();
|
||||
$dhlShipmentService = new DhlShipmentService;
|
||||
$result = $dhlShipmentService->createShipment($order, (float) $request->weight, $options);
|
||||
|
||||
Log::info('[DHL Controller] Shipment creation processed', [
|
||||
|
|
@ -336,16 +341,13 @@ class DhlShipmentController extends Controller
|
|||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Fehler beim Erstellen der Sendung: ' . $e->getMessage()
|
||||
'message' => 'Fehler beim Erstellen der Sendung: ' . $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified shipment
|
||||
*
|
||||
* @param DhlShipment $shipment
|
||||
* @return View
|
||||
*/
|
||||
public function show(DhlShipment $shipment): View
|
||||
{
|
||||
|
|
@ -356,57 +358,49 @@ class DhlShipmentController extends Controller
|
|||
|
||||
/**
|
||||
* Cancel the specified shipment
|
||||
*
|
||||
* @param Request $request
|
||||
* @param DhlShipment $shipment
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function cancel(Request $request, DhlShipment $shipment): JsonResponse
|
||||
{
|
||||
try {
|
||||
// Validate cancellation is possible
|
||||
if (!$shipment->canCancel()) {
|
||||
if (! $shipment->canCancel()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Diese Sendung kann nicht mehr storniert werden.'
|
||||
'message' => 'Diese Sendung kann nicht mehr storniert werden.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
// Dispatch cancellation job
|
||||
// Use DhlShipmentService (handles queue/sync automatically based on config)
|
||||
$options = [
|
||||
'priority' => $request->get('priority', 'normal')
|
||||
'priority' => $request->get('priority', 'normal'),
|
||||
];
|
||||
|
||||
CancelShipmentJob::dispatch($shipment, $options);
|
||||
$dhlShipmentService = new DhlShipmentService;
|
||||
$result = $dhlShipmentService->cancelShipment($shipment, $options);
|
||||
|
||||
Log::info('[DHL Controller] Shipment cancellation job dispatched', [
|
||||
Log::info('[DHL Controller] Shipment cancellation processed', [
|
||||
'shipment_id' => $shipment->id,
|
||||
'shipment_number' => $shipment->shipment_number,
|
||||
'dhl_shipment_no' => $shipment->dhl_shipment_no,
|
||||
'queued' => $result['queued'] ?? false,
|
||||
'success' => $result['success'] ?? false,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Sendung wird storniert...'
|
||||
]);
|
||||
return response()->json($result);
|
||||
} catch (Exception $e) {
|
||||
Log::error('[DHL Controller] Failed to dispatch shipment cancellation', [
|
||||
Log::error('[DHL Controller] Failed to process shipment cancellation', [
|
||||
'error' => $e->getMessage(),
|
||||
'shipment_id' => $shipment->id,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Fehler beim Stornieren der Sendung: ' . $e->getMessage()
|
||||
'message' => 'Fehler beim Stornieren der Sendung: ' . $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create return label for the specified shipment
|
||||
*
|
||||
* @param Request $request
|
||||
* @param DhlShipment $shipment
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function createReturnLabel(Request $request, DhlShipment $shipment): JsonResponse
|
||||
{
|
||||
|
|
@ -415,7 +409,7 @@ class DhlShipmentController extends Controller
|
|||
if ($shipment->type !== 'outbound') {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Retourenlabels können nur für ausgehende Sendungen erstellt werden.'
|
||||
'message' => 'Retourenlabels können nur für ausgehende Sendungen erstellt werden.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
|
|
@ -427,58 +421,156 @@ class DhlShipmentController extends Controller
|
|||
if ($existingReturn) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Für diese Sendung existiert bereits ein Retourenlabel.'
|
||||
'message' => 'Für diese Sendung existiert bereits ein Retourenlabel.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
// Dispatch return label creation job
|
||||
$options = [
|
||||
'auto_track' => $request->get('auto_track', false),
|
||||
'priority' => $request->get('priority', 'normal')
|
||||
];
|
||||
// Check DHL_USE_QUEUE configuration
|
||||
$settingController = new SettingController();
|
||||
$dhlConfig = $settingController->getDhlConfig();
|
||||
$useQueue = $dhlConfig['use_queue'] ?? false;
|
||||
|
||||
CreateReturnLabelJob::dispatch($shipment, $options);
|
||||
if ($useQueue) {
|
||||
// Dispatch return label creation job
|
||||
$options = [
|
||||
'auto_track' => $request->get('auto_track', false),
|
||||
'priority' => $request->get('priority', 'normal'),
|
||||
];
|
||||
|
||||
Log::info('[DHL Controller] Return label creation job dispatched', [
|
||||
'original_shipment_id' => $shipment->id,
|
||||
'shipment_number' => $shipment->shipment_number,
|
||||
]);
|
||||
CreateReturnLabelJob::dispatch($shipment, $options);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Retourenlabel wird erstellt...'
|
||||
]);
|
||||
Log::info('[DHL Controller] Return label creation job dispatched', [
|
||||
'original_shipment_id' => $shipment->id,
|
||||
'shipment_number' => $shipment->dhl_shipment_no,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Retourenlabel wird im Hintergrund erstellt. Dies kann einige Sekunden dauern.',
|
||||
]);
|
||||
} else {
|
||||
// Create synchronously
|
||||
$result = $this->createReturnLabelSync($shipment);
|
||||
|
||||
return response()->json($result);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Log::error('[DHL Controller] Failed to dispatch return label creation', [
|
||||
Log::error('[DHL Controller] Failed to create return label', [
|
||||
'error' => $e->getMessage(),
|
||||
'shipment_id' => $shipment->id,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Fehler beim Erstellen des Retourenlabels: ' . $e->getMessage()
|
||||
'message' => 'Fehler beim Erstellen des Retourenlabels: ' . $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create return label synchronously
|
||||
*/
|
||||
private function createReturnLabelSync(DhlShipment $shipment): array
|
||||
{
|
||||
try {
|
||||
Log::info('[DHL Controller] Creating return label synchronously', [
|
||||
'original_shipment_id' => $shipment->id,
|
||||
]);
|
||||
|
||||
// Get DHL configuration
|
||||
$settingController = new SettingController();
|
||||
$dhlConfig = $settingController->getDhlConfig();
|
||||
|
||||
// Initialize DHL client
|
||||
$dhlClient = new \Acme\Dhl\Support\DhlClient(
|
||||
$dhlConfig['base_url'],
|
||||
$dhlConfig['api_key'],
|
||||
$dhlConfig['username'],
|
||||
$dhlConfig['password']
|
||||
);
|
||||
|
||||
// Use ReturnsService instead of ShippingService
|
||||
$returnsService = new \Acme\Dhl\Services\ReturnsService($dhlClient);
|
||||
|
||||
// Prepare return label data
|
||||
$order = $shipment->shoppingOrder;
|
||||
$recipient = $shipment->recipient ?? [];
|
||||
|
||||
$returnData = [
|
||||
'order_id' => $order->id,
|
||||
'original_shipment_id' => $shipment->id,
|
||||
'weight_kg' => $shipment->weight_kg,
|
||||
'label_format' => $shipment->label_format ?? 'PDF',
|
||||
|
||||
// Shipper: Customer sends back to us (swap addresses)
|
||||
'shipper' => [
|
||||
'name' => trim(($recipient['firstname'] ?? '') . ' ' . ($recipient['lastname'] ?? '')),
|
||||
'name2' => $recipient['company'] ?? '',
|
||||
'street' => $recipient['street'] ?? '',
|
||||
'houseNumber' => $recipient['houseNumber'] ?? '',
|
||||
'postalCode' => $recipient['postalCode'] ?? '',
|
||||
'city' => $recipient['city'] ?? '',
|
||||
'country' => $recipient['country'] ?? 'DEU',
|
||||
'email' => $recipient['email'] ?? '',
|
||||
'phone' => $recipient['phone'] ?? '',
|
||||
],
|
||||
|
||||
// Consignee: Our warehouse
|
||||
'consignee' => [
|
||||
'name' => $dhlConfig['sender']['company'] ?? 'mivita care gmbh',
|
||||
'name2' => $dhlConfig['sender']['name'] ?? '',
|
||||
'street' => $dhlConfig['sender']['street'] ?? 'Leinfeld',
|
||||
'houseNumber' => $dhlConfig['sender']['house_number'] ?? '2',
|
||||
'postalCode' => $dhlConfig['sender']['postalCode'] ?? '87755',
|
||||
'city' => $dhlConfig['sender']['city'] ?? 'Kirchhaslach',
|
||||
'country' => $dhlConfig['sender']['country'] ?? 'DEU',
|
||||
'email' => $dhlConfig['sender']['email'] ?? 'versand@mivita.care',
|
||||
'phone' => $dhlConfig['sender']['phone'] ?? '+49 123 456789',
|
||||
],
|
||||
];
|
||||
|
||||
// Create the return label using ReturnsService
|
||||
$result = $returnsService->createReturn($returnData);
|
||||
|
||||
Log::info('[DHL Controller] Return label created successfully (sync)', [
|
||||
'original_shipment_id' => $shipment->id,
|
||||
'return_shipment_number' => $result['returnNumber'] ?? 'N/A',
|
||||
]);
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'message' => 'Retourenlabel wurde erfolgreich erstellt!',
|
||||
'shipment_number' => $result['returnNumber'] ?? null,
|
||||
'return_shipment' => $result['returnShipment'] ?? null,
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
Log::error('[DHL Controller] Return label creation failed (sync)', [
|
||||
'original_shipment_id' => $shipment->id,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'Fehler beim Erstellen des Retourenlabels: ' . $e->getMessage(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update tracking status for the specified shipment
|
||||
*
|
||||
* @param DhlShipment $shipment
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function updateTracking(DhlShipment $shipment): JsonResponse
|
||||
{
|
||||
try {
|
||||
if (!$shipment->dhl_shipment_no) {
|
||||
if (! $shipment->dhl_shipment_no) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Keine DHL-Sendungsnummer verfügbar.'
|
||||
'message' => 'Keine DHL-Sendungsnummer verfügbar.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
// Use DhlTrackingService (handles queue/sync automatically based on config)
|
||||
$dhlTrackingService = new DhlTrackingService();
|
||||
$dhlTrackingService = new DhlTrackingService;
|
||||
$result = $dhlTrackingService->updateTracking($shipment, ['auto_retrack' => false]);
|
||||
|
||||
Log::info('[DHL Controller] Tracking update processed', [
|
||||
|
|
@ -497,21 +589,108 @@ class DhlShipmentController extends Controller
|
|||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Fehler beim Aktualisieren der Tracking-Informationen: ' . $e->getMessage()
|
||||
'message' => 'Fehler beim Aktualisieren der Tracking-Informationen: ' . $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send tracking email to customer (supports multiple shipments per order)
|
||||
*/
|
||||
public function sendTrackingEmail(DhlShipment $shipment): JsonResponse
|
||||
{
|
||||
try {
|
||||
// Check if shipment has tracking number
|
||||
if (! $shipment->dhl_shipment_no) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Keine DHL-Sendungsnummer verfügbar.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
// Check if shipment can send email
|
||||
if (! $shipment->canSendTrackingEmail()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'E-Mail kann nicht gesendet werden. Bestellung oder E-Mail-Adresse fehlt.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
$order = $shipment->shoppingOrder;
|
||||
|
||||
// Determine recipient email: prefer shipment email, fallback to shopping user email
|
||||
$recipientEmail = null;
|
||||
if (! empty($shipment->email)) {
|
||||
$recipientEmail = $shipment->email;
|
||||
} elseif ($order->shopping_user && ! empty($order->shopping_user->email)) {
|
||||
$recipientEmail = $order->shopping_user->email;
|
||||
}
|
||||
|
||||
if (! $recipientEmail) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Keine Empfänger-E-Mail-Adresse verfügbar.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
// Collect all shipments for this order that have tracking numbers
|
||||
$allShipments = DhlShipment::where('order_id', $order->id)
|
||||
->whereNotNull('dhl_shipment_no')
|
||||
->whereIn('status', ['created', 'in_transit', 'out_for_delivery'])
|
||||
->orderBy('created_at', 'asc')
|
||||
->get();
|
||||
|
||||
// If no shipments found, use only the current one
|
||||
if ($allShipments->isEmpty()) {
|
||||
$allShipments = collect([$shipment]);
|
||||
}
|
||||
|
||||
// Send email with all shipments
|
||||
Mail::to($recipientEmail)->send(new MailDhlTracking($allShipments, $order));
|
||||
|
||||
// Mark all included shipments as sent
|
||||
foreach ($allShipments as $s) {
|
||||
$s->markTrackingEmailSent('manual');
|
||||
}
|
||||
|
||||
Log::info('[DHL Controller] Tracking email sent', [
|
||||
'shipment_ids' => $allShipments->pluck('id')->toArray(),
|
||||
'shipments_count' => $allShipments->count(),
|
||||
'dhl_shipment_nos' => $allShipments->pluck('dhl_shipment_no')->toArray(),
|
||||
'email' => $recipientEmail,
|
||||
'type' => 'manual',
|
||||
]);
|
||||
|
||||
$message = $allShipments->count() > 1
|
||||
? "Tracking-E-Mail mit {$allShipments->count()} Sendungen wurde erfolgreich an {$recipientEmail} gesendet."
|
||||
: "Tracking-E-Mail wurde erfolgreich an {$recipientEmail} gesendet.";
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => $message,
|
||||
'sent_at' => now()->format('d.m.Y H:i'),
|
||||
'shipments_count' => $allShipments->count(),
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
Log::error('[DHL Controller] Failed to send tracking email', [
|
||||
'error' => $e->getMessage(),
|
||||
'shipment_id' => $shipment->id,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Fehler beim Senden der Tracking-E-Mail: ' . $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download shipping label
|
||||
*
|
||||
* @param DhlShipment $shipment
|
||||
* @return Response
|
||||
*/
|
||||
public function downloadLabel(DhlShipment $shipment): Response
|
||||
{
|
||||
try {
|
||||
if (!$shipment->label_path || !Storage::exists($shipment->label_path)) {
|
||||
if (! $shipment->label_path || ! Storage::exists($shipment->label_path)) {
|
||||
abort(404, 'Versandlabel nicht gefunden.');
|
||||
}
|
||||
|
||||
|
|
@ -538,9 +717,6 @@ class DhlShipmentController extends Controller
|
|||
* Generate descriptive filename for DHL label
|
||||
* Format: DHL-Kundenname-Sendungsnummer-Datum.pdf
|
||||
* Example: DHL-Geraldine-Seebacher-0034043333301020015589177-15092025.pdf
|
||||
*
|
||||
* @param DhlShipment $shipment
|
||||
* @return string
|
||||
*/
|
||||
private function generateLabelFilename(DhlShipment $shipment): string
|
||||
{
|
||||
|
|
@ -586,8 +762,7 @@ class DhlShipmentController extends Controller
|
|||
|
||||
/**
|
||||
* Batch operations (multiple shipments)
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JsonResponse|BinaryFileResponse
|
||||
*/
|
||||
public function batchAction(Request $request)
|
||||
|
|
@ -621,7 +796,7 @@ class DhlShipmentController extends Controller
|
|||
|
||||
case 'update_tracking':
|
||||
if ($shipment->dhl_shipment_no) {
|
||||
$dhlTrackingService = new DhlTrackingService();
|
||||
$dhlTrackingService = new DhlTrackingService;
|
||||
$trackingResult = $dhlTrackingService->updateTracking($shipment, ['auto_retrack' => false]);
|
||||
|
||||
if ($trackingResult['success']) {
|
||||
|
|
@ -639,7 +814,7 @@ class DhlShipmentController extends Controller
|
|||
$labels[] = [
|
||||
'shipment' => $shipment,
|
||||
'filename' => $this->generateLabelFilename($shipment),
|
||||
'path' => $shipment->label_path
|
||||
'path' => $shipment->label_path,
|
||||
];
|
||||
$processed++;
|
||||
} else {
|
||||
|
|
@ -653,7 +828,7 @@ class DhlShipmentController extends Controller
|
|||
}
|
||||
|
||||
// Handle batch label download
|
||||
if ($action === 'download_labels' && !empty($labels)) {
|
||||
if ($action === 'download_labels' && ! empty($labels)) {
|
||||
return $this->createLabelsZip($labels);
|
||||
}
|
||||
|
||||
|
|
@ -677,16 +852,13 @@ class DhlShipmentController extends Controller
|
|||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Fehler bei der Stapelverarbeitung: ' . $e->getMessage()
|
||||
'message' => 'Fehler bei der Stapelverarbeitung: ' . $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Public tracking page (for customers)
|
||||
*
|
||||
* @param Request $request
|
||||
* @return View|JsonResponse
|
||||
*/
|
||||
public function track(Request $request): View|JsonResponse
|
||||
{
|
||||
|
|
@ -698,15 +870,15 @@ class DhlShipmentController extends Controller
|
|||
try {
|
||||
$shipment = DhlShipment::where('dhl_shipment_no', $request->tracking_number)->first();
|
||||
|
||||
if (!$shipment) {
|
||||
if (! $shipment) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Sendung nicht gefunden.'
|
||||
'message' => 'Sendung nicht gefunden.',
|
||||
], 404);
|
||||
}
|
||||
|
||||
// Use DhlTrackingService for tracking update
|
||||
$dhlTrackingService = new DhlTrackingService();
|
||||
$dhlTrackingService = new DhlTrackingService;
|
||||
$trackingResult = $dhlTrackingService->updateTracking($shipment, ['auto_retrack' => false]);
|
||||
|
||||
return response()->json([
|
||||
|
|
@ -717,7 +889,7 @@ class DhlShipmentController extends Controller
|
|||
'status' => $shipment->status,
|
||||
'tracking_status' => $shipment->tracking_status,
|
||||
'last_tracked_at' => $shipment->last_tracked_at?->format('d.m.Y H:i'),
|
||||
]
|
||||
],
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
Log::error('[DHL Controller] Public tracking failed', [
|
||||
|
|
@ -727,7 +899,7 @@ class DhlShipmentController extends Controller
|
|||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Fehler beim Abrufen der Tracking-Informationen.'
|
||||
'message' => 'Fehler beim Abrufen der Tracking-Informationen.',
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
|
@ -737,23 +909,23 @@ class DhlShipmentController extends Controller
|
|||
|
||||
/**
|
||||
* Create ZIP file with multiple labels
|
||||
*
|
||||
* @param array $labels Array of label data
|
||||
*
|
||||
* @param array $labels Array of label data
|
||||
* @return Response|BinaryFileResponse
|
||||
*/
|
||||
private function createLabelsZip(array $labels)
|
||||
{
|
||||
try {
|
||||
$zip = new ZipArchive();
|
||||
$zip = new ZipArchive;
|
||||
$zipFilename = 'dhl_labels_' . date('Y-m-d_H-i-s') . '.zip';
|
||||
$zipPath = storage_path('app/temp/' . $zipFilename);
|
||||
|
||||
// Ensure temp directory exists
|
||||
if (!file_exists(storage_path('app/temp'))) {
|
||||
if (! file_exists(storage_path('app/temp'))) {
|
||||
mkdir(storage_path('app/temp'), 0755, true);
|
||||
}
|
||||
|
||||
if ($zip->open($zipPath, ZipArchive::CREATE) !== TRUE) {
|
||||
if ($zip->open($zipPath, ZipArchive::CREATE) !== true) {
|
||||
throw new Exception('ZIP-Datei konnte nicht erstellt werden.');
|
||||
}
|
||||
|
||||
|
|
@ -779,19 +951,19 @@ class DhlShipmentController extends Controller
|
|||
Log::info('[DHL Controller] Labels ZIP created', [
|
||||
'zip_file' => $zipFilename,
|
||||
'files_count' => $addedFiles,
|
||||
'total_labels' => count($labels)
|
||||
'total_labels' => count($labels),
|
||||
]);
|
||||
|
||||
return response()->download($zipPath, $zipFilename)->deleteFileAfterSend(true);
|
||||
} catch (Exception $e) {
|
||||
Log::error('[DHL Controller] Failed to create labels ZIP', [
|
||||
'error' => $e->getMessage(),
|
||||
'labels_count' => count($labels)
|
||||
'labels_count' => count($labels),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Fehler beim Erstellen der ZIP-Datei: ' . $e->getMessage()
|
||||
'message' => 'Fehler beim Erstellen der ZIP-Datei: ' . $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class HomeController extends Controller
|
|||
$data = [
|
||||
'user' => Auth::user(),
|
||||
'now' => Carbon::now(),
|
||||
'dashboardNews' => \App\Models\DashboardNews::getActiveNews(),
|
||||
];
|
||||
return view('home', $data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ class LeadController extends Controller
|
|||
{
|
||||
$this->middleware('admin');
|
||||
$this->userRepo = $userRepo;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -49,7 +48,8 @@ class LeadController extends Controller
|
|||
}
|
||||
|
||||
|
||||
private function setFilterVars(){
|
||||
private function setFilterVars()
|
||||
{
|
||||
|
||||
/*if(!session('leads_filter_month')){
|
||||
session(['leads_filter_month' => intval(date('m'))]);
|
||||
|
|
@ -57,10 +57,10 @@ class LeadController extends Controller
|
|||
if(!session('leads_filter_year')){
|
||||
session(['leads_filter_year' => intval(date('Y'))]);
|
||||
}*/
|
||||
|
||||
|
||||
session(['leads_filter_sponsor_id' => Request::get('leads_filter_sponsor_id')]);
|
||||
|
||||
/* if(Request::get('leads_filter_month')){
|
||||
|
||||
/* if(Request::get('leads_filter_month')){
|
||||
session(['leads_filter_month' => Request::get('leads_filter_month')]);
|
||||
}
|
||||
if(Request::get('leads_filter_year')){
|
||||
|
|
@ -76,16 +76,16 @@ class LeadController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
if($id === "new"){
|
||||
if ($id === "new") {
|
||||
$user = new User();
|
||||
$user->account = new UserAccount();
|
||||
$user->account->same_as_billing = 1;
|
||||
$user->account->country_id = 1;
|
||||
$user->account->shipping_country_id = 1;
|
||||
$user->id = "new";
|
||||
}else{
|
||||
} else {
|
||||
$user = User::withTrashed()->findOrFail($id);
|
||||
if(!$user->account){
|
||||
if (!$user->account) {
|
||||
$user->account = new UserAccount();
|
||||
}
|
||||
}
|
||||
|
|
@ -108,27 +108,27 @@ class LeadController extends Controller
|
|||
$m_data_load = false;
|
||||
$m_data_error = false;
|
||||
$data = Request::all();
|
||||
if(!isset($data['edit_m_data_key']) || $data['edit_m_data_key'] !== config('mivita.edit_data_pass')){
|
||||
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{
|
||||
} else {
|
||||
$m_data_load = true;
|
||||
}
|
||||
|
||||
if($id === "new"){
|
||||
if ($id === "new") {
|
||||
$user = new User();
|
||||
$user->account = new UserAccount();
|
||||
$user->account->same_as_billing = 1;
|
||||
$user->account->country_id = 1;
|
||||
$user->account->shipping_country_id = 1;
|
||||
$user->id = "new";
|
||||
}else{
|
||||
} else {
|
||||
$user = User::withTrashed()->findOrFail($id);
|
||||
if(!$user->account){
|
||||
if (!$user->account) {
|
||||
$user->account = new UserAccount();
|
||||
}
|
||||
}
|
||||
$next_account_id = UserAccount::withTrashed()->max('m_account') +1;
|
||||
if($user->account->m_account === null){
|
||||
$next_account_id = UserAccount::withTrashed()->max('m_account') + 1;
|
||||
if ($user->account->m_account === null) {
|
||||
$user->account->m_account = $next_account_id;
|
||||
}
|
||||
|
||||
|
|
@ -152,16 +152,16 @@ class LeadController extends Controller
|
|||
|
||||
$data = Request::all();
|
||||
$show = Request::get('show');
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_validate" && isset($data['user_id'])){
|
||||
if (isset($data['action']) && $data['action'] == "reverse_charge_validate" && isset($data['user_id'])) {
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
return $this->userRepo->reverse_charge_validate($data, $user, route('admin_lead_edit', [$user->id]));
|
||||
}
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_delete" && isset($data['user_id'])){
|
||||
if (isset($data['action']) && $data['action'] == "reverse_charge_delete" && isset($data['user_id'])) {
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
return $this->userRepo->reverse_charge_delete($data, $user, route('admin_lead_edit', [$user->id]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if(isset($data['reverse_charge_validate']) && isset($data['user_id'])){
|
||||
|
|
@ -183,18 +183,18 @@ class LeadController extends Controller
|
|||
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'first_name'=>'required',
|
||||
'last_name'=>'required',
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'email-confirm' => 'required|same:email',
|
||||
);
|
||||
}else{
|
||||
} else {
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'first_name'=>'required',
|
||||
'last_name'=>'required',
|
||||
'address'=>'required',
|
||||
'zipcode'=>'required',
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'address' => 'required',
|
||||
'zipcode' => 'required',
|
||||
'city' => 'required',
|
||||
'email' => 'required|string|email|max:255|exists:users,email',
|
||||
'email-confirm' => 'required|same:email',
|
||||
|
|
@ -202,12 +202,12 @@ class LeadController extends Controller
|
|||
'bank_iban' => 'required',
|
||||
'bank_bic' => 'required',
|
||||
);
|
||||
if(!Request::get('same_as_billing')){
|
||||
if (!Request::get('same_as_billing')) {
|
||||
$rules = array_merge($rules, [
|
||||
'shipping_firstname'=>'required',
|
||||
'shipping_lastname'=>'required',
|
||||
'shipping_address'=>'required',
|
||||
'shipping_zipcode'=>'required',
|
||||
'shipping_firstname' => 'required',
|
||||
'shipping_lastname' => 'required',
|
||||
'shipping_address' => 'required',
|
||||
'shipping_zipcode' => 'required',
|
||||
'shipping_city' => 'required',
|
||||
'shipping_salutation' => 'required'
|
||||
|
||||
|
|
@ -215,9 +215,9 @@ class LeadController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
if(isset($data['m_account']) && $data['m_account']){
|
||||
if (isset($data['m_account']) && $data['m_account']) {
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
$rules['m_account'] = 'unique:user_accounts,m_account,'.$user->account->id.',id';
|
||||
$rules['m_account'] = 'unique:user_accounts,m_account,' . $user->account->id . ',id';
|
||||
}
|
||||
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
|
@ -225,86 +225,86 @@ class LeadController extends Controller
|
|||
|
||||
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
|
||||
$user_id = "new";
|
||||
}else{
|
||||
} else {
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
$user_id = $user->id;
|
||||
}
|
||||
return redirect(route('admin_lead_edit', [$user_id])."?show=".$show)->withErrors($validator)->withRequest(Request::all());
|
||||
return redirect(route('admin_lead_edit', [$user_id]) . "?show=" . $show)->withErrors($validator)->withRequest(Request::all());
|
||||
}
|
||||
|
||||
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
|
||||
$user = new User();
|
||||
$user->id = "new";
|
||||
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
|
||||
$user = new User();
|
||||
$user->id = "new";
|
||||
$user->account = new UserAccount();
|
||||
} else {
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
if (!$user->account) {
|
||||
$user->account = new UserAccount();
|
||||
|
||||
}else {
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
if(!$user->account){
|
||||
$user->account = new UserAccount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->userRepo->update($data);
|
||||
$this->userRepo->update($data);
|
||||
|
||||
if(isset($data['m_data_edit']) && $data['m_data_edit'] === "TSOK"){
|
||||
//syslog
|
||||
if(isset($data['m_sponsor'])){
|
||||
if($user->m_sponsor != $data['m_sponsor']){
|
||||
$from_user = isset($user->user_sponsor->email) ? $user->user_sponsor->email : "empty";
|
||||
$t_user = User::find($data['m_sponsor']);
|
||||
$to_user = isset($t_user->email) ? $t_user->email : "empty";
|
||||
if (isset($data['m_data_edit']) && $data['m_data_edit'] === "TSOK") {
|
||||
//syslog
|
||||
if (isset($data['m_sponsor'])) {
|
||||
if ($user->m_sponsor != $data['m_sponsor']) {
|
||||
$from_user = isset($user->user_sponsor->email) ? $user->user_sponsor->email : "empty";
|
||||
$t_user = User::find($data['m_sponsor']);
|
||||
$to_user = isset($t_user->email) ? $t_user->email : "empty";
|
||||
|
||||
SysLog::action('save-m_sponsor', 'lead_edit_sponsor', 3)
|
||||
SysLog::action('save-m_sponsor', 'lead_edit_sponsor', 3)
|
||||
->setUserId(\Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user new sponsor from: '.$from_user." | to: ".$to_user)
|
||||
->setMessage('Set user new sponsor from: ' . $from_user . " | to: " . $to_user)
|
||||
->save();
|
||||
}
|
||||
}
|
||||
|
||||
$user = $this->userRepo->getModel();
|
||||
$user->m_level = isset($data['m_level']) ? $data['m_level'] : NULL;
|
||||
$user->m_sponsor = isset($data['m_sponsor']) ? $data['m_sponsor'] : NULL;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
if(isset($data['contact_verify'])){
|
||||
$user = $this->userRepo->getModel();
|
||||
$user->m_level = isset($data['m_level']) ? $data['m_level'] : NULL;
|
||||
$user->m_sponsor = isset($data['m_sponsor']) ? $data['m_sponsor'] : NULL;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
$user = $this->userRepo->getModel();
|
||||
if (isset($data['contact_verify'])) {
|
||||
|
||||
$confirmation_code = UserService::createConfirmationCode();
|
||||
$user = $this->userRepo->getModel();
|
||||
|
||||
$user->lang = $user->getLandByCountry();
|
||||
$user->confirmation_code = $confirmation_code;
|
||||
//10 == start wizard form create Lead
|
||||
$user->wizard = 10;
|
||||
$user->save();
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailVerifyContact($confirmation_code, $user));
|
||||
$confirmation_code = UserService::createConfirmationCode();
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('admin_leads'));
|
||||
}
|
||||
$user->lang = $user->getLandByCountry();
|
||||
$user->confirmation_code = $confirmation_code;
|
||||
//10 == start wizard form create Lead
|
||||
$user->wizard = 10;
|
||||
$user->save();
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailVerifyContact($confirmation_code, $user));
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('admin_lead_edit', [$user->id])."?show=".$show);
|
||||
return redirect(route('admin_leads'));
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('admin_lead_edit', [$user->id]) . "?show=" . $show);
|
||||
}
|
||||
//user released when register is complete
|
||||
public function released($action, $id){
|
||||
public function released($action, $id)
|
||||
{
|
||||
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
if($action === 'completed'){
|
||||
if ($action === 'completed') {
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
if(!$user->m_sponsor){
|
||||
if (!$user->m_sponsor) {
|
||||
$validator->errors()->add('m_sponsor', __('Berater hat keinen Sponsor.'));
|
||||
}
|
||||
if(!$user->account->m_first_name){
|
||||
if (!$user->account->m_first_name) {
|
||||
$validator->errors()->add('m_first_name', __('Berater hat keinen Vornamen.'));
|
||||
}
|
||||
if(!$user->account->m_last_name){
|
||||
if (!$user->account->m_last_name) {
|
||||
$validator->errors()->add('m_last_name', __('Berater hat keinen Nachnamen.'));
|
||||
}
|
||||
if(!$user->account->m_account){
|
||||
if (!$user->account->m_account) {
|
||||
$validator->errors()->add('m_account', __('Berater hat keine Account ID'));
|
||||
}
|
||||
if ($validator->errors()->count()) {
|
||||
|
|
@ -314,7 +314,7 @@ class LeadController extends Controller
|
|||
//create PDF
|
||||
$pdf = new ContractPDFRepository($user);
|
||||
$pdf->_set('disk', 'user');
|
||||
$pdf->_set('dir', '/'.$user->id.'/documents/');
|
||||
$pdf->_set('dir', '/' . $user->id . '/documents/');
|
||||
$pdf->_set('user_id', $user->id);
|
||||
$pdf->_set('identifier', 'contract');
|
||||
$pdf->createContractPDF();
|
||||
|
|
@ -330,11 +330,11 @@ class LeadController extends Controller
|
|||
|
||||
//mail with code to user?
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailAccountActive($user));
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'released_completed', 'status'=>0]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action' => 'released_completed', 'status' => 0]);
|
||||
\Session()->flash('alert-success', "Berater freigeschaltet!");
|
||||
}
|
||||
|
||||
if($action === 'incomplete'){
|
||||
if ($action === 'incomplete') {
|
||||
|
||||
|
||||
//reset release
|
||||
|
|
@ -354,21 +354,20 @@ class LeadController extends Controller
|
|||
];
|
||||
try {
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailCustomMessage($user, $data, \Auth::user(), true));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
dump($e->getMessage());
|
||||
dd("error");
|
||||
}
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'released_incomplete', 'status'=>0]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action' => 'released_incomplete', 'status' => 0]);
|
||||
\Session()->flash('alert-success', "E-Mail an Berater gesendet.");
|
||||
|
||||
}
|
||||
return redirect(route('admin_lead_edit', [$user->id]));
|
||||
}
|
||||
|
||||
|
||||
//send new verfified mail to user
|
||||
public function newMailVerified($id){
|
||||
public function newMailVerified($id)
|
||||
{
|
||||
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
|
|
@ -380,29 +379,28 @@ class LeadController extends Controller
|
|||
|
||||
try {
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailVerifyAccount($confirmation_code, $user));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
dump($e->getMessage());
|
||||
dd("error");
|
||||
}
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'new_mail_verified', 'status'=>0]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action' => 'new_mail_verified', 'status' => 0]);
|
||||
|
||||
\Session()->flash('alert-success', "E-Mail erneut gesendet");
|
||||
return redirect(route('admin_lead_edit', [$user->id]));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function deleteFile($user_id, $file_id, $relation){
|
||||
public function deleteFile($user_id, $file_id, $relation)
|
||||
{
|
||||
|
||||
if($relation === 'upload'){
|
||||
if ($relation === 'upload') {
|
||||
$user = User::findOrFail($user_id);
|
||||
$file = $user->files()->findOrFail($file_id);
|
||||
if($file->identifier === 'business_license'){
|
||||
if ($file->identifier === 'business_license') {
|
||||
$user->account->setNotice('business_license', '');
|
||||
}
|
||||
//remove file
|
||||
\Storage::disk('user')->delete($file->dir.$file->filename);
|
||||
\Storage::disk('user')->delete($file->dir . $file->filename);
|
||||
$file->delete();
|
||||
\Session()->flash('alert-success', __('msg.file_deleted'));
|
||||
}
|
||||
|
|
@ -416,7 +414,7 @@ class LeadController extends Controller
|
|||
//$query = UserSalesVolume::with('user', 'user.account')->with('shopping_order')->select('user_sales_volumes.*')
|
||||
|
||||
$query = User::with('account')->select('users.*')->where('users.deleted_at', '=', null)->where('users.admin', "<", 5);
|
||||
if(Request::get('leads_filter_sponsor_id')){
|
||||
if (Request::get('leads_filter_sponsor_id')) {
|
||||
$query->where('users.m_sponsor', '=', Request::get('leads_filter_sponsor_id'));
|
||||
}
|
||||
return $query;
|
||||
|
|
@ -437,11 +435,11 @@ class LeadController extends Controller
|
|||
return $user->account ? $user->account->last_name : '';
|
||||
})
|
||||
->addColumn('user_level', function (User $user) {
|
||||
return $user->user_level ? '<span class="badge badge-outline-success">'.$user->user_level->name.'</span>' : '';
|
||||
return $user->user_level ? '<span class="badge badge-outline-success">' . $user->user_level->name . '</span>' : '';
|
||||
})
|
||||
->addColumn('user_sponsor', function (User $user) {
|
||||
return $user->user_sponsor ?
|
||||
'<span class="badge badge-outline-warning-dark">'.$user->user_sponsor->account->first_name." ".$user->user_sponsor->account->last_name.'</span>' : "-";
|
||||
return $user->user_sponsor ?
|
||||
'<span class="badge badge-outline-warning-dark">' . $user->user_sponsor->account->first_name . " " . $user->user_sponsor->account->last_name . '</span>' : "-";
|
||||
})
|
||||
->addColumn('id', function (User $user) {
|
||||
return '<a href="' . route('admin_lead_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
|
|
@ -458,30 +456,30 @@ class LeadController extends Controller
|
|||
|
||||
->addColumn('useractive', function (User $user) {
|
||||
$date = $user->getActiveDateFormat();
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-active" data-id="'.$user->id.'" data-email="'.$user->email.'" data-active="'.$user->active.'" data-active_date="'.$date.'">';
|
||||
return $user->active ? $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$date.'</span></a>' : $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-active" data-id="' . $user->id . '" data-email="' . $user->email . '" data-active="' . $user->active . '" data-active_date="' . $date . '">';
|
||||
return $user->active ? $link . '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> ' . $date . '</span></a>' : $link . '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
})
|
||||
->addColumn('payaccount', function (User $user) {
|
||||
$date = $user->getPaymentAccountDateFormat();
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-account" data-id="'.$user->id.'" data-email="'.$user->email.'" data-payment_account="'.$date.'">';
|
||||
if($user->payment_account){
|
||||
if($user->isActiveAccount()){
|
||||
return $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$date.'</span></a>';
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-account" data-id="' . $user->id . '" data-email="' . $user->email . '" data-payment_account="' . $date . '">';
|
||||
if ($user->payment_account) {
|
||||
if ($user->isActiveAccount()) {
|
||||
return $link . '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> ' . $date . '</span></a>';
|
||||
}
|
||||
return $link.'<span class="badge badge-pill badge-warning"><i class="fa fa-ban"></i> '.$date.'</span></a>';
|
||||
return $link . '<span class="badge badge-pill badge-warning"><i class="fa fa-ban"></i> ' . $date . '</span></a>';
|
||||
}
|
||||
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-danger"><i class="fa fa-times"></i></span></a>';
|
||||
})
|
||||
->addColumn('payshop', function (User $user) {
|
||||
$date = $user->getPaymentShopDateFormat();
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-shop" data-id="'.$user->id.'" data-email="'.$user->email.'" data-payment_shop="'.$date.'">';
|
||||
if($user->payment_shop){
|
||||
if($user->isActiveShop()){
|
||||
return $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$date.'</span></a>';
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-shop" data-id="' . $user->id . '" data-email="' . $user->email . '" data-payment_shop="' . $date . '">';
|
||||
if ($user->payment_shop) {
|
||||
if ($user->isActiveShop()) {
|
||||
return $link . '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> ' . $date . '</span></a>';
|
||||
}
|
||||
return $link.'<span class="badge badge-pill badge-warning"><i class="fa fa-ban"></i> '.$date.'</span></a>';
|
||||
return $link . '<span class="badge badge-pill badge-warning"><i class="fa fa-ban"></i> ' . $date . '</span></a>';
|
||||
}
|
||||
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-danger"><i class="fa fa-times"></i></span></a>';
|
||||
})
|
||||
|
||||
|
||||
|
|
@ -494,13 +492,12 @@ class LeadController extends Controller
|
|||
->addColumn('payment_shop', function (User $user) {
|
||||
return $user->payment_shop ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
|
||||
|
||||
->addColumn('payment_shop_date', function (User $user) {
|
||||
return $user->payment_shop ? $user->getPaymentShopDateFormat(false) : "-";
|
||||
})
|
||||
->addColumn('shop_domain', function (User $user) {
|
||||
return $user->shop ? ' <span class="small"><a href="'.$user->shop->getSubdomain(false).'" target="_blank">'.$user->shop->getSubdomain(false).'</a></span>' : '';
|
||||
|
||||
return $user->shop ? ' <span class="small"><a href="' . $user->shop->getSubdomain(false) . '" target="_blank">' . $user->shop->getSubdomain(false) . '</a></span>' : '';
|
||||
})
|
||||
->addColumn('turnover', function (User $user) {
|
||||
return "-";
|
||||
|
|
@ -517,4 +514,4 @@ class LeadController extends Controller
|
|||
->rawColumns(['id', 'user_level', 'user_sponsor', 'confirmed', 'useractive', 'payaccount', 'payshop', 'agreement', 'active', 'payment_account', 'payment_shop', 'shop_domain'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,14 +49,14 @@ class PayoneController extends Controller
|
|||
private $method = [];
|
||||
private $prepayment = [];
|
||||
|
||||
/* private $onlineTransfer = [];
|
||||
/* private $onlineTransfer = [];
|
||||
private $creditCard = []; */
|
||||
private $deliveryData = [];
|
||||
|
||||
|
||||
|
||||
|
||||
// private $payment_method;
|
||||
// private $payment_method;
|
||||
private $urls = [];
|
||||
|
||||
private $shopping_user;
|
||||
|
|
@ -65,21 +65,25 @@ class PayoneController extends Controller
|
|||
|
||||
private $reference;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->default = \Config::get('payone.defaults');
|
||||
}
|
||||
|
||||
public function init($shopping_user, $shopping_order){
|
||||
public function init($shopping_user, $shopping_order)
|
||||
{
|
||||
$this->shopping_user = $shopping_user;
|
||||
$this->shopping_order = $shopping_order;
|
||||
$this->default['mode'] = $this->shopping_order->mode;
|
||||
}
|
||||
|
||||
public function getShoppingPayment(){
|
||||
public function getShoppingPayment()
|
||||
{
|
||||
return $this->shopping_payment;
|
||||
}
|
||||
public function setAboPayment($user_abo, $amount, $currency){
|
||||
public function setAboPayment($user_abo, $amount, $currency)
|
||||
{
|
||||
$this->reference = substr(uniqid('m', false), 0, 16);
|
||||
|
||||
$this->method = [
|
||||
|
|
@ -91,16 +95,16 @@ class PayoneController extends Controller
|
|||
'onlinebanktransfertype' => '',
|
||||
"request" => "authorization",
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
$this->aboInitPayment = [
|
||||
'recurrence'=>'recurring',
|
||||
'customer_is_present'=>'no',
|
||||
'recurrence' => 'recurring',
|
||||
'customer_is_present' => 'no',
|
||||
'request' => 'authorization',
|
||||
'amount' => $amount
|
||||
];
|
||||
|
||||
$this->prepayment = [
|
||||
];
|
||||
|
||||
$this->prepayment = [
|
||||
"reference" => $this->reference, // a unique reference, e.g. order number
|
||||
"amount" => $amount, // amount in smallest currency unit, i.e. cents
|
||||
"currency" => $currency,
|
||||
|
|
@ -122,50 +126,49 @@ class PayoneController extends Controller
|
|||
]);
|
||||
}
|
||||
//make Payone payment
|
||||
public function setPrePayment($payment_method, $amount, $currency, $ret = []){
|
||||
public function setPrePayment($payment_method, $amount, $currency, $ret = [])
|
||||
{
|
||||
|
||||
$this->reference = substr(uniqid('m', false), 0, 16);
|
||||
$this->setMethod($payment_method, $ret);
|
||||
|
||||
$this->urls = [
|
||||
'successurl' => route('checkout.transaction_status', ['success', $this->reference]),
|
||||
'successurl' => route('checkout.transaction_status', ['success', $this->reference]),
|
||||
'errorurl' => route('checkout.transaction_status', ['error', $this->reference]),
|
||||
'backurl' => route('checkout.transaction_status', ['cancel', $this->reference]),
|
||||
];
|
||||
|
||||
$this->prepayment = [
|
||||
"reference" => $this->reference, // a unique reference, e.g. order number
|
||||
"amount" => $amount, // amount in smallest currency unit, i.e. cents
|
||||
"currency" => $currency,
|
||||
"param" => $this->shopping_order->id,
|
||||
];
|
||||
//init Abo
|
||||
if($this->shopping_order->is_abo){
|
||||
if($this->method["clearingtype"] === "cc"){
|
||||
"reference" => $this->reference, // a unique reference, e.g. order number
|
||||
"amount" => $amount, // amount in smallest currency unit, i.e. cents
|
||||
"currency" => $currency,
|
||||
"param" => $this->shopping_order->id,
|
||||
];
|
||||
//init Abo
|
||||
if ($this->shopping_order->is_abo) {
|
||||
if ($this->method["clearingtype"] === "cc") {
|
||||
$this->aboInitPayment = [
|
||||
'recurrence'=>'recurring',
|
||||
'customer_is_present'=>'yes',
|
||||
'recurrence' => 'recurring',
|
||||
'customer_is_present' => 'yes',
|
||||
'request' => 'authorization',
|
||||
'amount' => $amount,
|
||||
];
|
||||
$this->method['request'] = 'authorization';
|
||||
|
||||
];
|
||||
$this->method['request'] = 'authorization';
|
||||
}
|
||||
|
||||
if($this->method["clearingtype"] === "wlt"){
|
||||
|
||||
if ($this->method["clearingtype"] === "wlt") {
|
||||
//payment for Abo PayPal
|
||||
$this->aboInitPayment = [
|
||||
'recurrence'=>'recurring',
|
||||
'customer_is_present'=>'yes',
|
||||
'request' => 'authorization',
|
||||
'amount' => $amount,
|
||||
'add_paydata[redirection_mode]' => 'DIRECT_TO_MERCHANT',
|
||||
];
|
||||
$this->setDeliverylData($this->shopping_user);
|
||||
$this->method['request'] = 'authorization';
|
||||
}
|
||||
|
||||
}
|
||||
$this->aboInitPayment = [
|
||||
'recurrence' => 'recurring',
|
||||
'customer_is_present' => 'yes',
|
||||
'request' => 'authorization',
|
||||
'amount' => $amount,
|
||||
'add_paydata[redirection_mode]' => 'DIRECT_TO_MERCHANT',
|
||||
];
|
||||
$this->setDeliverylData($this->shopping_user);
|
||||
$this->method['request'] = 'authorization';
|
||||
}
|
||||
}
|
||||
|
||||
$this->shopping_payment = ShoppingPayment::create([
|
||||
'shopping_order_id' => $this->shopping_order->id,
|
||||
|
|
@ -186,7 +189,8 @@ class PayoneController extends Controller
|
|||
return $this->reference;
|
||||
}
|
||||
|
||||
public function setPersonalData(){
|
||||
public function setPersonalData()
|
||||
{
|
||||
$this->personalData = [
|
||||
"firstname" => $this->shopping_user->billing_firstname,
|
||||
"lastname" => $this->shopping_user->billing_lastname, // mandatory
|
||||
|
|
@ -195,7 +199,7 @@ class PayoneController extends Controller
|
|||
"city" => $this->shopping_user->billing_city,
|
||||
"country" => ($this->shopping_user->billing_country) ? $this->shopping_user->billing_country->code : "DE", // mandatory
|
||||
"email" => $this->shopping_user->billing_email,
|
||||
// "language" => ($this->shopping_user->billing_country) ? strtoupper($this->shopping_user->billing_country->code) : "DE", // mandatory
|
||||
// "language" => ($this->shopping_user->billing_country) ? strtoupper($this->shopping_user->billing_country->code) : "DE", // mandatory
|
||||
"language" => "DE",
|
||||
];
|
||||
|
||||
|
|
@ -210,27 +214,25 @@ class PayoneController extends Controller
|
|||
"shipping_city" => "Frankfurt am Main",
|
||||
"shipping_country" => "DE"
|
||||
);*/
|
||||
|
||||
}
|
||||
|
||||
private function setMethod($payment_method, $ret = []){
|
||||
private function setMethod($payment_method, $ret = [])
|
||||
{
|
||||
|
||||
if($payment_method){
|
||||
if(strpos($payment_method, '#')){
|
||||
if ($payment_method) {
|
||||
if (strpos($payment_method, '#')) {
|
||||
$payment_method = explode('#', $payment_method);
|
||||
//wallet Paypal
|
||||
if($payment_method[0] === 'wlt'){
|
||||
if ($payment_method[0] === 'wlt') {
|
||||
$this->method = [
|
||||
"clearingtype" => "wlt",
|
||||
"wallettype" => $payment_method[1],
|
||||
'onlinebanktransfertype' => "",
|
||||
"request" => "authorization"
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
//Online-Überweisung
|
||||
if($payment_method[0] === 'sb'){
|
||||
if ($payment_method[0] === 'sb') {
|
||||
$this->method = [
|
||||
"clearingtype" => "sb",
|
||||
"wallettype" => "",
|
||||
|
|
@ -241,18 +243,18 @@ class PayoneController extends Controller
|
|||
}
|
||||
|
||||
//Rechnungskauf
|
||||
if($payment_method[0] === 'fnc'){
|
||||
//MIVITA
|
||||
if(isset($payment_method[1]) && $payment_method[1] === 'MIV'){
|
||||
$this->method = [
|
||||
"clearingtype" => "fnc",
|
||||
"wallettype" => "",
|
||||
'onlinebanktransfertype' => "MIV",
|
||||
"request" => "authorization",
|
||||
];
|
||||
}
|
||||
//PAYONE
|
||||
/* $this->method = [
|
||||
if ($payment_method[0] === 'fnc') {
|
||||
//MIVITA
|
||||
if (isset($payment_method[1]) && $payment_method[1] === 'MIV') {
|
||||
$this->method = [
|
||||
"clearingtype" => "fnc",
|
||||
"wallettype" => "",
|
||||
'onlinebanktransfertype' => "MIV",
|
||||
"request" => "authorization",
|
||||
];
|
||||
}
|
||||
//PAYONE
|
||||
/* $this->method = [
|
||||
"clearingtype" => "fnc",
|
||||
"wallettype" => "",
|
||||
'onlinebanktransfertype' => "",
|
||||
|
|
@ -262,10 +264,9 @@ class PayoneController extends Controller
|
|||
"add_paydata[payment_type]" => "Payolution-Invoicing",
|
||||
];*/
|
||||
}
|
||||
|
||||
}
|
||||
//vorkasse
|
||||
if($payment_method === 'elv'){
|
||||
if ($payment_method === 'elv') {
|
||||
$this->method = [
|
||||
"clearingtype" => "elv",
|
||||
"wallettype" => "",
|
||||
|
|
@ -274,13 +275,13 @@ class PayoneController extends Controller
|
|||
"mandate_identification" => $ret['elv']['mandate_identification'],
|
||||
"iban" => $ret['elv']['iban'],
|
||||
"bic" => $ret['elv']['bic'],
|
||||
"bankaccountholder" =>$ret['elv']['bankaccountholder'],
|
||||
// "bankcountry" => "DE",
|
||||
"bankaccountholder" => $ret['elv']['bankaccountholder'],
|
||||
// "bankcountry" => "DE",
|
||||
];
|
||||
}
|
||||
|
||||
//vorkasse
|
||||
if($payment_method === 'vor'){
|
||||
if ($payment_method === 'vor') {
|
||||
$this->method = [
|
||||
"clearingtype" => "vor",
|
||||
"wallettype" => "",
|
||||
|
|
@ -290,7 +291,7 @@ class PayoneController extends Controller
|
|||
}
|
||||
|
||||
//CreditCard
|
||||
if($payment_method === 'cc'){
|
||||
if ($payment_method === 'cc') {
|
||||
//need the $cc_ret
|
||||
$this->method = [
|
||||
"clearingtype" => "cc",
|
||||
|
|
@ -304,18 +305,19 @@ class PayoneController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function onlyPaymentResponse(){
|
||||
public function onlyPaymentResponse()
|
||||
{
|
||||
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->aboInitPayment, $this->urls);
|
||||
$response = Payone::sendRequest($request);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function ResponseData($is_abo = false){
|
||||
public function ResponseData($is_abo = false)
|
||||
{
|
||||
|
||||
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->aboInitPayment, $this->urls);
|
||||
//dd($request);
|
||||
//RECHNUNG MIV
|
||||
if($this->shopping_payment->clearingtype === 'fnc' && $this->shopping_payment->onlinebanktransfertype === 'MIV'){
|
||||
if ($this->shopping_payment->clearingtype === 'fnc' && $this->shopping_payment->onlinebanktransfertype === 'MIV') {
|
||||
$payt = PaymentTransaction::create([
|
||||
'shopping_payment_id' => $this->shopping_payment->id,
|
||||
'request' => $this->method['request'],
|
||||
|
|
@ -326,23 +328,22 @@ class PayoneController extends Controller
|
|||
'txaction' => 'invoice_open',
|
||||
'mode' => $this->shopping_payment->mode,
|
||||
]);
|
||||
Util::setUserHistoryValue(['status'=>5]);
|
||||
if($is_abo){
|
||||
Util::setUserHistoryValue(['status' => 5]);
|
||||
if ($is_abo) {
|
||||
return $this->reference;
|
||||
}
|
||||
return redirect(route('checkout.transaction_approved', [$payt->id, $this->reference]));
|
||||
exit;
|
||||
}
|
||||
|
||||
$response = Payone::sendRequest($request);
|
||||
/*
|
||||
* status APPROVED / REDIRECT / ERROR / PENDING
|
||||
*/
|
||||
if($response['status'] === 'ERROR'){
|
||||
if ($response['status'] === 'ERROR') {
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'PayPal Preauthorization Fehler: ' . $response['errormessage'],
|
||||
'payone',
|
||||
'error',
|
||||
'PayPal Preauthorization Fehler: ' . $response['errormessage'],
|
||||
$response
|
||||
);
|
||||
PaymentTransaction::create([
|
||||
|
|
@ -354,8 +355,8 @@ class PayoneController extends Controller
|
|||
'status' => $response['status'],
|
||||
'mode' => $this->shopping_payment->mode,
|
||||
]);
|
||||
Util::setUserHistoryValue(['status'=>3]);
|
||||
if($is_abo){
|
||||
Util::setUserHistoryValue(['status' => 3]);
|
||||
if ($is_abo) {
|
||||
return $response;
|
||||
}
|
||||
\Session::flash('errormessage', $response['errormessage']);
|
||||
|
|
@ -364,7 +365,7 @@ class PayoneController extends Controller
|
|||
}
|
||||
|
||||
|
||||
if($response['status'] === 'REDIRECT'){
|
||||
if ($response['status'] === 'REDIRECT') {
|
||||
PaymentTransaction::create([
|
||||
'shopping_payment_id' => $this->shopping_payment->id,
|
||||
'request' => $this->method['request'],
|
||||
|
|
@ -374,17 +375,16 @@ class PayoneController extends Controller
|
|||
'mode' => $this->shopping_payment->mode,
|
||||
|
||||
]);
|
||||
Util::setUserHistoryValue(['status'=>4]);
|
||||
if($is_abo){
|
||||
Util::setUserHistoryValue(['status' => 4]);
|
||||
if ($is_abo) {
|
||||
return $response;
|
||||
}
|
||||
return redirect()->away($response["redirecturl"]);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
if($response['status'] === 'APPROVED'){
|
||||
// header("Location: " . $response["redirecturl"]); // or other redirect method
|
||||
if ($response['status'] === 'APPROVED') {
|
||||
// header("Location: " . $response["redirecturl"]); // or other redirect method
|
||||
$payt = PaymentTransaction::create([
|
||||
'shopping_payment_id' => $this->shopping_payment->id,
|
||||
'request' => $this->method['request'],
|
||||
|
|
@ -395,24 +395,24 @@ class PayoneController extends Controller
|
|||
'mode' => $this->shopping_payment->mode,
|
||||
|
||||
]);
|
||||
Util::setUserHistoryValue(['status'=>5]);
|
||||
if($is_abo){
|
||||
Util::setUserHistoryValue(['status' => 5]);
|
||||
if ($is_abo) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
if($payt->shopping_payment->clearingtype === "vor"){
|
||||
if ($payt->shopping_payment->clearingtype === "vor") {
|
||||
//vorkasse
|
||||
return redirect(route('checkout.transaction_approved', [$payt->id, $this->reference]));
|
||||
exit;
|
||||
}
|
||||
|
||||
if($payt->shopping_payment->clearingtype === "cc"){
|
||||
if ($payt->shopping_payment->clearingtype === "cc") {
|
||||
//creditcard
|
||||
return redirect(route('checkout.transaction_approved', [$payt->id, $this->reference]));
|
||||
exit;
|
||||
}
|
||||
|
||||
if($payt->shopping_payment->clearingtype === "elv"){
|
||||
if ($payt->shopping_payment->clearingtype === "elv") {
|
||||
//sepa
|
||||
return redirect(route('checkout.transaction_approved', [$payt->id, $this->reference]));
|
||||
exit;
|
||||
|
|
@ -427,11 +427,11 @@ class PayoneController extends Controller
|
|||
}
|
||||
|
||||
|
||||
if($response['status'] === 'PENDING'){
|
||||
if ($response['status'] === 'PENDING') {
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:1000 Status PENDING App\Http\Controllers\Pay\PayoneController::ResponseData response status PENDING',
|
||||
'payone',
|
||||
'error',
|
||||
'Error:1000 Status PENDING App\Http\Controllers\Pay\PayoneController::ResponseData response status PENDING',
|
||||
$response
|
||||
);
|
||||
die();
|
||||
|
|
@ -441,9 +441,9 @@ class PayoneController extends Controller
|
|||
//Debtor ID (PAYONE)
|
||||
}
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:1001 Der Zahlungsanbieter ist nicht erreichbar, die Zahlung konnte nicht durchgeführt werden. App\Http\Controllers\Pay\PayoneController::ResponseData error no response status',
|
||||
'payone',
|
||||
'error',
|
||||
'Error:1001 Der Zahlungsanbieter ist nicht erreichbar, die Zahlung konnte nicht durchgeführt werden. App\Http\Controllers\Pay\PayoneController::ResponseData error no response status',
|
||||
$response
|
||||
);
|
||||
abort(403, 'Der Zahlungsanbieter ist nicht erreichbar, die Zahlung konnte nicht durchgeführt werden. Bitte versuchen Sie es später erneut. Fehlercode: 1001');
|
||||
|
|
@ -456,7 +456,7 @@ class PayoneController extends Controller
|
|||
{
|
||||
$this->prepayment = [
|
||||
"request" => "creditcardcheck", // create account receivable and instantly book the amount
|
||||
"cardholder" => $data['cc_cardholder_first']." ".$data['cc_cardholder_last'],
|
||||
"cardholder" => $data['cc_cardholder_first'] . " " . $data['cc_cardholder_last'],
|
||||
"cardpan" => $data['cc_cardpan'],
|
||||
"cardexpiredate" => substr($data['cc_cardexpireyear'], -2) . $data['cc_cardexpiremonth'],
|
||||
"cardtype" => $data['cc_cardtype'],
|
||||
|
|
@ -489,29 +489,30 @@ class PayoneController extends Controller
|
|||
return Payone::sendRequest($request);
|
||||
}
|
||||
|
||||
public function setDeliverylData($shopping_user){
|
||||
if($shopping_user->same_as_billing == true){
|
||||
$this->deliveryData = [
|
||||
'shipping_firstname' => $shopping_user->billing_firstname,
|
||||
'shipping_lastname' => $shopping_user->billing_lastname,
|
||||
'shipping_zip' => $shopping_user->billing_zipcode,
|
||||
'shipping_city' => $shopping_user->billing_city,
|
||||
'shipping_country' => $shopping_user->billing_country->code,
|
||||
'shipping_street' => $shopping_user->billing_address,
|
||||
];
|
||||
}else{
|
||||
public function setDeliverylData($shopping_user)
|
||||
{
|
||||
if ($shopping_user->same_as_billing == true) {
|
||||
$this->deliveryData = [
|
||||
'shipping_firstname' => $shopping_user->shipping_firstname,
|
||||
'shipping_lastname' => $shopping_user->shipping_lastname,
|
||||
'shipping_zip' => $shopping_user->shipping_zipcode,
|
||||
'shipping_city' => $shopping_user->shipping_city,
|
||||
'shipping_country' => $shopping_user->shipping_country->code,
|
||||
'shipping_street' => $shopping_user->shipping_address,
|
||||
'shipping_firstname' => $shopping_user->billing_firstname,
|
||||
'shipping_lastname' => $shopping_user->billing_lastname,
|
||||
'shipping_zip' => $shopping_user->billing_zipcode,
|
||||
'shipping_city' => $shopping_user->billing_city,
|
||||
'shipping_country' => $shopping_user->billing_country->code,
|
||||
'shipping_street' => $shopping_user->billing_address,
|
||||
];
|
||||
} else {
|
||||
$this->deliveryData = [
|
||||
'shipping_firstname' => $shopping_user->shipping_firstname,
|
||||
'shipping_lastname' => $shopping_user->shipping_lastname,
|
||||
'shipping_zip' => $shopping_user->shipping_zipcode,
|
||||
'shipping_city' => $shopping_user->shipping_city,
|
||||
'shipping_country' => $shopping_user->shipping_country->code,
|
||||
'shipping_street' => $shopping_user->shipping_address,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/* public function getPDFFile($mandateId)
|
||||
/* public function getPDFFile($mandateId)
|
||||
{
|
||||
|
||||
$params['file_reference'] = $mandateId;//"XX-T0000000";
|
||||
|
|
@ -582,7 +583,7 @@ class PayoneController extends Controller
|
|||
* bic
|
||||
* bankcountry*/
|
||||
|
||||
/* * Card type
|
||||
/* * Card type
|
||||
V Visa
|
||||
M MasterCard
|
||||
A American Express
|
||||
|
|
@ -597,11 +598,4 @@ class PayoneController extends Controller
|
|||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Models\Country;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductBundle;
|
||||
use App\Models\ProductImage;
|
||||
use App\Models\ProductIngredient;
|
||||
use App\Repositories\ProductRepository;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
protected $productRepo;
|
||||
|
|
@ -20,32 +19,31 @@ class ProductController extends Controller
|
|||
{
|
||||
$this->middleware('admin');
|
||||
$this->productRepo = $productRepo;
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if(Request::get('show_active_products')){
|
||||
if (Request::get('show_active_products')) {
|
||||
set_user_attr('show_active_products', Request::get('show_active_products'));
|
||||
}
|
||||
if(get_user_attr('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{
|
||||
} else {
|
||||
$values = Product::orderBy('pos', 'DESC')->orderBy('id', 'DESC')->get();
|
||||
|
||||
}
|
||||
$data = [
|
||||
'values' => $values
|
||||
'values' => $values,
|
||||
];
|
||||
|
||||
return view('admin.product.index', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
if($id === "new"){
|
||||
$model = new Product();
|
||||
if ($id === 'new') {
|
||||
$model = new Product;
|
||||
$model->active = true;
|
||||
}else{
|
||||
} else {
|
||||
$model = Product::findOrFail($id);
|
||||
}
|
||||
$country_for_prices = Country::where('own_eur', '=', true)->orWhere('currency', '=', true)->get();
|
||||
|
|
@ -53,32 +51,32 @@ class ProductController extends Controller
|
|||
'product' => $model,
|
||||
'country_for_prices' => $country_for_prices,
|
||||
];
|
||||
|
||||
return view('admin.product.edit', $data);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
$data = Request::all();
|
||||
$rules = array(
|
||||
$rules = [
|
||||
'name' => 'required',
|
||||
);
|
||||
];
|
||||
/*if(isset($data['number']) && $data['number'] != ""){
|
||||
$rules['number'] = 'int';
|
||||
}*/
|
||||
if(isset($data['wp_number'])){
|
||||
if($data['id'] !== "new"){
|
||||
if (isset($data['wp_number'])) {
|
||||
if ($data['id'] !== 'new') {
|
||||
$model = Product::findOrFail($data['id']);
|
||||
$rules['wp_number'] = 'unique:products,wp_number,'.$model->id;
|
||||
}else{
|
||||
} else {
|
||||
$rules['wp_number'] = 'unique:products,wp_number';
|
||||
|
||||
}
|
||||
}
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
||||
if($data['id'] === "new"){
|
||||
$model = new Product();
|
||||
}else{
|
||||
if ($data['id'] === 'new') {
|
||||
$model = new Product;
|
||||
} else {
|
||||
$model = Product::findOrFail($data['id']);
|
||||
}
|
||||
$country_for_prices = Country::where('own_eur', '=', true)->orWhere('currency', '=', true)->get();
|
||||
|
|
@ -92,55 +90,66 @@ class ProductController extends Controller
|
|||
if ($validator->fails()) {
|
||||
|
||||
return view('admin.product.edit', $data)->withErrors($validator);
|
||||
|
||||
} else {
|
||||
$product = $this->productRepo->update(Request::all());
|
||||
\Session()->flash('alert-save', true);
|
||||
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
|
||||
return redirect(route('admin_product_show'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function copy($id){
|
||||
public function copy($id)
|
||||
{
|
||||
$model = Product::findOrFail($id);
|
||||
|
||||
$product = $this->productRepo->copy($model);
|
||||
|
||||
|
||||
|
||||
\Session()->flash('alert-success', 'Eintrag kopiert');
|
||||
|
||||
return redirect(route('admin_product_show'));
|
||||
}
|
||||
|
||||
public function delete($id, $do = 'product', $did = null){
|
||||
if($do === 'product'){
|
||||
public function delete($id, $do = 'product', $did = null)
|
||||
{
|
||||
if ($do === 'product') {
|
||||
$model = Product::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
|
||||
return redirect(route('admin_product_show'));
|
||||
}
|
||||
|
||||
if($do === 'ingredient'){
|
||||
if ($do === 'ingredient') {
|
||||
$model = Product::findOrFail($id);
|
||||
$ProductIngredient = ProductIngredient::where('ingredient_id', $did)->where('product_id', $model->id)->first();
|
||||
if($ProductIngredient){
|
||||
if ($ProductIngredient) {
|
||||
$ProductIngredient->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
|
||||
return redirect(route('admin_product_edit', [$model->id]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if ($do === 'bundle') {
|
||||
$model = Product::findOrFail($id);
|
||||
$ProductBundle = ProductBundle::where('bundle_product_id', $did)->where('product_id', $model->id)->first();
|
||||
if ($ProductBundle) {
|
||||
$ProductBundle->delete();
|
||||
\Session()->flash('alert-success', 'Bundle-Produkt entfernt');
|
||||
|
||||
return redirect(route('admin_product_edit', [$model->id]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public function imageUpload(){
|
||||
public function imageUpload()
|
||||
{
|
||||
|
||||
$product_id = Request::get('product_id');
|
||||
$product = Product::findOrFail($product_id);
|
||||
|
|
@ -148,15 +157,15 @@ class ProductController extends Controller
|
|||
try {
|
||||
$image = \App\Services\Slim::getImages('images')[0];
|
||||
|
||||
if ( isset($image['output']['data']) )
|
||||
{
|
||||
if (isset($image['output']['data'])) {
|
||||
|
||||
// Base64 of the image
|
||||
$data = $image['output']['data'];
|
||||
$file_ex = array( 'image/jpeg' => 'jpg', 'image/png' => 'png');
|
||||
$file_ex = ['image/jpeg' => 'jpg', 'image/png' => 'png'];
|
||||
|
||||
if (!isset($file_ex[$image['output']['type']])) {
|
||||
if (! isset($file_ex[$image['output']['type']])) {
|
||||
\Session()->flash('alert-danger', 'File is not jpg or png!');
|
||||
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
}
|
||||
|
||||
|
|
@ -164,7 +173,7 @@ class ProductController extends Controller
|
|||
// Original file name
|
||||
$name = $image['output']['name'];
|
||||
$name = \App\Services\Slim::sanitizeFileName($name);
|
||||
$name = uniqid() . '_' . $name;
|
||||
$name = uniqid().'_'.$name;
|
||||
|
||||
$data = \Storage::disk('public')->put(
|
||||
'images/product/'.$product->id.'/'.$name,
|
||||
|
|
@ -177,46 +186,48 @@ class ProductController extends Controller
|
|||
'original_name' => $image['output']['name'],
|
||||
'ext' => $ext,
|
||||
'mine' => $image['output']['type'],
|
||||
'size' => $image['input']['size']
|
||||
'size' => $image['input']['size'],
|
||||
]);
|
||||
|
||||
|
||||
\Session()->flash('alert-success', __('msg.file_uploaded'));
|
||||
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
}
|
||||
\Session()->flash('alert-danger', __('msg.file_empty'));
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
|
||||
}
|
||||
catch ( \Exception $e) {
|
||||
\Session()->flash('alert-danger', "Fehler".$e);
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
} catch (\Exception $e) {
|
||||
\Session()->flash('alert-danger', 'Fehler'.$e);
|
||||
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
}
|
||||
}
|
||||
|
||||
public function imageDelete($image_id, $product_id){
|
||||
public function imageDelete($image_id, $product_id)
|
||||
{
|
||||
|
||||
$product = Product::findOrFail($product_id);
|
||||
$product_image = ProductImage::findOrFail($image_id);
|
||||
|
||||
if($product_image->product_id == $product->id){
|
||||
$file = 'images/product/'.$product->id.'/'.$product_image->filename;
|
||||
if ($product_image->product_id == $product->id) {
|
||||
$file = 'images/product/'.$product->id.'/'.$product_image->filename;
|
||||
\Storage::disk('public')->delete($file);
|
||||
|
||||
$product_image->delete();
|
||||
|
||||
\Session()->flash('alert-success', __('msg.file_deleted'));
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
}
|
||||
\Session()->flash('alert-danger', __('msg.file_not_found'));
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
}
|
||||
|
||||
public function imageAttribute($product_id, $attr, $val = false){
|
||||
public function imageAttribute($product_id, $attr, $val = false)
|
||||
{
|
||||
|
||||
if(is_numeric($val) && $val < 0){
|
||||
if (is_numeric($val) && $val < 0) {
|
||||
$val = 0;
|
||||
}
|
||||
|
||||
|
|
@ -225,9 +236,8 @@ class ProductController extends Controller
|
|||
$product_image->{$attr} = $val;
|
||||
$product_image->save();
|
||||
|
||||
\Session()->flash('alert-success', "Wert gespeichert");
|
||||
\Session()->flash('alert-success', 'Wert gespeichert');
|
||||
|
||||
return redirect()->back();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Models\IqImage;
|
||||
use App\Models\IqSite;
|
||||
use App\Models\DashboardNews;
|
||||
use Request;
|
||||
|
||||
|
||||
|
|
@ -17,7 +18,99 @@ class SitesController extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
//
|
||||
}
|
||||
|
||||
// Dashboard News Methods
|
||||
public function dashboardNews()
|
||||
{
|
||||
$data = [
|
||||
'news' => DashboardNews::orderBy('created_at', 'DESC')->get(),
|
||||
'languages' => config('localization.supportedLocales'),
|
||||
];
|
||||
return view('admin.site.news.index', $data);
|
||||
}
|
||||
|
||||
public function dashboardNewsEdit($id)
|
||||
{
|
||||
$news = $id === 'new' ? new DashboardNews() : DashboardNews::findOrFail($id);
|
||||
$data = [
|
||||
'news' => $news,
|
||||
'languages' => config('localization.supportedLocales'),
|
||||
];
|
||||
return view('admin.site.news.edit', $data);
|
||||
}
|
||||
|
||||
public function dashboardNewsStore($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
|
||||
// Handle translations
|
||||
$transTitle = [];
|
||||
$transTeaser = [];
|
||||
$transContent = [];
|
||||
|
||||
foreach (config('localization.supportedLocales') as $locale => $localeData) {
|
||||
if ($locale !== 'de') {
|
||||
$transTitle[$locale] = Request::get('trans_title_' . $locale, '');
|
||||
$transTeaser[$locale] = Request::get('trans_teaser_' . $locale, '');
|
||||
$transContent[$locale] = Request::get('trans_content_' . $locale, '');
|
||||
}
|
||||
}
|
||||
|
||||
$data['trans_title'] = $transTitle;
|
||||
$data['trans_teaser'] = $transTeaser;
|
||||
$data['trans_content'] = $transContent;
|
||||
$data['active'] = Request::has('active') ? 1 : 0;
|
||||
|
||||
// Handle file links
|
||||
$fileLinks = Request::get('file_links', []);
|
||||
// Filter out empty entries (where neither label nor file_id is set)
|
||||
$filteredFileLinks = [];
|
||||
foreach ($fileLinks as $locale => $links) {
|
||||
if (is_array($links)) {
|
||||
$filteredFileLinks[$locale] = array_values(array_filter($links, function ($link) {
|
||||
return !empty($link['file_id']) || !empty($link['label']);
|
||||
}));
|
||||
}
|
||||
}
|
||||
$data['file_links'] = $filteredFileLinks;
|
||||
|
||||
// Handle display_date
|
||||
if (!empty($data['display_date'])) {
|
||||
try {
|
||||
$data['display_date'] = \Carbon\Carbon::createFromFormat('d.m.Y', $data['display_date'])->format('Y-m-d');
|
||||
} catch (\Throwable $e) {
|
||||
$data['display_date'] = now()->format('Y-m-d');
|
||||
}
|
||||
} else {
|
||||
$data['display_date'] = now()->format('Y-m-d');
|
||||
}
|
||||
|
||||
// Wenn diese News aktiv gesetzt wird, setze alle anderen auf inaktiv
|
||||
if ($data['active']) {
|
||||
DashboardNews::where('active', 1)->update(['active' => 0]);
|
||||
}
|
||||
|
||||
if ($id === 'new') {
|
||||
DashboardNews::create($data);
|
||||
} else {
|
||||
$news = DashboardNews::findOrFail($id);
|
||||
$news->fill($data);
|
||||
$news->save();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-success', __('msg.saved_successfully'));
|
||||
return redirect(route('admin_dashboard_news'));
|
||||
}
|
||||
|
||||
public function dashboardNewsDelete($id)
|
||||
{
|
||||
$news = DashboardNews::findOrFail($id);
|
||||
$news->delete();
|
||||
|
||||
\Session()->flash('alert-success', __('msg.deleted_successfully'));
|
||||
return redirect(route('admin_dashboard_news'));
|
||||
}
|
||||
|
||||
public function show($site)
|
||||
|
|
@ -35,9 +128,9 @@ class SitesController extends Controller
|
|||
$data['products'] = isset($data['products']) ? $data['products'] : null;
|
||||
$data['set_products'] = isset($data['set_products']) ? $data['set_products'] : null;
|
||||
|
||||
if($site == "new"){
|
||||
// $model = IqSite::create($data);
|
||||
}else{
|
||||
if ($site == "new") {
|
||||
// $model = IqSite::create($data);
|
||||
} else {
|
||||
$model = IqSite::find(1);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
|
|
@ -45,25 +138,24 @@ class SitesController extends Controller
|
|||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_sites', ['start']));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public function imageUpload($site){
|
||||
public function imageUpload($site)
|
||||
{
|
||||
|
||||
$model = IqSite::find(1);
|
||||
|
||||
try {
|
||||
$image = \App\Services\Slim::getImages('images')[0];
|
||||
|
||||
if ( isset($image['output']['data']) )
|
||||
{
|
||||
if (isset($image['output']['data'])) {
|
||||
|
||||
// Base64 of the image
|
||||
$data = $image['output']['data'];
|
||||
$file_ex = array( 'image/jpeg' => 'jpg', 'image/png' => 'png');
|
||||
$file_ex = array('image/jpeg' => 'jpg', 'image/png' => 'png');
|
||||
|
||||
if (!isset($file_ex[$image['output']['type']])) {
|
||||
\Session()->flash('alert-danger', 'File is not jpg or png!');
|
||||
|
|
@ -79,10 +171,10 @@ class SitesController extends Controller
|
|||
$image_name = "";
|
||||
do {
|
||||
$image_name = uniqid('', false) . '_' . $name;
|
||||
} while (\Storage::disk('public')->exists($path.$image_name));
|
||||
} while (\Storage::disk('public')->exists($path . $image_name));
|
||||
|
||||
$data = \Storage::disk('public')->put(
|
||||
$path.$image_name,
|
||||
$path . $image_name,
|
||||
$data
|
||||
);
|
||||
|
||||
|
|
@ -102,22 +194,21 @@ class SitesController extends Controller
|
|||
}
|
||||
\Session()->flash('alert-danger', __('msg.file_empty'));
|
||||
return redirect(route('admin_sites', [$model->slug]));
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
\Session()->flash('alert-danger', "Error: ".$e);
|
||||
} catch (\Exception $e) {
|
||||
\Session()->flash('alert-danger', "Error: " . $e);
|
||||
return redirect(route('admin_sites', [$model->slug]));
|
||||
}
|
||||
}
|
||||
|
||||
public function imageDelete($site, $image_id){
|
||||
public function imageDelete($site, $image_id)
|
||||
{
|
||||
|
||||
$iq_image = IqImage::findOrFail($image_id);
|
||||
$model = IqSite::find(1);
|
||||
|
||||
|
||||
if($iq_image->id == $model->iq_image->id){
|
||||
$file = 'images/iq_images/'.$iq_image->filename;
|
||||
if ($iq_image->id == $model->iq_image->id) {
|
||||
$file = 'images/iq_images/' . $iq_image->filename;
|
||||
\Storage::disk('public')->delete($file);
|
||||
$model->iq_image_id = NULL;
|
||||
$model->save();
|
||||
|
|
@ -126,14 +217,13 @@ class SitesController extends Controller
|
|||
|
||||
\Session()->flash('alert-success', __('msg.file_deleted'));
|
||||
return redirect(route('admin_sites', [$model->slug]));
|
||||
|
||||
}
|
||||
\Session()->flash('alert-danger', __('msg.file_not_found'));
|
||||
return redirect(route('admin_sites', [$model->slug]));
|
||||
|
||||
}
|
||||
|
||||
public function imageAttribute($site, $image_id, $attr, $val = false){
|
||||
public function imageAttribute($site, $image_id, $attr, $val = false)
|
||||
{
|
||||
|
||||
$iq_image = IqImage::findOrFail($image_id);
|
||||
|
||||
|
|
@ -142,7 +232,5 @@ class SitesController extends Controller
|
|||
|
||||
\Session()->flash('alert-success', "Wert gespeichert");
|
||||
return redirect()->back();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,7 +270,9 @@ class AboController extends Controller
|
|||
->addColumn('name', function (Product $product) use ($user_abo) {
|
||||
return '<strong>' . $product->getLang('name') . '</strong><br>' . get_abo_type_badge_by_product($product);
|
||||
})
|
||||
|
||||
->addColumn('points', function (Product $product) use ($user_abo) {
|
||||
return '<span class="no-line-break">' . $product->getFormattedPoints() . '</span>';
|
||||
})
|
||||
->addColumn('price_net', function (Product $product) use ($user_abo) {
|
||||
$ufactor = $user_abo->is_for === 'me' ? true : false;
|
||||
return '<span class="no-line-break">' . $product->getFormattedPriceWith(true, $ufactor, Yard::instance('shopping')->getUserCountry()) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(true, true, Yard::instance('shopping')->getUserCountry()) . '</span>';
|
||||
|
|
@ -298,7 +300,7 @@ class AboController extends Controller
|
|||
->orderColumn('contents_total', 'contents_total $1')
|
||||
->orderColumn('weight', 'weight $1')
|
||||
|
||||
->rawColumns(['add_card', 'product', 'name', 'quantity', 'picture', 'price_net', 'price_gross', 'action'])
|
||||
->rawColumns(['add_card', 'points', 'product', 'name', 'quantity', 'picture', 'price_net', 'price_gross', 'action'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,17 +44,16 @@ class OrderController extends Controller
|
|||
{
|
||||
$user = User::find(Auth::user()->id);
|
||||
$shopping_order = ShoppingOrder::findOrFail($id);
|
||||
|
||||
|
||||
if ($shopping_order->auth_user_id !== $user->id) {
|
||||
Log::channel(self::LOG_CHANNEL)->warning("Unauthorized access attempt to order #{$id} by user #{$user->id}");
|
||||
abort(404);
|
||||
}
|
||||
|
||||
|
||||
if ($shopping_order->payment_for === 6 || $shopping_order->payment_for === 7) {
|
||||
Log::channel(self::LOG_CHANNEL)->info("Redirecting user #{$user->id} to customer order detail for order #{$id}");
|
||||
return redirect(route('user_shop_order_detail', [$shopping_order->id]));
|
||||
}
|
||||
|
||||
|
||||
$shopping_order->getLastShoppingPayment();
|
||||
|
||||
return view('user.order.detail', [
|
||||
|
|
@ -73,7 +72,7 @@ class OrderController extends Controller
|
|||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<a href="'.route('user_order_detail', [$ShoppingOrder->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
return '<a href="' . route('user_order_detail', [$ShoppingOrder->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->created_at->format("d.m.Y");
|
||||
|
|
@ -82,7 +81,7 @@ class OrderController extends Controller
|
|||
return Payment::getShoppingOrderBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="no-line-break">'.$ShoppingOrder->getFormattedTotalShipping()." €</span>";
|
||||
return '<span class="no-line-break">' . $ShoppingOrder->getFormattedTotalShipping() . " €</span>";
|
||||
})
|
||||
->addColumn('payment', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('getPaymentType');
|
||||
|
|
@ -90,21 +89,21 @@ class OrderController extends Controller
|
|||
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
|
||||
if ($ShoppingOrder->payment_for === 8) {
|
||||
return '<button type="button" class="btn btn-xs btn-info btn-round" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$ShoppingOrder->id.'"
|
||||
data-id="' . $ShoppingOrder->id . '"
|
||||
data-action="shop-user-order-shipping-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="user"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-eye"></span></button>';
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-eye"></span></button>';
|
||||
}
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
|
||||
return '<span class="badge badge-pill badge-' . $ShoppingOrder->getShippedColor() . '">' . $ShoppingOrder->getShippedType() . '</span>';
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return Payment::getPaymentForBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('invoice', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->isInvoice() ? '<span class="no-line-break"><a href="'.route('storage_file', [$ShoppingOrder->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a>
|
||||
<a href="'.route('storage_file', [$ShoppingOrder->id, 'invoice', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a></span>' : '-';
|
||||
return $ShoppingOrder->isInvoice() ? '<span class="no-line-break"><a href="' . route('storage_file', [$ShoppingOrder->id, 'invoice', 'download']) . '" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a>
|
||||
<a href="' . route('storage_file', [$ShoppingOrder->id, 'invoice', 'stream']) . '" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a></span>' : '-';
|
||||
})
|
||||
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('reference');
|
||||
|
|
@ -126,27 +125,26 @@ class OrderController extends Controller
|
|||
$user = User::find(Auth::user()->id);
|
||||
$shopping_user = null;
|
||||
$delivery_id = null;
|
||||
|
||||
|
||||
if (strpos($for, 'ot') !== false) {
|
||||
$shopping_user = Shop::checkShoppingUser($id, $user);
|
||||
$delivery_id = $shopping_user->id;
|
||||
|
||||
|
||||
if (!Shop::checkShoppingCountry($for, $delivery_id) && !\Session()->has('custom-error')) {
|
||||
$country = Shop::getDeliveryCountry($for, $delivery_id);
|
||||
\Session()->flash('custom-error', $country.": ".__('validation.custom.shipping_not_found'));
|
||||
Log::channel(self::LOG_CHANNEL)->warning("Shipping country not found for user #{$user->id}, country: {$country}");
|
||||
\Session()->flash('custom-error', $country . ": " . __('validation.custom.shipping_not_found'));
|
||||
Log::channel(self::LOG_CHANNEL)->error("Shipping country not found for user #{$user->id}, country: {$country}");
|
||||
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
|
||||
}
|
||||
|
||||
|
||||
if ($for === 'abo-ot-customer') {
|
||||
if (AboHelper::hasAboByEmail($shopping_user->billing_email) && !\Session()->has('custom-error')) {
|
||||
\Session()->flash('custom-error', __('abo.error_email_has_abo', ['email' => $shopping_user->billing_email]));
|
||||
Log::channel(self::LOG_CHANNEL)->info("User #{$user->id} attempted to create abo for email that already has one: {$shopping_user->billing_email}");
|
||||
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
|
||||
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Request::get('action') === 'next') {
|
||||
Yard::instance('shopping')->destroy();
|
||||
if (strpos(Request::get('switchers-radio-is-for'), 'ot') !== false) {
|
||||
|
|
@ -154,7 +152,7 @@ class OrderController extends Controller
|
|||
}
|
||||
return redirect(route('user_order_my_list', [Request::get('switchers-radio-is-for'), $delivery_id]));
|
||||
}
|
||||
|
||||
|
||||
return view('user.order.delivery', [
|
||||
'shopping_user' => $shopping_user,
|
||||
'isAdmin' => false,
|
||||
|
|
@ -167,33 +165,33 @@ class OrderController extends Controller
|
|||
public function list($for, $id = null)
|
||||
{
|
||||
$user = User::find(Auth::user()->id);
|
||||
|
||||
|
||||
if ($for === 'abo-me' && AboHelper::userHasAbo($user)) {
|
||||
Log::channel(self::LOG_CHANNEL)->warning("User #{$user->id} attempted to create abo but already has one");
|
||||
Log::channel(self::LOG_CHANNEL)->error("User #{$user->id} attempted to create abo but already has one");
|
||||
abort(403, 'User has an Abo. Cannot order.');
|
||||
}
|
||||
|
||||
|
||||
$shopping_user = null;
|
||||
$delivery_id = null;
|
||||
|
||||
|
||||
if (strpos($for, 'ot') !== false) {
|
||||
$shopping_user = Shop::checkShoppingUser($id, $user);
|
||||
$delivery_id = $shopping_user->id;
|
||||
}
|
||||
|
||||
|
||||
if ($for === 'ot-customer' || $for === 'abo-ot-customer') {
|
||||
UserService::initCustomerYard($shopping_user, $for);
|
||||
} else {
|
||||
$shipping_country_id = Shop::checkShoppingCountry($for, $id);
|
||||
if (!$shipping_country_id) {
|
||||
$country = Shop::getDeliveryCountry($for, $id);
|
||||
\Session()->flash('custom-error', $country.": ".__('validation.custom.shipping_not_found'));
|
||||
\Session()->flash('custom-error', $country . ": " . __('validation.custom.shipping_not_found'));
|
||||
Log::channel(self::LOG_CHANNEL)->warning("Shipping country not found for user #{$user->id}, country: {$country}");
|
||||
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
|
||||
}
|
||||
UserService::initUserYard($user, $shipping_country_id, $for);
|
||||
}
|
||||
|
||||
|
||||
return view('user.order.list', [
|
||||
'shopping_user' => $shopping_user,
|
||||
'user' => $user,
|
||||
|
|
@ -211,7 +209,7 @@ class OrderController extends Controller
|
|||
{
|
||||
$data = Request::all();
|
||||
$user = User::find(Auth::user()->id);
|
||||
|
||||
|
||||
$rules = [
|
||||
'shipping_salutation' => 'required',
|
||||
'shipping_firstname' => 'required',
|
||||
|
|
@ -221,14 +219,13 @@ class OrderController extends Controller
|
|||
'shipping_city' => 'required',
|
||||
'shipping_state' => 'required',
|
||||
];
|
||||
|
||||
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
||||
|
||||
if ($validator->fails()) {
|
||||
Log::channel(self::LOG_CHANNEL)->info("Validation failed for payment form", ['errors' => $validator->errors()->toArray()]);
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$this->checkSendYardForPayment($data, $id);
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -243,28 +240,22 @@ class OrderController extends Controller
|
|||
if (Yard::instance('shopping')->getNumComp() > 0) {
|
||||
if (!isset($data['switchers-comp-product'])) {
|
||||
$validator->errors()->add('switchers-comp-product', __('msg.please_select_compensation_product'));
|
||||
Log::channel(self::LOG_CHANNEL)->info("Compensation product not selected");
|
||||
} else if (!is_array($data['switchers-comp-product'])) {
|
||||
$validator->errors()->add('switchers-comp-product', __('msg.please_select_compensation_product'));
|
||||
Log::channel(self::LOG_CHANNEL)->info("Compensation product selection is not an array");
|
||||
} else if (count($data['switchers-comp-product']) !== Yard::instance('shopping')->getNumComp()) {
|
||||
$validator->errors()->add('switchers-comp-product', __('mdg.please_select_count_compensation_products', ['count' => Yard::instance('shopping')->getNumComp()]));
|
||||
Log::channel(self::LOG_CHANNEL)->info("Incorrect number of compensation products selected", [
|
||||
'required' => Yard::instance('shopping')->getNumComp(),
|
||||
'selected' => count($data['switchers-comp-product'])
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
if ($validator->errors()->count()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Generate unique identifier
|
||||
do {
|
||||
$identifier = Util::getToken();
|
||||
} while (ShoppingInstance::where('identifier', $identifier)->count());
|
||||
|
||||
|
||||
// Prepare common data
|
||||
$data['is_from'] = 'user_order';
|
||||
$data['is_for'] = $for;
|
||||
|
|
@ -273,17 +264,11 @@ class OrderController extends Controller
|
|||
$data['shopping_user_id'] = $id;
|
||||
$data['user_price_infos'] = Yard::instance('shopping')->getUserPriceInfos();
|
||||
$data['mode'] = config('app.mode') === 'test' ? 'test' : 'live';
|
||||
|
||||
|
||||
// Remove unnecessary data
|
||||
unset($data['quantity']);
|
||||
unset($data['_token']);
|
||||
|
||||
Log::channel(self::LOG_CHANNEL)->info("Processing payment for user #{$user->id}", [
|
||||
'for' => $for,
|
||||
'identifier' => $identifier,
|
||||
'is_abo' => $data['is_abo']
|
||||
]);
|
||||
|
||||
|
||||
if ($for === 'ot-customer' || $for === 'abo-ot-customer') {
|
||||
return $this->processCustomerPayment($user, $identifier, $data, $id, $for);
|
||||
} else {
|
||||
|
|
@ -309,30 +294,26 @@ class OrderController extends Controller
|
|||
'shopping_data' => $data,
|
||||
'back' => url()->previous(),
|
||||
]);
|
||||
|
||||
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$yard_shopping_items = OrderPaymentService::getRestoredYardShoppingItems($shopping_instance);
|
||||
|
||||
// Send Mail to Customer
|
||||
try {
|
||||
$this->customPaymentSendMail($user, $identifier, $yard_shopping_items, $data);
|
||||
Log::channel(self::LOG_CHANNEL)->info("Custom payment email sent successfully", [
|
||||
'identifier' => $identifier,
|
||||
'user_id' => $user->id
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
Log::channel(self::LOG_CHANNEL)->error("Failed to send custom payment email: " . $e->getMessage(), [
|
||||
'identifier' => $identifier,
|
||||
'user_id' => $user->id
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
UserHistory::create([
|
||||
'user_id' => $user->id,
|
||||
'action' => 'user_order_customer',
|
||||
'status' => 1,
|
||||
'product_id' => null,
|
||||
'identifier' => $identifier,
|
||||
'user_id' => $user->id,
|
||||
'action' => 'user_order_customer',
|
||||
'status' => 1,
|
||||
'product_id' => null,
|
||||
'identifier' => $identifier,
|
||||
'is_abo' => $data['is_abo']
|
||||
]);
|
||||
|
||||
|
|
@ -359,18 +340,18 @@ class OrderController extends Controller
|
|||
'shopping_data' => $data,
|
||||
'back' => url()->previous(),
|
||||
]);
|
||||
|
||||
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
|
||||
|
||||
UserHistory::create([
|
||||
'user_id' => $user->id,
|
||||
'action' => 'user_order_payment',
|
||||
'status' => 1,
|
||||
'product_id' => null,
|
||||
'identifier' => $identifier,
|
||||
'user_id' => $user->id,
|
||||
'action' => 'user_order_payment',
|
||||
'status' => 1,
|
||||
'product_id' => null,
|
||||
'identifier' => $identifier,
|
||||
'is_abo' => $data['is_abo']
|
||||
]);
|
||||
|
||||
|
||||
$path = route('checkout.checkout_card', ['identifier' => $identifier]);
|
||||
return redirect()->secure($path);
|
||||
}
|
||||
|
|
@ -382,7 +363,7 @@ class OrderController extends Controller
|
|||
{
|
||||
$user = User::find(Auth::user()->id);
|
||||
$shopping_user = null;
|
||||
|
||||
|
||||
if (strpos($data['shipping_is_for'], 'ot') !== false) {
|
||||
$shopping_user = Shop::checkShoppingUser($id, $user);
|
||||
}
|
||||
|
|
@ -396,13 +377,13 @@ class OrderController extends Controller
|
|||
'shopping_user_id' => $id,
|
||||
'yard_identifier' => $identifier
|
||||
];
|
||||
|
||||
|
||||
MyLog::writeLog('payment', 'error', 'no shipping_country_id found | Yard identifier: ' . $identifier, $data);
|
||||
Log::channel(self::LOG_CHANNEL)->error("Shipping country not found", $logData);
|
||||
|
||||
|
||||
throw new \Exception(__('msg.shipping_country_was_not_found'));
|
||||
}
|
||||
|
||||
|
||||
// Must be the same shipping country
|
||||
if ($shipping_country_id != Yard::instance('shopping')->getShippingCountryId()) {
|
||||
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
|
||||
|
|
@ -414,10 +395,10 @@ class OrderController extends Controller
|
|||
'expected' => $shipping_country_id,
|
||||
'actual' => Yard::instance('shopping')->getShippingCountryId()
|
||||
];
|
||||
|
||||
|
||||
MyLog::writeLog('payment', 'error', 'shipping_country_id is not the same from Yard | Yard identifier: ' . $identifier, $data);
|
||||
Log::channel(self::LOG_CHANNEL)->error("Shipping country mismatch", $logData);
|
||||
|
||||
|
||||
throw new \Exception(__('msg.shipping_country_was_not_correctly'));
|
||||
}
|
||||
|
||||
|
|
@ -430,14 +411,14 @@ class OrderController extends Controller
|
|||
'shopping_user_id' => $id,
|
||||
'yard_identifier' => $identifier
|
||||
];
|
||||
|
||||
|
||||
MyLog::writeLog('payment', 'error', 'Yard can by not shipping_free | Yard identifier: ' . $identifier, $data);
|
||||
Log::channel(self::LOG_CHANNEL)->error("Yard cannot be shipping free", $logData);
|
||||
|
||||
|
||||
throw new \Exception(__('msg.shopping_cart_was_shipping_free'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($data['shipping_is_for'] === 'ot-customer') {
|
||||
if (!$user->shop) {
|
||||
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
|
||||
|
|
@ -447,16 +428,16 @@ class OrderController extends Controller
|
|||
'shopping_user_id' => $id,
|
||||
'yard_identifier' => $identifier
|
||||
];
|
||||
|
||||
|
||||
MyLog::writeLog('payment', 'error', 'User has no Shop for an User to Customer order| Yard identifier: ' . $identifier, $data);
|
||||
Log::channel(self::LOG_CHANNEL)->error("User has no shop for customer order", $logData);
|
||||
|
||||
|
||||
throw new \Exception(__('msg.shopping_cart_was_not_user_shop'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$shipping_price = Shop::getShippingPriceByShippingCountryId($shipping_country_id, Yard::instance('shopping')->weight());
|
||||
|
||||
|
||||
// For other and has weight - check
|
||||
if (strpos($data['shipping_is_for'], 'ot') !== false && $data['shipping_is_for'] !== 'ot-customer' && Yard::instance('shopping')->weight() > 0) {
|
||||
if (!Yard::instance('shopping')->getShippingPrice() || Yard::instance('shopping')->getShippingPrice() == 0) {
|
||||
|
|
@ -468,13 +449,13 @@ class OrderController extends Controller
|
|||
'yard_identifier' => $identifier,
|
||||
'weight' => Yard::instance('shopping')->weight()
|
||||
];
|
||||
|
||||
|
||||
MyLog::writeLog('payment', 'error', 'Yard OT shipping_price is 0 | Yard identifier: ' . $identifier, $data);
|
||||
Log::channel(self::LOG_CHANNEL)->error("Shipping price cannot be zero for order with weight", $logData);
|
||||
|
||||
|
||||
throw new \Exception(__('msg.shipping_cost_cannot_be_0'));
|
||||
}
|
||||
|
||||
|
||||
if (Yard::instance('shopping')->getShippingPrice() != $shipping_price->price) {
|
||||
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
|
|
@ -485,14 +466,14 @@ class OrderController extends Controller
|
|||
'expected' => $shipping_price->price,
|
||||
'actual' => Yard::instance('shopping')->getShippingPrice()
|
||||
];
|
||||
|
||||
|
||||
MyLog::writeLog('payment', 'error', 'Yard OT shipping_price is not the same from shipping_price | Yard identifier: ' . $identifier, $data);
|
||||
Log::channel(self::LOG_CHANNEL)->error("Shipping price mismatch", $logData);
|
||||
|
||||
|
||||
throw new \Exception(__('msg.shipping_costs_were_not_calculated_correctly'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($data['shipping_is_for'] == 'me' || $data['shipping_is_for'] == 'abo-me') && Yard::instance('shopping')->weight() > 0) {
|
||||
if (!Yard::instance('shopping')->getShippingPrice() || Yard::instance('shopping')->getShippingPrice() == 0) {
|
||||
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
|
||||
|
|
@ -503,14 +484,14 @@ class OrderController extends Controller
|
|||
'yard_identifier' => $identifier,
|
||||
'weight' => Yard::instance('shopping')->weight()
|
||||
];
|
||||
|
||||
|
||||
MyLog::writeLog('payment', 'error', 'Yard ME shipping_price is 0 | Yard identifier: ' . $identifier, $data);
|
||||
Log::channel(self::LOG_CHANNEL)->error("Shipping price cannot be zero for personal order with weight", $logData);
|
||||
|
||||
|
||||
throw new \Exception(__('msg.shipping_cost_cannot_be_0'));
|
||||
}
|
||||
|
||||
if(Shop::isCompProducts($data['shipping_is_for'])){
|
||||
|
||||
if (Shop::isCompProducts($data['shipping_is_for'])) {
|
||||
if (Yard::instance('shopping')->getShippingPrice() != $shipping_price->price_comp) {
|
||||
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
|
|
@ -521,13 +502,13 @@ class OrderController extends Controller
|
|||
'expected' => $shipping_price->price_comp,
|
||||
'actual' => Yard::instance('shopping')->getShippingPrice()
|
||||
];
|
||||
|
||||
|
||||
MyLog::writeLog('payment', 'error', 'Yard ME shipping_price is not the same from shipping_price with comp products | Yard identifier: ' . $identifier, $data);
|
||||
Log::channel(self::LOG_CHANNEL)->error("Shipping price mismatch for personal order", $logData);
|
||||
|
||||
|
||||
throw new \Exception(__('msg.shipping_costs_were_not_calculated_correctly'));
|
||||
}
|
||||
|
||||
|
||||
if (Yard::instance('shopping')->getNumComp() != $shipping_price->num_comp) {
|
||||
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
|
|
@ -538,13 +519,13 @@ class OrderController extends Controller
|
|||
'expected' => $shipping_price->num_comp,
|
||||
'actual' => Yard::instance('shopping')->getNumComp()
|
||||
];
|
||||
|
||||
|
||||
MyLog::writeLog('payment', 'error', 'Yard num_comp is not correct | Yard identifier: ' . $identifier, $data);
|
||||
Log::channel(self::LOG_CHANNEL)->error("Compensation product count mismatch", $logData);
|
||||
|
||||
|
||||
throw new \Exception(__('msg.compensation_products_cannot_be_0'));
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
if (Yard::instance('shopping')->getShippingPrice() != $shipping_price->price) {
|
||||
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
|
|
@ -555,14 +536,13 @@ class OrderController extends Controller
|
|||
'expected' => $shipping_price->price,
|
||||
'actual' => Yard::instance('shopping')->getShippingPrice()
|
||||
];
|
||||
|
||||
|
||||
MyLog::writeLog('payment', 'error', 'Yard ME shipping_price is not the same from shipping_price without comp products | Yard identifier: ' . $identifier, $data);
|
||||
Log::channel(self::LOG_CHANNEL)->error("Shipping price mismatch for personal order", $logData);
|
||||
|
||||
|
||||
throw new \Exception(__('msg.shipping_costs_were_not_calculated_correctly'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -570,60 +550,58 @@ class OrderController extends Controller
|
|||
{
|
||||
$isAbo = Request::get('is_abo');
|
||||
$shippingIsFor = Request::get('shipping_is_for');
|
||||
|
||||
|
||||
if ($shippingIsFor === 'me' || $shippingIsFor === 'abo-me') {
|
||||
$show_on_ids = $isAbo ? ['12', '13'] : ['2'];
|
||||
|
||||
|
||||
$query = Product::with('product_buyings')
|
||||
->select('products.*')
|
||||
->where('products.active', true)
|
||||
->where(function($q) use ($show_on_ids) {
|
||||
->where(function ($q) use ($show_on_ids) {
|
||||
foreach ($show_on_ids as $id) {
|
||||
$q->orWhereJsonContains('show_on', $id);
|
||||
}
|
||||
})
|
||||
->orderByRaw("CASE
|
||||
->orderByRaw(
|
||||
"CASE
|
||||
WHEN JSON_CONTAINS(show_on, ?, '$') THEN 1
|
||||
WHEN JSON_CONTAINS(show_on, ?, '$') THEN 2
|
||||
ELSE 3 END",
|
||||
[$show_on_ids[0], isset($show_on_ids[1]) ? $show_on_ids[1] : $show_on_ids[0]]);
|
||||
ELSE 3 END",
|
||||
[$show_on_ids[0], isset($show_on_ids[1]) ? $show_on_ids[1] : $show_on_ids[0]]
|
||||
);
|
||||
} else {
|
||||
$show_on_ids = $isAbo ? ['12', '13'] : ['3'];
|
||||
|
||||
|
||||
$query = Product::select('products.*')
|
||||
->where('active', true)
|
||||
->where(function($q) use ($show_on_ids) {
|
||||
->where(function ($q) use ($show_on_ids) {
|
||||
foreach ($show_on_ids as $id) {
|
||||
$q->orWhereJsonContains('show_on', $id);
|
||||
}
|
||||
})
|
||||
->orderByRaw("CASE
|
||||
->orderByRaw(
|
||||
"CASE
|
||||
WHEN JSON_CONTAINS(show_on, ?, '$') THEN 1
|
||||
WHEN JSON_CONTAINS(show_on, ?, '$') THEN 2
|
||||
ELSE 3 END",
|
||||
[$show_on_ids[0], isset($show_on_ids[1]) ? $show_on_ids[1] : $show_on_ids[0]]);
|
||||
ELSE 3 END",
|
||||
[$show_on_ids[0], isset($show_on_ids[1]) ? $show_on_ids[1] : $show_on_ids[0]]
|
||||
);
|
||||
}
|
||||
|
||||
Log::channel(self::LOG_CHANNEL)->info("Datatable query executed", [
|
||||
'is_abo' => $isAbo,
|
||||
'shipping_is_for' => $shippingIsFor,
|
||||
'show_on_ids' => $show_on_ids
|
||||
]);
|
||||
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('product', function (Product $product) {
|
||||
$cartItem = Yard::instance('shopping')->getCartItemByProduct($product->id);
|
||||
$qty = isset($cartItem->qty) ? $cartItem->qty : 0;
|
||||
$rowId = isset($cartItem->rowId) ? $cartItem->rowId : '';
|
||||
return '<strong>'.$product->getLang('name').'</strong><br>
|
||||
return '<strong>' . $product->getLang('name') . '</strong><br>
|
||||
<div class="no-line-break input-group-min-w">
|
||||
<div class="input-group d-inline-flex w-auto">
|
||||
<span class="input-group-prepend">
|
||||
<button type="button" class="btn btn-secondary icon-btn md-btn-extra remove-product-basket" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'">-</button>
|
||||
<button type="button" class="btn btn-secondary icon-btn md-btn-extra remove-product-basket" data-row-id="' . $rowId . '" data-product-id="' . $product->id . '">-</button>
|
||||
</span>
|
||||
<input type="text" class="form-control text-center input-extra table-input-event-onchange" name="product_qty_'.$product->id.'" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'" value="'.$qty.'">
|
||||
<input type="text" class="form-control text-center input-extra table-input-event-onchange" name="product_qty_' . $product->id . '" data-row-id="' . $rowId . '" data-product-id="' . $product->id . '" value="' . $qty . '">
|
||||
<span class="input-group-append">
|
||||
<button type="button" class="btn btn-secondary icon-btn md-btn-extra add-product-basket" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'">+</button>
|
||||
<button type="button" class="btn btn-secondary icon-btn md-btn-extra add-product-basket" data-row-id="' . $rowId . '" data-product-id="' . $product->id . '">+</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
|
|
@ -632,37 +610,40 @@ class OrderController extends Controller
|
|||
return AboHelper::getAboTypeBadge(AboHelper::getAboShowOn($product));
|
||||
})
|
||||
->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 "";
|
||||
})
|
||||
->addColumn('points', function (Product $product) {
|
||||
return '<span class="no-line-break">' . $product->getFormattedPoints() . '</span>';
|
||||
})
|
||||
->addColumn('price_net', function (Product $product) {
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(true, true, Yard::instance('shopping')->getUserCountry()). " €</span>".'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(true, true, Yard::instance('shopping')->getUserCountry()).'</span>';
|
||||
return '<span class="no-line-break">' . $product->getFormattedPriceWith(true, true, Yard::instance('shopping')->getUserCountry()) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(true, true, Yard::instance('shopping')->getUserCountry()) . '</span>';
|
||||
})
|
||||
->addColumn('price_gross', function (Product $product) {
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(false, true, Yard::instance('shopping')->getUserCountry()). " €</span>".'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(false, true, Yard::instance('shopping')->getUserCountry()).'</span>';
|
||||
return '<span class="no-line-break">' . $product->getFormattedPriceWith(false, true, Yard::instance('shopping')->getUserCountry()) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(false, true, Yard::instance('shopping')->getUserCountry()) . '</span>';
|
||||
})
|
||||
->addColumn('price_vk_gross', function (Product $product) {
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(false, false, Yard::instance('shopping')->getUserCountry()). " €</span>".'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(false, false, Yard::instance('shopping')->getUserCountry()).'</span>';
|
||||
return '<span class="no-line-break">' . $product->getFormattedPriceWith(false, false, Yard::instance('shopping')->getUserCountry()) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(false, false, Yard::instance('shopping')->getUserCountry()) . '</span>';
|
||||
})
|
||||
->addColumn('customer_price_net', function (Product $product) {
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(true, false, Yard::instance('shopping')->getUserCountry()). " €</span>".'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(true, false, Yard::instance('shopping')->getUserCountry()).'</span>';
|
||||
return '<span class="no-line-break">' . $product->getFormattedPriceWith(true, false, Yard::instance('shopping')->getUserCountry()) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(true, false, Yard::instance('shopping')->getUserCountry()) . '</span>';
|
||||
})
|
||||
->addColumn('customer_price_gross', function (Product $product) {
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(false, false, Yard::instance('shopping')->getUserCountry()). " €</span>".'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(false, false, Yard::instance('shopping')->getUserCountry()).'</span>';
|
||||
return '<span class="no-line-break">' . $product->getFormattedPriceWith(false, false, Yard::instance('shopping')->getUserCountry()) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(false, false, Yard::instance('shopping')->getUserCountry()) . '</span>';
|
||||
})
|
||||
->addColumn('my_commission_net', function (Product $product) {
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(true, false, Yard::instance('shopping')->getUserCountry(), true). " €</span>".'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(true, false, Yard::instance('shopping')->getUserCountry(), true).'</span>';
|
||||
return '<span class="no-line-break">' . $product->getFormattedPriceWith(true, false, Yard::instance('shopping')->getUserCountry(), true) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(true, false, Yard::instance('shopping')->getUserCountry(), true) . '</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')
|
||||
|
|
@ -678,7 +659,7 @@ class OrderController extends Controller
|
|||
->orderColumn('contents_total', 'contents_total $1')
|
||||
->orderColumn('weight', 'weight $1')
|
||||
->orderColumn('abo', 'show_on $1')
|
||||
->rawColumns(['add_card', 'price_net', 'price_gross', 'price_vk_gross', 'customer_price_net', 'customer_price_gross', 'my_commission_net', 'product', 'quantity', 'picture', 'abo', 'action'])
|
||||
->rawColumns(['add_card', 'points', 'price_net', 'price_gross', 'price_vk_gross', 'customer_price_net', 'customer_price_gross', 'my_commission_net', 'product', 'quantity', 'picture', 'abo', 'action'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
|
@ -691,7 +672,7 @@ class OrderController extends Controller
|
|||
Log::channel(self::LOG_CHANNEL)->warning("Non-AJAX request to performRequest method");
|
||||
return response()->json(['response' => false, 'message' => 'Only AJAX requests are allowed']);
|
||||
}
|
||||
|
||||
|
||||
$data = Request::all();
|
||||
$is_for = isset($data['shipping_is_for']) ? $data['shipping_is_for'] : 'ot-member';
|
||||
$data['for'] = $is_for;
|
||||
|
|
@ -705,17 +686,16 @@ class OrderController extends Controller
|
|||
if ($data['action'] === 'updateCart' && isset($data['product_id'])) {
|
||||
return $this->handleUpdateCart($data, $is_for);
|
||||
}
|
||||
|
||||
|
||||
if ($data['action'] === 'clearCart') {
|
||||
Yard::instance('shopping')->destroy();
|
||||
Log::channel(self::LOG_CHANNEL)->info("Cart cleared");
|
||||
return response()->json(['response' => true, 'data' => Yard::instance('shopping')->count(), 'html_card' => '', 'html_comp' => '']);
|
||||
}
|
||||
|
||||
if ($data['action'] === 'updateShippingCountry') {
|
||||
return $this->handleUpdateShippingCountry($data, $is_for);
|
||||
}
|
||||
|
||||
|
||||
if ($data['action'] === 'updateCompProduct') {
|
||||
return $this->handleUpdateCompProduct($data, $is_for);
|
||||
}
|
||||
|
|
@ -743,41 +723,44 @@ class OrderController extends Controller
|
|||
// Get the cart item
|
||||
if ($is_for === 'ot-customer' || $is_for === 'abo-ot-customer') {
|
||||
$cartItem = Yard::instance('shopping')
|
||||
->add($product->id, $product->getLang('name'), 1,
|
||||
round($product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), 1), false, false,
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
->add(
|
||||
$product->id,
|
||||
$product->getLang('name'),
|
||||
1,
|
||||
round($product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), 1),
|
||||
false,
|
||||
false,
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]
|
||||
);
|
||||
} else {
|
||||
$cartItem = Yard::instance('shopping')
|
||||
->add($product->id, $product->getLang('name'), 1,
|
||||
$product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), true, Yard::instance('shopping')->getUserCountry()), false, false,
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
->add(
|
||||
$product->id,
|
||||
$product->getLang('name'),
|
||||
1,
|
||||
$product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), true, Yard::instance('shopping')->getUserCountry()),
|
||||
false,
|
||||
false,
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (Yard::instance('shopping')->getUserTaxFree()) {
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
} else {
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(Yard::instance('shopping')->getUserCountry()));
|
||||
}
|
||||
|
||||
|
||||
if (isset($data['qty']) && $data['qty'] > 0) {
|
||||
Yard::instance('shopping')->update($cartItem->rowId, $data['qty']);
|
||||
Log::channel(self::LOG_CHANNEL)->info("Cart item updated", [
|
||||
'product_id' => $product->id,
|
||||
'product_name' => $product->getLang('name'),
|
||||
'qty' => $data['qty']
|
||||
]);
|
||||
} else {
|
||||
// If 0 get the item by qty:1 and remove it
|
||||
Yard::instance('shopping')->remove($cartItem->rowId);
|
||||
Log::channel(self::LOG_CHANNEL)->info("Cart item removed", [
|
||||
'product_id' => $product->id,
|
||||
'product_name' => $product->getLang('name')
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Yard::instance('shopping')->reCalculateShippingPrice();
|
||||
$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();
|
||||
|
||||
|
|
@ -794,21 +777,16 @@ class OrderController extends Controller
|
|||
if ($shipping_country) {
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country->id, $is_for);
|
||||
$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
|
||||
|
||||
Log::channel(self::LOG_CHANNEL)->info("Shipping country updated", [
|
||||
'shipping_country_id' => $shipping_country->id,
|
||||
'shipping_country_name' => $shipping_country->name ?? 'unknown'
|
||||
]);
|
||||
} else {
|
||||
Log::channel(self::LOG_CHANNEL)->warning("Shipping country not found", [
|
||||
'shipping_country_id' => $data['shipping_country_id']
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$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]);
|
||||
}
|
||||
|
||||
|
|
@ -819,13 +797,7 @@ class OrderController extends Controller
|
|||
{
|
||||
$this->updateCompProduct($data);
|
||||
Yard::instance('shopping')->reCalculateShippingPrice();
|
||||
|
||||
Log::channel(self::LOG_CHANNEL)->info("Compensation product updated", [
|
||||
'comp_product_id' => $data['comp_product_id'] ?? null,
|
||||
'comp_num' => $data['comp_num'] ?? null,
|
||||
'count_comp_products' => $data['count_comp_products'] ?? null
|
||||
]);
|
||||
|
||||
|
||||
$html_card = view("user.order.yard_view_form", $data)->render();
|
||||
$html_comp = view("user.order.comp_product", $data)->render();
|
||||
|
||||
|
|
@ -841,12 +813,6 @@ class OrderController extends Controller
|
|||
// If equal or greater, delete due to new shipping costs
|
||||
if ($row->options->comp && $row->options->comp > intval($count_comp_products)) {
|
||||
Yard::instance('shopping')->remove($row->rowId);
|
||||
Log::channel(self::LOG_CHANNEL)->info("Compensation product removed due to count change", [
|
||||
'product_id' => $row->id,
|
||||
'product_name' => $row->name,
|
||||
'comp_value' => $row->options->comp,
|
||||
'required_comp' => $count_comp_products
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -864,13 +830,6 @@ class OrderController extends Controller
|
|||
//comp_num welches comp product wird hinzugefügt
|
||||
if ($row->options->comp && ($row->options->comp == intval($data['comp_num']) || $row->options->comp > intval($data['count_comp_products']))) {
|
||||
Yard::instance('shopping')->remove($row->rowId);
|
||||
Log::channel(self::LOG_CHANNEL)->info("Compensation product removed during update", [
|
||||
'product_id' => $row->id,
|
||||
'product_name' => $row->name,
|
||||
'comp_value' => $row->options->comp,
|
||||
'comp_num' => $data['comp_num'],
|
||||
'count_comp_products' => $data['count_comp_products']
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -881,23 +840,24 @@ class OrderController extends Controller
|
|||
if ($product->images->count()) {
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, 0, false, false, [
|
||||
'image' => $image,
|
||||
'slug' => $product->slug,
|
||||
'weight' => 0,
|
||||
$cartItem = Yard::instance('shopping')->add(
|
||||
$product->id,
|
||||
$product->getLang('name'),
|
||||
1,
|
||||
0,
|
||||
false,
|
||||
false,
|
||||
[
|
||||
'image' => $image,
|
||||
'slug' => $product->slug,
|
||||
'weight' => 0,
|
||||
'points' => 0,
|
||||
'comp' => intval($data['comp_num']),
|
||||
'comp' => intval($data['comp_num']),
|
||||
'product_id' => $product->id
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
|
||||
Log::channel(self::LOG_CHANNEL)->info("Compensation product added", [
|
||||
'product_id' => $product->id,
|
||||
'product_name' => $product->getLang('name'),
|
||||
'comp_num' => $data['comp_num']
|
||||
]);
|
||||
} else {
|
||||
Log::channel(self::LOG_CHANNEL)->warning("Compensation product not found", [
|
||||
'comp_product_id' => $data['comp_product_id']
|
||||
|
|
@ -913,7 +873,6 @@ class OrderController extends Controller
|
|||
{
|
||||
try {
|
||||
$data = OrderPaymentService::getCustomPayment($identifier);
|
||||
Log::channel(self::LOG_CHANNEL)->info("Custom payment page accessed", ['identifier' => $identifier]);
|
||||
return view('user.order.payment.custom_payment', $data);
|
||||
} catch (\Exception $e) {
|
||||
Log::channel(self::LOG_CHANNEL)->error("Error accessing custom payment: " . $e->getMessage(), ['identifier' => $identifier]);
|
||||
|
|
@ -928,38 +887,32 @@ class OrderController extends Controller
|
|||
{
|
||||
$bcc = [];
|
||||
$shopping_instance = ShoppingInstance::where('identifier', $identifier)->first();
|
||||
|
||||
|
||||
if (!$shopping_instance) {
|
||||
Log::channel(self::LOG_CHANNEL)->error("Shopping instance not found for email", ['identifier' => $identifier]);
|
||||
throw new \Exception(__('msg.shopping_instance_not_found'));
|
||||
}
|
||||
|
||||
|
||||
$shopping_user = $data['shopping_user_id'] ? ShoppingUser::find($data['shopping_user_id']) : null;
|
||||
|
||||
|
||||
if (!$shopping_user) {
|
||||
Log::channel(self::LOG_CHANNEL)->error("Shopping user not found for email", ['shopping_user_id' => $data['shopping_user_id']]);
|
||||
throw new \Exception(__('msg.shopping_user_not_found'));
|
||||
}
|
||||
|
||||
$route = route('checkout.checkout_card', ['identifier' => $identifier]);
|
||||
|
||||
|
||||
$billing_email = $shopping_user->billing_email;
|
||||
if (!$billing_email) {
|
||||
$billing_email = $data['mode'] === 'test' ? config('app.checkout_test_mail') : config('app.checkout_mail');
|
||||
}
|
||||
|
||||
|
||||
$bcc[] = $data['mode'] === 'test' ? config('app.checkout_test_mail') : config('app.checkout_mail');
|
||||
$bcc[] = $shopping_user->member ? $shopping_user->member->email : $user->email;
|
||||
|
||||
Log::channel(self::LOG_CHANNEL)->info("Sending custom payment email", [
|
||||
'to' => $billing_email,
|
||||
'bcc' => $bcc,
|
||||
'identifier' => $identifier
|
||||
]);
|
||||
|
||||
Mail::to($billing_email)
|
||||
->bcc($bcc)
|
||||
->locale(\App::getLocale())
|
||||
->send(new MailCustomPaymet($route, $shopping_user, $shopping_instance, $yard_shopping_items, $data['mode']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use App\Services\BusinessPlan\TreeCalcBot;
|
|||
use App\Services\BusinessPlan\TreeCalcBotOptimized;
|
||||
use App\Services\BusinessPlan\TreeHelperOptimized;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Services\LevelReportService;
|
||||
use App\Services\NextLevelBadgeHelper;
|
||||
use App\Services\TranslationHelper;
|
||||
use App\User;
|
||||
|
|
@ -134,7 +135,7 @@ class TeamController extends Controller
|
|||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
if (config('app.debug')) {
|
||||
$user = User::find(454);
|
||||
// $user = User::find(454);
|
||||
}
|
||||
$this->setFilterVars();
|
||||
|
||||
|
|
@ -491,6 +492,141 @@ class TeamController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeigt Level-Aufstieg Reports für das eigene Team
|
||||
* Nur für einen ausgewählten Monat/Jahr basierend auf TreeCalcBotOptimized
|
||||
*/
|
||||
public function levelReports(Request $request)
|
||||
{
|
||||
$startTime = microtime(true);
|
||||
|
||||
try {
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$this->setFilterVars();
|
||||
|
||||
// Monat und Jahr aus Request oder Session
|
||||
$month = Request::get('month') ?: session('team_user_filter_month_prev', intval(date('m') - 1));
|
||||
$year = Request::get('year') ?: session('team_user_filter_year', date('Y'));
|
||||
$onlyNotUpdated = Request::boolean('not_updated', false);
|
||||
|
||||
// Prüfe ob Live-Berechnung erzwungen werden soll
|
||||
$forceLiveCalculation = false; //Request::get('force_live_calculation', false) || Request::get('live', false);
|
||||
|
||||
\Log::info("TeamController: Building level reports for user {$user->id} ({$month}/{$year})");
|
||||
|
||||
// Lade Team-Struktur mit TreeCalcBotOptimized
|
||||
$treeCalcBot = new TreeCalcBotOptimized($month, $year, 'member', $forceLiveCalculation);
|
||||
$treeCalcBot->initStructureUser($user->id, $forceLiveCalculation);
|
||||
|
||||
// Lade Level-Reports für Team
|
||||
$levelReportService = new LevelReportService();
|
||||
$filters = ['only_not_updated' => $onlyNotUpdated];
|
||||
$promotions = $levelReportService->getTeamLevelPromotions($treeCalcBot, $month, $year, $filters);
|
||||
$statistics = $levelReportService->getStatistics($promotions);
|
||||
|
||||
$endTime = microtime(true);
|
||||
$executionTime = round(($endTime - $startTime) * 1000, 2);
|
||||
|
||||
\Log::info("TeamController: Level reports loaded for user {$user->id} in {$executionTime}ms - " . $promotions->count() . " promotions found");
|
||||
|
||||
$availableYears = range(date('Y'), date('Y') - 5);
|
||||
$availableMonths = [
|
||||
1 => __('cal.months.January'),
|
||||
2 => __('cal.months.February'),
|
||||
3 => __('cal.months.March'),
|
||||
4 => __('cal.months.April'),
|
||||
5 => __('cal.months.May'),
|
||||
6 => __('cal.months.June'),
|
||||
7 => __('cal.months.July'),
|
||||
8 => __('cal.months.August'),
|
||||
9 => __('cal.months.September'),
|
||||
10 => __('cal.months.October'),
|
||||
11 => __('cal.months.November'),
|
||||
12 => __('cal.months.December')
|
||||
];
|
||||
|
||||
$data = [
|
||||
'promotions' => $promotions,
|
||||
'statistics' => $statistics,
|
||||
'filters' => [
|
||||
'month' => $month,
|
||||
'year' => $year,
|
||||
'only_not_updated' => $onlyNotUpdated
|
||||
],
|
||||
'availableYears' => $availableYears,
|
||||
'availableMonths' => $availableMonths,
|
||||
'performance' => [
|
||||
'execution_time' => $executionTime,
|
||||
'user_id' => $user->id
|
||||
]
|
||||
];
|
||||
|
||||
return view('user.team.level-reports', $data);
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("TeamController: Error loading level reports: " . $e->getMessage());
|
||||
|
||||
return view('user.team.level-reports', [
|
||||
'error' => 'Fehler beim Laden der Level-Reports: ' . $e->getMessage(),
|
||||
'promotions' => collect([]),
|
||||
'statistics' => ['total_count' => 0, 'level_stats' => [], 'period_stats' => []],
|
||||
'filters' => ['month' => date('m'), 'year' => date('Y'), 'only_not_updated' => false],
|
||||
'availableYears' => range(date('Y'), date('Y') - 5),
|
||||
'availableMonths' => [
|
||||
1 => __('cal.months.January'),
|
||||
2 => __('cal.months.February'),
|
||||
3 => __('cal.months.March'),
|
||||
4 => __('cal.months.April'),
|
||||
5 => __('cal.months.May'),
|
||||
6 => __('cal.months.June'),
|
||||
7 => __('cal.months.July'),
|
||||
8 => __('cal.months.August'),
|
||||
9 => __('cal.months.September'),
|
||||
10 => __('cal.months.October'),
|
||||
11 => __('cal.months.November'),
|
||||
12 => __('cal.months.December')
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CSV Export für Team Level-Reports
|
||||
*/
|
||||
public function levelReportsExport(Request $request)
|
||||
{
|
||||
try {
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$this->setFilterVars();
|
||||
|
||||
$month = Request::get('month') ?: session('team_user_filter_month_prev', intval(date('m') - 1));
|
||||
$year = Request::get('year') ?: session('team_user_filter_year', date('Y'));
|
||||
$onlyNotUpdated = Request::boolean('not_updated', false);
|
||||
$forceLiveCalculation = Request::get('force_live_calculation', false) || Request::get('live', false);
|
||||
|
||||
// Lade Team-Struktur
|
||||
$treeCalcBot = new TreeCalcBotOptimized($month, $year, 'member', $forceLiveCalculation);
|
||||
$treeCalcBot->initStructureUser($user->id, $forceLiveCalculation);
|
||||
|
||||
// Lade Level-Reports
|
||||
$levelReportService = new LevelReportService();
|
||||
$filters = ['only_not_updated' => $onlyNotUpdated];
|
||||
$promotions = $levelReportService->getTeamLevelPromotions($treeCalcBot, $month, $year, $filters);
|
||||
|
||||
if ($promotions->isEmpty()) {
|
||||
return redirect()->back()->with('error', 'Keine Daten für Export gefunden.');
|
||||
}
|
||||
|
||||
// CSV erstellen
|
||||
$filename = 'team_level_promotions_' . date('Y-m-d_H-i-s') . '.csv';
|
||||
$filepath = $levelReportService->exportToCsv($promotions, $filename);
|
||||
|
||||
return response()->download($filepath, $filename)->deleteFileAfterSend(true);
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("TeamController: Error exporting level reports: " . $e->getMessage());
|
||||
return redirect()->back()->with('error', 'Fehler beim Export: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeigt den Marketingplan für User an
|
||||
* Übersichtliche Darstellung aller Karriere-Level mit wichtigen Informationen
|
||||
|
|
@ -553,6 +689,94 @@ class TeamController extends Controller
|
|||
return view('user.team.members', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeigt die Abos der Team-Mitglieder an
|
||||
*/
|
||||
public function showAbos()
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$this->setFilterVars();
|
||||
|
||||
// Nutze TreeCalcBotOptimized um das Team zu bekommen
|
||||
$month = session('team_user_filter_month');
|
||||
$year = session('team_user_filter_year');
|
||||
|
||||
// Lade Team-Struktur
|
||||
$TreeCalcBot = new TreeCalcBotOptimized($month, $year, 'member', false);
|
||||
$TreeCalcBot->initStructureUser($user->id, false);
|
||||
|
||||
// Hole flache Liste aller Team-Mitglieder
|
||||
$teamUsersRaw = $this->getTeamUsersFromStructure($TreeCalcBot);
|
||||
|
||||
// Sammle User-IDs für Abo-Abfrage
|
||||
$teamUserIds = [];
|
||||
foreach ($teamUsersRaw as $teamUser) {
|
||||
if ($teamUser->user_id && $teamUser->user_id != $user->id) {
|
||||
$teamUserIds[] = $teamUser->user_id;
|
||||
}
|
||||
}
|
||||
|
||||
// Hole Abos der Team-Mitglieder
|
||||
$abos = \App\Models\UserAbo::whereIn('user_id', $teamUserIds)
|
||||
->where('is_for', 'me')
|
||||
->with(['user', 'user.account', 'user_abo_items', 'user_abo_items.product'])
|
||||
->orderBy('next_date', 'asc')
|
||||
->get();
|
||||
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
'filter_years' => HTMLHelper::getYearRange(2022),
|
||||
'abos' => $abos,
|
||||
];
|
||||
|
||||
return view('user.team.abos', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeigt die Detail-Ansicht eines Team-Abos an
|
||||
*/
|
||||
public function detailAbo($id)
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$user_abo = \App\Models\UserAbo::findOrFail($id);
|
||||
|
||||
// Prüfe ob das Abo zu einem Team-Mitglied gehört
|
||||
$this->setFilterVars();
|
||||
$month = session('team_user_filter_month');
|
||||
$year = session('team_user_filter_year');
|
||||
|
||||
$TreeCalcBot = new TreeCalcBotOptimized($month, $year, 'member', false);
|
||||
$TreeCalcBot->initStructureUser($user->id, false);
|
||||
|
||||
$teamUsersRaw = $this->getTeamUsersFromStructure($TreeCalcBot);
|
||||
$teamUserIds = [];
|
||||
foreach ($teamUsersRaw as $teamUser) {
|
||||
if ($teamUser->user_id) {
|
||||
$teamUserIds[] = $teamUser->user_id;
|
||||
}
|
||||
}
|
||||
|
||||
// Prüfe Berechtigung
|
||||
if (!in_array($user_abo->user_id, $teamUserIds)) {
|
||||
abort(403, 'Unauthorized action. This subscription does not belong to your team.');
|
||||
}
|
||||
|
||||
// Lade Abo-Details (ähnlich wie AboController)
|
||||
\App\Services\AboOrderCart::initYard($user_abo);
|
||||
$customer_detail = \App\Services\AboOrderCart::getCustomerDetail();
|
||||
\App\Services\AboOrderCart::makeOrderYard($user_abo);
|
||||
|
||||
$data = [
|
||||
'user_abo' => $user_abo,
|
||||
'isAdmin' => false,
|
||||
'customer_detail' => $customer_detail,
|
||||
'view' => 'team',
|
||||
'comp_products' => [],
|
||||
];
|
||||
|
||||
return view('user.team.abo_detail', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialisiert die Team-Suche für den eingeloggten User
|
||||
*/
|
||||
|
|
@ -674,6 +898,9 @@ class TeamController extends Controller
|
|||
if (!session('team_user_filter_month')) {
|
||||
session(['team_user_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if (!session('team_user_filter_month_prev')) {
|
||||
session(['team_user_filter_month_prev' => intval(date('m') - 1)]);
|
||||
}
|
||||
if (!session('team_user_filter_year')) {
|
||||
session(['team_user_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
|
|
@ -696,6 +923,9 @@ class TeamController extends Controller
|
|||
if (Request::get('team_user_filter_month')) {
|
||||
session(['team_user_filter_month' => Request::get('team_user_filter_month')]);
|
||||
}
|
||||
if (Request::get('team_user_filter_month_prev')) {
|
||||
session(['team_user_filter_month_prev' => Request::get('team_user_filter_month_prev')]);
|
||||
}
|
||||
if (Request::get('team_user_filter_year')) {
|
||||
session(['team_user_filter_year' => Request::get('team_user_filter_year')]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Api\KasController;
|
||||
use App\Models\UserShop;
|
||||
use App\Models\UserShopOnSite;
|
||||
|
|
@ -36,14 +37,15 @@ class UserShopController extends Controller
|
|||
} else {
|
||||
$user->shop->contact = __('shop.shop_contact_text');
|
||||
}
|
||||
$user->shop->accessibility =__('shop.shop_accessibility_text');
|
||||
|
||||
$user->shop->accessibility = __('shop.shop_accessibility_text');
|
||||
}
|
||||
if ($user->shop && $user->shop->active == 0) {
|
||||
return redirect(route('user_shop_name_edit'));
|
||||
}
|
||||
$data = [
|
||||
'user' => $user,
|
||||
];
|
||||
return view('user.shop', $data);
|
||||
|
||||
}
|
||||
|
||||
public function translate()
|
||||
|
|
@ -55,7 +57,6 @@ class UserShopController extends Controller
|
|||
|
||||
];
|
||||
return view('user.shop.translate', $data);
|
||||
|
||||
}
|
||||
|
||||
public function translateStore()
|
||||
|
|
@ -66,7 +67,7 @@ class UserShopController extends Controller
|
|||
if (!$user->shop) {
|
||||
abort(404);
|
||||
}
|
||||
foreach($data['trans'] as $lang => $val){
|
||||
foreach ($data['trans'] as $lang => $val) {
|
||||
$this->storeTranslations($user->shop, $lang, $val);
|
||||
}
|
||||
\Session()->flash('alert-save', true);
|
||||
|
|
@ -89,22 +90,22 @@ class UserShopController extends Controller
|
|||
\Session()->flash('alert-save', true);
|
||||
|
||||
return redirect(route('user_shop'));
|
||||
|
||||
}
|
||||
|
||||
private function storeTranslations($user_shop, $lang, $data){
|
||||
private function storeTranslations($user_shop, $lang, $data)
|
||||
{
|
||||
|
||||
if($lang == 'de'){
|
||||
$user_shop->contact = trim(preg_replace('/\s*\n+/',"\n", $data['contact']));
|
||||
$user_shop->accessibility = trim(preg_replace('/\s*\n+/',"\n", $data['accessibility']));
|
||||
$user_shop->about = trim(preg_replace('/\s+/', ' ',$data['about']));
|
||||
if ($lang == 'de') {
|
||||
$user_shop->contact = trim(preg_replace('/\s*\n+/', "\n", $data['contact']));
|
||||
$user_shop->accessibility = trim(preg_replace('/\s*\n+/', "\n", $data['accessibility']));
|
||||
$user_shop->about = trim(preg_replace('/\s+/', ' ', $data['about']));
|
||||
$user_shop->save();
|
||||
return;
|
||||
}
|
||||
$trans = $user_shop->trans;
|
||||
$trans[$lang]['contact'] = trim(preg_replace('/\s*\n+/',"\n", $data['contact']));
|
||||
$trans[$lang]['accessibility'] = trim(preg_replace('/\s*\n+/',"\n", $data['accessibility']));
|
||||
$trans[$lang]['about'] = trim(preg_replace('/\s+/', ' ',$data['about']));
|
||||
$trans[$lang]['contact'] = trim(preg_replace('/\s*\n+/', "\n", $data['contact']));
|
||||
$trans[$lang]['accessibility'] = trim(preg_replace('/\s*\n+/', "\n", $data['accessibility']));
|
||||
$trans[$lang]['about'] = trim(preg_replace('/\s+/', ' ', $data['about']));
|
||||
$user_shop->trans = $trans;
|
||||
$user_shop->save();
|
||||
return;
|
||||
|
|
@ -117,42 +118,41 @@ class UserShopController extends Controller
|
|||
|
||||
$ret = $user->account->street != "" ? $user->account->street : __('shop.your_street_number');
|
||||
$ret .= " • ";
|
||||
$ret.= $user->account->postal_code != "" ? $user->account->postal_code." " : __('shop.your_zip_code');
|
||||
$ret.= $user->account->city != "" ? $user->account->city : __('shop.your_city');
|
||||
$ret.= $sep;
|
||||
$ret .= $user->account->postal_code != "" ? $user->account->postal_code . " " : __('shop.your_zip_code');
|
||||
$ret .= $user->account->city != "" ? $user->account->city : __('shop.your_city');
|
||||
$ret .= $sep;
|
||||
|
||||
$pre = $user->account->pre_phone_id != "" ? $user->account->pre_phone->phone." " : "";
|
||||
$ret.= __('shop.phone').": ".($user->account->phone != "" ? $pre.$user->account->phone : __('shop.your_phone_number'));
|
||||
$ret.= $sep;
|
||||
$pre = $user->account->pre_phone_id != "" ? $user->account->pre_phone->phone . " " : "";
|
||||
$ret .= __('shop.phone') . ": " . ($user->account->phone != "" ? $pre . $user->account->phone : __('shop.your_phone_number'));
|
||||
$ret .= $sep;
|
||||
|
||||
$pre = $user->account->pre_mobil_id != "" ? $user->account->pre_mobil->phone." " : "";
|
||||
$ret.= __('shop.mobil').": ".($user->account->mobil != "" ? $pre.$user->account->mobil : __('shop.your_mobile_number'));
|
||||
$ret.= $sep;
|
||||
$pre = $user->account->pre_mobil_id != "" ? $user->account->pre_mobil->phone . " " : "";
|
||||
$ret .= __('shop.mobil') . ": " . ($user->account->mobil != "" ? $pre . $user->account->mobil : __('shop.your_mobile_number'));
|
||||
$ret .= $sep;
|
||||
|
||||
$ret.= $user->email;
|
||||
$ret .= $user->email;
|
||||
|
||||
return $ret;
|
||||
|
||||
}
|
||||
|
||||
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public function uploadImage(){
|
||||
public function uploadImage()
|
||||
{
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
if(!$user->shop){
|
||||
if (!$user->shop) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
try {
|
||||
$image = \App\Services\Slim::getImages('images')[0];
|
||||
|
||||
if ( isset($image['output']['data']) )
|
||||
{
|
||||
if (isset($image['output']['data'])) {
|
||||
// Base64 of the image
|
||||
$data = $image['output']['data'];
|
||||
$file_ex = array( 'image/jpeg' => 'jpg', 'image/png' => 'png');
|
||||
$file_ex = array('image/jpeg' => 'jpg', 'image/png' => 'png');
|
||||
|
||||
if (!isset($file_ex[$image['output']['type']])) {
|
||||
\Session()->flash('alert-danger', 'File is not jpg or png!');
|
||||
|
|
@ -166,7 +166,7 @@ class UserShopController extends Controller
|
|||
$name = uniqid() . '_' . $name;
|
||||
|
||||
$data = \Storage::disk('public')->put(
|
||||
'images/shop/'.$name,
|
||||
'images/shop/' . $name,
|
||||
$data
|
||||
);
|
||||
|
||||
|
|
@ -184,24 +184,23 @@ class UserShopController extends Controller
|
|||
}
|
||||
\Session()->flash('alert-danger', __('msg.file_empty'));
|
||||
return redirect(route('user_shop'));
|
||||
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
\Session()->flash('alert-danger', "Error: ".$e);
|
||||
} catch (\Exception $e) {
|
||||
\Session()->flash('alert-danger', "Error: " . $e);
|
||||
return redirect(route('user_shop'));
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteImage(){
|
||||
public function deleteImage()
|
||||
{
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
if(!$user->shop){
|
||||
if (!$user->shop) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if($user->shop->filename){
|
||||
$file = 'images/shop/'.$user->shop->filename;
|
||||
if ($user->shop->filename) {
|
||||
$file = 'images/shop/' . $user->shop->filename;
|
||||
\Storage::disk('public')->delete($file);
|
||||
|
||||
$user->shop->filename = null;
|
||||
|
|
@ -213,31 +212,29 @@ class UserShopController extends Controller
|
|||
|
||||
\Session()->flash('alert-success', __('msg.file_deleted'));
|
||||
return redirect(route('user_shop'));
|
||||
|
||||
}
|
||||
\Session()->flash('alert-danger', __('msg.file_not_found'));
|
||||
return redirect(route('user_shop'));
|
||||
|
||||
}
|
||||
|
||||
public function uploadOnSiteImage(){
|
||||
public function uploadOnSiteImage()
|
||||
{
|
||||
|
||||
$user = Auth::user();
|
||||
$user_shop_id = Request::get('user_shop_id');
|
||||
|
||||
if(!$user->shop || $user->shop->id != $user_shop_id){
|
||||
if (!$user->shop || $user->shop->id != $user_shop_id) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
try {
|
||||
$image = \App\Services\Slim::getImages('images')[0];
|
||||
|
||||
if ( isset($image['output']['data']) )
|
||||
{
|
||||
if (isset($image['output']['data'])) {
|
||||
|
||||
// Base64 of the image
|
||||
$data = $image['output']['data'];
|
||||
$file_ex = array( 'image/jpeg' => 'jpg', 'image/png' => 'png');
|
||||
$file_ex = array('image/jpeg' => 'jpg', 'image/png' => 'png');
|
||||
|
||||
if (!isset($file_ex[$image['output']['type']])) {
|
||||
\Session()->flash('alert-danger', 'File is not jpg or png!');
|
||||
|
|
@ -251,7 +248,7 @@ class UserShopController extends Controller
|
|||
$name = uniqid() . '_' . $name;
|
||||
|
||||
$data = \Storage::disk('public')->put(
|
||||
'images/user_shop/'.$user->shop->id.'/'.$name,
|
||||
'images/user_shop/' . $user->shop->id . '/' . $name,
|
||||
$data
|
||||
);
|
||||
|
||||
|
|
@ -269,99 +266,99 @@ class UserShopController extends Controller
|
|||
}
|
||||
\Session()->flash('alert-danger', __('msg.file_empty'));
|
||||
return redirect(route('user_shop'));
|
||||
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
\Session()->flash('alert-danger', "Error: ".$e);
|
||||
} catch (\Exception $e) {
|
||||
\Session()->flash('alert-danger', "Error: " . $e);
|
||||
return redirect(route('user_shop'));
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteOnSiteImage($image_id, $user_shop_id){
|
||||
public function deleteOnSiteImage($image_id, $user_shop_id)
|
||||
{
|
||||
|
||||
$user = Auth::user();
|
||||
if(!$user->shop || $user->shop->id != $user_shop_id){
|
||||
if (!$user->shop || $user->shop->id != $user_shop_id) {
|
||||
abort(404);
|
||||
}
|
||||
$image = UserShopOnSite::findOrFail($image_id);
|
||||
|
||||
if($image->user_shop_id == $user_shop_id){
|
||||
$file = 'images/user_shop/'.$user_shop_id.'/'.$image->filename;
|
||||
if ($image->user_shop_id == $user_shop_id) {
|
||||
$file = 'images/user_shop/' . $user_shop_id . '/' . $image->filename;
|
||||
\Storage::disk('public')->delete($file);
|
||||
|
||||
$image->delete();
|
||||
|
||||
\Session()->flash('alert-success', __('msg.file_deleted'));
|
||||
return redirect(route('user_shop'));
|
||||
|
||||
}
|
||||
\Session()->flash('alert-danger', __('msg.file_not_found'));
|
||||
return redirect(route('user_shop'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function userShopRegisterForm(){
|
||||
public function userShopRegisterForm()
|
||||
{
|
||||
|
||||
if(Request::get('shop_submit') == 'check'){
|
||||
$rules = array(
|
||||
'user_shop_name' => ' required|alpha_dash|unique:user_shops,name|min:4|max:20|full_word_check',
|
||||
);
|
||||
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
|
||||
if(in_array($value, config('profanity.full_word_check'))){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
if (Request::get('shop_submit') == 'check') {
|
||||
$rules = array(
|
||||
'user_shop_name' => ' required|alpha_dash|unique:user_shops,name|min:4|max:20|full_word_check',
|
||||
);
|
||||
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
|
||||
if (in_array($value, config('profanity.full_word_check'))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
\Session()->flash('shop-name-error', 'error');
|
||||
return redirect()->back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
\Session()->flash('shop-name-error', 'check');
|
||||
if(Request::get('user_shop_id')){
|
||||
return back()->withInput(Request::all());
|
||||
}
|
||||
return redirect(route('user_shop'))->withInput(Request::all());
|
||||
}
|
||||
|
||||
if(Request::get('shop_submit') == 'action') {
|
||||
|
||||
$rules = array(
|
||||
'user_shop_name' => ' required|alpha_dash|unique:user_shops,name|min:4|max:20|full_word_check',
|
||||
'user_shop_active' => 'accepted',
|
||||
|
||||
);
|
||||
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
|
||||
if(in_array($value, config('profanity.full_word_check'))){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
if ($validator->fails()) {
|
||||
\Session()->flash('shop-name-error', 'error');
|
||||
return redirect()->back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
\Session()->flash('shop-name-error', 'check');
|
||||
return redirect()->back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
\Session()->flash('shop-name-error', 'check');
|
||||
if (Request::get('user_shop_id')) {
|
||||
return back()->withInput(Request::all());
|
||||
}
|
||||
return redirect(route('user_shop'))->withInput(Request::all());
|
||||
}
|
||||
|
||||
//all is right - save
|
||||
$user = Auth::user();
|
||||
$data = Request::all();
|
||||
$slug = SlugService::createSlug(UserShop::class, 'slug', $data['user_shop_name']);
|
||||
if(isset($data['user_shop_id'])){
|
||||
if (Request::get('shop_submit') == 'action') {
|
||||
|
||||
$rules = array(
|
||||
'user_shop_name' => ' required|alpha_dash|unique:user_shops,name|min:4|max:20|full_word_check',
|
||||
'user_shop_active' => 'accepted',
|
||||
|
||||
);
|
||||
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
|
||||
if (in_array($value, config('profanity.full_word_check'))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
\Session()->flash('shop-name-error', 'error');
|
||||
return redirect()->back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
\Session()->flash('shop-name-error', 'check');
|
||||
|
||||
//all is right - save
|
||||
$user = Auth::user();
|
||||
$data = Request::all();
|
||||
$slug = SlugService::createSlug(UserShop::class, 'slug', $data['user_shop_name']);
|
||||
if (isset($data['user_shop_id'])) {
|
||||
$user_shop = UserShop::find($data['user_shop_id']);
|
||||
if($user_shop->user_id != $user->id){
|
||||
if ($user_shop->user_id != $user->id) {
|
||||
abort(404);
|
||||
}
|
||||
$user_shop->name = $slug;
|
||||
$user_shop->slug = $slug;
|
||||
$user_shop->active = 1;
|
||||
$user_shop->save();
|
||||
}else{
|
||||
$user_shop = UserShop::create([
|
||||
} else {
|
||||
$user_shop = UserShop::create(
|
||||
[
|
||||
'user_id' => $user->id,
|
||||
'name' => $slug,
|
||||
'active' => true,
|
||||
|
|
@ -369,9 +366,9 @@ class UserShopController extends Controller
|
|||
]
|
||||
);
|
||||
}
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('user_shop'));
|
||||
/*$ret = $this->userShopRegisterSubDomain($user_shop->slug);
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('user_shop'));
|
||||
/*$ret = $this->userShopRegisterSubDomain($user_shop->slug);
|
||||
if($ret['success'] === true){
|
||||
\Session()->flash('alert-save', true);
|
||||
}else{
|
||||
|
|
@ -379,12 +376,12 @@ class UserShopController extends Controller
|
|||
\Session()->flash('alert-error', $ret['error']);
|
||||
}
|
||||
return redirect(route('user_shop'));*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function userShopRegisterSubDomain($slug){
|
||||
public function userShopRegisterSubDomain($slug)
|
||||
{
|
||||
|
||||
$kas = new KasController();
|
||||
$domain = 'mivita.care';
|
||||
|
|
@ -392,17 +389,17 @@ class UserShopController extends Controller
|
|||
|
||||
//check if exisist
|
||||
$subdomains = $kas->action('get_subdomains');
|
||||
foreach ($subdomains as $subdomain){
|
||||
if(!isset($subdomain['subdomain_name'])){
|
||||
foreach ($subdomains as $subdomain) {
|
||||
if (!isset($subdomain['subdomain_name'])) {
|
||||
continue;
|
||||
}
|
||||
$sub = str_replace(".".$domain, '', $subdomain['subdomain_name']);
|
||||
if($sub == $slug){
|
||||
return ['success' => false, 'error' => __('shop.error_subdomain_exists')];
|
||||
$sub = str_replace("." . $domain, '', $subdomain['subdomain_name']);
|
||||
if ($sub == $slug) {
|
||||
return ['success' => false, 'error' => __('shop.error_subdomain_exists')];
|
||||
}
|
||||
}
|
||||
//add
|
||||
$full_subdomain_name = $slug.".".$domain;
|
||||
$full_subdomain_name = $slug . "." . $domain;
|
||||
$pra = array(
|
||||
'subdomain_name' => $slug,
|
||||
'domain_name' => $domain,
|
||||
|
|
@ -412,49 +409,51 @@ class UserShopController extends Controller
|
|||
//'redirect_status' => 0
|
||||
);
|
||||
$add_subdomain = $kas->action('add_subdomain', $pra);
|
||||
if($add_subdomain == $full_subdomain_name){
|
||||
if ($add_subdomain == $full_subdomain_name) {
|
||||
return ['success' => true];
|
||||
}
|
||||
return ['success' => false, 'error' => $add_subdomain];
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return string to ajax
|
||||
*/
|
||||
public function checkUserShopName(){
|
||||
public function checkUserShopName()
|
||||
{
|
||||
|
||||
$rules = array(
|
||||
'user_shop_name' => ' required|alpha_dash|unique:user_shops,name|min:4|max:20|full_word_check',
|
||||
);
|
||||
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
|
||||
if(in_array($value, config('profanity.full_word_check'))){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
//$messages = $validator->messages();
|
||||
return Response::json(array(
|
||||
'success' => false,
|
||||
'errors' => $validator->getMessageBag()->toArray()
|
||||
|
||||
));
|
||||
$rules = array(
|
||||
'user_shop_name' => ' required|alpha_dash|unique:user_shops,name|min:4|max:20|full_word_check',
|
||||
);
|
||||
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
|
||||
if (in_array($value, config('profanity.full_word_check'))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
//$messages = $validator->messages();
|
||||
return Response::json(array(
|
||||
'success' => false,
|
||||
'errors' => $validator->getMessageBag()->toArray()
|
||||
|
||||
));
|
||||
}
|
||||
$slug = SlugService::createSlug(UserShop::class, 'slug', Request::get('user_shop_name'));
|
||||
|
||||
return Response::json(array(
|
||||
'success' => true,
|
||||
'preview_user_shop_name' => "https://".$slug.".".config('app.domain').config('app.tld_care'),
|
||||
));
|
||||
return Response::json(array(
|
||||
'success' => true,
|
||||
'preview_user_shop_name' => "https://" . $slug . "." . config('app.domain') . config('app.tld_care'),
|
||||
));
|
||||
}
|
||||
|
||||
public function editName(){
|
||||
public function editName()
|
||||
{
|
||||
$user = Auth::user();
|
||||
$user_shop = $user->shop;
|
||||
if(!$user_shop){
|
||||
if (!$user_shop) {
|
||||
abort(404);
|
||||
}
|
||||
$user_shop_domain = $user_shop->getSubdomain(false);
|
||||
|
|
@ -465,5 +464,4 @@ class UserShopController extends Controller
|
|||
];
|
||||
return view('user.shop_edit_name', $data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue